other fix

This commit is contained in:
Jared Wasinger 2024-02-19 20:09:52 -08:00
parent 095a65e2b7
commit 93557ab8fe

View file

@ -194,13 +194,6 @@ func (s *stateObject) GetCommittedState(key common.Hash) common.Hash {
err error err error
value common.Hash value common.Hash
) )
if s.db.witness != nil && s.db.snap != nil && s.origin != nil {
// when building a witness with snapshot enabled, prefetch all read slots to be collected
// and included in the witness when the block root hash is committed (intermediateroot/commit?)
s.db.readPrefetcher.prefetch(s.addrHash, s.origin.Root, s.address, [][]byte{key[:]})
}
if s.db.snap != nil { if s.db.snap != nil {
start := time.Now() start := time.Now()
enc, err = s.db.snap.Storage(s.addrHash, crypto.Keccak256Hash(key.Bytes())) enc, err = s.db.snap.Storage(s.addrHash, crypto.Keccak256Hash(key.Bytes()))
@ -214,6 +207,11 @@ func (s *stateObject) GetCommittedState(key common.Hash) common.Hash {
} }
value.SetBytes(content) value.SetBytes(content)
} }
// If witness building is enabled, prefetch any trie paths loaded directly
// via the snapshots
if s.db.prefetcher != nil && err == nil && s.db.witness != nil && s.data.Root != types.EmptyRootHash {
s.db.prefetcher.prefetch(s.addrHash, s.origin.Root, s.address, [][]byte{key[:]})
}
} }
// If the snapshot is unavailable or reading from it fails, load from the database. // If the snapshot is unavailable or reading from it fails, load from the database.
if s.db.snap == nil || err != nil { if s.db.snap == nil || err != nil {
@ -224,7 +222,6 @@ func (s *stateObject) GetCommittedState(key common.Hash) common.Hash {
return common.Hash{} return common.Hash{}
} }
val, err := tr.GetStorage(s.address, key.Bytes()) val, err := tr.GetStorage(s.address, key.Bytes())
//fmt.Printf("trie access list is %v\n", tr.AccessList())
if metrics.EnabledExpensive { if metrics.EnabledExpensive {
s.db.StorageReads += time.Since(start) s.db.StorageReads += time.Since(start)
} }