forked from ethereum-optimism/optimism
-
Notifications
You must be signed in to change notification settings - Fork 3
WIP: opcmv2 upgrade op chain #752
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
0xiamflux
merged 9 commits into
sc-feat/opcm2-upgrade-op-chain
from
feat/opcm2-upgrade-op-chain
Dec 12, 2025
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
e90cacd
feat: upgrade op chain wip
0xniha 4b4487f
feat: add deployv2 wip
0xniha f2d235c
fix: deployerv2 wip
0xniha ac8d696
refactor: remove additional V2 version of scripts
0xiamflux 2d3a9ab
refactor: adds OPCM v2 support for UpgradeOPChain.s.sol
0xiamflux d707408
refactor: adds OPCM v2 support for UpgradeSuperchainConfig.s.sol
0xiamflux 24ab506
fix: uses correct json key for upgradeInput
0xiamflux ebca1da
fix: uses correct feature flag for OPCM v2 in devfeatures.go
0xiamflux 61ffba6
chore: add json tag to ExtraInstruction
0xiamflux 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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| package embedded | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "math/big" | ||
|
|
||
| "github.com/ethereum-optimism/optimism/op-chain-ops/script" | ||
| "github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/opcm" | ||
| "github.com/ethereum/go-ethereum/common" | ||
| "github.com/lmittmann/w3" | ||
| ) | ||
|
|
||
| type DeployOPChainV2Input struct { | ||
| Opcm common.Address `json:"opcm"` | ||
| FullConfigV2 FullConfigV2 `evm:"-" json:"fullConfig"` | ||
| } | ||
|
|
||
| type FullConfigV2 struct { | ||
| SaltMixer string `json:"saltMixer"` | ||
| SuperchainConfig common.Address `json:"superchainConfig"` | ||
| ProxyAdminOwner common.Address `json:"proxyAdminOwner"` | ||
| SystemConfigOwner common.Address `json:"systemConfigOwner"` | ||
| UnsafeBlockSigner common.Address `json:"unsafeBlockSigner"` | ||
| Batcher common.Address `json:"batcher"` | ||
| StartingAnchorRoot Proposal `json:"startingAnchorRoot"` | ||
| StartingRespectedGameType uint32 `json:"startingRespectedGameType"` | ||
| BasefeeScalar uint32 `json:"basefeeScalar"` | ||
| BlobBasefeeScalar uint32 `json:"blobBasefeeScalar"` | ||
| GasLimit uint64 `json:"gasLimit"` | ||
| L2ChainId *big.Int `json:"l2ChainId"` | ||
| ResourceConfig ResourceConfig `json:"resourceConfig"` | ||
| DisputeGameConfigs []DisputeGameConfig `json:"disputeGameConfigs"` | ||
| } | ||
|
|
||
| type Proposal struct { | ||
| Root [32]byte `json:"root"` | ||
| L2SequenceNumber uint64 `json:"l2SequenceNumber"` | ||
| } | ||
|
|
||
| type ResourceConfig struct { | ||
| MaxResourceLimit uint32 `json:"maxResourceLimit"` | ||
| ElasticityMultiplier uint8 `json:"elasticityMultiplier"` | ||
| BaseFeeMaxChangeDenominator uint8 `json:"baseFeeMaxChangeDenominator"` | ||
| MinimumBaseFee uint32 `json:"minimumBaseFee"` | ||
| SystemTxMaxGas uint32 `json:"systemTxMaxGas"` | ||
| MaximumBaseFee *big.Int `json:"maximumBaseFee"` | ||
| } | ||
|
|
||
| type DeployOPChainV2Output struct { | ||
| ChainContractsV2 ChainContracts `evm:"-" json:"chainContracts"` | ||
| } | ||
|
|
||
| func (d *DeployOPChainV2Output) ChainContracts() ([]byte, error) { | ||
| return chainContractsEncoder.EncodeArgs(&d.ChainContractsV2) | ||
| } | ||
|
|
||
| func (d *DeployOPChainV2Output) SetChainContracts(data []byte) error { | ||
| return chainContractsEncoder.DecodeReturns(data, &d.ChainContractsV2) | ||
| } | ||
|
|
||
| type ChainContracts struct { | ||
| SystemConfig common.Address `json:"systemConfig"` | ||
| ProxyAdmin common.Address `json:"proxyAdmin"` | ||
| AddressManager common.Address `json:"addressManager"` | ||
| L1CrossDomainMessenger common.Address `json:"l1CrossDomainMessenger"` | ||
| L1ERC721Bridge common.Address `json:"l1ERC721Bridge"` | ||
| L1StandardBridge common.Address `json:"l1StandardBridge"` | ||
| OptimismPortal common.Address `json:"optimismPortal"` | ||
| EthLockbox common.Address `json:"ethLockbox"` | ||
| OptimismMintableERC20Factory common.Address `json:"optimismMintableERC20Factory"` | ||
| DisputeGameFactory common.Address `json:"disputeGameFactory"` | ||
| AnchorStateRegistry common.Address `json:"anchorStateRegistry"` | ||
| DelayedWETH common.Address `json:"delayedWETH"` | ||
| } | ||
|
|
||
| var fullConfigEncoder = w3.MustNewFunc( | ||
| "dummy((string saltMixer,address superchainConfig,address proxyAdminOwner,address systemConfigOwner,address unsafeBlockSigner,address batcher,(bytes32 root,uint256 l2SequenceNumber) startingAnchorRoot,uint32 startingRespectedGameType,uint32 basefeeScalar,uint32 blobBasefeeScalar,uint64 gasLimit,uint256 l2ChainId,(uint32 maxResourceLimit,uint8 elasticityMultiplier,uint8 baseFeeMaxChangeDenominator,uint32 minimumBaseFee,uint32 systemTxMaxGas,uint128 maximumBaseFee) resourceConfig,(bool enabled,uint256 initBond,uint32 gameType,bytes gameArgs)[] disputeGameConfigs))", | ||
| "", | ||
| ) | ||
|
|
||
| var chainContractsEncoder = w3.MustNewFunc( | ||
| "dummy()", | ||
| "(address systemConfig,address proxyAdmin,address addressManager,address l1CrossDomainMessenger,address l1ERC721Bridge,address l1StandardBridge,address optimismPortal,address ethLockbox,address optimismMintableERC20Factory,address disputeGameFactory,address anchorStateRegistry,address delayedWETH)", | ||
| ) | ||
|
|
||
| func (d *DeployOPChainV2Input) FullConfig() ([]byte, error) { | ||
| data, err := fullConfigEncoder.EncodeArgs(&d.FullConfigV2) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("failed to encode full config: %w", err) | ||
| } | ||
|
|
||
| // Strip the 4-byte function selector | ||
| return data[4:], nil | ||
| } | ||
|
|
||
| func DeployOPChainV2(host *script.Host, input DeployOPChainV2Input) (*DeployOPChainV2Output, error) { | ||
| output, err := opcm.RunScriptSingle[DeployOPChainV2Input, DeployOPChainV2Output]( | ||
| host, | ||
| input, | ||
| "DeployOPChainV2.s.sol", | ||
| "DeployOPChainV2", | ||
| ) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("failed to deploy OP chain V2: %w", err) | ||
| } | ||
| return &output, nil | ||
| } |
46 changes: 46 additions & 0 deletions
46
op-deployer/pkg/deployer/upgrade/embedded/upgrade_superchain_v2.go
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,46 @@ | ||
| package embedded | ||
|
|
||
| import ( | ||
| "fmt" | ||
|
|
||
| "github.com/ethereum-optimism/optimism/op-chain-ops/script" | ||
| "github.com/ethereum-optimism/optimism/op-deployer/pkg/deployer/opcm" | ||
| "github.com/ethereum/go-ethereum/common" | ||
| "github.com/lmittmann/w3" | ||
| ) | ||
|
|
||
| type UpgradeSuperchainV2Input struct { | ||
| Prank common.Address `json:"prank"` | ||
| Opcm common.Address `json:"opcm"` | ||
| SuperchainConfig common.Address `evm:"-" json:"superchainConfig"` | ||
| SuperchainInstructions []ExtraInstruction `evm:"-" json:"superchainInstructions"` | ||
| } | ||
|
|
||
| type SuperchainUpgradeInputV2 struct { | ||
| SuperchainConfig common.Address | ||
| ExtraInstructions []ExtraInstruction | ||
| } | ||
|
|
||
| var superchainUpgradeInputEncoder = w3.MustNewFunc( | ||
| "dummy((address superchainConfig,(string key,bytes data)[] extraInstructions))", | ||
| "", | ||
| ) | ||
|
|
||
| func (u *UpgradeSuperchainV2Input) SuperchainUpgradeInput() ([]byte, error) { | ||
| input := SuperchainUpgradeInputV2{ | ||
| SuperchainConfig: u.SuperchainConfig, | ||
| ExtraInstructions: u.SuperchainInstructions, | ||
| } | ||
|
|
||
| data, err := superchainUpgradeInputEncoder.EncodeArgs(&input) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("failed to encode superchain upgrade input: %w", err) | ||
| } | ||
|
|
||
| // Strip the 4-byte function selector | ||
| return data[4:], nil | ||
| } | ||
|
|
||
| func UpgradeSuperchainV2(host *script.Host, input UpgradeSuperchainV2Input) error { | ||
| return opcm.RunScriptVoid(host, input, "UpgradeSuperchainV2.s.sol", "UpgradeSuperchain") | ||
| } |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: DevFeatureBitmap overwrite loses combined feature flags in test
Line 210 sets
cfg.DevFeatureBitmaptott.devFeature, but lines 225-227 unconditionally overwrite it with justdeployer.OpcmV2DevFlagwhen that flag is detected. This is currently harmless because theopcm-v2test case only hasOpcmV2DevFlag. However, if a combined test case is added (e.g., combiningOpcmV2DevFlagwithCannonKonaDevFlag), the overwrite would discard the additional flags, causing the test to use incorrect feature configuration. The conditional block appears redundant and potentially harmful.