-
Notifications
You must be signed in to change notification settings - Fork 234
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
feat: add pathfinder_getProof
#726
Conversation
88c9136
to
213336b
Compare
I've had a (non-comprehnsive) look at the code so far. I mainly focussed on the test code because
failed to pass. I'll look at rest of the code tomorrow. Also test code is the most important code :D The tests failed due to bugs in the If we consider what some external
To verify the graphness, we'll have to verify the hashes as we go along. The current So I would first suggest creating a new enum type (couldn't think of better names on the fly, feel free to experiment): pub enum ProofNode {
Edge(EdgeProofNode),
Binary(BinaryProofNode),
}
pub struct BinaryProofNode {
left: StarkHash,
right: StarkHash,
}
pub struct EdgeProofNode {
pub path: BitVec<Msb0, u8>,
child: StarkHash
} This will more accurately describe what you'll see. Note that a I would then suggest an algorithm as follows for
|
213336b
to
4c2cb91
Compare
4c2cb91
to
afb51bd
Compare
Hey @Mirko-von-Leipzig , thanks for your comment. Your algorithm is so much more cleaner and elegant than what I had come up with.
I do already have a couple of questions though:
|
I would suggest keeping the commits and just doing normal pushes.
You should move those definitions into the
I think that its a proper
I'll have a look, but I would say just keep that as the last thing todo once you're sure everything is 100% correct and you're happy with the API. In general:
|
So the I've moved the Regarding the
|
Yes, thats true -- for now. At some point you'll have to use them in the RPC code to translate it from our pathfinder internal code (what you're busy with now) into json. At that point you'll be mapping from the these internal structs and their fields into json. But for now just slapping
I think it depends on what we want to return in the RPC.. its technically redudant information but if we include it, then we have to add a leaf type to the RPC enum. And callers still have to verify that the full path is correct - so I don't think there is any value in having it. I would remove it - however you can't simply A nice functional way to remove it nicely (i.e. without raw indices): if matches!(nodes.last(), Some(Node::Leaf(_))) {
nodes.pop();
}
💪 Probably means that its worth adding a comment explaining this for the next poor soul that has to try understand the intent of it all :) And thanks for keeping the commits - as you've noticed it means you can even point me at which ones do what. Makes discussions simpler etc. |
… Option<Membership> instead of bool
match context | ||
.pending_data | ||
.ok_or_else(|| anyhow!("Pending data not supported in this configuration"))? | ||
.state_update() | ||
.await | ||
{ | ||
Some(update) => { | ||
let pending_value = update | ||
.state_diff | ||
.storage_diffs | ||
.get(&input.contract_address) | ||
.and_then(|storage| { | ||
storage.iter().find_map(|update| { | ||
(update.key == input.key).then_some(update.value) | ||
}) | ||
}); | ||
|
||
// match pending_value { | ||
// Some(value) => return Ok(value), | ||
// None => StarknetBlocksBlockId::Latest, | ||
// } | ||
StarknetBlocksBlockId::Latest | ||
} | ||
None => StarknetBlocksBlockId::Latest, | ||
} | ||
} |
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.
Need to find a way to fix that :)
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.
Overall, looking very good! Thanks for all your effort on this!
Co-authored-by: Mirko von Leipzig <48352201+Mirko-von-Leipzig@users.noreply.github.com>
Co-authored-by: Mirko von Leipzig <48352201+Mirko-von-Leipzig@users.noreply.github.com>
I'm yet to go through the tests, but overall everything looks good |
Co-authored-by: CHr15F0x <42979253+CHr15F0x@users.noreply.github.com>
Co-authored-by: CHr15F0x <42979253+CHr15F0x@users.noreply.github.com>
I've just gone through the tests, I really like it. And I do appreciate the ascii art 👍 which always helps with understanding the concept of this tree when going through examples, which these tests in fact are. |
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 - we'll need to do some follow-ups on the issues you've created to complete this entirely, but should be fairly quick.
Thanks again; really appreciate all the effort you've put in here.
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 👍
Thanks for the effort!
Implementation of #714
pathfinder_getStorageProofs
)get_proof
/get_proofs
forMerkleTree
.verify_proof
function in the test module, that can be used as a starting point for people wanting to implement their own verifier.Closes #714