-
Notifications
You must be signed in to change notification settings - Fork 6
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
fix: Nullifier tree bug #231
Conversation
@@ -405,6 +397,12 @@ TEST_F(base_rollup_tests, new_nullifier_tree_all_larger) | |||
AppendOnlyTreeSnapshot<NT> nullifier_tree_start_snapshot = std::get<1>(inputs_and_snapshots); | |||
AppendOnlyTreeSnapshot<NT> nullifier_tree_end_snapshot = std::get<2>(inputs_and_snapshots); | |||
|
|||
// info("testing inputs"); |
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.
delete if not needed?
} | ||
|
||
// TEST_F(base_rollup_tests, new_commitments_tree) {} | ||
// Note leaving this test here as there are no negative tests, even though it no longer passes |
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.
does this work now or is this not needed? With composer we can now test negative 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.
added
// TODO: test | ||
fr NullifierMemoryTreeTestingHarness::append_value(fr const& value) | ||
{ | ||
// If the value is 0, then we force insert the value to increase the size of the tree |
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.
sorry why do we do this again?
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.
It allows the size of the tree to progress each kernel circuit so that subtrees can be inserted at once.
Say, for example we are adding three nullifiers (a,b,c), and want to perform a batch insertion of 4 notes each time (in reality its 8 but 4 is quicker to illustrate).
h(ab,c0)
/ \
h(a,b) h(c,0)
/ \ / \
a b c 0
To insert this subtree we need to insert 4 values into the tree, increasing its size to 4. If we didnt the next subtree would write to our first 0.
e.g. if inserting (d,e,f,g)
h(abcd,efg0)
/ \
h(ab,cd) h(ef,g0)
/ \ / \
h(a,b) h(c,d) h(e,f) h(g,0)
/ \ / \ / \ / \
a b c d e f g 0
As you can see here we cant cleanly insert our subtree d e f g as we have a leaf that is updating the left subtree. We now must do a few more checks. The hash h(c,0) -> h(c,d) and cascades upwards meaning we have alot more nodes that have changed.
h(abc0,defg)
/ \
h(ab,c0) h(de,fg)
/ \ / \
h(a,b) h(c,0) h(d,e) h(f,g)
/ \ / \ / \ / \
a b c 0 d e f g
In this case where we allow sparse insertions we can cleanly insert defg without changing any of the leftmost subtree paths.
4ad37c3
to
4019d9b
Compare
return false; | ||
} | ||
|
||
// TODO: test |
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.
note: this is going to change with #161 hence why its not deeply integrated yet. The purpose of this fix is to unblock pacakges
Description
Please provide a paragraph or two giving a summary of the change, including relevant motivation and context.
Checklist:
/specs
have been updated.@brief
describing the intended functionality.