From 2443349b31df798b0af10252e978bab32ceefc0f Mon Sep 17 00:00:00 2001 From: devopsbo3 <69951731+devopsbo3@users.noreply.github.com> Date: Fri, 10 Nov 2023 12:27:53 -0600 Subject: [PATCH] Revert "core/rawdb: allocate database keys with explicit size to avoid slice growth (#27772)" This reverts commit 4639725b104945962fac7589c4107c45ac606528. --- core/rawdb/schema.go | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/core/rawdb/schema.go b/core/rawdb/schema.go index 7269fe5d56..b9b9aae0d2 100644 --- a/core/rawdb/schema.go +++ b/core/rawdb/schema.go @@ -195,11 +195,7 @@ func accountSnapshotKey(hash common.Hash) []byte { // storageSnapshotKey = SnapshotStoragePrefix + account hash + storage hash func storageSnapshotKey(accountHash, storageHash common.Hash) []byte { - buf := make([]byte, len(SnapshotStoragePrefix)+common.HashLength+common.HashLength) - n := copy(buf, SnapshotStoragePrefix) - n += copy(buf[n:], accountHash.Bytes()) - copy(buf[n:], storageHash.Bytes()) - return buf + return append(append(SnapshotStoragePrefix, accountHash.Bytes()...), storageHash.Bytes()...) } // storageSnapshotsKey = SnapshotStoragePrefix + account hash + storage hash @@ -263,11 +259,7 @@ func accountTrieNodeKey(path []byte) []byte { // storageTrieNodeKey = trieNodeStoragePrefix + accountHash + nodePath. func storageTrieNodeKey(accountHash common.Hash, path []byte) []byte { - buf := make([]byte, len(trieNodeStoragePrefix)+common.HashLength+len(path)) - n := copy(buf, trieNodeStoragePrefix) - n += copy(buf[n:], accountHash.Bytes()) - copy(buf[n:], path) - return buf + return append(append(trieNodeStoragePrefix, accountHash.Bytes()...), path...) } // IsLegacyTrieNode reports whether a provided database entry is a legacy trie