-
Notifications
You must be signed in to change notification settings - Fork 3.9k
feat(contracts): add OPCMV2 batch upgrade invariant test #18954
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
a53f581
feat(contracts): add OPCMV2 batch upgrade invariant test
maurelian dff7553
test(contracts): increase batch test to 15
maurelian 92fa1cd
fix: correct natspec comment
maurelian e6d1d20
test(contracts): skip batch upgrade test in coverage mode
maurelian fec13c4
Add LibString import and enhance batch upgrade error handling
maurelian 7861d06
fix: forge fmt
maurelian fce823a
refactor(test): move batch upgrade test to non-forked test contract
maurelian 6377239
feat: allow Feat* prefix in test validation and rename batch upgrade …
maurelian File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
34 changes: 34 additions & 0 deletions
34
packages/contracts-bedrock/test/L1/opcm/helpers/BatchUpgrader.sol
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| // SPDX-License-Identifier: MIT | ||
| pragma solidity 0.8.15; | ||
|
|
||
| import { IOPContractsManagerV2 } from "interfaces/L1/opcm/IOPContractsManagerV2.sol"; | ||
| import { LibString } from "@solady/utils/LibString.sol"; | ||
|
|
||
| /// @title BatchUpgrader | ||
| /// @notice Helper contract for testing that multiple upgrade operations can be executed | ||
| /// within a single transaction. Used to enforce the OPCMV2 invariant that | ||
| /// approximately 5 upgrade operations should be executable in one transaction. | ||
| contract BatchUpgrader { | ||
| /// @notice The OPContractsManagerV2 instance to use for upgrades. | ||
| IOPContractsManagerV2 public immutable opcm; | ||
|
|
||
| /// @param _opcm The OPContractsManagerV2 contract address. | ||
| constructor(IOPContractsManagerV2 _opcm) { | ||
| opcm = _opcm; | ||
| } | ||
|
|
||
| /// @notice Executes multiple upgrade operations sequentially in a single transaction. | ||
| /// @param _inputs Array of upgrade inputs, one per chain to upgrade. | ||
| function batchUpgrade(IOPContractsManagerV2.UpgradeInput[] memory _inputs) external { | ||
| for (uint256 i = 0; i < _inputs.length; i++) { | ||
| (bool success, bytes memory returnData) = | ||
| address(opcm).delegatecall(abi.encodeCall(IOPContractsManagerV2.upgrade, (_inputs[i]))); | ||
| require( | ||
| success, | ||
| string.concat( | ||
| "BatchUpgrader: upgrade failed for chain ", LibString.toString(i), ": ", string(returnData) | ||
| ) | ||
| ); | ||
| } | ||
| } | ||
| } | ||
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.
Uh oh!
There was an error while loading. Please reload this page.