diff --git a/core/blockchain.go b/core/blockchain.go index be23f7b039..18fdc173b5 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -597,7 +597,7 @@ func (bc *BlockChain) tryRewindBadBlocks() { snaps := bc.snaps // Verified and Result is false if snaps != nil && snaps.Snapshot(block.Root()) != nil && - snaps.Snapshot(block.Root()).Verified() && !snaps.Snapshot(block.Root()).WaitVerified() { + snaps.Snapshot(block.Root()).Verified() && !snaps.Snapshot(block.Root()).WaitAndGetVerifyRes() { // Rewind by one block log.Warn("current block verified failed, rewind to its parent", "height", block.NumberU64(), "hash", block.Hash()) bc.futureBlocks.Remove(block.Hash()) diff --git a/core/state/snapshot/difflayer.go b/core/state/snapshot/difflayer.go index 29207fd6a7..d6624285a4 100644 --- a/core/state/snapshot/difflayer.go +++ b/core/state/snapshot/difflayer.go @@ -260,8 +260,8 @@ func (dl *diffLayer) Root() common.Hash { return dl.root } -// WaitVerified will wait until the diff layer been verified and return the verification result -func (dl *diffLayer) WaitVerified() bool { +// WaitAndGetVerifyRes will wait until the diff layer been verified and return the verification result +func (dl *diffLayer) WaitAndGetVerifyRes() bool { if dl.verifiedCh == nil { return true } diff --git a/core/state/snapshot/disklayer.go b/core/state/snapshot/disklayer.go index 004c1c1955..c1de41782c 100644 --- a/core/state/snapshot/disklayer.go +++ b/core/state/snapshot/disklayer.go @@ -49,7 +49,7 @@ func (dl *diskLayer) Root() common.Hash { return dl.root } -func (dl *diskLayer) WaitVerified() bool { +func (dl *diskLayer) WaitAndGetVerifyRes() bool { return true } diff --git a/core/state/snapshot/snapshot.go b/core/state/snapshot/snapshot.go index b4bb90d441..8ac93f28e4 100644 --- a/core/state/snapshot/snapshot.go +++ b/core/state/snapshot/snapshot.go @@ -101,8 +101,8 @@ type Snapshot interface { // Root returns the root hash for which this snapshot was made. Root() common.Hash - // WaitVerified will wait until the snapshot been verified - WaitVerified() bool + // WaitAndGetVerifyRes will wait until the snapshot been verified and return verification result + WaitAndGetVerifyRes() bool // Verified returns whether the snapshot is verified Verified() bool diff --git a/core/state/statedb.go b/core/state/statedb.go index 04e3483e4c..9103e83ac8 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -170,7 +170,7 @@ func newStateDB(root common.Hash, db Database, snaps *snapshot.Tree) (*StateDB, snapVerified := sdb.snap != nil && sdb.snap.Verified() tr, err := db.OpenTrie(root) - // return error when 1. failed to open trie and 2. the snap is not nil and done verification + // return error when 1. failed to open trie and 2. the snap is nil or the snap is not nil and done verification if err != nil && (sdb.snap == nil || snapVerified) { return nil, err } @@ -1020,7 +1020,7 @@ func (s *StateDB) AccountsIntermediateRoot() error { // We need wait for the parent trie to commit if s.snap != nil { - if valid := s.snap.WaitVerified(); !valid { + if valid := s.snap.WaitAndGetVerifyRes(); !valid { return fmt.Errorf("verification on parent snap failed") } } diff --git a/eth/tracers/api.go b/eth/tracers/api.go index 97c248ebf6..6be15e3f2a 100644 --- a/eth/tracers/api.go +++ b/eth/tracers/api.go @@ -558,7 +558,7 @@ func (api *API) IntermediateRoots(ctx context.Context, hash common.Hash, config // so any modifications are written to the trie root, err := statedb.IntermediateRoot(deleteEmptyObjects) if err != nil { - return roots, err + return nil, err } roots = append(roots, root) }