Skip to content

fix(op-stack): use the withdrawal's L2 timestamp for super-root games - #5302

Merged
jxom merged 4 commits into
mainfrom
claude/op-stack-super-root-l2-timestamp
Oct 26, 2026
Merged

jxom merged 4 commits into
mainfrom
claude/op-stack-super-root-l2-timestamp

Conversation

@jxom

@jxom jxom commented Oct 26, 2026 •

Copy link
Copy Markdown
Member

Supersedes #5296 by @Anirudh-712. Their commit is kept as-is, with follow-up commits on top.

Problem

When the respected dispute game anchors on super roots (OP Mainnet, game type 9), getGames stores the game's L2 timestamp in l2BlockNumber. When l2Timestamp isn't passed, getWithdrawalStatus, getTimeToProve and waitToProve compare those timestamps against receipt.blockNumber. A block number is always smaller than a timestamp, so every game appears to cover the withdrawal. As a result:

  • getWithdrawalStatus returns ready-to-prove too early.
  • getTimeToProve returns seconds: 0.
  • waitToProve returns a game whose L2 state predates the withdrawal.

Change

From #5296:

  • If l2Timestamp isn't passed and the portal is v3+, the actions read respectedGameType().
  • For super-root game types, they use the receipt logs' blockTimestamp. If that is missing, they throw L2TimestampRequiredError.
  • Other game types, the legacy L2OutputOracle path, and callers that pass l2Timestamp are unchanged.
  • Adds docs for l2Timestamp on the three action pages, plus a patch changeset.

Follow-ups:

  • In getWithdrawalStatus, the timestamp lookup now runs inside the settled batch. Before, it could throw before finalizedWithdrawals was checked. A finalized withdrawal on a super-root chain therefore still returns finalized in two cases where it previously threw:
    • the { withdrawalHash, sender, l2BlockNumber } form, which has no receipt;
    • a receipt whose logs have no blockTimestamp.
  • Adds tests for that finalized case and for the getTimeToProve error path.
  • The getTimeToProve super-root test no longer fakes the clock.
  • Docs: l2Timestamp is ordered alphabetically, and the docs say its default only applies to super-root games.

Tests

All tests are fork tests at L1 block 26270300 and OP block 158668700.

Action Input Result here Result on main
getWithdrawalStatus 0xdab8…05f6 waiting-to-prove ready-to-prove
getWithdrawalStatus 0xee9f…3e5d (covered by the latest game) ready-to-prove ready-to-prove
getWithdrawalStatus finalized withdrawal, no l2Timestamp finalized finalized
getWithdrawalStatus logs without blockTimestamp throws L2TimestampRequiredError ready-to-prove
getTimeToProve 0xdab8…05f6 seconds > 0 seconds: 0
getTimeToProve logs without blockTimestamp throws L2TimestampRequiredError seconds: 0
waitToProve logs without blockTimestamp throws L2TimestampRequiredError returns an old game

Checked via RPC: respectedGameType() is 9 at L1 block 26270300, and finalizedWithdrawals(0x1cd5…8e55) is true there.

tsc -p src, a typecheck of the three test files, and biome check are clean. I couldn't run the fork tests for the follow-up commits locally because anvil isn't available, so CI is their first run.

main is merged in, including #5298 (getTimeToFinalize waits for the dispute game); it doesn't overlap with this change.

🤖 Generated with Claude Code

https://claude.ai/code/session_01VQrn3pHwhyRp35QAdpXpB1

Anirudh-712 and others added 2 commits October 25, 2026 18:44
Without l2Timestamp, getWithdrawalStatus, getTimeToProve and waitToProve matched super-root games (L2 timestamps) against the receipt's L2 block number, so every withdrawal looked provable at once. For super-root game types, take the timestamp from the receipt logs' blockTimestamp, or throw L2TimestampRequiredError when it is missing.
…mestamp check

`getWithdrawalStatus` threw `L2TimestampRequiredError` before reading
`finalizedWithdrawals`, so a finalized withdrawal on a super-root chain
failed when no L2 timestamp was available. The timestamp lookup now only
fails the game lookup.

Also resets fake timers in `afterEach` in the `getTimeToProve` tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VQrn3pHwhyRp35QAdpXpB1
@vercel

vercel Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
viem Ready Ready Preview Oct 26, 2026 5:31am UTC

Request Review

@changeset-bot

changeset-bot Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: d39198a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
viem Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-26T05:28:16.602750Z d39198a New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@pkg-pr-new

pkg-pr-new Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/viem@5302

commit: d582caf

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d582caf22b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/op-stack/actions/getTimeToProve.ts Resolved
Comment on lines +180 to +182
functionName: 'respectedGameType',
})
if (!isSuperGameType(gameType)) return receipt.blockNumber

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Re-evaluate the unit while waitToProve polls

When l2Timestamp is omitted, this converts the receipt position to either a block number or timestamp only once before waitForNextGame begins its potentially long poll. If respectedGameType changes between legacy and super-root games while that poll is active, subsequent getGame calls read the new game type but keep comparing against the old unit, so the wait can either return a super-root game that predates the withdrawal or fail to match new legacy games indefinitely. The unit selection needs to follow the game type on each polling lookup rather than being frozen here.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leaving this as is. The failure needs respectedGameType to switch between a block-number and a super-root game type while one waitToProve call is polling. That only happens in a governance upgrade, a rare one-off event. Fixing it would mean reworking waitForNextGame/getGame to re-derive the unit on every poll, which is a larger change than this fix warrants. A caller can also pass l2Timestamp to pin the unit. Happy to follow up separately if maintainers want it.


Generated by Claude Code

- Order `l2Timestamp` after `l2OutputOracleAddress` on the action pages and
  document that its default only applies to super-root games.
- Cover the `L2TimestampRequiredError` path in `getTimeToProve`.
- Drop the faked clock from the `getTimeToProve` super-root test.
- Separate execution from assertions in the new `getWithdrawalStatus` tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VQrn3pHwhyRp35QAdpXpB1
@jxom
jxom merged commit c42c189 into main Oct 26, 2026
33 of 35 checks passed
@jxom
jxom deleted the claude/op-stack-super-root-l2-timestamp branch October 26, 2026 05:26
@github-actions github-actions Bot mentioned this pull request Oct 26, 2026

This branch was successfully deployed

1 active deployment
Preview — d39198a7 Deployed Oct 26, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants