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

fix(l1): remove "inconsistent internal tree structure" panics #1288

Merged
merged 10 commits into from
Nov 29, 2024

Conversation

xqft
Copy link
Contributor

@xqft xqft commented Nov 26, 2024

Motivation

The Trie library assumes that all tries are well-formed: this means that if some node contains the hash of a child, then that child is in the tire's database. If this doesn't hold, then a get() call panics with an inconsistent internal tree structure message.

For the L2 prover we're using "pruned tries" which only store the relevant nodes for the set of values touched in some execution, breaking the previous hypothesis. One option was to capture the panics on the get calls, but this wasn't safe because Trie has internal mutability. The path chosen is to remove the panics altogether and replace them with errors.

Description

  • replaces mentioned panics for errors

@xqft xqft changed the title fix(l2): capture panics on get() calls for pruned tries fix(l2): remove "inconsistent internal tree structure" panics Nov 27, 2024
@xqft xqft marked this pull request as ready for review November 27, 2024 15:42
@xqft xqft requested a review from a team as a code owner November 27, 2024 15:42
@xqft xqft changed the title fix(l2): remove "inconsistent internal tree structure" panics fix(l1): remove "inconsistent internal tree structure" panics Nov 27, 2024
@xqft xqft added the L1 label Nov 27, 2024
// it's potentially a new account. This is because we're using pruned tries
// so the path into a new account might not be included in the pruned state trie.
let mut account_state = match account_state {
Ok(Some(encoded_state)) => AccountState::decode(&encoded_state)?,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we use "?" instead of matching with multiple Oks/Err?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't because we want to match the InconsistentTree error and interpret it as a "state not found" error instead of propagating it

Copy link
Contributor

@fmoletta fmoletta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! This is very useful! 🚀

@jrchatruc jrchatruc added this pull request to the merge queue Nov 29, 2024
Merged via the queue into main with commit 3b25e94 Nov 29, 2024
16 checks passed
@jrchatruc jrchatruc deleted the l2/capture_trie_panic branch November 29, 2024 19:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants