From 373c1deeb837c4d5bcf8735ed031fd862e8b7d02 Mon Sep 17 00:00:00 2001 From: j75689 Date: Wed, 27 Jul 2022 10:27:58 +0800 Subject: [PATCH] fix: remove diffhash patch introduced fro m separate node --- core/state/state_object.go | 17 +---------------- core/state/statedb.go | 13 ------------- 2 files changed, 1 insertion(+), 29 deletions(-) diff --git a/core/state/state_object.go b/core/state/state_object.go index 780cd6d255..86cff96e8a 100644 --- a/core/state/state_object.go +++ b/core/state/state_object.go @@ -18,7 +18,6 @@ package state import ( "bytes" - "errors" "fmt" "io" "math/big" @@ -26,15 +25,12 @@ import ( "time" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/state/snapshot" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/metrics" "github.com/ethereum/go-ethereum/rlp" ) -const snapshotStaleRetryInterval = time.Millisecond * 10 - var emptyCodeHash = crypto.Keccak256(nil) type Code []byte @@ -271,18 +267,7 @@ func (s *StateObject) GetCommittedState(db Database, key common.Hash) common.Has } enc, err = s.db.snap.Storage(s.addrHash, crypto.Keccak256Hash(key.Bytes())) } - // ErrSnapshotStale may occur due to diff layers in the update, so we should try again in noTrie mode. - if s.db.NoTrie() && err != nil && errors.Is(err, snapshot.ErrSnapshotStale) { - // This error occurs when statedb.snaps.Cap changes the state of the merged difflayer - // to stale during the refresh of the difflayer, indicating that it is about to be discarded. - // Since the difflayer is refreshed in parallel, - // there is a small chance that the difflayer of the stale will be read while reading, - // resulting in an empty array being returned here. - // Therefore, noTrie mode must retry here, - // and add a time interval when retrying to avoid stacking too much and causing stack overflow. - time.Sleep(snapshotStaleRetryInterval) - return s.GetCommittedState(db, key) - } + // If snapshot unavailable or reading from it failed, load from the database if s.db.snap == nil || err != nil { if meter != nil { diff --git a/core/state/statedb.go b/core/state/statedb.go index 2edeb379e5..8c597d39da 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -655,19 +655,6 @@ func (s *StateDB) getDeletedStateObject(addr common.Address) *StateObject { } } - // ErrSnapshotStale may occur due to diff layers in the update, so we should try again in noTrie mode. - if s.NoTrie() && err != nil && errors.Is(err, snapshot.ErrSnapshotStale) { - // This error occurs when statedb.snaps.Cap changes the state of the merged difflayer - // to stale during the refresh of the difflayer, indicating that it is about to be discarded. - // Since the difflayer is refreshed in parallel, - // there is a small chance that the difflayer of the stale will be read while reading, - // resulting in an empty array being returned here. - // Therefore, noTrie mode must retry here, - // and add a time interval when retrying to avoid stacking too much and causing OOM. - time.Sleep(snapshotStaleRetryInterval) - return s.getDeletedStateObject(addr) - } - // If snapshot unavailable or reading from it failed, load from the database if s.snap == nil || err != nil { if s.trie == nil {