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

Theodore/proofnarrowing #34

Merged
merged 5 commits into from
Sep 10, 2024
Merged

Theodore/proofnarrowing #34

merged 5 commits into from
Sep 10, 2024

Conversation

theodorebugnet
Copy link
Contributor

Add proof narrowing capabilities to the tree: given a range proof, supply two sets of leafs (contiguous with the edges of the original range), to generate a proof for the remaining sub-range.

This feature is useful for generating proofs of individual blobs in a Celestia namespace using the full-namespace proof returned by the GetSharesByNamespace RPC call.

Going above 20 was quickly becoming too slow anyway, so no real point in adding an extra dependency and more indirection.
Cargo.toml Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
src/nmt_proof.rs Outdated Show resolved Hide resolved
src/nmt_proof.rs Outdated Show resolved Hide resolved
Copy link
Member

@preston-evans98 preston-evans98 left a comment

Choose a reason for hiding this comment

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

Based on the new test (which is very nice, btw!) this seems to work when the inputs are well-constructed. Unfortunately, it's pretty difficult to be confident about the correctness at a logical level given the current state of the code. Since this is pretty involved logic, I think it's probably worth investing in even more detailed explanations (probably including diagrams) in the core functions.

@theodorebugnet
Copy link
Contributor Author

theodorebugnet commented Sep 2, 2024

Actually your comment about the ranges is spot-on - the current test was missing a whole bunch of edge cases due to being non-inclusive. Whoops!
I'm fixing that now, and then it will probably be fine to assert that "it seems to work".

Happy to add some more comments and explanations, especially now that I've slept on it and can look at it from a slight distance.

@theodorebugnet
Copy link
Contributor Author

By the way, the codecov.io token seems dead, so the badge in the README isn't updating anymore

 - reverted the tendermint version bump
 - fixed edge cases on trees of total size 0 and 1
 - fixed incorrect implementation in nmt_proof.rs (now just wraps the simple proof.rs)
 - fixed missing test cases for the above two issues
 - cleaned up inconsistent parameter naming to be more clear
 - cleaned up large argument sets in a few places to make data flow easier to follow
 - documented all assertions with a description of why they should never break
 - added documentation to the functions and descriptions of the narrowing logic
Copy link
Member

@preston-evans98 preston-evans98 left a comment

Choose a reason for hiding this comment

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

Thanks for making a pass on the naming and docs. It's much easier to understand this time around. Looks great, thanks @theodorebugnet!

@theodorebugnet theodorebugnet merged commit 7b73324 into master Sep 10, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants