ethereum/go-ethereum · error
trying to insert into hash
Error message
trying to insert into hash
What it means
Error "trying to insert into hash" thrown in ethereum/go-ethereum.
Source
Thrown at trie/stacktrie.go:328
// value and another containing the new value. The child leaf
// is hashed directly in order to free up some memory.
origIdx := st.key[diffidx]
p.children[origIdx] = newLeaf(st.key[diffidx+1:], st.val)
t.hash(p.children[origIdx], append(path, st.key[:diffidx+1]...))
newIdx := key[diffidx]
p.children[newIdx] = newLeaf(key[diffidx+1:], value)
// Finally, cut off the key part that has been passed
// over to the children.
st.key = st.key[:diffidx]
st.val = nil
case emptyNode: /* Empty */
*st = *newLeaf(key, value)
case hashedNode:
panic("trying to insert into hash")
default:
panic("invalid type")
}
}
// hash converts st into a 'hashedNode', if possible. Possible outcomes:
//
// 1. The rlp-encoded value was >= 32 bytes:
// - Then the 32-byte `hash` will be accessible in `st.val`.
// - And the 'st.type' will be 'hashedNode'
//
// 2. The rlp-encoded value was < 32 bytes
// - Then the <32 byte rlp-encoded value will be accessible in 'st.val'.
// - And the 'st.type' will be 'hashedNode' AGAIN
//
// This method also sets 'st.type' to hashedNode, and clears 'st.key'.
func (t *StackTrie) hash(st *stNode, path []byte) {View on GitHub (pinned to 6bb0588ad8)
Solutions
- Insertions must happen before the trie is hashed/committed. Do not call Update on a StackTrie after its nodes have been hashed; build a new StackTrie for new data.
- Insert keys in strictly ascending order so the stacktrie never needs to descend into an already-hashed node.
Example fix
// Sort keys before insertion; never insert after st.Hash()/Commit().
for _, kv := range sortedKVs { st.Update(kv.K, kv.V) }
root := st.Hash() When it happens
Trigger: Attempting to insert a key whose path descends into a node that was already converted to a hash — i.e., out-of-order insertion into a StackTrie.
Common situations: Unsorted or interleaved insert/hash usage of StackTrie during block derivation or receipt root computation.
AI-assisted analysis of ethereum/go-ethereum@6bb0588ad8 (2026-08-15).
Data as JSON: /api/errors/3ff6f2da3722d5f7.
Report an issue: GitHub.