diff --git a/noir-projects/aztec-nr/aztec/src/discovery/mod.nr b/noir-projects/aztec-nr/aztec/src/discovery/mod.nr index 0155e087b679..d473c3d19eaf 100644 --- a/noir-projects/aztec-nr/aztec/src/discovery/mod.nr +++ b/noir-projects/aztec-nr/aztec/src/discovery/mod.nr @@ -18,7 +18,7 @@ pub global MAX_NOTE_PACKED_LEN: u32 = pub struct NoteHashAndNullifier { /// The result of NoteHash::compute_note_hash pub note_hash: Field, - /// The result of NoteHash::compute_nullifier_unconstrained (since all of note discovery is unconstrained) + /// The result of NoteHash::compute_nullifier_unconstrained (since all of message discovery is unconstrained) pub inner_nullifier: Field, } @@ -59,16 +59,17 @@ pub struct NoteHashAndNullifier { /// ``` type ComputeNoteHashAndNullifier = unconstrained fn[Env](/* packed_note_content */BoundedVec, /* storage_slot */ Field, /* note_type_id */ Field, /* contract_address */ AztecAddress, /* nonce */ Field) -> Option; -/// Performs the note discovery process, in which private and public logs are downloaded and inspected to find private -/// notes, partial notes, and their completion. This is the mechanism via which PXE learns of new notes. +/// Performs the message discovery process, in which private are downloaded and inspected to find new private notes, +/// partial notes and events, etc., and pending partial notes are processed to search for their completion logs. +/// This is the mechanism via which a contract updates its knowldge of its private state. /// -/// Receives the address of the contract on which discovery is performed (i.e. the contract that emitted the notes) -/// along with its `compute_note_hash_and_nullifier` function. -pub unconstrained fn discover_new_notes( +/// Receives the address of the contract on which discovery is performed along with its +/// `compute_note_hash_and_nullifier` function. +pub unconstrained fn discover_new_messages( contract_address: AztecAddress, compute_note_hash_and_nullifier: ComputeNoteHashAndNullifier, ) { - debug_log("Performing note discovery"); + debug_log("Performing message discovery"); private_logs::fetch_and_process_private_tagged_logs( contract_address, diff --git a/noir-projects/aztec-nr/aztec/src/discovery/nonce_discovery.nr b/noir-projects/aztec-nr/aztec/src/discovery/nonce_discovery.nr index 54c28f831e96..271472a38a9d 100644 --- a/noir-projects/aztec-nr/aztec/src/discovery/nonce_discovery.nr +++ b/noir-projects/aztec-nr/aztec/src/discovery/nonce_discovery.nr @@ -35,7 +35,7 @@ pub unconstrained fn attempt_note_nonce_discovery( let discovered_notes = &mut BoundedVec::new(); debug_log_format( - "Attempting note discovery on {0} potential notes on contract {1} for storage slot {2}", + "Attempting nonce discovery on {0} potential notes on contract {1} for storage slot {2}", [unique_note_hashes_in_tx.len() as Field, contract_address.to_field(), storage_slot], ); diff --git a/noir-projects/aztec-nr/aztec/src/discovery/partial_notes.nr b/noir-projects/aztec-nr/aztec/src/discovery/partial_notes.nr index dab4ee952a40..7b517c34ae4f 100644 --- a/noir-projects/aztec-nr/aztec/src/discovery/partial_notes.nr +++ b/noir-projects/aztec-nr/aztec/src/discovery/partial_notes.nr @@ -5,7 +5,7 @@ use crate::{ nonce_discovery::{attempt_note_nonce_discovery, DiscoveredNoteInfo}, private_logs::MAX_PARTIAL_NOTE_PRIVATE_PACKED_LEN, }, - oracle::note_discovery::{deliver_note, get_log_by_tag}, + oracle::message_discovery::{deliver_note, get_log_by_tag}, utils::array, }; @@ -72,8 +72,8 @@ pub unconstrained fn fetch_and_process_public_partial_note_completion_logs( ); *i += 1 as u32; // Note that we're not removing the pending partial note from the PXE DB, so we will continue searching - // for this tagged log when performing note discovery in the future until we either find it or the entry - // is somehow removed from the PXE DB. + // for this tagged log when performing message discovery in the future until we either find it or the + // entry is somehow removed from the PXE DB. } else { debug_log_format( "Completion log found for partial note with tag {}", diff --git a/noir-projects/aztec-nr/aztec/src/discovery/private_logs.nr b/noir-projects/aztec-nr/aztec/src/discovery/private_logs.nr index 5a36e2c18a80..d5591d8a6ee0 100644 --- a/noir-projects/aztec-nr/aztec/src/discovery/private_logs.nr +++ b/noir-projects/aztec-nr/aztec/src/discovery/private_logs.nr @@ -2,7 +2,7 @@ use std::static_assert; use crate::{ capsules::CapsuleArray, - oracle::note_discovery::{deliver_note, sync_notes}, + oracle::message_discovery::{deliver_note, sync_notes}, utils::array, }; diff --git a/noir-projects/aztec-nr/aztec/src/encrypted_logs/log_assembly_strategies/default_aes128/note/encryption.nr b/noir-projects/aztec-nr/aztec/src/encrypted_logs/log_assembly_strategies/default_aes128/note/encryption.nr index b6970235f00e..78302f6e26b5 100644 --- a/noir-projects/aztec-nr/aztec/src/encrypted_logs/log_assembly_strategies/default_aes128/note/encryption.nr +++ b/noir-projects/aztec-nr/aztec/src/encrypted_logs/log_assembly_strategies/default_aes128/note/encryption.nr @@ -46,7 +46,7 @@ pub global PRIVATE_LOG_PLAINTEXT_SIZE_IN_FIELDS: u32 = PRIVATE_LOG_PLAINTEXT_SIZ /// The resulting log has the following format: /// ```text /// [ -/// tag: Field, // Tag for note discovery, derived from sender/recipient +/// tag: Field, // Tag for message discovery, derived from sender/recipient /// epk_x: Field, // X coordinate of ephemeral public key /// log_bytes: [Field], // Encrypted data converted from bytes to fields, containing: /// [ diff --git a/noir-projects/aztec-nr/aztec/src/macros/functions/utils.nr b/noir-projects/aztec-nr/aztec/src/macros/functions/utils.nr index 36195ef25092..d395e5706aa0 100644 --- a/noir-projects/aztec-nr/aztec/src/macros/functions/utils.nr +++ b/noir-projects/aztec-nr/aztec/src/macros/functions/utils.nr @@ -97,10 +97,10 @@ pub(crate) comptime fn transform_private(f: FunctionDefinition) -> Quoted { quote {} }; - // All private functions perform note discovery, since they may need to access notes. This is slightly inefficient - // and could be improved by only doing it once we actually attempt to read any. - let note_discovery_call = if NOTES.len() > 0 { - create_note_discovery_call() + // All private functions perform message discovery, since they may need to access notes. This is slightly + // inefficient and could be improved by only doing it once we actually attempt to read any. + let message_discovery_call = if NOTES.len() > 0 { + create_message_discovery_call() } else { quote {} }; @@ -156,7 +156,7 @@ pub(crate) comptime fn transform_private(f: FunctionDefinition) -> Quoted { $internal_check $view_check $storage_init - $note_discovery_call + $message_discovery_call }; let to_append = quote { @@ -324,10 +324,11 @@ pub(crate) comptime fn transform_top_level_unconstrained(f: FunctionDefinition) quote {} }; - // All unconstrained functions perform note discovery, since they may need to access notes. This is slightly - // inefficient and could be improved by only doing it once we actually attempt to read any. - let note_discovery_call = if NOTES.len() > 0 { - create_note_discovery_call() + // All unconstrained functions perform message discovery, since they may need to access private notes that would be + // found during this process. This is slightly inefficient and could be improved by only doing it once we actually + // attempt to read any. + let message_discovery_call = if NOTES.len() > 0 { + create_message_discovery_call() } else { quote {} }; @@ -335,7 +336,7 @@ pub(crate) comptime fn transform_top_level_unconstrained(f: FunctionDefinition) let to_prepend = quote { $context_creation $storage_init - $note_discovery_call + $message_discovery_call }; let body = f.body().as_block().unwrap(); let modified_body = modify_fn_body(body, to_prepend, quote {}); @@ -379,14 +380,14 @@ comptime fn create_init_check(f: FunctionDefinition) -> Quoted { .quoted_contents() } -/// Injects a call to `aztec::discovery::discover_new_notes`, causing for new notes to be added to PXE and made +/// Injects a call to `aztec::discovery::discover_new_messages`, causing for new notes to be added to PXE and made /// available for the current execution. -pub(crate) comptime fn create_note_discovery_call() -> Quoted { +pub(crate) comptime fn create_message_discovery_call() -> Quoted { quote { - /// Safety: note discovery returns nothing and is performed solely for its side-effects. It is therefore always - /// safe to call. + /// Safety: message discovery returns nothing and is performed solely for its side-effects. It is therefore + /// always safe to call. unsafe { - dep::aztec::discovery::discover_new_notes( + dep::aztec::discovery::discover_new_messages( context.this_address(), _compute_note_hash_and_nullifier, ); diff --git a/noir-projects/aztec-nr/aztec/src/macros/mod.nr b/noir-projects/aztec-nr/aztec/src/macros/mod.nr index 3c2fd7c460f2..d16b7984a7f6 100644 --- a/noir-projects/aztec-nr/aztec/src/macros/mod.nr +++ b/noir-projects/aztec-nr/aztec/src/macros/mod.nr @@ -7,7 +7,7 @@ pub mod events; use functions::{ stub_registry, - utils::{create_note_discovery_call, find_and_transform_top_level_unconstrained_fns}, + utils::{create_message_discovery_call, find_and_transform_top_level_unconstrained_fns}, }; use notes::{generate_note_export, NOTES}; use storage::STORAGE_LAYOUT_NAME; @@ -189,7 +189,7 @@ comptime fn generate_contract_library_method_compute_note_hash_and_nullifier() - let note_hash = $compute_note_hash(note, storage_slot); - // The note discovery process finds settled notes, that is, notes that were created in prior + // The message discovery process finds settled notes, that is, notes that were created in prior // transactions and are therefore already part of the note hash tree. We therefore compute the // nullification note hash by treating the note as a settled note with the provided nonce. 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() - /// tree with `nonce`. /// /// The signature of this function notably matches the `aztec::discovery::ComputeNoteHashAndNullifier` type, - /// and so it can be used to call functions from that module such as `discover_new_notes`, `do_process_log` - /// and `attempt_note_discovery`. + /// and so it can be used to call functions from that module such as `discover_new_messages`, + /// `do_process_log` and `attempt_note_discovery`. /// /// This function is automatically injected by the `#[aztec]` macro. #[contract_library_method] @@ -263,7 +263,7 @@ comptime fn generate_contract_library_method_compute_note_hash_and_nullifier() - comptime fn generate_process_log() -> Quoted { // This mandatory function processes a log emitted by the contract. This is currently used to process private logs - // and perform note discovery of either private notes or partial notes. + // and perform message discovery, resulting in new private notes, partial notes and events. // The bulk of the work of this function is done by aztec::discovery::do_process_log, so all we need to do is call // that function. @@ -279,9 +279,9 @@ comptime fn generate_process_log() -> Quoted { first_nullifier_in_tx: Field, recipient: aztec::protocol_types::address::AztecAddress, ) { - // Because this unconstrained function is injected after the contract is processed by the macros, it'll not - // be modified by the macros that alter unconstrained functions. As such, we need to manually inject the - // unconstrained execution context since it will not be available otherwise. + // Because this unconstrained function is injected after the contract is processed by the macros, it'll + // not be modified by the macros that alter unconstrained functions. As such, we need to manually inject + // the unconstrained execution context since it will not be available otherwise. let context = dep::aztec::context::unconstrained_context::UnconstrainedContext::new(); // TODO(#10727): allow other contracts to process logs and deliver notes @@ -327,7 +327,7 @@ comptime fn generate_note_exports() -> Quoted { } comptime fn generate_sync_notes() -> Quoted { - let note_discovery_call = create_note_discovery_call(); + let message_discovery_call = create_message_discovery_call(); quote { unconstrained fn sync_notes() { // Because this unconstrained function is injected after the contract is processed by the macros, it'll not @@ -335,7 +335,7 @@ comptime fn generate_sync_notes() -> Quoted { // unconstrained execution context since it will not be available otherwise. let context = dep::aztec::context::unconstrained_context::UnconstrainedContext::new(); - $note_discovery_call + $message_discovery_call } } } diff --git a/noir-projects/aztec-nr/aztec/src/oracle/note_discovery.nr b/noir-projects/aztec-nr/aztec/src/oracle/message_discovery.nr similarity index 100% rename from noir-projects/aztec-nr/aztec/src/oracle/note_discovery.nr rename to noir-projects/aztec-nr/aztec/src/oracle/message_discovery.nr diff --git a/noir-projects/aztec-nr/aztec/src/oracle/mod.nr b/noir-projects/aztec-nr/aztec/src/oracle/mod.nr index 044d7cd87e81..fb3245f99ebc 100644 --- a/noir-projects/aztec-nr/aztec/src/oracle/mod.nr +++ b/noir-projects/aztec-nr/aztec/src/oracle/mod.nr @@ -17,7 +17,7 @@ pub mod get_membership_witness; pub mod keys; pub mod key_validation_request; pub mod logs; -pub mod note_discovery; +pub mod message_discovery; pub mod notes; pub mod random; pub mod shared_secret; diff --git a/yarn-project/stdlib/src/logs/log_with_tx_data.ts b/yarn-project/stdlib/src/logs/log_with_tx_data.ts index fd1c1f67d6f2..67cf66e1e015 100644 --- a/yarn-project/stdlib/src/logs/log_with_tx_data.ts +++ b/yarn-project/stdlib/src/logs/log_with_tx_data.ts @@ -1,8 +1,8 @@ import { MAX_NOTE_HASHES_PER_TX, PUBLIC_LOG_DATA_SIZE_IN_FIELDS } from '@aztec/constants'; import { Fr } from '@aztec/foundation/fields'; -// TypeScript representation of the Noir aztec::oracle::note_discovery::LogWithTxData struct. This is used as a response -// for PXE's custom getLogByTag oracle. +// TypeScript representation of the Noir aztec::oracle::message_discovery::LogWithTxData struct. This is used as a +// response for PXE's custom getLogByTag oracle. export class LogWithTxData { constructor( public logContent: Fr[],