Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test to ensure DIFFICULTY/PREVRANDAO opcode returns the expected value of 1 #1667

Merged
merged 28 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
d02469c
test to ensure DIFFICULTY/PREVRANDAO opcode returns the expected valu…
amsanghi May 25, 2023
31a0a67
Fix contracts branch
amsanghi May 25, 2023
ccf472d
Fix contracts branch
amsanghi May 25, 2023
9b632f9
update submodules
amsanghi May 25, 2023
442aa7c
Merge branch 'master' into test_PREVRANDAO
amsanghi May 25, 2023
e7220b6
update submodules
amsanghi May 25, 2023
f57855c
Merge branch 'master' into test_PREVRANDAO
amsanghi May 30, 2023
1d3a93c
Changes based on PR comments
amsanghi May 30, 2023
dc01bf6
Merge branch 'master' into test_PREVRANDAO
amsanghi Jun 21, 2023
b517b8e
Changes based on PR comments
amsanghi Jun 21, 2023
37ff4e7
minor fix
amsanghi Jun 21, 2023
bc8e7bb
Changes based on PR comments
amsanghi Jun 21, 2023
025ae7c
Merge branch 'master' into test_PREVRANDAO
amsanghi Sep 29, 2023
b725fec
Changes based on PR comments
amsanghi Sep 29, 2023
1b76e9e
Changes based on PR comments
amsanghi Oct 25, 2023
12b5a71
Merge branch 'master' into test_PREVRANDAO
amsanghi Oct 25, 2023
b0c0db9
update contract
amsanghi Oct 25, 2023
9067c64
minor fix
amsanghi Oct 25, 2023
35b4bcf
update contract
amsanghi Oct 25, 2023
17ce3cc
update contract
amsanghi Oct 25, 2023
46287a1
minor fix
amsanghi Oct 25, 2023
b5383bd
changes based on pr comments
amsanghi Oct 26, 2023
ba0de15
update block validator test
amsanghi Oct 26, 2023
0b8fdaa
Merge branch 'master' into test_PREVRANDAO
amsanghi Nov 28, 2023
5a47889
minor fix
amsanghi Nov 28, 2023
b4a3e2e
Merge branch 'master' into test_PREVRANDAO
amsanghi Nov 28, 2023
d9aa22a
Merge branch 'master' into test_PREVRANDAO
joshuacolvin0 Nov 28, 2023
ceaaa6a
Merge branch 'master' into test_PREVRANDAO
joshuacolvin0 Nov 28, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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{})
amsanghi marked this conversation as resolved.
Show resolved Hide resolved
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) {
amsanghi marked this conversation as resolved.
Show resolved Hide resolved
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
Loading