Skip to content

Commit

Permalink
Merge branch 'master' into multi-act-wasm
Browse files Browse the repository at this point in the history
  • Loading branch information
eljobe committed Jul 18, 2024
2 parents 5382ce5 + b066a58 commit 84f63be
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 26 deletions.
6 changes: 3 additions & 3 deletions cmd/staterecovery/staterecovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ 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/trie/triedb/hashdb"
"github.com/ethereum/go-ethereum/triedb"
"github.com/ethereum/go-ethereum/triedb/hashdb"
)

func RecreateMissingStates(chainDb ethdb.Database, bc *core.BlockChain, cacheConfig *core.CacheConfig, startBlock uint64) error {
Expand All @@ -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,
}
Expand Down
2 changes: 1 addition & 1 deletion go-ethereum
Submodule go-ethereum updated 164 files
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
58 changes: 44 additions & 14 deletions system_tests/program_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1694,20 +1694,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)
Expand All @@ -1720,11 +1712,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()
Expand All @@ -1749,8 +1740,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
Expand All @@ -1769,7 +1760,46 @@ 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"))
multicall := deployWasm(t, ctx, auth, l2client, rustFile("multicall"))

zero := common.Hash{}
val := common.HexToHash("0x121233445566")

data := argsForMulticall(vm.DELEGATECALL, storage, big.NewInt(0), argsForStorageWrite(zero, val))
storeTx := l2info.PrepareTxTo("Owner", &multicall, l2info.TransferGas, nil, data)

data = argsForMulticall(vm.DELEGATECALL, storage, big.NewInt(0), argsForStorageRead(zero))
loadTx := l2info.PrepareTxTo("Owner", &multicall, l2info.TransferGas, nil, data)

testWasmRecreate(t, builder, storeTx, loadTx, val[:])
}

// createMapFromDb is used in verifying if wasm store rebuilding works
Expand Down
7 changes: 3 additions & 4 deletions system_tests/test_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -109,8 +108,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)
Expand All @@ -120,7 +119,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,
Expand Down

0 comments on commit 84f63be

Please sign in to comment.