Skip to content

Commit

Permalink
Fix: contention issue of Trie for PEVM (bnb-chain#41)
Browse files Browse the repository at this point in the history
Co-authored-by: Sunny <sunny2022.za@gmail.com>
  • Loading branch information
DavidZangNR and sunny2022da committed Nov 14, 2024
1 parent d1aad9b commit b5b5eb2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions core/state/state_object.go
Original file line number Diff line number Diff line change
Expand Up @@ -411,14 +411,14 @@ func (s *stateObject) GetCommittedState(key common.Hash) common.Hash {
// If the snapshot is unavailable or reading from it fails, load from the database.
if s.db.snap == nil || err != nil {
start := time.Now()
s.db.trieParallelLock.Lock()
defer s.db.trieParallelLock.Unlock()
tr, err := s.getTrie()
if err != nil {
s.db.setError(err)
return common.Hash{}
}
s.db.trieParallelLock.Lock()
val, err := tr.GetStorage(s.address, key.Bytes())
s.db.trieParallelLock.Unlock()
if metrics.EnabledExpensive {
s.db.StorageReads += time.Since(start)
}
Expand Down Expand Up @@ -977,14 +977,14 @@ func (s *stateObject) GetCommittedStateNoUpdate(key common.Hash) common.Hash {
// If the snapshot is unavailable or reading from it fails, load from the database.
if s.db.snap == nil || err != nil {
start := time.Now()
s.db.trieParallelLock.Lock()
defer s.db.trieParallelLock.Unlock()
tr, err := s.getTrie()
if err != nil {
s.db.setError(err)
return common.Hash{}
}
s.db.trieParallelLock.Lock()
val, err := tr.GetStorage(s.address, key.Bytes())
s.db.trieParallelLock.Unlock()
if metrics.EnabledExpensive {
s.db.StorageReads += time.Since(start)
}
Expand Down

0 comments on commit b5b5eb2

Please sign in to comment.