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 6 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 go-ethereum
17 changes: 14 additions & 3 deletions system_tests/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -597,17 +597,28 @@ func createTestNodeOnL1WithConfigImpl(
// L2 -Only. Enough for tests that needs no interface to L1
// Requires precompiles.AllowDebugPrecompiles = true
func CreateTestL2(t *testing.T, ctx context.Context) (*BlockchainTestInfo, *arbnode.Node, *ethclient.Client) {
return CreateTestL2WithConfig(t, ctx, nil, arbnode.ConfigDefaultL2Test(), true)
return CreateTestL2WithArbOS(t, ctx, 11)
}

func CreateTestL2WithArbOS(t *testing.T, ctx context.Context, arbOS uint64) (*BlockchainTestInfo, *arbnode.Node, *ethclient.Client) {
return CreateTestL2WithConfigArbOS(t, ctx, nil, arbnode.ConfigDefaultL2Test(), true, arbOS)
}

func CreateTestL2WithConfig(
t *testing.T, ctx context.Context, l2Info *BlockchainTestInfo, nodeConfig *arbnode.Config, takeOwnership bool,
) (*BlockchainTestInfo, *arbnode.Node, *ethclient.Client) {
return CreateTestL2WithConfigArbOS(t, ctx, l2Info, nodeConfig, takeOwnership, 11)
}

func CreateTestL2WithConfigArbOS(
amsanghi marked this conversation as resolved.
Show resolved Hide resolved
t *testing.T, ctx context.Context, l2Info *BlockchainTestInfo, nodeConfig *arbnode.Config, takeOwnership bool, arbOS uint64,
) (*BlockchainTestInfo, *arbnode.Node, *ethclient.Client) {
feedErrChan := make(chan error, 10)

AddDefaultValNode(t, ctx, nodeConfig, true)

l2info, stack, chainDb, arbDb, blockchain := createL2BlockChain(t, l2Info, "", params.ArbitrumDevTestChainConfig())
chainConfig := params.ArbitrumDevTestChainConfig()
chainConfig.ArbitrumChainParams.InitialArbOSVersion = arbOS
l2info, stack, chainDb, arbDb, blockchain := createL2BlockChain(t, l2Info, "", chainConfig)
currentNode, err := arbnode.CreateNode(ctx, stack, chainDb, arbDb, NewFetcherFromConfig(nodeConfig), blockchain, nil, nil, nil, nil, nil, feedErrChan)
Require(t, err)

Expand Down
40 changes: 40 additions & 0 deletions system_tests/estimation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,46 @@ func TestEstimate(t *testing.T) {
}
}

func TestDifficultyForLatestArbOS(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

l2info, node, client := CreateTestL2(t, ctx)
defer node.StopAndWait()

auth := l2info.GetDefaultTransactOpts("Owner", ctx)

// deploy a test contract
_, _, simple, err := mocksgen.DeploySimple(&auth, client)
Require(t, err, "could not deploy contract")

difficulty, err := simple.GetBlockDifficulty(&bind.CallOpts{})
Require(t, err)
if difficulty.Uint64() != 1 {
Fail(t, "Expected difficulty to be 1 by 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()

l2info, node, client := CreateTestL2WithArbOS(t, ctx, 10)
defer node.StopAndWait()

auth := l2info.GetDefaultTransactOpts("Owner", ctx)

// deploy a test contract
_, _, simple, err := mocksgen.DeploySimple(&auth, client)
Require(t, err, "could not deploy contract")

difficulty, err := simple.GetBlockDifficulty(&bind.CallOpts{})
Require(t, err)
if difficulty.Uint64() != 1 {
amsanghi marked this conversation as resolved.
Show resolved Hide resolved
Fail(t, "Expected difficulty to be 1 by got:", difficulty)
}
}

func TestComponentEstimate(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
Expand Down