Skip to content

fix(op-stack): read dispute game factory from portal when missing - #5548

Merged
jxom merged 3 commits into
wevm:mainfrom
gomesalexandre:fix_op_dispute_game_factory_fallback
Nov 16, 2026
Merged

jxom merged 3 commits into
wevm:mainfrom
gomesalexandre:fix_op_dispute_game_factory_fallback

Conversation

@gomesalexandre

Copy link
Copy Markdown
Contributor

Every fault-proof action ends up in getGames, which reads targetChain.contracts.disputeGameFactory[chain.id] with no fallback. getWithdrawalStatus, waitToProve and getTimeToProve also accept a target chain with only l2OutputOracle + portal. So when a chain like that has a portal on v3+, those actions type-check but take the fault-proof path and throw TypeError: Cannot read properties of undefined (reading '1').

This PR reads the factory from the portal (disputeGameFactory(), already in portal2Abi) when neither disputeGameFactoryAddress nor the chain config gives one. getWithdrawalStatus already reads anchorStateRegistry() off the portal the same way. Chains that do configure a factory work as before and make no extra call. The fallback read goes through withCache with the same key shape and 300 ms window as getPortalVersion, because waitForNextGame calls getGame on every poll. Types are unchanged.

#5547 is the data fix for the 10 bundled chains in this state (BOB, Zircuit, Shape, Ancient8, Metal L2 and testnets). This PR covers the same class for custom defineChain configs and for any chain that moves to fault proofs before its definition is updated. It does not fix a factory that is configured but stale, like Superseed's in #5547, since the configured address still wins.

Real calls against publicnode L1 with the bundled chains as they are on main (no factory configured):

                                             main        branch
getGames bob/zircuit/shape/ancient8/metalL2  TypeError   3 games each (limit 3)
getTimeToProve, same 5 chains                TypeError   { interval, seconds }
getWithdrawalStatus bob     0x21cbe21c...    TypeError   waiting-to-finalize
getWithdrawalStatus metalL2 0x214cb594...    TypeError   ready-to-prove
getWithdrawalStatus zircuit 0xe92efebe...    TypeError   waiting-to-prove

These are the same statuses #5547 gets with the factories configured.

The tests add a target chain without disputeGameFactory to getGames.test.ts and getWithdrawalStatus.test.ts, on a mainnet fork at block 26430000. They fail on main with the TypeError and pass here. src/op-stack/** is excluded from the core project, so I ran these files locally with a config that includes it. The only results that differ between main and this branch are the two new tests.

🤖 Generated with Claude Code

gomesalexandre and others added 3 commits November 16, 2026 22:44
getGames read targetChain.contracts.disputeGameFactory[chain.id] with
no fallback. getWithdrawalStatus, waitToProve and getTimeToProve accept
a target chain with only l2OutputOracle + portal, so on a chain whose
portal moved to fault proofs they threw a TypeError. Fall back to
portal.disputeGameFactory() when the chain config has no factory.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
waitForNextGame polls getGame, so cache the fallback read the same way
getPortalVersion caches the portal version.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Use the real L2 block for the timestamp, keep the status tests in order,
and name every action the fix covers in the changeset.

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

vercel Bot commented Nov 16, 2026

Copy link
Copy Markdown

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

A member of the Team first needs to authorize it.

@changeset-bot

changeset-bot Bot commented Nov 16, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f698d65

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

@jxom
jxom merged commit 2970f8c into wevm:main Nov 16, 2026
22 of 33 checks passed
This was referenced Nov 16, 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