-
Notifications
You must be signed in to change notification settings - Fork 117
chore(l2): refactor get_embedded_node and remove hash cloning
#5001
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -56,6 +56,24 @@ impl NodeHash { | |
| } | ||
| } | ||
|
|
||
| /// Returns a reference to the finalized hash, hashing `self` if it's `NodeHash::Inline`, and storing the result by | ||
| /// changing it to the `NodeHash::Hashed` variant. | ||
| pub fn finalize_mut(&mut self) -> &H256 { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This function leaves the tree in an inconsistent state, right? If any function expects There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You mean if there's a function that expects the node's RLP encoding (in the case it's <32 bytes) instead of its hash? Which caller could assume that? and also, how could that leave a trie in an inconsistent state? |
||
| if let NodeHash::Inline(_) = self { | ||
| let hash = H256( | ||
| Keccak256::new() | ||
| .chain_update(self.as_ref()) | ||
| .finalize() | ||
| .into(), | ||
| ); | ||
| *self = NodeHash::Hashed(hash); | ||
| } | ||
| let NodeHash::Hashed(hash_ref) = self else { | ||
| unreachable!(); | ||
| }; | ||
| hash_ref | ||
| } | ||
|
|
||
| /// Returns true if the hash is valid | ||
| /// The hash will only be considered invalid if it is empty | ||
| /// Aka if it has a default value instead of being a product of hash computation | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.