Skip to content

Commit

Permalink
cmd/evm: fix dump after state-test exec (ethereum#28650)
Browse files Browse the repository at this point in the history
The dump after state-test didn't work, the problem was an error, "Already committed", which was silently ignored. 

This change re-initialises the state, so the dumping works again.
  • Loading branch information
holiman authored and Dergarcon committed Jan 31, 2024
1 parent ae2dd1f commit dcdcb04
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
17 changes: 9 additions & 8 deletions cmd/evm/staterunner.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,18 +100,19 @@ func runStateTest(fname string, cfg vm.Config, jsonOut, dump bool) error {
for _, st := range test.Subtests() {
// Run the test and aggregate the result
result := &StatetestResult{Name: key, Fork: st.Fork, Pass: true}
test.Run(st, cfg, false, rawdb.HashScheme, func(err error, snaps *snapshot.Tree, state *state.StateDB) {
if state != nil {
root := state.IntermediateRoot(false)
test.Run(st, cfg, false, rawdb.HashScheme, func(err error, snaps *snapshot.Tree, statedb *state.StateDB) {
var root common.Hash
if statedb != nil {
root = statedb.IntermediateRoot(false)
result.Root = &root
if jsonOut {
fmt.Fprintf(os.Stderr, "{\"stateRoot\": \"%#x\"}\n", root)
}
}
// Dump any state to aid debugging
if dump {
dump := state.RawDump(nil)
result.State = &dump
if dump { // Dump any state to aid debugging
cpy, _ := state.New(root, statedb.Database(), nil)
dump := cpy.RawDump(nil)
result.State = &dump
}
}
if err != nil {
// Test failed, mark as so
Expand Down
1 change: 1 addition & 0 deletions core/state/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ func (s *StateDB) DumpToCollector(c DumpCollector, conf *DumpConfig) (nextKey []

trieIt, err := s.trie.NodeIterator(conf.Start)
if err != nil {
log.Error("Trie dumping error", "err", err)
return nil
}
it := trie.NewIterator(trieIt)
Expand Down

0 comments on commit dcdcb04

Please sign in to comment.