Skip to content

Commit

Permalink
op-deployer: Test mainnet deployment (#12958)
Browse files Browse the repository at this point in the history
Adds a unit test for mainnet deployments at version 1.6.0.
  • Loading branch information
mslipper authored Nov 19, 2024
1 parent 50e1623 commit cd2df97
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 17 deletions.
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -867,6 +867,7 @@ jobs:
export ENABLE_ANVIL=true
export SEPOLIA_RPC_URL="https://ci-sepolia-l1-archive.optimism.io"
export MAINNET_RPC_URL="https://ci-mainnet-l1-archive.optimism.io"
gotestsum --format=testname \
--junitfile=./tmp/test-results/results.xml \
Expand Down
46 changes: 29 additions & 17 deletions op-deployer/pkg/deployer/integration_test/apply_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ network_params:
genesis_delay: 0
`

const defaultL1ChainID uint64 = 77799777

type deployerKey struct{}

func (d *deployerKey) HDPath() string {
Expand Down Expand Up @@ -99,7 +101,7 @@ func TestEndToEndApply(t *testing.T) {
require.NoError(t, err)

depKey := new(deployerKey)
l1ChainID := big.NewInt(77799777)
l1ChainID := new(big.Int).SetUint64(defaultL1ChainID)
dk, err := devkeys.NewMnemonicDevKeys(devkeys.TestMnemonic)
require.NoError(t, err)
pk, err := dk.Secret(depKey)
Expand Down Expand Up @@ -151,9 +153,19 @@ func TestEndToEndApply(t *testing.T) {
}

func TestApplyExistingOPCM(t *testing.T) {
t.Run("mainnet", func(t *testing.T) {
testApplyExistingOPCM(t, 1, os.Getenv("MAINNET_RPC_URL"), standard.L1VersionsMainnet)
})
t.Run("sepolia", func(t *testing.T) {
testApplyExistingOPCM(t, 11155111, os.Getenv("SEPOLIA_RPC_URL"), standard.L1VersionsSepolia)
})
}

func testApplyExistingOPCM(t *testing.T, l1ChainID uint64, forkRPCUrl string, versions standard.L1Versions) {
op_e2e.InitParallel(t)

anvil.Test(t)

forkRPCUrl := os.Getenv("SEPOLIA_RPC_URL")
if forkRPCUrl == "" {
t.Skip("no fork RPC URL provided")
}
Expand All @@ -177,20 +189,20 @@ func TestApplyExistingOPCM(t *testing.T) {
l1Client, err := ethclient.Dial(runner.RPCUrl())
require.NoError(t, err)

l1ChainID := big.NewInt(11155111)
l1ChainIDBig := new(big.Int).SetUint64(l1ChainID)
dk, err := devkeys.NewMnemonicDevKeys(devkeys.TestMnemonic)
require.NoError(t, err)
// index 0 from Anvil's test set
pk, err := crypto.HexToECDSA("ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80")
require.NoError(t, err)

l2ChainID := uint256.NewInt(1)
l2ChainID := uint256.NewInt(777)

// Hardcode the below tags to ensure the test is validating the correct
// version even if the underlying tag changes
intent, st := newIntent(
t,
l1ChainID,
l1ChainIDBig,
dk,
l2ChainID,
artifacts.MustNewLocatorFromTag("op-contracts/v1.6.0"),
Expand All @@ -214,7 +226,7 @@ func TestApplyExistingOPCM(t *testing.T) {

validateOPChainDeployment(t, ethClientCodeGetter(ctx, l1Client), st, intent)

releases := standard.L1VersionsSepolia.Releases["op-contracts/v1.6.0"]
releases := versions.Releases["op-contracts/v1.6.0"]

implTests := []struct {
name string
Expand Down Expand Up @@ -287,7 +299,7 @@ func TestApplyExistingOPCM(t *testing.T) {

require.EqualValues(t, expectedSemversL2, semvers)

f, err := os.Open("./testdata/allocs-l2-v160.json.gz")
f, err := os.Open(fmt.Sprintf("./testdata/allocs-l2-v160-%d.json.gz", l1ChainID))
require.NoError(t, err)
defer f.Close()
gzr, err := gzip.NewReader(f)
Expand Down Expand Up @@ -370,7 +382,7 @@ func TestL2BlockTimeOverride(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

opts, intent, st := setupGenesisChain(t)
opts, intent, st := setupGenesisChain(t, defaultL1ChainID)
intent.GlobalDeployOverrides = map[string]interface{}{
"l2BlockTime": float64(3),
}
Expand All @@ -388,7 +400,7 @@ func TestApplyGenesisStrategy(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

opts, intent, st := setupGenesisChain(t)
opts, intent, st := setupGenesisChain(t, defaultL1ChainID)

require.NoError(t, deployer.ApplyPipeline(ctx, opts))

Expand All @@ -408,7 +420,7 @@ func TestProofParamOverrides(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

opts, intent, st := setupGenesisChain(t)
opts, intent, st := setupGenesisChain(t, defaultL1ChainID)
intent.GlobalDeployOverrides = map[string]any{
"withdrawalDelaySeconds": standard.WithdrawalDelaySeconds + 1,
"minProposalSizeBytes": standard.MinProposalSizeBytes + 1,
Expand Down Expand Up @@ -505,7 +517,7 @@ func TestInteropDeployment(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

opts, intent, st := setupGenesisChain(t)
opts, intent, st := setupGenesisChain(t, defaultL1ChainID)
intent.UseInterop = true

require.NoError(t, deployer.ApplyPipeline(ctx, opts))
Expand All @@ -523,7 +535,7 @@ func TestAltDADeployment(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

opts, intent, st := setupGenesisChain(t)
opts, intent, st := setupGenesisChain(t, defaultL1ChainID)
altDACfg := genesis.AltDADeployConfig{
UseAltDA: true,
DACommitmentType: altda.KeccakCommitmentString,
Expand Down Expand Up @@ -601,7 +613,7 @@ func TestInvalidL2Genesis(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
opts, intent, _ := setupGenesisChain(t)
opts, intent, _ := setupGenesisChain(t, defaultL1ChainID)
intent.DeploymentStrategy = state.DeploymentStrategyGenesis
intent.GlobalDeployOverrides = tt.overrides

Expand All @@ -612,11 +624,11 @@ func TestInvalidL2Genesis(t *testing.T) {
}
}

func setupGenesisChain(t *testing.T) (deployer.ApplyPipelineOpts, *state.Intent, *state.State) {
func setupGenesisChain(t *testing.T, l1ChainID uint64) (deployer.ApplyPipelineOpts, *state.Intent, *state.State) {
lgr := testlog.Logger(t, slog.LevelDebug)

depKey := new(deployerKey)
l1ChainID := big.NewInt(77799777)
l1ChainIDBig := new(big.Int).SetUint64(l1ChainID)
dk, err := devkeys.NewMnemonicDevKeys(devkeys.TestMnemonic)
require.NoError(t, err)

Expand All @@ -627,8 +639,8 @@ func setupGenesisChain(t *testing.T) (deployer.ApplyPipelineOpts, *state.Intent,

loc, _ := testutil.LocalArtifacts(t)

intent, st := newIntent(t, l1ChainID, dk, l2ChainID1, loc, loc)
intent.Chains = append(intent.Chains, newChainIntent(t, dk, l1ChainID, l2ChainID1))
intent, st := newIntent(t, l1ChainIDBig, dk, l2ChainID1, loc, loc)
intent.Chains = append(intent.Chains, newChainIntent(t, dk, l1ChainIDBig, l2ChainID1))
intent.DeploymentStrategy = state.DeploymentStrategyGenesis

opts := deployer.ApplyPipelineOpts{
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit cd2df97

Please sign in to comment.