diff --git a/noir-projects/aztec-nr/aztec/src/context/private_context.nr b/noir-projects/aztec-nr/aztec/src/context/private_context.nr index 30ff19883d2..8ea2ddc9014 100644 --- a/noir-projects/aztec-nr/aztec/src/context/private_context.nr +++ b/noir-projects/aztec-nr/aztec/src/context/private_context.nr @@ -222,7 +222,7 @@ impl PrivateContext { let cached_request = self.last_key_validation_requests[key_index].unwrap_or(KeyValidationRequest::empty()); if cached_request.pk_m.hash() == pk_m_hash { - // We get a match so the cached request is the latest one + // We get a match so the cached request is the latest one cached_request.sk_app } else { // We didn't get a match meaning the cached result is stale. We fetch new values from oracle and instruct @@ -323,7 +323,7 @@ impl PrivateContext { self.call_private_function_with_packed_args(contract_address, function_selector, args_hash, false, true) } - pub fn call_private_function_no_args( + pub fn call_private_function_no_args( &mut self, contract_address: AztecAddress, function_selector: FunctionSelector @@ -331,7 +331,7 @@ impl PrivateContext { self.call_private_function_with_packed_args(contract_address, function_selector, 0, false, false) } - pub fn static_call_private_function_no_args( + pub fn static_call_private_function_no_args( &mut self, contract_address: AztecAddress, function_selector: FunctionSelector @@ -339,7 +339,7 @@ impl PrivateContext { self.call_private_function_with_packed_args(contract_address, function_selector, 0, true, false) } - pub fn delegate_call_private_function_no_args( + pub fn delegate_call_private_function_no_args( &mut self, contract_address: AztecAddress, function_selector: FunctionSelector @@ -347,7 +347,7 @@ impl PrivateContext { self.call_private_function_with_packed_args(contract_address, function_selector, 0, false, true) } - pub fn call_private_function_with_packed_args( + pub fn call_private_function_with_packed_args( &mut self, contract_address: AztecAddress, function_selector: FunctionSelector, @@ -511,7 +511,7 @@ impl PrivateContext { self.set_public_teardown_function_with_packed_args(contract_address, function_selector, args_hash, false, false) } - pub fn set_public_teardown_function_with_packed_args( + pub fn set_public_teardown_function_with_packed_args( &mut self, contract_address: AztecAddress, function_selector: FunctionSelector, diff --git a/noir-projects/aztec-nr/aztec/src/context/public_context.nr b/noir-projects/aztec-nr/aztec/src/context/public_context.nr index 57a57c05935..762fde1c1c8 100644 --- a/noir-projects/aztec-nr/aztec/src/context/public_context.nr +++ b/noir-projects/aztec-nr/aztec/src/context/public_context.nr @@ -391,10 +391,6 @@ impl FunctionReturns { FunctionReturns { values } } - pub fn assert_empty(returns: FunctionReturns<0>) { - assert(returns.values.len() == 0); - } - pub fn raw(self) -> [Field; N] { self.values } @@ -403,3 +399,9 @@ impl FunctionReturns { Deserialize::deserialize(self.raw()) } } + +impl FunctionReturns<0> { + pub fn assert_empty(self) { + assert(self.values.len() == 0); + } +} diff --git a/noir-projects/aztec-nr/aztec/src/note/note_getter/mod.nr b/noir-projects/aztec-nr/aztec/src/note/note_getter/mod.nr index 576d05a0885..ab9d0edef96 100644 --- a/noir-projects/aztec-nr/aztec/src/note/note_getter/mod.nr +++ b/noir-projects/aztec-nr/aztec/src/note/note_getter/mod.nr @@ -14,7 +14,7 @@ fn extract_property_value_from_selector( serialized_note: [Field; N], selector: PropertySelector ) -> Field { - // Selectors use PropertySelectors in order to locate note properties inside the serialized note. + // Selectors use PropertySelectors in order to locate note properties inside the serialized note. // This allows easier packing and custom (de)serialization schemas. A note property is located // inside the serialized note using the index inside the array, a byte offset and a length. let value = serialized_note[selector.index].to_be_bytes(32); @@ -113,7 +113,7 @@ pub fn get_notes( constrain_get_notes_internal(context, storage_slot, opt_notes, options) } -unconstrained fn apply_preprocessor( +unconstrained fn apply_preprocessor( notes: [Option; MAX_NOTE_HASH_READ_REQUESTS_PER_CALL], preprocessor: fn([Option; MAX_NOTE_HASH_READ_REQUESTS_PER_CALL], PREPROCESSOR_ARGS) -> [Option; MAX_NOTE_HASH_READ_REQUESTS_PER_CALL], preprocessor_args: PREPROCESSOR_ARGS @@ -264,7 +264,7 @@ unconstrained pub fn view_notes( notes } -unconstrained fn flatten_options( +unconstrained fn flatten_options( selects: BoundedVec, N>, sorts: BoundedVec, N> ) -> (u8, [u8; N], [u8; N], [u8; N], [Field; N], [u8; N], [u8; N], [u8; N], [u8; N], [u8; N]) { diff --git a/noir-projects/aztec-nr/aztec/src/note/note_getter_options.nr b/noir-projects/aztec-nr/aztec/src/note/note_getter_options.nr index 61049c8f19e..88263962e7e 100644 --- a/noir-projects/aztec-nr/aztec/src/note/note_getter_options.nr +++ b/noir-projects/aztec-nr/aztec/src/note/note_getter_options.nr @@ -70,7 +70,7 @@ global NoteStatus = NoteStatusEnum { // TODO 4217: add 'NULLIFIED' }; -fn return_all_notes( +fn return_all_notes( notes: [Option; MAX_NOTE_HASH_READ_REQUESTS_PER_CALL], _p: Field ) -> [Option; MAX_NOTE_HASH_READ_REQUESTS_PER_CALL] { @@ -100,64 +100,9 @@ struct NoteGetterOptions NoteGetterOptions { - // This function initializes a NoteGetterOptions that simply returns the maximum number of notes allowed in a call. - pub fn new() -> NoteGetterOptions where Note: NoteInterface { - NoteGetterOptions { - selects: BoundedVec::new(), - sorts: BoundedVec::new(), - limit: MAX_NOTE_HASH_READ_REQUESTS_PER_CALL as u32, - offset: 0, - preprocessor: return_all_notes, - preprocessor_args: 0, - filter: return_all_notes, - filter_args: 0, - status: NoteStatus.ACTIVE - } - } - - // This function initializes a NoteGetterOptions with a preprocessor, which takes the notes returned from - // the database and preprocessor_args as its parameters. - // `preprocessor_args` allows you to provide additional data or context to the custom preprocessor. - pub fn with_preprocessor( - preprocessor: fn([Option; MAX_NOTE_HASH_READ_REQUESTS_PER_CALL], PREPROCESSOR_ARGS) -> [Option; MAX_NOTE_HASH_READ_REQUESTS_PER_CALL], - preprocessor_args: PREPROCESSOR_ARGS - ) -> NoteGetterOptions where Note: NoteInterface { - NoteGetterOptions { - selects: BoundedVec::new(), - sorts: BoundedVec::new(), - limit: MAX_NOTE_HASH_READ_REQUESTS_PER_CALL as u32, - offset: 0, - preprocessor, - preprocessor_args, - filter: return_all_notes, - filter_args: 0, - status: NoteStatus.ACTIVE - } - } - - // This function initializes a NoteGetterOptions with a filter, which takes - // the notes returned from the database and filter_args as its parameters. - // `filter_args` allows you to provide additional data or context to the custom filter. - pub fn with_filter( - filter: fn([Option; MAX_NOTE_HASH_READ_REQUESTS_PER_CALL], FILTER_ARGS) -> [Option; MAX_NOTE_HASH_READ_REQUESTS_PER_CALL], - filter_args: FILTER_ARGS - ) -> NoteGetterOptions where Note: NoteInterface { - NoteGetterOptions { - selects: BoundedVec::new(), - sorts: BoundedVec::new(), - limit: MAX_NOTE_HASH_READ_REQUESTS_PER_CALL as u32, - offset: 0, - preprocessor: return_all_notes, - preprocessor_args: 0, - filter, - filter_args, - status: NoteStatus.ACTIVE - } - } - // This method adds a `Select` criterion to the options. - // It takes a property_selector indicating which field to select, - // a value representing the specific value to match in that field, and + // It takes a property_selector indicating which field to select, + // a value representing the specific value to match in that field, and // a comparator (For possible values of comparators, please see the Comparator enum above) pub fn select( &mut self, @@ -207,3 +152,64 @@ impl NoteGetterOpt *self } } + +impl NoteGetterOptions where Note: NoteInterface { + // This function initializes a NoteGetterOptions that simply returns the maximum number of notes allowed in a call. + pub fn new() -> Self { + Self { + selects: BoundedVec::new(), + sorts: BoundedVec::new(), + limit: MAX_NOTE_HASH_READ_REQUESTS_PER_CALL as u32, + offset: 0, + preprocessor: return_all_notes, + preprocessor_args: 0, + filter: return_all_notes, + filter_args: 0, + status: NoteStatus.ACTIVE + } + } +} + +impl NoteGetterOptions where Note: NoteInterface { + // This function initializes a NoteGetterOptions with a preprocessor, which takes the notes returned from + // the database and preprocessor_args as its parameters. + // `preprocessor_args` allows you to provide additional data or context to the custom preprocessor. + pub fn with_preprocessor( + preprocessor: fn([Option; MAX_NOTE_HASH_READ_REQUESTS_PER_CALL], PREPROCESSOR_ARGS) -> [Option; MAX_NOTE_HASH_READ_REQUESTS_PER_CALL], + preprocessor_args: PREPROCESSOR_ARGS + ) -> Self { + Self { + selects: BoundedVec::new(), + sorts: BoundedVec::new(), + limit: MAX_NOTE_HASH_READ_REQUESTS_PER_CALL as u32, + offset: 0, + preprocessor, + preprocessor_args, + filter: return_all_notes, + filter_args: 0, + status: NoteStatus.ACTIVE + } + } +} + +impl NoteGetterOptions where Note: NoteInterface { + // This function initializes a NoteGetterOptions with a filter, which takes + // the notes returned from the database and filter_args as its parameters. + // `filter_args` allows you to provide additional data or context to the custom filter. + pub fn with_filter( + filter: fn([Option; MAX_NOTE_HASH_READ_REQUESTS_PER_CALL], FILTER_ARGS) -> [Option; MAX_NOTE_HASH_READ_REQUESTS_PER_CALL], + filter_args: FILTER_ARGS + ) -> Self { + Self { + selects: BoundedVec::new(), + sorts: BoundedVec::new(), + limit: MAX_NOTE_HASH_READ_REQUESTS_PER_CALL as u32, + offset: 0, + preprocessor: return_all_notes, + preprocessor_args: 0, + filter, + filter_args, + status: NoteStatus.ACTIVE + } + } +} diff --git a/noir-projects/aztec-nr/aztec/src/oracle/arguments.nr b/noir-projects/aztec-nr/aztec/src/oracle/arguments.nr index 278a646da1e..50316d50893 100644 --- a/noir-projects/aztec-nr/aztec/src/oracle/arguments.nr +++ b/noir-projects/aztec-nr/aztec/src/oracle/arguments.nr @@ -5,18 +5,18 @@ unconstrained fn pack_arguments_array_oracle(_args: [Field; N]) -> F unconstrained fn pack_arguments_oracle(_args: [Field]) -> Field {} /// - Pack arguments (array version) will notify the simulator that these arguments will be used later at -/// some point in the call. +/// some point in the call. /// - When the external call is made later, the simulator will know what the values unpack to. -/// - This oracle will not be required in public vm functions, as the vm will keep track of arguments +/// - This oracle will not be required in public vm functions, as the vm will keep track of arguments /// itself. unconstrained pub fn pack_arguments_array(args: [Field; N]) -> Field { pack_arguments_array_oracle(args) } /// - Pack arguments (slice version) will notify the simulator that these arguments will be used later at -/// some point in the call. +/// some point in the call. /// - When the external call is made later, the simulator will know what the values unpack to. -/// - This oracle will not be required in public vm functions, as the vm will keep track of arguments +/// - This oracle will not be required in public vm functions, as the vm will keep track of arguments /// itself. unconstrained pub fn pack_arguments(args: [Field]) -> Field { pack_arguments_oracle(args) diff --git a/noir-projects/aztec-nr/aztec/src/oracle/get_membership_witness.nr b/noir-projects/aztec-nr/aztec/src/oracle/get_membership_witness.nr index 4ed39cd3ce9..125848fd25d 100644 --- a/noir-projects/aztec-nr/aztec/src/oracle/get_membership_witness.nr +++ b/noir-projects/aztec-nr/aztec/src/oracle/get_membership_witness.nr @@ -33,7 +33,7 @@ unconstrained pub fn get_membership_witness( // Note: get_nullifier_membership_witness function is implemented in get_nullifier_membership_witness.nr -unconstrained pub fn get_note_hash_membership_witness( +unconstrained pub fn get_note_hash_membership_witness( block_number: u32, leaf_value: Field ) -> MembershipWitness { diff --git a/noir-projects/aztec-nr/aztec/src/oracle/notes.nr b/noir-projects/aztec-nr/aztec/src/oracle/notes.nr index 8732937b7af..b384ff82488 100644 --- a/noir-projects/aztec-nr/aztec/src/oracle/notes.nr +++ b/noir-projects/aztec-nr/aztec/src/oracle/notes.nr @@ -22,13 +22,9 @@ unconstrained pub fn notify_created_note( } #[oracle(notifyNullifiedNote)] -unconstrained fn notify_nullified_note_oracle(_nullifier: Field, _note_hash: Field, _counter: u32) -> Field {} +unconstrained fn notify_nullified_note_oracle(_nullifier: Field, _note_hash: Field, _counter: u32) -> Field {} -unconstrained pub fn notify_nullified_note( - nullifier: Field, - note_hash: Field, - counter: u32 -) -> Field { +unconstrained pub fn notify_nullified_note(nullifier: Field, note_hash: Field, counter: u32) -> Field { notify_nullified_note_oracle(nullifier, note_hash, counter) } diff --git a/noir-projects/aztec-nr/aztec/src/oracle/returns.nr b/noir-projects/aztec-nr/aztec/src/oracle/returns.nr index c0ed6529761..b7372f40a0d 100644 --- a/noir-projects/aztec-nr/aztec/src/oracle/returns.nr +++ b/noir-projects/aztec-nr/aztec/src/oracle/returns.nr @@ -1,5 +1,5 @@ #[oracle(packReturns)] -unconstrained fn pack_returns_oracle(_returns: [Field]) -> Field {} +unconstrained fn pack_returns_oracle(_returns: [Field]) -> Field {} unconstrained pub fn pack_returns(returns: [Field]) { let _unused = pack_returns_oracle(returns); diff --git a/noir-projects/aztec-nr/aztec/src/state_vars/map.nr b/noir-projects/aztec-nr/aztec/src/state_vars/map.nr index f1d5604952d..5ca79f852b9 100644 --- a/noir-projects/aztec-nr/aztec/src/state_vars/map.nr +++ b/noir-projects/aztec-nr/aztec/src/state_vars/map.nr @@ -33,3 +33,4 @@ impl Map { } // docs:end:at } + diff --git a/noir-projects/aztec-nr/aztec/src/state_vars/shared_mutable/shared_mutable.nr b/noir-projects/aztec-nr/aztec/src/state_vars/shared_mutable/shared_mutable.nr index 71cd7ba2a2b..93f6e076b5b 100644 --- a/noir-projects/aztec-nr/aztec/src/state_vars/shared_mutable/shared_mutable.nr +++ b/noir-projects/aztec-nr/aztec/src/state_vars/shared_mutable/shared_mutable.nr @@ -62,16 +62,6 @@ impl SharedMutable, - delay_change: ScheduledDelayChange - ) -> Field { - // TODO(#5491 and https://github.com/noir-lang/noir/issues/4784): update this so that we don't need to rely on - // ScheduledValueChange serializing to 3 and ScheduledDelayChange serializing to 1 - let concatenated: [Field; 4] = concat_arrays(value_change.serialize(), delay_change.serialize()); - poseidon2_hash(concatenated) - } - // Since we can't rely on the native storage allocation scheme, we hash the storage slot to get a unique location in // which we can safely store as much data as we need. // See https://github.com/AztecProtocol/aztec-packages/issues/5492 and @@ -228,6 +218,16 @@ impl SharedMutable, + delay_change: ScheduledDelayChange + ) -> Field { + // TODO(#5491 and https://github.com/noir-lang/noir/issues/4784): update this so that we don't need to rely on + // ScheduledValueChange serializing to 3 and ScheduledDelayChange serializing to 1 + let concatenated: [Field; 4] = concat_arrays(value_change.serialize(), delay_change.serialize()); + poseidon2_hash(concatenated) + } } impl SharedMutable where T: ToField + FromField + Eq { diff --git a/noir-projects/aztec-nr/easy-private-state/src/easy_private_uint.nr b/noir-projects/aztec-nr/easy-private-state/src/easy_private_uint.nr index 4f829187d07..944c29603a6 100644 --- a/noir-projects/aztec-nr/easy-private-state/src/easy_private_uint.nr +++ b/noir-projects/aztec-nr/easy-private-state/src/easy_private_uint.nr @@ -21,7 +21,7 @@ impl EasyPrivateUint { } } -impl EasyPrivateUint<&mut PrivateContext> { +impl EasyPrivateUint<&mut PrivateContext> { // Very similar to `value_note::utils::increment`. pub fn add(self, addend: u64, owner: AztecAddress, outgoing_viewer: AztecAddress) { let owner_keys = get_current_public_keys(self.context, owner); diff --git a/noir-projects/noir-contracts/contracts/counter_contract/src/main.nr b/noir-projects/noir-contracts/contracts/counter_contract/src/main.nr index 97e5e40dec3..d5e554022cf 100644 --- a/noir-projects/noir-contracts/contracts/counter_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/counter_contract/src/main.nr @@ -55,7 +55,7 @@ contract Counter { let initial_value: Field = 5; env.impersonate(owner); - // Deploy contract and initialize + // Deploy contract and initialize let initializer = Counter::interface().initialize(initial_value as u64, owner, outgoing_viewer); let counter_contract = env.deploy_self("Counter").with_private_initializer(initializer); let contract_address = counter_contract.to_address(); diff --git a/noir-projects/noir-contracts/contracts/easy_private_token_contract/src/main.nr b/noir-projects/noir-contracts/contracts/easy_private_token_contract/src/main.nr index 3467cfef4c6..72959179f75 100644 --- a/noir-projects/noir-contracts/contracts/easy_private_token_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/easy_private_token_contract/src/main.nr @@ -1,6 +1,6 @@ // docs:start:easy_private_token_contract contract EasyPrivateToken { - use dep::aztec::prelude::{AztecAddress, NoteHeader, Map}; + use dep::aztec::prelude::{AztecAddress, Map}; use dep::value_note::balance_utils; use dep::easy_private_state::EasyPrivateUint; diff --git a/noir-projects/noir-contracts/contracts/static_parent_contract/src/main.nr b/noir-projects/noir-contracts/contracts/static_parent_contract/src/main.nr index 39cb8ffe155..1b30deb1b8f 100644 --- a/noir-projects/noir-contracts/contracts/static_parent_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/static_parent_contract/src/main.nr @@ -1,7 +1,7 @@ // A contract used along with `StaticChild` contract to test static calls. contract StaticParent { - use dep::aztec::prelude::{AztecAddress, FunctionSelector, Deserialize}; + use dep::aztec::prelude::{AztecAddress, FunctionSelector}; use dep::aztec::context::gas::GasOpts; use dep::static_child_contract::StaticChild;