Skip to content

Commit

Permalink
fix trie prefetch issue after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
sunny2022da committed Oct 8, 2024
1 parent 5e70537 commit 7ef4adf
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions core/state/parallel_statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -1798,7 +1798,9 @@ func (s *ParallelStateDB) FinaliseForParallel(deleteEmptyObjects bool, mainDB *S
}

if mainDB.prefetcher != nil && len(addressesToPrefetch) > 0 {
mainDB.trieParallelLock.Lock()
mainDB.prefetcher.prefetch(common.Hash{}, s.originalRoot, common.Address{}, addressesToPrefetch)
mainDB.trieParallelLock.Unlock()
}
// Invalidate journal because reverting across transactions is not allowed.
s.clearJournalAndRefund()
Expand Down
2 changes: 2 additions & 0 deletions core/state/state_object.go
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,9 @@ func (s *stateObject) finalise(prefetch bool) {
s.dirtyCodeHash = nil
}
if s.db.prefetcher != nil && prefetch && len(slotsToPrefetch) > 0 && s.data.Root != types.EmptyRootHash {
s.db.trieParallelLock.Lock()
s.db.prefetcher.prefetch(s.addrHash, s.data.Root, s.address, slotsToPrefetch)
s.db.trieParallelLock.Unlock()
}
if s.dirtyStorage.Length() > 0 {
s.dirtyStorage = newStorage(s.isParallel)
Expand Down
6 changes: 6 additions & 0 deletions core/state/statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -2451,12 +2451,16 @@ func (s *StateDB) AddrPrefetch(slotDb *ParallelStateDB) {
})
obj.storageRecordsLock.RUnlock()
if s.prefetcher != nil && len(slotsToPrefetch) > 0 {
s.trieParallelLock.Lock()
s.prefetcher.prefetch(obj.addrHash, obj.data.Root, obj.address, slotsToPrefetch)
s.trieParallelLock.Unlock()
}
}

if s.prefetcher != nil && len(addressesToPrefetch) > 0 {
s.trieParallelLock.Lock()
s.prefetcher.prefetch(common.Hash{}, s.originalRoot, emptyAddr, addressesToPrefetch)
s.trieParallelLock.Unlock()
}
}

Expand Down Expand Up @@ -2623,7 +2627,9 @@ func (s *StateDB) MergeSlotDB(slotDb *ParallelStateDB, slotReceipt *types.Receip
}

if s.prefetcher != nil && len(addressesToPrefetch) > 0 {
s.trieParallelLock.Lock()
s.prefetcher.prefetch(common.Hash{}, s.originalRoot, emptyAddr, addressesToPrefetch) // prefetch for trie node of account
s.trieParallelLock.Unlock()
}

for addr := range slotDb.stateObjectsPending {
Expand Down

0 comments on commit 7ef4adf

Please sign in to comment.