From ad758e1f8f56466eefc67dc470dd4b6e6c3b7efc Mon Sep 17 00:00:00 2001 From: Guillaume Ballet <3272758+gballet@users.noreply.github.com> Date: Mon, 6 Apr 2026 17:16:58 +0200 Subject: [PATCH] trie/bintrie: spec change, big endian hashing of slot key --- trie/bintrie/key_encoding.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/trie/bintrie/key_encoding.go b/trie/bintrie/key_encoding.go index c009f1529f..265935293b 100644 --- a/trie/bintrie/key_encoding.go +++ b/trie/bintrie/key_encoding.go @@ -54,15 +54,12 @@ func getBinaryTreeKey(addr common.Address, offset []byte, overflow bool) []byte defer returnSha256(hasher) hasher.Write(zeroHash[:12]) hasher.Write(addr[:]) - var buf [32]byte - // key is big endian, hashed value is little endian - for i := range offset[:31] { - buf[i] = offset[30-i] - } + var buf [32]byte // TODO: make offset a 33-byte value to avoid an extra stack alloc + copy(buf[1:32], offset[:31]) if overflow { // Overflow detected when adding MAIN_STORAGE_OFFSET, // reporting it in the shifter 32 byte value. - buf[31] = 1 + buf[0] = 1 } hasher.Write(buf[:]) k := hasher.Sum(nil)