feat(contracts): validate l2ChainIds in OPContractsManagerMigrator.migrate#20926
Open
stevennevins wants to merge 2 commits into
Open
feat(contracts): validate l2ChainIds in OPContractsManagerMigrator.migrate#20926stevennevins wants to merge 2 commits into
stevennevins wants to merge 2 commits into
Conversation
…grate Reject zero, duplicate, and unsorted l2ChainId values supplied to OPContractsManagerMigrator.migrate. Without these checks, two migrated portals sharing the post-migration super-root dispute game system could report the same l2ChainId and resolve the same output root, letting a single L2 withdrawal proof finalize through multiple portals.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #20926 +/- ##
==========================================
+ Coverage 76.3% 82.0% +5.7%
==========================================
Files 185 130 -55
Lines 10698 6674 -4024
==========================================
- Hits 8166 5478 -2688
+ Misses 2388 1196 -1192
+ Partials 144 0 -144
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Contributor
Author
|
/piper |
wwared
approved these changes
May 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
OPContractsManagerMigrator.migrate checks that every supplied chain has the same ProxyAdmin owner and the same SuperchainConfig, but it never checks SystemConfig.l2ChainId() or requires the migrated chain IDs to be unique.
That missing precondition is dangerous after the portals share one super-root dispute game system. For super game types, OptimismPortal2.proveWithdrawalTransaction extracts the output root with rootClaimByChainId(systemConfig.l2ChainId()). If two migrated portals report the same chain ID, both portals select the same output root from the same shared game.
Changes
This change adds three new errors (
OPContractsManagerMigrator_ZeroL2ChainId,OPContractsManagerMigrator_DuplicateL2ChainId,OPContractsManagerMigrator_ChainIdsNotAscending) and requireschainSystemConfigsto be supplied with non-zero and in ascending order;The existing per-chain checks are moved into a new
_validateChainSystemConfigshelper to keepmigrate()under the stack-too-deep limit.Tests
Tests now cover zero, duplicate, unsorted, and single-chain-zero cases
All existing migrate tests continue to pass.
fixes #20882