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

chore(noir-contracts): 1655 - rename functions to make hack clearer for publicly created notes #2230

Merged
merged 5 commits into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ contract NativeToken {
let public_note = TransparentNote::new_from_secret(amount, secret);

// Ensure that the note exists in the tree and remove it.
pending_shields.assert_contains_and_remove(public_note);
pending_shields.assert_contains_and_remove_publicly_created(public_note);

// Mint the tokens
let balance = storage.balances.at(owner);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ contract NonNativeToken {
let public_note = TransparentNote::new_from_secret(amount, secret);

// Ensure that the note exists in the tree and remove it.
pending_shields.assert_contains_and_remove(public_note);
pending_shields.assert_contains_and_remove_publicly_created(public_note);

// Mint the tokens
let balance = storage.balances.at(owner);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ contract PrivateTokenAirdrop {

// Remove the claim note if it exists in the set.
let note = ClaimNote::new(amount, secret);
storage.claims.assert_contains_note_and_remove(note);
storage.claims.assert_contains_and_remove(note);

// Send the value note.
let balance = storage.balances.at(owner);
Expand Down
14 changes: 7 additions & 7 deletions yarn-project/noir-libs/aztec-noir/src/state_vars/set.nr
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ impl<Note, N> Set<Note, N> {
);
}

// TODO(#1386)
// Should be replaced by `assert_contains_and_remove`.
fn assert_contains_note_and_remove(self, note: Note) {
fn assert_contains_and_remove(self, note: Note) {
let mut note_with_header = note;
// TODO(1386): replace with `ensure_note_hash_exists`
// once `get_commitment` works for privately created note hashes
ensure_note_exists(
self.context.private.unwrap(),
self.storage_slot,
Expand All @@ -67,10 +67,10 @@ impl<Note, N> Set<Note, N> {
);
}

// TODO(https://github.com/AztecProtocol/aztec-packages/issues/1386):
// replace function above ^ once public kernel injects
// nonces to note hashes.
fn assert_contains_and_remove(self, note: Note) {
// NOTE: this function should ONLY be used for PUBLICLY-CREATED note hashes!
// WARNING: function will be deprecated/removed eventually once `assert_contains_and_remove`
// works for publicly-created note hashes as well.
fn assert_contains_and_remove_publicly_created(self, note: Note) {
let mut note_with_header = note;
// Modifies note with the header which is necessary for the next step (remove).
ensure_note_hash_exists(
Expand Down