-
Notifications
You must be signed in to change notification settings - Fork 117
refactor(l1): make TrieError::InconsistentTree more specific #4836
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
Merged
Merged
Changes from 16 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
3f423cf
make TrieError::InconsistentTree point the node's hash
cdiielsi a0d62b6
Merge branch 'main' into more-specific-trie-error
cdiielsi 335cac6
add more errors
cdiielsi 8f37de6
upgrade error name to be shorter
cdiielsi 91f0139
print NodeRef instead of the hash for all cases
cdiielsi d1ba664
merge main into branch
cdiielsi 782f3bf
Merge branch 'main' into more-specific-trie-error
cdiielsi 61c17d6
show node hashes for any type of node
cdiielsi 569a4c1
fix for clippy
cdiielsi c96891c
drop impl Debug for NodeHash
cdiielsi 5f0c9bf
new enum for inconsistent tree error more specific
cdiielsi 3118135
new struct for ExtensionNodeError metadata boxed to not mess with per…
cdiielsi 7d44ad2
new get_root_node method
cdiielsi 2b94661
change errors for insertion on Extension node
cdiielsi 47863ea
Merge branch 'main' into more-specific-trie-error
cdiielsi ab4f7cd
Box InconsistentTreeError
cdiielsi e721265
drop Box used in InconsistentTreeError and add comment on why Box
cdiielsi aa26484
Merge branch 'main' into more-specific-trie-error
cdiielsi ff58529
Merge branch 'main' into more-specific-trie-error
cdiielsi dad633a
add comment on why Box
cdiielsi 7d2cc47
Merge branch 'more-specific-trie-error' of github.com:lambdaclass/eth…
cdiielsi 8a1b84a
Merge branch 'main' into more-specific-trie-error
cdiielsi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,18 +1,51 @@ | ||
| use ethereum_types::H256; | ||
| use ethrex_rlp::error::RLPDecodeError; | ||
| use thiserror::Error; | ||
|
|
||
| use crate::Nibbles; | ||
|
|
||
| #[derive(Debug, Error)] | ||
| pub enum TrieError { | ||
| #[error(transparent)] | ||
| RLPDecode(#[from] RLPDecodeError), | ||
| #[error("Verification Error: {0}")] | ||
| Verify(String), | ||
| #[error("Inconsistent internal tree structure")] | ||
| InconsistentTree, | ||
| #[error("Inconsistent internal tree structure: {0}")] | ||
| InconsistentTree(Box<InconsistentTreeError>), | ||
| #[error("Lock Error: Panicked when trying to acquire a lock")] | ||
| LockError, | ||
| #[error("Database error: {0}")] | ||
| DbError(anyhow::Error), | ||
| #[error("Invalid trie input")] | ||
| InvalidInput, | ||
| } | ||
|
|
||
| #[derive(Debug, Error)] | ||
| pub enum InconsistentTreeError { | ||
| #[error("Child node of {0}, differs from expected")] | ||
| ExtensionNodeChildDiffers(Box<ExtensionNodeErrorData>), | ||
| #[error("No Child Node found of {0}")] | ||
| ExtensionNodeChildNotFound(Box<ExtensionNodeErrorData>), | ||
cdiielsi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| #[error("Node with hash {0:#x} not found in Branch Node with hash {1:#x} using path {2:?}")] | ||
| NodeNotFoundOnBranchNode(H256, H256, Nibbles), | ||
| #[error("Root node with hash {0:#x} not found")] | ||
| RootNotFound(H256), | ||
| } | ||
|
|
||
| #[derive(Debug)] | ||
| pub struct ExtensionNodeErrorData { | ||
| pub node_hash: H256, | ||
| pub extension_node_hash: H256, | ||
| pub extension_node_prefix: Nibbles, | ||
| pub node_path: Nibbles, | ||
| } | ||
|
|
||
| impl std::fmt::Display for ExtensionNodeErrorData { | ||
| fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
| write!( | ||
| f, | ||
| "Node with hash {:#x}, child of the Extension Node (hash {:#x}, prefix {:?}) on path {:?}", | ||
| self.node_hash, self.extension_node_hash, self.extension_node_hash, self.node_path | ||
| ) | ||
| } | ||
| } | ||
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.