Skip to content

Commit 2a7c4b6

Browse files
committed
eth: fix tracing state retrieval if requesting the non-dirty genesis
1 parent 9d10856 commit 2a7c4b6

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

eth/state_accessor.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,16 @@ func (eth *Ethereum) stateAtBlock(block *types.Block, reexec uint64, base *state
6161
// the internal junks created by tracing will be persisted into the disk.
6262
database = state.NewDatabaseWithConfig(eth.chainDb, &trie.Config{Cache: 16})
6363

64+
// If we didn't check the dirty database, do check the clean one, otherwise
65+
// we would rewind past a persisted block (specific corner case is chain
66+
// tracing from the genesis).
67+
if !checkLive {
68+
statedb, err = state.New(current.Root(), database, nil)
69+
if err == nil {
70+
return statedb, nil
71+
}
72+
}
73+
// Database does not have the state for the given block, try to regenerate
6474
for i := uint64(0); i < reexec; i++ {
6575
if current.NumberU64() == 0 {
6676
return nil, errors.New("genesis state is missing")

0 commit comments

Comments
 (0)