trie: Fix unit tests when trie refs are reset#19113
Merged
Merged
Conversation
Contributor
Author
|
RPC eth_getProof test suite passes as well. |
antonis19
commented
Feb 11, 2026
Comment on lines
-1660
to
-1681
| // we need to check if we are dealing with the next node being an account node and we have a storage key, | ||
| // in that case start a new tree for the storage | ||
| if nextAccNode, ok := nextNode.(*trie.AccountNode); ok && len(hashedKey) > 64 { | ||
| // If the account has an empty storage root, stop traversal here. | ||
| // There's no storage trie to expand into, and continuing would incorporate | ||
| // garbage data from rows below the account into the proof. | ||
| if nextAccNode.Root == trie.EmptyRoot { | ||
| if hph.trace { | ||
| fmt.Printf("[witness] AccountNode (empty storage root, break) (%d, %0x, depth=%d) %s proof %+v\n", row, currentNibble, hph.depths[row], cellToExpand.FullString(), nextAccNode) | ||
| } | ||
| break | ||
| } | ||
| if cellToExpand.hashedExtLen > 0 { | ||
| extKey := common.Copy(cellToExpand.hashedExtension[:cellToExpand.hashedExtLen]) | ||
| nextNode = &trie.ShortNode{Key: extKey} | ||
| } else { | ||
| nextNode = &trie.FullNode{} | ||
| } | ||
| nextAccNode.Storage = nextNode | ||
| if hph.trace { | ||
| fmt.Printf("[witness] AccountNode (+StorageTrie) (%d, %0x, depth=%d) %s [proof %+v\n", row, currentNibble, hph.depths[row], cellToExpand.FullString(), nextAccNode) | ||
| } |
Contributor
Author
There was a problem hiding this comment.
This was dead code.
mh0lt
approved these changes
Feb 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Some tests in
Test_WitnessTrie_GenerateWitnessincorrectly passed because the cached trie node hashes were cached, but whentr.Reset()was being called, the unit tests started failing which exposed issues in the trie structure.Due to this, problems appeared with the witness of #18290 because proofs are requested even for storage keys that haven't been created yet for accounts with no storage, and there was no logic to prevent traversing further than the account. There was a handling introduced for that in #18988 but the fix there was insufficient and the caching hid that the problem wasn't fixed.
This PR fixes the unit tests correctly.