Skip to content

Commit d729550

Browse files
gballetrjl493456442
andcommitted
review feedback from Gary part 1
Co-authored-by: Gary Rong <[email protected]>
1 parent a0e6f53 commit d729550

File tree

4 files changed

+18
-14
lines changed

4 files changed

+18
-14
lines changed

cmd/evm/internal/t8ntool/execution.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig,
194194
Time: pre.Env.ParentTimestamp,
195195
ExcessBlobGas: pre.Env.ParentExcessBlobGas,
196196
BlobGasUsed: pre.Env.ParentBlobGasUsed,
197+
BaseFee: pre.Env.ParentBaseFee,
197198
}
198199
header := &types.Header{
199200
Time: pre.Env.Timestamp,

cmd/evm/internal/t8ntool/transition.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,15 @@ func Transition(ctx *cli.Context) error {
118118
}
119119
}
120120
prestate.Pre = inputData.Alloc
121+
121122
if btStr != stdinSelector && btStr != "" {
122123
if err := readFile(btStr, "BT", &inputData.BT); err != nil {
123124
return err
124125
}
125126
}
126127

127128
prestate.BT = inputData.BT
129+
128130
// Set the block environment
129131
if envStr != stdinSelector {
130132
var env stEnv
@@ -195,8 +197,10 @@ func Transition(ctx *cli.Context) error {
195197
return err
196198
}
197199
// Dump the execution result
198-
collector := make(Alloc)
199-
var btleaves map[common.Hash]hexutil.Bytes
200+
var (
201+
collector = make(Alloc)
202+
btleaves map[common.Hash]hexutil.Bytes
203+
)
200204
isBinary := chainConfig.IsVerkle(big.NewInt(int64(prestate.Env.Number)), prestate.Env.Timestamp)
201205
if !isBinary {
202206
s.DumpToCollector(collector, nil)
@@ -492,7 +496,6 @@ func genBinTrieFromAlloc(alloc core.GenesisAlloc) (*bintrie.BinaryTrie, error) {
492496
return nil, fmt.Errorf("error inserting storage: %w", err)
493497
}
494498
}
495-
496499
account := &types.StateAccount{
497500
Balance: uint256.MustFromBig(acc.Balance),
498501
Nonce: acc.Nonce,
@@ -503,7 +506,6 @@ func genBinTrieFromAlloc(alloc core.GenesisAlloc) (*bintrie.BinaryTrie, error) {
503506
if err != nil {
504507
return nil, fmt.Errorf("error inserting account: %w", err)
505508
}
506-
507509
err = bt.UpdateContractCode(addr, common.BytesToHash(account.CodeHash), acc.Code)
508510
if err != nil {
509511
return nil, fmt.Errorf("error inserting code: %w", err)

core/state/dump.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package state
1818

1919
import (
2020
"encoding/json"
21+
"errors"
2122
"fmt"
2223
"time"
2324

@@ -224,17 +225,17 @@ func (s *StateDB) DumpToCollector(c DumpCollector, conf *DumpConfig) (nextKey []
224225

225226
// DumpBinTrieLeaves collects all binary trie leaf nodes into the provided map.
226227
func (s *StateDB) DumpBinTrieLeaves(collector map[common.Hash]hexutil.Bytes) error {
227-
if s.trie == nil {
228-
trie, err := s.db.OpenTrie(s.originalRoot)
229-
if err != nil {
230-
return err
231-
}
232-
s.trie = trie
228+
tr, err := s.db.OpenTrie(s.originalRoot)
229+
if err != nil {
230+
return err
233231
}
234-
235-
it, err := s.trie.(*bintrie.BinaryTrie).NodeIterator(nil)
232+
btr, ok := tr.(*bintrie.BinaryTrie)
233+
if !ok {
234+
return errors.New("trie is not a binary trie")
235+
}
236+
it, err := btr.NodeIterator(nil)
236237
if err != nil {
237-
panic(err)
238+
return err
238239
}
239240
for it.Next(true) {
240241
if it.Leaf() {

tests/block_test_util.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ func (t *BlockTest) Run(snapshotter bool, scheme string, witness bool, tracer *t
118118
}
119119
// import pre accounts & construct test genesis block & state root
120120
// Commit genesis state
121-
gspec := t.genesis(config)
122121
var (
122+
gspec = t.genesis(config)
123123
db = rawdb.NewMemoryDatabase()
124124
tconf = &triedb.Config{
125125
Preimages: true,

0 commit comments

Comments
 (0)