Skip to content

feat: add note metadata#12240

Merged
nventuro merged 10 commits intomasterfrom
nv/note-metadata
Feb 25, 2025
Merged

feat: add note metadata#12240
nventuro merged 10 commits intomasterfrom
nv/note-metadata

Conversation

@nventuro
Copy link
Contributor

Follow up to #11942. This improves the readability and management of code that reads and destroys notes by introducing the NoteMetadata struct, which handles the different combinations of note hash counter and nonce internally. This is a stepping stone towards #8589.

@nventuro nventuro requested a review from benesjan February 24, 2025 20:56
Copy link
Contributor

@benesjan benesjan left a comment

Choose a reason for hiding this comment

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

Lovely. Just needs fixing some comments.

@nventuro
Copy link
Contributor Author

I adjusted some of the naming: we now correctly call same-tx notes 'pending' instead of 'transient', and clarified that the separation is not revertible vs non-revertible, but rather same phase or previous phase.

I also removed the note hash counter from the struct. This value was not being used anywhere, but was dangerous to have around since it was underconstrained. We only ever check if it is zero or non-zero to determine if the note is pending or not, but we never do validate its content (nor can we, since the read request does not include the counter, and we cannot inspect the new note hashes array). Therefore the only correct thing to do is to get rid of it.

Copy link
Contributor

@benesjan benesjan 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. Would just expand a bit in those 2 comments

/// requests) nor note hash (since it would be meaningless to tie this to a note that has been read).
///
/// Second, it always compute the nullifier for a **settled** note, i.e. a note that has been created in a previous
/// transaction, which therefore has a nonce. This is typically fine, since this function will mostly be used in
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// transaction, which therefore has a nonce. This is typically fine, since this function will mostly be used in
/// transaction, which therefore has a nonce (nonces are injected in the kernel tail circuit after pending note squashing). This is typically fine, since this function will mostly be used in

I think readers would generally have no clue why this implies that it has a nonce.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After some reflection I think we just simplify this fn so that it also takes a note hash. I'll do that once both our PRs are in.

@nventuro nventuro enabled auto-merge (squash) February 25, 2025 20:31
@nventuro nventuro merged commit 65b9f1e into master Feb 25, 2025
9 checks passed
@nventuro nventuro deleted the nv/note-metadata branch February 25, 2025 21:29
@iAmMichaelConnor
Copy link
Contributor

Hey, we had unresolved arguments about this, from yesterday

nventuro added a commit that referenced this pull request Feb 26, 2025
Follow up from #12240. This aligns both compute nullifier functions.
With the new metadata bits calling this is quite simple, and it's very
clear that we're only using it for note discovery. Some macros were
simplified a bit as a result as well.
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.

3 participants