Skip to content

Commit 4726d3a

Browse files
authored
chore: apply code consistency consolidation (#22251)
1 parent fd0acc6 commit 4726d3a

File tree

7 files changed

+25
-15
lines changed

7 files changed

+25
-15
lines changed

noir-projects/aztec-nr/aztec/src/authwit/authorization_selector.nr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::protocol::{hash::poseidon2_hash_bytes, traits::{Deserialize, Empty, F
22

33
#[derive(Eq, Serialize, Deserialize)]
44
pub struct AuthorizationSelector {
5-
// 1st 4-bytes (big-endian leftmost) of abi-encoding of an event.
5+
// Low 32 bits of the poseidon2 hash of the function signature.
66
inner: u32,
77
}
88

noir-projects/aztec-nr/aztec/src/event/event_selector.nr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::protocol::{hash::poseidon2_hash_bytes, traits::{Deserialize, Empty, F
22

33
#[derive(Deserialize, Eq, Serialize)]
44
pub struct EventSelector {
5-
// 1st 4-bytes (big-endian leftmost) of abi-encoding of an event.
5+
// Low 32 bits of the poseidon2 hash of the event signature.
66
inner: u32,
77
}
88

noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,25 @@ pub comptime fn noinitcheck(f: FunctionDefinition) {
137137
}
138138
}
139139

140-
/// An allow_phase_change function will allow transitioning from the non-revertible to the revertible phase during its
140+
/// An `allow_phase_change` function will allow transitioning from the non-revertible to the revertible phase during its
141141
/// execution.
142142
///
143143
/// This is an advanced feature that is typically only required for account contract entrypoints that handle
144144
/// transaction fee payment.
145+
///
146+
/// ## Note Retrieval
147+
///
148+
/// When notes are read e.g. via [`crate::note::note_getter::get_notes`], a
149+
/// [`ConfirmedNote`](crate::note::ConfirmedNote) value is returned which includes note metadata, notably whether the
150+
/// note was created in a previous transaction (a settled note) or in the current one (a pending note), either in the
151+
/// current or previous phase. Because `allow_phase_change` functions can change phases, this metadata can be left
152+
/// stale, e.g. it is possible to read a pending current phase note and then change phases, resulting in the note being
153+
/// [`PENDING_PREVIOUS_PHASE`](crate::note::note_metadata::NoteStageEnum::PENDING_PREVIOUS_PHASE) instead.
154+
///
155+
/// Such a note would be rejected by the kernels if it was tried to be nullified, as the metadata is incorrect. It is
156+
/// therefore important to not allow [`ConfirmedNote`](crate::note::ConfirmedNote),
157+
/// [`HintedNote`](crate::note::HintedNote) or [`NoteMetadata`](crate::note::note_metadata::NoteMetadata) values to
158+
/// cross the phase barrier caused by [`crate::context::PrivateContext::end_setup`].
145159
pub comptime fn allow_phase_change(f: FunctionDefinition) {
146160
// Marker attribute - see the comment at the top of this file
147161
if !is_fn_external(f) {

noir-projects/aztec-nr/aztec/src/note/note_metadata.nr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ struct NoteStageEnum {
3131
PENDING_PREVIOUS_PHASE: u8,
3232
/// A note created in a prior transaction.
3333
///
34-
/// Settled notes have alrady been inserted into the note hash tree.
34+
/// Settled notes have already been inserted into the note hash tree.
3535
SETTLED: u8,
3636
}
3737

noir-projects/aztec-nr/uint-note/src/uint_note.nr

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use aztec::{
2-
context::{PrivateContext, PublicContext},
3-
history::nullifier::assert_nullifier_existed_by,
2+
context::{NullifierExistenceRequest, PrivateContext, PublicContext},
43
keys::getters::{get_nhk_app, get_public_keys, try_get_public_keys},
54
macros::notes::custom_note,
65
messages::{
@@ -216,14 +215,11 @@ impl PartialUintNote {
216215
// We verify that the partial note we're completing is valid (i.e. completer is correct, it uses the correct
217216
// state variable's storage slot, and it is internally consistent).
218217
let validity_commitment = self.compute_validity_commitment(completer);
219-
// `assert_nullifier_existed_by` function expects the nullifier to be siloed (hashed with the address of the
220-
// contract that emitted the nullifier) as it checks the value directly against the nullifier tree and all the
221-
// nullifiers in the tree are siloed by the protocol.
218+
222219
let siloed_validity_commitment = compute_siloed_nullifier(context.this_address(), validity_commitment);
223-
assert_nullifier_existed_by(
224-
context.get_anchor_block_header(),
225-
siloed_validity_commitment,
226-
);
220+
// Note that this means we don't support scenarios in which the validity commitment was created in the same
221+
// transaction.
222+
context.assert_nullifier_exists(NullifierExistenceRequest::for_settled(siloed_validity_commitment));
227223

228224
// We need to do two things:
229225
// - emit an unencrypted log containing the public fields (the storage slot and value) via the private log

noir-projects/noir-protocol-circuits/crates/types/src/abis/function_selector.nr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::meta::derive;
33

44
#[derive(Deserialize, Eq, Serialize)]
55
pub struct FunctionSelector {
6-
// 1st 4-bytes (big-endian leftmost) of abi-encoding of an event.
6+
// Low 32 bits of the poseidon2 hash of the function signature.
77
pub inner: u32,
88
}
99

yarn-project/stdlib/src/abi/selector.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { bufferToHex } from '@aztec/foundation/string';
44

55
import { inspect } from 'util';
66

7-
/** A selector is the first 4 bytes of the hash of a signature. */
7+
/** A selector is the low 4 bytes of the poseidon2 hash of a signature. */
88
export abstract class Selector {
99
/** The size of the selector in bytes. */
1010
public static SIZE = 4;

0 commit comments

Comments
 (0)