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: Exposing more of nullifier tree state #589

Closed
wants to merge 6 commits into from

Conversation

benesjan
Copy link
Contributor

@benesjan benesjan commented Jul 7, 2023

Description

Making more of nullifier tree state "protected" instead of "private" so that a testing harness can be written.

Note: Don't merge or review before #584 is merged.

Checklist:

  • I have reviewed my diff in github, line by line.
  • Every change is related to the PR description.
  • The branch has been merged with/rebased against the head of its merge target.
  • There are no unexpected formatting changes, superfluous debug logs, or commented-out code.
  • There are no circuit changes, OR a cryptographer has been assigned for review.
  • 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.
  • No superfluous include directives have been added.
  • I have linked to any issue(s) it resolves.
  • I'm happy for the PR to be merged at the reviewer's next convenience.

@benesjan benesjan marked this pull request as draft July 7, 2023 14:17
@kevaundray kevaundray changed the title refactor: exposing more of nullifier tree state refactor: Exposing more of nullifier tree state Jul 10, 2023
continue;
}

if (data.size() == 64) {
Copy link
Contributor

Choose a reason for hiding this comment

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

whats special about 64?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hello, I intended this PR to be reviewed and merged after #584 is merged. This PR is unfinished and messy.

But your comment applies to #584 as well. The get_sibling_path method is based on get_hash_path and in both cases 64 is a size of a regular node (65 is "stump"). I think introducing a constant is a good idea and I will do that in #584.

} else {
// This is a stump. The sibling path can be fully restored from this node.
// In case of a stump, we store: [key : (value, local_index, true)], i.e. 65-byte data.
ASSERT(data.size() == 65);
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of a magic number, can we make this a constant? ditto for the number 32 and 64

using MerkleTree<Store>::update_element;
using MerkleTree<Store>::get_element;
using MerkleTree<Store>::compute_zero_path_hash;

private:
// const std::vector<barretenberg::fr>& get_hashes() { return hashes_; }
Copy link
Contributor

Choose a reason for hiding this comment

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

commented out code, also two lines below

@@ -25,12 +25,19 @@ template <typename Store> class NullifierTree : public MerkleTree<Store> {

fr update_element(fr const& value);

private:
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we changing this from private to protected, only for testing purposes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, because through the testing harness in aztec3 package we are exposing some of the internal values for testing purposes. But the original implementation of the testing harness used NullifierMemoryTree which was always only for testing so I can imagine that when it was originally implemented nobody cared about exposing more stuff.

Do you think we should rethink how we test it or is having some of the value as protected ok with you?

Copy link
Contributor

Choose a reason for hiding this comment

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

Without looking deeper, it's okay with me. Just wanted to flag it up as usually changing the viability of an item for tests is a code smell.

Moreover, we discussed this being a problem in other parts of the code in Valencia, so this can be addressed when we look into cleaning up the API as a whole.

I'll open up an issue to track this when I get back to my laptop

@benesjan
Copy link
Contributor Author

Closing this as it has been decided that we'll update the Nullifier tree stuff in aztec-packages at a later date making this PR not yet necessary.

@benesjan benesjan closed this Jul 10, 2023
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