diff --git a/trie/bintrie/store_ops.go b/trie/bintrie/store_ops.go index ad47347986..23e3e4520e 100644 --- a/trie/bintrie/store_ops.go +++ b/trie/bintrie/store_ops.go @@ -278,6 +278,11 @@ func (s *NodeStore) splitStemValuesInsert(existingRef nodeRef, newStem []byte, v } newChild, err := s.insertValuesAtStem(child, newStem, values, resolver, depth+1) if err != nil { + // Roll back the depth increment so a retry sees the same + // existing state and extracts bitStem at the correct offset. + // nRef itself leaks (no internal free-list), but the slot is + // unreachable from the tree and harmless. + existing.depth-- return nRef, err } if bitStem == 0 {