From 3c1443e5251a654b310ce674ec182a2127d5107d Mon Sep 17 00:00:00 2001 From: jsvisa Date: Wed, 29 Oct 2025 03:17:15 +0000 Subject: [PATCH] triedb/pathdb: use copy instead of append to reduce memory alloc Signed-off-by: jsvisa --- triedb/pathdb/disklayer.go | 3 ++- triedb/pathdb/flush.go | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/triedb/pathdb/disklayer.go b/triedb/pathdb/disklayer.go index 76f3f5a46ea..7ad31ced415 100644 --- a/triedb/pathdb/disklayer.go +++ b/triedb/pathdb/disklayer.go @@ -275,7 +275,8 @@ func (dl *diskLayer) storage(accountHash, storageHash common.Hash, depth int) ([ // If the layer is being generated, ensure the requested storage slot // has already been covered by the generator. - key := append(accountHash[:], storageHash[:]...) + skey := storageKey(accountHash, storageHash) + key := skey[:] marker := dl.genMarker() if marker != nil && bytes.Compare(key, marker) > 0 { return nil, errNotCoveredYet diff --git a/triedb/pathdb/flush.go b/triedb/pathdb/flush.go index 6563dbccff6..1be684a257c 100644 --- a/triedb/pathdb/flush.go +++ b/triedb/pathdb/flush.go @@ -116,15 +116,17 @@ func writeStates(batch ethdb.Batch, genMarker []byte, accountData map[common.Has continue } slots += 1 + skey := storageKey(addrHash, storageHash) + key := skey[:] if len(blob) == 0 { rawdb.DeleteStorageSnapshot(batch, addrHash, storageHash) if clean != nil { - clean.Set(append(addrHash[:], storageHash[:]...), nil) + clean.Set(key, nil) } } else { rawdb.WriteStorageSnapshot(batch, addrHash, storageHash, blob) if clean != nil { - clean.Set(append(addrHash[:], storageHash[:]...), blob) + clean.Set(key, blob) } } }