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

chore: fixes the HashLeaf description #92

Merged
merged 1 commit into from
Jan 30, 2023

Conversation

staheri14
Copy link
Contributor

@staheri14 staheri14 commented Jan 27, 2023

Overview

While reviewing the nmt codebase (as part of this EPIC) I realized the description of the HashLeaf function does not match its implementation (w.r.t. referred variable names) which causes confusion when comprehending the code. This PR aims to correct and revise that description.

Also, the illustration of an nmt provided in the Readme file seems not aligned with the leaf hash calculation, where in the node_0.0 the d_0.0=H(data_0) while it should be d_0.0=H(0x00, nid_0, data_0). I was not able to edit the image as its source code is not available.

@staheri14 staheri14 self-assigned this Jan 27, 2023
@codecov
Copy link

codecov bot commented Jan 27, 2023

Codecov Report

Merging #92 (5e7a91e) into master (29cca3c) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           master      #92   +/-   ##
=======================================
  Coverage   96.21%   96.21%           
=======================================
  Files           6        6           
  Lines         423      423           
=======================================
  Hits          407      407           
  Misses         10       10           
  Partials        6        6           
Impacted Files Coverage Δ
hasher.go 96.00% <ø> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@staheri14 staheri14 marked this pull request as ready for review January 27, 2023 19:11
Comment on lines -147 to +148
// ns(rawData) || ns(rawData) || hash(leafPrefix || rawData), where raw data is the leaf's
// data minus the namespaceID (namely leaf[NamespaceLen:]).
// ns(leaf) || ns(leaf) || hash(leafPrefix || leaf), where ns(leaf) is the namespaceID
// inside the leaf's data namely leaf[:n.NamespaceLen]).
Copy link
Member

Choose a reason for hiding this comment

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

Thanks, this is clearer as it is aligned with the naming of the actual variable (leaf). I think the original comment was a somewhat confusing attempt to say that the leaf contains both the namespace + the raw data. This is still implicitly there ("where ns(leaf) is the namespaceID inside the leaf's data namely leaf[:n.NamespaceLen])".

Copy link
Member

@evan-forbes evan-forbes left a comment

Choose a reason for hiding this comment

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

good catch! 👍 LGTM

@staheri14 staheri14 merged commit 75ea372 into master Jan 30, 2023
@staheri14 staheri14 deleted the corrects-hashleaf-description branch January 30, 2023 19:19
@gitpoap-bot
Copy link

gitpoap-bot bot commented Jan 30, 2023

Congrats, your important contribution to this open-source project has earned you a GitPOAP!

GitPOAP: 2023 Celestia Contributor:

GitPOAP: 2023 Celestia Contributor GitPOAP Badge

Head to gitpoap.io & connect your GitHub account to mint!

Learn more about GitPOAPs here.

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.

3 participants