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 536d5d9 commit b2082a0
Show file tree
Hide file tree
Showing 2 changed files with 8 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 @@ -1800,7 +1800,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
6 changes: 6 additions & 0 deletions core/state/statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -2461,14 +2461,18 @@ 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 {
// log.Info("AddrPrefetch", "slotDb.TxIndex", slotDb.TxIndex(),
// "len(addressesToPrefetch)", len(slotDb.parallel.addressesToPrefetch))
s.trieParallelLock.Lock()
s.prefetcher.prefetch(common.Hash{}, s.originalRoot, emptyAddr, addressesToPrefetch)
s.trieParallelLock.Unlock()
}
}

Expand Down Expand Up @@ -2645,7 +2649,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 b2082a0

Please sign in to comment.