diff --git a/core/blockchain.go b/core/blockchain.go index 1f978ea485..b40f853db5 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -2233,28 +2233,28 @@ func (bc *BlockChain) insertChain(chain types.Blocks, setHead bool) (int, error) } log.Info("+++++++++++++start block", "number", block.NumberU64()) defer log.Info("+++++++++++++end block", "number", block.NumberU64()) - statedb, err := state.NewWithSharedPool(parent.Root, bc.stateCache, bc.snaps) + statedb, err := state.NewWithSharedPool(parent.Root, bc.stateCache, nil) if err != nil { return it.index, err } bc.updateHighestVerifiedHeader(block.Header()) // Enable prefetching to pull in trie node paths while processing transactions - statedb.StartPrefetcher("chain") + //statedb.StartPrefetcher("chain") interruptCh := make(chan struct{}) // For diff sync, it may fallback to full sync, so we still do prefetch - if len(block.Transactions()) >= prefetchTxNumber { - // do Prefetch in a separate goroutine to avoid blocking the critical path - - // 1.do state prefetch for snapshot cache - throwaway := statedb.CopyDoPrefetch() - go bc.prefetcher.Prefetch(block, throwaway, &bc.vmConfig, interruptCh) - - // 2.do trie prefetch for MPT trie node cache - // it is for the big state trie tree, prefetch based on transaction's From/To address. - // trie prefetcher is thread safe now, ok to prefetch in a separate routine - go throwaway.TriePrefetchInAdvance(block, signer) - } + //if len(block.Transactions()) >= prefetchTxNumber { + // // do Prefetch in a separate goroutine to avoid blocking the critical path + // + // // 1.do state prefetch for snapshot cache + // throwaway := statedb.CopyDoPrefetch() + // go bc.prefetcher.Prefetch(block, throwaway, &bc.vmConfig, interruptCh) + // + // // 2.do trie prefetch for MPT trie node cache + // // it is for the big state trie tree, prefetch based on transaction's From/To address. + // // trie prefetcher is thread safe now, ok to prefetch in a separate routine + // go throwaway.TriePrefetchInAdvance(block, signer) + //} // Process block using the parent state as reference point if bc.pipeCommit { diff --git a/core/state/statedb.go b/core/state/statedb.go index dd6ce9443a..1c34b7fcee 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -172,6 +172,7 @@ func NewWithSharedPool(root common.Hash, db Database, snaps *snapshot.Tree) (*St // New creates a new state from a given trie. func New(root common.Hash, db Database, snaps *snapshot.Tree) (*StateDB, error) { + snaps = nil sdb := &StateDB{ db: db, originalRoot: root, @@ -222,6 +223,9 @@ func (s *StateDB) TransferPrefetcher(prev *StateDB) { prev.prefetcherLock.Lock() fetcher = prev.prefetcher prev.prefetcher = nil + if fetcher != nil { + panic("TransferPrefetcher") + } prev.prefetcherLock.Unlock() s.prefetcherLock.Lock() @@ -243,6 +247,7 @@ func (s *StateDB) StartPrefetcher(namespace string) { s.prefetcher = nil } if s.snap != nil { + panic("StartPrefetcher") parent := s.snap.Parent() if parent != nil { s.prefetcher = newTriePrefetcher(s.db, s.originalRoot, parent.Root(), namespace) diff --git a/eth/backend.go b/eth/backend.go index aa0b90e49c..986e8a467d 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -270,7 +270,7 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) { TrieDirtyDisabled: config.NoPruning, TrieTimeLimit: config.TrieTimeout, NoTries: config.TriesVerifyMode != core.LocalVerify, - SnapshotLimit: config.SnapshotCache, + SnapshotLimit: 0, // forbid snapshot TriesInMemory: config.TriesInMemory, Preimages: config.Preimages, StateHistory: config.StateHistory, diff --git a/trie/secure_trie.go b/trie/secure_trie.go index 5462f6eb7e..7157531fd1 100644 --- a/trie/secure_trie.go +++ b/trie/secure_trie.go @@ -19,6 +19,7 @@ package trie import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/rlp" "github.com/ethereum/go-ethereum/trie/trienode" "github.com/ethereum/go-ethereum/triedb/database" @@ -86,12 +87,13 @@ func (t *StateTrie) MustGet(key []byte) []byte { // and slot key. The value bytes must not be modified by the caller. // If the specified storage slot is not in the trie, nil will be returned. // If a trie node is not found in the database, a MissingNodeError is returned. -func (t *StateTrie) GetStorage(_ common.Address, key []byte) ([]byte, error) { +func (t *StateTrie) GetStorage(addr common.Address, key []byte) ([]byte, error) { enc, err := t.trie.Get(t.hashKey(key)) if err != nil || len(enc) == 0 { return nil, err } _, content, _, err := rlp.Split(enc) + log.Info("get storage", "owner", addr.String(), "key", common.Bytes2Hex(key), "val", common.Bytes2Hex(content)) return content, err } @@ -105,6 +107,7 @@ func (t *StateTrie) GetAccount(address common.Address) (*types.StateAccount, err } ret := new(types.StateAccount) err = rlp.DecodeBytes(res, ret) + log.Info("get account", "addr", address.String(), "nonce", ret.Nonce, "balance", ret.Balance, "root", ret.Root.String(), "code", common.Bytes2Hex(ret.CodeHash)) return ret, err }