-
Notifications
You must be signed in to change notification settings - Fork 43
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: ensures consistent use of the assumption that NMT nodes are ordered ascendingly #188
feat: ensures consistent use of the assumption that NMT nodes are ordered ascendingly #188
Conversation
minNs := min(leftMinNs, rightMinNs) | ||
var maxNs []byte | ||
if n.ignoreMaxNs && n.precomputedMaxNs.Equal(leftMinNs) { | ||
maxNs = n.precomputedMaxNs |
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 leftMinNs
represents the maximum possible namespace ID, then by definition, rightMax
must also be the maximum possible namespace ID (left and right nodes are already checked to be ordered based on their namespaces). Therefore, this check can be removed.
Codecov Report
@@ Coverage Diff @@
## master #188 +/- ##
==========================================
- Coverage 95.41% 95.39% -0.03%
==========================================
Files 5 5
Lines 567 564 -3
==========================================
- Hits 541 538 -3
Misses 15 15
Partials 11 11
|
rightMinNs: []byte{0x02}, | ||
rightMaxNs: precomputedMaxNs, | ||
expectedMinNs: []byte{0x00}, | ||
expectedMaxNs: precomputedMaxNs, |
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.
[non-blocking][question] this test case has me puzzled. Based on the feature ignoreMaxNs
I would expect max ns to be []byte{0x02}
.
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.
Good question, the IgnoreMaxNamespace
ignores the MaxNs
from the namespace range of the parent node when the right subtree (the right child) of the parent is filled with the leaves all with MaxNs
. In this testcase, the right subtree is not populated only by MaxNs
leaves, so, the condition is not met hence the normal range calculation takes place. This is how it is done in the original code as well, please see
Lines 280 to 288 in fd00c52
minNs := min(leftMinNs, rightMinNs) | |
var maxNs []byte | |
if n.ignoreMaxNs && n.precomputedMaxNs.Equal(leftMinNs) { | |
maxNs = n.precomputedMaxNs | |
} else if n.ignoreMaxNs && n.precomputedMaxNs.Equal(rightMinNs) { | |
maxNs = leftMaxNs | |
} else { | |
maxNs = max(leftMaxNs, rightMaxNs) | |
} |
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.
Thanks for explaining. I think we can def merge this PR.
No concrete feedback but I think the ignoreMaxNs
feature is confusing b/c it only applies under certain circumstances.
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 agree with the confusion part. It takes time for one's mental model to be shaped around the semantics of IgnoreMaxNamespace, especially without any context regarding its use case in Celestia. Without such context, it may never make sense.
it only applies under certain circumstances.
To provide further clarity, this condition applies only under two circumstances. Firstly, when the tree has more than one leaf, and secondly, when the right half of a (parent) node is fully occupied by values that all have the Maximum namespace. In essence, the first condition can be deduced from the second one, so there is effectively only one condition.
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 we should (eventually) move the ignoreNS logic to celestia somehow as it is really difficult to grasp in the context of the NMT only.
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 we should (eventually) move the ignoreNS logic to celestia somehow as it is really difficult to grasp in the context of the NMT only.
Agree with this, created the tracking issue as well #195
Overview
Closes #121 and closes #148.
Please refer to this PR to compare the new and old version of namsespacre range calculation for a parent node in the
HashNode()
.Checklist