Skip to content

feat(contracts): validate l2ChainIds in OPContractsManagerMigrator.migrate#20926

Open
stevennevins wants to merge 2 commits into
developfrom
stevennevins/opcm-migrator-duplicate-chainid-check
Open

feat(contracts): validate l2ChainIds in OPContractsManagerMigrator.migrate#20926
stevennevins wants to merge 2 commits into
developfrom
stevennevins/opcm-migrator-duplicate-chainid-check

Conversation

@stevennevins
Copy link
Copy Markdown
Contributor

@stevennevins stevennevins commented May 20, 2026

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 requires chainSystemConfigs to be supplied with non-zero and in ascending order;
The existing per-chain checks are moved into a new _validateChainSystemConfigs helper to keep migrate() 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

…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.
@stevennevins stevennevins requested review from a team and Inphi May 20, 2026 18:57
@codecov
Copy link
Copy Markdown

codecov Bot commented May 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.0%. Comparing base (6e38f8a) to head (d47a178).
⚠️ Report is 4 commits behind head on develop.

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     
Flag Coverage Δ
cannon-go-tests-64 ?
contracts-bedrock-tests 82.0% <100.0%> (-0.4%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...bedrock/src/L1/opcm/OPContractsManagerMigrator.sol 98.7% <100.0%> (+0.1%) ⬆️

... and 56 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@stevennevins stevennevins requested a review from a team as a code owner May 20, 2026 20:08
Copy link
Copy Markdown
Contributor

@maurelian maurelian left a comment

Choose a reason for hiding this comment

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

This LGTM.

@stevennevins
Copy link
Copy Markdown
Contributor Author

/piper

@stevennevins stevennevins added this pull request to the merge queue May 21, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks May 21, 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.

fix: cantina #23 Migrator accepts duplicate chain IDs

3 participants