Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug(trie): invalid trie masks #12129

Open
rkrasiuk opened this issue Oct 28, 2024 · 2 comments
Open

bug(trie): invalid trie masks #12129

rkrasiuk opened this issue Oct 28, 2024 · 2 comments
Labels
A-trie Related to Merkle Patricia Trie implementation C-bug An unexpected or incorrect behavior

Comments

@rkrasiuk
Copy link
Member

rkrasiuk commented Oct 28, 2024

Description

Currently, we commit intermediate trie nodes with invalid trie masks (issue to be amended with the cause after investigation cc @fgimenez). This causes trie walker to have invalid stack when it calls self.consume_node and pushes a subnode to the stack which does not share a common prefix with the previous last node on the stack.

if !self.can_skip_current_node && self.children_are_in_trie() {
// If we can't skip the current node and the children are in the trie,
// either consume the next node or move to the next sibling.
match last.nibble() {
-1 => self.move_to_next_sibling(true)?,
_ => self.consume_node()?,
}
} else {
// If we can skip the current node, move to the next sibling.
self.move_to_next_sibling(false)?;
}
// Update the skip node flag based on the new position in the trie.
self.update_skip_node();

Once the subnode is done processing, it comes back to a previous one and returns a node key that is out of order causing has builder to panic.

Addition Info

Issue reports: #11471, #11955

@rkrasiuk rkrasiuk added C-bug An unexpected or incorrect behavior A-trie Related to Merkle Patricia Trie implementation labels Oct 28, 2024
@jenpaff jenpaff added this to the release 1.1.1 milestone Oct 28, 2024
@DaveWK
Copy link

DaveWK commented Oct 28, 2024

I saw the recent fix come in and was wondering if this also has the potential to write a bunch of dangling storage tries that never get used?

I noticed there's the command reth recover storage-tries and wondering if this would be beneficial to run on my node to potentially clean up bad entries that are being written/read from disk and impacting the db performance. Also wondering if this storage trie cleanup ran periodically during normal operation as a form of maintenance/vacuuming to reduce excess writes/storage.

@fgimenez
Copy link
Member

We have tests that show the issue here #12080

@mattsse mattsse removed this from the release 1.1.1 milestone Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-trie Related to Merkle Patricia Trie implementation C-bug An unexpected or incorrect behavior
Projects
Status: Todo
Development

No branches or pull requests

5 participants