fix the race condition by using lru.Cache

Signed-off-by: Guillaume Ballet <3272758+gballet@users.noreply.github.com>
This commit is contained in:
Guillaume Ballet 2025-07-14 11:37:43 +02:00
parent 7fd5179029
commit 86183a8373

View file

@ -201,7 +201,7 @@ type CachingDB struct {
pointCache *utils.PointCache pointCache *utils.PointCache
// Transition-specific fields // Transition-specific fields
TransitionStatePerRoot lru.BasicLRU[common.Hash, *TransitionState] TransitionStatePerRoot *lru.Cache[common.Hash, *TransitionState]
} }
// NewDatabase creates a state database with the provided data sources. // NewDatabase creates a state database with the provided data sources.
@ -213,7 +213,7 @@ func NewDatabase(triedb *triedb.Database, snap *snapshot.Tree) *CachingDB {
codeCache: lru.NewSizeConstrainedCache[common.Hash, []byte](codeCacheSize), codeCache: lru.NewSizeConstrainedCache[common.Hash, []byte](codeCacheSize),
codeSizeCache: lru.NewCache[common.Hash, int](codeSizeCacheSize), codeSizeCache: lru.NewCache[common.Hash, int](codeSizeCacheSize),
pointCache: utils.NewPointCache(pointCacheSize), pointCache: utils.NewPointCache(pointCacheSize),
TransitionStatePerRoot: lru.NewBasicLRU[common.Hash, *TransitionState](1000), TransitionStatePerRoot: lru.NewCache[common.Hash, *TransitionState](1000),
} }
} }