From 5632a7addeb3777d92be5df9215c124de2f30e09 Mon Sep 17 00:00:00 2001 From: weiihann Date: Tue, 29 Apr 2025 17:25:21 +0800 Subject: [PATCH] blockchain,triedb: avoid checking recoverable twice --- core/blockchain.go | 3 +++ triedb/pathdb/database.go | 4 ---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/core/blockchain.go b/core/blockchain.go index 6667f64911..f0d0f04470 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -867,6 +867,9 @@ func (bc *BlockChain) rewindPathHead(head *types.Header, root common.Hash) (*typ } // Recover if the target state if it's not available yet. if !bc.HasState(head.Root) { + if !bc.stateRecoverable(head.Root) { + log.Crit("State is unrecoverable, failed to rollback") + } if err := bc.triedb.Recover(head.Root); err != nil { log.Crit("Failed to rollback state", "err", err) } diff --git a/triedb/pathdb/database.go b/triedb/pathdb/database.go index d48850c102..de6dd1da9a 100644 --- a/triedb/pathdb/database.go +++ b/triedb/pathdb/database.go @@ -430,10 +430,6 @@ func (db *Database) Recover(root common.Hash) error { if db.freezer == nil { return errors.New("state rollback is non-supported") } - // Short circuit if the target state is not recoverable - if !db.Recoverable(root) { - return errStateUnrecoverable - } // Apply the state histories upon the disk layer in order var ( start = time.Now()