From 6299c90de3ab359c1c7d38438793d3fc64e2c5b4 Mon Sep 17 00:00:00 2001 From: zjubfd <296179868@qq.com> Date: Fri, 14 Jan 2022 11:03:08 +0800 Subject: [PATCH] resolve keefe's comment --- core/blockchain.go | 2 ++ core/state/statedb.go | 5 +---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/core/blockchain.go b/core/blockchain.go index f95d312692..be23f7b039 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -602,6 +602,8 @@ func (bc *BlockChain) tryRewindBadBlocks() { log.Warn("current block verified failed, rewind to its parent", "height", block.NumberU64(), "hash", block.Hash()) bc.futureBlocks.Remove(block.Hash()) bc.badBlockCache.Add(block.Hash(), time.Now()) + bc.diffLayerCache.Remove(block.Hash()) + bc.diffLayerRLPCache.Remove(block.Hash()) bc.reportBlock(block, nil, errStateRootVerificationFailed) bc.setHeadBeyondRoot(block.NumberU64()-1, common.Hash{}) } diff --git a/core/state/statedb.go b/core/state/statedb.go index cf4ef4545b..04e3483e4c 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -172,10 +172,7 @@ func newStateDB(root common.Hash, db Database, snaps *snapshot.Tree) (*StateDB, tr, err := db.OpenTrie(root) // return error when 1. failed to open trie and 2. the snap is not nil and done verification if err != nil && (sdb.snap == nil || snapVerified) { - if err != nil { - return nil, err - } - return nil, fmt.Errorf("no available state") + return nil, err } sdb.trie = tr return sdb, nil