mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-12 01:41:36 +00:00
trie/bintrie: roll back split-stem depth on error
splitStemValuesInsert increments existing.depth before recursing into insertValuesAtStem. If the recursion fails, the depth stays incremented but the tree is not re-rooted through the new internal, so a retry reads bitStem at the wrong offset and can place the stem on the wrong side of a fresh split. Roll back existing.depth on error to keep the stem consistent across retries.
This commit is contained in:
parent
7f20e908e2
commit
99520432ec
1 changed files with 5 additions and 0 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in a new issue