trie/bintrie: spec change, big endian hashing of slot key

This commit is contained in:
Guillaume Ballet 2026-04-06 17:16:58 +02:00
parent 8a3a309fa9
commit ad758e1f8f

View file

@ -54,15 +54,12 @@ func getBinaryTreeKey(addr common.Address, offset []byte, overflow bool) []byte
defer returnSha256(hasher) defer returnSha256(hasher)
hasher.Write(zeroHash[:12]) hasher.Write(zeroHash[:12])
hasher.Write(addr[:]) hasher.Write(addr[:])
var buf [32]byte var buf [32]byte // TODO: make offset a 33-byte value to avoid an extra stack alloc
// key is big endian, hashed value is little endian copy(buf[1:32], offset[:31])
for i := range offset[:31] {
buf[i] = offset[30-i]
}
if overflow { if overflow {
// Overflow detected when adding MAIN_STORAGE_OFFSET, // Overflow detected when adding MAIN_STORAGE_OFFSET,
// reporting it in the shifter 32 byte value. // reporting it in the shifter 32 byte value.
buf[31] = 1 buf[0] = 1
} }
hasher.Write(buf[:]) hasher.Write(buf[:])
k := hasher.Sum(nil) k := hasher.Sum(nil)