-
Notifications
You must be signed in to change notification settings - Fork 105
fix(replay): fix execution with eth_getProof #4616
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes execution with eth_getProof by addressing issues with the trie implementation when nodes are missing. The solution involves pre-injecting nodes into the trie and adding dummy nodes to handle missing references.
Key changes:
- Pre-inject root nodes into the state trie to ensure they're available for child node discovery
- Extract trie traversal logic into a helper function for code reusability
- Insert dummy branch nodes for missing storage node references to prevent execution failures
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
crates/common/trie/node/branch.rs | Add Default trait to BranchNode to enable creation of dummy nodes |
cmd/ethrex_replay/src/rpc/db.rs | Fix root node injection by ensuring it's added to state_nodes collection |
cmd/ethrex_replay/src/lib.rs | Add helpers module to lib exports |
cmd/ethrex_replay/src/helpers.rs | New helper function to extract referenced hashes from trie nodes |
cmd/ethrex_replay/src/cli.rs | Refactor trie handling to use helper function and add dummy node injection for storage tries |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Co-authored-by: Copilot <[email protected]>
Benchmark for 8085d49Click to view benchmark
|
cmd/ethrex_replay/src/helpers.rs
Outdated
Node::Branch(node) => { | ||
for choice in &node.choices { | ||
let NodeRef::Hash(hash) = *choice else { | ||
unreachable!() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Return errors instead of this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! just one comment
Benchmark for 5dc4763Click to view benchmark
|
Benchmark for 48c2cd0Click to view benchmark
|
Benchmark for d43e64cClick to view benchmark
|
Pull Request is not mergeable
Benchmark for 72c30cdClick to view benchmark
|
Benchmark for 14c6871Click to view benchmark
|
Motivation
Description
Execution with eth_getProof had some caveats regarding the trie. For making it work we need to do 2 things:
The
1
was already done in the code but wasn't working properly, the problem was just that the root node wasn't being inserted into the nodes that were used for building the trie that's used for getting potential child nodes.The 2 is a modification that we don't want in our MPT so we didn't carry along with that. However, in execution without zkVM we have the possibility of inserting arbitrary nodes with the hashes that we want and RLP content that doesn't necessarily match to that hash, so we can "deceive" the trie into thinking it has some nodes when in fact they are just dummy nodes.
How can we use it to our advantage? We insert dummy branch nodes in every single place where a storage node is being referenced but it's missing. This way, if we want to do a trie restructuring we will find the node that otherwise we wouldn't have found, and the good thing is that we don't care about the contents of this node because they won't change, in this particular case the node will be referenced by a one nibble extension node. For more info read https://github.com/kkrt-labs/zk-pig/blob/main/docs/modified-mpt.md#modified-mpt-implementation
Closes #issue_number