Skip to content

Commit e94d14c

Browse files
gballetrjl493456442
andcommitted
Gary's review feedback, part 2
Co-authored-by: Gary Rong <[email protected]>
1 parent d729550 commit e94d14c

File tree

3 files changed

+10
-21
lines changed

3 files changed

+10
-21
lines changed

cmd/evm/internal/t8ntool/flags.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,6 @@ var (
9696
"\t<file> - into the file <file> ",
9797
Value: "vkt.json",
9898
}
99-
OutputWitnessFlag = &cli.StringFlag{
100-
Name: "output.witness",
101-
Usage: "Determines where to put the `witness` of the post-state.\n" +
102-
"\t`stdout` - into the stdout output\n" +
103-
"\t`stderr` - into the stderr output\n" +
104-
"\t<file> - into the file <file> ",
105-
Value: "witness.json",
106-
}
10799
InputAllocFlag = &cli.StringFlag{
108100
Name: "input.alloc",
109101
Usage: "`stdin` or file name of where to find the prestate alloc to use.",

cmd/evm/internal/t8ntool/transition.go

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import (
4242
"github.com/ethereum/go-ethereum/tests"
4343
"github.com/ethereum/go-ethereum/trie/bintrie"
4444
"github.com/ethereum/go-ethereum/triedb"
45+
"github.com/ethereum/go-ethereum/triedb/database"
4546
"github.com/holiman/uint256"
4647
"github.com/urfave/cli/v2"
4748
)
@@ -124,7 +125,6 @@ func Transition(ctx *cli.Context) error {
124125
return err
125126
}
126127
}
127-
128128
prestate.BT = inputData.BT
129129

130130
// Set the block environment
@@ -386,9 +386,7 @@ func dispatchOutput(ctx *cli.Context, baseDir string, result *ExecutionResult, a
386386
return nil
387387
}
388388

389-
// The logic for tree key
390-
// BinKey computes the tree key given an address and an optional
391-
// slot number.
389+
// BinKey computes the tree key given an address and an optional slot number.
392390
func BinKey(ctx *cli.Context) error {
393391
if ctx.Args().Len() == 0 || ctx.Args().Len() > 2 {
394392
return errors.New("invalid number of arguments: expecting an address and an optional slot number")
@@ -427,8 +425,10 @@ func BinKeys(ctx *cli.Context) error {
427425
return err
428426
}
429427
}
428+
db := triedb.NewDatabase(rawdb.NewMemoryDatabase(), triedb.VerkleDefaults)
429+
defer db.Close()
430430

431-
bt, err := genBinTrieFromAlloc(alloc)
431+
bt, err := genBinTrieFromAlloc(alloc, db)
432432
if err != nil {
433433
return fmt.Errorf("error generating bt: %w", err)
434434
}
@@ -469,8 +469,10 @@ func BinTrieRoot(ctx *cli.Context) error {
469469
return err
470470
}
471471
}
472+
db := triedb.NewDatabase(rawdb.NewMemoryDatabase(), triedb.VerkleDefaults)
473+
defer db.Close()
472474

473-
bt, err := genBinTrieFromAlloc(alloc)
475+
bt, err := genBinTrieFromAlloc(alloc, db)
474476
if err != nil {
475477
return fmt.Errorf("error generating bt: %w", err)
476478
}
@@ -480,15 +482,11 @@ func BinTrieRoot(ctx *cli.Context) error {
480482
}
481483

482484
// TODO(@CPerezz): Should this go to `bintrie` module?
483-
func genBinTrieFromAlloc(alloc core.GenesisAlloc) (*bintrie.BinaryTrie, error) {
484-
bt, err := bintrie.NewBinaryTrie(types.EmptyBinaryHash, triedb.NewDatabase(rawdb.NewMemoryDatabase(),
485-
&triedb.Config{
486-
IsVerkle: true,
487-
}))
485+
func genBinTrieFromAlloc(alloc core.GenesisAlloc, db database.NodeDatabase) (*bintrie.BinaryTrie, error) {
486+
bt, err := bintrie.NewBinaryTrie(types.EmptyBinaryHash, db)
488487
if err != nil {
489488
return nil, err
490489
}
491-
492490
for addr, acc := range alloc {
493491
for slot, value := range acc.Storage {
494492
err := bt.UpdateStorage(addr, slot.Bytes(), value.Big().Bytes())

core/state/reader.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,6 @@ func newTrieReader(root common.Hash, db *triedb.Database, cache *utils.PointCach
276276
// by using TransitionTrie when there's no actual transition happening.
277277
tr = transitiontrie.NewTransitionTrie(nil, binTrie, false)
278278
}
279-
err = binErr
280279
}
281280
if err != nil {
282281
return nil, err

0 commit comments

Comments
 (0)