trie/bintrie: use correct key mapping in GetStorage and DeleteStorage

This commit is contained in:
phrwlk 2026-02-10 00:37:19 +02:00 committed by GitHub
parent c9b7ae422c
commit 28397f4f25
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -236,7 +236,7 @@ func (t *BinaryTrie) GetAccount(addr common.Address) (*types.StateAccount, error
// not be modified by the caller. If a node was not found in the database, a // not be modified by the caller. If a node was not found in the database, a
// trie.MissingNodeError is returned. // trie.MissingNodeError is returned.
func (t *BinaryTrie) GetStorage(addr common.Address, key []byte) ([]byte, error) { func (t *BinaryTrie) GetStorage(addr common.Address, key []byte) ([]byte, error) {
return t.root.Get(GetBinaryTreeKey(addr, key), t.nodeResolver) return t.root.Get(GetBinaryTreeKeyStorageSlot(addr, key), t.nodeResolver)
} }
// UpdateAccount updates the account information for the given address. // UpdateAccount updates the account information for the given address.
@ -302,7 +302,7 @@ func (t *BinaryTrie) DeleteAccount(addr common.Address) error {
// DeleteStorage removes any existing value for key from the trie. If a node was not // DeleteStorage removes any existing value for key from the trie. If a node was not
// found in the database, a trie.MissingNodeError is returned. // found in the database, a trie.MissingNodeError is returned.
func (t *BinaryTrie) DeleteStorage(addr common.Address, key []byte) error { func (t *BinaryTrie) DeleteStorage(addr common.Address, key []byte) error {
k := GetBinaryTreeKey(addr, key) k := GetBinaryTreeKeyStorageSlot(addr, key)
var zero [HashSize]byte var zero [HashSize]byte
root, err := t.root.Insert(k, zero[:], t.nodeResolver, 0) root, err := t.root.Insert(k, zero[:], t.nodeResolver, 0)
if err != nil { if err != nil {