From 33c0b5dd69700247bd09e64fbf838cad9ef4f641 Mon Sep 17 00:00:00 2001 From: Pratik Patil Date: Mon, 18 Sep 2023 10:43:16 +0530 Subject: [PATCH] added mutex to trie.tracer (#1007) --- trie/trie.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/trie/trie.go b/trie/trie.go index 33b14bfd55..726308ff80 100644 --- a/trie/trie.go +++ b/trie/trie.go @@ -21,6 +21,7 @@ import ( "bytes" "errors" "fmt" + "sync" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" @@ -48,7 +49,8 @@ type Trie struct { // tracer is the tool to track the trie changes. // It will be reset after each commit operation. - tracer *tracer + tracer *tracer + tracerMutex sync.Mutex } // newFlag returns the cache flag value for a newly created node. @@ -605,7 +607,9 @@ func (t *Trie) resolveAndTrack(n hashNode, prefix []byte) (node, error) { return nil, err } + t.tracerMutex.Lock() t.tracer.onRead(prefix, blob) + t.tracerMutex.Unlock() return mustDecodeNode(n, blob), nil }