From b5b5eb223978164423885a149ea2abfbc19473b7 Mon Sep 17 00:00:00 2001 From: DavidZang <110075234+DavidZangNR@users.noreply.github.com> Date: Tue, 20 Aug 2024 09:08:58 +0800 Subject: [PATCH] Fix: contention issue of Trie for PEVM (#41) Co-authored-by: Sunny --- core/state/state_object.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/state/state_object.go b/core/state/state_object.go index 010a9abe71..d2f988c6c5 100644 --- a/core/state/state_object.go +++ b/core/state/state_object.go @@ -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) } @@ -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) }