-
Notifications
You must be signed in to change notification settings - Fork 45
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: compute leaf hashes in the Push method #172
Merged
Merged
Changes from 18 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
73dd229
adds hash computation to the Push method
staheri14 3a649ee
comments out computeLeafHashes from the main methods
staheri14 1beb01d
removes computeLeafHashes
staheri14 faf8fe5
removes computeLeafHashes method
staheri14 b4bfe30
fixes a test in the nmt proof file
staheri14 79d344a
modifies computeRoot to use the calculated leafHashes
staheri14 3942342
refactors the codes based on the new computeRoot logic
staheri14 3da6ebb
removes commented codes
staheri14 dc55e52
cleans up the tests
staheri14 2747ab7
a minor update on the docs
staheri14 e5a609a
modifies a test vector to only contain a corrupt leafHash
staheri14 6bfa019
keeps the leaf intact and only corrupts the leaf hash
staheri14 57be188
introduces MustHashLeaf
staheri14 ffb44f8
implements tests for the MustHashLeaf method
staheri14 200af3d
incorporates MustHashLeaf in the Push method
staheri14 e53775c
fixes gofumpt complaints
staheri14 88d38a0
adds a missing godoc for the Test_MustHashLeaf_panic
staheri14 40a4f4e
Merge branch 'master' into hash-and-push
staheri14 634687e
Merge remote-tracking branch 'origin/master' into hash-and-push
staheri14 d60367b
replaces MustHashLeaf with HashLeaf
staheri14 5b53987
Merge branch 'master' into hash-and-push
staheri14 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
why not bubble the error here if there ever is one?
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 are two reasons why the error is not being bubbled up:
In line 410, the data validity is checked through the
validateAndExtractNamespace
function call. As a result, theHashLeaf
function call cannot produce an error. To handle this scenario, theMustHashLeaf
function is introduced, which assumes that the data passed to it has already been validated. This approach is similar to the current situation and avoids any unnecessary error handling.If we were to use
HashLeaf
and bubble up the error, we would need to introduce an if block in our code i.e., thePush
method. However, this if block would not be covered in our tests, leading to a reduction in test coverage percentage. Therefore, I have opted not to bubble up the error in this situation.Please let me know if this addresses your question.
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.
that makes sense, but documenting it in the code for posterity would be a good addition imo. we could also just ignore the error if its impossible (and we have comments), but in general I think its always best to bubble even if we don't strictly need to. Its one less thing the reader or future contributors have to think about.
I'm not blocking on it though! will defer to the author 🙂
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.
Fair point, replaced MustHashLeaf with HashLeaf and bubbled up the error, please see d60367b
With this change, the code coverage percentage decreases below the set threshold, and there is no way to develop a test to cover the line that captures the returned error. In such situations, what should we do? Should we still merge the PR?
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.
Yeah, 100% merge imo