Skip to content

fix(op-stack): read the dispute game factory from the portal for OP Stack Upgrade 22 - #5625

Merged
jxom merged 2 commits into
mainfrom
op-stack-lagoon
Nov 20, 2026
Merged

jxom merged 2 commits into
mainfrom
op-stack-lagoon

Conversation

@jxom

@jxom jxom commented Nov 20, 2026

Copy link
Copy Markdown
Member

Refs #5623. Supersedes #5624 by @sbvegan, whose commit is kept as is; this branch adds tests on top.

Root cause

getGames (and every action built on it: getGame, getL2Output, getTimeToProve, waitToProve, getWithdrawalStatus, getTimeToNextGame, waitForNextGame) used the chain definition's contracts.disputeGameFactory before the portal's. OP Stack Upgrade 22 (Lagoon) runs OptimismPortal2.migrateToSharedDisputeGame on OP Mainnet and Unichain (and OP Sepolia and Unichain Sepolia), which points the portal at a new shared AnchorStateRegistry. OptimismPortal2.disputeGameFactory() returns anchorStateRegistry.disputeGameFactory(), and proveWithdrawalTransaction only accepts games from that factory, so the hardcoded per-chain factories go stale: waitToProve never resolves and proofs built from old-factory games are rejected.

The superchain-registry confirms the scope: OP Mainnet and Unichain (and their Sepolia chains) share an [interop] dependency set; Ink and Soneium get lagoon_time but no shared contracts. Activation: 1796918401 (Sepolia), 1799683201 (mainnet).

Changes

From #5624:

  • getGames reads the factory from the portal (cached for 300s per client and portal) unless disputeGameFactoryAddress is passed. This works before and after the migration, and on every chain.
  • ZK_DISPUTE_GAME (type 10) is a super-root game, matching GameTypes.isSuperGame. Its l2SequenceNumber() is the super root timestamp, and the portal reads rootClaimByChainId for it, so the existing super-root proof path applies unchanged.
  • The opGasRefund receipt field is typed and formatted as bigint | null (SDM spec).

Added here:

  • A getGames regression test where the chain definition holds a different factory (Unichain's) than the portal. It fails on main (game index 17677 vs 21374) and passes here.
  • The getWithdrawalStatus read-rounds test now answers disputeGameFactory; it timed out on fix(op-stack): read the dispute game factory from the portal, treat ZK games as super-root, format opGasRefund #5624 because its fake RPC had no reply for the new read. The snapshot shows the one extra read round on a cache miss.
  • opGasRefund tests folded into one inline snapshot, and the changeset reworded as one past-tense sentence.

Follow-ups (not in this PR)

  • The 0x7D post-exec transaction type is not modeled yet.
  • Interop message expiry and refund actions from the issue.
  • Withdrawals proven against an old-factory game before the migration show ready-to-prove afterwards (the new AnchorStateRegistry does not treat old games as proper), so users re-prove. That is existing behavior, not a change here.

Testing

src/op-stack/** is excluded from the Vitest projects, so I ran these with a temporary config that includes it:

  • gameTypes, formatters (unit), the new getGames test, and the getWithdrawalStatus rounds test pass.
  • Across getGames, getGame, getWithdrawalStatus, getTimeToProve, waitToProve, getL2Output, getTimeToNextGame and formatters, the remaining 19 failures are the same set on main (stale fork blocks and live-RPC snapshot drift).
  • tsc -b for src and test, and Biome on the touched files, pass.

sbvegan and others added 2 commits November 20, 2026 14:40
…me actions

Read the DisputeGameFactory from the portal instead of the chain
definition, treat ZK_DISPUTE_GAME (10) as a super-root game, and format
the opGasRefund receipt field.

Refs #5623

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…chain definition

Adds a getGames regression test where the chain definition holds a
different factory than the portal, updates the getWithdrawalStatus read
rounds for the portal's disputeGameFactory read, folds the opGasRefund
tests into one inline snapshot, and rewords the changeset in past tense.

Refs #5623

Amp-Thread-ID: https://ampcode.com/threads/T-01a1fb1a-603b-73f0-9c51-9607e94ee4af
Co-authored-by: jxom <[email protected]>
@changeset-bot

changeset-bot Bot commented Nov 20, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 6ea69eb

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

@vercel

vercel Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
viem Error Error Nov 20, 2026 11:05pm UTC

Request Review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-20T23:02:31.193196Z 6ea69eb PR opened
ℹ️ 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.

@github-actions

Copy link
Copy Markdown
Contributor

Published [email protected] under the pr-5625 dist-tag, which follows this pull request until it closes.

pnpm add viem@pr-5625
pnpm add [email protected]

This branch had an error being deployed

1 failed deployment
Preview — 6ea69ebe Deployed Nov 20, 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