Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
148ee03
WIP: opcmv2 upgrade op chain (#752)
0xniha Dec 12, 2025
a252244
feat: adds intermediary struct for op-deployer upgrade (#759)
0xiamflux Dec 16, 2025
85b1af9
Merge develop into sc-feat/opcm2-upgrade-op-chain
0xiamflux Dec 16, 2025
800a13e
Merge pull request #761 from defi-wonderland/sync/opcm2
0xiamflux Dec 16, 2025
a481a60
Merge branch 'develop' into sync/opcm2
0xiamflux Dec 17, 2025
5a087eb
chore: pre-pr ready
0xiamflux Dec 17, 2025
a425048
Merge pull request #763 from defi-wonderland/sync/opcm2
0xiamflux Dec 17, 2025
5ffe81c
Merge pull request #764 from defi-wonderland/fix/opcm2-upgradeopchain…
0xiamflux Dec 17, 2025
79e6f66
refactor: remove enshrined v7_0_0 upgrade in op-deployer (#766)
0xiamflux Dec 17, 2025
3e42753
test: use correct game type and pass correct extra instruction to Upg…
0xiamflux Dec 18, 2025
db4b389
feat: initial add-game-type-v2 command
0xiamflux Dec 18, 2025
137d8fb
test: add tests for ShouldAllowV1 flag
0xiamflux Dec 18, 2025
b41c647
refactor: remove shouldAllowV1 flag
0xiamflux Dec 19, 2025
ccb6287
chore: remove unused private key flag from the add game type v2 command
0xiamflux Dec 19, 2025
e12db7f
chore: remove skipping upgrade test
0xiamflux Dec 19, 2025
cfd0286
chore: name changes and comments
0xiamflux Dec 19, 2025
f565e96
chore: update usage description add-game-type-v2
0xiamflux Dec 19, 2025
21a45ba
test: update add-game-type-opcm-v2 tests
0xiamflux Dec 19, 2025
e4da83a
Merge branch 'sc-feat/opcm2-add-gametypev2-command' into feat/opcm2-a…
0xiamflux Dec 19, 2025
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
195 changes: 155 additions & 40 deletions op-deployer/pkg/deployer/integration_test/apply_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,50 +169,66 @@ func TestEndToEndBootstrapApply(t *testing.T) {
func TestEndToEndBootstrapApplyWithUpgrade(t *testing.T) {
op_e2e.InitParallel(t)

lgr := testlog.Logger(t, slog.LevelDebug)
tests := []struct {
name string
devFeature common.Hash
}{
{"default", common.Hash{}},
{"opcm-v2", deployer.OpcmV2DevFlag},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
op_e2e.InitParallel(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)
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)
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)

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: common.Hash{},
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'},
FaultGameMaxGameDepth: standard.DisputeMaxGameDepth,
FaultGameSplitDepth: standard.DisputeSplitDepth,
FaultGameClockExtension: standard.DisputeClockExtension,
FaultGameMaxClockDuration: standard.DisputeMaxClockDuration,
}
if deployer.IsDevFeatureEnabled(tt.devFeature, deployer.OpcmV2DevFlag) {
cfg.DevFeatureBitmap = deployer.OpcmV2DevFlag
}

runEndToEndBootstrapAndApplyUpgradeTest(t, afactsFS, cfg)
})
}
runEndToEndBootstrapAndApplyUpgradeTest(t, afactsFS, cfg)
}

