mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-04-13 13:18:35 +00:00
trie/bintrie: spec change, big endian hashing of slot key (#34670)
The spec has been changed during SIC #49, the offset is encoded as a big-endian number.
This commit is contained in:
parent
6333855163
commit
735bfd121a
2 changed files with 4 additions and 7 deletions
|
|
@ -308,7 +308,7 @@ func TestVerkleGenesisCommit(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
expected := common.FromHex("1fd154971d9a386c4ec75fe7138c17efb569bfc2962e46e94a376ba997e3fadc")
|
||||
expected := common.FromHex("0870fd587c41dc778019de8c5cb3193fe4ef1f417976461952d3712ba39163f5")
|
||||
got := genesis.ToBlock().Root().Bytes()
|
||||
if !bytes.Equal(got, expected) {
|
||||
t.Fatalf("invalid genesis state root, expected %x, got %x", expected, got)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue