-
Notifications
You must be signed in to change notification settings - Fork 38
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: Add Merkle tree libraries #32
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.
I think this is all correct but it's hard to tell without any tests. I do think it would be better to add tests and then merge it instead of adding in the tests later.
Converting to draft to add tests. |
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.
Awesome job 👍 Only small suggestions that i think make sense.
if (l.min == Constants.PARITY_SHARE_NAMESPACE_ID) { | ||
max = Constants.PARITY_SHARE_NAMESPACE_ID; | ||
} else if (r.min == Constants.PARITY_SHARE_NAMESPACE_ID) { | ||
max = r.max; |
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.
if (l.min == Constants.PARITY_SHARE_NAMESPACE_ID) { | |
max = Constants.PARITY_SHARE_NAMESPACE_ID; | |
} else if (r.min == Constants.PARITY_SHARE_NAMESPACE_ID) { | |
max = r.max; | |
if (l.min == Constants.PARITY_SHARE_NAMESPACE_ID || r.min == Constants.PARITY_SHARE_NAMESPACE_ID) { | |
max = Constants.PARITY_SHARE_NAMESPACE_ID; |
If I understand right, node.min <= node.max
. And since the leaves are ordered. Then, if we have one left leaf/node having a min == PARITY_SHARE_NAMESPACE_ID
. Then, all the rest will have {min,max} == PARITY_SHARE_NAMESPACE_ID
.
Correct me If I am missing something.
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.
Yes, that's the reasoning!
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.
Your suggested fix isn't correct thought because if the NMT contains non-parity shares, then max
should be the maximum non-parity namespace ID. (I copied the logic in the contract directly from the specs for this reason.)
* Update docs. * Clean up doc. * Refactor out message tuple, and add oracle interface. * Improve docs. * More docs, fix type. * Refactor and add oracle iterface. * Fix incorrect check. * Add more documentation. * Fix order of parameters. * Rename. * Change to data root tuple. * Rename file. * Use data root instead of message. * Clean up. * Update readme. * Update README.md Co-authored-by: CHAMI Rachid <chamirachid1@gmail.com> Co-authored-by: CHAMI Rachid <chamirachid1@gmail.com>
Ahhh I accidentally merged #33 into here... @sweexordious any outstanding comments on this one? |
Fixes #6.
Tests are being added in #51