func TestEndToEndApply(t *testing.T) {
Expand Down Expand Up @@ -790,7 +806,7 @@ func TestIntentConfiguration(t *testing.T) {
func runEndToEndBootstrapAndApplyUpgradeTest(t *testing.T, afactsFS foundry.StatDirFs, implementationsConfig bootstrap.ImplementationsConfig) {
lgr := implementationsConfig.Logger

ctx, cancel := context.WithTimeout(context.Background(), 90*time.Second)
ctx, cancel := context.WithTimeout(context.Background(), 180*time.Second)
defer cancel()

superchainProxyAdminOwner := implementationsConfig.L1ProxyAdminOwner
Expand Down Expand Up @@ -845,10 +861,14 @@ func runEndToEndBootstrapAndApplyUpgradeTest(t *testing.T, afactsFS foundry.Stat

// Then run the OPCM upgrade
t.Run("upgrade opcm", func(t *testing.T) {
if deployer.IsDevFeatureEnabled(implementationsConfig.DevFeatureBitmap, deployer.OpcmV2DevFlag) {
t.Skip("Skipping OPCM upgrade for OPCM V2")
return
}
upgradeConfig := embedded.UpgradeOPChainInput{
Prank: superchainProxyAdminOwner,
Opcm: impls.Opcm,
EncodedChainConfigs: []embedded.OPChainConfig{
ChainConfigs: []embedded.OPChainConfig{
{
SystemConfigProxy: common.HexToAddress("034edD2A225f7f429A63E0f1D2084B9E0A93b538"),
CannonPrestate: common.Hash{'C', 'A', 'N', 'N', 'O', 'N'},
Expand All @@ -862,6 +882,101 @@ func runEndToEndBootstrapAndApplyUpgradeTest(t *testing.T, afactsFS foundry.Stat
err = embedded.DefaultUpgrader.Upgrade(host, upgradeConfigBytes)
require.NoError(t, err, "OPCM upgrade should succeed")
})
t.Run("upgrade opcm v2", func(t *testing.T) {
if !deployer.IsDevFeatureEnabled(implementationsConfig.DevFeatureBitmap, deployer.OpcmV2DevFlag) {
t.Skip("Skipping OPCM V2 upgrade for non-OPCM V2 dev feature")
return
}
require.NotEqual(t, common.Address{}, impls.OpcmV2, "OpcmV2 address should not be zero")
t.Logf("Using OpcmV2 at address: %s", impls.OpcmV2.Hex())
t.Logf("Using OpcmUtils at address: %s", impls.OpcmUtils.Hex())
t.Logf("Using OpcmContainer at address: %s", impls.OpcmContainer.Hex())

// Verify OPCM V2 has code deployed
opcmCode, err := versionClient.CodeAt(ctx, impls.OpcmV2, nil)
require.NoError(t, err)
require.NotEmpty(t, opcmCode, "OPCM V2 should have code deployed")
t.Logf("OPCM V2 code size: %d bytes", len(opcmCode))

// Verify OpcmUtils has code deployed
utilsCode, err := versionClient.CodeAt(ctx, impls.OpcmUtils, nil)
require.NoError(t, err)
require.NotEmpty(t, utilsCode, "OpcmUtils should have code deployed")
t.Logf("OpcmUtils code size: %d bytes", len(utilsCode))

// Verify OpcmContainer has code deployed
containerCode, err := versionClient.CodeAt(ctx, impls.OpcmContainer, nil)
require.NoError(t, err)
require.NotEmpty(t, containerCode, "OpcmContainer should have code deployed")
t.Logf("OpcmContainer code size: %d bytes", len(containerCode))

// First, upgrade the superchain with V2
t.Run("upgrade superchain v2", func(t *testing.T) {
superchainUpgradeConfig := embedded.UpgradeSuperchainConfigInput{
Prank: superchainProxyAdminOwner,
Opcm: impls.OpcmV2,
SuperchainConfig: implementationsConfig.SuperchainConfigProxy,
ExtraInstructions: []embedded.ExtraInstruction{
{
Key: "PermittedProxyDeployment",
Data: []byte("DelayedWETH"),
},
},
}
err := embedded.UpgradeSuperchainConfig(host, superchainUpgradeConfig)
if err != nil {
t.Logf("Superchain upgrade may have failed (could already be upgraded): %v", err)
} else {
t.Log("Superchain V2 upgrade succeeded")
}
})

// Then test upgrade on the V2-deployed chain
t.Run("upgrade chain v2", func(t *testing.T) {
upgradeConfig := embedded.UpgradeOPChainInput{
Prank: superchainProxyAdminOwner,
Opcm: impls.OpcmV2,
UpgradeInputV2: &embedded.UpgradeInputV2{
SystemConfig: common.HexToAddress("034edD2A225f7f429A63E0f1D2084B9E0A93b538"),
DisputeGameConfigs: []embedded.DisputeGameConfig{
{
Enabled: true,
InitBond: big.NewInt(1000000000000000000),
GameType: embedded.GameTypeCannon,
GameArgs: []byte{},
},
{
Enabled: true,
InitBond: big.NewInt(1000000000000000000),
GameType: embedded.GameTypePermissionedCannon,
GameArgs: []byte{},
},
{
Enabled: false,
InitBond: big.NewInt(0),
GameType: embedded.GameTypeCannonKona,
GameArgs: []byte{},
},
},
ExtraInstructions: []embedded.ExtraInstruction{
{
Key: "PermittedProxyDeployment",
Data: []byte("DelayedWETH"),
},
{
Key: "overrides.cfg.useCustomGasToken",
Data: make([]byte, 32),
},
},
},
}

upgradeConfigBytes, err := json.Marshal(upgradeConfig)
require.NoError(t, err, "UpgradeOPChainV2Input should marshal to JSON")
err = embedded.DefaultUpgrader.Upgrade(host, upgradeConfigBytes)
require.NoError(t, err, "OPCM V2 chain upgrade should succeed")
})
})
})
}

Expand Down
Loading