From 1c7e627e28eeabe0cbf9ccae45e107d66b0953b0 Mon Sep 17 00:00:00 2001 From: Tom French <15848336+TomAFrench@users.noreply.github.com> Date: Mon, 14 Oct 2024 16:46:37 +0100 Subject: [PATCH] chore: swap `pub` and `unconstrained` in function signatures (#9237) This PR allows `pub unconstrained fn` which is preferred over `unconstrained pub fn` --- .../aztec-nr/authwit/src/auth_witness.nr | 2 +- .../aztec/src/context/public_context.nr | 2 +- .../aztec-nr/aztec/src/keys/getters/mod.nr | 4 +- .../aztec-nr/aztec/src/macros/dispatch/mod.nr | 2 +- .../aztec/src/note/note_getter/mod.nr | 2 +- .../aztec-nr/aztec/src/note/utils.nr | 2 +- .../aztec/src/oracle/call_private_function.nr | 2 +- .../oracle/enqueue_public_function_call.nr | 6 +-- .../aztec-nr/aztec/src/oracle/execution.nr | 8 ++-- .../aztec/src/oracle/get_contract_instance.nr | 2 +- .../oracle/get_l1_to_l2_membership_witness.nr | 2 +- .../src/oracle/get_membership_witness.nr | 6 +-- .../get_nullifier_membership_witness.nr | 4 +- .../src/oracle/get_public_data_witness.nr | 2 +- .../aztec/src/oracle/get_sibling_path.nr | 2 +- .../aztec-nr/aztec/src/oracle/header.nr | 2 +- .../src/oracle/key_validation_request.nr | 2 +- .../aztec-nr/aztec/src/oracle/keys.nr | 2 +- .../aztec-nr/aztec/src/oracle/logs.nr | 2 +- .../aztec-nr/aztec/src/oracle/notes.nr | 4 +- .../aztec-nr/aztec/src/oracle/random.nr | 2 +- .../aztec-nr/aztec/src/oracle/returns.nr | 4 +- .../aztec-nr/aztec/src/oracle/storage.nr | 4 +- .../aztec/src/state_vars/private_immutable.nr | 4 +- .../aztec/src/state_vars/private_mutable.nr | 4 +- .../aztec/src/state_vars/private_set.nr | 2 +- .../aztec/src/state_vars/public_immutable.nr | 2 +- .../aztec/src/state_vars/public_mutable.nr | 2 +- .../aztec/src/state_vars/shared_immutable.nr | 2 +- .../shared_mutable/shared_mutable.nr | 2 +- .../aztec/src/test/helpers/cheatcodes.nr | 42 +++++++++---------- .../src/test/helpers/test_environment.nr | 2 +- .../aztec-nr/aztec/src/test/helpers/utils.nr | 8 ++-- .../aztec-nr/value-note/src/balance_utils.nr | 4 +- .../contracts/auth_contract/src/test/utils.nr | 2 +- .../contracts/card_game_contract/src/cards.nr | 2 +- .../src/capsule.nr | 2 +- .../contracts/nft_contract/src/test/utils.nr | 12 +++--- .../src/auth_oracle.nr | 2 +- .../spam_contract/src/types/balance_set.nr | 4 +- .../src/types/balances_map.nr | 4 +- .../contracts/token_contract/src/main.nr | 2 +- .../token_contract/src/test/utils.nr | 8 ++-- .../token_contract/src/types/balance_set.nr | 4 +- .../previous_kernel_validator_hints.nr | 2 +- .../find_first_revertible_item_index.nr | 2 +- ...e_kernel_circuit_public_inputs_composer.nr | 2 +- .../src/components/reset_output_composer.nr | 4 +- .../reset_output_hints.nr | 2 +- ...r_propagated_note_hash_indexes_for_logs.nr | 2 +- .../squash_transient_data.nr | 2 +- .../src/components/tail_output_composer.nr | 4 +- .../tail_output_hints.nr | 2 +- .../tail_to_public_output_composer.nr | 4 +- .../split_to_public.nr | 2 +- .../tail_to_public_output_hints.nr | 2 +- .../components/public_tail_output_composer.nr | 4 +- .../combine_data.nr | 2 +- .../generate_output_hints.nr | 2 +- ...generate_overridable_public_data_writes.nr | 2 +- .../generate_public_data_leaves.nr | 2 +- .../src/note_hash_read_request_reset.nr | 2 +- .../src/nullifier_read_request_reset.nr | 2 +- .../private_validation_request_processor.nr | 2 +- .../src/public_data_read_request_hints.nr | 2 +- .../src/reset/key_validation_hint.nr | 2 +- .../src/reset/read_request.nr | 4 +- .../src/reset/transient_data.nr | 4 +- .../note_hash_read_request_hints_builder.nr | 2 +- ...non_existent_read_request_hints_builder.nr | 2 +- .../nullifier_read_request_hints_builder.nr | 2 +- .../crates/types/src/debug_log.nr | 2 +- .../crates/types/src/utils/arrays.nr | 2 +- .../src/utils/arrays/assert_combined_array.nr | 2 +- .../get_combined_order_hints.nr | 4 +- .../assert_combined_transformed_array.nr | 2 +- .../src/utils/arrays/assert_deduped_array.nr | 2 +- .../get_order_hints.nr | 6 +-- .../get_split_order_hints.nr | 4 +- .../src/utils/arrays/get_sorted_result.nr | 2 +- .../src/utils/arrays/get_sorted_tuple.nr | 2 +- .../crates/types/src/utils/arrays/sort_by.nr | 2 +- .../types/src/utils/arrays/sort_by_counter.nr | 4 +- .../src/parser/parser/function.rs | 11 ++++- .../src/parser/parser/modifiers.rs | 15 ++++++- .../noir_stdlib/src/array/quicksort.nr | 2 +- .../noir_stdlib/src/collections/umap.nr | 26 ++++++------ noir/noir-repo/noir_stdlib/src/field/bn254.nr | 2 +- noir/noir-repo/noir_stdlib/src/test.nr | 12 +++--- 89 files changed, 188 insertions(+), 166 deletions(-) diff --git a/noir-projects/aztec-nr/authwit/src/auth_witness.nr b/noir-projects/aztec-nr/authwit/src/auth_witness.nr index b87d9d0ab39..1bc8e19f246 100644 --- a/noir-projects/aztec-nr/authwit/src/auth_witness.nr +++ b/noir-projects/aztec-nr/authwit/src/auth_witness.nr @@ -7,6 +7,6 @@ unconstrained fn get_auth_witness_oracle(_message_hash: Field) -> [F * @param message_hash The hash of the message for which the `auth_witness` is to be fetched. * @return The `auth_witness` for the given `message_hash` as Field array. */ -unconstrained pub fn get_auth_witness(message_hash: Field) -> [Field; N] { +pub unconstrained fn get_auth_witness(message_hash: Field) -> [Field; N] { get_auth_witness_oracle(message_hash) } 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 b8c3adfbea8..ff476c4a672 100644 --- a/noir-projects/aztec-nr/aztec/src/context/public_context.nr +++ b/noir-projects/aztec-nr/aztec/src/context/public_context.nr @@ -291,7 +291,7 @@ unconstrained fn call_static( call_static_opcode(gas, address, args, function_selector) } -unconstrained pub fn calldata_copy(cdoffset: u32, copy_size: u32) -> [Field; N] { +pub unconstrained fn calldata_copy(cdoffset: u32, copy_size: u32) -> [Field; N] { calldata_copy_opcode(cdoffset, copy_size) } diff --git a/noir-projects/aztec-nr/aztec/src/keys/getters/mod.nr b/noir-projects/aztec-nr/aztec/src/keys/getters/mod.nr index de16b98a6ec..4e599139665 100644 --- a/noir-projects/aztec-nr/aztec/src/keys/getters/mod.nr +++ b/noir-projects/aztec-nr/aztec/src/keys/getters/mod.nr @@ -6,14 +6,14 @@ use crate::{ mod test; -unconstrained pub fn get_nsk_app(npk_m_hash: Field) -> Field { +pub unconstrained fn get_nsk_app(npk_m_hash: Field) -> Field { get_key_validation_request(npk_m_hash, NULLIFIER_INDEX).sk_app } // A helper function that gets app-siloed outgoing viewing key for a given `ovpk_m_hash`. This function is used // in unconstrained contexts only - when computing unconstrained note logs. The safe alternative is `request_ovsk_app` // function defined on `PrivateContext`. -unconstrained pub fn get_ovsk_app(ovpk_m_hash: Field) -> Field { +pub unconstrained fn get_ovsk_app(ovpk_m_hash: Field) -> Field { get_key_validation_request(ovpk_m_hash, OUTGOING_INDEX).sk_app } diff --git a/noir-projects/aztec-nr/aztec/src/macros/dispatch/mod.nr b/noir-projects/aztec-nr/aztec/src/macros/dispatch/mod.nr index bbd9f972421..52a42d1694d 100644 --- a/noir-projects/aztec-nr/aztec/src/macros/dispatch/mod.nr +++ b/noir-projects/aztec-nr/aztec/src/macros/dispatch/mod.nr @@ -93,7 +93,7 @@ pub comptime fn generate_public_dispatch(m: Module) -> Quoted { // functions having this attribute. However, the public MACRO will // handle the public_dispatch function specially and do nothing. #[public] - unconstrained pub fn public_dispatch(selector: Field) { + pub unconstrained fn public_dispatch(selector: Field) { $dispatch } }; 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 615609690e6..9185bccdd3b 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 @@ -222,7 +222,7 @@ unconstrained fn get_notes_internal( +pub unconstrained fn view_notes( storage_slot: Field, options: NoteViewerOptions ) -> BoundedVec where Note: NoteInterface { diff --git a/noir-projects/aztec-nr/aztec/src/note/utils.nr b/noir-projects/aztec-nr/aztec/src/note/utils.nr index 47f58177c04..7ff195bb09e 100644 --- a/noir-projects/aztec-nr/aztec/src/note/utils.nr +++ b/noir-projects/aztec-nr/aztec/src/note/utils.nr @@ -105,7 +105,7 @@ pub fn compute_note_hash_for_nullify(note: Note) -> Field wher compute_note_hash_for_nullify_internal(note, note_hash_for_read_request) } -unconstrained pub fn compute_note_hash_and_optionally_a_nullifier( +pub unconstrained fn compute_note_hash_and_optionally_a_nullifier( deserialize_content: fn([Field; N]) -> T, note_header: NoteHeader, compute_nullifier: bool, diff --git a/noir-projects/aztec-nr/aztec/src/oracle/call_private_function.nr b/noir-projects/aztec-nr/aztec/src/oracle/call_private_function.nr index 4423595f99b..46975d97bd6 100644 --- a/noir-projects/aztec-nr/aztec/src/oracle/call_private_function.nr +++ b/noir-projects/aztec-nr/aztec/src/oracle/call_private_function.nr @@ -10,7 +10,7 @@ unconstrained fn call_private_function_oracle( _is_delegate_call: bool ) -> [Field; 2] {} -unconstrained pub fn call_private_function_internal( +pub unconstrained fn call_private_function_internal( contract_address: AztecAddress, function_selector: FunctionSelector, args_hash: Field, diff --git a/noir-projects/aztec-nr/aztec/src/oracle/enqueue_public_function_call.nr b/noir-projects/aztec-nr/aztec/src/oracle/enqueue_public_function_call.nr index 623b14be232..a50b4fa55e7 100644 --- a/noir-projects/aztec-nr/aztec/src/oracle/enqueue_public_function_call.nr +++ b/noir-projects/aztec-nr/aztec/src/oracle/enqueue_public_function_call.nr @@ -10,7 +10,7 @@ unconstrained fn enqueue_public_function_call_oracle( _is_delegate_call: bool ) -> Field {} -unconstrained pub fn enqueue_public_function_call_internal( +pub unconstrained fn enqueue_public_function_call_internal( contract_address: AztecAddress, function_selector: FunctionSelector, args_hash: Field, @@ -38,7 +38,7 @@ unconstrained fn set_public_teardown_function_call_oracle( _is_delegate_call: bool ) -> Field {} -unconstrained pub fn set_public_teardown_function_call_internal( +pub unconstrained fn set_public_teardown_function_call_internal( contract_address: AztecAddress, function_selector: FunctionSelector, args_hash: Field, @@ -62,7 +62,7 @@ pub fn notify_set_min_revertible_side_effect_counter(counter: u32) { }; } -unconstrained pub fn notify_set_min_revertible_side_effect_counter_oracle_wrapper(counter: u32) { +pub unconstrained fn notify_set_min_revertible_side_effect_counter_oracle_wrapper(counter: u32) { notify_set_min_revertible_side_effect_counter_oracle(counter); } diff --git a/noir-projects/aztec-nr/aztec/src/oracle/execution.nr b/noir-projects/aztec-nr/aztec/src/oracle/execution.nr index a64606e2dbb..b96b588d150 100644 --- a/noir-projects/aztec-nr/aztec/src/oracle/execution.nr +++ b/noir-projects/aztec-nr/aztec/src/oracle/execution.nr @@ -12,18 +12,18 @@ unconstrained fn get_chain_id_oracle() -> Field {} #[oracle(getVersion)] unconstrained fn get_version_oracle() -> Field {} -unconstrained pub fn get_contract_address() -> AztecAddress { +pub unconstrained fn get_contract_address() -> AztecAddress { get_contract_address_oracle() } -unconstrained pub fn get_block_number() -> u32 { +pub unconstrained fn get_block_number() -> u32 { get_block_number_oracle() } -unconstrained pub fn get_chain_id() -> Field { +pub unconstrained fn get_chain_id() -> Field { get_chain_id_oracle() } -unconstrained pub fn get_version() -> Field { +pub unconstrained fn get_version() -> Field { get_version_oracle() } diff --git a/noir-projects/aztec-nr/aztec/src/oracle/get_contract_instance.nr b/noir-projects/aztec-nr/aztec/src/oracle/get_contract_instance.nr index 392e85c189f..0912dd49d02 100644 --- a/noir-projects/aztec-nr/aztec/src/oracle/get_contract_instance.nr +++ b/noir-projects/aztec-nr/aztec/src/oracle/get_contract_instance.nr @@ -14,7 +14,7 @@ unconstrained fn get_contract_instance_internal(address: AztecAddress) -> [Field get_contract_instance_oracle(address) } -unconstrained pub fn get_contract_instance_internal_avm(address: AztecAddress) -> [Field; CONTRACT_INSTANCE_LENGTH + 1] { +pub unconstrained fn get_contract_instance_internal_avm(address: AztecAddress) -> [Field; CONTRACT_INSTANCE_LENGTH + 1] { get_contract_instance_oracle_avm(address) } diff --git a/noir-projects/aztec-nr/aztec/src/oracle/get_l1_to_l2_membership_witness.nr b/noir-projects/aztec-nr/aztec/src/oracle/get_l1_to_l2_membership_witness.nr index b1adf7818c7..b5774779874 100644 --- a/noir-projects/aztec-nr/aztec/src/oracle/get_l1_to_l2_membership_witness.nr +++ b/noir-projects/aztec-nr/aztec/src/oracle/get_l1_to_l2_membership_witness.nr @@ -2,7 +2,7 @@ use dep::protocol_types::{address::AztecAddress, constants::L1_TO_L2_MSG_TREE_HE /// Returns the leaf index and sibling path of an entry in the L1 to L2 messaging tree, which can then be used to prove /// its existence. -unconstrained pub fn get_l1_to_l2_membership_witness( +pub unconstrained fn get_l1_to_l2_membership_witness( contract_address: AztecAddress, message_hash: Field, secret: Field 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 9aeb08f8265..c4f81e072c2 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 @@ -22,7 +22,7 @@ unconstrained fn get_membership_witness_oracle( _leaf_value: Field ) -> [Field; M] {} -unconstrained pub fn get_membership_witness( +pub unconstrained fn get_membership_witness( block_number: u32, tree_id: Field, leaf_value: Field @@ -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( +pub unconstrained fn get_note_hash_membership_witness( block_number: u32, leaf_value: Field ) -> MembershipWitness { @@ -43,7 +43,7 @@ unconstrained pub fn get_note_hash_membership_witness( // There is no `get_public_data_membership_witness` function because it doesn't make sense to be getting a membership // witness for a value in the public data tree. -unconstrained pub fn get_archive_membership_witness( +pub unconstrained fn get_archive_membership_witness( block_number: u32, leaf_value: Field ) -> MembershipWitness { diff --git a/noir-projects/aztec-nr/aztec/src/oracle/get_nullifier_membership_witness.nr b/noir-projects/aztec-nr/aztec/src/oracle/get_nullifier_membership_witness.nr index 92031f28785..c63db464eb2 100644 --- a/noir-projects/aztec-nr/aztec/src/oracle/get_nullifier_membership_witness.nr +++ b/noir-projects/aztec-nr/aztec/src/oracle/get_nullifier_membership_witness.nr @@ -35,7 +35,7 @@ unconstrained fn get_low_nullifier_membership_witness_oracle( // Nullifier here refers to the nullifier we are looking to get non-inclusion proof for (by proving that a lower // nullifier's next_value is bigger than the nullifier) -unconstrained pub fn get_low_nullifier_membership_witness(block_number: u32, nullifier: Field) -> NullifierMembershipWitness { +pub unconstrained fn get_low_nullifier_membership_witness(block_number: u32, nullifier: Field) -> NullifierMembershipWitness { let fields = get_low_nullifier_membership_witness_oracle(block_number, nullifier); NullifierMembershipWitness::deserialize(fields) } @@ -48,7 +48,7 @@ unconstrained fn get_nullifier_membership_witness_oracle( // Nullifier here refers to the nullifier we are looking to get non-inclusion proof for (by proving that a lower // nullifier's next_value is bigger than the nullifier) -unconstrained pub fn get_nullifier_membership_witness(block_number: u32, nullifier: Field) -> NullifierMembershipWitness { +pub unconstrained fn get_nullifier_membership_witness(block_number: u32, nullifier: Field) -> NullifierMembershipWitness { let fields = get_nullifier_membership_witness_oracle(block_number, nullifier); NullifierMembershipWitness::deserialize(fields) } diff --git a/noir-projects/aztec-nr/aztec/src/oracle/get_public_data_witness.nr b/noir-projects/aztec-nr/aztec/src/oracle/get_public_data_witness.nr index 1db5554f9aa..6fde781574b 100644 --- a/noir-projects/aztec-nr/aztec/src/oracle/get_public_data_witness.nr +++ b/noir-projects/aztec-nr/aztec/src/oracle/get_public_data_witness.nr @@ -15,7 +15,7 @@ unconstrained fn get_public_data_witness_oracle( _public_data_tree_index: Field ) -> [Field; PUBLIC_DATA_WITNESS] {} -unconstrained pub fn get_public_data_witness( +pub unconstrained fn get_public_data_witness( block_number: u32, public_data_tree_index: Field ) -> PublicDataWitness { diff --git a/noir-projects/aztec-nr/aztec/src/oracle/get_sibling_path.nr b/noir-projects/aztec-nr/aztec/src/oracle/get_sibling_path.nr index db421c0641a..252fbc06cd2 100644 --- a/noir-projects/aztec-nr/aztec/src/oracle/get_sibling_path.nr +++ b/noir-projects/aztec-nr/aztec/src/oracle/get_sibling_path.nr @@ -5,7 +5,7 @@ unconstrained fn get_sibling_path_oracle( _leaf_index: Field ) -> [Field; N] {} -unconstrained pub fn get_sibling_path(block_number: u32, tree_id: Field, leaf_index: Field) -> [Field; N] { +pub unconstrained fn get_sibling_path(block_number: u32, tree_id: Field, leaf_index: Field) -> [Field; N] { let value: [Field; N] = get_sibling_path_oracle(block_number, tree_id, leaf_index); value } diff --git a/noir-projects/aztec-nr/aztec/src/oracle/header.nr b/noir-projects/aztec-nr/aztec/src/oracle/header.nr index 32c570026ec..3b4ccb2ceff 100644 --- a/noir-projects/aztec-nr/aztec/src/oracle/header.nr +++ b/noir-projects/aztec-nr/aztec/src/oracle/header.nr @@ -8,7 +8,7 @@ use crate::test::helpers::test_environment::TestEnvironment; #[oracle(getHeader)] unconstrained fn get_header_at_oracle(_block_number: u32) -> [Field; HEADER_LENGTH] {} -unconstrained pub fn get_header_at_internal(block_number: u32) -> Header { +pub unconstrained fn get_header_at_internal(block_number: u32) -> Header { let header = get_header_at_oracle(block_number); Header::deserialize(header) } diff --git a/noir-projects/aztec-nr/aztec/src/oracle/key_validation_request.nr b/noir-projects/aztec-nr/aztec/src/oracle/key_validation_request.nr index 2a9eb412c9c..8db93e173b0 100644 --- a/noir-projects/aztec-nr/aztec/src/oracle/key_validation_request.nr +++ b/noir-projects/aztec-nr/aztec/src/oracle/key_validation_request.nr @@ -14,7 +14,7 @@ unconstrained fn get_key_validation_request_internal( KeyValidationRequest::deserialize(result) } -unconstrained pub fn get_key_validation_request( +pub unconstrained fn get_key_validation_request( pk_m_hash: Field, key_index: Field ) -> KeyValidationRequest { diff --git a/noir-projects/aztec-nr/aztec/src/oracle/keys.nr b/noir-projects/aztec-nr/aztec/src/oracle/keys.nr index 0326b6e6142..434635d40c8 100644 --- a/noir-projects/aztec-nr/aztec/src/oracle/keys.nr +++ b/noir-projects/aztec-nr/aztec/src/oracle/keys.nr @@ -6,7 +6,7 @@ use dep::protocol_types::{ #[oracle(getPublicKeysAndPartialAddress)] unconstrained fn get_public_keys_and_partial_address_oracle(_address: AztecAddress) -> [Field; 13] {} -unconstrained pub fn get_public_keys_and_partial_address(address: AztecAddress) -> (PublicKeys, PartialAddress) { +pub unconstrained fn get_public_keys_and_partial_address(address: AztecAddress) -> (PublicKeys, PartialAddress) { let result = get_public_keys_and_partial_address_oracle(address); let keys = PublicKeys { diff --git a/noir-projects/aztec-nr/aztec/src/oracle/logs.nr b/noir-projects/aztec-nr/aztec/src/oracle/logs.nr index af0a5d5e756..462a57d2f1a 100644 --- a/noir-projects/aztec-nr/aztec/src/oracle/logs.nr +++ b/noir-projects/aztec-nr/aztec/src/oracle/logs.nr @@ -46,7 +46,7 @@ unconstrained fn emit_unencrypted_log_private_oracle_wrapper(contract_address /// Temporary substitute for `emit_unencrypted_log_private` that is used for handling contract class registration. This /// variant returns the log hash, which would be too large to compute inside a circuit. -unconstrained pub fn emit_contract_class_unencrypted_log_private( +pub unconstrained fn emit_contract_class_unencrypted_log_private( contract_address: AztecAddress, message: [Field; N], counter: u32 diff --git a/noir-projects/aztec-nr/aztec/src/oracle/notes.nr b/noir-projects/aztec-nr/aztec/src/oracle/notes.nr index f1f08a15f17..c34f14463ce 100644 --- a/noir-projects/aztec-nr/aztec/src/oracle/notes.nr +++ b/noir-projects/aztec-nr/aztec/src/oracle/notes.nr @@ -115,7 +115,7 @@ unconstrained fn get_notes_oracle_wrapper( ) } -unconstrained pub fn get_notes( +pub unconstrained fn get_notes( storage_slot: Field, num_selects: u8, select_by_indexes: [u8; M], @@ -175,7 +175,7 @@ unconstrained pub fn get_notes bool { +pub unconstrained fn check_nullifier_exists(inner_nullifier: Field) -> bool { check_nullifier_exists_oracle(inner_nullifier) == 1 } diff --git a/noir-projects/aztec-nr/aztec/src/oracle/random.nr b/noir-projects/aztec-nr/aztec/src/oracle/random.nr index a3b901d714d..e01affe2d1a 100644 --- a/noir-projects/aztec-nr/aztec/src/oracle/random.nr +++ b/noir-projects/aztec-nr/aztec/src/oracle/random.nr @@ -2,7 +2,7 @@ /// truly random: we assume that the oracle is cooperating and returning random values. /// In some applications this behavior might not be acceptable and other techniques might be more suitable, such as /// producing pseudo-random values by hashing values outside of user control (like block hashes) or secrets. -unconstrained pub fn random() -> Field { +pub unconstrained fn random() -> Field { rand_oracle() } diff --git a/noir-projects/aztec-nr/aztec/src/oracle/returns.nr b/noir-projects/aztec-nr/aztec/src/oracle/returns.nr index 4b1dec74105..f38cbf78a11 100644 --- a/noir-projects/aztec-nr/aztec/src/oracle/returns.nr +++ b/noir-projects/aztec-nr/aztec/src/oracle/returns.nr @@ -10,11 +10,11 @@ pub fn pack_returns(returns: [Field]) { }; } -unconstrained pub fn pack_returns_oracle_wrapper(returns: [Field]) { +pub unconstrained fn pack_returns_oracle_wrapper(returns: [Field]) { let _ = pack_returns_oracle(returns); } -unconstrained pub fn unpack_returns(return_hash: Field) -> [Field; N] { +pub unconstrained fn unpack_returns(return_hash: Field) -> [Field; N] { unpack_returns_oracle(return_hash) } diff --git a/noir-projects/aztec-nr/aztec/src/oracle/storage.nr b/noir-projects/aztec-nr/aztec/src/oracle/storage.nr index 196aa5a275a..02e7a4b9258 100644 --- a/noir-projects/aztec-nr/aztec/src/oracle/storage.nr +++ b/noir-projects/aztec-nr/aztec/src/oracle/storage.nr @@ -3,7 +3,7 @@ use dep::protocol_types::{address::AztecAddress, traits::Deserialize}; #[oracle(storageRead)] unconstrained fn storage_read_oracle(address: Field, storage_slot: Field, block_number: Field, length: Field) -> [Field; N] {} -unconstrained pub fn raw_storage_read( +pub unconstrained fn raw_storage_read( address: AztecAddress, storage_slot: Field, block_number: u32 @@ -16,7 +16,7 @@ unconstrained pub fn raw_storage_read( ) } -unconstrained pub fn storage_read( +pub unconstrained fn storage_read( address: AztecAddress, storage_slot: Field, block_number: u32 diff --git a/noir-projects/aztec-nr/aztec/src/state_vars/private_immutable.nr b/noir-projects/aztec-nr/aztec/src/state_vars/private_immutable.nr index 37e23170beb..7f626fc8f00 100644 --- a/noir-projects/aztec-nr/aztec/src/state_vars/private_immutable.nr +++ b/noir-projects/aztec-nr/aztec/src/state_vars/private_immutable.nr @@ -64,7 +64,7 @@ impl PrivateImmutable { impl PrivateImmutable { // docs:start:is_initialized - unconstrained pub fn is_initialized(self) -> bool { + pub unconstrained fn is_initialized(self) -> bool { let nullifier = self.compute_initialization_nullifier(); check_nullifier_exists(nullifier) } @@ -72,7 +72,7 @@ impl PrivateImmutable { // view_note does not actually use the context, but it calls oracles that are only available in private // docs:start:view_note - unconstrained pub fn view_note(self) -> Note where Note: NoteInterface + NullifiableNote { + pub unconstrained fn view_note(self) -> Note where Note: NoteInterface + NullifiableNote { let mut options = NoteViewerOptions::new(); view_notes(self.storage_slot, options.set_limit(1)).get(0) } diff --git a/noir-projects/aztec-nr/aztec/src/state_vars/private_mutable.nr b/noir-projects/aztec-nr/aztec/src/state_vars/private_mutable.nr index 66412d6b1d4..f3a75cba580 100644 --- a/noir-projects/aztec-nr/aztec/src/state_vars/private_mutable.nr +++ b/noir-projects/aztec-nr/aztec/src/state_vars/private_mutable.nr @@ -104,13 +104,13 @@ impl PrivateMutable where Note: Not } impl PrivateMutable where Note: NoteInterface + NullifiableNote { - unconstrained pub fn is_initialized(self) -> bool { + pub unconstrained fn is_initialized(self) -> bool { let nullifier = self.compute_initialization_nullifier(); check_nullifier_exists(nullifier) } // docs:start:view_note - unconstrained pub fn view_note(self) -> Note { + pub unconstrained fn view_note(self) -> Note { let mut options = NoteViewerOptions::new(); view_notes(self.storage_slot, options.set_limit(1)).get(0) } diff --git a/noir-projects/aztec-nr/aztec/src/state_vars/private_set.nr b/noir-projects/aztec-nr/aztec/src/state_vars/private_set.nr index 282a11c58aa..f8b78647137 100644 --- a/noir-projects/aztec-nr/aztec/src/state_vars/private_set.nr +++ b/noir-projects/aztec-nr/aztec/src/state_vars/private_set.nr @@ -85,7 +85,7 @@ impl PrivateSet where Note: NoteInt impl PrivateSet where Note: NoteInterface + NullifiableNote { // docs:start:view_notes - unconstrained pub fn view_notes( + pub unconstrained fn view_notes( self, options: NoteViewerOptions ) -> BoundedVec { diff --git a/noir-projects/aztec-nr/aztec/src/state_vars/public_immutable.nr b/noir-projects/aztec-nr/aztec/src/state_vars/public_immutable.nr index 745f3d9eefc..3446d4b78f5 100644 --- a/noir-projects/aztec-nr/aztec/src/state_vars/public_immutable.nr +++ b/noir-projects/aztec-nr/aztec/src/state_vars/public_immutable.nr @@ -47,7 +47,7 @@ impl PublicImmutable where } impl PublicImmutablewhere T: Deserialize { - unconstrained pub fn read(self) -> T { + pub unconstrained fn read(self) -> T { self.context.storage_read(self.storage_slot) } } diff --git a/noir-projects/aztec-nr/aztec/src/state_vars/public_mutable.nr b/noir-projects/aztec-nr/aztec/src/state_vars/public_mutable.nr index 1e8840db7cf..d89a65567b9 100644 --- a/noir-projects/aztec-nr/aztec/src/state_vars/public_mutable.nr +++ b/noir-projects/aztec-nr/aztec/src/state_vars/public_mutable.nr @@ -39,7 +39,7 @@ impl PublicMutable where T: } impl PublicMutable where T: Deserialize { - unconstrained pub fn read(self) -> T { + pub unconstrained fn read(self) -> T { self.context.storage_read(self.storage_slot) } } diff --git a/noir-projects/aztec-nr/aztec/src/state_vars/shared_immutable.nr b/noir-projects/aztec-nr/aztec/src/state_vars/shared_immutable.nr index 2fa82e94a08..447ed264913 100644 --- a/noir-projects/aztec-nr/aztec/src/state_vars/shared_immutable.nr +++ b/noir-projects/aztec-nr/aztec/src/state_vars/shared_immutable.nr @@ -39,7 +39,7 @@ impl SharedImmutable where } impl SharedImmutable where T: Serialize + Deserialize { - unconstrained pub fn read_public(self) -> T { + pub unconstrained fn read_public(self) -> T { self.context.storage_read(self.storage_slot) } } 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 2d6bef36da2..663a4613978 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 @@ -215,7 +215,7 @@ impl SharedMutable SharedMutable where T: ToField + FromField + Eq { - unconstrained pub fn get_current_value_in_unconstrained(self) -> T { + pub unconstrained fn get_current_value_in_unconstrained(self) -> T { let block_number = self.context.block_number() as u32; self.read_value_change().get_current_at(block_number) } diff --git a/noir-projects/aztec-nr/aztec/src/test/helpers/cheatcodes.nr b/noir-projects/aztec-nr/aztec/src/test/helpers/cheatcodes.nr index f9530f9406f..96cb1d3c02e 100644 --- a/noir-projects/aztec-nr/aztec/src/test/helpers/cheatcodes.nr +++ b/noir-projects/aztec-nr/aztec/src/test/helpers/cheatcodes.nr @@ -5,23 +5,23 @@ use dep::protocol_types::{ use crate::context::inputs::PrivateContextInputs; use crate::test::helpers::utils::TestAccount; -unconstrained pub fn reset() { +pub unconstrained fn reset() { oracle_reset(); } -unconstrained pub fn set_contract_address(address: AztecAddress) { +pub unconstrained fn set_contract_address(address: AztecAddress) { oracle_set_contract_address(address); } -unconstrained pub fn advance_blocks_by(blocks: u32) { +pub unconstrained fn advance_blocks_by(blocks: u32) { oracle_advance_blocks_by(blocks); } -unconstrained pub fn get_private_context_inputs(historical_block_number: u32) -> PrivateContextInputs { +pub unconstrained fn get_private_context_inputs(historical_block_number: u32) -> PrivateContextInputs { oracle_get_private_context_inputs(historical_block_number) } -unconstrained pub fn deploy( +pub unconstrained fn deploy( path: str, name: str, initializer: str

, @@ -32,47 +32,47 @@ unconstrained pub fn deploy( ContractInstance::deserialize(instance_fields) } -unconstrained pub fn direct_storage_write(contract_address: AztecAddress, storage_slot: Field, fields: [Field; N]) { +pub unconstrained fn direct_storage_write(contract_address: AztecAddress, storage_slot: Field, fields: [Field; N]) { let _hash = direct_storage_write_oracle(contract_address, storage_slot, fields); } -unconstrained pub fn create_account() -> TestAccount { +pub unconstrained fn create_account() -> TestAccount { oracle_create_account() } -unconstrained pub fn add_account(secret: Field) -> TestAccount { +pub unconstrained fn add_account(secret: Field) -> TestAccount { oracle_add_account(secret) } -unconstrained pub fn derive_keys(secret: Field) -> PublicKeys { +pub unconstrained fn derive_keys(secret: Field) -> PublicKeys { oracle_derive_keys(secret) } -unconstrained pub fn set_msg_sender(msg_sender: AztecAddress) { +pub unconstrained fn set_msg_sender(msg_sender: AztecAddress) { oracle_set_msg_sender(msg_sender) } -unconstrained pub fn set_calldata(calldata: [Field]) { +pub unconstrained fn set_calldata(calldata: [Field]) { oracle_set_calldata(calldata) } -unconstrained pub fn get_msg_sender() -> AztecAddress { +pub unconstrained fn get_msg_sender() -> AztecAddress { oracle_get_msg_sender() } -unconstrained pub fn get_side_effects_counter() -> u32 { +pub unconstrained fn get_side_effects_counter() -> u32 { oracle_get_side_effects_counter() } -unconstrained pub fn add_authwit(address: AztecAddress, message_hash: Field) { +pub unconstrained fn add_authwit(address: AztecAddress, message_hash: Field) { orable_add_authwit(address, message_hash) } -unconstrained pub fn assert_public_call_fails(target_address: AztecAddress, function_selector: FunctionSelector, args: [Field]) { +pub unconstrained fn assert_public_call_fails(target_address: AztecAddress, function_selector: FunctionSelector, args: [Field]) { oracle_assert_public_call_fails(target_address, function_selector, args) } -unconstrained pub fn assert_private_call_fails( +pub unconstrained fn assert_private_call_fails( target_address: AztecAddress, function_selector: FunctionSelector, argsHash: Field, @@ -90,23 +90,23 @@ unconstrained pub fn assert_private_call_fails( ) } -unconstrained pub fn add_nullifiers(contractAddress: AztecAddress, nullifiers: [Field]) { +pub unconstrained fn add_nullifiers(contractAddress: AztecAddress, nullifiers: [Field]) { oracle_add_nullifiers(contractAddress, nullifiers) } -unconstrained pub fn add_note_hashes(contractAddress: AztecAddress, note_hashes: [Field]) { +pub unconstrained fn add_note_hashes(contractAddress: AztecAddress, note_hashes: [Field]) { oracle_add_note_hashes(contractAddress, note_hashes) } -unconstrained pub fn get_function_selector() -> FunctionSelector { +pub unconstrained fn get_function_selector() -> FunctionSelector { oracle_get_function_selector() } -unconstrained pub fn set_fn_selector(selector: FunctionSelector) { +pub unconstrained fn set_fn_selector(selector: FunctionSelector) { oracle_set_function_selector(selector) } -unconstrained pub fn set_is_static_call(is_static: bool) { +pub unconstrained fn set_is_static_call(is_static: bool) { oracle_set_is_static_call(is_static) } diff --git a/noir-projects/aztec-nr/aztec/src/test/helpers/test_environment.nr b/noir-projects/aztec-nr/aztec/src/test/helpers/test_environment.nr index f2d680a00a2..09b36efade8 100644 --- a/noir-projects/aztec-nr/aztec/src/test/helpers/test_environment.nr +++ b/noir-projects/aztec-nr/aztec/src/test/helpers/test_environment.nr @@ -190,7 +190,7 @@ impl TestEnvironment { /// Manually adds a note to TXE. This needs to be called if you want to work with a note in your test with the note /// not having an encrypted log emitted. TXE alternative to `PXE.addNote(...)`. - unconstrained pub fn add_note( + pub unconstrained fn add_note( _self: Self, note: &mut Note, storage_slot: Field, diff --git a/noir-projects/aztec-nr/aztec/src/test/helpers/utils.nr b/noir-projects/aztec-nr/aztec/src/test/helpers/utils.nr index 6201b36127f..dd87de5b622 100644 --- a/noir-projects/aztec-nr/aztec/src/test/helpers/utils.nr +++ b/noir-projects/aztec-nr/aztec/src/test/helpers/utils.nr @@ -12,7 +12,7 @@ use crate::test::helpers::cheatcodes; use crate::oracle::{execution::{get_block_number, get_contract_address}}; use protocol_types::constants::PUBLIC_DISPATCH_SELECTOR; -unconstrained pub fn apply_side_effects_private(contract_address: AztecAddress, public_inputs: PrivateCircuitPublicInputs) { +pub unconstrained fn apply_side_effects_private(contract_address: AztecAddress, public_inputs: PrivateCircuitPublicInputs) { let mut nullifiers = &[]; for nullifier in public_inputs.nullifiers { if nullifier.value != 0 { @@ -36,7 +36,7 @@ pub struct Deployer { } impl Deployer { - unconstrained pub fn with_private_initializer( + pub unconstrained fn with_private_initializer( self, call_interface: C ) -> ContractInstance where C: CallInterface { @@ -66,7 +66,7 @@ impl Deployer { instance } - unconstrained pub fn with_public_initializer( + pub unconstrained fn with_public_initializer( self, call_interface: C ) -> ContractInstance where C: CallInterface { @@ -102,7 +102,7 @@ impl Deployer { instance } - unconstrained pub fn without_initializer(self) -> ContractInstance { + pub unconstrained fn without_initializer(self) -> ContractInstance { cheatcodes::deploy(self.path, self.name, "", &[], self.public_keys_hash) } } diff --git a/noir-projects/aztec-nr/value-note/src/balance_utils.nr b/noir-projects/aztec-nr/value-note/src/balance_utils.nr index 42491588dbf..c5aa44fcb4a 100644 --- a/noir-projects/aztec-nr/value-note/src/balance_utils.nr +++ b/noir-projects/aztec-nr/value-note/src/balance_utils.nr @@ -1,11 +1,11 @@ use dep::aztec::{context::UnconstrainedContext, state_vars::PrivateSet, note::{note_viewer_options::NoteViewerOptions}}; use crate::value_note::ValueNote; -unconstrained pub fn get_balance(set: PrivateSet) -> Field { +pub unconstrained fn get_balance(set: PrivateSet) -> Field { get_balance_with_offset(set, 0) } -unconstrained pub fn get_balance_with_offset( +pub unconstrained fn get_balance_with_offset( set: PrivateSet, offset: u32 ) -> Field { diff --git a/noir-projects/noir-contracts/contracts/auth_contract/src/test/utils.nr b/noir-projects/noir-contracts/contracts/auth_contract/src/test/utils.nr index 5f3204cf9c3..1af722d1973 100644 --- a/noir-projects/noir-contracts/contracts/auth_contract/src/test/utils.nr +++ b/noir-projects/noir-contracts/contracts/auth_contract/src/test/utils.nr @@ -2,7 +2,7 @@ use dep::aztec::{prelude::AztecAddress, test::helpers::test_environment::TestEnv use crate::Auth; -unconstrained pub fn setup() -> (&mut TestEnvironment, AztecAddress, AztecAddress, AztecAddress, AztecAddress) { +pub unconstrained fn setup() -> (&mut TestEnvironment, AztecAddress, AztecAddress, AztecAddress, AztecAddress) { let mut env = TestEnvironment::new(); let admin = env.create_account(); diff --git a/noir-projects/noir-contracts/contracts/card_game_contract/src/cards.nr b/noir-projects/noir-contracts/contracts/card_game_contract/src/cards.nr index 93fecf7c288..9d00224d299 100644 --- a/noir-projects/noir-contracts/contracts/card_game_contract/src/cards.nr +++ b/noir-projects/noir-contracts/contracts/card_game_contract/src/cards.nr @@ -127,7 +127,7 @@ impl Deck<&mut PrivateContext> { } impl Deck { - unconstrained pub fn view_cards(self, offset: u32) -> BoundedVec { + pub unconstrained fn view_cards(self, offset: u32) -> BoundedVec { let mut options = NoteViewerOptions::new(); let notes = self.set.view_notes(options.set_offset(offset)); diff --git a/noir-projects/noir-contracts/contracts/contract_class_registerer_contract/src/capsule.nr b/noir-projects/noir-contracts/contracts/contract_class_registerer_contract/src/capsule.nr index 32d739f3946..8b5ef24bbda 100644 --- a/noir-projects/noir-contracts/contracts/contract_class_registerer_contract/src/capsule.nr +++ b/noir-projects/noir-contracts/contracts/contract_class_registerer_contract/src/capsule.nr @@ -5,7 +5,7 @@ unconstrained fn pop_capsule_oracle() -> [Field; N] {} // A capsule is a "blob" of data that is passed to the contract through an oracle. -unconstrained pub fn pop_capsule() -> [Field; N] { +pub unconstrained fn pop_capsule() -> [Field; N] { pop_capsule_oracle() } // docs:end:pop_capsule \ No newline at end of file diff --git a/noir-projects/noir-contracts/contracts/nft_contract/src/test/utils.nr b/noir-projects/noir-contracts/contracts/nft_contract/src/test/utils.nr index c1cfc8ed520..0dc1e3c73c9 100644 --- a/noir-projects/noir-contracts/contracts/nft_contract/src/test/utils.nr +++ b/noir-projects/noir-contracts/contracts/nft_contract/src/test/utils.nr @@ -7,7 +7,7 @@ use dep::aztec::{ }; use std::test::OracleMock; -unconstrained pub fn setup(with_account_contracts: bool) -> (&mut TestEnvironment, AztecAddress, AztecAddress, AztecAddress) { +pub unconstrained fn setup(with_account_contracts: bool) -> (&mut TestEnvironment, AztecAddress, AztecAddress, AztecAddress) { // Setup env, generate keys let mut env = TestEnvironment::new(); let (owner, recipient) = if with_account_contracts { @@ -35,7 +35,7 @@ unconstrained pub fn setup(with_account_contracts: bool) -> (&mut TestEnvironmen (&mut env, nft_contract_address, owner, recipient) } -unconstrained pub fn setup_and_mint(with_account_contracts: bool) -> (&mut TestEnvironment, AztecAddress, AztecAddress, AztecAddress, Field) { +pub unconstrained fn setup_and_mint(with_account_contracts: bool) -> (&mut TestEnvironment, AztecAddress, AztecAddress, AztecAddress, Field) { // Setup let (env, nft_contract_address, owner, recipient) = setup(with_account_contracts); let minted_token_id = 615; @@ -46,7 +46,7 @@ unconstrained pub fn setup_and_mint(with_account_contracts: bool) -> (&mut TestE (env, nft_contract_address, owner, recipient, minted_token_id) } -unconstrained pub fn setup_mint_and_transfer_to_private(with_account_contracts: bool) -> (&mut TestEnvironment, AztecAddress, AztecAddress, AztecAddress, Field) { +pub unconstrained fn setup_mint_and_transfer_to_private(with_account_contracts: bool) -> (&mut TestEnvironment, AztecAddress, AztecAddress, AztecAddress, Field) { let (env, nft_contract_address, owner, recipient, minted_token_id) = setup_and_mint(with_account_contracts); let note_randomness = random(); @@ -86,7 +86,7 @@ unconstrained pub fn setup_mint_and_transfer_to_private(with_account_contracts: (env, nft_contract_address, owner, recipient, minted_token_id) } -unconstrained pub fn get_nft_exists(nft_contract_address: AztecAddress, token_id: Field) -> bool { +pub unconstrained fn get_nft_exists(nft_contract_address: AztecAddress, token_id: Field) -> bool { let current_contract_address = get_contract_address(); cheatcodes::set_contract_address(nft_contract_address); let block_number = get_block_number(); @@ -99,7 +99,7 @@ unconstrained pub fn get_nft_exists(nft_contract_address: AztecAddress, token_id exists } -unconstrained pub fn assert_owns_public_nft( +pub unconstrained fn assert_owns_public_nft( env: &mut TestEnvironment, nft_contract_address: AztecAddress, owner: AztecAddress, @@ -111,7 +111,7 @@ unconstrained pub fn assert_owns_public_nft( assert(owner == obtained_owner, "Incorrect NFT owner"); } -unconstrained pub fn assert_owns_private_nft(nft_contract_address: AztecAddress, owner: AztecAddress, token_id: Field) { +pub unconstrained fn assert_owns_private_nft(nft_contract_address: AztecAddress, owner: AztecAddress, token_id: Field) { let current_contract_address = get_contract_address(); cheatcodes::set_contract_address(nft_contract_address); diff --git a/noir-projects/noir-contracts/contracts/schnorr_single_key_account_contract/src/auth_oracle.nr b/noir-projects/noir-contracts/contracts/schnorr_single_key_account_contract/src/auth_oracle.nr index 45922e2a4fc..92bf7d6ad45 100644 --- a/noir-projects/noir-contracts/contracts/schnorr_single_key_account_contract/src/auth_oracle.nr +++ b/noir-projects/noir-contracts/contracts/schnorr_single_key_account_contract/src/auth_oracle.nr @@ -21,7 +21,7 @@ impl AuthWitness { } } -unconstrained pub fn get_auth_witness(message_hash: Field) -> AuthWitness { +pub unconstrained fn get_auth_witness(message_hash: Field) -> AuthWitness { let witness: [Field; 77] = auth_witness::get_auth_witness(message_hash); AuthWitness::deserialize(witness) } diff --git a/noir-projects/noir-contracts/contracts/spam_contract/src/types/balance_set.nr b/noir-projects/noir-contracts/contracts/spam_contract/src/types/balance_set.nr index ffc233f335d..d5f5f1a82c6 100644 --- a/noir-projects/noir-contracts/contracts/spam_contract/src/types/balance_set.nr +++ b/noir-projects/noir-contracts/contracts/spam_contract/src/types/balance_set.nr @@ -19,11 +19,11 @@ impl BalanceSet { } impl BalanceSet { - unconstrained pub fn balance_of(self: Self) -> U128 where T: NoteInterface + NullifiableNote + OwnedNote { + pub unconstrained fn balance_of(self: Self) -> U128 where T: NoteInterface + NullifiableNote + OwnedNote { self.balance_of_with_offset(0) } - unconstrained pub fn balance_of_with_offset( + pub unconstrained fn balance_of_with_offset( self: Self, offset: u32 ) -> U128 where T: NoteInterface + NullifiableNote + OwnedNote { diff --git a/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/balances_map.nr b/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/balances_map.nr index 6fb9f33271b..2c7b6fbd21f 100644 --- a/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/balances_map.nr +++ b/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/types/balances_map.nr @@ -24,14 +24,14 @@ impl BalancesMap { } impl BalancesMap { - unconstrained pub fn balance_of( + pub unconstrained fn balance_of( self: Self, owner: AztecAddress ) -> U128 where T: NoteInterface + NullifiableNote + OwnedNote { self.balance_of_with_offset(owner, 0) } - unconstrained pub fn balance_of_with_offset( + pub unconstrained fn balance_of_with_offset( self: Self, owner: AztecAddress, offset: u32 diff --git a/noir-projects/noir-contracts/contracts/token_contract/src/main.nr b/noir-projects/noir-contracts/contracts/token_contract/src/main.nr index 1525d3fce63..fe056215b44 100644 --- a/noir-projects/noir-contracts/contracts/token_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/token_contract/src/main.nr @@ -590,7 +590,7 @@ contract Token { // docs:end:reduce_total_supply /// Unconstrained /// // docs:start:balance_of_private - unconstrained pub(crate) fn balance_of_private(owner: AztecAddress) -> pub Field { + pub(crate) unconstrained fn balance_of_private(owner: AztecAddress) -> pub Field { storage.balances.at(owner).balance_of().to_field() } // docs:end:balance_of_private diff --git a/noir-projects/noir-contracts/contracts/token_contract/src/test/utils.nr b/noir-projects/noir-contracts/contracts/token_contract/src/test/utils.nr index b05d4e6c00c..cbf51ff961c 100644 --- a/noir-projects/noir-contracts/contracts/token_contract/src/test/utils.nr +++ b/noir-projects/noir-contracts/contracts/token_contract/src/test/utils.nr @@ -7,7 +7,7 @@ use dep::aztec::{ use crate::{types::transparent_note::TransparentNote, Token}; -unconstrained pub fn setup(with_account_contracts: bool) -> (&mut TestEnvironment, AztecAddress, AztecAddress, AztecAddress) { +pub unconstrained fn setup(with_account_contracts: bool) -> (&mut TestEnvironment, AztecAddress, AztecAddress, AztecAddress) { // Setup env, generate keys let mut env = TestEnvironment::new(); let (owner, recipient) = if with_account_contracts { @@ -36,7 +36,7 @@ unconstrained pub fn setup(with_account_contracts: bool) -> (&mut TestEnvironmen (&mut env, token_contract_address, owner, recipient) } -unconstrained pub fn setup_and_mint(with_account_contracts: bool) -> (&mut TestEnvironment, AztecAddress, AztecAddress, AztecAddress, Field) { +pub unconstrained fn setup_and_mint(with_account_contracts: bool) -> (&mut TestEnvironment, AztecAddress, AztecAddress, AztecAddress, Field) { // Setup let (env, token_contract_address, owner, recipient) = setup(with_account_contracts); let mint_amount = 10000; @@ -69,7 +69,7 @@ unconstrained pub fn setup_and_mint(with_account_contracts: bool) -> (&mut TestE } // docs:start:txe_test_read_public -unconstrained pub fn check_public_balance( +pub unconstrained fn check_public_balance( token_contract_address: AztecAddress, address: AztecAddress, address_amount: Field @@ -87,7 +87,7 @@ unconstrained pub fn check_public_balance( // docs:end:txe_test_read_public // docs:start:txe_test_call_unconstrained -unconstrained pub fn check_private_balance( +pub unconstrained fn check_private_balance( token_contract_address: AztecAddress, address: AztecAddress, address_amount: Field diff --git a/noir-projects/noir-contracts/contracts/token_contract/src/types/balance_set.nr b/noir-projects/noir-contracts/contracts/token_contract/src/types/balance_set.nr index 876cbda476f..edc7909bd02 100644 --- a/noir-projects/noir-contracts/contracts/token_contract/src/types/balance_set.nr +++ b/noir-projects/noir-contracts/contracts/token_contract/src/types/balance_set.nr @@ -19,11 +19,11 @@ impl BalanceSet { } impl BalanceSet { - unconstrained pub fn balance_of(self: Self) -> U128 where T: NoteInterface + NullifiableNote + OwnedNote { + pub unconstrained fn balance_of(self: Self) -> U128 where T: NoteInterface + NullifiableNote + OwnedNote { self.balance_of_with_offset(0) } - unconstrained pub fn balance_of_with_offset( + pub unconstrained fn balance_of_with_offset( self: Self, offset: u32 ) -> U128 where T: NoteInterface + NullifiableNote + OwnedNote { diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/previous_kernel_validator/previous_kernel_validator_hints.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/previous_kernel_validator/previous_kernel_validator_hints.nr index 4a213530454..b106bc1a3e0 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/previous_kernel_validator/previous_kernel_validator_hints.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/previous_kernel_validator/previous_kernel_validator_hints.nr @@ -7,7 +7,7 @@ pub struct PreviousKernelValidatorHints { note_hash_indexes_for_nullifiers: [u32; MAX_NULLIFIERS_PER_TX], } -unconstrained pub fn generate_previous_kernel_validator_hints(previous_kernel: PrivateKernelCircuitPublicInputs) -> PreviousKernelValidatorHints { +pub unconstrained fn generate_previous_kernel_validator_hints(previous_kernel: PrivateKernelCircuitPublicInputs) -> PreviousKernelValidatorHints { let mut note_hash_indexes_for_nullifiers = [0; MAX_NULLIFIERS_PER_TX]; let note_hashes = previous_kernel.end.note_hashes; let nullifiers = previous_kernel.end.nullifiers; diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/private_call_data_validator/find_first_revertible_item_index.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/private_call_data_validator/find_first_revertible_item_index.nr index 2fde0424d62..9e929e53347 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/private_call_data_validator/find_first_revertible_item_index.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/private_call_data_validator/find_first_revertible_item_index.nr @@ -1,6 +1,6 @@ use dep::types::{abis::side_effect::Ordered, traits::Empty, utils::arrays::array_length}; -unconstrained pub fn find_first_revertible_item_index( +pub unconstrained fn find_first_revertible_item_index( min_revertible_side_effect_counter: u32, items: [T; N] ) -> u32 where T: Ordered + Empty + Eq { diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/private_kernel_circuit_public_inputs_composer.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/private_kernel_circuit_public_inputs_composer.nr index 8ecef1deef9..cfe96b06f3b 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/private_kernel_circuit_public_inputs_composer.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/private_kernel_circuit_public_inputs_composer.nr @@ -96,7 +96,7 @@ impl PrivateKernelCircuitPublicInputsComposer { *self } - unconstrained pub fn sort_ordered_values(&mut self) { + pub unconstrained fn sort_ordered_values(&mut self) { // Note hashes, nullifiers, note_encrypted_logs_hashes, and encrypted_logs_hashes are sorted in the reset circuit. self.public_inputs.end.l2_to_l1_msgs.storage = sort_by_counter_asc(self.public_inputs.end.l2_to_l1_msgs.storage); self.public_inputs.end.unencrypted_logs_hashes.storage = sort_by_counter_asc(self.public_inputs.end.unencrypted_logs_hashes.storage); diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/reset_output_composer.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/reset_output_composer.nr index cb10b27ed85..a143d3fc069 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/reset_output_composer.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/reset_output_composer.nr @@ -46,7 +46,7 @@ impl< NLL_RR_SETTLED, KEY_VALIDATION_REQUESTS, > { - unconstrained pub fn new( + pub unconstrained fn new( previous_kernel: PrivateKernelCircuitPublicInputs, validation_request_processor: PrivateValidationRequestProcessor, transient_data_index_hints: [TransientDataIndexHint; TRANSIENT_DATA_AMOUNT], @@ -65,7 +65,7 @@ impl< } } - unconstrained pub fn finish(self) -> PrivateKernelCircuitPublicInputs { + pub unconstrained fn finish(self) -> PrivateKernelCircuitPublicInputs { let mut output = self.previous_kernel; output.validation_requests = self.validation_request_processor.compose(); diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/reset_output_composer/reset_output_hints.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/reset_output_composer/reset_output_hints.nr index bd165f2f7b4..10dedc2a4af 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/reset_output_composer/reset_output_hints.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/reset_output_composer/reset_output_hints.nr @@ -33,7 +33,7 @@ pub struct ResetOutputHints { sorted_encrypted_log_hash_indexes: [u32; MAX_ENCRYPTED_LOGS_PER_TX], } -unconstrained pub fn generate_reset_output_hints( +pub unconstrained fn generate_reset_output_hints( previous_kernel: PrivateKernelCircuitPublicInputs, transient_data_index_hints: [TransientDataIndexHint; NUM_TRANSIENT_DATA_INDEX_HINTS] ) -> ResetOutputHints { diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/reset_output_composer/reset_output_hints/get_transient_or_propagated_note_hash_indexes_for_logs.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/reset_output_composer/reset_output_hints/get_transient_or_propagated_note_hash_indexes_for_logs.nr index a96feb849b1..fe8912df3a3 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/reset_output_composer/reset_output_hints/get_transient_or_propagated_note_hash_indexes_for_logs.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/reset_output_composer/reset_output_hints/get_transient_or_propagated_note_hash_indexes_for_logs.nr @@ -1,7 +1,7 @@ use dep::reset_kernel_lib::TransientDataIndexHint; use dep::types::{abis::{log_hash::NoteLogHash, note_hash::ScopedNoteHash}, utils::arrays::find_index_hint}; -unconstrained pub fn get_transient_or_propagated_note_hash_indexes_for_logs( +pub unconstrained fn get_transient_or_propagated_note_hash_indexes_for_logs( note_logs: [NoteLogHash; NUM_LOGS], note_hashes: [ScopedNoteHash; NUM_NOTE_HASHES], expected_note_hashes: [ScopedNoteHash; NUM_NOTE_HASHES], diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/reset_output_composer/reset_output_hints/squash_transient_data.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/reset_output_composer/reset_output_hints/squash_transient_data.nr index b2bdc3b9312..e076a27572b 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/reset_output_composer/reset_output_hints/squash_transient_data.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/reset_output_composer/reset_output_hints/squash_transient_data.nr @@ -1,7 +1,7 @@ use dep::reset_kernel_lib::TransientDataIndexHint; use dep::types::abis::{note_hash::ScopedNoteHash, nullifier::ScopedNullifier, log_hash::NoteLogHash}; -unconstrained pub fn squash_transient_data( +pub unconstrained fn squash_transient_data( note_hashes: [ScopedNoteHash; M], nullifiers: [ScopedNullifier; N], logs: [NoteLogHash; P], diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_output_composer.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_output_composer.nr index 818ea635972..fea9bb3c97d 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_output_composer.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_output_composer.nr @@ -19,14 +19,14 @@ pub struct TailOutputComposer { } impl TailOutputComposer { - unconstrained pub fn new(previous_kernel: PrivateKernelCircuitPublicInputs) -> Self { + pub unconstrained fn new(previous_kernel: PrivateKernelCircuitPublicInputs) -> Self { let mut output_composer = PrivateKernelCircuitPublicInputsComposer::new_from_previous_kernel(previous_kernel); output_composer.sort_ordered_values(); TailOutputComposer { output_composer } } - unconstrained pub fn finish(self) -> KernelCircuitPublicInputs { + pub unconstrained fn finish(self) -> KernelCircuitPublicInputs { let source = self.output_composer.finish(); let mut output = KernelCircuitPublicInputs::empty(); output.rollup_validation_requests = source.validation_requests.for_rollup; diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_output_validator/tail_output_hints.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_output_validator/tail_output_hints.nr index 5a6325c5b69..beecc52bc9f 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_output_validator/tail_output_hints.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_output_validator/tail_output_hints.nr @@ -12,7 +12,7 @@ pub struct TailOutputHints { sorted_unencrypted_log_hash_hints: [OrderHint; MAX_UNENCRYPTED_LOGS_PER_TX], } -unconstrained pub fn generate_tail_output_hints(previous_kernel: PrivateKernelCircuitPublicInputs) -> TailOutputHints { +pub unconstrained fn generate_tail_output_hints(previous_kernel: PrivateKernelCircuitPublicInputs) -> TailOutputHints { // l2_to_l1_msgs let sorted_l2_to_l1_msg_hints = get_order_hints_asc(previous_kernel.end.l2_to_l1_msgs); diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_to_public_output_composer.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_to_public_output_composer.nr index 0d1bc18226a..10c5fa7688d 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_to_public_output_composer.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_to_public_output_composer.nr @@ -18,14 +18,14 @@ pub struct TailToPublicOutputComposer { } impl TailToPublicOutputComposer { - unconstrained pub fn new(previous_kernel: PrivateKernelCircuitPublicInputs) -> Self { + pub unconstrained fn new(previous_kernel: PrivateKernelCircuitPublicInputs) -> Self { let mut output_composer = PrivateKernelCircuitPublicInputsComposer::new_from_previous_kernel(previous_kernel); output_composer.sort_ordered_values(); TailToPublicOutputComposer { output_composer } } - unconstrained pub fn finish(self) -> PublicKernelCircuitPublicInputs { + pub unconstrained fn finish(self) -> PublicKernelCircuitPublicInputs { let source = self.output_composer.public_inputs; let mut validation_requests = PublicValidationRequests::empty(); diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_to_public_output_composer/split_to_public.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_to_public_output_composer/split_to_public.nr index 79bc70f7ad1..0e69b2cbf89 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_to_public_output_composer/split_to_public.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_to_public_output_composer/split_to_public.nr @@ -6,7 +6,7 @@ use dep::types::abis::{ } }; -unconstrained pub fn split_to_public( +pub unconstrained fn split_to_public( data: PrivateAccumulatedDataBuilder, min_revertible_side_effect_counter: u32 ) -> (PublicAccumulatedData, PublicAccumulatedData) { diff --git a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_to_public_output_validator/tail_to_public_output_hints.nr b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_to_public_output_validator/tail_to_public_output_hints.nr index 3c829e4b559..3086bbb6cbd 100644 --- a/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_to_public_output_validator/tail_to_public_output_hints.nr +++ b/noir-projects/noir-protocol-circuits/crates/private-kernel-lib/src/components/tail_to_public_output_validator/tail_to_public_output_hints.nr @@ -13,7 +13,7 @@ pub struct TailToPublicOutputHints { sorted_public_call_request_hints: SplitOrderHints, } -unconstrained pub fn generate_tail_to_public_output_hints(previous_kernel: PrivateKernelCircuitPublicInputs) -> TailToPublicOutputHints { +pub unconstrained fn generate_tail_to_public_output_hints(previous_kernel: PrivateKernelCircuitPublicInputs) -> TailToPublicOutputHints { let split_counter = previous_kernel.min_revertible_side_effect_counter; // l2_to_l1_msgss diff --git a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_tail_output_composer.nr b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_tail_output_composer.nr index e3756c8304d..d7898c51a26 100644 --- a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_tail_output_composer.nr +++ b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_tail_output_composer.nr @@ -19,7 +19,7 @@ pub struct PublicTailOutputComposer { } impl PublicTailOutputComposer { - unconstrained pub fn new( + pub unconstrained fn new( previous_kernel: PublicKernelCircuitPublicInputs, start_state: PartialStateReference, public_data_leaf_hints: [PublicDataLeafHint; NUM_PUBLIC_DATA_LEAVES] @@ -27,7 +27,7 @@ impl PublicTailOutputComposer (KernelCircuitPublicInputs, OutputHints) { + pub unconstrained fn finish(self) -> (KernelCircuitPublicInputs, OutputHints) { let output_hints = generate_output_hints(self.previous_kernel, self.public_data_leaf_hints); let end = combine_data( diff --git a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_tail_output_composer/combine_data.nr b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_tail_output_composer/combine_data.nr index e8e93c8a02d..896616409ab 100644 --- a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_tail_output_composer/combine_data.nr +++ b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_tail_output_composer/combine_data.nr @@ -7,7 +7,7 @@ use dep::types::{ utils::arrays::{array_merge, dedupe_array, sort_by_counter_asc} }; -unconstrained pub fn combine_data( +pub unconstrained fn combine_data( non_revertible: PublicAccumulatedData, revertible: PublicAccumulatedData, output_hints: OutputHints diff --git a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_tail_output_composer/generate_output_hints.nr b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_tail_output_composer/generate_output_hints.nr index f73a491339b..7de87149d65 100644 --- a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_tail_output_composer/generate_output_hints.nr +++ b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_tail_output_composer/generate_output_hints.nr @@ -48,7 +48,7 @@ pub struct OutputHints { public_data_linked_index_hints: [LinkedIndexHint; MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX], } -unconstrained pub fn generate_output_hints( +pub unconstrained fn generate_output_hints( previous_kernel: PublicKernelCircuitPublicInputs, public_data_leaf_hints: [PublicDataLeafHint; NUM_PUBLIC_DATA_LEAVES] ) -> OutputHints { diff --git a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_tail_output_composer/generate_overridable_public_data_writes.nr b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_tail_output_composer/generate_overridable_public_data_writes.nr index 143214a6b22..d49503dd011 100644 --- a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_tail_output_composer/generate_overridable_public_data_writes.nr +++ b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_tail_output_composer/generate_overridable_public_data_writes.nr @@ -14,7 +14,7 @@ impl Empty for LinkedIndexHint { } } -unconstrained pub fn generate_overridable_public_data_writes( +pub unconstrained fn generate_overridable_public_data_writes( public_data_writes: [PublicDataUpdateRequest; NUM_WRITES], public_data_leaves: [OverridablePublicDataTreeLeaf; NUM_LEAVES] ) -> ([OverridablePublicDataWrite; NUM_WRITES], [LinkedIndexHint; NUM_WRITES]) { diff --git a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_tail_output_composer/generate_public_data_leaves.nr b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_tail_output_composer/generate_public_data_leaves.nr index d3eeb603d92..2bb554c27d9 100644 --- a/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_tail_output_composer/generate_public_data_leaves.nr +++ b/noir-projects/noir-protocol-circuits/crates/public-kernel-lib/src/components/public_tail_output_composer/generate_public_data_leaves.nr @@ -34,7 +34,7 @@ fn compare_by_index(a: SlotIndex, b: SlotIndex) -> bool { (a.slot != 0) & ((b.slot == 0) | (a.index < b.index)) } -unconstrained pub fn generate_public_data_leaves( +pub unconstrained fn generate_public_data_leaves( reads: [PublicDataRead; NUM_READS], writes: [PublicDataUpdateRequest; NUM_WRITES], hints: [PublicDataLeafHint; NUM_HINTS] diff --git a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/note_hash_read_request_reset.nr b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/note_hash_read_request_reset.nr index 131470c6431..0dba5d72b02 100644 --- a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/note_hash_read_request_reset.nr +++ b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/note_hash_read_request_reset.nr @@ -150,7 +150,7 @@ mod tests { (hints, tree_root) } - unconstrained pub fn get_unverified_read_requests(self) -> [ScopedReadRequest; READ_REQUEST_LEN] { + pub unconstrained fn get_unverified_read_requests(self) -> [ScopedReadRequest; READ_REQUEST_LEN] { get_unverified_read_requests(self.read_requests, self.read_request_statuses) } diff --git a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/nullifier_read_request_reset.nr b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/nullifier_read_request_reset.nr index 61648d95a5c..7c93d97b742 100644 --- a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/nullifier_read_request_reset.nr +++ b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/nullifier_read_request_reset.nr @@ -142,7 +142,7 @@ mod tests { (hints, tree_root) } - unconstrained pub fn get_unverified_read_requests(self) -> [ScopedReadRequest; READ_REQUEST_LEN] { + pub unconstrained fn get_unverified_read_requests(self) -> [ScopedReadRequest; READ_REQUEST_LEN] { get_unverified_read_requests(self.read_requests, self.read_request_statuses) } diff --git a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/private_validation_request_processor.nr b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/private_validation_request_processor.nr index be1925fd774..7674cb15a83 100644 --- a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/private_validation_request_processor.nr +++ b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/private_validation_request_processor.nr @@ -28,7 +28,7 @@ impl< let NLL_RR_SETTLED: u32, let KEY_VALIDATION_REQUESTS: u32 > PrivateValidationRequestProcessor { - unconstrained pub fn compose(self) -> PrivateValidationRequests { + pub unconstrained fn compose(self) -> PrivateValidationRequests { let note_hash_read_requests = get_unverified_read_requests( self.validation_requests.note_hash_read_requests, self.note_hash_read_request_hints.read_request_statuses diff --git a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/public_data_read_request_hints.nr b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/public_data_read_request_hints.nr index 962e8ce3e0b..817a577127a 100644 --- a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/public_data_read_request_hints.nr +++ b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/public_data_read_request_hints.nr @@ -10,7 +10,7 @@ pub struct PublicDataReadRequestHints { leaf_data_read_hints: [ReadIndexHint; NUM_READS], } -unconstrained pub fn build_public_data_read_request_hints( +pub unconstrained fn build_public_data_read_request_hints( reads: [PublicDataRead; NUM_READS], writes: [OverridablePublicDataWrite; NUM_WRITES], leaf_data: [OverridablePublicDataTreeLeaf; NUM_LEAVES] diff --git a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/reset/key_validation_hint.nr b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/reset/key_validation_hint.nr index 06130872323..0ead614801d 100644 --- a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/reset/key_validation_hint.nr +++ b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/reset/key_validation_hint.nr @@ -88,7 +88,7 @@ pub fn verify_reset_key_validation_requests( +pub unconstrained fn get_unverified_key_validation_requests( key_validation_requests: [ScopedKeyValidationRequestAndGenerator; REQUEST_LEN], hints: [KeyValidationHint; NUM_HINTS] ) -> [ScopedKeyValidationRequestAndGenerator; REQUEST_LEN] { diff --git a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/reset/read_request.nr b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/reset/read_request.nr index 788ff80b66e..157615b076f 100644 --- a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/reset/read_request.nr +++ b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/reset/read_request.nr @@ -176,7 +176,7 @@ pub fn verify_reset_read_requests< ); } -unconstrained pub fn get_unverified_read_requests( +pub unconstrained fn get_unverified_read_requests( read_requests: [ScopedReadRequest; READ_REQUEST_LEN], read_request_statuses: [ReadRequestStatus; READ_REQUEST_LEN] ) -> [ScopedReadRequest; READ_REQUEST_LEN] { @@ -362,7 +362,7 @@ mod tests { TestSettledReadHint::nada(self.read_requests.len()) } - unconstrained pub fn get_unverified_read_requests(self) -> [ScopedReadRequest; READ_REQUEST_LEN] { + pub unconstrained fn get_unverified_read_requests(self) -> [ScopedReadRequest; READ_REQUEST_LEN] { get_unverified_read_requests(self.read_requests, self.read_request_statuses) } diff --git a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/reset/transient_data.nr b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/reset/transient_data.nr index c02447fc6f8..fad2acf2962 100644 --- a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/reset/transient_data.nr +++ b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/reset/transient_data.nr @@ -124,7 +124,7 @@ pub fn verify_squashed_transient_data_with_hint_indexes< } } -unconstrained pub fn get_squashed_note_hash_hints(transient_data_index_hints: [TransientDataIndexHint; NUM_INDEX_HINTS]) -> [bool; NUM_NOTE_HASHES] { +pub unconstrained fn get_squashed_note_hash_hints(transient_data_index_hints: [TransientDataIndexHint; NUM_INDEX_HINTS]) -> [bool; NUM_NOTE_HASHES] { let mut hints = [false; NUM_NOTE_HASHES]; for i in 0..transient_data_index_hints.len() { let note_hash_index = transient_data_index_hints[i].note_hash_index; @@ -135,7 +135,7 @@ unconstrained pub fn get_squashed_note_hash_hints(transient_data_index_hints: [TransientDataIndexHint; NUM_INDEX_HINTS]) -> [bool; NUM_NULLIFIERS] { +pub unconstrained fn get_squashed_nullifier_hints(transient_data_index_hints: [TransientDataIndexHint; NUM_INDEX_HINTS]) -> [bool; NUM_NULLIFIERS] { let mut hints = [false; NUM_NULLIFIERS]; for i in 0..transient_data_index_hints.len() { let nullifier_index = transient_data_index_hints[i].nullifier_index; diff --git a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/tests/note_hash_read_request_hints_builder.nr b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/tests/note_hash_read_request_hints_builder.nr index 7c09a56a388..f819601eb69 100644 --- a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/tests/note_hash_read_request_hints_builder.nr +++ b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/tests/note_hash_read_request_hints_builder.nr @@ -22,7 +22,7 @@ impl NoteHashReadRequest } } - unconstrained pub fn to_hints(self) -> NoteHashReadRequestHints { + pub unconstrained fn to_hints(self) -> NoteHashReadRequestHints { NoteHashReadRequestHints { read_request_statuses: self.read_request_statuses, pending_read_hints: self.pending_read_hints.storage, diff --git a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/tests/nullifier_non_existent_read_request_hints_builder.nr b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/tests/nullifier_non_existent_read_request_hints_builder.nr index 25c6fd0f1b2..22f7330f903 100644 --- a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/tests/nullifier_non_existent_read_request_hints_builder.nr +++ b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/tests/nullifier_non_existent_read_request_hints_builder.nr @@ -49,7 +49,7 @@ impl NullifierNonExistentReadRequestHintsBuilder { self.non_membership_hints.push(hint); } - unconstrained pub fn to_hints(self) -> NullifierNonExistentReadRequestHints { + pub unconstrained fn to_hints(self) -> NullifierNonExistentReadRequestHints { let sorted_result = get_sorted_result( self.pending_nullifiers, |a: Nullifier, b: Nullifier| (b.value == 0) | ((a.value != 0) & a.value.lt(b.value)) diff --git a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/tests/nullifier_read_request_hints_builder.nr b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/tests/nullifier_read_request_hints_builder.nr index 4b9462e01ce..0a24622d9eb 100644 --- a/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/tests/nullifier_read_request_hints_builder.nr +++ b/noir-projects/noir-protocol-circuits/crates/reset-kernel-lib/src/tests/nullifier_read_request_hints_builder.nr @@ -22,7 +22,7 @@ impl NullifierReadReques } } - unconstrained pub fn to_hints(self) -> NullifierReadRequestHints { + pub unconstrained fn to_hints(self) -> NullifierReadRequestHints { NullifierReadRequestHints { read_request_statuses: self.read_request_statuses, pending_read_hints: self.pending_read_hints.storage, diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/debug_log.nr b/noir-projects/noir-protocol-circuits/crates/types/src/debug_log.nr index e5045456b65..8bf831ced3f 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/debug_log.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/debug_log.nr @@ -17,7 +17,7 @@ pub fn debug_log_format(msg: str, args: [Field; N]) { }; } -unconstrained pub fn debug_log_oracle_wrapper(msg: str, args: [Field; N]) { +pub unconstrained fn debug_log_oracle_wrapper(msg: str, args: [Field; N]) { debug_log_oracle(msg, args.as_slice()); } diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays.nr b/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays.nr index 718f83ef761..f8ee3ffd248 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays.nr @@ -51,7 +51,7 @@ pub fn array_to_bounded_vec(array: [T; N]) -> BoundedVec wh BoundedVec { storage: array, len } } -unconstrained pub fn find_index_hint(array: [T; N], find: fn[Env](T) -> bool) -> u32 { +pub unconstrained fn find_index_hint(array: [T; N], find: fn[Env](T) -> bool) -> u32 { let mut index = N; for i in 0..N { if (index == N) & find(array[i]) { diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/assert_combined_array.nr b/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/assert_combined_array.nr index 209a7a749c9..99889e586bd 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/assert_combined_array.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/assert_combined_array.nr @@ -18,7 +18,7 @@ pub fn assert_combined_array( ) } -unconstrained pub fn combine_arrays( +pub unconstrained fn combine_arrays( original_array_lt: [T; N], original_array_gte: [T; N] ) -> [T; N] where T: Empty + Eq { diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/assert_combined_sorted_transformed_value_array/get_combined_order_hints.nr b/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/assert_combined_sorted_transformed_value_array/get_combined_order_hints.nr index ffaf1b6ed2e..3d0899b2c59 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/assert_combined_sorted_transformed_value_array/get_combined_order_hints.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/assert_combined_sorted_transformed_value_array/get_combined_order_hints.nr @@ -20,7 +20,7 @@ impl Eq for CombinedOrderHint { } } -unconstrained pub fn count_private_items(array: [T; N]) -> u32 where T: Ordered + Empty + Eq { +pub unconstrained fn count_private_items(array: [T; N]) -> u32 where T: Ordered + Empty + Eq { let mut length = 0; for item in array { if !is_empty(item) & (item.counter() == 0) { @@ -30,7 +30,7 @@ unconstrained pub fn count_private_items(array: [T; N]) -> u32 wh length } -unconstrained pub fn get_combined_order_hints_asc( +pub unconstrained fn get_combined_order_hints_asc( array_lt: [T; N], array_gte: [T; N] ) -> [CombinedOrderHint; N] where T: Ordered + Eq + Empty { diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/assert_combined_transformed_array.nr b/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/assert_combined_transformed_array.nr index 85489ae3f18..d621a1f0546 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/assert_combined_transformed_array.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/assert_combined_transformed_array.nr @@ -25,7 +25,7 @@ pub fn assert_combined_transformed_array( } } -unconstrained pub fn combine_and_transform_arrays( +pub unconstrained fn combine_and_transform_arrays( original_array_lt: [T; N], original_array_gte: [T; N], transform: fn[Env](T) -> S diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/assert_deduped_array.nr b/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/assert_deduped_array.nr index 078d9e9985f..2afcd75b7c3 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/assert_deduped_array.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/assert_deduped_array.nr @@ -22,7 +22,7 @@ pub fn assert_deduped_array( } } -unconstrained pub fn dedupe_array(original_array: [S; N]) -> [T; N] where S: Overridable + Inner { +pub unconstrained fn dedupe_array(original_array: [S; N]) -> [T; N] where S: Overridable + Inner { let mut deduped = BoundedVec::new(); for i in 0..original_array.len() { let original = original_array[i]; diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/assert_exposed_sorted_transformed_value_array/get_order_hints.nr b/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/assert_exposed_sorted_transformed_value_array/get_order_hints.nr index 55ff2c86848..3122a29fd58 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/assert_exposed_sorted_transformed_value_array/get_order_hints.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/assert_exposed_sorted_transformed_value_array/get_order_hints.nr @@ -23,7 +23,7 @@ impl Eq for OrderHint { } } -unconstrained pub fn get_order_hints( +pub unconstrained fn get_order_hints( array: [T; N], ordering: fn(T, T) -> bool ) -> [OrderHint; N] where T: Ordered { @@ -40,11 +40,11 @@ unconstrained pub fn get_order_hints( hints } -unconstrained pub fn get_order_hints_asc(array: [T; N]) -> [OrderHint; N] where T: Ordered + Eq + Empty { +pub unconstrained fn get_order_hints_asc(array: [T; N]) -> [OrderHint; N] where T: Ordered + Eq + Empty { get_order_hints(array, compare_by_counter_empty_padded_asc) } -unconstrained pub fn get_order_hints_desc(array: [T; N]) -> [OrderHint; N] where T: Ordered + Eq + Empty { +pub unconstrained fn get_order_hints_desc(array: [T; N]) -> [OrderHint; N] where T: Ordered + Eq + Empty { get_order_hints(array, compare_by_counter_empty_padded_desc) } diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/assert_split_sorted_transformed_value_arrays/get_split_order_hints.nr b/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/assert_split_sorted_transformed_value_arrays/get_split_order_hints.nr index 1b51607e7c9..5a2b95333f4 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/assert_split_sorted_transformed_value_arrays/get_split_order_hints.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/assert_split_sorted_transformed_value_arrays/get_split_order_hints.nr @@ -67,14 +67,14 @@ unconstrained fn get_split_order_hints( SplitOrderHints { sorted_counters_lt, sorted_counters_gte, sorted_indexes } } -unconstrained pub fn get_split_order_hints_asc( +pub unconstrained fn get_split_order_hints_asc( array: [T; N], split_counter: u32 ) -> SplitOrderHints where T: Ordered + Eq + Empty { get_split_order_hints(array, split_counter, true) } -unconstrained pub fn get_split_order_hints_desc( +pub unconstrained fn get_split_order_hints_desc( array: [T; N], split_counter: u32 ) -> SplitOrderHints where T: Ordered + Eq + Empty { diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/get_sorted_result.nr b/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/get_sorted_result.nr index 3c51059a76b..928f4520833 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/get_sorted_result.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/get_sorted_result.nr @@ -6,7 +6,7 @@ pub struct SortedResult { original_index_hints: [u32; N], } -unconstrained pub fn get_sorted_result( +pub unconstrained fn get_sorted_result( values: [T; N], ordering: fn(T, T) -> bool ) -> SortedResult { diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/get_sorted_tuple.nr b/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/get_sorted_tuple.nr index bc57dfcd30a..4dce601f563 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/get_sorted_tuple.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/get_sorted_tuple.nr @@ -5,7 +5,7 @@ pub struct SortedTuple { original_index: u32, } -unconstrained pub fn get_sorted_tuple(array: [T; N], ordering: fn[Env](T, T) -> bool) -> [SortedTuple; N] { +pub unconstrained fn get_sorted_tuple(array: [T; N], ordering: fn[Env](T, T) -> bool) -> [SortedTuple; N] { let mut tuples = [SortedTuple { elem: array[0], original_index: 0 }; N]; for i in 0..N { tuples[i] = SortedTuple { diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/sort_by.nr b/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/sort_by.nr index 22e31f626e8..99f2b25d1af 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/sort_by.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/sort_by.nr @@ -3,7 +3,7 @@ use crate::utils::arrays::find_index_hint; // Copied from the stdlib Array.sort_via. // But this one doesn't use `ordering` to check that the array is sorted. // This is to allow preserving the order of equal values. -unconstrained pub fn sort_by(array: [T; N], ordering: fn[Env](T, T) -> bool) -> [T; N] { +pub unconstrained fn sort_by(array: [T; N], ordering: fn[Env](T, T) -> bool) -> [T; N] { let mut result = array; let sorted_index = unsafe { get_sorting_index(array, ordering) diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/sort_by_counter.nr b/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/sort_by_counter.nr index dd07448eaee..edb5279f50e 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/sort_by_counter.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/utils/arrays/sort_by_counter.nr @@ -8,11 +8,11 @@ pub fn compare_by_counter_empty_padded_desc(a: T, b: T) -> bool where T: Orde !is_empty(a) & (is_empty(b) | (a.counter() >= b.counter())) } -unconstrained pub fn sort_by_counter_asc(array: [T; N]) -> [T; N] where T: Ordered + Empty + Eq { +pub unconstrained fn sort_by_counter_asc(array: [T; N]) -> [T; N] where T: Ordered + Empty + Eq { sort_by(array, compare_by_counter_empty_padded_asc) } -unconstrained pub fn sort_by_counter_desc(array: [T; N]) -> [T; N] where T: Ordered + Empty + Eq { +pub unconstrained fn sort_by_counter_desc(array: [T; N]) -> [T; N] where T: Ordered + Empty + Eq { sort_by(array, compare_by_counter_empty_padded_desc) } diff --git a/noir/noir-repo/compiler/noirc_frontend/src/parser/parser/function.rs b/noir/noir-repo/compiler/noirc_frontend/src/parser/parser/function.rs index 6d1fc611767..acec7942e24 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/parser/parser/function.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/parser/parser/function.rs @@ -285,7 +285,7 @@ fn empty_body() -> BlockExpression { #[cfg(test)] mod tests { use crate::{ - ast::{NoirFunction, UnresolvedTypeData, Visibility}, + ast::{ItemVisibility, NoirFunction, UnresolvedTypeData, Visibility}, parser::{ parser::{ parse_program, @@ -480,4 +480,13 @@ mod tests { let error = get_single_error(&errors, span); assert_eq!(error.to_string(), "Expected a type but found ,"); } + + #[test] + fn parse_function_with_unconstrained_after_visibility() { + let src = "pub unconstrained fn foo() {}"; + let noir_function = parse_function_no_error(src); + assert_eq!("foo", noir_function.def.name.to_string()); + assert!(noir_function.def.is_unconstrained); + assert_eq!(noir_function.def.visibility, ItemVisibility::Public); + } } diff --git a/noir/noir-repo/compiler/noirc_frontend/src/parser/parser/modifiers.rs b/noir/noir-repo/compiler/noirc_frontend/src/parser/parser/modifiers.rs index d3bf692ee53..a668d3bae6a 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/parser/parser/modifiers.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/parser/parser/modifiers.rs @@ -14,7 +14,10 @@ pub(crate) struct Modifiers { } impl<'a> Parser<'a> { - /// Modifiers = 'unconstrained'? ItemVisibility 'comptime'? 'mut'? + /// Modifiers = ItemVisibility 'unconstrained'? 'comptime'? 'mut'? + /// + /// NOTE: we also allow `unconstrained` before the visibility for backwards compatibility. + /// The formatter will put it after the visibility. pub(crate) fn parse_modifiers(&mut self, allow_mutable: bool) -> Modifiers { let unconstrained = if self.eat_keyword(Keyword::Unconstrained) { Some(self.previous_token_span) @@ -26,6 +29,16 @@ impl<'a> Parser<'a> { let visibility = self.parse_item_visibility(); let visibility_span = self.span_since(start_span); + let unconstrained = if unconstrained.is_none() { + if self.eat_keyword(Keyword::Unconstrained) { + Some(self.previous_token_span) + } else { + None + } + } else { + unconstrained + }; + let comptime = if self.eat_keyword(Keyword::Comptime) { Some(self.previous_token_span) } else { None }; let mutable = if allow_mutable && self.eat_keyword(Keyword::Mut) { diff --git a/noir/noir-repo/noir_stdlib/src/array/quicksort.nr b/noir/noir-repo/noir_stdlib/src/array/quicksort.nr index 6a54ed246f5..8563a5d75bd 100644 --- a/noir/noir-repo/noir_stdlib/src/array/quicksort.nr +++ b/noir/noir-repo/noir_stdlib/src/array/quicksort.nr @@ -30,7 +30,7 @@ unconstrained fn quicksort_recursive(arr: &mut [T; N], low: } } -unconstrained pub(crate) fn quicksort(_arr: [T; N], sortfn: fn[Env](T, T) -> bool) -> [T; N] { +pub(crate) unconstrained fn quicksort(_arr: [T; N], sortfn: fn[Env](T, T) -> bool) -> [T; N] { let mut arr: [T; N] = _arr; if arr.len() <= 1 {} else { quicksort_recursive(&mut arr, 0, arr.len() - 1, sortfn); diff --git a/noir/noir-repo/noir_stdlib/src/collections/umap.nr b/noir/noir-repo/noir_stdlib/src/collections/umap.nr index 9d23e216731..33010e75560 100644 --- a/noir/noir-repo/noir_stdlib/src/collections/umap.nr +++ b/noir/noir-repo/noir_stdlib/src/collections/umap.nr @@ -21,7 +21,7 @@ pub struct UHashMap { } // Data unit in the UHashMap table. -// In case Noir adds support for enums in the future, this +// In case Noir adds support for enums in the future, this // should be refactored to have three states: // 1. (key, value) // 2. (empty) @@ -60,7 +60,7 @@ impl Slot { } // Shall not override `_key_value` with Option::none(), - // because we must be able to differentiate empty + // because we must be able to differentiate empty // and deleted slots for lookup. fn mark_deleted(&mut self) { self._is_deleted = true; @@ -68,7 +68,7 @@ impl Slot { } // While conducting lookup, we iterate attempt from 0 to N - 1 due to heuristic, -// that if we have went that far without finding desired, +// that if we have went that far without finding desired, // it is very unlikely to be after - performance will be heavily degraded. impl UHashMap { // Creates a new instance of UHashMap with specified BuildHasher. @@ -188,7 +188,7 @@ impl UHashMap { // For each key-value entry applies mutator function. // docs:start:iter_mut - unconstrained pub fn iter_mut( + pub unconstrained fn iter_mut( &mut self, f: fn(K, V) -> (K, V) ) @@ -210,10 +210,10 @@ impl UHashMap { // For each key applies mutator function. // docs:start:iter_keys_mut - unconstrained pub fn iter_keys_mut( + pub unconstrained fn iter_keys_mut( &mut self, f: fn(K) -> K - ) + ) where K: Eq + Hash, B: BuildHasher, @@ -277,7 +277,7 @@ impl UHashMap { // Get the value by key. If it does not exist, returns none(). // docs:start:get - unconstrained pub fn get( + pub unconstrained fn get( self, key: K ) -> Option @@ -307,9 +307,9 @@ impl UHashMap { result } - // Insert key-value entry. In case key was already present, value is overridden. + // Insert key-value entry. In case key was already present, value is overridden. // docs:start:insert - unconstrained pub fn insert( + pub unconstrained fn insert( &mut self, key: K, value: V @@ -362,7 +362,7 @@ impl UHashMap { // Removes a key-value entry. If key is not present, UHashMap remains unchanged. // docs:start:remove - unconstrained pub fn remove( + pub unconstrained fn remove( &mut self, key: K ) @@ -407,14 +407,14 @@ impl UHashMap { // Probing scheme: quadratic function. // We use 0.5 constant near variadic attempt and attempt^2 monomials. // This ensures good uniformity of distribution for table sizes - // equal to prime numbers or powers of two. + // equal to prime numbers or powers of two. fn quadratic_probe(self: Self, hash: u32, attempt: u32) -> u32 { (hash + (attempt + attempt * attempt) / 2) % self._table.len() } } -// Equality class on UHashMap has to test that they have -// equal sets of key-value entries, +// Equality class on UHashMap has to test that they have +// equal sets of key-value entries, // thus one is a subset of the other and vice versa. // docs:start:eq impl Eq for UHashMap diff --git a/noir/noir-repo/noir_stdlib/src/field/bn254.nr b/noir/noir-repo/noir_stdlib/src/field/bn254.nr index 99b73d86c05..9f580fe8a5c 100644 --- a/noir/noir-repo/noir_stdlib/src/field/bn254.nr +++ b/noir/noir-repo/noir_stdlib/src/field/bn254.nr @@ -23,7 +23,7 @@ fn compute_decomposition(x: Field) -> (Field, Field) { (low, high) } -unconstrained pub(crate) fn decompose_hint(x: Field) -> (Field, Field) { +pub(crate) unconstrained fn decompose_hint(x: Field) -> (Field, Field) { compute_decomposition(x) } diff --git a/noir/noir-repo/noir_stdlib/src/test.nr b/noir/noir-repo/noir_stdlib/src/test.nr index e906ad54d55..4d6954913d1 100644 --- a/noir/noir-repo/noir_stdlib/src/test.nr +++ b/noir/noir-repo/noir_stdlib/src/test.nr @@ -21,30 +21,30 @@ pub struct OracleMock { } impl OracleMock { - unconstrained pub fn mock(name: str) -> Self { + pub unconstrained fn mock(name: str) -> Self { Self { id: create_mock_oracle(name) } } - unconstrained pub fn with_params

(self, params: P) -> Self { + pub unconstrained fn with_params

(self, params: P) -> Self { set_mock_params_oracle(self.id, params); self } - unconstrained pub fn get_last_params

(self) -> P { + pub unconstrained fn get_last_params

(self) -> P { get_mock_last_params_oracle(self.id) } - unconstrained pub fn returns(self, returns: R) -> Self { + pub unconstrained fn returns(self, returns: R) -> Self { set_mock_returns_oracle(self.id, returns); self } - unconstrained pub fn times(self, times: u64) -> Self { + pub unconstrained fn times(self, times: u64) -> Self { set_mock_times_oracle(self.id, times); self } - unconstrained pub fn clear(self) { + pub unconstrained fn clear(self) { clear_mock_oracle(self.id); } }