forked from cerc-io/plugeth
cmd/evm: fix dump after state-test exec (#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.
This commit is contained in:
parent
5a45e7a631
commit
1048e2d6a3
@ -100,19 +100,20 @@ func runStateTest(fname string, cfg vm.Config, jsonOut, dump bool) error {
|
|||||||
for _, st := range test.Subtests() {
|
for _, st := range test.Subtests() {
|
||||||
// Run the test and aggregate the result
|
// Run the test and aggregate the result
|
||||||
result := &StatetestResult{Name: key, Fork: st.Fork, Pass: true}
|
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) {
|
test.Run(st, cfg, false, rawdb.HashScheme, func(err error, snaps *snapshot.Tree, statedb *state.StateDB) {
|
||||||
if state != nil {
|
var root common.Hash
|
||||||
root := state.IntermediateRoot(false)
|
if statedb != nil {
|
||||||
|
root = statedb.IntermediateRoot(false)
|
||||||
result.Root = &root
|
result.Root = &root
|
||||||
if jsonOut {
|
if jsonOut {
|
||||||
fmt.Fprintf(os.Stderr, "{\"stateRoot\": \"%#x\"}\n", root)
|
fmt.Fprintf(os.Stderr, "{\"stateRoot\": \"%#x\"}\n", root)
|
||||||
}
|
}
|
||||||
}
|
if dump { // Dump any state to aid debugging
|
||||||
// Dump any state to aid debugging
|
cpy, _ := state.New(root, statedb.Database(), nil)
|
||||||
if dump {
|
dump := cpy.RawDump(nil)
|
||||||
dump := state.RawDump(nil)
|
|
||||||
result.State = &dump
|
result.State = &dump
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// Test failed, mark as so
|
// Test failed, mark as so
|
||||||
result.Pass, result.Error = false, err.Error()
|
result.Pass, result.Error = false, err.Error()
|
||||||
|
@ -129,6 +129,7 @@ func (s *StateDB) DumpToCollector(c DumpCollector, conf *DumpConfig) (nextKey []
|
|||||||
|
|
||||||
trieIt, err := s.trie.NodeIterator(conf.Start)
|
trieIt, err := s.trie.NodeIterator(conf.Start)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Error("Trie dumping error", "err", err)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
it := trie.NewIterator(trieIt)
|
it := trie.NewIterator(trieIt)
|
||||||
|
Loading…
Reference in New Issue
Block a user