diff --git a/contracts b/contracts index 695750067b..4184926b5e 160000 --- a/contracts +++ b/contracts @@ -1 +1 @@ -Subproject commit 695750067b2b7658556bdf61ec8cf16132d83dd0 +Subproject commit 4184926b5ea855365fb60b13a4bd52e59b9136ca diff --git a/system_tests/block_validator_test.go b/system_tests/block_validator_test.go index 33314d347a..e2e4227bf6 100644 --- a/system_tests/block_validator_test.go +++ b/system_tests/block_validator_test.go @@ -14,6 +14,7 @@ import ( "time" "github.com/ethereum/go-ethereum" + "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/core/vm" @@ -22,7 +23,9 @@ import ( "github.com/offchainlabs/nitro/arbos/l2pricing" "github.com/offchainlabs/nitro/arbutil" "github.com/offchainlabs/nitro/execution/gethexec" + "github.com/offchainlabs/nitro/solgen/go/mocksgen" "github.com/offchainlabs/nitro/solgen/go/precompilesgen" + "github.com/offchainlabs/nitro/util/arbmath" ) type workloadType uint @@ -71,6 +74,7 @@ func testBlockValidatorSimple(t *testing.T, dasModeString string, workloadLoops perTransfer := big.NewInt(1e12) + var simple *mocksgen.Simple if workload != upgradeArbOs { for i := 0; i < workloadLoops; i++ { var tx *types.Transaction @@ -122,10 +126,24 @@ func testBlockValidatorSimple(t *testing.T, dasModeString string, workloadLoops } } else { auth := builder.L2Info.GetDefaultTransactOpts("Owner", ctx) + // deploy a test contract + var err error + _, _, simple, err = mocksgen.DeploySimple(&auth, builder.L2.Client) + Require(t, err, "could not deploy contract") + + tx, err := simple.StoreDifficulty(&auth) + Require(t, err) + _, err = EnsureTxSucceeded(ctx, builder.L2.Client, tx) + Require(t, err) + difficulty, err := simple.GetBlockDifficulty(&bind.CallOpts{}) + Require(t, err) + if !arbmath.BigEquals(difficulty, common.Big1) { + Fatal(t, "Expected difficulty to be 1 but got:", difficulty) + } // make auth a chain owner arbDebug, err := precompilesgen.NewArbDebug(common.HexToAddress("0xff"), builder.L2.Client) Require(t, err) - tx, err := arbDebug.BecomeChainOwner(&auth) + tx, err = arbDebug.BecomeChainOwner(&auth) Require(t, err) _, err = builder.L2.EnsureTxSucceeded(tx) Require(t, err) @@ -136,6 +154,16 @@ func testBlockValidatorSimple(t *testing.T, dasModeString string, workloadLoops _, err = builder.L2.EnsureTxSucceeded(tx) Require(t, err) + tx, err = simple.StoreDifficulty(&auth) + Require(t, err) + _, err = EnsureTxSucceeded(ctx, builder.L2.Client, tx) + Require(t, err) + difficulty, err = simple.GetBlockDifficulty(&bind.CallOpts{}) + Require(t, err) + if !arbmath.BigEquals(difficulty, common.Big1) { + Fatal(t, "Expected difficulty to be 1 but got:", difficulty) + } + tx = builder.L2Info.PrepareTxTo("Owner", nil, builder.L2Info.TransferGas, perTransfer, []byte{byte(vm.PUSH0)}) err = builder.L2.Client.SendTransaction(ctx, tx) Require(t, err) diff --git a/system_tests/estimation_test.go b/system_tests/estimation_test.go index 691b02a123..eda7fb449f 100644 --- a/system_tests/estimation_test.go +++ b/system_tests/estimation_test.go @@ -129,6 +129,57 @@ func TestEstimate(t *testing.T) { } } +func TestDifficultyForLatestArbOS(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) + + // deploy a test contract + _, _, simple, err := mocksgen.DeploySimple(&auth, builder.L2.Client) + Require(t, err, "could not deploy contract") + + tx, err := simple.StoreDifficulty(&auth) + Require(t, err) + _, err = EnsureTxSucceeded(ctx, builder.L2.Client, tx) + Require(t, err) + difficulty, err := simple.GetBlockDifficulty(&bind.CallOpts{}) + Require(t, err) + if !arbmath.BigEquals(difficulty, common.Big1) { + Fatal(t, "Expected difficulty to be 1 but got:", difficulty) + } +} + +func TestDifficultyForArbOSTen(t *testing.T) { + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + + builder := NewNodeBuilder(ctx).DefaultConfig(t, false) + builder.chainConfig.ArbitrumChainParams.InitialArbOSVersion = 10 + cleanup := builder.Build(t) + defer cleanup() + + auth := builder.L2Info.GetDefaultTransactOpts("Owner", ctx) + + // deploy a test contract + _, _, simple, err := mocksgen.DeploySimple(&auth, builder.L2.Client) + Require(t, err, "could not deploy contract") + + tx, err := simple.StoreDifficulty(&auth) + Require(t, err) + _, err = EnsureTxSucceeded(ctx, builder.L2.Client, tx) + Require(t, err) + difficulty, err := simple.GetBlockDifficulty(&bind.CallOpts{}) + Require(t, err) + if !arbmath.BigEquals(difficulty, common.Big1) { + Fatal(t, "Expected difficulty to be 1 but got:", difficulty) + } +} + func TestComponentEstimate(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) defer cancel()