From 1251a256d470bbbafd802c983cc3dbc8855d034a Mon Sep 17 00:00:00 2001 From: Ignacio Hagopian Date: Tue, 30 Jul 2024 17:23:42 -0300 Subject: [PATCH 01/27] t8n: verkle-genesis Signed-off-by: Ignacio Hagopian --- cmd/evm/internal/t8ntool/execution.go | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/cmd/evm/internal/t8ntool/execution.go b/cmd/evm/internal/t8ntool/execution.go index 609716dbbf3a..0d1a7b3ff5ba 100644 --- a/cmd/evm/internal/t8ntool/execution.go +++ b/cmd/evm/internal/t8ntool/execution.go @@ -185,17 +185,14 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig, GasLimit: pre.Env.GasLimit, GetHash: getHash, } - // Save pre verkle tree to build the proof at the end - if pre.VKT != nil && len(pre.VKT) > 0 { - switch tr := statedb.GetTrie().(type) { - case *trie.VerkleTrie: - vtrpre = tr.Copy() - case *trie.TransitionTrie: - vtrpre = tr.Overlay().Copy() - default: - panic("invalid trie type") - } + + switch tr := statedb.GetTrie().(type) { + case *trie.VerkleTrie: + vtrpre = tr.Copy() + case *trie.TransitionTrie: + vtrpre = tr.Overlay().Copy() } + // If currentBaseFee is defined, add it to the vmContext. if pre.Env.BaseFee != nil { vmContext.BaseFee = new(big.Int).Set(pre.Env.BaseFee) @@ -428,6 +425,11 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig, func MakePreState(db ethdb.Database, chainConfig *params.ChainConfig, pre *Prestate, verkle bool) *state.StateDB { // Start with generating the MPT DB, which should be empty if it's post-verkle transition sdb := state.NewDatabaseWithConfig(db, &trie.Config{Preimages: true, Verkle: false}) + + // TODO: this only works for verkle-genesis tests. We can fix this line whenever the testing infra sends the correct + // started/ended transition flags in env for verkle-genesis tests. + sdb.InitTransitionStatus(true, true, common.Hash{}) + statedb, _ := state.New(types.EmptyRootHash, sdb, nil) // MPT pre is the same as the pre state for first conversion block @@ -448,6 +450,11 @@ func MakePreState(db ethdb.Database, chainConfig *params.ChainConfig, pre *Prest if err != nil { panic(err) } + + if _, ok := statedb.GetTrie().(*trie.VerkleTrie); ok { + return statedb + } + rawdb.WritePreimages(sdb.DiskDB(), statedb.Preimages()) sdb.TrieDB().WritePreimages() snaps, err := snapshot.New(snapshot.Config{AsyncBuild: false, CacheSize: 10}, sdb.DiskDB(), sdb.TrieDB(), mptRoot) From cb40b1b4bd7219410ed941526f80915e9f9f9a6e Mon Sep 17 00:00:00 2001 From: Ignacio Hagopian Date: Wed, 31 Jul 2024 07:54:18 -0300 Subject: [PATCH 02/27] review feedback Signed-off-by: Ignacio Hagopian --- cmd/evm/internal/t8ntool/execution.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmd/evm/internal/t8ntool/execution.go b/cmd/evm/internal/t8ntool/execution.go index 0d1a7b3ff5ba..1e3f42388429 100644 --- a/cmd/evm/internal/t8ntool/execution.go +++ b/cmd/evm/internal/t8ntool/execution.go @@ -186,6 +186,8 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig, GetHash: getHash, } + // We save the current state of the Verkle Tree before applying the transactions. + // Note that if the Verkle fork isn't active, this will be a noop. switch tr := statedb.GetTrie().(type) { case *trie.VerkleTrie: vtrpre = tr.Copy() @@ -451,6 +453,8 @@ func MakePreState(db ethdb.Database, chainConfig *params.ChainConfig, pre *Prest panic(err) } + // If the current tree is a VerkleTrie, it means the state conversion has ended. + // We don't need to continue with conversion setups and can return early. if _, ok := statedb.GetTrie().(*trie.VerkleTrie); ok { return statedb } From 8ff94100b137d6a25928720180a047d4046e8d93 Mon Sep 17 00:00:00 2001 From: Ignacio Hagopian Date: Thu, 1 Aug 2024 11:23:05 -0300 Subject: [PATCH 03/27] imprv Signed-off-by: Ignacio Hagopian --- cmd/evm/internal/t8ntool/execution.go | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/cmd/evm/internal/t8ntool/execution.go b/cmd/evm/internal/t8ntool/execution.go index 1e3f42388429..40db78ad28a6 100644 --- a/cmd/evm/internal/t8ntool/execution.go +++ b/cmd/evm/internal/t8ntool/execution.go @@ -428,12 +428,26 @@ func MakePreState(db ethdb.Database, chainConfig *params.ChainConfig, pre *Prest // Start with generating the MPT DB, which should be empty if it's post-verkle transition sdb := state.NewDatabaseWithConfig(db, &trie.Config{Preimages: true, Verkle: false}) - // TODO: this only works for verkle-genesis tests. We can fix this line whenever the testing infra sends the correct - // started/ended transition flags in env for verkle-genesis tests. - sdb.InitTransitionStatus(true, true, common.Hash{}) + if pre.Env.Ended != nil && *pre.Env.Ended { + sdb.InitTransitionStatus(true, true, common.Hash{}) + } statedb, _ := state.New(types.EmptyRootHash, sdb, nil) + if pre.Env.Ended != nil && *pre.Env.Ended { + vtr := statedb.GetTrie().(*trie.VerkleTrie) + + // create the vkt, should be empty on first insert + for k, v := range pre.VKT { + values := make([][]byte, 256) + values[k[31]] = make([]byte, 32) + copy(values[k[31]], v) + vtr.UpdateStem(k.Bytes(), values) + } + + return statedb + } + // MPT pre is the same as the pre state for first conversion block for addr, a := range pre.Pre { statedb.SetCode(addr, a.Code) From 3edbc5b87cf30a71f6d2c77df3b68909dcaf1911 Mon Sep 17 00:00:00 2001 From: Ignacio Hagopian Date: Fri, 2 Aug 2024 11:51:58 -0300 Subject: [PATCH 04/27] t8n/evm: add new cli command Signed-off-by: Ignacio Hagopian --- cmd/evm/internal/t8ntool/transition.go | 79 ++++++++++++++++++-------- cmd/evm/main.go | 9 +++ 2 files changed, 65 insertions(+), 23 deletions(-) diff --git a/cmd/evm/internal/t8ntool/transition.go b/cmd/evm/internal/t8ntool/transition.go index d525a68c0650..5a8723761f87 100644 --- a/cmd/evm/internal/t8ntool/transition.go +++ b/cmd/evm/internal/t8ntool/transition.go @@ -548,13 +548,65 @@ func VerkleKeys(ctx *cli.Context) error { } } + vkt, err := genVktFromAlloc(alloc) + if err != nil { + return fmt.Errorf("error generating vkt: %w", err) + } + + collector := make(map[common.Hash]hexutil.Bytes) + it, err := vkt.NodeIterator(nil) + if err != nil { + panic(err) + } + for it.Next(true) { + if it.Leaf() { + collector[common.BytesToHash(it.LeafKey())] = it.LeafBlob() + } + } + + output, err := json.MarshalIndent(collector, "", "") + if err != nil { + return fmt.Errorf("error outputting tree: %w", err) + } + + fmt.Println(string(output)) + + return nil +} + +// VerkleRoot computes the root of a VKT from a genesis alloc. +func VerkleRoot(ctx *cli.Context) error { + var allocStr = ctx.String(InputAllocFlag.Name) + var alloc core.GenesisAlloc + if allocStr == stdinSelector { + decoder := json.NewDecoder(os.Stdin) + if err := decoder.Decode(&alloc); err != nil { + return NewError(ErrorJson, fmt.Errorf("failed unmarshaling stdin: %v", err)) + } + } + if allocStr != stdinSelector { + if err := readFile(allocStr, "alloc", &alloc); err != nil { + return err + } + } + + vkt, err := genVktFromAlloc(alloc) + if err != nil { + return fmt.Errorf("error generating vkt: %w", err) + } + fmt.Println(vkt.Hash().Hex()) + + return nil +} + +func genVktFromAlloc(alloc core.GenesisAlloc) (*trie.VerkleTrie, error) { vkt := trie.NewVerkleTrie(verkle.New(), trie.NewDatabase(rawdb.NewMemoryDatabase()), utils.NewPointCache(), true) for addr, acc := range alloc { for slot, value := range acc.Storage { err := vkt.UpdateStorage(addr, slot.Bytes(), value.Big().Bytes()) if err != nil { - return fmt.Errorf("error inserting storage: %w", err) + return nil, fmt.Errorf("error inserting storage: %w", err) } } @@ -566,34 +618,15 @@ func VerkleKeys(ctx *cli.Context) error { } err := vkt.UpdateAccount(addr, account) if err != nil { - return fmt.Errorf("error inserting account: %w", err) + return nil, fmt.Errorf("error inserting account: %w", err) } err = vkt.UpdateContractCode(addr, common.BytesToHash(account.CodeHash), acc.Code) if err != nil { - return fmt.Errorf("error inserting code: %w", err) - } - } - - collector := make(map[common.Hash]hexutil.Bytes) - it, err := vkt.NodeIterator(nil) - if err != nil { - panic(err) - } - for it.Next(true) { - if it.Leaf() { - collector[common.BytesToHash(it.LeafKey())] = it.LeafBlob() + return nil, fmt.Errorf("error inserting code: %w", err) } } - - output, err := json.MarshalIndent(collector, "", "") - if err != nil { - return fmt.Errorf("error outputting tree: %w", err) - } - - fmt.Println(string(output)) - - return nil + return vkt, nil } // VerkleCodeChunkKey computes the tree key of a code-chunk for a given address. diff --git a/cmd/evm/main.go b/cmd/evm/main.go index b2f70f0930f2..465148e8358d 100644 --- a/cmd/evm/main.go +++ b/cmd/evm/main.go @@ -188,6 +188,15 @@ var verkleCommand = &cli.Command{ Usage: "chunkify a given bytecode", Action: t8ntool.VerkleChunkifyCode, }, + { + Name: "state-root", + Aliases: []string{"VR"}, + Usage: "compute the state-root of a verkle tree for the given alloc", + Action: t8ntool.VerkleRoot, + Flags: []cli.Flag{ + t8ntool.InputAllocFlag, + }, + }, }, } From a3a612c1a41e7cd70ac4ac0b7ee902363418d36b Mon Sep 17 00:00:00 2001 From: Ignacio Hagopian Date: Sat, 3 Aug 2024 12:46:56 -0300 Subject: [PATCH 05/27] fixes to run conversion fixture Signed-off-by: Ignacio Hagopian --- cmd/evm/blockrunner.go | 2 +- core/genesis.go | 15 ++++++++++++++- tests/block_test_util.go | 2 +- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/cmd/evm/blockrunner.go b/cmd/evm/blockrunner.go index ffd3165f5569..cddd486d3064 100644 --- a/cmd/evm/blockrunner.go +++ b/cmd/evm/blockrunner.go @@ -64,7 +64,7 @@ func blockTestCmd(ctx *cli.Context) error { return err } for i, test := range tests { - if err := test.Run(false, tracer); err != nil { + if err := test.Run(true, tracer); err != nil { return fmt.Errorf("test %v: %w", i, err) } } diff --git a/core/genesis.go b/core/genesis.go index a5803644f4fe..93192472d2b5 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -30,6 +30,7 @@ import ( "github.com/ethereum/go-ethereum/common/math" "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/core/state" + "github.com/ethereum/go-ethereum/core/state/snapshot" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/ethdb" @@ -172,6 +173,18 @@ func (ga *GenesisAlloc) flush(db ethdb.Database, triedb *trie.Database, blockhas if err != nil { return err } + + sdb := database + sdb.TrieDB().WritePreimages() + snaps, err := snapshot.New(snapshot.Config{AsyncBuild: false, CacheSize: 10}, sdb.DiskDB(), sdb.TrieDB(), types.EmptyRootHash) + if err != nil { + panic(err) + } + if snaps == nil { + panic("snapshot is nil") + } + snaps.Cap(types.EmptyRootHash, 0) + // Commit newly generated states into disk if it's not empty. if root != types.EmptyRootHash { if err := triedb.Commit(root, true); err != nil { @@ -560,7 +573,7 @@ func (g *Genesis) Commit(db ethdb.Database, triedb *trie.Database) (*types.Block // Note the state changes will be committed in hash-based scheme, use Commit // if path-scheme is preferred. func (g *Genesis) MustCommit(db ethdb.Database) *types.Block { - triedb := trie.NewDatabaseWithConfig(db, &trie.Config{Verkle: g.Config != nil && g.Config.IsVerkle(big.NewInt(int64(g.Number)), g.Timestamp)}) + triedb := trie.NewDatabaseWithConfig(db, &trie.Config{Verkle: g.Config != nil && g.Config.IsVerkle(big.NewInt(int64(g.Number)), g.Timestamp), Preimages: true}) block, err := g.Commit(db, triedb) if err != nil { panic(err) diff --git a/tests/block_test_util.go b/tests/block_test_util.go index d3e525a387e3..0fafa103efc7 100644 --- a/tests/block_test_util.go +++ b/tests/block_test_util.go @@ -148,7 +148,7 @@ func (t *BlockTest) Run(snapshotter bool, tracer vm.EVMLogger) error { return fmt.Errorf("post state validation failed: %v", err) } // Cross-check the snapshot-to-hash against the trie hash - if snapshotter { + if snapshotter && false { if err := chain.Snapshots().Verify(chain.CurrentBlock().Root); err != nil { return err } From cf22fe917857dd007da61f0541c498af6bb6793d Mon Sep 17 00:00:00 2001 From: Ignacio Hagopian Date: Tue, 6 Aug 2024 09:04:33 -0300 Subject: [PATCH 06/27] t8n/evm: use pre alloc to save code in rawdb Signed-off-by: Ignacio Hagopian --- cmd/evm/internal/t8ntool/execution.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cmd/evm/internal/t8ntool/execution.go b/cmd/evm/internal/t8ntool/execution.go index 40db78ad28a6..01d23052a877 100644 --- a/cmd/evm/internal/t8ntool/execution.go +++ b/cmd/evm/internal/t8ntool/execution.go @@ -445,6 +445,12 @@ func MakePreState(db ethdb.Database, chainConfig *params.ChainConfig, pre *Prest vtr.UpdateStem(k.Bytes(), values) } + codeWriter := statedb.Database().DiskDB() + for _, acc := range pre.Pre { + codeHash := crypto.Keccak256Hash(acc.Code) + rawdb.WriteCode(codeWriter, codeHash, acc.Code) + } + return statedb } From 10967b8e5eaadc33f43d6774fa8a06d22fcd16e2 Mon Sep 17 00:00:00 2001 From: Ignacio Hagopian Date: Tue, 6 Aug 2024 09:12:10 -0300 Subject: [PATCH 07/27] vm: fix gas underflow Signed-off-by: Ignacio Hagopian --- core/vm/interpreter.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/vm/interpreter.go b/core/vm/interpreter.go index f355bb68a030..30c3ec0c3126 100644 --- a/core/vm/interpreter.go +++ b/core/vm/interpreter.go @@ -183,7 +183,9 @@ func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool) ( // if the PC ends up in a new "chunk" of verkleized code, charge the // associated costs. contractAddr := contract.Address() - contract.Gas -= in.evm.TxContext.Accesses.TouchCodeChunksRangeAndChargeGas(contractAddr[:], pc, 1, uint64(len(contract.Code)), false) + if !contract.UseGas(in.evm.TxContext.Accesses.TouchCodeChunksRangeAndChargeGas(contractAddr[:], pc, 1, uint64(len(contract.Code)), false)) { + return nil, ErrOutOfGas + } } // Get the operation from the jump table and validate the stack to ensure there are From 679b9b138567f14e61e4b2fcee38a9572288f1b3 Mon Sep 17 00:00:00 2001 From: Ignacio Hagopian Date: Tue, 6 Aug 2024 10:28:18 -0300 Subject: [PATCH 08/27] ci: add verkle-genesis filling and consumption Signed-off-by: Ignacio Hagopian --- .github/workflows/spectests-genesis.yml | 37 +++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .github/workflows/spectests-genesis.yml diff --git a/.github/workflows/spectests-genesis.yml b/.github/workflows/spectests-genesis.yml new file mode 100644 index 000000000000..7c6215948377 --- /dev/null +++ b/.github/workflows/spectests-genesis.yml @@ -0,0 +1,37 @@ +name: Execution spec tests + +on: + push: + branches: [master] + pull_request: + branches: [master, kaustinen-with-shapella] + workflow_dispatch: + +jobs: + spectests: + runs-on: self-hosted + steps: + - uses: actions/checkout@v2 + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: "3.12.4" + # python-version: 'pypy3.10' + cache: "" + - name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.22.4 + - name: Fill tests + run: | + export PATH=$PATH:/home/devops/.cargo/bin + go build -v ./cmd/evm + git clone https://github.com/jsign/execution-spec-tests -b jsign-verkle-rebased-mainnet + cd execution-spec-tests + python3 -m venv venv + . ./venv/bin/activate + pip install -e ".[docs,lint,test]" + + fill --fork Verkle -n 4 --evm-dump-dir=../tmp -v -m blockchain_test --evm-bin=../evm -k eip6800_genesis + - name: Consume tests + run: find ./tmp -type f | xargs ./evm blocktest From bd6b3b6b00cfdbd0e99f1e6cbc52223fcf7c7723 Mon Sep 17 00:00:00 2001 From: Ignacio Hagopian Date: Wed, 7 Aug 2024 09:25:09 -0300 Subject: [PATCH 09/27] ci: update runner Signed-off-by: Ignacio Hagopian --- .github/workflows/spectests-genesis.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/spectests-genesis.yml b/.github/workflows/spectests-genesis.yml index 7c6215948377..3ecc79e7d914 100644 --- a/.github/workflows/spectests-genesis.yml +++ b/.github/workflows/spectests-genesis.yml @@ -9,14 +9,13 @@ on: jobs: spectests: - runs-on: self-hosted + runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Setup Python uses: actions/setup-python@v5 with: python-version: "3.12.4" - # python-version: 'pypy3.10' cache: "" - name: Set up Go uses: actions/setup-go@v2 From 33ba03afb917237b5d5b1e359756c0991bd7a3e9 Mon Sep 17 00:00:00 2001 From: Ignacio Hagopian Date: Wed, 7 Aug 2024 09:29:22 -0300 Subject: [PATCH 10/27] ci: fixes Signed-off-by: Ignacio Hagopian --- .github/workflows/spectests-genesis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/spectests-genesis.yml b/.github/workflows/spectests-genesis.yml index 3ecc79e7d914..6a3910a7d65e 100644 --- a/.github/workflows/spectests-genesis.yml +++ b/.github/workflows/spectests-genesis.yml @@ -30,6 +30,8 @@ jobs: python3 -m venv venv . ./venv/bin/activate pip install -e ".[docs,lint,test]" + solc-select install 0.8.20 + solc-select use 0.8.20 fill --fork Verkle -n 4 --evm-dump-dir=../tmp -v -m blockchain_test --evm-bin=../evm -k eip6800_genesis - name: Consume tests From d186f34b02ebf8ba768fc8a16ed3f6e9e94cf133 Mon Sep 17 00:00:00 2001 From: Ignacio Hagopian Date: Wed, 7 Aug 2024 09:41:27 -0300 Subject: [PATCH 11/27] ci: use consume direct to run fixtures Signed-off-by: Ignacio Hagopian --- .github/workflows/spectests-genesis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/spectests-genesis.yml b/.github/workflows/spectests-genesis.yml index 6a3910a7d65e..6d63ac445026 100644 --- a/.github/workflows/spectests-genesis.yml +++ b/.github/workflows/spectests-genesis.yml @@ -33,6 +33,6 @@ jobs: solc-select install 0.8.20 solc-select use 0.8.20 - fill --fork Verkle -n 4 --evm-dump-dir=../tmp -v -m blockchain_test --evm-bin=../evm -k eip6800_genesis + fill --fork Verkle -n 4 -v -m blockchain_test --evm-bin=../evm -k eip6800_genesis - name: Consume tests - run: find ./tmp -type f | xargs ./evm blocktest + run: consume direct --evm-bin=$(pwd)/evm --input=fixtures/blockchain_tests/ -v From a9ee2e2bbfd78f040b48038ef955b5915c19268b Mon Sep 17 00:00:00 2001 From: Ignacio Hagopian Date: Wed, 7 Aug 2024 10:16:45 -0300 Subject: [PATCH 12/27] ci: fixes Signed-off-by: Ignacio Hagopian --- .github/workflows/spectests-genesis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/spectests-genesis.yml b/.github/workflows/spectests-genesis.yml index 6d63ac445026..141d73dbddbb 100644 --- a/.github/workflows/spectests-genesis.yml +++ b/.github/workflows/spectests-genesis.yml @@ -34,5 +34,5 @@ jobs: solc-select use 0.8.20 fill --fork Verkle -n 4 -v -m blockchain_test --evm-bin=../evm -k eip6800_genesis - - name: Consume tests - run: consume direct --evm-bin=$(pwd)/evm --input=fixtures/blockchain_tests/ -v + + consume direct --evm-bin=../evm --input=fixtures/blockchain_tests/ -v From 3433b45c8ecc7005758762912d852b18adf47f0a Mon Sep 17 00:00:00 2001 From: Ignacio Hagopian Date: Wed, 7 Aug 2024 10:22:17 -0300 Subject: [PATCH 13/27] ci: include 4762 Signed-off-by: Ignacio Hagopian --- .github/workflows/spectests-genesis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/spectests-genesis.yml b/.github/workflows/spectests-genesis.yml index 141d73dbddbb..e73998e08fdd 100644 --- a/.github/workflows/spectests-genesis.yml +++ b/.github/workflows/spectests-genesis.yml @@ -21,7 +21,7 @@ jobs: uses: actions/setup-go@v2 with: go-version: 1.22.4 - - name: Fill tests + - name: Fill & consume tests run: | export PATH=$PATH:/home/devops/.cargo/bin go build -v ./cmd/evm @@ -34,5 +34,6 @@ jobs: solc-select use 0.8.20 fill --fork Verkle -n 4 -v -m blockchain_test --evm-bin=../evm -k eip6800_genesis + fill --fork Verkle -n 4 -v -m blockchain_test --evm-bin=../evm -k eip4762 consume direct --evm-bin=../evm --input=fixtures/blockchain_tests/ -v From 90db7db835ccce205e646da74cc33a1fb34a0ab1 Mon Sep 17 00:00:00 2001 From: Ignacio Hagopian Date: Wed, 7 Aug 2024 13:10:22 -0300 Subject: [PATCH 14/27] ci: add transition tests Signed-off-by: Ignacio Hagopian --- .github/workflows/spectests-genesis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/spectests-genesis.yml b/.github/workflows/spectests-genesis.yml index e73998e08fdd..1a69e6151971 100644 --- a/.github/workflows/spectests-genesis.yml +++ b/.github/workflows/spectests-genesis.yml @@ -33,6 +33,7 @@ jobs: solc-select install 0.8.20 solc-select use 0.8.20 + fill --fork EIP6800Transition -n 4 -v -m blockchain_test --evm-bin=../evm -k test_verkle_from_mpt_conversion fill --fork Verkle -n 4 -v -m blockchain_test --evm-bin=../evm -k eip6800_genesis fill --fork Verkle -n 4 -v -m blockchain_test --evm-bin=../evm -k eip4762 From 308e8021395e7bcb1e7c540bd021c1c09230623b Mon Sep 17 00:00:00 2001 From: Ignacio Hagopian Date: Wed, 7 Aug 2024 13:11:04 -0300 Subject: [PATCH 15/27] ci: parallelize running Signed-off-by: Ignacio Hagopian --- .github/workflows/spectests-genesis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/spectests-genesis.yml b/.github/workflows/spectests-genesis.yml index 1a69e6151971..350fcdcb3a74 100644 --- a/.github/workflows/spectests-genesis.yml +++ b/.github/workflows/spectests-genesis.yml @@ -37,4 +37,4 @@ jobs: fill --fork Verkle -n 4 -v -m blockchain_test --evm-bin=../evm -k eip6800_genesis fill --fork Verkle -n 4 -v -m blockchain_test --evm-bin=../evm -k eip4762 - consume direct --evm-bin=../evm --input=fixtures/blockchain_tests/ -v + consume direct --evm-bin=../evm --input=fixtures/blockchain_tests/ -v -n 8 From 47addd7be52f2e07743aa2f4710236f463c5afdf Mon Sep 17 00:00:00 2001 From: spencer Date: Thu, 8 Aug 2024 13:00:01 +0100 Subject: [PATCH 16/27] ci: include conversion tests | use matrix. (#470) * feat: tweak eest ci (matrix). * chore: remove prev ci. --- .github/workflows/spec-tests.yml | 118 ++++++++++++++++++++++++ .github/workflows/spectests-genesis.yml | 40 -------- 2 files changed, 118 insertions(+), 40 deletions(-) create mode 100644 .github/workflows/spec-tests.yml delete mode 100644 .github/workflows/spectests-genesis.yml diff --git a/.github/workflows/spec-tests.yml b/.github/workflows/spec-tests.yml new file mode 100644 index 000000000000..17e3a929b8ee --- /dev/null +++ b/.github/workflows/spec-tests.yml @@ -0,0 +1,118 @@ +name: Execution Spec Tests Fill and Consume (Verkle genesis & conversion) + +on: + push: + branches: [master] + pull_request: + branches: [master, kaustinen-with-shapella] + workflow_dispatch: + +env: + EEST_USER: 'jsign' + EEST_BRANCH: 'jsign-verkle-rebased-mainnet' + +jobs: + setup: + runs-on: ubuntu-latest + steps: + - name: Checkout go-ethereum + uses: actions/checkout@v4 + + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: "3.12.4" + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: 1.22.4 + + - name: Build geth evm + run: | + go build -v ./cmd/evm + mkdir -p ${{ github.workspace }}/bin + mv evm ${{ github.workspace }}/bin/evm + chmod +x ${{ github.workspace }}/bin/evm + + - name: Archive built evm + uses: actions/upload-artifact@v4 + with: + name: evm + path: ${{ github.workspace }}/bin/evm + + fill: + runs-on: ubuntu-latest + needs: setup + strategy: + matrix: + test-type: [genesis, conversion] + steps: + - name: Download geth evm + uses: actions/download-artifact@v4 + with: + name: evm + path: ./bin + + - name: Make evm binary executable and add to PATH + run: | + chmod +x ./bin/evm + echo "${{ github.workspace }}/bin" >> $GITHUB_PATH + + - name: Clone execution-spec-tests and fill tests + run: | + git clone https://github.com/${{ env.EEST_USER }}/execution-spec-tests -b ${{ env.EEST_BRANCH }} + cd execution-spec-tests + python3 -m venv venv + . venv/bin/activate + pip install --upgrade pip + pip install -e ".[docs,lint,test]" + solc-select use 0.8.24 --always-install + if [ "${{ matrix.test-type }}" == "genesis" ]; then + fill --fork Verkle --output=../fixtures-${{ matrix.test-type }} -v -m blockchain_test -n auto + else + fill --fork EIP6800Transition --output=../fixtures-${{ matrix.test-type }} -v -m blockchain_test -n auto + fi + shell: bash + + - name: Upload fixtures + uses: actions/upload-artifact@v4 + with: + name: fixtures-${{ matrix.test-type }} + path: fixtures-${{ matrix.test-type }} + + consume: + runs-on: ubuntu-latest + needs: fill + strategy: + matrix: + test-type: [genesis, conversion] + steps: + - name: Download geth evm + uses: actions/download-artifact@v4 + with: + name: evm + path: ./bin + + - name: Make evm binary executable and add to PATH + run: | + chmod +x ./bin/evm + echo "${{ github.workspace }}/bin" >> $GITHUB_PATH + + - name: Download fixtures + uses: actions/download-artifact@v4 + with: + name: fixtures-${{ matrix.test-type }} + path: ./fixtures-${{ matrix.test-type }} + + - name: Clone execution-spec-tests and consume tests + run: | + git clone https://github.com/${{ env.EEST_USER }}/execution-spec-tests -b ${{ env.EEST_BRANCH }} + cd execution-spec-tests + python3 -m venv venv + . venv/bin/activate + pip install --upgrade pip + pip install -e ".[docs,lint,test]" + solc-select use 0.8.24 --always-install + consume direct --input=../fixtures-${{ matrix.test-type }} -n auto + shell: bash \ No newline at end of file diff --git a/.github/workflows/spectests-genesis.yml b/.github/workflows/spectests-genesis.yml deleted file mode 100644 index 350fcdcb3a74..000000000000 --- a/.github/workflows/spectests-genesis.yml +++ /dev/null @@ -1,40 +0,0 @@ -name: Execution spec tests - -on: - push: - branches: [master] - pull_request: - branches: [master, kaustinen-with-shapella] - workflow_dispatch: - -jobs: - spectests: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Setup Python - uses: actions/setup-python@v5 - with: - python-version: "3.12.4" - cache: "" - - name: Set up Go - uses: actions/setup-go@v2 - with: - go-version: 1.22.4 - - name: Fill & consume tests - run: | - export PATH=$PATH:/home/devops/.cargo/bin - go build -v ./cmd/evm - git clone https://github.com/jsign/execution-spec-tests -b jsign-verkle-rebased-mainnet - cd execution-spec-tests - python3 -m venv venv - . ./venv/bin/activate - pip install -e ".[docs,lint,test]" - solc-select install 0.8.20 - solc-select use 0.8.20 - - fill --fork EIP6800Transition -n 4 -v -m blockchain_test --evm-bin=../evm -k test_verkle_from_mpt_conversion - fill --fork Verkle -n 4 -v -m blockchain_test --evm-bin=../evm -k eip6800_genesis - fill --fork Verkle -n 4 -v -m blockchain_test --evm-bin=../evm -k eip4762 - - consume direct --evm-bin=../evm --input=fixtures/blockchain_tests/ -v -n 8 From 93ad9d785f59c08548de4eafb2f5003c11b32773 Mon Sep 17 00:00:00 2001 From: Ignacio Hagopian Date: Fri, 9 Aug 2024 15:22:23 -0300 Subject: [PATCH 17/27] t8n/evm: fix pre-state for forks before verkle Signed-off-by: Ignacio Hagopian --- cmd/evm/internal/t8ntool/execution.go | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/cmd/evm/internal/t8ntool/execution.go b/cmd/evm/internal/t8ntool/execution.go index 01d23052a877..5cd520092741 100644 --- a/cmd/evm/internal/t8ntool/execution.go +++ b/cmd/evm/internal/t8ntool/execution.go @@ -464,15 +464,15 @@ func MakePreState(db ethdb.Database, chainConfig *params.ChainConfig, pre *Prest } } + state.NoBanner() + // Commit db an create a snapshot from it. + mptRoot, err := statedb.Commit(0, false) + if err != nil { + panic(err) + } + // If verkle mode started, establish the conversion if verkle { - state.NoBanner() - // Commit db an create a snapshot from it. - mptRoot, err := statedb.Commit(0, false) - if err != nil { - panic(err) - } - // If the current tree is a VerkleTrie, it means the state conversion has ended. // We don't need to continue with conversion setups and can return early. if _, ok := statedb.GetTrie().(*trie.VerkleTrie); ok { @@ -553,6 +553,11 @@ func MakePreState(db ethdb.Database, chainConfig *params.ChainConfig, pre *Prest if err != nil { panic(err) } + } else { + statedb, err = state.New(mptRoot, sdb, nil) + if err != nil { + panic(err) + } } if statedb.Database().InTransition() || statedb.Database().Transitioned() { From 660e2ebba282c42435ab9efc14e337bc68b945b8 Mon Sep 17 00:00:00 2001 From: Ignacio Hagopian Date: Tue, 13 Aug 2024 15:49:09 -0300 Subject: [PATCH 18/27] t8n: remove EIP6800Transition from forks Signed-off-by: Ignacio Hagopian --- tests/init.go | 19 ------------------- 1 file changed, 19 deletions(-) diff --git a/tests/init.go b/tests/init.go index c65c4cff147d..63b619557fea 100644 --- a/tests/init.go +++ b/tests/init.go @@ -337,25 +337,6 @@ var Forks = map[string]*params.ChainConfig{ ShanghaiTime: u64(0), VerkleTime: u64(0), }, - "ShanghaiToVerkleAtTime32": { - ChainID: big.NewInt(1), - HomesteadBlock: big.NewInt(0), - EIP150Block: big.NewInt(0), - EIP155Block: big.NewInt(0), - EIP158Block: big.NewInt(0), - ByzantiumBlock: big.NewInt(0), - ConstantinopleBlock: big.NewInt(0), - PetersburgBlock: big.NewInt(0), - IstanbulBlock: big.NewInt(0), - MuirGlacierBlock: big.NewInt(0), - BerlinBlock: big.NewInt(0), - LondonBlock: big.NewInt(0), - ArrowGlacierBlock: big.NewInt(0), - MergeNetsplitBlock: big.NewInt(0), - TerminalTotalDifficulty: big.NewInt(0), - ShanghaiTime: u64(0), - VerkleTime: u64(32), - }, } // AvailableForks returns the set of defined fork names From 6dcdaebd489c0311df6289ef55eca500f8aa4405 Mon Sep 17 00:00:00 2001 From: Ignacio Hagopian Date: Tue, 13 Aug 2024 15:50:08 -0300 Subject: [PATCH 19/27] ci: change execution-spec-tests target branch Signed-off-by: Ignacio Hagopian --- .github/workflows/spec-tests.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/spec-tests.yml b/.github/workflows/spec-tests.yml index 17e3a929b8ee..ef6c8190c5ff 100644 --- a/.github/workflows/spec-tests.yml +++ b/.github/workflows/spec-tests.yml @@ -8,8 +8,8 @@ on: workflow_dispatch: env: - EEST_USER: 'jsign' - EEST_BRANCH: 'jsign-verkle-rebased-mainnet' + EEST_USER: "jsign" + EEST_BRANCH: "jsign-fix-vm" jobs: setup: @@ -115,4 +115,4 @@ jobs: pip install -e ".[docs,lint,test]" solc-select use 0.8.24 --always-install consume direct --input=../fixtures-${{ matrix.test-type }} -n auto - shell: bash \ No newline at end of file + shell: bash From 8f4187361c0f507a09cc22a4838a774315da9ddf Mon Sep 17 00:00:00 2001 From: Ignacio Hagopian Date: Tue, 13 Aug 2024 15:57:04 -0300 Subject: [PATCH 20/27] ci: fill more tests Signed-off-by: Ignacio Hagopian --- .github/workflows/spec-tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/spec-tests.yml b/.github/workflows/spec-tests.yml index ef6c8190c5ff..7f8d0233cd46 100644 --- a/.github/workflows/spec-tests.yml +++ b/.github/workflows/spec-tests.yml @@ -71,7 +71,7 @@ jobs: if [ "${{ matrix.test-type }}" == "genesis" ]; then fill --fork Verkle --output=../fixtures-${{ matrix.test-type }} -v -m blockchain_test -n auto else - fill --fork EIP6800Transition --output=../fixtures-${{ matrix.test-type }} -v -m blockchain_test -n auto + fill --from Shanghai --until EIP6800Transition --output=../fixtures-${{ matrix.test-type }} -v -m blockchain_test -n auto fi shell: bash From 72b03c415eef1371d2064fa4cbc8c5500b803d8b Mon Sep 17 00:00:00 2001 From: Ignacio Hagopian Date: Tue, 13 Aug 2024 16:23:55 -0300 Subject: [PATCH 21/27] Revert "t8n: remove EIP6800Transition from forks" This reverts commit 660e2ebba282c42435ab9efc14e337bc68b945b8. --- tests/init.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/init.go b/tests/init.go index 63b619557fea..c65c4cff147d 100644 --- a/tests/init.go +++ b/tests/init.go @@ -337,6 +337,25 @@ var Forks = map[string]*params.ChainConfig{ ShanghaiTime: u64(0), VerkleTime: u64(0), }, + "ShanghaiToVerkleAtTime32": { + ChainID: big.NewInt(1), + HomesteadBlock: big.NewInt(0), + EIP150Block: big.NewInt(0), + EIP155Block: big.NewInt(0), + EIP158Block: big.NewInt(0), + ByzantiumBlock: big.NewInt(0), + ConstantinopleBlock: big.NewInt(0), + PetersburgBlock: big.NewInt(0), + IstanbulBlock: big.NewInt(0), + MuirGlacierBlock: big.NewInt(0), + BerlinBlock: big.NewInt(0), + LondonBlock: big.NewInt(0), + ArrowGlacierBlock: big.NewInt(0), + MergeNetsplitBlock: big.NewInt(0), + TerminalTotalDifficulty: big.NewInt(0), + ShanghaiTime: u64(0), + VerkleTime: u64(32), + }, } // AvailableForks returns the set of defined fork names From 1f72eda43b164aeeeb057dcf49bf9dbb8629043e Mon Sep 17 00:00:00 2001 From: Ignacio Hagopian Date: Tue, 13 Aug 2024 16:26:57 -0300 Subject: [PATCH 22/27] ci: use verkle/main branch for tests Signed-off-by: Ignacio Hagopian --- .github/workflows/spec-tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/spec-tests.yml b/.github/workflows/spec-tests.yml index 7f8d0233cd46..2de4a05fb50c 100644 --- a/.github/workflows/spec-tests.yml +++ b/.github/workflows/spec-tests.yml @@ -8,8 +8,8 @@ on: workflow_dispatch: env: - EEST_USER: "jsign" - EEST_BRANCH: "jsign-fix-vm" + EEST_USER: "ethereum" + EEST_BRANCH: "verkle/main" jobs: setup: From ff8272192e9b8786bfdad673de501c62102403ee Mon Sep 17 00:00:00 2001 From: Ignacio Hagopian Date: Thu, 15 Aug 2024 15:01:08 -0300 Subject: [PATCH 23/27] add todo Signed-off-by: Ignacio Hagopian --- tests/block_test_util.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/block_test_util.go b/tests/block_test_util.go index 0fafa103efc7..00c73c93e0a6 100644 --- a/tests/block_test_util.go +++ b/tests/block_test_util.go @@ -148,6 +148,8 @@ func (t *BlockTest) Run(snapshotter bool, tracer vm.EVMLogger) error { return fmt.Errorf("post state validation failed: %v", err) } // Cross-check the snapshot-to-hash against the trie hash + // TODO: re-enable this whenever we decide how to handle the Overlay Tree situation + // for snapshot regeneration. if snapshotter && false { if err := chain.Snapshots().Verify(chain.CurrentBlock().Root); err != nil { return err From c08f8c154aecf4bdc538a9a2b1dd620b816df3ca Mon Sep 17 00:00:00 2001 From: Ignacio Hagopian Date: Tue, 20 Aug 2024 15:53:39 -0300 Subject: [PATCH 24/27] preimages fixes Signed-off-by: Ignacio Hagopian --- consensus/beacon/consensus.go | 3 +-- core/genesis.go | 20 +++++--------------- tests/block_test_util.go | 2 +- 3 files changed, 7 insertions(+), 18 deletions(-) diff --git a/consensus/beacon/consensus.go b/consensus/beacon/consensus.go index 75729721cd71..acf5abeb1a99 100644 --- a/consensus/beacon/consensus.go +++ b/consensus/beacon/consensus.go @@ -28,7 +28,6 @@ import ( "github.com/ethereum/go-ethereum/core/overlay" "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/rpc" "github.com/ethereum/go-ethereum/trie" @@ -366,7 +365,7 @@ func (beacon *Beacon) Finalize(chain consensus.ChainHeaderReader, header *types. // fmt.Println("at block", header.Number, "performing transition?", state.Database().InTransition()) parent := chain.GetHeaderByHash(header.ParentHash) if err := overlay.OverlayVerkleTransition(state, parent.Root, chain.Config().OverlayStride); err != nil { - log.Error("error performing the transition", "err", err) + panic(fmt.Sprintf("error performing the transition: %s", err)) } } } diff --git a/core/genesis.go b/core/genesis.go index 93192472d2b5..b202f4dacfcb 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -30,7 +30,6 @@ import ( "github.com/ethereum/go-ethereum/common/math" "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/core/state" - "github.com/ethereum/go-ethereum/core/state/snapshot" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/ethdb" @@ -173,18 +172,6 @@ func (ga *GenesisAlloc) flush(db ethdb.Database, triedb *trie.Database, blockhas if err != nil { return err } - - sdb := database - sdb.TrieDB().WritePreimages() - snaps, err := snapshot.New(snapshot.Config{AsyncBuild: false, CacheSize: 10}, sdb.DiskDB(), sdb.TrieDB(), types.EmptyRootHash) - if err != nil { - panic(err) - } - if snaps == nil { - panic("snapshot is nil") - } - snaps.Cap(types.EmptyRootHash, 0) - // Commit newly generated states into disk if it's not empty. if root != types.EmptyRootHash { if err := triedb.Commit(root, true); err != nil { @@ -343,7 +330,10 @@ func SetupGenesisBlockWithOverride(db ethdb.Database, triedb *trie.Database, gen } // Just commit the new block if there is no stored genesis block. stored := rawdb.ReadCanonicalHash(db, 0) - if (stored == common.Hash{}) { + // TODO: remove `true`. The problem is that for test consumption, the genesis block is stored + // in the db and is unaware of preimage recording. This means that we won't enter this if and + // save the genesis block state with preimages enabled, thus missing the genesis preimages. + if true || (stored == common.Hash{}) { if genesis == nil { log.Info("Writing default main-net genesis block") genesis = DefaultGenesisBlock() @@ -573,7 +563,7 @@ func (g *Genesis) Commit(db ethdb.Database, triedb *trie.Database) (*types.Block // Note the state changes will be committed in hash-based scheme, use Commit // if path-scheme is preferred. func (g *Genesis) MustCommit(db ethdb.Database) *types.Block { - triedb := trie.NewDatabaseWithConfig(db, &trie.Config{Verkle: g.Config != nil && g.Config.IsVerkle(big.NewInt(int64(g.Number)), g.Timestamp), Preimages: true}) + triedb := trie.NewDatabaseWithConfig(db, &trie.Config{Verkle: g.Config != nil && g.Config.IsVerkle(big.NewInt(int64(g.Number)), g.Timestamp)}) block, err := g.Commit(db, triedb) if err != nil { panic(err) diff --git a/tests/block_test_util.go b/tests/block_test_util.go index 00c73c93e0a6..9c0ee3b1a93d 100644 --- a/tests/block_test_util.go +++ b/tests/block_test_util.go @@ -119,7 +119,7 @@ func (t *BlockTest) Run(snapshotter bool, tracer vm.EVMLogger) error { // Wrap the original engine within the beacon-engine engine := beacon.New(ethash.NewFaker()) - cache := &core.CacheConfig{TrieCleanLimit: 0} + cache := &core.CacheConfig{TrieCleanLimit: 0, Preimages: true} if snapshotter { cache.SnapshotLimit = 1 cache.SnapshotWait = true From f3ff46e6efa608e447f84261a449138fc8c14a51 Mon Sep 17 00:00:00 2001 From: Ignacio Hagopian Date: Tue, 20 Aug 2024 19:43:53 -0300 Subject: [PATCH 25/27] fix genesis Signed-off-by: Ignacio Hagopian --- core/genesis.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/genesis.go b/core/genesis.go index b202f4dacfcb..cb45de4d043d 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -161,7 +161,7 @@ func (ga *GenesisAlloc) flush(db ethdb.Database, triedb *trie.Database, blockhas } for addr, account := range *ga { - statedb.AddBalance(addr, account.Balance) + statedb.SetBalance(addr, account.Balance) statedb.SetCode(addr, account.Code) statedb.SetNonce(addr, account.Nonce) for key, value := range account.Storage { From b640d338c82e4b851f1f5030161f7ab51ee50418 Mon Sep 17 00:00:00 2001 From: Ignacio Hagopian Date: Thu, 22 Aug 2024 08:48:44 -0300 Subject: [PATCH 26/27] record preimages in genesis commit Signed-off-by: Ignacio Hagopian --- core/genesis.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/genesis.go b/core/genesis.go index cb45de4d043d..24bd7a2af6f7 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -333,7 +333,7 @@ func SetupGenesisBlockWithOverride(db ethdb.Database, triedb *trie.Database, gen // TODO: remove `true`. The problem is that for test consumption, the genesis block is stored // in the db and is unaware of preimage recording. This means that we won't enter this if and // save the genesis block state with preimages enabled, thus missing the genesis preimages. - if true || (stored == common.Hash{}) { + if (stored == common.Hash{}) { if genesis == nil { log.Info("Writing default main-net genesis block") genesis = DefaultGenesisBlock() @@ -563,7 +563,7 @@ func (g *Genesis) Commit(db ethdb.Database, triedb *trie.Database) (*types.Block // Note the state changes will be committed in hash-based scheme, use Commit // if path-scheme is preferred. func (g *Genesis) MustCommit(db ethdb.Database) *types.Block { - triedb := trie.NewDatabaseWithConfig(db, &trie.Config{Verkle: g.Config != nil && g.Config.IsVerkle(big.NewInt(int64(g.Number)), g.Timestamp)}) + triedb := trie.NewDatabaseWithConfig(db, &trie.Config{Preimages: true, Verkle: g.Config != nil && g.Config.IsVerkle(big.NewInt(int64(g.Number)), g.Timestamp)}) block, err := g.Commit(db, triedb) if err != nil { panic(err) From a324f5983b900de56914d498912c473bc9178a12 Mon Sep 17 00:00:00 2001 From: Ignacio Hagopian Date: Fri, 23 Aug 2024 08:33:00 -0300 Subject: [PATCH 27/27] review feedback Signed-off-by: Ignacio Hagopian --- cmd/evm/main.go | 8 ++++---- consensus/beacon/consensus.go | 2 ++ core/genesis.go | 1 + 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/cmd/evm/main.go b/cmd/evm/main.go index 465148e8358d..b7bb52425e83 100644 --- a/cmd/evm/main.go +++ b/cmd/evm/main.go @@ -172,25 +172,25 @@ var verkleCommand = &cli.Command{ }, { Name: "single-key", - Aliases: []string{"V"}, + Aliases: []string{"vk"}, Usage: "compute the verkle tree key given an address and optional slot number", Action: t8ntool.VerkleKey, }, { Name: "code-chunk-key", - Aliases: []string{"VCK"}, + Aliases: []string{"vck"}, Usage: "compute the verkle tree key given an address and chunk number", Action: t8ntool.VerkleCodeChunkKey, }, { Name: "chunkify-code", - Aliases: []string{"VCC"}, + Aliases: []string{"vcc"}, Usage: "chunkify a given bytecode", Action: t8ntool.VerkleChunkifyCode, }, { Name: "state-root", - Aliases: []string{"VR"}, + Aliases: []string{"vsr"}, Usage: "compute the state-root of a verkle tree for the given alloc", Action: t8ntool.VerkleRoot, Flags: []cli.Flag{ diff --git a/consensus/beacon/consensus.go b/consensus/beacon/consensus.go index acf5abeb1a99..1fe5ffb612ff 100644 --- a/consensus/beacon/consensus.go +++ b/consensus/beacon/consensus.go @@ -28,6 +28,7 @@ import ( "github.com/ethereum/go-ethereum/core/overlay" "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/rpc" "github.com/ethereum/go-ethereum/trie" @@ -365,6 +366,7 @@ func (beacon *Beacon) Finalize(chain consensus.ChainHeaderReader, header *types. // fmt.Println("at block", header.Number, "performing transition?", state.Database().InTransition()) parent := chain.GetHeaderByHash(header.ParentHash) if err := overlay.OverlayVerkleTransition(state, parent.Root, chain.Config().OverlayStride); err != nil { + log.Error("error performing the transition", "err", err) panic(fmt.Sprintf("error performing the transition: %s", err)) } } diff --git a/core/genesis.go b/core/genesis.go index 24bd7a2af6f7..b5fe17a6f4ae 100644 --- a/core/genesis.go +++ b/core/genesis.go @@ -161,6 +161,7 @@ func (ga *GenesisAlloc) flush(db ethdb.Database, triedb *trie.Database, blockhas } for addr, account := range *ga { + // TODO set back to AddBalance after rebase statedb.SetBalance(addr, account.Balance) statedb.SetCode(addr, account.Code) statedb.SetNonce(addr, account.Nonce)