-
Notifications
You must be signed in to change notification settings - Fork 42
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!: adds input range check to optimize VerifyLeafHashes and VerifyInclusion methods #253
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.
LGTM
[To the reviewers] The codecov error is not specific to this PR, I am investigating it. |
Thanks yea agreed the CodeCov issue isn't caused by this PR: #250 |
Waiting on #255 to merge |
…into sanaz/optimization
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #253 +/- ##
==========================================
+ Coverage 66.24% 66.50% +0.26%
==========================================
Files 6 6
Lines 1022 1030 +8
==========================================
+ Hits 677 685 +8
Misses 328 328
Partials 17 17 ☔ View full report in Codecov by Sentry. |
Motivation: because celestia-core v1.37.0 uses NMT v0.21.0 which contains this fix: celestiaorg/nmt#253
Motivation: because celestia-core v1.37.0 uses NMT v0.21.0 which contains this fix: celestiaorg/nmt#253
This PR optimizes the
VerifyLeafHashes
andVerifyInclusion
methods by ensuring that the size of the provided leaves or leaf hashes matches the proof range and, if not, making an early return in order to prevent unnecessary hashing operations that would otherwise occur.It introduces a breaking change by altering the behaviour of
VerifyLeafHashes
andVerifyInclusion
. Previously, verification would succeed even if the provided leaves or leaf hashes exceeded the proof range, as long as the proof was valid and the extra leaves were appended at the end. In the new implementation, the verification will return false or an error in such cases.