Skip to content

Commit

Permalink
fix: remove diffhash patch introduced fro
Browse files Browse the repository at this point in the history
m separate node
  • Loading branch information
j75689 committed Jul 27, 2022
1 parent dd3b3a6 commit 373c1de
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 29 deletions.
17 changes: 1 addition & 16 deletions core/state/state_object.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,19 @@ package state

import (
"bytes"
"errors"
"fmt"
"io"
"math/big"
"sync"
"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
Expand Down Expand Up @@ -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 {
Expand Down
13 changes: 0 additions & 13 deletions core/state/statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 373c1de

Please sign in to comment.