Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion op-chain-ops/interopgen/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ func MigrateInterop(
l2Deployment := l2Deployments[l2ChainID]
chainConfigs[i] = manage.OPChainConfig{
SystemConfigProxy: l2Deployment.SystemConfigProxy,
AbsolutePrestate: l2Cfgs[l2ChainID].DisputeAbsolutePrestate,
CannonPrestate: l2Cfgs[l2ChainID].DisputeAbsolutePrestate,
}
}

Expand Down
1 change: 1 addition & 0 deletions op-deployer/pkg/deployer/devfeatures.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func IsDevFeatureEnabled(bitmap, flag common.Hash) bool {
return featuresIsNonZero && bitmapContainsFeatures
}

// EnableDevFeature enables a specific development feature in a feature bitmap
func EnableDevFeature(bitmap, flag common.Hash) common.Hash {
var result common.Hash
for i := 0; i < 32; i++ {
Expand Down
5 changes: 5 additions & 0 deletions op-deployer/pkg/deployer/devfeatures_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ func TestIsDevFeatureEnabled(t *testing.T) {
})
}

func TestEnableDevFeature(t *testing.T) {
result := EnableDevFeature(EMPTY_FEATURES, FEATURE_A)
require.Equal(t, FEATURE_A, result)
}

func or(values ...[32]byte) [32]byte {
var out [32]byte
for i := 0; i < 32; i++ {
Expand Down
145 changes: 62 additions & 83 deletions op-deployer/pkg/deployer/integration_test/apply_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,93 +156,67 @@ func TestEndToEndBootstrapApply(t *testing.T) {
// 3. call opcm.upgradeSuperchainConfig on the opcm deployed in [2] (prerequisite for opcm.upgrade)
// 4. call opcm.upgrade on the opcm deployed in [2]
func TestEndToEndBootstrapApplyWithUpgrade(t *testing.T) {
t.Run("main upgrade", func(t *testing.T) {
lgr := testlog.Logger(t, slog.LevelDebug)

forkedL1, stopL1, err := devnet.NewForkedSepolia(lgr)
require.NoError(t, err)
pkHex, _, _ := shared.DefaultPrivkey(t)
t.Cleanup(func() {
require.NoError(t, stopL1())
})
loc, afactsFS := testutil.LocalArtifacts(t)
testCacheDir := testutils.IsolatedTestDirWithAutoCleanup(t)

superchain, err := standard.SuperchainFor(11155111)
require.NoError(t, err)

superchainProxyAdmin, err := standard.SuperchainProxyAdminAddrFor(11155111)
require.NoError(t, err)

superchainProxyAdminOwner, err := standard.L1ProxyAdminOwner(11155111)
require.NoError(t, err)

runEndToEndBootstrapAndApplyUpgradeTest(t, afactsFS, bootstrap.ImplementationsConfig{
L1RPCUrl: forkedL1.RPCUrl(),
PrivateKey: pkHex,
ArtifactsLocator: loc,
MIPSVersion: int(standard.MIPSVersion),
WithdrawalDelaySeconds: standard.WithdrawalDelaySeconds,
MinProposalSizeBytes: standard.MinProposalSizeBytes,
ChallengePeriodSeconds: standard.ChallengePeriodSeconds,
ProofMaturityDelaySeconds: standard.ProofMaturityDelaySeconds,
DisputeGameFinalityDelaySeconds: standard.DisputeGameFinalityDelaySeconds,
DevFeatureBitmap: common.Hash{},
SuperchainConfigProxy: superchain.SuperchainConfigAddr,
ProtocolVersionsProxy: superchain.ProtocolVersionsAddr,
L1ProxyAdminOwner: superchainProxyAdminOwner,
SuperchainProxyAdmin: superchainProxyAdmin,
CacheDir: testCacheDir,
Logger: lgr,
Challenger: common.Address{'C'},
})
})

t.Run("upgrade with DeployV2DisputeGamesDevFlag", func(t *testing.T) {
lgr := testlog.Logger(t, slog.LevelDebug)
op_e2e.InitParallel(t)

forkedL1, stopL1, err := devnet.NewForkedSepolia(lgr)
require.NoError(t, err)
pkHex, _, _ := shared.DefaultPrivkey(t)
t.Cleanup(func() {
require.NoError(t, stopL1())
})
loc, afactsFS := testutil.LocalArtifacts(t)
testCacheDir := testutils.IsolatedTestDirWithAutoCleanup(t)
tests := []struct {
name string
devFeature common.Hash
}{
{"default", common.Hash{}},
{"deploy-v2-disputegames", deployer.DeployV2DisputeGamesDevFlag},
{"cannon-kona", deployer.EnableDevFeature(deployer.DeployV2DisputeGamesDevFlag, deployer.CannonKonaDevFlag)},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
op_e2e.InitParallel(t)
lgr := testlog.Logger(t, slog.LevelDebug)

superchain, err := standard.SuperchainFor(11155111)
require.NoError(t, err)
forkedL1, stopL1, err := devnet.NewForkedSepolia(lgr)
require.NoError(t, err)
pkHex, _, _ := shared.DefaultPrivkey(t)
t.Cleanup(func() {
require.NoError(t, stopL1())
})
loc, afactsFS := testutil.LocalArtifacts(t)
testCacheDir := testutils.IsolatedTestDirWithAutoCleanup(t)

superchain, err := standard.SuperchainFor(11155111)
require.NoError(t, err)

superchainProxyAdmin, err := standard.SuperchainProxyAdminAddrFor(11155111)
require.NoError(t, err)
superchainProxyAdmin, err := standard.SuperchainProxyAdminAddrFor(11155111)
require.NoError(t, err)

superchainProxyAdminOwner, err := standard.L1ProxyAdminOwner(11155111)
require.NoError(t, err)
superchainProxyAdminOwner, err := standard.L1ProxyAdminOwner(11155111)
require.NoError(t, err)

runEndToEndBootstrapAndApplyUpgradeTest(t, afactsFS, bootstrap.ImplementationsConfig{
L1RPCUrl: forkedL1.RPCUrl(),
PrivateKey: pkHex,
ArtifactsLocator: loc,
MIPSVersion: int(standard.MIPSVersion),
WithdrawalDelaySeconds: standard.WithdrawalDelaySeconds,
MinProposalSizeBytes: standard.MinProposalSizeBytes,
ChallengePeriodSeconds: standard.ChallengePeriodSeconds,
ProofMaturityDelaySeconds: standard.ProofMaturityDelaySeconds,
DisputeGameFinalityDelaySeconds: standard.DisputeGameFinalityDelaySeconds,
DevFeatureBitmap: deployer.DeployV2DisputeGamesDevFlag,
SuperchainConfigProxy: superchain.SuperchainConfigAddr,
ProtocolVersionsProxy: superchain.ProtocolVersionsAddr,
L1ProxyAdminOwner: superchainProxyAdminOwner,
SuperchainProxyAdmin: superchainProxyAdmin,
CacheDir: testCacheDir,
Logger: lgr,
Challenger: common.Address{'C'},
FaultGameMaxGameDepth: standard.DisputeMaxGameDepth,
FaultGameSplitDepth: standard.DisputeSplitDepth,
FaultGameClockExtension: standard.DisputeClockExtension,
FaultGameMaxClockDuration: standard.DisputeMaxClockDuration,
cfg := bootstrap.ImplementationsConfig{
L1RPCUrl: forkedL1.RPCUrl(),
PrivateKey: pkHex,
ArtifactsLocator: loc,
MIPSVersion: int(standard.MIPSVersion),
WithdrawalDelaySeconds: standard.WithdrawalDelaySeconds,
MinProposalSizeBytes: standard.MinProposalSizeBytes,
ChallengePeriodSeconds: standard.ChallengePeriodSeconds,
ProofMaturityDelaySeconds: standard.ProofMaturityDelaySeconds,
DisputeGameFinalityDelaySeconds: standard.DisputeGameFinalityDelaySeconds,
DevFeatureBitmap: tt.devFeature,
SuperchainConfigProxy: superchain.SuperchainConfigAddr,
ProtocolVersionsProxy: superchain.ProtocolVersionsAddr,
L1ProxyAdminOwner: superchainProxyAdminOwner,
SuperchainProxyAdmin: superchainProxyAdmin,
CacheDir: testCacheDir,
Logger: lgr,
Challenger: common.Address{'C'},
}
if deployer.IsDevFeatureEnabled(tt.devFeature, deployer.DeployV2DisputeGamesDevFlag) {
cfg.FaultGameMaxGameDepth = standard.DisputeMaxGameDepth
cfg.FaultGameSplitDepth = standard.DisputeSplitDepth
cfg.FaultGameClockExtension = standard.DisputeClockExtension
cfg.FaultGameMaxClockDuration = standard.DisputeMaxClockDuration
}
runEndToEndBootstrapAndApplyUpgradeTest(t, afactsFS, cfg)
})
})
}
}

func TestEndToEndApply(t *testing.T) {
Expand Down Expand Up @@ -755,14 +729,19 @@ func runEndToEndBootstrapAndApplyUpgradeTest(t *testing.T, afactsFS foundry.Stat
})

// Then run the OPCM upgrade
var cannonKonaPrestate common.Hash
if deployer.IsDevFeatureEnabled(implementationsConfig.DevFeatureBitmap, deployer.CannonKonaDevFlag) {
cannonKonaPrestate = common.Hash{'K', 'O', 'N', 'A'}
}
t.Run("upgrade opcm", func(t *testing.T) {
upgradeConfig := embedded.UpgradeOPChainInput{
Prank: superchainProxyAdminOwner,
Opcm: impls.Opcm,
EncodedChainConfigs: []embedded.OPChainConfig{
{
SystemConfigProxy: common.HexToAddress("034edD2A225f7f429A63E0f1D2084B9E0A93b538"),
AbsolutePrestate: common.Hash{'A', 'P'},
SystemConfigProxy: common.HexToAddress("034edD2A225f7f429A63E0f1D2084B9E0A93b538"),
CannonPrestate: common.Hash{'C', 'A', 'N', 'N', 'O', 'N'},
CannonKonaPrestate: cannonKonaPrestate,
},
},
}
Expand Down
9 changes: 5 additions & 4 deletions op-deployer/pkg/deployer/manage/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ func (u *InteropMigrationInput) OpChainConfigs() ([]byte, error) {
}

type OPChainConfig struct {
SystemConfigProxy common.Address `json:"systemConfigProxy"`
AbsolutePrestate common.Hash `json:"absolutePrestate"`
SystemConfigProxy common.Address `json:"systemConfigProxy"`
CannonPrestate common.Hash `json:"cannonPrestate"`
CannonKonaPrestate common.Hash `json:"cannonKonaPrestate"`
}

type InteropMigrationOutput struct {
Expand All @@ -65,7 +66,7 @@ func (output *InteropMigrationOutput) CheckOutput(input common.Address) error {
return nil
}

var opChainConfigEncoder = w3.MustNewFunc("dummy((address systemConfigProxy,bytes32 absolutePrestate)[])", "")
var opChainConfigEncoder = w3.MustNewFunc("dummy((address systemConfigProxy, bytes32 cannonPrestate, bytes32 cannonKonaPrestate)[])", "")

type InteropMigration struct {
Run func(input common.Address)
Expand Down Expand Up @@ -111,7 +112,7 @@ func MigrateCLI(cliCtx *cli.Context) error {
EncodedChainConfigs: []OPChainConfig{
{
SystemConfigProxy: common.HexToAddress(cliCtx.String(SystemConfigProxyFlag.Name)),
AbsolutePrestate: common.HexToHash(cliCtx.String(DisputeAbsolutePrestateFlag.Name)),
CannonPrestate: common.HexToHash(cliCtx.String(DisputeAbsolutePrestateFlag.Name)),
},
},
}
Expand Down
2 changes: 1 addition & 1 deletion op-deployer/pkg/deployer/manage/migrate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func TestInteropMigration(t *testing.T) {
EncodedChainConfigs: []OPChainConfig{
{
SystemConfigProxy: common.HexToAddress("0x034edD2A225f7f429A63E0f1D2084B9E0A93b538"),
AbsolutePrestate: common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000abc"),
CannonPrestate: common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000abc"),
},
},
}
Expand Down
9 changes: 5 additions & 4 deletions op-deployer/pkg/deployer/upgrade/embedded/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ type UpgradeOPChainInput struct {
}

type OPChainConfig struct {
SystemConfigProxy common.Address `json:"systemConfigProxy"`
AbsolutePrestate common.Hash `json:"absolutePrestate"`
SystemConfigProxy common.Address `json:"systemConfigProxy"`
CannonPrestate common.Hash `json:"cannonPrestate"`
CannonKonaPrestate common.Hash `json:"cannonKonaPrestate"`
}

var opChainConfigEncoder = w3.MustNewFunc("dummy((address systemConfigProxy,bytes32 absolutePrestate)[])", "")
var opChainConfigEncoder = w3.MustNewFunc("dummy((address systemConfigProxy,bytes32 cannonPrestate,bytes32 cannonKonaPrestate)[])", "")

func (u *UpgradeOPChainInput) OpChainConfigs() ([]byte, error) {
data, err := opChainConfigEncoder.EncodeArgs(u.EncodedChainConfigs)
Expand All @@ -37,7 +38,7 @@ type UpgradeOPChain struct {
}

func Upgrade(host *script.Host, input UpgradeOPChainInput) error {
return opcm.RunScriptVoid[UpgradeOPChainInput](host, input, "UpgradeOPChain.s.sol", "UpgradeOPChain")
return opcm.RunScriptVoid(host, input, "UpgradeOPChain.s.sol", "UpgradeOPChain")
}

type Upgrader struct{}
Expand Down
2 changes: 1 addition & 1 deletion op-devstack/sysgo/superroot.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func WithSuperRoots(l1ChainID eth.ChainID, l1ELID stack.L1ELNodeID, l2CLID stack
l2ChainIDs = append(l2ChainIDs, l2ChainID)
opChainConfigs = append(opChainConfigs, bindings.OPContractsManagerOpChainConfig{
SystemConfigProxy: l2Deployment.SystemConfigProxyAddr(),
AbsolutePrestate: absolutePrestate,
CannonPrestate: absolutePrestate,
})
}

Expand Down
204 changes: 123 additions & 81 deletions op-e2e/bindings/opcontractsmanager.go

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,8 @@ interface IOPContractsManager {
/// @notice The input required to identify a chain for upgrading.
struct OpChainConfig {
ISystemConfig systemConfigProxy;
Claim absolutePrestate;
Claim cannonPrestate;
Claim cannonKonaPrestate;
}

/// @notice The input required to identify a chain for updating prestates
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { stdJson } from "forge-std/StdJson.sol";
/// directory located at foundry root.
/// Config example:
/// {
/// "absolutePrestate": "0x1234567890abcdef1234567890abcdef12345678",
/// "cannonPrestate": "0x1234567890abcdef1234567890abcdef12345678",
/// "usePermissionlessGame": true,
/// "startingAnchorRoot": {
/// "root": "0xabcdefabcdefabcdefabcdefabcdefabcdefabcd",
Expand All @@ -44,7 +44,7 @@ import { stdJson } from "forge-std/StdJson.sol";
/// ]
/// }
contract GenerateOPCMMigrateCalldata is Script {
bytes32 absolutePrestate;
bytes32 cannonPrestate;
bool usePermissionlessGame;
Proposal startingAnchorRoot;
address proposer;
Expand All @@ -71,8 +71,8 @@ contract GenerateOPCMMigrateCalldata is Script {
require(false, "GenerateOPCMMigrateCalldata: Failed to read config file");
}

absolutePrestate = stdJson.readBytes32(json, "$.absolutePrestate");
require(absolutePrestate != bytes32(0), "GenerateOPCMMigrateCalldata: absolutePrestate cannot be 0");
cannonPrestate = stdJson.readBytes32(json, "$.cannonPrestate");
require(cannonPrestate != bytes32(0), "GenerateOPCMMigrateCalldata: cannonPrestate cannot be 0");

usePermissionlessGame = stdJson.readBool(json, "$.usePermissionlessGame");
startingAnchorRoot = Proposal({
Expand Down Expand Up @@ -120,7 +120,9 @@ contract GenerateOPCMMigrateCalldata is Script {
for (uint256 i = 0; i < j.length; i++) {
opChainConfigs[i] = IOPContractsManager.OpChainConfig({
systemConfigProxy: ISystemConfig(j[i].systemConfigProxy),
absolutePrestate: Claim.wrap(absolutePrestate)
cannonPrestate: Claim.wrap(cannonPrestate),
// TODO(#17743): cannon-kona for opcm.migrate
cannonKonaPrestate: Claim.wrap(bytes32(0))
});
require(
opChainConfigs[i].systemConfigProxy != ISystemConfig(address(0)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,12 @@
},
{
"internalType": "Claim",
"name": "absolutePrestate",
"name": "cannonPrestate",
"type": "bytes32"
},
{
"internalType": "Claim",
"name": "cannonKonaPrestate",
"type": "bytes32"
}
],
Expand Down Expand Up @@ -772,7 +777,12 @@
},
{
"internalType": "Claim",
"name": "absolutePrestate",
"name": "cannonPrestate",
"type": "bytes32"
},
{
"internalType": "Claim",
"name": "cannonKonaPrestate",
"type": "bytes32"
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,12 @@
},
{
"internalType": "Claim",
"name": "absolutePrestate",
"name": "cannonPrestate",
"type": "bytes32"
},
{
"internalType": "Claim",
"name": "cannonKonaPrestate",
"type": "bytes32"
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,12 @@
},
{
"internalType": "Claim",
"name": "absolutePrestate",
"name": "cannonPrestate",
"type": "bytes32"
},
{
"internalType": "Claim",
"name": "cannonKonaPrestate",
"type": "bytes32"
}
],
Expand Down
4 changes: 2 additions & 2 deletions packages/contracts-bedrock/snapshots/semver-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
"sourceCodeHash": "0xfca613b5d055ffc4c3cbccb0773ddb9030abedc1aa6508c9e2e7727cc0cd617b"
},
"src/L1/OPContractsManager.sol:OPContractsManager": {
"initCodeHash": "0xe264ff78622d5baea636012c17562a4f105182626c3a3841cc65912cb20dff9f",
"sourceCodeHash": "0x7e4a03b442d7b9bcd43cedabc15f98740345fb3d3224cbba3b4eedc6f2fcc65d"
"initCodeHash": "0x659729d1df8a1d04fa09f8aacbd83d63511af4b41ca92f334b324dc97833839b",
"sourceCodeHash": "0x47d94eda9ea1a238d770f9a51ea3648ccd279f5b567d50844d62dddb1b910a1c"
},
"src/L1/OPContractsManagerStandardValidator.sol:OPContractsManagerStandardValidator": {
"initCodeHash": "0x0c8b15453d0f0bc5d9af07f104505e0bbb2b358f0df418289822fb73a8652b30",
Expand Down
Loading