From b5adaedafed993caab25316f5daff1d3fa8afc0a Mon Sep 17 00:00:00 2001 From: tongjicoder Date: Fri, 14 Jun 2024 18:09:07 +0800 Subject: [PATCH 01/11] chore: make function comment match function name Signed-off-by: tongjicoder --- validator/server_arb/execution_run.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/validator/server_arb/execution_run.go b/validator/server_arb/execution_run.go index 255d42ab16..4af5736ba6 100644 --- a/validator/server_arb/execution_run.go +++ b/validator/server_arb/execution_run.go @@ -19,7 +19,7 @@ type executionRun struct { close sync.Once } -// NewExecutionChallengeBackend creates a backend with the given arguments. +// NewExecutionRun creates a backend with the given arguments. // Note: machineCache may be nil, but if present, it must not have a restricted range. func NewExecutionRun( ctxIn context.Context, From b08928dcc1877fda9e55235fd8fc899b6948d67a Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Fri, 28 Jun 2024 18:50:51 +0530 Subject: [PATCH 02/11] Skip TestSequencerPriceAdjustsFrom* on local builds --- .github/workflows/ci.yml | 2 +- system_tests/fees_test.go | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4d97b5bfd5..c2ee39a6d1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -145,7 +145,7 @@ jobs: if: matrix.test-mode == 'defaults' run: | packages=`go list ./...` - stdbuf -oL gotestsum --format short-verbose --packages="$packages" --rerun-fails=1 --no-color=false -- ./... -coverprofile=coverage.txt -covermode=atomic -coverpkg=./...,./go-ethereum/... -timeout 20m -parallel=8 > >(stdbuf -oL tee full.log | grep -vE "INFO|seal") + stdbuf -oL gotestsum --format short-verbose --packages="$packages" --rerun-fails=1 --no-color=false -- ./... -coverprofile=coverage.txt -covermode=atomic -coverpkg=./...,./go-ethereum/... -timeout 20m -parallel=8 -tags=feestest > >(stdbuf -oL tee full.log | grep -vE "INFO|seal") - name: run tests with race detection if: matrix.test-mode == 'race' diff --git a/system_tests/fees_test.go b/system_tests/fees_test.go index 4d8fbf43fd..2a53e42a23 100644 --- a/system_tests/fees_test.go +++ b/system_tests/fees_test.go @@ -2,8 +2,10 @@ // For license information, see https://github.com/nitro/blob/master/LICENSE // these tests seems to consume too much memory with race detection -//go:build !race -// +build !race +// Test randomly fails with L1 gas price estimate should tend toward the basefee +// so skipping locally, but running on CI +//go:build !race && feestest +// +build !race,feestest package arbtest From 73be2edc259a64d3b0d8f08ec95afd89caf8eb3f Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Thu, 11 Jul 2024 10:59:46 +0530 Subject: [PATCH 03/11] Changes based on PR comments --- .github/workflows/ci.yml | 2 +- system_tests/fees_test.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 02ef915f16..7fea04de4b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -145,7 +145,7 @@ jobs: if: matrix.test-mode == 'defaults' run: | packages=`go list ./...` - stdbuf -oL gotestsum --format short-verbose --packages="$packages" --rerun-fails=1 --no-color=false -- ./... -coverprofile=coverage.txt -covermode=atomic -coverpkg=./...,./go-ethereum/... -timeout 20m -parallel=8 -tags=feestest > >(stdbuf -oL tee full.log | grep -vE "INFO|seal") + stdbuf -oL gotestsum --format short-verbose --packages="$packages" --rerun-fails=1 --no-color=false -- ./... -coverprofile=coverage.txt -covermode=atomic -coverpkg=./...,./go-ethereum/... -timeout 20m -parallel=8 -tags=cionly > >(stdbuf -oL tee full.log | grep -vE "INFO|seal") - name: run tests with race detection if: matrix.test-mode == 'race' diff --git a/system_tests/fees_test.go b/system_tests/fees_test.go index 2a53e42a23..ccca82e009 100644 --- a/system_tests/fees_test.go +++ b/system_tests/fees_test.go @@ -4,8 +4,8 @@ // these tests seems to consume too much memory with race detection // Test randomly fails with L1 gas price estimate should tend toward the basefee // so skipping locally, but running on CI -//go:build !race && feestest -// +build !race,feestest +//go:build !race && cionly +// +build !race,cionly package arbtest From 9b1faa22de915a41db2acd93d33a0368806f30c3 Mon Sep 17 00:00:00 2001 From: Gabriel de Quadros Ligneul Date: Wed, 10 Jul 2024 13:03:08 -0300 Subject: [PATCH 04/11] Add TestWasmRecreateWithDelegatecall Test that the given Stylus program will be lazily recreated after being called by a Solidity contract with a delegate call. This change modifies the existing recreation test so both tests can share most of the code. --- contracts | 2 +- system_tests/program_test.go | 70 ++++++++++++++++++++++++++++-------- 2 files changed, 57 insertions(+), 15 deletions(-) diff --git a/contracts b/contracts index 61204dd455..9c1d3010e8 160000 --- a/contracts +++ b/contracts @@ -1 +1 @@ -Subproject commit 61204dd455966cb678192427a07aa9795ff91c14 +Subproject commit 9c1d3010e85e920252798077b83b48c6beed26e4 diff --git a/system_tests/program_test.go b/system_tests/program_test.go index b05589a1bf..0164218bad 100644 --- a/system_tests/program_test.go +++ b/system_tests/program_test.go @@ -1668,20 +1668,12 @@ func formatTime(duration time.Duration) string { return fmt.Sprintf("%.2f%s", span, units[unit]) } -func TestWasmRecreate(t *testing.T) { - builder, auth, cleanup := setupProgramTest(t, true) +func testWasmRecreate(t *testing.T, builder *NodeBuilder, storeTx *types.Transaction, loadTx *types.Transaction, want []byte) { ctx := builder.ctx l2info := builder.L2Info l2client := builder.L2.Client - defer cleanup() - - storage := deployWasm(t, ctx, auth, l2client, rustFile("storage")) - - zero := common.Hash{} - val := common.HexToHash("0x121233445566") // do an onchain call - store value - storeTx := l2info.PrepareTxTo("Owner", &storage, l2info.TransferGas, nil, argsForStorageWrite(zero, val)) Require(t, l2client.SendTransaction(ctx, storeTx)) _, err := EnsureTxSucceeded(ctx, l2client, storeTx) Require(t, err) @@ -1694,11 +1686,10 @@ func TestWasmRecreate(t *testing.T) { Require(t, err) // make sure reading 2nd value succeeds from 2nd node - loadTx := l2info.PrepareTxTo("Owner", &storage, l2info.TransferGas, nil, argsForStorageRead(zero)) result, err := arbutil.SendTxAsCall(ctx, nodeB.Client, loadTx, l2info.GetAddress("Owner"), nil, true) Require(t, err) - if common.BytesToHash(result) != val { - Fatal(t, "got wrong value") + if !bytes.Equal(result, want) { + t.Fatalf("got wrong value, got %x, want %x", result, want) } // close nodeB cleanupB() @@ -1723,8 +1714,8 @@ func TestWasmRecreate(t *testing.T) { // test nodeB - answers eth_call (requires reloading wasm) result, err = arbutil.SendTxAsCall(ctx, nodeB.Client, loadTx, l2info.GetAddress("Owner"), nil, true) Require(t, err) - if common.BytesToHash(result) != val { - Fatal(t, "got wrong value") + if !bytes.Equal(result, want) { + t.Fatalf("got wrong value, got %x, want %x", result, want) } // send new tx (requires wasm) and check nodeB sees it as well @@ -1743,7 +1734,58 @@ func TestWasmRecreate(t *testing.T) { Fatal(t, "not contents found before delete") } os.RemoveAll(wasmPath) +} + +func TestWasmRecreate(t *testing.T) { + builder, auth, cleanup := setupProgramTest(t, true) + ctx := builder.ctx + l2info := builder.L2Info + l2client := builder.L2.Client + defer cleanup() + + storage := deployWasm(t, ctx, auth, l2client, rustFile("storage")) + + zero := common.Hash{} + val := common.HexToHash("0x121233445566") + + storeTx := l2info.PrepareTxTo("Owner", &storage, l2info.TransferGas, nil, argsForStorageWrite(zero, val)) + loadTx := l2info.PrepareTxTo("Owner", &storage, l2info.TransferGas, nil, argsForStorageRead(zero)) + + testWasmRecreate(t, builder, storeTx, loadTx, val[:]) +} + +func TestWasmRecreateWithDelegatecall(t *testing.T) { + builder, auth, cleanup := setupProgramTest(t, true) + ctx := builder.ctx + l2info := builder.L2Info + l2client := builder.L2.Client + defer cleanup() + + storage := deployWasm(t, ctx, auth, l2client, rustFile("storage")) + + zero := common.Hash{} + val := common.HexToHash("0x121233445566") + + // deploy mock that contains the delegatecall method + mock, tx, _, err := mocksgen.DeployProgramTest(&auth, l2client) + Require(t, err) + _, err = EnsureTxSucceeded(ctx, l2client, tx) + Require(t, err) + mockAbi, err := mocksgen.ProgramTestMetaData.GetAbi() + Require(t, err) + + data, err := mockAbi.Pack("delegatecallProgram", storage, argsForStorageWrite(zero, val)) + Require(t, err) + storeTx := l2info.PrepareTxTo("Owner", &mock, l2info.TransferGas, nil, data) + + data, err = mockAbi.Pack("delegatecallProgram", storage, argsForStorageRead(zero)) + Require(t, err) + loadTx := l2info.PrepareTxTo("Owner", &mock, l2info.TransferGas, nil, data) + + want, err := mockAbi.Methods["delegatecallProgram"].Outputs.Pack(val[:]) + Require(t, err) + testWasmRecreate(t, builder, storeTx, loadTx, want) } // createMapFromDb is used in verifying if wasm store rebuilding works From 228d1160f15b10bef7736183c911b958175f8f89 Mon Sep 17 00:00:00 2001 From: Gabriel de Quadros Ligneul Date: Fri, 12 Jul 2024 14:29:01 -0300 Subject: [PATCH 05/11] Revert contracts submodule change --- contracts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts b/contracts index 9c1d3010e8..61204dd455 160000 --- a/contracts +++ b/contracts @@ -1 +1 @@ -Subproject commit 9c1d3010e85e920252798077b83b48c6beed26e4 +Subproject commit 61204dd455966cb678192427a07aa9795ff91c14 From d3b8732f7e2143e32d44271f08235a52be7f82ab Mon Sep 17 00:00:00 2001 From: Gabriel de Quadros Ligneul Date: Fri, 12 Jul 2024 15:01:41 -0300 Subject: [PATCH 06/11] Use multicall Stylus contract to delegate call --- system_tests/program_test.go | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/system_tests/program_test.go b/system_tests/program_test.go index 0164218bad..b748739cdc 100644 --- a/system_tests/program_test.go +++ b/system_tests/program_test.go @@ -1762,30 +1762,18 @@ func TestWasmRecreateWithDelegatecall(t *testing.T) { defer cleanup() storage := deployWasm(t, ctx, auth, l2client, rustFile("storage")) + multicall := deployWasm(t, ctx, auth, l2client, rustFile("multicall")) zero := common.Hash{} val := common.HexToHash("0x121233445566") - // deploy mock that contains the delegatecall method - mock, tx, _, err := mocksgen.DeployProgramTest(&auth, l2client) - Require(t, err) - _, err = EnsureTxSucceeded(ctx, l2client, tx) - Require(t, err) - mockAbi, err := mocksgen.ProgramTestMetaData.GetAbi() - Require(t, err) - - data, err := mockAbi.Pack("delegatecallProgram", storage, argsForStorageWrite(zero, val)) - Require(t, err) - storeTx := l2info.PrepareTxTo("Owner", &mock, l2info.TransferGas, nil, data) + data := argsForMulticall(vm.DELEGATECALL, storage, big.NewInt(0), argsForStorageWrite(zero, val)) + storeTx := l2info.PrepareTxTo("Owner", &multicall, l2info.TransferGas, nil, data) - data, err = mockAbi.Pack("delegatecallProgram", storage, argsForStorageRead(zero)) - Require(t, err) - loadTx := l2info.PrepareTxTo("Owner", &mock, l2info.TransferGas, nil, data) + data = argsForMulticall(vm.DELEGATECALL, storage, big.NewInt(0), argsForStorageRead(zero)) + loadTx := l2info.PrepareTxTo("Owner", &multicall, l2info.TransferGas, nil, data) - want, err := mockAbi.Methods["delegatecallProgram"].Outputs.Pack(val[:]) - Require(t, err) - - testWasmRecreate(t, builder, storeTx, loadTx, want) + testWasmRecreate(t, builder, storeTx, loadTx, val[:]) } // createMapFromDb is used in verifying if wasm store rebuilding works From c96a07e1d5de74768e287d9a994c9fb84e072a2c Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Mon, 15 Jul 2024 15:46:08 +0530 Subject: [PATCH 07/11] Merge v1.13.13 --- go-ethereum | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go-ethereum b/go-ethereum index e35bf9cdd3..90b36cf0b8 160000 --- a/go-ethereum +++ b/go-ethereum @@ -1 +1 @@ -Subproject commit e35bf9cdd3d02034ac1be34a479d101f12012ba6 +Subproject commit 90b36cf0b87b96e0a74acf91d9603b341d8165d4 From df164cd61630de5e483fee1e5fbca6aa8c2f34f0 Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Mon, 15 Jul 2024 15:48:52 +0530 Subject: [PATCH 08/11] update module --- go-ethereum | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go-ethereum b/go-ethereum index 90b36cf0b8..7c6e05f753 160000 --- a/go-ethereum +++ b/go-ethereum @@ -1 +1 @@ -Subproject commit 90b36cf0b87b96e0a74acf91d9603b341d8165d4 +Subproject commit 7c6e05f75337d59562a6e2b8e1bdf1e445ad14fb From 47bfc4c1c60840bd3516ab0aeee731759801f798 Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Mon, 15 Jul 2024 16:09:04 +0530 Subject: [PATCH 09/11] update import --- cmd/staterecovery/staterecovery.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/staterecovery/staterecovery.go b/cmd/staterecovery/staterecovery.go index 58ad06ad14..a7de58b2c9 100644 --- a/cmd/staterecovery/staterecovery.go +++ b/cmd/staterecovery/staterecovery.go @@ -10,7 +10,7 @@ import ( "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/trie" - "github.com/ethereum/go-ethereum/trie/triedb/hashdb" + "github.com/ethereum/go-ethereum/triedb/hashdb" ) func RecreateMissingStates(chainDb ethdb.Database, bc *core.BlockChain, cacheConfig *core.CacheConfig, startBlock uint64) error { From 3942bc500dcd61a110332cbc08fb59614c98b818 Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Mon, 15 Jul 2024 17:03:36 +0530 Subject: [PATCH 10/11] fix --- cmd/staterecovery/staterecovery.go | 4 ++-- go.mod | 4 ++-- go.sum | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cmd/staterecovery/staterecovery.go b/cmd/staterecovery/staterecovery.go index a7de58b2c9..19ed51ef2d 100644 --- a/cmd/staterecovery/staterecovery.go +++ b/cmd/staterecovery/staterecovery.go @@ -9,7 +9,7 @@ import ( "github.com/ethereum/go-ethereum/core/vm" "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/log" - "github.com/ethereum/go-ethereum/trie" + "github.com/ethereum/go-ethereum/triedb" "github.com/ethereum/go-ethereum/triedb/hashdb" ) @@ -32,7 +32,7 @@ func RecreateMissingStates(chainDb ethdb.Database, bc *core.BlockChain, cacheCon } hashConfig := *hashdb.Defaults hashConfig.CleanCacheSize = cacheConfig.TrieCleanLimit * 1024 * 1024 - trieConfig := &trie.Config{ + trieConfig := &triedb.Config{ Preimages: false, HashDB: &hashConfig, } diff --git a/go.mod b/go.mod index 00cee1a99a..d0c8d5e719 100644 --- a/go.mod +++ b/go.mod @@ -118,7 +118,7 @@ require ( github.com/graph-gophers/graphql-go v1.3.0 // indirect github.com/h2non/filetype v1.0.6 // indirect github.com/hashicorp/go-bexpr v0.1.10 // indirect - github.com/holiman/billy v0.0.0-20230718173358-1c7e68d277a7 // indirect + github.com/holiman/billy v0.0.0-20240216141850-2abb0c79d3c4 // indirect github.com/holiman/bloomfilter/v2 v2.0.3 // indirect github.com/huin/goupnp v1.3.0 // indirect github.com/jackpal/go-nat-pmp v1.0.2 // indirect @@ -162,7 +162,7 @@ require ( go.opencensus.io v0.22.5 // indirect golang.org/x/mod v0.14.0 // indirect golang.org/x/net v0.21.0 // indirect - golang.org/x/sync v0.5.0 // indirect + golang.org/x/sync v0.5.0 golang.org/x/text v0.14.0 // indirect golang.org/x/time v0.3.0 // indirect google.golang.org/protobuf v1.30.0 // indirect diff --git a/go.sum b/go.sum index 8676c270c4..ff4726b22f 100644 --- a/go.sum +++ b/go.sum @@ -420,8 +420,8 @@ github.com/hashicorp/vault/api v1.0.4/go.mod h1:gDcqh3WGcR1cpF5AJz/B1UFheUEneMoI github.com/hashicorp/vault/sdk v0.1.13/go.mod h1:B+hVj7TpuQY1Y/GPbCpffmgd+tSEwvhkWnjtSYCaS2M= github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= -github.com/holiman/billy v0.0.0-20230718173358-1c7e68d277a7 h1:3JQNjnMRil1yD0IfZKHF9GxxWKDJGj8I0IqOUol//sw= -github.com/holiman/billy v0.0.0-20230718173358-1c7e68d277a7/go.mod h1:5GuXa7vkL8u9FkFuWdVvfR5ix8hRB7DbOAaYULamFpc= +github.com/holiman/billy v0.0.0-20240216141850-2abb0c79d3c4 h1:X4egAf/gcS1zATw6wn4Ej8vjuVGxeHdan+bRb2ebyv4= +github.com/holiman/billy v0.0.0-20240216141850-2abb0c79d3c4/go.mod h1:5GuXa7vkL8u9FkFuWdVvfR5ix8hRB7DbOAaYULamFpc= github.com/holiman/bloomfilter/v2 v2.0.3 h1:73e0e/V0tCydx14a0SCYS/EWCxgwLZ18CZcZKVu0fao= github.com/holiman/bloomfilter/v2 v2.0.3/go.mod h1:zpoh+gs7qcpqrHr3dB55AMiJwo0iURXE7ZOP9L9hSkA= github.com/holiman/uint256 v1.2.4 h1:jUc4Nk8fm9jZabQuqr2JzednajVmBpC+oiTiXZJEApU= From 74da3216fa1430c74e617a6498a83e728f2943df Mon Sep 17 00:00:00 2001 From: Aman Sanghi Date: Mon, 15 Jul 2024 17:22:47 +0530 Subject: [PATCH 11/11] fix --- system_tests/test_info.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/system_tests/test_info.go b/system_tests/test_info.go index 764a8ae396..ee84564bdc 100644 --- a/system_tests/test_info.go +++ b/system_tests/test_info.go @@ -16,7 +16,6 @@ import ( "github.com/ethereum/go-ethereum/accounts/abi/bind" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/log" @@ -110,8 +109,8 @@ func (b *BlockchainTestInfo) GenerateGenesisAccount(name string, balance *big.In }) } -func (b *BlockchainTestInfo) GetGenesisAlloc() core.GenesisAlloc { - alloc := make(core.GenesisAlloc) +func (b *BlockchainTestInfo) GetGenesisAlloc() types.GenesisAlloc { + alloc := make(types.GenesisAlloc) for _, info := range b.ArbInitData.Accounts { var contractCode []byte contractStorage := make(map[common.Hash]common.Hash) @@ -121,7 +120,7 @@ func (b *BlockchainTestInfo) GetGenesisAlloc() core.GenesisAlloc { contractStorage[k] = v } } - alloc[info.Addr] = core.GenesisAccount{ + alloc[info.Addr] = types.Account{ Balance: new(big.Int).Set(info.EthBalance), Nonce: info.Nonce, Code: contractCode,