Skip to content

Commit

Permalink
Merge branch 'master' into geth-270-272
Browse files Browse the repository at this point in the history
  • Loading branch information
PlasmaPower authored Nov 29, 2023
2 parents 28a22cf + 7699979 commit b9f0376
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 2 deletions.
2 changes: 1 addition & 1 deletion contracts
30 changes: 29 additions & 1 deletion system_tests/block_validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down
51 changes: 51 additions & 0 deletions system_tests/estimation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit b9f0376

Please sign in to comment.