-
Notifications
You must be signed in to change notification settings - Fork 270
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
Conversation
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.
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/noir-contracts/contracts/test_contract/src/main.nr
Outdated
Show resolved
Hide resolved
|
||
filter.status = filter.status ?? 'activeOnly'; | ||
|
||
if (filter.status == 'activeOnly' || filter.status == 'includeNullified') { |
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.
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
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 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; |
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 it would be interesting here to check more than the first note.
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.
+1
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.
Btw I think you can get the return value by simulate()
- should have a return_values
or something similar?
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.
simulate
resolves to Tx
- I couldn't find anything that seemed like it'd be return values there.
|
||
// 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; |
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.
+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; |
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.
Btw I think you can get the return value by simulate()
- should have a return_values
or something similar?
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.
LGTM. The formatting is likely from a different pr or the like
a.next() | ||
} -> std::convertible_to<uint32_t>; | ||
}; | ||
{ |
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.
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 () => { |
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 adding this one for my alzheimers brain
Superceded by #4238, since we cannot run CI here due to this being created from a fork. |
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.
…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.
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.
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 anullified_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 anoptions
parameter. Ultimately though it is not hard to construct an equivalent call usingget_notes
by passing alimit
value of 1 (which is whatget_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.