remove recording of read storage slots in statedb

This commit is contained in:
Jared Wasinger 2023-12-06 19:48:12 +08:00
parent 1e81f97554
commit 168245aa7e

View file

@ -74,7 +74,6 @@ type stateObject struct {
originStorage Storage // Storage cache of original entries to dedup rewrites
pendingStorage Storage // Storage entries that need to be flushed to disk, at the end of an entire block
dirtyStorage Storage // Storage entries that have been modified in the current transaction execution, reset for every transaction
readStorage []common.Hash
// Cache flags.
dirtyCode bool // true if the code was updated
@ -112,7 +111,6 @@ func newObject(db *StateDB, address common.Address, acct *types.StateAccount) *s
originStorage: make(Storage),
pendingStorage: make(Storage),
dirtyStorage: make(Storage),
readStorage: []common.Hash{},
}
}
@ -259,22 +257,12 @@ func (s *stateObject) finalise(prefetch bool) {
}
}
// prefetch slots that are read so that they will appear in witness
for _, value := range s.readStorage {
if _, ok := s.dirtyStorage[value]; !ok {
slotsToPrefetch = append(slotsToPrefetch, common.CopyBytes(value[:]))
}
}
if s.db.prefetcher != nil && prefetch && len(slotsToPrefetch) > 0 && s.data.Root != types.EmptyRootHash {
s.db.prefetcher.prefetch(s.addrHash, s.data.Root, s.address, slotsToPrefetch)
}
if len(s.dirtyStorage) > 0 {
s.dirtyStorage = make(Storage)
}
if len(s.readStorage) > 0 {
s.readStorage = []common.Hash{}
}
}
// updateTrie is responsible for persisting cached storage changes into the