From a20f0aa1b67855ad6950a805a301c3292879dcda Mon Sep 17 00:00:00 2001 From: Jerry Date: Fri, 9 May 2025 10:49:50 -0700 Subject: [PATCH] [bug fix] Avoid concurrent access to hasher buffer --- core/state/reader.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/state/reader.go b/core/state/reader.go index cd960a60a8..667082439c 100644 --- a/core/state/reader.go +++ b/core/state/reader.go @@ -79,7 +79,7 @@ func newStateReader(root common.Hash, snaps *snapshot.Tree) (*stateReader, error // // The returned account might be nil if it's not existent. func (r *stateReader) Account(addr common.Address) (*types.StateAccount, error) { - ret, err := r.snap.Account(crypto.HashData(r.buff, addr.Bytes())) + ret, err := r.snap.Account(crypto.HashData(crypto.NewKeccakState(), addr.Bytes())) if err != nil { return nil, err } @@ -109,8 +109,8 @@ func (r *stateReader) Account(addr common.Address) (*types.StateAccount, error) // // The returned storage slot might be empty if it's not existent. func (r *stateReader) Storage(addr common.Address, key common.Hash) (common.Hash, error) { - addrHash := crypto.HashData(r.buff, addr.Bytes()) - slotHash := crypto.HashData(r.buff, key.Bytes()) + addrHash := crypto.HashData(crypto.NewKeccakState(), addr.Bytes()) + slotHash := crypto.HashData(crypto.NewKeccakState(), key.Bytes()) ret, err := r.snap.Storage(addrHash, slotHash) if err != nil { return common.Hash{}, err @@ -223,7 +223,7 @@ func (r *trieReader) Storage(addr common.Address, key common.Hash) (common.Hash, root = r.subRoots[addr] } var err error - tr, err = trie.NewStateTrie(trie.StorageTrieID(r.root, crypto.HashData(r.buff, addr.Bytes()), root), r.db) + tr, err = trie.NewStateTrie(trie.StorageTrieID(r.root, crypto.HashData(crypto.NewKeccakState(), addr.Bytes()), root), r.db) if err != nil { return common.Hash{}, err }