Skip to content

Commit ae4f935

Browse files
authored
chore: rename note discovery to message discovery (#12755)
It's not just notes, so updating some of the terms ahead of known future improvements.
1 parent 39986e5 commit ae4f935

File tree

10 files changed

+43
-41
lines changed

10 files changed

+43
-41
lines changed

noir-projects/aztec-nr/aztec/src/discovery/mod.nr

+8-7
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pub global MAX_NOTE_PACKED_LEN: u32 =
1818
pub struct NoteHashAndNullifier {
1919
/// The result of NoteHash::compute_note_hash
2020
pub note_hash: Field,
21-
/// The result of NoteHash::compute_nullifier_unconstrained (since all of note discovery is unconstrained)
21+
/// The result of NoteHash::compute_nullifier_unconstrained (since all of message discovery is unconstrained)
2222
pub inner_nullifier: Field,
2323
}
2424

@@ -59,16 +59,17 @@ pub struct NoteHashAndNullifier {
5959
/// ```
6060
type ComputeNoteHashAndNullifier<Env> = unconstrained fn[Env](/* packed_note_content */BoundedVec<Field, MAX_NOTE_PACKED_LEN>, /* storage_slot */ Field, /* note_type_id */ Field, /* contract_address */ AztecAddress, /* nonce */ Field) -> Option<NoteHashAndNullifier>;
6161

62-
/// Performs the note discovery process, in which private and public logs are downloaded and inspected to find private
63-
/// notes, partial notes, and their completion. This is the mechanism via which PXE learns of new notes.
62+
/// Performs the message discovery process, in which private are downloaded and inspected to find new private notes,
63+
/// partial notes and events, etc., and pending partial notes are processed to search for their completion logs.
64+
/// This is the mechanism via which a contract updates its knowldge of its private state.
6465
///
65-
/// Receives the address of the contract on which discovery is performed (i.e. the contract that emitted the notes)
66-
/// along with its `compute_note_hash_and_nullifier` function.
67-
pub unconstrained fn discover_new_notes<Env>(
66+
/// Receives the address of the contract on which discovery is performed along with its
67+
/// `compute_note_hash_and_nullifier` function.
68+
pub unconstrained fn discover_new_messages<Env>(
6869
contract_address: AztecAddress,
6970
compute_note_hash_and_nullifier: ComputeNoteHashAndNullifier<Env>,
7071
) {
71-
debug_log("Performing note discovery");
72+
debug_log("Performing message discovery");
7273

7374
private_logs::fetch_and_process_private_tagged_logs(
7475
contract_address,

noir-projects/aztec-nr/aztec/src/discovery/nonce_discovery.nr

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pub unconstrained fn attempt_note_nonce_discovery<Env>(
3535
let discovered_notes = &mut BoundedVec::new();
3636

3737
debug_log_format(
38-
"Attempting note discovery on {0} potential notes on contract {1} for storage slot {2}",
38+
"Attempting nonce discovery on {0} potential notes on contract {1} for storage slot {2}",
3939
[unique_note_hashes_in_tx.len() as Field, contract_address.to_field(), storage_slot],
4040
);
4141

noir-projects/aztec-nr/aztec/src/discovery/partial_notes.nr

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::{
55
nonce_discovery::{attempt_note_nonce_discovery, DiscoveredNoteInfo},
66
private_logs::MAX_PARTIAL_NOTE_PRIVATE_PACKED_LEN,
77
},
8-
oracle::note_discovery::{deliver_note, get_log_by_tag},
8+
oracle::message_discovery::{deliver_note, get_log_by_tag},
99
utils::array,
1010
};
1111

@@ -72,8 +72,8 @@ pub unconstrained fn fetch_and_process_public_partial_note_completion_logs<Env>(
7272
);
7373
*i += 1 as u32;
7474
// Note that we're not removing the pending partial note from the PXE DB, so we will continue searching
75-
// for this tagged log when performing note discovery in the future until we either find it or the entry
76-
// is somehow removed from the PXE DB.
75+
// for this tagged log when performing message discovery in the future until we either find it or the
76+
// entry is somehow removed from the PXE DB.
7777
} else {
7878
debug_log_format(
7979
"Completion log found for partial note with tag {}",

noir-projects/aztec-nr/aztec/src/discovery/private_logs.nr

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::static_assert;
22

33
use crate::{
44
capsules::CapsuleArray,
5-
oracle::note_discovery::{deliver_note, sync_notes},
5+
oracle::message_discovery::{deliver_note, sync_notes},
66
utils::array,
77
};
88

noir-projects/aztec-nr/aztec/src/encrypted_logs/log_assembly_strategies/default_aes128/note/encryption.nr

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ pub global PRIVATE_LOG_PLAINTEXT_SIZE_IN_FIELDS: u32 = PRIVATE_LOG_PLAINTEXT_SIZ
4646
/// The resulting log has the following format:
4747
/// ```text
4848
/// [
49-
/// tag: Field, // Tag for note discovery, derived from sender/recipient
49+
/// tag: Field, // Tag for message discovery, derived from sender/recipient
5050
/// epk_x: Field, // X coordinate of ephemeral public key
5151
/// log_bytes: [Field], // Encrypted data converted from bytes to fields, containing:
5252
/// [

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

+16-15
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,10 @@ pub(crate) comptime fn transform_private(f: FunctionDefinition) -> Quoted {
9898
quote {}
9999
};
100100

101-
// All private functions perform note discovery, since they may need to access notes. This is slightly inefficient
102-
// and could be improved by only doing it once we actually attempt to read any.
103-
let note_discovery_call = if NOTES.len() > 0 {
104-
create_note_discovery_call()
101+
// All private functions perform message discovery, since they may need to access notes. This is slightly
102+
// inefficient and could be improved by only doing it once we actually attempt to read any.
103+
let message_discovery_call = if NOTES.len() > 0 {
104+
create_message_discovery_call()
105105
} else {
106106
quote {}
107107
};
@@ -157,7 +157,7 @@ pub(crate) comptime fn transform_private(f: FunctionDefinition) -> Quoted {
157157
$internal_check
158158
$view_check
159159
$storage_init
160-
$note_discovery_call
160+
$message_discovery_call
161161
};
162162

163163
let to_append = quote {
@@ -325,18 +325,19 @@ pub(crate) comptime fn transform_top_level_unconstrained(f: FunctionDefinition)
325325
quote {}
326326
};
327327

328-
// All unconstrained functions perform note discovery, since they may need to access notes. This is slightly
329-
// inefficient and could be improved by only doing it once we actually attempt to read any.
330-
let note_discovery_call = if NOTES.len() > 0 {
331-
create_note_discovery_call()
328+
// All unconstrained functions perform message discovery, since they may need to access private notes that would be
329+
// found during this process. This is slightly inefficient and could be improved by only doing it once we actually
330+
// attempt to read any.
331+
let message_discovery_call = if NOTES.len() > 0 {
332+
create_message_discovery_call()
332333
} else {
333334
quote {}
334335
};
335336

336337
let to_prepend = quote {
337338
$context_creation
338339
$storage_init
339-
$note_discovery_call
340+
$message_discovery_call
340341
};
341342
let body = f.body().as_block().unwrap();
342343
let modified_body = modify_fn_body(body, to_prepend, quote {});
@@ -380,14 +381,14 @@ comptime fn create_init_check(f: FunctionDefinition) -> Quoted {
380381
.quoted_contents()
381382
}
382383

383-
/// Injects a call to `aztec::discovery::discover_new_notes`, causing for new notes to be added to PXE and made
384+
/// Injects a call to `aztec::discovery::discover_new_messages`, causing for new notes to be added to PXE and made
384385
/// available for the current execution.
385-
pub(crate) comptime fn create_note_discovery_call() -> Quoted {
386+
pub(crate) comptime fn create_message_discovery_call() -> Quoted {
386387
quote {
387-
/// Safety: note discovery returns nothing and is performed solely for its side-effects. It is therefore always
388-
/// safe to call.
388+
/// Safety: message discovery returns nothing and is performed solely for its side-effects. It is therefore
389+
/// always safe to call.
389390
unsafe {
390-
dep::aztec::discovery::discover_new_notes(
391+
dep::aztec::discovery::discover_new_messages(
391392
context.this_address(),
392393
_compute_note_hash_and_nullifier,
393394
);

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

+10-10
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ pub mod events;
77

88
use functions::{
99
stub_registry,
10-
utils::{create_note_discovery_call, find_and_transform_top_level_unconstrained_fns},
10+
utils::{create_message_discovery_call, find_and_transform_top_level_unconstrained_fns},
1111
};
1212
use notes::{generate_note_export, NOTES};
1313
use storage::STORAGE_LAYOUT_NAME;
@@ -189,7 +189,7 @@ comptime fn generate_contract_library_method_compute_note_hash_and_nullifier() -
189189

190190
let note_hash = $compute_note_hash(note, storage_slot);
191191

192-
// The note discovery process finds settled notes, that is, notes that were created in prior
192+
// The message discovery process finds settled notes, that is, notes that were created in prior
193193
// transactions and are therefore already part of the note hash tree. We therefore compute the
194194
// nullification note hash by treating the note as a settled note with the provided nonce.
195195
let note_hash_for_nullify = aztec::note::utils::compute_note_hash_for_nullify(
@@ -221,8 +221,8 @@ comptime fn generate_contract_library_method_compute_note_hash_and_nullifier() -
221221
/// tree with `nonce`.
222222
///
223223
/// The signature of this function notably matches the `aztec::discovery::ComputeNoteHashAndNullifier` type,
224-
/// and so it can be used to call functions from that module such as `discover_new_notes`, `do_process_log`
225-
/// and `attempt_note_discovery`.
224+
/// and so it can be used to call functions from that module such as `discover_new_messages`,
225+
/// `do_process_log` and `attempt_note_discovery`.
226226
///
227227
/// This function is automatically injected by the `#[aztec]` macro.
228228
#[contract_library_method]
@@ -263,7 +263,7 @@ comptime fn generate_contract_library_method_compute_note_hash_and_nullifier() -
263263

264264
comptime fn generate_process_log() -> Quoted {
265265
// This mandatory function processes a log emitted by the contract. This is currently used to process private logs
266-
// and perform note discovery of either private notes or partial notes.
266+
// and perform message discovery, resulting in new private notes, partial notes and events.
267267
// The bulk of the work of this function is done by aztec::discovery::do_process_log, so all we need to do is call
268268
// that function.
269269

@@ -279,9 +279,9 @@ comptime fn generate_process_log() -> Quoted {
279279
first_nullifier_in_tx: Field,
280280
recipient: aztec::protocol_types::address::AztecAddress,
281281
) {
282-
// Because this unconstrained function is injected after the contract is processed by the macros, it'll not
283-
// be modified by the macros that alter unconstrained functions. As such, we need to manually inject the
284-
// unconstrained execution context since it will not be available otherwise.
282+
// Because this unconstrained function is injected after the contract is processed by the macros, it'll
283+
// not be modified by the macros that alter unconstrained functions. As such, we need to manually inject
284+
// the unconstrained execution context since it will not be available otherwise.
285285
let context = dep::aztec::context::unconstrained_context::UnconstrainedContext::new();
286286

287287
// TODO(#10727): allow other contracts to process logs and deliver notes
@@ -327,15 +327,15 @@ comptime fn generate_note_exports() -> Quoted {
327327
}
328328

329329
comptime fn generate_sync_notes() -> Quoted {
330-
let note_discovery_call = create_note_discovery_call();
330+
let message_discovery_call = create_message_discovery_call();
331331
quote {
332332
unconstrained fn sync_notes() {
333333
// Because this unconstrained function is injected after the contract is processed by the macros, it'll not
334334
// be modified by the macros that alter unconstrained functions. As such, we need to manually inject the
335335
// unconstrained execution context since it will not be available otherwise.
336336
let context = dep::aztec::context::unconstrained_context::UnconstrainedContext::new();
337337

338-
$note_discovery_call
338+
$message_discovery_call
339339
}
340340
}
341341
}

noir-projects/aztec-nr/aztec/src/oracle/mod.nr

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub mod get_membership_witness;
1717
pub mod keys;
1818
pub mod key_validation_request;
1919
pub mod logs;
20-
pub mod note_discovery;
20+
pub mod message_discovery;
2121
pub mod notes;
2222
pub mod random;
2323
pub mod shared_secret;

yarn-project/stdlib/src/logs/log_with_tx_data.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { MAX_NOTE_HASHES_PER_TX, PUBLIC_LOG_DATA_SIZE_IN_FIELDS } from '@aztec/constants';
22
import { Fr } from '@aztec/foundation/fields';
33

4-
// TypeScript representation of the Noir aztec::oracle::note_discovery::LogWithTxData struct. This is used as a response
5-
// for PXE's custom getLogByTag oracle.
4+
// TypeScript representation of the Noir aztec::oracle::message_discovery::LogWithTxData struct. This is used as a
5+
// response for PXE's custom getLogByTag oracle.
66
export class LogWithTxData {
77
constructor(
88
public logContent: Fr[],

0 commit comments

Comments
 (0)