Skip to content

Commit 1048e2d

Browse files
authored
cmd/evm: fix dump after state-test exec (ethereum#28650)
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.
1 parent 5a45e7a commit 1048e2d

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

cmd/evm/staterunner.go

+9-8
Original file line numberDiff line numberDiff line change
@@ -100,18 +100,19 @@ func runStateTest(fname string, cfg vm.Config, jsonOut, dump bool) error {
100100
for _, st := range test.Subtests() {
101101
// Run the test and aggregate the result
102102
result := &StatetestResult{Name: key, Fork: st.Fork, Pass: true}
103-
test.Run(st, cfg, false, rawdb.HashScheme, func(err error, snaps *snapshot.Tree, state *state.StateDB) {
104-
if state != nil {
105-
root := state.IntermediateRoot(false)
103+
test.Run(st, cfg, false, rawdb.HashScheme, func(err error, snaps *snapshot.Tree, statedb *state.StateDB) {
104+
var root common.Hash
105+
if statedb != nil {
106+
root = statedb.IntermediateRoot(false)
106107
result.Root = &root
107108
if jsonOut {
108109
fmt.Fprintf(os.Stderr, "{\"stateRoot\": \"%#x\"}\n", root)
109110
}
110-
}
111-
// Dump any state to aid debugging
112-
if dump {
113-
dump := state.RawDump(nil)
114-
result.State = &dump
111+
if dump { // Dump any state to aid debugging
112+
cpy, _ := state.New(root, statedb.Database(), nil)
113+
dump := cpy.RawDump(nil)
114+
result.State = &dump
115+
}
115116
}
116117
if err != nil {
117118
// Test failed, mark as so

core/state/dump.go

+1
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ func (s *StateDB) DumpToCollector(c DumpCollector, conf *DumpConfig) (nextKey []
129129

130130
trieIt, err := s.trie.NodeIterator(conf.Start)
131131
if err != nil {
132+
log.Error("Trie dumping error", "err", err)
132133
return nil
133134
}
134135
it := trie.NewIterator(trieIt)

0 commit comments

Comments
 (0)