Skip to content

fix(op-stack): read the dispute game factory from the portal, treat ZK games as super-root, format opGasRefund - #5624

Closed
sbvegan wants to merge 1 commit into
wevm:mainfrom
sbvegan:sb/op-stack-lagoon
Closed

sbvegan wants to merge 1 commit into
wevm:mainfrom
sbvegan:sb/op-stack-lagoon

Conversation

@sbvegan

@sbvegan sbvegan commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

Refs #5623. Fixes the two breaking items there and types the new receipt field. The 0x7D post-execution transaction type is left for a follow-up, since it adds a new transaction type to the OP Stack API.

Changes

1. Read the DisputeGameFactory from the portal (getGames).
getGames used the chain definition's contracts.disputeGameFactory first. It only read OptimismPortal2.disputeGameFactory() when the definition had none.

Before OP Stack Upgrade 22 (Lagoon), OPContractsManagerV2.migrate moves OP Mainnet and Unichain, and their Sepolia chains, onto a new shared factory. After that the portal only accepts games from the shared factory. The old per-chain addresses in optimism, unichain, optimismSepolia and unichainSepolia then point at a factory that gets no new games. So waitToProve never resolves, and proofs built from old games are rejected.

getGames now reads the factory from the portal, cached as before, unless disputeGameFactoryAddress is passed. This covers getGame, getL2Output, getTimeToProve, waitToProve, getWithdrawalStatus, getTimeToNextGame and waitForNextGame. The portal is already read in the same call (respectedGameType), so this works for every chain where getGames already worked.

Trade-off: one extra eth_call per cacheTime window for chains that had a static factory. The alternative is updating the four chain definitions once the migration executes, which still breaks every client pinned to an older viem.

2. Treat ZK_DISPUTE_GAME (game type 10) as a super-root game.
GameTypes.isSuperGame in contracts-bedrock/src/dispute/lib/Types.sol includes ZK_DISPUTE_GAME, and OptimismPortal2 reads rootClaimByChainId for it. OP Mainnet and Unichain plan to make it their respected game type after Lagoon activates. Without this, getGames sets usesSuperRoots: false for type 10 and reads the game's L2 timestamp as a block number.

3. Format the opGasRefund receipt field.
Lagoon receipts gain opGasRefund, a Quantity or null (spec). It is now typed and formatted as bigint | null, and left out when the RPC omits it.

Docs: the disputeGameFactoryAddress default on getGame, getGames, getTimeToNextGame and waitForNextGame now says it comes from the portal.

Testing

  • pnpm check:types passes.
  • New unit tests cover game type 10 and opGasRefund (refund, null, absent). They pass alongside the existing formatter and game-type unit tests.
  • I did not run the anvil-forked getGames and withdrawal action tests locally (no fork RPC configured), so those rely on CI.
  • biome check is clean, and there's a changeset.

🤖 Generated with Claude Code

…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 wevm#5623

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@changeset-bot

changeset-bot Bot commented Nov 20, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 29922ed

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

@sbvegan is attempting to deploy a commit to the Wevm Team on Vercel.

A member of the Team first needs to authorize it.

jxom commented Nov 20, 2026

Copy link
Copy Markdown
Member

Thanks a lot for the clear write-up and the fix, @sbvegan! I verified it against OptimismPortal2 and the superchain-registry, and it's right. Your commit is kept as is in #5625, which adds a regression test for the stale-factory case and fixes the getWithdrawalStatus read-rounds test the new portal read broke. Closing this in favor of #5625.

@jxom jxom closed this Nov 20, 2026
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.

2 participants