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

refactor: cliarify a few names and add some docs to the wrapper #1418

Merged
merged 8 commits into from
Feb 23, 2023

Conversation

evan-forbes
Copy link
Member

Overview

some non-breaking refactors to hopefully make the wrapper slightly clearer

Checklist

  • New and updated code has appropriate documentation
  • New and updated code has new and/or updated testing
  • Required CI checks are passing
  • Visual proof for any user facing features like CLI or documentation updates
  • Linked issues closed with keywords

@evan-forbes evan-forbes added the documentation Improvements or additions to documentation label Feb 22, 2023
@evan-forbes evan-forbes added this to the Mainnet milestone Feb 22, 2023
@evan-forbes evan-forbes self-assigned this Feb 22, 2023
@MSevey MSevey requested review from a team, staheri14 and rach-id and removed request for a team February 22, 2023 20:31
@MSevey MSevey requested a review from a team February 22, 2023 20:33
rootulp
rootulp previously approved these changes Feb 22, 2023
Copy link
Collaborator

@rootulp rootulp left a comment

Choose a reason for hiding this comment

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

LGTM w/ some optional feedback

pkg/wrapper/nmt_wrapper.go Outdated Show resolved Hide resolved
pkg/wrapper/nmt_wrapper.go Outdated Show resolved Hide resolved
Comment on lines 118 to 122
// isQuadrant0 returns true if the current share index and axis index are both
// in the original data square.
func (w *ErasuredNamespacedMerkleTree) isQuadrant0() bool {
return !(uint64(w.shareIndex)+1 > w.squareSize || uint64(w.axisIndex)+1 > w.squareSize)
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

[very optional] removed a negation because this may be clearer for readers

Suggested change
// isQuadrant0 returns true if the current share index and axis index are both
// in the original data square.
func (w *ErasuredNamespacedMerkleTree) isQuadrant0() bool {
return !(uint64(w.shareIndex)+1 > w.squareSize || uint64(w.axisIndex)+1 > w.squareSize)
}
// isQuadrantZero returns true if the current share index and axis index are both
// in the original data square.
func (w *ErasuredNamespacedMerkleTree) isQuadrantZero() bool {
return w.shareIndex < w.squareSize && w.axisIndex < w.squareSize
}

Copy link
Member Author

Choose a reason for hiding this comment

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

yes good idea, I just copy pasta'd

Copy link
Member Author

Choose a reason for hiding this comment

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

68a1ea6

couldn't accept here as we had to update the usage to the new name

pkg/wrapper/nmt_wrapper.go Outdated Show resolved Hide resolved
Co-authored-by: Rootul P <rootulp@gmail.com>
@codecov-commenter
Copy link

Codecov Report

Merging #1418 (84a492c) into main (f19c2ff) will increase coverage by 0.85%.
The diff coverage is 88.88%.

@@            Coverage Diff             @@
##             main    #1418      +/-   ##
==========================================
+ Coverage   48.39%   49.25%   +0.85%     
==========================================
  Files          79       79              
  Lines        4465     4467       +2     
==========================================
+ Hits         2161     2200      +39     
+ Misses       2121     2085      -36     
+ Partials      183      182       -1     
Impacted Files Coverage Δ
pkg/wrapper/nmt_wrapper.go 82.50% <84.61%> (+1.94%) ⬆️
pkg/inclusion/nmt_caching.go 81.66% <100.00%> (ø)
testutil/testnode/full_node.go 83.22% <100.00%> (+23.08%) ⬆️
testutil/testnode/node_init.go 64.17% <0.00%> (+1.40%) ⬆️

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

rootulp
rootulp previously approved these changes Feb 22, 2023
Copy link
Member

@rach-id rach-id left a comment

Choose a reason for hiding this comment

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

LGTM, would defer to others for final approval

staheri14
staheri14 previously approved these changes Feb 22, 2023
Copy link
Contributor

@staheri14 staheri14 left a comment

Choose a reason for hiding this comment

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

Nice! Thanks a lot for this clarifying PR! (added some suggestions)

// pushed to the tree. It is expected to be in the range: 0 <= shareIndex <
// 2*squareSize. shareIndex is used to help determine which quadrant each
// leaf belongs to.
shareIndex uint64
Copy link
Contributor

@staheri14 staheri14 Feb 22, 2023

Choose a reason for hiding this comment

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

It is worth mentioning that the shareIndex also keeps track of the number of shares (i.e., the total number of leaves) that have been added to the tree so far.

Copy link
Member Author

Choose a reason for hiding this comment

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

sure thing! afd0849

pkg/wrapper/nmt_wrapper.go Outdated Show resolved Hide resolved
@evan-forbes evan-forbes dismissed stale reviews from staheri14 and rootulp via 71e196c February 23, 2023 01:51
Co-authored-by: Sanaz Taheri <35961250+staheri14@users.noreply.github.com>
@MSevey MSevey requested a review from a team February 23, 2023 01:51
@evan-forbes evan-forbes enabled auto-merge (squash) February 23, 2023 01:54
@evan-forbes evan-forbes merged commit e6bbc30 into main Feb 23, 2023
@evan-forbes evan-forbes deleted the evan/clarify-wrapper-name branch February 23, 2023 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants