core: fix rewinding in path

This commit is contained in:
Gary Rong 2024-03-11 18:10:12 +08:00
parent 470916de46
commit c6b0eb75fa

View file

@ -739,8 +739,8 @@ func (bc *BlockChain) rewindPathHead(root common.Hash) (*types.Header, uint64) {
headBlock = bc.GetHeader(headBlock.ParentHash, headBlock.Number.Uint64()-1) // Keep rewinding
}
// Recover if the target state if it's not available yet.
if !bc.HasState(root) {
if err := bc.triedb.Recover(root); err != nil {
if !bc.HasState(headBlock.Root) {
if err := bc.triedb.Recover(headBlock.Root); err != nil {
log.Crit("Failed to rollback state", "err", err)
}
}