Commit cd2df972 authored by Matthew Slipper's avatar Matthew Slipper Committed by GitHub

op-deployer: Test mainnet deployment (#12958)

Adds a unit test for mainnet deployments at version 1.6.0.
parent 50e1623a
......@@ -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 \
......
......@@ -68,6 +68,8 @@ network_params:
genesis_delay: 0
`
const defaultL1ChainID uint64 = 77799777
type deployerKey struct{}
func (d *deployerKey) HDPath() string {
......@@ -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)
......@@ -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")
}
......@@ -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"),
......@@ -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
......@@ -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)
......@@ -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),
}
......@@ -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))
......@@ -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,
......@@ -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))
......@@ -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,
......@@ -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
......@@ -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)
......@@ -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{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment