From 9027dc1f7e9437f06788f9ce9f27b76e9324a250 Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Thu, 12 Dec 2024 09:48:32 -0300 Subject: [PATCH 01/16] Moves TestScheduleArbosUpgrade to its own file --- system_tests/arbos_upgrade_test.go | 64 ++++++++++++++++++++++++++++++ system_tests/precompile_test.go | 51 ------------------------ 2 files changed, 64 insertions(+), 51 deletions(-) create mode 100644 system_tests/arbos_upgrade_test.go diff --git a/system_tests/arbos_upgrade_test.go b/system_tests/arbos_upgrade_test.go new file mode 100644 index 0000000000..084f962209 --- /dev/null +++ b/system_tests/arbos_upgrade_test.go @@ -0,0 +1,64 @@ +// Copyright 2021-2024, Offchain Labs, Inc. +// For license information, see https://github.com/OffchainLabs/nitro/blob/master/LICENSE + +package arbtest + +import ( + "context" + "testing" + + "github.com/ethereum/go-ethereum/accounts/abi/bind" + "github.com/ethereum/go-ethereum/common" + "github.com/offchainlabs/nitro/solgen/go/precompilesgen" +) + +func TestScheduleArbosUpgrade(t *testing.T) { + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + + builder := NewNodeBuilder(ctx).DefaultConfig(t, false) + cleanup := builder.Build(t) + defer cleanup() + + auth := builder.L2Info.GetDefaultTransactOpts("Owner", ctx) + + arbOwnerPublic, err := precompilesgen.NewArbOwnerPublic(common.HexToAddress("0x6b"), builder.L2.Client) + Require(t, err, "could not bind ArbOwner contract") + + arbOwner, err := precompilesgen.NewArbOwner(common.HexToAddress("0x70"), builder.L2.Client) + Require(t, err, "could not bind ArbOwner contract") + + callOpts := &bind.CallOpts{Context: ctx} + scheduled, err := arbOwnerPublic.GetScheduledUpgrade(callOpts) + Require(t, err, "failed to call GetScheduledUpgrade before scheduling upgrade") + if scheduled.ArbosVersion != 0 || scheduled.ScheduledForTimestamp != 0 { + t.Errorf("expected no upgrade to be scheduled, got version %v timestamp %v", scheduled.ArbosVersion, scheduled.ScheduledForTimestamp) + } + + // Schedule a noop upgrade, which should test GetScheduledUpgrade in the same way an already completed upgrade would. + tx, err := arbOwner.ScheduleArbOSUpgrade(&auth, 1, 1) + Require(t, err) + _, err = builder.L2.EnsureTxSucceeded(tx) + Require(t, err) + + scheduled, err = arbOwnerPublic.GetScheduledUpgrade(callOpts) + Require(t, err, "failed to call GetScheduledUpgrade after scheduling noop upgrade") + if scheduled.ArbosVersion != 0 || scheduled.ScheduledForTimestamp != 0 { + t.Errorf("expected completed scheduled upgrade to be ignored, got version %v timestamp %v", scheduled.ArbosVersion, scheduled.ScheduledForTimestamp) + } + + // TODO: Once we have an ArbOS 30, test a real upgrade with it + // We can't test 11 -> 20 because 11 doesn't have the GetScheduledUpgrade method we want to test + var testVersion uint64 = 100 + var testTimestamp uint64 = 1 << 62 + tx, err = arbOwner.ScheduleArbOSUpgrade(&auth, 100, 1<<62) + Require(t, err) + _, err = builder.L2.EnsureTxSucceeded(tx) + Require(t, err) + + scheduled, err = arbOwnerPublic.GetScheduledUpgrade(callOpts) + Require(t, err, "failed to call GetScheduledUpgrade after scheduling upgrade") + if scheduled.ArbosVersion != testVersion || scheduled.ScheduledForTimestamp != testTimestamp { + t.Errorf("expected upgrade to be scheduled for version %v timestamp %v, got version %v timestamp %v", testVersion, testTimestamp, scheduled.ArbosVersion, scheduled.ScheduledForTimestamp) + } +} diff --git a/system_tests/precompile_test.go b/system_tests/precompile_test.go index 78f34df6c7..f0757a1a46 100644 --- a/system_tests/precompile_test.go +++ b/system_tests/precompile_test.go @@ -504,57 +504,6 @@ func TestGetBrotliCompressionLevel(t *testing.T) { } } -func TestScheduleArbosUpgrade(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - defer cancel() - - builder := NewNodeBuilder(ctx).DefaultConfig(t, false) - cleanup := builder.Build(t) - defer cleanup() - - auth := builder.L2Info.GetDefaultTransactOpts("Owner", ctx) - - arbOwnerPublic, err := precompilesgen.NewArbOwnerPublic(common.HexToAddress("0x6b"), builder.L2.Client) - Require(t, err, "could not bind ArbOwner contract") - - arbOwner, err := precompilesgen.NewArbOwner(common.HexToAddress("0x70"), builder.L2.Client) - Require(t, err, "could not bind ArbOwner contract") - - callOpts := &bind.CallOpts{Context: ctx} - scheduled, err := arbOwnerPublic.GetScheduledUpgrade(callOpts) - Require(t, err, "failed to call GetScheduledUpgrade before scheduling upgrade") - if scheduled.ArbosVersion != 0 || scheduled.ScheduledForTimestamp != 0 { - t.Errorf("expected no upgrade to be scheduled, got version %v timestamp %v", scheduled.ArbosVersion, scheduled.ScheduledForTimestamp) - } - - // Schedule a noop upgrade, which should test GetScheduledUpgrade in the same way an already completed upgrade would. - tx, err := arbOwner.ScheduleArbOSUpgrade(&auth, 1, 1) - Require(t, err) - _, err = builder.L2.EnsureTxSucceeded(tx) - Require(t, err) - - scheduled, err = arbOwnerPublic.GetScheduledUpgrade(callOpts) - Require(t, err, "failed to call GetScheduledUpgrade after scheduling noop upgrade") - if scheduled.ArbosVersion != 0 || scheduled.ScheduledForTimestamp != 0 { - t.Errorf("expected completed scheduled upgrade to be ignored, got version %v timestamp %v", scheduled.ArbosVersion, scheduled.ScheduledForTimestamp) - } - - // TODO: Once we have an ArbOS 30, test a real upgrade with it - // We can't test 11 -> 20 because 11 doesn't have the GetScheduledUpgrade method we want to test - var testVersion uint64 = 100 - var testTimestamp uint64 = 1 << 62 - tx, err = arbOwner.ScheduleArbOSUpgrade(&auth, 100, 1<<62) - Require(t, err) - _, err = builder.L2.EnsureTxSucceeded(tx) - Require(t, err) - - scheduled, err = arbOwnerPublic.GetScheduledUpgrade(callOpts) - Require(t, err, "failed to call GetScheduledUpgrade after scheduling upgrade") - if scheduled.ArbosVersion != testVersion || scheduled.ScheduledForTimestamp != testTimestamp { - t.Errorf("expected upgrade to be scheduled for version %v timestamp %v, got version %v timestamp %v", testVersion, testTimestamp, scheduled.ArbosVersion, scheduled.ScheduledForTimestamp) - } -} - func TestArbStatistics(t *testing.T) { t.Parallel() From b37cd1f7ba4f3a6e321546fb9e19c991f83637f4 Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Fri, 13 Dec 2024 10:53:28 -0300 Subject: [PATCH 02/16] Basic TestArbos11To32Upgrade --- system_tests/arbos_upgrade_test.go | 52 ++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/system_tests/arbos_upgrade_test.go b/system_tests/arbos_upgrade_test.go index 084f962209..111da1dabe 100644 --- a/system_tests/arbos_upgrade_test.go +++ b/system_tests/arbos_upgrade_test.go @@ -5,10 +5,13 @@ package arbtest import ( "context" + "math/big" "testing" "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/types" + "github.com/offchainlabs/nitro/arbos/arbosState" "github.com/offchainlabs/nitro/solgen/go/precompilesgen" ) @@ -62,3 +65,52 @@ func TestScheduleArbosUpgrade(t *testing.T) { t.Errorf("expected upgrade to be scheduled for version %v timestamp %v, got version %v timestamp %v", testVersion, testTimestamp, scheduled.ArbosVersion, scheduled.ScheduledForTimestamp) } } + +func checkArbOSVersion(t *testing.T, builder *NodeBuilder, expectedVersion uint64, scenario string) { + statedb, err := builder.L2.ExecNode.Backend.ArbInterface().BlockChain().State() + Require(t, err, "could not get statedb", scenario) + state, err := arbosState.OpenSystemArbosState(statedb, nil, true) + Require(t, err, "could not open ArbOS state", scenario) + if state.ArbOSVersion() != expectedVersion { + t.Errorf("%s: expected ArbOS version %v, got %v", scenario, expectedVersion, state.ArbOSVersion()) + } + +} + +func TestArbos11To32Upgrade(t *testing.T) { + t.Parallel() + + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + + initialVersion := uint64(11) + finalVersion := uint64(32) + + builder := NewNodeBuilder(ctx). + DefaultConfig(t, false). + WithArbOSVersion(initialVersion) + cleanup := builder.Build(t) + defer cleanup() + + checkArbOSVersion(t, builder, initialVersion, "initial") + + auth := builder.L2Info.GetDefaultTransactOpts("Owner", ctx) + + arbOwner, err := precompilesgen.NewArbOwner(types.ArbOwnerAddress, builder.L2.Client) + Require(t, err, "could not bind ArbOwner contract") + + tx, err := arbOwner.ScheduleArbOSUpgrade(&auth, finalVersion, 0) + Require(t, err) + _, err = builder.L2.EnsureTxSucceeded(tx) + Require(t, err) + + // generate a new block to trigger the upgrade + builder.L2Info.GenerateAccount("User2") + tx = builder.L2Info.PrepareTx("Owner", "User2", builder.L2Info.TransferGas, big.NewInt(1e12), nil) + err = builder.L2.Client.SendTransaction(ctx, tx) + Require(t, err) + _, err = builder.L2.EnsureTxSucceeded(tx) + Require(t, err) + + checkArbOSVersion(t, builder, finalVersion, "final") +} From 61ce80b3fe80c6abd24a61cf756a5cd32b695732 Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Mon, 16 Dec 2024 10:38:26 -0300 Subject: [PATCH 03/16] Update contracts to have ArbOS11To32UpgradeTest --- contracts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts b/contracts index b140ed63ac..cd9b8d6afc 160000 --- a/contracts +++ b/contracts @@ -1 +1 @@ -Subproject commit b140ed63acdb53cb906ffd1fa3c36fdbd474364e +Subproject commit cd9b8d6afce238d1cb12c8ce1952f745bead71ac From 658e2d1f108f9bd235dc0e4a9551533958ae6bb5 Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Mon, 16 Dec 2024 10:47:50 -0300 Subject: [PATCH 04/16] Calls DeployArbOS11To32UpgradeTest --- system_tests/arbos_upgrade_test.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/system_tests/arbos_upgrade_test.go b/system_tests/arbos_upgrade_test.go index 111da1dabe..1194f3232f 100644 --- a/system_tests/arbos_upgrade_test.go +++ b/system_tests/arbos_upgrade_test.go @@ -12,6 +12,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/offchainlabs/nitro/arbos/arbosState" + "github.com/offchainlabs/nitro/solgen/go/mocksgen" "github.com/offchainlabs/nitro/solgen/go/precompilesgen" ) @@ -97,14 +98,19 @@ func TestArbos11To32Upgrade(t *testing.T) { auth := builder.L2Info.GetDefaultTransactOpts("Owner", ctx) arbOwner, err := precompilesgen.NewArbOwner(types.ArbOwnerAddress, builder.L2.Client) - Require(t, err, "could not bind ArbOwner contract") + Require(t, err) + + _, tx, contract, err := mocksgen.DeployArbOS11To32UpgradeTest(&auth, builder.L2.Client) + Require(t, err) + _, err = EnsureTxSucceeded(ctx, builder.L2.Client, tx) + Require(t, err) - tx, err := arbOwner.ScheduleArbOSUpgrade(&auth, finalVersion, 0) + tx, err = arbOwner.ScheduleArbOSUpgrade(&auth, finalVersion, 0) Require(t, err) _, err = builder.L2.EnsureTxSucceeded(tx) Require(t, err) - // generate a new block to trigger the upgrade + // generates a new block to trigger the upgrade builder.L2Info.GenerateAccount("User2") tx = builder.L2Info.PrepareTx("Owner", "User2", builder.L2Info.TransferGas, big.NewInt(1e12), nil) err = builder.L2.Client.SendTransaction(ctx, tx) @@ -112,5 +118,9 @@ func TestArbos11To32Upgrade(t *testing.T) { _, err = builder.L2.EnsureTxSucceeded(tx) Require(t, err) + callOpts := &bind.CallOpts{Context: ctx} + err = contract.Mcopy(callOpts) + Require(t, err) + checkArbOSVersion(t, builder, finalVersion, "final") } From 61ab0c70e13e52a28b3907793fd3eee25892d0d4 Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Mon, 16 Dec 2024 13:47:10 -0300 Subject: [PATCH 05/16] mcopy as a transaction instead of a call --- contracts | 2 +- system_tests/arbos_upgrade_test.go | 27 ++++++++++++++++----------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/contracts b/contracts index cd9b8d6afc..54ec0a90af 160000 --- a/contracts +++ b/contracts @@ -1 +1 @@ -Subproject commit cd9b8d6afce238d1cb12c8ce1952f745bead71ac +Subproject commit 54ec0a90af2068d5c4e9b7865d87221aa12e6969 diff --git a/system_tests/arbos_upgrade_test.go b/system_tests/arbos_upgrade_test.go index 1194f3232f..52660817fb 100644 --- a/system_tests/arbos_upgrade_test.go +++ b/system_tests/arbos_upgrade_test.go @@ -67,8 +67,8 @@ func TestScheduleArbosUpgrade(t *testing.T) { } } -func checkArbOSVersion(t *testing.T, builder *NodeBuilder, expectedVersion uint64, scenario string) { - statedb, err := builder.L2.ExecNode.Backend.ArbInterface().BlockChain().State() +func checkArbOSVersion(t *testing.T, testClient *TestClient, expectedVersion uint64, scenario string) { + statedb, err := testClient.ExecNode.Backend.ArbInterface().BlockChain().State() Require(t, err, "could not get statedb", scenario) state, err := arbosState.OpenSystemArbosState(statedb, nil, true) Require(t, err, "could not open ArbOS state", scenario) @@ -93,18 +93,25 @@ func TestArbos11To32Upgrade(t *testing.T) { cleanup := builder.Build(t) defer cleanup() - checkArbOSVersion(t, builder, initialVersion, "initial") - auth := builder.L2Info.GetDefaultTransactOpts("Owner", ctx) - arbOwner, err := precompilesgen.NewArbOwner(types.ArbOwnerAddress, builder.L2.Client) - Require(t, err) - + // deploys test contract _, tx, contract, err := mocksgen.DeployArbOS11To32UpgradeTest(&auth, builder.L2.Client) Require(t, err) _, err = EnsureTxSucceeded(ctx, builder.L2.Client, tx) Require(t, err) + checkArbOSVersion(t, builder.L2, initialVersion, "initial") + + // mcopy should revert since arbos 11 doesn't support it + _, err = contract.Mcopy(&auth) + if (err == nil) || (err.Error() != "invalid opcode: MCOPY") { + t.Fatalf("expected MCOPY to revert, got %v", err) + } + + // upgrade arbos to final version + arbOwner, err := precompilesgen.NewArbOwner(types.ArbOwnerAddress, builder.L2.Client) + Require(t, err) tx, err = arbOwner.ScheduleArbOSUpgrade(&auth, finalVersion, 0) Require(t, err) _, err = builder.L2.EnsureTxSucceeded(tx) @@ -118,9 +125,7 @@ func TestArbos11To32Upgrade(t *testing.T) { _, err = builder.L2.EnsureTxSucceeded(tx) Require(t, err) - callOpts := &bind.CallOpts{Context: ctx} - err = contract.Mcopy(callOpts) + checkArbOSVersion(t, builder.L2, finalVersion, "final") + _, err = contract.Mcopy(&auth) Require(t, err) - - checkArbOSVersion(t, builder, finalVersion, "final") } From 5dc83ac5888cfd182d98d47a357adf88265d6fd8 Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Mon, 16 Dec 2024 15:41:58 -0300 Subject: [PATCH 06/16] TestArbos11To32Upgrade use L1 --- system_tests/arbos_upgrade_test.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/system_tests/arbos_upgrade_test.go b/system_tests/arbos_upgrade_test.go index 52660817fb..418046ed73 100644 --- a/system_tests/arbos_upgrade_test.go +++ b/system_tests/arbos_upgrade_test.go @@ -88,13 +88,21 @@ func TestArbos11To32Upgrade(t *testing.T) { finalVersion := uint64(32) builder := NewNodeBuilder(ctx). - DefaultConfig(t, false). + DefaultConfig(t, true). WithArbOSVersion(initialVersion) cleanup := builder.Build(t) defer cleanup() auth := builder.L2Info.GetDefaultTransactOpts("Owner", ctx) + // makes Owner a chain owner + arbDebug, err := precompilesgen.NewArbDebug(types.ArbDebugAddress, builder.L2.Client) + Require(t, err) + tx, err := arbDebug.BecomeChainOwner(&auth) + Require(t, err) + _, err = EnsureTxSucceeded(ctx, builder.L2.Client, tx) + Require(t, err) + // deploys test contract _, tx, contract, err := mocksgen.DeployArbOS11To32UpgradeTest(&auth, builder.L2.Client) Require(t, err) From 1fe4c311d0c64ef04ffd3b4b346f45318d0fe815 Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Mon, 16 Dec 2024 16:13:00 -0300 Subject: [PATCH 07/16] Tries mcopy tx in the same block that arbos upgrades will take effect --- system_tests/arbos_upgrade_test.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/system_tests/arbos_upgrade_test.go b/system_tests/arbos_upgrade_test.go index 418046ed73..ce9accaed1 100644 --- a/system_tests/arbos_upgrade_test.go +++ b/system_tests/arbos_upgrade_test.go @@ -125,13 +125,13 @@ func TestArbos11To32Upgrade(t *testing.T) { _, err = builder.L2.EnsureTxSucceeded(tx) Require(t, err) - // generates a new block to trigger the upgrade - builder.L2Info.GenerateAccount("User2") - tx = builder.L2Info.PrepareTx("Owner", "User2", builder.L2Info.TransferGas, big.NewInt(1e12), nil) - err = builder.L2.Client.SendTransaction(ctx, tx) - Require(t, err) - _, err = builder.L2.EnsureTxSucceeded(tx) - Require(t, err) + // // generates a new block to trigger the upgrade + // builder.L2Info.GenerateAccount("User2") + // tx = builder.L2Info.PrepareTx("Owner", "User2", builder.L2Info.TransferGas, big.NewInt(1e12), nil) + // err = builder.L2.Client.SendTransaction(ctx, tx) + // Require(t, err) + // _, err = builder.L2.EnsureTxSucceeded(tx) + // Require(t, err) checkArbOSVersion(t, builder.L2, finalVersion, "final") _, err = contract.Mcopy(&auth) From 1b3734e510333effb1bc26b31b929a468c1b637a Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Tue, 17 Dec 2024 10:42:16 -0300 Subject: [PATCH 08/16] Adds replica node to TestArbos11To32Upgrade --- system_tests/arbos_upgrade_test.go | 87 +++++++++++++++++++++++------- 1 file changed, 67 insertions(+), 20 deletions(-) diff --git a/system_tests/arbos_upgrade_test.go b/system_tests/arbos_upgrade_test.go index ce9accaed1..e6be0de16c 100644 --- a/system_tests/arbos_upgrade_test.go +++ b/system_tests/arbos_upgrade_test.go @@ -6,11 +6,14 @@ package arbtest import ( "context" "math/big" + "strings" "testing" + "time" "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/offchainlabs/nitro/arbnode" "github.com/offchainlabs/nitro/arbos/arbosState" "github.com/offchainlabs/nitro/solgen/go/mocksgen" "github.com/offchainlabs/nitro/solgen/go/precompilesgen" @@ -92,48 +95,92 @@ func TestArbos11To32Upgrade(t *testing.T) { WithArbOSVersion(initialVersion) cleanup := builder.Build(t) defer cleanup() + seqTestClient := builder.L2 auth := builder.L2Info.GetDefaultTransactOpts("Owner", ctx) + auth.GasLimit = 32000000 // makes Owner a chain owner - arbDebug, err := precompilesgen.NewArbDebug(types.ArbDebugAddress, builder.L2.Client) + arbDebug, err := precompilesgen.NewArbDebug(types.ArbDebugAddress, seqTestClient.Client) Require(t, err) tx, err := arbDebug.BecomeChainOwner(&auth) Require(t, err) - _, err = EnsureTxSucceeded(ctx, builder.L2.Client, tx) + _, err = EnsureTxSucceeded(ctx, seqTestClient.Client, tx) Require(t, err) // deploys test contract - _, tx, contract, err := mocksgen.DeployArbOS11To32UpgradeTest(&auth, builder.L2.Client) + _, tx, contract, err := mocksgen.DeployArbOS11To32UpgradeTest(&auth, seqTestClient.Client) Require(t, err) - _, err = EnsureTxSucceeded(ctx, builder.L2.Client, tx) + _, err = EnsureTxSucceeded(ctx, seqTestClient.Client, tx) Require(t, err) - checkArbOSVersion(t, builder.L2, initialVersion, "initial") + // build replica node + replicaConfig := arbnode.ConfigDefaultL1Test() + replicaConfig.BatchPoster.Enable = false + replicaTestClient, replicaCleanup := builder.Build2ndNode(t, &SecondNodeParams{nodeConfig: replicaConfig}) + defer replicaCleanup() - // mcopy should revert since arbos 11 doesn't support it - _, err = contract.Mcopy(&auth) - if (err == nil) || (err.Error() != "invalid opcode: MCOPY") { - t.Fatalf("expected MCOPY to revert, got %v", err) + checkArbOSVersion(t, seqTestClient, initialVersion, "initial sequencer") + checkArbOSVersion(t, replicaTestClient, initialVersion, "initial replica") + + // mcopy should fail since arbos 11 doesn't support it + tx, err = contract.Mcopy(&auth) + Require(t, err) + _, err = seqTestClient.EnsureTxSucceeded(tx) + if (err == nil) || !strings.Contains(err.Error(), "invalid opcode: MCOPY") { + t.Errorf("expected MCOPY to fail, got %v", err) } + _, err = WaitForTx(ctx, replicaTestClient.Client, tx.Hash(), time.Second*15) + Require(t, err) // upgrade arbos to final version - arbOwner, err := precompilesgen.NewArbOwner(types.ArbOwnerAddress, builder.L2.Client) + arbOwner, err := precompilesgen.NewArbOwner(types.ArbOwnerAddress, seqTestClient.Client) Require(t, err) tx, err = arbOwner.ScheduleArbOSUpgrade(&auth, finalVersion, 0) Require(t, err) - _, err = builder.L2.EnsureTxSucceeded(tx) + _, err = seqTestClient.EnsureTxSucceeded(tx) + Require(t, err) + _, err = WaitForTx(ctx, replicaTestClient.Client, tx.Hash(), time.Second*15) + Require(t, err) + + // checks upgrade worked + tx, err = contract.Mcopy(&auth) + Require(t, err) + _, err = seqTestClient.EnsureTxSucceeded(tx) Require(t, err) + _, err = WaitForTx(ctx, replicaTestClient.Client, tx.Hash(), time.Second*15) + Require(t, err) + + checkArbOSVersion(t, seqTestClient, finalVersion, "final sequencer") + checkArbOSVersion(t, replicaTestClient, finalVersion, "final replica") + + // generates more blocks + builder.L2Info.GenerateAccount("User2") + for i := 0; i < 3; i++ { + tx = builder.L2Info.PrepareTx("Owner", "User2", builder.L2Info.TransferGas, big.NewInt(1e12), nil) + err = seqTestClient.Client.SendTransaction(ctx, tx) + Require(t, err) + _, err = seqTestClient.EnsureTxSucceeded(tx) + Require(t, err) + _, err = WaitForTx(ctx, replicaTestClient.Client, tx.Hash(), time.Second*15) + Require(t, err) + } - // // generates a new block to trigger the upgrade - // builder.L2Info.GenerateAccount("User2") - // tx = builder.L2Info.PrepareTx("Owner", "User2", builder.L2Info.TransferGas, big.NewInt(1e12), nil) - // err = builder.L2.Client.SendTransaction(ctx, tx) - // Require(t, err) - // _, err = builder.L2.EnsureTxSucceeded(tx) - // Require(t, err) + blockNumberSeq, err := seqTestClient.Client.BlockNumber(ctx) + Require(t, err) + blockNumberReplica, err := replicaTestClient.Client.BlockNumber(ctx) + Require(t, err) + if blockNumberSeq != blockNumberReplica { + t.Errorf("expected sequencer and replica to have same block number, got %v and %v", blockNumberSeq, blockNumberReplica) + } + // #nosec G115 + blockNumber := big.NewInt(int64(blockNumberSeq)) - checkArbOSVersion(t, builder.L2, finalVersion, "final") - _, err = contract.Mcopy(&auth) + blockSeq, err := seqTestClient.Client.BlockByNumber(ctx, blockNumber) Require(t, err) + blockReplica, err := replicaTestClient.Client.BlockByNumber(ctx, blockNumber) + Require(t, err) + if blockSeq.Hash() != blockReplica.Hash() { + t.Errorf("expected sequencer and replica to have same block hash, got %v and %v", blockSeq.Hash(), blockReplica.Hash()) + } } From 9f9038a80f5d8ab45bf0d38a0b906dfe934ce021 Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Tue, 17 Dec 2024 14:28:30 -0300 Subject: [PATCH 09/16] Fix lint issue --- system_tests/arbos_upgrade_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/system_tests/arbos_upgrade_test.go b/system_tests/arbos_upgrade_test.go index e6be0de16c..d2b2b7b9af 100644 --- a/system_tests/arbos_upgrade_test.go +++ b/system_tests/arbos_upgrade_test.go @@ -13,6 +13,7 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/offchainlabs/nitro/arbnode" "github.com/offchainlabs/nitro/arbos/arbosState" "github.com/offchainlabs/nitro/solgen/go/mocksgen" From 86ca279098d74452428cc1f4532fc9e0fcbcab91 Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Tue, 17 Dec 2024 15:05:26 -0300 Subject: [PATCH 10/16] Update contracts --- contracts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts b/contracts index 54ec0a90af..550bfe608a 160000 --- a/contracts +++ b/contracts @@ -1 +1 @@ -Subproject commit 54ec0a90af2068d5c4e9b7865d87221aa12e6969 +Subproject commit 550bfe608a9d9009518a52c502389270ed14e273 From 4598b50d56c4d151581c1d249846ccfbd755987d Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Wed, 18 Dec 2024 09:24:44 -0300 Subject: [PATCH 11/16] Update contracts --- contracts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts b/contracts index 550bfe608a..faf77b348e 160000 --- a/contracts +++ b/contracts @@ -1 +1 @@ -Subproject commit 550bfe608a9d9009518a52c502389270ed14e273 +Subproject commit faf77b348e52338cca22852393feedc7b550e9db From c139ee1ed2bd2076fbe38ba08f03f2b3293cc2ac Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Wed, 18 Dec 2024 10:11:54 -0300 Subject: [PATCH 12/16] Removes TODO --- system_tests/arbos_upgrade_test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/system_tests/arbos_upgrade_test.go b/system_tests/arbos_upgrade_test.go index d2b2b7b9af..805def1781 100644 --- a/system_tests/arbos_upgrade_test.go +++ b/system_tests/arbos_upgrade_test.go @@ -55,7 +55,6 @@ func TestScheduleArbosUpgrade(t *testing.T) { t.Errorf("expected completed scheduled upgrade to be ignored, got version %v timestamp %v", scheduled.ArbosVersion, scheduled.ScheduledForTimestamp) } - // TODO: Once we have an ArbOS 30, test a real upgrade with it // We can't test 11 -> 20 because 11 doesn't have the GetScheduledUpgrade method we want to test var testVersion uint64 = 100 var testTimestamp uint64 = 1 << 62 From b2aedea8a49b0a0c1652de175946c70aba550686 Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Thu, 19 Dec 2024 16:22:42 -0300 Subject: [PATCH 13/16] Update contracts --- contracts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts b/contracts index faf77b348e..763bd77906 160000 --- a/contracts +++ b/contracts @@ -1 +1 @@ -Subproject commit faf77b348e52338cca22852393feedc7b550e9db +Subproject commit 763bd77906b7677da691eaa31c6e195d455197a4 From 71bd119e7aea567a8d4f2583bf5058906f8b673f Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Thu, 19 Dec 2024 16:25:43 -0300 Subject: [PATCH 14/16] Adds pre-bold as a nitro-contracts branch exception in submodule-pin-check --- .github/workflows/submodule-pin-check.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/submodule-pin-check.yml b/.github/workflows/submodule-pin-check.yml index 60dd8ad827..a3cfc3b4f0 100644 --- a/.github/workflows/submodule-pin-check.yml +++ b/.github/workflows/submodule-pin-check.yml @@ -26,8 +26,9 @@ jobs: status_state="pending" declare -Ar exceptions=( [contracts]=origin/develop + [contracts]=origin/pre-bold [nitro-testnode]=origin/master - + #TODO Rachel to check these are the intended branches. [arbitrator/langs/c]=origin/vm-storage-cache [arbitrator/tools/wasmer]=origin/adopt-v4.2.8 @@ -38,7 +39,7 @@ jobs: if [[ -v exceptions[$mod] ]]; then branch=${exceptions[$mod]} fi - + if ! git -C $mod merge-base --is-ancestor HEAD $branch; then echo $mod diverges from $branch divergent=1 From 027f35c44cb4d667cc755695ca798c868b28ef87 Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Fri, 20 Dec 2024 09:29:26 -0300 Subject: [PATCH 15/16] pre-bold instead of develop as the exception branch used to check submodule pin for nitro-contracts --- .github/workflows/submodule-pin-check.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/submodule-pin-check.yml b/.github/workflows/submodule-pin-check.yml index 60dd8ad827..94fa705655 100644 --- a/.github/workflows/submodule-pin-check.yml +++ b/.github/workflows/submodule-pin-check.yml @@ -25,9 +25,9 @@ jobs: run: | status_state="pending" declare -Ar exceptions=( - [contracts]=origin/develop + [contracts]=origin/pre-bold [nitro-testnode]=origin/master - + #TODO Rachel to check these are the intended branches. [arbitrator/langs/c]=origin/vm-storage-cache [arbitrator/tools/wasmer]=origin/adopt-v4.2.8 @@ -38,7 +38,7 @@ jobs: if [[ -v exceptions[$mod] ]]; then branch=${exceptions[$mod]} fi - + if ! git -C $mod merge-base --is-ancestor HEAD $branch; then echo $mod diverges from $branch divergent=1 From 957b50e71eedee1887da99933f08d47b9e496d20 Mon Sep 17 00:00:00 2001 From: Diego Ximenes Date: Fri, 20 Dec 2024 09:38:09 -0300 Subject: [PATCH 16/16] Fixes exception branch for nitro-contracts --- .github/workflows/submodule-pin-check.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/submodule-pin-check.yml b/.github/workflows/submodule-pin-check.yml index a3cfc3b4f0..94fa705655 100644 --- a/.github/workflows/submodule-pin-check.yml +++ b/.github/workflows/submodule-pin-check.yml @@ -25,7 +25,6 @@ jobs: run: | status_state="pending" declare -Ar exceptions=( - [contracts]=origin/develop [contracts]=origin/pre-bold [nitro-testnode]=origin/master