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

feat: nullified note retrieval in get_notes and view_notes #4208

Closed
wants to merge 19 commits into from
Closed

feat: nullified note retrieval in get_notes and view_notes #4208

wants to merge 19 commits into from

Conversation

nventuro
Copy link
Contributor

@nventuro nventuro commented Jan 25, 2024

This adds an include_nullified flag to the note getter/viewer options which results in the oracle combining both nullified and active notes in its response. We may eventually add a nullified_only option, though that would require performing an inclusion tesf on the nullifier tree, which will be made easier once #4179 is addressed. At this point the flag would turn into an enum, but I decided to go with the simpler approach for now.

The get_note function was not given a way to query nullified notes, mostly to not break the current API as it does not have an options parameter. Ultimately though it is not hard to construct an equivalent call using get_notes by passing a limit value of 1 (which is what get_note does under the hood) and get a single potentially nullified note that way.

A potential issue that might arise with the current API is that the user does not know whether the notes they got are nullified or note, so they won't know if e.g. they need to nullify them after consuming them. However it is expected that use cases that require this option will not care about this distinction.

This PR has conflicts with #3927, as that one performs some refactors on the KV PXE database which change or remove the underlying data structures used to store nullified notes. We're still coordinating with @alexghr on how to address these conflicts, so we shouldn't merge this immediately.

Fixes #3755.

@nventuro nventuro requested a review from LHerskind January 25, 2024 12:44
Copy link
Contributor

@LHerskind LHerskind left a comment

Choose a reason for hiding this comment

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

Looks good, have a few nits and think a test showing it read both nullified and active at the same time would be very neat to have 👍

yarn-project/circuit-types/src/notes/note_filter.ts Outdated Show resolved Hide resolved

filter.status = filter.status ?? 'activeOnly';

if (filter.status == 'activeOnly' || filter.status == 'includeNullified') {
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the benefit of this if? It includes both cases non-undefined cases and if undefined you will set the value to activeOnly on 187.

What more options did you have for the status? Also, can we use an enum or something instead, seems very easy to miss

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think was alredy considering the scenario in which we'd have three options (active only, include nullified, nullified only). Supporting such a case would simply require adding the new value to the second if (active notes are candidates if querying for active or both, nullified are candidates if querying for both or nullified).

More importantly though, this part is going to be affected by the refactor in #3927 and I wanted to keep the intent clear to help avoid issues when solving the merge conflicts.


// We can't get the return value of a private function from the outside world in an end to end test, so we
// expose it via an unecrypted log instead.
let value = opt_notes[0].unwrap().value;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be interesting here to check more than the first note.

Copy link
Contributor

Choose a reason for hiding this comment

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

+1

Copy link
Contributor

Choose a reason for hiding this comment

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

Btw I think you can get the return value by simulate() - should have a return_values or something similar?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

simulate resolves to Tx - I couldn't find anything that seemed like it'd be return values there.

yarn-project/end-to-end/src/e2e_get_notes.test.ts Outdated Show resolved Hide resolved
yarn-project/aztec-nr/aztec/src/note/note_getter.nr Outdated Show resolved Hide resolved

// We can't get the return value of a private function from the outside world in an end to end test, so we
// expose it via an unecrypted log instead.
let value = opt_notes[0].unwrap().value;
Copy link
Contributor

Choose a reason for hiding this comment

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

+1


// We can't get the return value of a private function from the outside world in an end to end test, so we
// expose it via an unecrypted log instead.
let value = opt_notes[0].unwrap().value;
Copy link
Contributor

Choose a reason for hiding this comment

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

Btw I think you can get the return value by simulate() - should have a return_values or something similar?

yarn-project/pxe/src/database/kv_pxe_database.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@LHerskind LHerskind left a comment

Choose a reason for hiding this comment

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

LGTM. The formatting is likely from a different pr or the like

a.next()
} -> std::convertible_to<uint32_t>;
};
{
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it a different formatter or how come it changes all of these cpp files 🤔 Likely addressed with a rebase

await assertNoteIsReturned(storageSlot, VALUE, activeOrNullified);
}, 30_000);

it('returns both active and nullified notes', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

🙏 thanks for adding this one for my alzheimers brain

@LHerskind
Copy link
Contributor

@nventuro realized that the extra test added is not added to run in ci. If you look at #4236, @sklppy88 is adding his test. Consider doing the same or since the tests are somewhat related, might make sense to put them into the same environment to reduce number of sandboxes needed to be run.

@nventuro
Copy link
Contributor Author

Superceded by #4238, since we cannot run CI here due to this being created from a fork.

@nventuro nventuro closed this Jan 26, 2024
@nventuro nventuro deleted the get-nullified-notes branch January 26, 2024 16:49
nventuro added a commit that referenced this pull request Jan 30, 2024
Supercedes #4208,
which was closed as that one was created from a fork and we therefore
cannot run CI there.

Fixes #3755.
AztecBot pushed a commit to AztecProtocol/aztec-nr that referenced this pull request Jan 31, 2024
Supercedes AztecProtocol/aztec-packages#4208,
which was closed as that one was created from a fork and we therefore
cannot run CI there.

Fixes AztecProtocol/aztec-packages#3755.
michaelelliot pushed a commit to Swoir/noir_rs that referenced this pull request Feb 28, 2024
…ocol#4238)

Supercedes AztecProtocol#4208,
which was closed as that one was created from a fork and we therefore
cannot run CI there.

Fixes AztecProtocol#3755.
superstar0402 added a commit to superstar0402/aztec-nr that referenced this pull request Aug 16, 2024
Supercedes AztecProtocol/aztec-packages#4208,
which was closed as that one was created from a fork and we therefore
cannot run CI there.

Fixes AztecProtocol/aztec-packages#3755.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Allow get_note to return notes that have been nullified.
3 participants