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

fix: Nullifier tree bug #231

Merged
merged 5 commits into from
Apr 12, 2023
Merged

fix: Nullifier tree bug #231

merged 5 commits into from
Apr 12, 2023

Conversation

Maddiaa0
Copy link
Member

Description

Please provide a paragraph or two giving a summary of the change, including relevant motivation and context.

Checklist:

  • I have reviewed my diff in github, line by line.
  • Every change is related to the PR description.
  • I have linked this pull request to the issue(s) that it resolves.
  • There are no unexpected formatting changes, superfluous debug logs, or commented-out code.
  • There are no circuit changes, OR specifications in /specs have been updated.
  • There are no circuit changes, OR a cryptographer has been assigned for review.
  • I've updated any terraform that needs updating (e.g. environment variables) for deployment.
  • The branch has been rebased against the head of its merge target.
  • I'm happy for the PR to be merged at the reviewer's next convenience.
  • New functions, classes, etc. have been documented according to the doxygen comment format. Classes and structs must have @brief describing the intended functionality.
  • If existing code has been modified, such documentation has been added or updated.

Note
If you are updating the submodule, please make sure you do it in its own special PR and avoid making changes to the submodule as a part of other PRs.
To update a submodule, you can run the following commands:

$ git submodule update --recursive

Alternatively, you can select a particular commit in barretenberg/aztec3 that you wish to point to:

$ cd barretenberg
$ git pull origin aztec3        # This will point to the latest commit in `barretenberg/aztec3`
$ git checkout <commit_hash>    # Use this if you wish to point to a particular commit.
$ cd ..
$ git add . && git commit -m <commit_msg>
$ git push

@@ -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");
Copy link
Contributor

Choose a reason for hiding this comment

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

delete if not needed?

cpp/src/aztec3/circuits/rollup/base/.test.cpp Show resolved Hide resolved
}

// 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
Copy link
Contributor

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!

Copy link
Member Author

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
Copy link
Contributor

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?

Copy link
Member Author

@Maddiaa0 Maddiaa0 Apr 12, 2023

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.

@Maddiaa0 Maddiaa0 force-pushed the md/update-nt-regression branch from 4ad37c3 to 4019d9b Compare April 12, 2023 16:41
return false;
}

// TODO: test
Copy link
Member Author

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

@Maddiaa0 Maddiaa0 merged commit 9b64d57 into master Apr 12, 2023
@Maddiaa0 Maddiaa0 deleted the md/update-nt-regression branch April 12, 2023 20:49
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.

2 participants