From 65b6dd7d888d25fa233263090e47dec22622dccf Mon Sep 17 00:00:00 2001 From: TomAFrench Date: Tue, 15 Oct 2024 08:23:39 +0000 Subject: [PATCH 01/14] fix: remove need for duplicate attributes on each function --- boxes/boxes/react/src/contracts/src/main.nr | 4 +- boxes/boxes/vanilla/src/contracts/src/main.nr | 4 +- boxes/init/src/main.nr | 3 +- .../aztec/src/macros/functions/mod.nr | 20 +++--- .../app_subscription_contract/src/main.nr | 5 +- .../contracts/auth_contract/src/main.nr | 18 ++--- .../auth_registry_contract/src/main.nr | 11 +-- .../auth_wit_test_contract/src/main.nr | 2 - .../avm_initializer_test_contract/src/main.nr | 4 +- .../contracts/avm_test_contract/src/main.nr | 72 ------------------- .../benchmarking_contract/src/main.nr | 4 -- .../contracts/card_game_contract/src/main.nr | 8 --- .../contracts/child_contract/src/main.nr | 11 --- .../contracts/claim_contract/src/main.nr | 4 +- .../src/main.nr | 3 - .../src/main.nr | 1 - .../contracts/counter_contract/src/main.nr | 4 +- .../crowdfunding_contract/src/main.nr | 6 +- .../delegated_on_contract/src/main.nr | 3 - .../contracts/delegator_contract/src/main.nr | 4 -- .../docs_example_contract/src/main.nr | 25 +------ .../easy_private_token_contract/src/main.nr | 5 +- .../easy_private_voting_contract/src/main.nr | 6 +- .../ecdsa_k_account_contract/src/main.nr | 9 +-- .../ecdsa_r_account_contract/src/main.nr | 9 +-- .../contracts/escrow_contract/src/main.nr | 4 +- .../contracts/fee_juice_contract/src/main.nr | 10 +-- .../contracts/fpc_contract/src/main.nr | 8 +-- .../import_test_contract/src/main.nr | 4 -- .../inclusion_proofs_contract/src/main.nr | 16 +---- .../contracts/lending_contract/src/main.nr | 26 ++----- .../src/main.nr | 1 - .../contracts/nft_contract/src/main.nr | 35 +++------ .../contracts/parent_contract/src/main.nr | 16 ----- .../pending_note_hashes_contract/src/main.nr | 15 ---- .../contracts/price_feed_contract/src/main.nr | 4 +- .../private_fpc_contract/src/main.nr | 4 +- .../contracts/router_contract/src/main.nr | 8 +-- .../schnorr_account_contract/src/main.nr | 11 ++- .../src/main.nr | 4 +- .../src/main.nr | 4 +- .../contracts/spam_contract/src/main.nr | 2 - .../stateful_test_contract/src/main.nr | 26 +++---- .../static_child_contract/src/main.nr | 15 ++-- .../static_parent_contract/src/main.nr | 15 ---- .../contracts/test_contract/src/main.nr | 32 --------- .../contracts/test_log_contract/src/main.nr | 2 - .../token_blacklist_contract/src/main.nr | 24 ++----- .../token_bridge_contract/src/main.nr | 14 +--- .../contracts/token_contract/src/main.nr | 53 +++----------- .../contracts/uniswap_contract/src/main.nr | 9 +-- 51 files changed, 96 insertions(+), 511 deletions(-) diff --git a/boxes/boxes/react/src/contracts/src/main.nr b/boxes/boxes/react/src/contracts/src/main.nr index 83c0fccead6..90c5e16673a 100644 --- a/boxes/boxes/react/src/contracts/src/main.nr +++ b/boxes/boxes/react/src/contracts/src/main.nr @@ -16,8 +16,7 @@ contract BoxReact { } #[private] - #['private] - #['initializer] + #[initializer] fn constructor( number: Field, owner: AztecAddress, @@ -31,7 +30,6 @@ contract BoxReact { } #[private] - #['private] fn setNumber( number: Field, owner: AztecAddress, diff --git a/boxes/boxes/vanilla/src/contracts/src/main.nr b/boxes/boxes/vanilla/src/contracts/src/main.nr index 73e50e49c8c..8763e30760f 100644 --- a/boxes/boxes/vanilla/src/contracts/src/main.nr +++ b/boxes/boxes/vanilla/src/contracts/src/main.nr @@ -16,8 +16,7 @@ contract Vanilla { } #[private] - #['private] - #['initializer] + #[initializer] fn constructor( number: Field, owner: AztecAddress, @@ -31,7 +30,6 @@ contract Vanilla { } #[private] - #['private] fn setNumber( number: Field, owner: AztecAddress, diff --git a/boxes/init/src/main.nr b/boxes/init/src/main.nr index c7f6de05921..7924ff03505 100644 --- a/boxes/init/src/main.nr +++ b/boxes/init/src/main.nr @@ -4,7 +4,6 @@ use dep::aztec::macros::aztec; #[aztec] contract Main { #[private] - #['private] - #['initializer] + #[initializer] fn constructor() { } } diff --git a/noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr b/noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr index e46eecab75b..7a8112fed78 100644 --- a/noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr +++ b/noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr @@ -22,8 +22,8 @@ use interfaces::{create_fn_abi_export, register_stub, stub_fn}; // Therefore, the execution order of `#[internal]` and `#[private]` is irrelevant. /// Internal functions can only be called by the contract itself, typically from private into public. -pub comptime fn internal(_f: FunctionDefinition) { - // Marker attribute +pub comptime fn internal(f: FunctionDefinition) { + f.add_attribute("internal") } comptime fn create_internal_check(f: FunctionDefinition) -> Quoted { @@ -33,8 +33,8 @@ comptime fn create_internal_check(f: FunctionDefinition) -> Quoted { } /// View functions can only be called in a static execution context. -pub comptime fn view(_f: FunctionDefinition) { - // Marker attribute +pub comptime fn view(f: FunctionDefinition) { + f.add_attribute("view") } comptime fn create_view_check(f: FunctionDefinition) -> Quoted { @@ -53,13 +53,13 @@ comptime fn create_view_check(f: FunctionDefinition) -> Quoted { /// - it can only be called once /// - if there are multiple initializer functions, only one of them can be called /// - no non-initializer functions can be called until an initializer has ben called (except `noinitcheck` functions) -pub comptime fn initializer(_f: FunctionDefinition) { - // Marker attribute +pub comptime fn initializer(f: FunctionDefinition) { + f.add_attribute("initializer") } /// Functions with noinitcheck can be called before contract initialization. -pub comptime fn noinitcheck(_f: FunctionDefinition) { - // Marker attribute +pub comptime fn noinitcheck(f: FunctionDefinition) { + f.add_attribute("noinitcheck") } comptime fn create_assert_correct_initializer_args(f: FunctionDefinition) -> Quoted { @@ -79,6 +79,8 @@ comptime fn create_init_check(f: FunctionDefinition) -> Quoted { /// Private functions are executed client-side and preserve privacy. pub comptime fn private(f: FunctionDefinition) -> Quoted { + f.add_attribute("private"); + let fn_abi = create_fn_abi_export(f); let fn_stub = stub_fn(f); register_stub(f.module(), fn_stub); @@ -225,6 +227,8 @@ pub comptime fn private(f: FunctionDefinition) -> Quoted { /// Public functions are executed sequencer-side and do not preserve privacy, similar to the EVM. pub comptime fn public(f: FunctionDefinition) -> Quoted { + f.add_attribute("public"); + // We don't want to transform the public_dispatch function. if f.name() == quote { public_dispatch } { quote {} diff --git a/noir-projects/noir-contracts/contracts/app_subscription_contract/src/main.nr b/noir-projects/noir-contracts/contracts/app_subscription_contract/src/main.nr index 8adcbb95e8b..dfd2f5480ab 100644 --- a/noir-projects/noir-contracts/contracts/app_subscription_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/app_subscription_contract/src/main.nr @@ -34,7 +34,6 @@ contract AppSubscription { global SUBSCRIPTION_TXS = 5; #[private] - #['private] fn entrypoint(payload: DAppPayload, user_address: AztecAddress) { // Default msg_sender for entrypoints is now Fr.max_value rather than 0 addr (see #7190 & #7404) assert(context.msg_sender().to_field() == MAX_FIELD_VALUE); @@ -65,8 +64,7 @@ contract AppSubscription { } #[public] - #['public] - #['initializer] + #[initializer] fn constructor( target_address: AztecAddress, subscription_recipient_address: AztecAddress, @@ -82,7 +80,6 @@ contract AppSubscription { } #[private] - #['private] fn subscribe(subscriber: AztecAddress, nonce: Field, expiry_block_number: Field, tx_count: Field) { assert(tx_count as u64 <= SUBSCRIPTION_TXS as u64); diff --git a/noir-projects/noir-contracts/contracts/auth_contract/src/main.nr b/noir-projects/noir-contracts/contracts/auth_contract/src/main.nr index 1b2d99856ce..18f4cd0aebb 100644 --- a/noir-projects/noir-contracts/contracts/auth_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/auth_contract/src/main.nr @@ -24,8 +24,7 @@ contract Auth { } #[public] - #['public] - #['initializer] + #[initializer] fn constructor(admin: AztecAddress) { assert(!admin.is_zero(), "invalid admin"); storage.admin.initialize(admin); @@ -33,7 +32,6 @@ contract Auth { // docs:start:shared_mutable_schedule #[public] - #['public] fn set_authorized(authorized: AztecAddress) { assert_eq(storage.admin.read(), context.msg_sender(), "caller is not admin"); storage.authorized.schedule_value_change(authorized); @@ -42,8 +40,7 @@ contract Auth { // docs:start:public_getter #[public] - #['public] - #['view] + #[view] fn get_authorized() -> AztecAddress { // docs:start:shared_mutable_get_current_public storage.authorized.get_current_value_in_public() @@ -52,8 +49,7 @@ contract Auth { // docs:end:public_getter #[public] - #['public] - #['view] + #[view] fn get_scheduled_authorized() -> AztecAddress { // docs:start:shared_mutable_get_scheduled_public let (scheduled_value, _block_of_change): (AztecAddress, u32) = storage.authorized.get_scheduled_value_in_public(); @@ -62,20 +58,17 @@ contract Auth { } #[public] - #['public] - #['view] + #[view] fn get_authorized_delay() -> pub u32 { storage.authorized.get_current_delay_in_public() } #[public] - #['public] fn set_authorized_delay(new_delay: u32) { storage.authorized.schedule_delay_change(new_delay); } #[private] - #['private] fn do_private_authorized_thing() { // Reading a value from authorized in private automatically adds an extra validity condition: the base rollup // circuit will reject this tx if included in a block past the block horizon, which is as far as the circuit can @@ -87,8 +80,7 @@ contract Auth { } #[private] - #['private] - #['view] + #[view] fn get_authorized_in_private() -> AztecAddress { storage.authorized.get_current_value_in_private() } diff --git a/noir-projects/noir-contracts/contracts/auth_registry_contract/src/main.nr b/noir-projects/noir-contracts/contracts/auth_registry_contract/src/main.nr index 63a744345f9..6293a1967de 100644 --- a/noir-projects/noir-contracts/contracts/auth_registry_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/auth_registry_contract/src/main.nr @@ -22,7 +22,6 @@ contract AuthRegistry { * @param authorize True if the caller is authorized to perform the message hash, false otherwise */ #[public] - #['public] fn set_authorized(message_hash: Field, authorize: bool) { storage.approved_actions.at(context.msg_sender()).at(message_hash).write(authorize); } @@ -35,7 +34,6 @@ contract AuthRegistry { * @param reject True if all actions should be rejected, false otherwise */ #[public] - #['public] fn set_reject_all(reject: bool) { storage.reject_all.at(context.msg_sender()).write(reject); } @@ -51,7 +49,6 @@ contract AuthRegistry { * @return `IS_VALID_SELECTOR` if the action was consumed, revert otherwise */ #[public] - #['public] fn consume(on_behalf_of: AztecAddress, inner_hash: Field) -> Field { assert_eq(false, storage.reject_all.at(on_behalf_of).read(), "rejecting all"); @@ -82,7 +79,6 @@ contract AuthRegistry { * @param authorize True if the message hash should be authorized, false otherwise */ #[private] - #['private] fn set_authorized_private(approver: AztecAddress, message_hash: Field, authorize: bool) { assert_current_call_valid_authwit(&mut context, approver); AuthRegistry::at(context.this_address())._set_authorized(approver, message_hash, authorize).enqueue(&mut context); @@ -97,7 +93,6 @@ contract AuthRegistry { * @param authorize True if the caller is authorized to perform the message hash, false otherwise */ #[public] - #['public] #['internal] fn _set_authorized(approver: AztecAddress, message_hash: Field, authorize: bool) { storage.approved_actions.at(approver).at(message_hash).write(authorize); @@ -110,8 +105,7 @@ contract AuthRegistry { * @return True if all actions are rejected, false otherwise */ #[public] - #['public] - #['view] + #[view] fn is_reject_all(on_behalf_of: AztecAddress) -> bool { storage.reject_all.at(on_behalf_of).read() } @@ -124,8 +118,7 @@ contract AuthRegistry { * @return True if the caller is authorized to perform the action, false otherwise */ #[public] - #['public] - #['view] + #[view] fn is_consumable(on_behalf_of: AztecAddress, message_hash: Field) -> bool { storage.approved_actions.at(on_behalf_of).at(message_hash).read() } diff --git a/noir-projects/noir-contracts/contracts/auth_wit_test_contract/src/main.nr b/noir-projects/noir-contracts/contracts/auth_wit_test_contract/src/main.nr index 6d705d070f3..8fbf2ba8c82 100644 --- a/noir-projects/noir-contracts/contracts/auth_wit_test_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/auth_wit_test_contract/src/main.nr @@ -7,13 +7,11 @@ contract AuthWitTest { use dep::authwit::auth::{assert_inner_hash_valid_authwit, assert_inner_hash_valid_authwit_public}; #[private] - #['private] fn consume(on_behalf_of: AztecAddress, inner_hash: Field) { assert_inner_hash_valid_authwit(&mut context, on_behalf_of, inner_hash); } #[public] - #['public] fn consume_public(on_behalf_of: AztecAddress, inner_hash: Field) { assert_inner_hash_valid_authwit_public(&mut context, on_behalf_of, inner_hash); } diff --git a/noir-projects/noir-contracts/contracts/avm_initializer_test_contract/src/main.nr b/noir-projects/noir-contracts/contracts/avm_initializer_test_contract/src/main.nr index 157f27e1663..8c74544a783 100644 --- a/noir-projects/noir-contracts/contracts/avm_initializer_test_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/avm_initializer_test_contract/src/main.nr @@ -14,14 +14,12 @@ contract AvmInitializerTest { * Storage ************************************************************************/ #[public] - #['public] - #['initializer] + #[initializer] fn constructor() { storage.immutable.initialize(42); } #[public] - #['public] fn read_storage_immutable() -> pub Field { storage.immutable.read() } diff --git a/noir-projects/noir-contracts/contracts/avm_test_contract/src/main.nr b/noir-projects/noir-contracts/contracts/avm_test_contract/src/main.nr index bd80f6b4904..79b67ccf7de 100644 --- a/noir-projects/noir-contracts/contracts/avm_test_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/avm_test_contract/src/main.nr @@ -50,40 +50,34 @@ contract AvmTest { * Storage ************************************************************************/ #[public] - #['public] fn set_storage_single(a: Field) { storage.single.write(a); } #[public] - #['public] fn read_storage_single() -> Field { storage.single.read() } // should still be able to use ` -> pub *` for return type even though macro forces `pub` #[public] - #['public] fn set_read_storage_single(a: Field) -> pub Field { storage.single.write(a); storage.single.read() } #[public] - #['public] fn set_storage_list(a: Field, b: Field) { storage.list.write(Note { a, b }); } #[public] - #['public] fn read_storage_list() -> [Field; 2] { let note: Note = storage.list.read(); note.serialize() } #[public] - #['public] fn set_storage_map(to: AztecAddress, amount: u32) -> Field { storage.map.at(to).write(amount); // returns storage slot for key @@ -91,7 +85,6 @@ contract AvmTest { } #[public] - #['public] fn add_storage_map(to: AztecAddress, amount: u32) -> Field { let new_balance = storage.map.at(to).read().add(amount); storage.map.at(to).write(new_balance); @@ -100,13 +93,11 @@ contract AvmTest { } #[public] - #['public] fn read_storage_map(address: AztecAddress) -> u32 { storage.map.at(address).read() } #[public] - #['public] fn add_args_return(arg_a: Field, arg_b: Field) -> Field { arg_a + arg_b } @@ -115,61 +106,51 @@ contract AvmTest { * General Opcodes ************************************************************************/ #[public] - #['public] fn set_opcode_u8() -> u8 { 8 as u8 } #[public] - #['public] fn set_opcode_u32() -> u32 { 1 << 30 as u8 } #[public] - #['public] fn set_opcode_u64() -> u64 { 1 << 60 as u8 } #[public] - #['public] fn set_opcode_small_field() -> Field { big_field_128_bits } #[public] - #['public] fn set_opcode_big_field() -> Field { big_field_136_bits } #[public] - #['public] fn set_opcode_really_big_field() -> Field { big_field_254_bits } #[public] - #['public] fn add_u128(a: U128, b: U128) -> U128 { a + b } #[public] - #['public] fn modulo2(a: u64) -> u64 { a % 2 } #[public] - #['public] fn elliptic_curve_add(lhs: Point, rhs: Point) -> Point { lhs + rhs } #[public] - #['public] fn elliptic_curve_add_and_double() -> Point { let g = Point { x: 1, y: 17631683881184975370165255887551781615748388533673675138860, is_infinite: false }; @@ -179,7 +160,6 @@ contract AvmTest { } #[public] - #['public] fn variable_base_msm() -> Point { let g = Point { x: 1, y: 17631683881184975370165255887551781615748388533673675138860, is_infinite: false }; let scalar = Scalar { lo: 3, hi: 0 }; @@ -189,7 +169,6 @@ contract AvmTest { } #[public] - #['public] fn pedersen_commit(x: Field, y: Field) -> EmbeddedCurvePoint { let commitment = dep::std::hash::pedersen_commitment_with_separator([x, y], 20); commitment @@ -200,7 +179,6 @@ contract AvmTest { ************************************************************************/ #[public] - #['public] fn u128_addition_overflow() -> U128 { let max_u128: U128 = U128::from_hex("0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"); let one: U128 = U128::from_integer(1); @@ -208,14 +186,12 @@ contract AvmTest { } #[public] - #['public] fn u128_from_integer_overflow() -> U128 { let should_overflow: Field = 2.pow_32(128); // U128::max() + 1; U128::from_integer(should_overflow) } #[public] - #['public] fn to_radix_le(input: Field) -> [u8; 10] { input.to_le_radix(/*base=*/ 2) } @@ -230,13 +206,11 @@ contract AvmTest { } #[public] - #['public] fn assertion_failure() { helper_with_failed_assertion() } #[public] - #['public] fn debug_logging() { dep::aztec::oracle::debug_log::debug_log("just text"); dep::aztec::oracle::debug_log::debug_log_format("second: {1}", [1, 2, 3, 4]); @@ -245,14 +219,12 @@ contract AvmTest { } #[public] - #['public] fn assert_same(arg_a: Field, arg_b: Field) -> pub Field { assert(arg_a == arg_b, "Values are not equal"); 1 } #[public] - #['public] fn assert_calldata_copy(args: [Field; 3]) { let offset = 0; let cd: [Field; 3] = dep::aztec::context::public_context::calldata_copy(offset, 3); @@ -260,7 +232,6 @@ contract AvmTest { } #[public] - #['public] fn return_oracle() -> [Field; 3] { dep::aztec::context::public_context::avm_return([1, 2, 3]); [4, 5, 6] // Should not get here. @@ -270,37 +241,31 @@ contract AvmTest { * Hashing functions ************************************************************************/ #[public] - #['public] fn keccak_hash(data: [u8; 10]) -> [u8; 32] { std::hash::keccak256(data, data.len() as u32) } #[public] - #['public] fn keccak_f1600(data: [u64; 25]) -> [u64; 25] { std::hash::keccak::keccakf1600(data) } #[public] - #['public] fn poseidon2_hash(data: [Field; 10]) -> Field { std::hash::poseidon2::Poseidon2::hash(data, data.len()) } #[public] - #['public] fn sha256_hash(data: [u8; 10]) -> [u8; 32] { std::hash::sha256(data) } #[public] - #['public] fn pedersen_hash(data: [Field; 10]) -> Field { std::hash::pedersen_hash(data) } #[public] - #['public] fn pedersen_hash_with_index(data: [Field; 10]) -> Field { std::hash::pedersen_hash_with_separator(data, /*index=*/ 20) } @@ -309,7 +274,6 @@ contract AvmTest { * Contract instance ************************************************************************/ #[public] - #['public] fn test_get_contract_instance_raw() { let fields = get_contract_instance_internal_avm(context.this_address()); // The values here should match those in `avm_simulator.test.ts>Contract>GETCONTRACTINSTANCE deserializes correctly` @@ -323,7 +287,6 @@ contract AvmTest { } #[public] - #['public] fn test_get_contract_instance() { let ci = get_contract_instance_avm(context.this_address()); assert(ci.is_some(), "Contract instance not found!"); @@ -333,92 +296,77 @@ contract AvmTest { * AvmContext functions ************************************************************************/ #[public] - #['public] fn get_address() -> AztecAddress { context.this_address() } #[public] - #['public] fn get_storage_address() -> AztecAddress { context.storage_address() } #[public] - #['public] fn get_sender() -> AztecAddress { context.msg_sender() } #[public] - #['public] fn get_function_selector() -> FunctionSelector { context.selector() } #[public] - #['public] fn get_transaction_fee() -> Field { context.transaction_fee() } #[public] - #['public] fn get_chain_id() -> Field { context.chain_id() } #[public] - #['public] fn get_version() -> Field { context.version() } #[public] - #['public] fn get_block_number() -> Field { context.block_number() } #[public] - #['public] fn get_timestamp() -> u64 { context.timestamp() } #[public] - #['public] fn get_fee_per_l2_gas() -> Field { context.fee_per_l2_gas() } #[public] - #['public] fn get_fee_per_da_gas() -> Field { context.fee_per_da_gas() } #[public] - #['public] fn get_l2_gas_left() -> Field { context.l2_gas_left() } #[public] - #['public] fn get_da_gas_left() -> Field { context.da_gas_left() } #[public] - #['public] fn assert_timestamp(expected_timestamp: u64) { let timestamp = context.timestamp(); assert(timestamp == expected_timestamp, "timestamp does not match"); } #[public] - #['public] fn check_selector() { assert( context.selector() == comptime { @@ -428,13 +376,11 @@ contract AvmTest { } #[public] - #['public] fn get_args_hash(_a: u8, _fields: [Field; 3]) -> Field { context.get_args_hash() } #[public] - #['public] fn emit_unencrypted_log() { context.emit_unencrypted_log(/*message=*/ [10, 20, 30]); context.emit_unencrypted_log(/*message=*/ "Hello, world!"); @@ -443,41 +389,35 @@ contract AvmTest { } #[public] - #['public] fn note_hash_exists(note_hash: Field, leaf_index: Field) -> bool { context.note_hash_exists(note_hash, leaf_index) } // Use the standard context interface to emit a new note hash #[public] - #['public] fn new_note_hash(note_hash: Field) { context.push_note_hash(note_hash); } // Use the standard context interface to emit a new nullifier #[public] - #['public] fn new_nullifier(nullifier: Field) { context.push_nullifier(nullifier); } // Use the standard context interface to check for a nullifier #[public] - #['public] fn nullifier_exists(nullifier: Field) -> bool { context.nullifier_exists(nullifier, context.storage_address()) } #[public] - #['public] fn assert_nullifier_exists(nullifier: Field) { assert(context.nullifier_exists(nullifier, context.storage_address()), "Nullifier doesn't exist!"); } // Use the standard context interface to emit a new nullifier #[public] - #['public] fn emit_nullifier_and_check(nullifier: Field) { context.push_nullifier(nullifier); let exists = context.nullifier_exists(nullifier, context.storage_address()); @@ -486,7 +426,6 @@ contract AvmTest { // Create the same nullifier twice (shouldn't work!) #[public] - #['public] fn nullifier_collision(nullifier: Field) { context.push_nullifier(nullifier); // Can't do this twice! @@ -494,13 +433,11 @@ contract AvmTest { } #[public] - #['public] fn l1_to_l2_msg_exists(msg_hash: Field, msg_leaf_index: Field) -> bool { context.l1_to_l2_msg_exists(msg_hash, msg_leaf_index) } #[public] - #['public] fn send_l2_to_l1_msg(recipient: EthAddress, content: Field) { context.message_portal(recipient, content) } @@ -509,7 +446,6 @@ contract AvmTest { * Nested calls ************************************************************************/ #[public] - #['public] fn nested_call_to_add_with_gas( arg_a: Field, arg_b: Field, @@ -521,41 +457,35 @@ contract AvmTest { // Use the `call_public_function` wrapper to initiate a nested call to the add function #[public] - #['public] fn nested_call_to_add(arg_a: Field, arg_b: Field) -> pub Field { AvmTest::at(context.this_address()).add_args_return(arg_a, arg_b).call(&mut context) } // Indirectly call_static the external call opcode to initiate a nested call to the add function #[public] - #['public] fn nested_static_call_to_add(arg_a: Field, arg_b: Field) -> pub Field { AvmTest::at(context.this_address()).add_args_return(arg_a, arg_b).view(&mut context) } // Indirectly call_static `set_storage_single`. Should revert since it's accessing storage. #[public] - #['public] fn nested_static_call_to_set_storage() { AvmTest::at(context.this_address()).set_storage_single(20).view(&mut context); } #[public] - #['public] fn create_same_nullifier_in_nested_call(nestedAddress: AztecAddress, nullifier: Field) { context.push_nullifier(nullifier); AvmTest::at(nestedAddress).new_nullifier(nullifier).call(&mut context); } #[public] - #['public] fn create_different_nullifier_in_nested_call(nestedAddress: AztecAddress, nullifier: Field) { context.push_nullifier(nullifier); AvmTest::at(nestedAddress).new_nullifier(nullifier + 1).call(&mut context); } #[public] - #['public] fn nested_call_to_assert_same(arg_a: Field, arg_b: Field) -> pub Field { AvmTest::at(context.this_address()).assert_same(arg_a, arg_b).call(&mut context) } @@ -564,7 +494,6 @@ contract AvmTest { * Enqueue a public call from private */ #[private] - #['private] fn enqueue_public_from_private() { AvmTest::at(context.this_address()).set_opcode_u8().enqueue_view(&mut context); AvmTest::at(context.this_address()).set_read_storage_single(5).enqueue(&mut context); @@ -577,7 +506,6 @@ contract AvmTest { * be optimized away. ************************************************************************/ #[public] - #['public] fn bulk_testing(args_field: [Field; 10], args_u8: [u8; 10]) { dep::aztec::oracle::debug_log::debug_log("set_storage_single"); set_storage_single(30); diff --git a/noir-projects/noir-contracts/contracts/benchmarking_contract/src/main.nr b/noir-projects/noir-contracts/contracts/benchmarking_contract/src/main.nr index 3b59926503e..2116a55fa3a 100644 --- a/noir-projects/noir-contracts/contracts/benchmarking_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/benchmarking_contract/src/main.nr @@ -20,7 +20,6 @@ contract Benchmarking { // Creates a new value note for the target owner. Use this method to seed an initial set of notes. #[private] - #['private] fn create_note(owner: AztecAddress, outgoing_viewer: AztecAddress, value: Field) { // docs:start:increment_valuenote increment(storage.notes.at(owner), value, owner, outgoing_viewer); @@ -32,7 +31,6 @@ contract Benchmarking { // See https://discourse.aztec.network/t/utxo-concurrency-issues-for-private-state/635 // by @rahul-kothari for a full explanation on why this is needed. #[private] - #['private] fn recreate_note(owner: AztecAddress, outgoing_viewer: AztecAddress, index: u32) { let owner_notes = storage.notes.at(owner); let mut getter_options = NoteGetterOptions::new(); @@ -43,7 +41,6 @@ contract Benchmarking { // Reads and writes to public storage and enqueues a call to another public function. #[public] - #['public] fn increment_balance(owner: AztecAddress, value: Field) { let current = storage.balances.at(owner).read(); storage.balances.at(owner).write(current + value); @@ -52,7 +49,6 @@ contract Benchmarking { // Emits a public log. #[public] - #['public] fn broadcast(owner: AztecAddress) { context.emit_unencrypted_log(storage.balances.at(owner).read()); } diff --git a/noir-projects/noir-contracts/contracts/card_game_contract/src/main.nr b/noir-projects/noir-contracts/contracts/card_game_contract/src/main.nr index efbf2f00cbf..0b28831ae34 100644 --- a/noir-projects/noir-contracts/contracts/card_game_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/card_game_contract/src/main.nr @@ -22,7 +22,6 @@ contract CardGame { } #[private] - #['private] fn buy_pack(seed: Field // The randomness used to generate the cards. Passed in for now. ) { let buyer = context.msg_sender(); @@ -33,7 +32,6 @@ contract CardGame { } #[private] - #['private] fn join_game(game: u32, cards_fields: [Field; 2]) { let cards = cards_fields.map(|card_field| Card::from_field(card_field)); @@ -48,7 +46,6 @@ contract CardGame { } #[public] - #['public] #['internal] fn on_game_joined(game: u32, player: AztecAddress, deck_strength: u32) { let game_storage = storage.games.at(game as Field); @@ -60,7 +57,6 @@ contract CardGame { } #[public] - #['public] fn start_game(game: u32) { let game_storage = storage.games.at(game as Field); @@ -70,7 +66,6 @@ contract CardGame { } #[private] - #['private] fn play_card(game: u32, card: Card) { let player = context.msg_sender(); @@ -83,7 +78,6 @@ contract CardGame { } #[public] - #['public] #['internal] fn on_card_played(game: u32, player: AztecAddress, card_as_field: Field) { let game_storage = storage.games.at(game as Field); @@ -99,7 +93,6 @@ contract CardGame { } #[private] - #['private] fn claim_cards(game: u32, cards_fields: [Field; PLAYABLE_CARDS]) { let player = context.msg_sender(); let cards = cards_fields.map(|card_field| Card::from_field(card_field)); @@ -110,7 +103,6 @@ contract CardGame { } #[public] - #['public] #['internal] fn on_cards_claimed(game: u32, player: AztecAddress, cards_hash: Field) { let game_storage = storage.games.at(game as Field); diff --git a/noir-projects/noir-contracts/contracts/child_contract/src/main.nr b/noir-projects/noir-contracts/contracts/child_contract/src/main.nr index b9ec1d59cb7..9e595672b2e 100644 --- a/noir-projects/noir-contracts/contracts/child_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/child_contract/src/main.nr @@ -21,14 +21,12 @@ contract Child { // Returns a sum of the input and the chain id and version of the contract in private circuit public input's return_values. #[private] - #['private] fn value(input: Field) -> Field { input + context.chain_id() + context.version() } // Returns a sum of the input and the chain id and version of the contract in private circuit public input's return_values. // Can only be called from this contract. #[private] - #['private] #['internal] fn value_internal(input: Field) -> Field { input + context.chain_id() + context.version() @@ -36,7 +34,6 @@ contract Child { // Returns base_value + chain_id + version + block_number + timestamp #[public] - #['public] fn pub_get_value(base_value: Field) -> Field { let return_value = base_value + context.chain_id() @@ -49,7 +46,6 @@ contract Child { // Sets `current_value` to `new_value` #[public] - #['public] fn pub_set_value(new_value: Field) -> Field { storage.current_value.write(new_value); context.emit_unencrypted_log(new_value); @@ -58,7 +54,6 @@ contract Child { } #[private] - #['private] fn private_set_value(new_value: Field, owner: AztecAddress) -> Field { let owner_keys = get_public_keys(owner); @@ -68,7 +63,6 @@ contract Child { } #[private] - #['private] fn private_get_value(amount: Field, owner: AztecAddress) -> Field { let mut options = NoteGetterOptions::new(); options = options.select(ValueNote::properties().value, Comparator.EQ, amount).set_limit(1); @@ -78,7 +72,6 @@ contract Child { // Increments `current_value` by `new_value` #[public] - #['public] fn pub_inc_value(new_value: Field) -> Field { let old_value = storage.current_value.read(); storage.current_value.write(old_value + new_value); @@ -89,7 +82,6 @@ contract Child { // Increments `current_value` by `new_value`. Can only be called from this contract. #[public] - #['public] #['internal] fn pub_inc_value_internal(new_value: Field) -> Field { let old_value = storage.current_value.read(); @@ -100,7 +92,6 @@ contract Child { } #[public] - #['public] fn set_value_twice_with_nested_first() { let _result = Child::at(context.this_address()).pub_set_value(10).call(&mut context); storage.current_value.write(20); @@ -108,7 +99,6 @@ contract Child { } #[public] - #['public] fn set_value_twice_with_nested_last() { storage.current_value.write(20); context.emit_unencrypted_log(20); @@ -116,7 +106,6 @@ contract Child { } #[public] - #['public] fn set_value_with_two_nested_calls() { Child::at(context.this_address()).set_value_twice_with_nested_first().call(&mut context); Child::at(context.this_address()).set_value_twice_with_nested_last().call(&mut context); diff --git a/noir-projects/noir-contracts/contracts/claim_contract/src/main.nr b/noir-projects/noir-contracts/contracts/claim_contract/src/main.nr index 2a1fced7b88..93d42b7e9ee 100644 --- a/noir-projects/noir-contracts/contracts/claim_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/claim_contract/src/main.nr @@ -19,15 +19,13 @@ contract Claim { } #[public] - #['public] - #['initializer] + #[initializer] fn constructor(target_contract: AztecAddress, reward_token: AztecAddress) { storage.target_contract.initialize(target_contract); storage.reward_token.initialize(reward_token); } #[private] - #['private] fn claim(proof_note: ValueNote, recipient: AztecAddress) { // 1) Check that the note corresponds to the target contract and belongs to the sender let target_address = storage.target_contract.read_private(); diff --git a/noir-projects/noir-contracts/contracts/contract_class_registerer_contract/src/main.nr b/noir-projects/noir-contracts/contracts/contract_class_registerer_contract/src/main.nr index e70c0ccb7ad..030354ca07b 100644 --- a/noir-projects/noir-contracts/contracts/contract_class_registerer_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/contract_class_registerer_contract/src/main.nr @@ -32,7 +32,6 @@ contract ContractClassRegisterer { // docs:end:import_pop_capsule #[private] - #['private] fn register( artifact_hash: Field, private_functions_root: Field, @@ -70,7 +69,6 @@ contract ContractClassRegisterer { } #[private] - #['private] fn broadcast_private_function( contract_class_id: ContractClassId, artifact_metadata_hash: Field, @@ -113,7 +111,6 @@ contract ContractClassRegisterer { } #[private] - #['private] fn broadcast_unconstrained_function( contract_class_id: ContractClassId, artifact_metadata_hash: Field, diff --git a/noir-projects/noir-contracts/contracts/contract_instance_deployer_contract/src/main.nr b/noir-projects/noir-contracts/contracts/contract_instance_deployer_contract/src/main.nr index bca64c13f1a..98b576ce140 100644 --- a/noir-projects/noir-contracts/contracts/contract_instance_deployer_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/contract_instance_deployer_contract/src/main.nr @@ -27,7 +27,6 @@ contract ContractInstanceDeployer { } #[private] - #['private] fn deploy( salt: Field, contract_class_id: ContractClassId, diff --git a/noir-projects/noir-contracts/contracts/counter_contract/src/main.nr b/noir-projects/noir-contracts/contracts/counter_contract/src/main.nr index c6b803a15f7..42bc8c396f8 100644 --- a/noir-projects/noir-contracts/contracts/counter_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/counter_contract/src/main.nr @@ -17,9 +17,8 @@ contract Counter { // docs:end:storage_struct // docs:start:constructor - #['initializer] + #[initializer] #[private] - #['private] // We can name our initializer anything we want as long as it's marked as aztec(initializer) fn initialize(headstart: u64, owner: AztecAddress, outgoing_viewer: AztecAddress) { let counters = storage.counters; @@ -29,7 +28,6 @@ contract Counter { // docs:start:increment #[private] - #['private] fn increment(owner: AztecAddress, outgoing_viewer: AztecAddress) { unsafe { dep::aztec::oracle::debug_log::debug_log_format("Incrementing counter for owner {0}", [owner.to_field()]); diff --git a/noir-projects/noir-contracts/contracts/crowdfunding_contract/src/main.nr b/noir-projects/noir-contracts/contracts/crowdfunding_contract/src/main.nr index 76ecc48d30e..6b5ff5b4887 100644 --- a/noir-projects/noir-contracts/contracts/crowdfunding_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/crowdfunding_contract/src/main.nr @@ -47,8 +47,7 @@ contract Crowdfunding { // docs:start:init-header // docs:start:init-header-error #[public] - #['public] - #['initializer] + #[initializer] // this-will-error:init-header-error fn init(donation_token: AztecAddress, operator: AztecAddress, deadline: u64) { // docs:end:init-header @@ -61,7 +60,6 @@ contract Crowdfunding { // docs:start:donate #[private] - #['private] fn donate(amount: u64) { // 1) Check that the deadline has not passed --> we do that via the router contract to conceal which contract // is performing the check. @@ -89,7 +87,6 @@ contract Crowdfunding { // docs:start:operator-withdrawals // Withdraws balance to the operator. Requires that msg_sender() is the operator. #[private] - #['private] fn withdraw(amount: u64) { // 1) Check that msg_sender() is the operator let operator_address = storage.operator.read_private(); @@ -103,7 +100,6 @@ contract Crowdfunding { // docs:end:operator-withdrawals #[public] - #['public] #['internal] fn _publish_donation_receipts(amount: u64, to: AztecAddress) { WithdrawalProcessed { amount, who: to }.emit(encode_event(&mut context)); diff --git a/noir-projects/noir-contracts/contracts/delegated_on_contract/src/main.nr b/noir-projects/noir-contracts/contracts/delegated_on_contract/src/main.nr index f9a5266da96..30a4ab02771 100644 --- a/noir-projects/noir-contracts/contracts/delegated_on_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/delegated_on_contract/src/main.nr @@ -18,7 +18,6 @@ contract DelegatedOn { } #[private] - #['private] fn private_set_value(new_value: Field, owner: AztecAddress) -> Field { let msg_sender_keys = get_public_keys(context.msg_sender()); let owner_keys = get_public_keys(owner); @@ -29,14 +28,12 @@ contract DelegatedOn { } #[public] - #['public] fn public_set_value(new_value: Field) -> Field { storage.current_value.write(new_value); new_value } #[private] - #['private] fn get_private_value(amount: Field, owner: AztecAddress) -> pub Field { let mut options = NoteGetterOptions::new(); options = options.select(ValueNote::properties().value, Comparator.EQ, amount).set_limit(1); diff --git a/noir-projects/noir-contracts/contracts/delegator_contract/src/main.nr b/noir-projects/noir-contracts/contracts/delegator_contract/src/main.nr index e206c7e2ea3..80e095d0e43 100644 --- a/noir-projects/noir-contracts/contracts/delegator_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/delegator_contract/src/main.nr @@ -14,7 +14,6 @@ contract Delegator { a_map_with_private_values: Map, Context>, } #[private] - #['private] fn private_delegate_set_value( target_contract: AztecAddress, value: Field, @@ -24,17 +23,14 @@ contract Delegator { DelegatedOn::at(target_contract).private_set_value(value, owner).delegate_call(&mut context) } #[private] - #['private] fn enqueued_delegate_set_value(target_contract: AztecAddress, value: Field) { DelegatedOn::at(target_contract).public_set_value(value).delegate_enqueue(&mut context) } #[public] - #['public] fn public_delegate_set_value(target_contract: AztecAddress, value: Field) -> Field { DelegatedOn::at(target_contract).public_set_value(value).delegate_call(&mut context) } #[private] - #['private] fn get_private_value(amount: Field, owner: AztecAddress) -> Field { let mut options = NoteGetterOptions::new(); options = options.select(ValueNote::properties().value, Comparator.EQ, amount).set_limit(1); diff --git a/noir-projects/noir-contracts/contracts/docs_example_contract/src/main.nr b/noir-projects/noir-contracts/contracts/docs_example_contract/src/main.nr index 59cc4859e31..bf0e71e558b 100644 --- a/noir-projects/noir-contracts/contracts/docs_example_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/docs_example_contract/src/main.nr @@ -99,14 +99,12 @@ contract DocsExample { } #[public] - #['public] fn initialize_shared_immutable(points: u8) { let mut new_leader = Leader { account: context.msg_sender(), points }; storage.shared_immutable.initialize(new_leader); } #[private] - #['private] fn match_shared_immutable(account: AztecAddress, points: u8) { let expected = Leader { account, points }; let read = storage.shared_immutable.read_private(); @@ -116,7 +114,6 @@ contract DocsExample { } #[private] - #['private] fn get_shared_immutable_constrained_private_indirect() -> Leader { // This is a private function that calls another private function // and returns the response. @@ -128,7 +125,6 @@ contract DocsExample { } #[public] - #['public] fn get_shared_immutable_constrained_public_indirect() -> Leader { // This is a public function that calls another public function // and returns the response. @@ -140,22 +136,19 @@ contract DocsExample { } #[public] - #['public] - #['view] + #[view] fn get_shared_immutable_constrained_public() -> Leader { storage.shared_immutable.read_public() } #[public] - #['public] fn get_shared_immutable_constrained_public_multiple() -> [Leader; 5] { let a = storage.shared_immutable.read_public(); [a, a, a, a, a] } #[private] - #['private] - #['view] + #[view] fn get_shared_immutable_constrained_private() -> Leader { storage.shared_immutable.read_private() } @@ -165,7 +158,6 @@ contract DocsExample { } #[public] - #['public] fn initialize_public_immutable(points: u8) { // docs:start:initialize_public_immutable let mut new_leader = Leader { account: context.msg_sender(), points }; @@ -181,7 +173,6 @@ contract DocsExample { // docs:start:initialize-private-mutable #[private] - #['private] fn initialize_private_immutable(randomness: Field, points: u8) { let msg_sender_keys = get_public_keys(context.msg_sender()); @@ -198,7 +189,6 @@ contract DocsExample { // docs:end:initialize-private-mutable #[private] - #['private] // msg_sender() is 0 at deploy time. So created another function fn initialize_private(randomness: Field, points: u8) { let msg_sender_keys = get_public_keys(context.msg_sender()); @@ -216,7 +206,6 @@ contract DocsExample { } #[private] - #['private] fn insert_notes(amounts: [u8; 3]) { let msg_sender_keys = get_public_keys(context.msg_sender()); @@ -233,7 +222,6 @@ contract DocsExample { } } #[private] - #['private] fn insert_note(amount: u8, randomness: Field) { let msg_sender_keys = get_public_keys(context.msg_sender()); @@ -254,7 +242,6 @@ contract DocsExample { } // docs:end:state_vars-NoteGetterOptionsComparatorExampleNoir #[private] - #['private] fn update_legendary_card(randomness: Field, points: u8) { let msg_sender_keys = get_public_keys(context.msg_sender()); @@ -270,7 +257,6 @@ contract DocsExample { DocsExample::at(context.this_address()).update_leader(context.msg_sender(), points).enqueue(&mut context); } #[private] - #['private] fn increase_legendary_points() { // Ensure `points` > current value // Also serves as a e2e test that you can `get_note()` and then `replace()` @@ -295,18 +281,15 @@ contract DocsExample { DocsExample::at(context.this_address()).update_leader(context.msg_sender(), points).enqueue(&mut context); } #[private] - #['private] - #['view] + #[view] fn verify_private_authwit(inner_hash: Field) -> Field { 1 } #[public] - #['public] fn spend_public_authwit(inner_hash: Field) -> Field { 1 } #[public] - #['public] #['internal] fn update_leader(account: AztecAddress, points: u8) { let new_leader = Leader { account, points }; @@ -325,7 +308,6 @@ contract DocsExample { // docs:end:private_mutable_is_initialized // docs:start:get_note-private-immutable #[private] - #['private] fn get_imm_card() -> CardNote { storage.private_immutable.get_note() } @@ -341,7 +323,6 @@ contract DocsExample { use dep::aztec::context::inputs::PrivateContextInputs; // docs:start:simple_macro_example #[private] - #['private] fn simple_macro_example(a: Field, b: Field) -> Field { a + b } diff --git a/noir-projects/noir-contracts/contracts/easy_private_token_contract/src/main.nr b/noir-projects/noir-contracts/contracts/easy_private_token_contract/src/main.nr index ececc9162d6..ef7c89c22a0 100644 --- a/noir-projects/noir-contracts/contracts/easy_private_token_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/easy_private_token_contract/src/main.nr @@ -17,8 +17,7 @@ contract EasyPrivateToken { * initialize the contract's initial state variables. */ #[private] - #['private] - #['initializer] + #[initializer] fn constructor(initial_supply: u64, owner: AztecAddress, outgoing_viewer: AztecAddress) { let balances = storage.balances; @@ -27,7 +26,6 @@ contract EasyPrivateToken { // Mints `amount` of tokens to `owner`. #[private] - #['private] fn mint(amount: u64, owner: AztecAddress, outgoing_viewer: AztecAddress) { let balances = storage.balances; @@ -36,7 +34,6 @@ contract EasyPrivateToken { // Transfers `amount` of tokens from `sender` to a `recipient`. #[private] - #['private] fn transfer(amount: u64, sender: AztecAddress, recipient: AztecAddress, outgoing_viewer: AztecAddress) { let balances = storage.balances; diff --git a/noir-projects/noir-contracts/contracts/easy_private_voting_contract/src/main.nr b/noir-projects/noir-contracts/contracts/easy_private_voting_contract/src/main.nr index 17f79da58fa..8d5a4997b0f 100644 --- a/noir-projects/noir-contracts/contracts/easy_private_voting_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/easy_private_voting_contract/src/main.nr @@ -21,8 +21,7 @@ contract EasyPrivateVoting { // docs:start:constructor #[public] - #['public] - #['initializer] + #[initializer] // annotation to mark function as a constructor fn constructor(admin: AztecAddress) { storage.admin.write(admin); @@ -33,7 +32,6 @@ contract EasyPrivateVoting { // docs:start:cast_vote #[private] - #['private] // annotation to mark function as private and expose private context fn cast_vote(candidate: Field) { let msg_sender_npk_m_hash = get_public_keys(context.msg_sender()).npk_m.hash(); @@ -47,7 +45,6 @@ contract EasyPrivateVoting { // docs:start:add_to_tally_public #[public] - #['public] #['internal] fn add_to_tally_public(candidate: Field) { assert(storage.vote_ended.read() == false, "Vote has ended"); // assert that vote has not ended @@ -58,7 +55,6 @@ contract EasyPrivateVoting { // docs:start:end_vote #[public] - #['public] fn end_vote() { assert(storage.admin.read().eq(context.msg_sender()), "Only admin can end votes"); // assert that caller is admin storage.vote_ended.write(true); diff --git a/noir-projects/noir-contracts/contracts/ecdsa_k_account_contract/src/main.nr b/noir-projects/noir-contracts/contracts/ecdsa_k_account_contract/src/main.nr index 41507b112e9..3e3b9c0405d 100644 --- a/noir-projects/noir-contracts/contracts/ecdsa_k_account_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/ecdsa_k_account_contract/src/main.nr @@ -25,8 +25,7 @@ contract EcdsaKAccount { // Creates a new account out of an ECDSA public key to use for signature verification #[private] - #['private] - #['initializer] + #[initializer] fn constructor(signing_pub_key_x: [u8; 32], signing_pub_key_y: [u8; 32]) { let this = context.this_address(); let this_keys = get_public_keys(this); @@ -40,16 +39,14 @@ contract EcdsaKAccount { // Note: If you globally change the entrypoint signature don't forget to update account_entrypoint.ts #[private] - #['private] fn entrypoint(app_payload: AppPayload, fee_payload: FeePayload, cancellable: bool) { let actions = AccountActions::init(&mut context, is_valid_impl); actions.entrypoint(app_payload, fee_payload, cancellable); } #[private] - #['private] - #['noinitcheck] - #['view] + #[noinitcheck] + #[view] fn verify_private_authwit(inner_hash: Field) -> Field { let actions = AccountActions::init(&mut context, is_valid_impl); actions.verify_private_authwit(inner_hash) diff --git a/noir-projects/noir-contracts/contracts/ecdsa_r_account_contract/src/main.nr b/noir-projects/noir-contracts/contracts/ecdsa_r_account_contract/src/main.nr index f20fbcdd684..be0c4d14ccb 100644 --- a/noir-projects/noir-contracts/contracts/ecdsa_r_account_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/ecdsa_r_account_contract/src/main.nr @@ -24,8 +24,7 @@ contract EcdsaRAccount { // Creates a new account out of an ECDSA public key to use for signature verification #[private] - #['private] - #['initializer] + #[initializer] fn constructor(signing_pub_key_x: [u8; 32], signing_pub_key_y: [u8; 32]) { let this = context.this_address(); let this_keys = get_public_keys(this); @@ -39,16 +38,14 @@ contract EcdsaRAccount { // Note: If you globally change the entrypoint signature don't forget to update account_entrypoint.ts #[private] - #['private] fn entrypoint(app_payload: AppPayload, fee_payload: FeePayload, cancellable: bool) { let actions = AccountActions::init(&mut context, is_valid_impl); actions.entrypoint(app_payload, fee_payload, cancellable); } #[private] - #['private] - #['noinitcheck] - #['view] + #[noinitcheck] + #[view] fn verify_private_authwit(inner_hash: Field) -> Field { let actions = AccountActions::init(&mut context, is_valid_impl); actions.verify_private_authwit(inner_hash) diff --git a/noir-projects/noir-contracts/contracts/escrow_contract/src/main.nr b/noir-projects/noir-contracts/contracts/escrow_contract/src/main.nr index cac065c15a2..785f6dbcfc1 100644 --- a/noir-projects/noir-contracts/contracts/escrow_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/escrow_contract/src/main.nr @@ -21,8 +21,7 @@ contract Escrow { // Creates a new instance #[private] - #['private] - #['initializer] + #[initializer] fn constructor(owner: AztecAddress) { let owner_keys = get_public_keys(owner); let msg_sender_keys = get_public_keys(context.msg_sender()); @@ -34,7 +33,6 @@ contract Escrow { // Withdraws balance. Requires that msg.sender is the owner. #[private] - #['private] fn withdraw(token: AztecAddress, amount: Field, recipient: AztecAddress) { let sender = context.msg_sender(); diff --git a/noir-projects/noir-contracts/contracts/fee_juice_contract/src/main.nr b/noir-projects/noir-contracts/contracts/fee_juice_contract/src/main.nr index 538aa16618c..ea9b1923be4 100644 --- a/noir-projects/noir-contracts/contracts/fee_juice_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/fee_juice_contract/src/main.nr @@ -23,7 +23,6 @@ contract FeeJuice { // Not flagged as initializer to reduce cost of checking init nullifier in all functions. // This function should be called as entrypoint to initialize the contract by minting itself funds. #[private] - #['private] fn initialize(portal_address: EthAddress) { // Validate contract class parameters are correct let self = context.this_address(); @@ -41,14 +40,12 @@ contract FeeJuice { // the contract to a specific L1 portal address, since the Fee Juice address // is a hardcoded constant in the rollup circuits. #[public] - #['public] fn set_portal(portal_address: EthAddress) { assert(storage.portal_address.read_public().is_zero()); storage.portal_address.initialize(portal_address); } #[private] - #['private] fn claim(to: AztecAddress, amount: Field, secret: Field) { let content_hash = get_bridge_gas_msg_hash(to, amount); let portal_address = storage.portal_address.read_private(); @@ -64,7 +61,6 @@ contract FeeJuice { } #[public] - #['public] #['internal] fn _increase_public_balance(to: AztecAddress, amount: Field) { let new_balance = storage.balances.at(to).read().add(U128::from_integer(amount)); @@ -72,8 +68,7 @@ contract FeeJuice { } #[public] - #['public] - #['view] + #[view] fn check_balance(fee_limit: Field) { let fee_limit = U128::from_integer(fee_limit); assert(storage.balances.at(context.msg_sender()).read() >= fee_limit, "Balance too low"); @@ -81,8 +76,7 @@ contract FeeJuice { // utility function for testing #[public] - #['public] - #['view] + #[view] fn balance_of_public(owner: AztecAddress) -> pub Field { storage.balances.at(owner).read().to_field() } diff --git a/noir-projects/noir-contracts/contracts/fpc_contract/src/main.nr b/noir-projects/noir-contracts/contracts/fpc_contract/src/main.nr index abf6e375e22..d70c897e75e 100644 --- a/noir-projects/noir-contracts/contracts/fpc_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/fpc_contract/src/main.nr @@ -18,14 +18,12 @@ contract FPC { } #[public] - #['public] - #['initializer] + #[initializer] fn constructor(other_asset: AztecAddress) { storage.other_asset.initialize(other_asset); } #[private] - #['private] fn fee_entrypoint_private(amount: Field, asset: AztecAddress, secret_hash: Field, nonce: Field) { assert(asset == storage.other_asset.read_private()); Token::at(asset).unshield(context.msg_sender(), context.this_address(), amount, nonce).call(&mut context); @@ -42,7 +40,6 @@ contract FPC { } #[private] - #['private] fn fee_entrypoint_public(amount: Field, asset: AztecAddress, nonce: Field) { FPC::at(context.this_address()).prepare_fee(context.msg_sender(), amount, asset, nonce).enqueue(&mut context); context.set_as_fee_payer(); @@ -58,7 +55,6 @@ contract FPC { } #[public] - #['public] #['internal] fn prepare_fee(from: AztecAddress, amount: Field, asset: AztecAddress, nonce: Field) { // docs:start:public_call @@ -67,7 +63,6 @@ contract FPC { } #[public] - #['public] #['internal] fn pay_refund(refund_address: AztecAddress, amount: Field, asset: AztecAddress) { // Just do public refunds for the present @@ -76,7 +71,6 @@ contract FPC { } #[public] - #['public] #['internal] fn pay_refund_with_shielded_rebate(amount: Field, asset: AztecAddress, secret_hash: Field) { let refund = compute_rebate(context, amount); diff --git a/noir-projects/noir-contracts/contracts/import_test_contract/src/main.nr b/noir-projects/noir-contracts/contracts/import_test_contract/src/main.nr index 62f3e4e9d9c..6f5a19f3fda 100644 --- a/noir-projects/noir-contracts/contracts/import_test_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/import_test_contract/src/main.nr @@ -15,7 +15,6 @@ contract ImportTest { // See yarn-project/simulator/src/client/private_execution.ts // See yarn-project/end-to-end/src/e2e_nested_contract.test.ts #[private] - #['private] fn main_contract(target: AztecAddress) -> Field { Test::at(target).test_code_gen( 1, @@ -40,7 +39,6 @@ contract ImportTest { // Used for testing calling a function with no arguments // See yarn-project/end-to-end/src/e2e_nested_contract.test.ts #[private] - #['private] fn call_no_args(target: AztecAddress) -> AztecAddress { Test::at(target).get_this_address().call(&mut context) } @@ -49,7 +47,6 @@ contract ImportTest { // Used for testing calling a public function // See yarn-project/end-to-end/src/e2e_nested_contract.test.ts #[private] - #['private] fn call_public_fn(target: AztecAddress) { Test::at(target).emit_nullifier_public(1).enqueue(&mut context); } @@ -58,7 +55,6 @@ contract ImportTest { // Used for testing calling a public function from another public function // See yarn-project/end-to-end/src/e2e_nested_contract.test.ts #[public] - #['public] fn pub_call_public_fn(target: AztecAddress) { Test::at(target).emit_nullifier_public(1).call(&mut context); } diff --git a/noir-projects/noir-contracts/contracts/inclusion_proofs_contract/src/main.nr b/noir-projects/noir-contracts/contracts/inclusion_proofs_contract/src/main.nr index 4c31aa5ca69..971162f2d7e 100644 --- a/noir-projects/noir-contracts/contracts/inclusion_proofs_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/inclusion_proofs_contract/src/main.nr @@ -21,8 +21,7 @@ contract InclusionProofs { } #[public] - #['public] - #['initializer] + #[initializer] fn constructor(public_value: Field) { storage.public_value.write(public_value); } @@ -30,7 +29,6 @@ contract InclusionProofs { // docs:start:create_note // Creates a value note owned by `owner`. #[private] - #['private] fn create_note(owner: AztecAddress, value: Field) { let msg_sender_keys = get_public_keys(context.msg_sender()); let owner_keys = get_public_keys(owner); @@ -41,7 +39,6 @@ contract InclusionProofs { // docs:end:create_note #[private] - #['private] fn test_note_inclusion( owner: AztecAddress, use_block_number: bool, @@ -72,7 +69,6 @@ contract InclusionProofs { } #[private] - #['private] fn test_note_inclusion_fail_case( owner: AztecAddress, use_block_number: bool, @@ -93,7 +89,6 @@ contract InclusionProofs { // Proves that the note was not yet nullified at block `block_number`. #[private] - #['private] fn test_note_not_nullified( owner: AztecAddress, use_block_number: bool, @@ -123,7 +118,6 @@ contract InclusionProofs { } #[private] - #['private] fn test_note_validity( owner: AztecAddress, use_block_number: bool, @@ -152,7 +146,6 @@ contract InclusionProofs { // docs:start:nullify_note #[private] - #['private] fn nullify_note(owner: AztecAddress) { let private_values = storage.private_values.at(owner); let mut options = NoteGetterOptions::new(); @@ -166,7 +159,6 @@ contract InclusionProofs { // Note: I am not getting a nullifier of the note that was created in this contract in this function because it is // currently not possible to obtain a nullified note from PXE. #[private] - #['private] fn test_nullifier_inclusion( nullifier: Field, use_block_number: bool, @@ -183,20 +175,17 @@ contract InclusionProofs { } #[public] - #['public] fn push_nullifier_public(nullifier: Field) { context.push_nullifier(nullifier); } // Proves nullifier existed at latest block #[public] - #['public] fn test_nullifier_inclusion_from_public(nullifier: Field) { assert(context.nullifier_exists(nullifier, context.this_address())); } #[private] - #['private] fn test_storage_historical_read_unset_slot(block_number: u32 // The block at which we'll read the public storage value ) { let header = context.get_header_at(block_number); @@ -211,7 +200,6 @@ contract InclusionProofs { } #[private] - #['private] fn test_storage_historical_read( expected: Field, use_block_number: bool, @@ -230,7 +218,6 @@ contract InclusionProofs { // Proves that a contract was publicly deployed and/or initialized at block `block_number`. #[private] - #['private] fn test_contract_inclusion( contract_address: AztecAddress, block_number: u32, @@ -253,7 +240,6 @@ contract InclusionProofs { // Proves that a contract was NOT publicly deployed and/or initialized at block `block_number`. #[private] - #['private] fn test_contract_non_inclusion( contract_address: AztecAddress, block_number: u32, diff --git a/noir-projects/noir-contracts/contracts/lending_contract/src/main.nr b/noir-projects/noir-contracts/contracts/lending_contract/src/main.nr index d92b2f704df..664499acb2d 100644 --- a/noir-projects/noir-contracts/contracts/lending_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/lending_contract/src/main.nr @@ -37,13 +37,11 @@ contract Lending { // Constructs the contract. #[private] - #['private] - #['initializer] + #[initializer] fn constructor( ) {} #[public] - #['public] fn init( oracle: AztecAddress, loan_to_value: Field, @@ -71,7 +69,6 @@ contract Lending { // Create a position. #[public] - #['public] fn update_accumulator() -> Asset { let asset_loc = storage.assets.at(0); let mut asset: Asset = asset_loc.read(); @@ -97,7 +94,6 @@ contract Lending { } #[private] - #['private] fn deposit_private( from: AztecAddress, amount: Field, @@ -118,7 +114,6 @@ contract Lending { } #[public] - #['public] fn deposit_public(amount: Field, nonce: Field, on_behalf_of: Field, collateral_asset: AztecAddress) { let _ = Token::at(collateral_asset).transfer_public(context.msg_sender(), context.this_address(), amount, nonce).call(&mut context); let _ = Lending::at(context.this_address())._deposit( @@ -129,7 +124,6 @@ contract Lending { } #[public] - #['public] #['internal] fn _deposit(owner: AztecAddress, amount: Field, collateral_asset: AztecAddress) { let _asset = Lending::at(context.this_address()).update_accumulator().call(&mut context); @@ -143,20 +137,17 @@ contract Lending { } #[private] - #['private] fn withdraw_private(secret: Field, to: AztecAddress, amount: Field) { let on_behalf_of = compute_identifier(secret, 0, context.msg_sender().to_field()); Lending::at(context.this_address())._withdraw(AztecAddress::from_field(on_behalf_of), to, amount).enqueue(&mut context); } #[public] - #['public] fn withdraw_public(to: AztecAddress, amount: Field) { let _ = Lending::at(context.this_address())._withdraw(context.msg_sender(), to, amount).call(&mut context); } #[public] - #['public] #['internal] fn _withdraw(owner: AztecAddress, recipient: AztecAddress, amount: Field) { let asset = Lending::at(context.this_address()).update_accumulator().call(&mut context); @@ -194,20 +185,17 @@ contract Lending { } #[private] - #['private] fn borrow_private(secret: Field, to: AztecAddress, amount: Field) { let on_behalf_of = compute_identifier(secret, 0, context.msg_sender().to_field()); let _ = Lending::at(context.this_address())._borrow(AztecAddress::from_field(on_behalf_of), to, amount).enqueue(&mut context); } #[public] - #['public] fn borrow_public(to: AztecAddress, amount: Field) { let _ = Lending::at(context.this_address())._borrow(context.msg_sender(), to, amount).call(&mut context); } #[public] - #['public] #['internal] fn _borrow(owner: AztecAddress, to: AztecAddress, amount: Field) { let asset = Lending::at(context.this_address()).update_accumulator().call(&mut context); @@ -241,7 +229,6 @@ contract Lending { } #[private] - #['private] fn repay_private( from: AztecAddress, amount: Field, @@ -258,14 +245,12 @@ contract Lending { } #[public] - #['public] fn repay_public(amount: Field, nonce: Field, owner: AztecAddress, stable_coin: AztecAddress) { let _ = Token::at(stable_coin).burn_public(context.msg_sender(), amount, nonce).call(&mut context); let _ = Lending::at(context.this_address())._repay(owner, amount, stable_coin).call(&mut context); } #[public] - #['public] #['internal] fn _repay(owner: AztecAddress, amount: Field, stable_coin: AztecAddress) { let asset = Lending::at(context.this_address()).update_accumulator().call(&mut context); @@ -285,15 +270,13 @@ contract Lending { } #[public] - #['public] - #['view] + #[view] fn get_asset(asset_id: Field) -> Asset { storage.assets.at(asset_id).read() } #[public] - #['public] - #['view] + #[view] fn get_position(owner: AztecAddress) -> pub Position { let collateral = storage.collateral.at(owner).read(); let static_debt = storage.static_debt.at(owner).read(); @@ -306,8 +289,7 @@ contract Lending { } #[public] - #['public] - #['view] + #[view] fn get_assets() -> pub [AztecAddress; 2] { [storage.collateral_asset.read(), storage.stable_coin.read()] } diff --git a/noir-projects/noir-contracts/contracts/multi_call_entrypoint_contract/src/main.nr b/noir-projects/noir-contracts/contracts/multi_call_entrypoint_contract/src/main.nr index 443158ecde6..2351f61ecc0 100644 --- a/noir-projects/noir-contracts/contracts/multi_call_entrypoint_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/multi_call_entrypoint_contract/src/main.nr @@ -8,7 +8,6 @@ contract MultiCallEntrypoint { use dep::aztec::macros::functions::private; #[private] - #['private] fn entrypoint(app_payload: AppPayload) { app_payload.execute_calls(&mut context); } diff --git a/noir-projects/noir-contracts/contracts/nft_contract/src/main.nr b/noir-projects/noir-contracts/contracts/nft_contract/src/main.nr index bc1302c1aaa..3f5a9eaf6cc 100644 --- a/noir-projects/noir-contracts/contracts/nft_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/nft_contract/src/main.nr @@ -52,8 +52,7 @@ contract NFT { } #[public] - #['public] - #['initializer] + #[initializer] fn constructor(admin: AztecAddress, name: str<31>, symbol: str<31>) { assert(!admin.is_zero(), "invalid admin"); storage.admin.write(admin); @@ -63,21 +62,18 @@ contract NFT { } #[public] - #['public] fn set_admin(new_admin: AztecAddress) { assert(storage.admin.read().eq(context.msg_sender()), "caller is not an admin"); storage.admin.write(new_admin); } #[public] - #['public] fn set_minter(minter: AztecAddress, approve: bool) { assert(storage.admin.read().eq(context.msg_sender()), "caller is not an admin"); storage.minters.at(minter).write(approve); } #[public] - #['public] fn mint(to: AztecAddress, token_id: Field) { assert(token_id != 0, "zero token ID not supported"); assert(storage.minters.at(context.msg_sender()).read(), "caller is not a minter"); @@ -89,49 +85,42 @@ contract NFT { } #[public] - #['public] - #['view] + #[view] fn public_get_name() -> pub FieldCompressedString { storage.name.read_public() } #[private] - #['private] - #['view] + #[view] fn private_get_name() -> pub FieldCompressedString { storage.name.read_private() } #[public] - #['public] - #['view] + #[view] fn public_get_symbol() -> pub FieldCompressedString { storage.symbol.read_public() } #[private] - #['private] - #['view] + #[view] fn private_get_symbol() -> pub FieldCompressedString { storage.symbol.read_private() } #[public] - #['public] - #['view] + #[view] fn get_admin() -> Field { storage.admin.read().to_field() } #[public] - #['public] - #['view] + #[view] fn is_minter(minter: AztecAddress) -> bool { storage.minters.at(minter).read() } #[public] - #['public] fn transfer_in_public(from: AztecAddress, to: AztecAddress, token_id: Field, nonce: Field) { if (!from.eq(context.msg_sender())) { assert_current_call_valid_authwit_public(&mut context, from); @@ -150,7 +139,6 @@ contract NFT { /// as an argument so that we can derive `transfer_preparer_storage_slot_commitment` off-chain and then pass it /// as an argument to the followup call to `finalize_transfer_to_private`. #[private] - #['private] fn prepare_transfer_to_private( from: AztecAddress, to: AztecAddress, @@ -188,7 +176,6 @@ contract NFT { } #[public] - #['public] #['internal] fn _store_point_in_transient_storage(point: Point, slot: Field) { // We don't perform check for the overwritten value to be non-zero because the slots are siloed to `to` @@ -201,7 +188,6 @@ contract NFT { /// The `transfer_preparer_storage_slot_commitment` has to be computed off-chain the same way as was done /// in the preparation call. #[public] - #['public] fn finalize_transfer_to_private( token_id: Field, transfer_preparer_storage_slot_commitment: Field @@ -245,7 +231,6 @@ contract NFT { * @param inner_hash The inner hash of the authwit to cancel. */ #[private] - #['private] fn cancel_authwit(inner_hash: Field) { let on_behalf_of = context.msg_sender(); let nullifier = compute_authwit_nullifier(on_behalf_of, inner_hash); @@ -253,7 +238,6 @@ contract NFT { } #[private] - #['private] fn transfer_in_private(from: AztecAddress, to: AztecAddress, token_id: Field, nonce: Field) { if (!from.eq(context.msg_sender())) { assert_current_call_valid_authwit(&mut context, from); @@ -276,7 +260,6 @@ contract NFT { } #[private] - #['private] fn transfer_to_public(from: AztecAddress, to: AztecAddress, token_id: Field, nonce: Field) { if (!from.eq(context.msg_sender())) { assert_current_call_valid_authwit(&mut context, from); @@ -293,7 +276,6 @@ contract NFT { } #[public] - #['public] #['internal] fn _finish_transfer_to_public(to: AztecAddress, token_id: Field) { storage.public_owners.at(token_id).write(to); @@ -301,8 +283,7 @@ contract NFT { // Returns zero address when the token does not have a public owner. Reverts if the token does not exist. #[public] - #['public] - #['view] + #[view] fn owner_of(token_id: Field) -> AztecAddress { assert(storage.nft_exists.at(token_id).read(), "token does not exist"); storage.public_owners.at(token_id).read() diff --git a/noir-projects/noir-contracts/contracts/parent_contract/src/main.nr b/noir-projects/noir-contracts/contracts/parent_contract/src/main.nr index 0598b2b0069..9d44bf56cae 100644 --- a/noir-projects/noir-contracts/contracts/parent_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/parent_contract/src/main.nr @@ -8,14 +8,12 @@ contract Parent { use dep::aztec::{context::gas::GasOpts, macros::functions::{private, public}}; // Private function to call another private function in the target_contract using the provided selector #[private] - #['private] fn entry_point(target_contract: AztecAddress, target_selector: FunctionSelector) -> Field { // Call the target private function context.call_private_function(target_contract, target_selector, [0]).unpack_into() } // Public function to directly call another public function to the target_contract using the selector and value provided #[public] - #['public] fn pub_entry_point( target_contract: AztecAddress, target_selector: FunctionSelector, @@ -30,7 +28,6 @@ contract Parent { } // Same as pub_entry_point, but calls the target contract twice, using the return value from the first invocation as the argument for the second. #[public] - #['public] fn pub_entry_point_twice( target_contract: AztecAddress, target_selector: FunctionSelector, @@ -51,7 +48,6 @@ contract Parent { } // Private function to enqueue a call to the target_contract address using the selector and argument provided #[private] - #['private] fn enqueue_call_to_child( target_contract: AztecAddress, target_selector: FunctionSelector, @@ -63,7 +59,6 @@ contract Parent { // - one through a nested call to enqueue_call_to_child with value 10, // - followed by one issued directly from this function with value 20. #[private] - #['private] fn enqueue_calls_to_child_with_nested_first(target_contract: AztecAddress, target_selector: FunctionSelector) { let enqueue_call_to_child_selector = comptime { FunctionSelector::from_signature("enqueue_call_to_child((Field),(u32),Field)") @@ -79,7 +74,6 @@ contract Parent { // - one issued directly from this function with value 20, // - followed by one through a nested call to enqueue_call_to_child with value 10. #[private] - #['private] fn enqueue_calls_to_child_with_nested_last(target_contract: AztecAddress, target_selector: FunctionSelector) { context.call_public_function(target_contract, target_selector, [20]); let enqueue_call_to_child_selector = comptime { @@ -93,7 +87,6 @@ contract Parent { } // Private function to enqueue a call to the target_contract address using the selector and argument provided #[private] - #['private] fn enqueue_call_to_child_twice( target_contract: AztecAddress, target_selector: FunctionSelector, @@ -106,7 +99,6 @@ contract Parent { } // Private function to enqueue a call to the pub_entry_point function of this same contract, passing the target arguments provided #[private] - #['private] fn enqueue_call_to_pub_entry_point( target_contract: AztecAddress, target_selector: FunctionSelector, @@ -124,7 +116,6 @@ contract Parent { } // Private function to enqueue two calls to the pub_entry_point function of this same contract, passing the target arguments provided #[private] - #['private] fn enqueue_calls_to_pub_entry_point( target_contract: AztecAddress, target_selector: FunctionSelector, @@ -146,7 +137,6 @@ contract Parent { ); } #[private] - #['private] fn private_static_call( target_contract: AztecAddress, target_selector: FunctionSelector, @@ -156,7 +146,6 @@ contract Parent { context.static_call_private_function(target_contract, target_selector, args).unpack_into() } #[private] - #['private] fn private_call( target_contract: AztecAddress, target_selector: FunctionSelector, @@ -167,7 +156,6 @@ contract Parent { } // Private function to set a static context and verify correct propagation for nested private calls #[private] - #['private] fn private_nested_static_call( target_contract: AztecAddress, target_selector: FunctionSelector, @@ -186,7 +174,6 @@ contract Parent { } // Public function to directly call another public function to the target_contract using the selector and value provided #[public] - #['public] fn public_static_call( target_contract: AztecAddress, target_selector: FunctionSelector, @@ -201,7 +188,6 @@ contract Parent { } // Public function to set a static context and verify correct propagation for nested public calls #[public] - #['public] fn public_nested_static_call( target_contract: AztecAddress, target_selector: FunctionSelector, @@ -219,7 +205,6 @@ contract Parent { } // Private function to enqueue a static call to the pub_entry_point function of another contract, passing the target arguments provided #[private] - #['private] fn enqueue_static_nested_call_to_pub_function(target_contract: AztecAddress, target_selector: FunctionSelector, args: [Field; 1]) { // Call the target public function through the pub entrypoint statically let pub_entry_point_selector = FunctionSelector::from_signature("pub_entry_point((Field),(u32),Field)"); @@ -232,7 +217,6 @@ contract Parent { } // Private function to enqueue a static call to the pub_entry_point function of another contract, passing the target arguments provided #[private] - #['private] fn enqueue_static_call_to_pub_function( target_contract: AztecAddress, target_selector: FunctionSelector, diff --git a/noir-projects/noir-contracts/contracts/pending_note_hashes_contract/src/main.nr b/noir-projects/noir-contracts/contracts/pending_note_hashes_contract/src/main.nr index d90babbc5b1..dcd8391242f 100644 --- a/noir-projects/noir-contracts/contracts/pending_note_hashes_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/pending_note_hashes_contract/src/main.nr @@ -27,7 +27,6 @@ contract PendingNoteHashes { // getting / reading that note all in the same contract function // Realistic way to describe this test is "Mint note A, then burn note A in the same transaction" #[private] - #['private] fn test_insert_then_get_then_nullify_flat(amount: Field, owner: AztecAddress, outgoing_viewer: AztecAddress) -> Field { let owner_balance = storage.balances.at(owner); @@ -59,7 +58,6 @@ contract PendingNoteHashes { // Confirm cannot access note hashes inserted later in same function #[private] - #['private] fn test_bad_get_then_insert_flat(amount: Field, owner: AztecAddress) -> Field { let owner_balance = storage.balances.at(owner); @@ -80,12 +78,10 @@ contract PendingNoteHashes { // Dummy nested/inner function (to pass a function which does nothing) #[private] - #['private] fn dummy(amount: Field, owner: AztecAddress, outgoing_viewer: AztecAddress) {} // Nested/inner function to create and insert a note #[private] - #['private] fn insert_note(amount: Field, owner: AztecAddress, outgoing_viewer: AztecAddress) { let owner_balance = storage.balances.at(owner); @@ -109,7 +105,6 @@ contract PendingNoteHashes { // TESTING: inserts a static randomness value to test notes with // the same note hash are dealt with correctly #[private] - #['private] fn insert_note_static_randomness( amount: Field, owner: AztecAddress, @@ -137,7 +132,6 @@ contract PendingNoteHashes { // Nested/inner function to create and insert a note // then emit another note log for the same note #[private] - #['private] fn insert_note_extra_emit(amount: Field, owner: AztecAddress, outgoing_viewer: AztecAddress) { let mut owner_balance = storage.balances.at(owner); @@ -171,7 +165,6 @@ contract PendingNoteHashes { // Nested/inner function to get a note and confirm it matches the expected value #[private] - #['private] fn get_then_nullify_note(expected_value: Field, owner: AztecAddress) -> Field { let owner_balance = storage.balances.at(owner); @@ -185,7 +178,6 @@ contract PendingNoteHashes { // Nested/inner function to get a note and confirms that none is returned #[private] - #['private] fn get_note_zero_balance(owner: AztecAddress) { let owner_balance = storage.balances.at(owner); @@ -199,7 +191,6 @@ contract PendingNoteHashes { // and "read" / get of that pending note hash in another nested call // Realistic way to describe this test is "Mint note A, then burn note A in the same transaction" #[private] - #['private] fn test_insert_then_get_then_nullify_all_in_nested_calls( amount: Field, owner: AztecAddress, @@ -223,7 +214,6 @@ contract PendingNoteHashes { // same test as above, but insert 2, get 2, nullify 2 #[private] - #['private] fn test_insert2_then_get2_then_nullify2_all_in_nested_calls( amount: Field, owner: AztecAddress, @@ -264,7 +254,6 @@ contract PendingNoteHashes { // same test as above, but insert 2, get 1, nullify 1 #[private] - #['private] fn test_insert2_then_get2_then_nullify1_all_in_nested_calls( amount: Field, owner: AztecAddress, @@ -299,7 +288,6 @@ contract PendingNoteHashes { // one nullifier will be squashed with the pending note, one will become persistent. // ONLY WORKS IF THERE IS A PERSISTENT NOTE TO GET #[private] - #['private] fn test_insert1_then_get2_then_nullify2_all_in_nested_calls( amount: Field, owner: AztecAddress, @@ -346,7 +334,6 @@ contract PendingNoteHashes { //} #[private] - #['private] fn test_recursively_create_notes( owner: AztecAddress, outgoing_viewer: AztecAddress, @@ -358,7 +345,6 @@ contract PendingNoteHashes { } #[private] - #['private] fn recursively_destroy_and_create_notes(owner: AztecAddress, outgoing_viewer: AztecAddress, executions_left: u64) { assert(executions_left > 0); @@ -376,7 +362,6 @@ contract PendingNoteHashes { // by using an existing note's counter via its header. This is used to check that // the pxe rejects the note log later. #[private] - #['private] fn test_emit_bad_note_log(owner: AztecAddress, outgoing_viewer: AztecAddress) { let owner_balance = storage.balances.at(owner); diff --git a/noir-projects/noir-contracts/contracts/price_feed_contract/src/main.nr b/noir-projects/noir-contracts/contracts/price_feed_contract/src/main.nr index d3bbd678ffb..f360c87ad74 100644 --- a/noir-projects/noir-contracts/contracts/price_feed_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/price_feed_contract/src/main.nr @@ -16,15 +16,13 @@ contract PriceFeed { } #[public] - #['public] fn set_price(asset_id: Field, price: Field) { let asset = storage.assets.at(asset_id); asset.write(Asset { price: U128::from_integer(price) }); } #[public] - #['public] - #['view] + #[view] fn get_price(asset_id: Field) -> Asset { storage.assets.at(asset_id).read() } diff --git a/noir-projects/noir-contracts/contracts/private_fpc_contract/src/main.nr b/noir-projects/noir-contracts/contracts/private_fpc_contract/src/main.nr index c25d634435d..2c5663962c3 100644 --- a/noir-projects/noir-contracts/contracts/private_fpc_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/private_fpc_contract/src/main.nr @@ -18,15 +18,13 @@ contract PrivateFPC { } #[public] - #['public] - #['initializer] + #[initializer] fn constructor(other_asset: AztecAddress, admin: AztecAddress) { let settings = Settings { other_asset, admin }; storage.settings.initialize(settings); } #[private] - #['private] fn fund_transaction_privately(amount: Field, asset: AztecAddress) { // TODO: Once SharedImmutable performs only 1 merkle proof here, we'll save ~4k gates let settings = storage.settings.read_private(); diff --git a/noir-projects/noir-contracts/contracts/router_contract/src/main.nr b/noir-projects/noir-contracts/contracts/router_contract/src/main.nr index 430337b8768..9414e1b4962 100644 --- a/noir-projects/noir-contracts/contracts/router_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/router_contract/src/main.nr @@ -14,15 +14,13 @@ contract Router { /// Asserts that the current timestamp in the enqueued public call satisfies the `operation` with respect /// to the `value. #[private] - #['private] fn check_timestamp(operation: u8, value: u64) { Router::at(context.this_address())._check_timestamp(operation, value).enqueue_view(&mut context); } #[public] - #['public] #['internal] - #['view] + #[view] fn _check_timestamp(operation: u8, value: u64) { let lhs_field = context.timestamp() as Field; let rhs_field = value as Field; @@ -33,15 +31,13 @@ contract Router { /// Asserts that the current block number in the enqueued public call satisfies the `operation` with respect /// to the `value. #[private] - #['private] fn check_block_number(operation: u8, value: Field) { Router::at(context.this_address())._check_block_number(operation, value).enqueue_view(&mut context); } #[public] - #['public] #['internal] - #['view] + #[view] fn _check_block_number(operation: u8, value: Field) { assert(compare(context.block_number(), operation, value), "Block number mismatch."); } diff --git a/noir-projects/noir-contracts/contracts/schnorr_account_contract/src/main.nr b/noir-projects/noir-contracts/contracts/schnorr_account_contract/src/main.nr index ec17610217a..7a2aba19720 100644 --- a/noir-projects/noir-contracts/contracts/schnorr_account_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/schnorr_account_contract/src/main.nr @@ -27,8 +27,7 @@ contract SchnorrAccount { // Constructs the contract #[private] - #['private] - #['initializer] + #[initializer] fn constructor(signing_pub_key_x: Field, signing_pub_key_y: Field) { let this = context.this_address(); let this_keys = get_public_keys(this); @@ -42,17 +41,15 @@ contract SchnorrAccount { // Note: If you globally change the entrypoint signature don't forget to update account_entrypoint.ts file #[private] - #['private] - #['noinitcheck] + #[noinitcheck] fn entrypoint(app_payload: AppPayload, fee_payload: FeePayload, cancellable: bool) { let actions = AccountActions::init(&mut context, is_valid_impl); actions.entrypoint(app_payload, fee_payload, cancellable); } #[private] - #['private] - #['noinitcheck] - #['view] + #[noinitcheck] + #[view] fn verify_private_authwit(inner_hash: Field) -> Field { let actions = AccountActions::init(&mut context, is_valid_impl); actions.verify_private_authwit(inner_hash) diff --git a/noir-projects/noir-contracts/contracts/schnorr_hardcoded_account_contract/src/main.nr b/noir-projects/noir-contracts/contracts/schnorr_hardcoded_account_contract/src/main.nr index ec73f0cc4a9..f61dea42972 100644 --- a/noir-projects/noir-contracts/contracts/schnorr_hardcoded_account_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/schnorr_hardcoded_account_contract/src/main.nr @@ -17,15 +17,13 @@ contract SchnorrHardcodedAccount { // Note: If you globally change the entrypoint signature don't forget to update account_entrypoint.ts #[private] - #['private] fn entrypoint(app_payload: AppPayload, fee_payload: FeePayload, cancellable: bool) { let actions = AccountActions::init(&mut context, is_valid_impl); actions.entrypoint(app_payload, fee_payload, cancellable); } #[private] - #['private] - #['view] + #[view] fn verify_private_authwit(inner_hash: Field) -> Field { let actions = AccountActions::init(&mut context, is_valid_impl); actions.verify_private_authwit(inner_hash) diff --git a/noir-projects/noir-contracts/contracts/schnorr_single_key_account_contract/src/main.nr b/noir-projects/noir-contracts/contracts/schnorr_single_key_account_contract/src/main.nr index 8a570394374..b9f00815f63 100644 --- a/noir-projects/noir-contracts/contracts/schnorr_single_key_account_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/schnorr_single_key_account_contract/src/main.nr @@ -15,15 +15,13 @@ contract SchnorrSingleKeyAccount { // Note: If you globally change the entrypoint signature don't forget to update account_entrypoint.ts #[private] - #['private] fn entrypoint(app_payload: AppPayload, fee_payload: FeePayload, cancellable: bool) { let actions = AccountActions::init(&mut context, is_valid_impl); actions.entrypoint(app_payload, fee_payload, cancellable); } #[private] - #['private] - #['view] + #[view] fn verify_private_authwit(inner_hash: Field) -> Field { let actions = AccountActions::init(&mut context, is_valid_impl); actions.verify_private_authwit(inner_hash) diff --git a/noir-projects/noir-contracts/contracts/spam_contract/src/main.nr b/noir-projects/noir-contracts/contracts/spam_contract/src/main.nr index bb6c71a032b..c55a5d10a75 100644 --- a/noir-projects/noir-contracts/contracts/spam_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/spam_contract/src/main.nr @@ -29,7 +29,6 @@ contract Spam { } #[private] - #['private] fn spam(nullifier_seed: Field, nullifier_count: u32, call_public: bool) { let caller = context.msg_sender(); let caller_keys = get_public_keys(caller); @@ -62,7 +61,6 @@ contract Spam { } #[public] - #['public] #['internal] fn public_spam(start: u32, end: u32) { let one = U128::from_integer(1); diff --git a/noir-projects/noir-contracts/contracts/stateful_test_contract/src/main.nr b/noir-projects/noir-contracts/contracts/stateful_test_contract/src/main.nr index d8f5eb2b164..fd229a997d6 100644 --- a/noir-projects/noir-contracts/contracts/stateful_test_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/stateful_test_contract/src/main.nr @@ -17,15 +17,13 @@ contract StatefulTest { } #[private] - #['private] - #['initializer] + #[initializer] fn constructor(owner: AztecAddress, outgoing_viewer: AztecAddress, value: Field) { StatefulTest::at(context.this_address()).create_note_no_init_check(owner, outgoing_viewer, value).call(&mut context); } #[private] - #['private] - #['initializer] + #[initializer] fn wrong_constructor() { let selector = FunctionSelector::from_signature("not_exists(Field)"); let _res = context.call_public_function(context.this_address(), selector, [42]); @@ -34,14 +32,12 @@ contract StatefulTest { // Having _ignored_arg here as it makes the params the same as for the private constructor which makes // contract_class_registration tests way less cluttered. This is a test contract. Don't judge me. #[public] - #['public] - #['initializer] + #[initializer] fn public_constructor(owner: AztecAddress, _ignored_arg: AztecAddress, value: Field) { StatefulTest::at(context.this_address()).increment_public_value_no_init_check(owner, value).call(&mut context); } #[private] - #['private] fn create_note(owner: AztecAddress, outgoing_viewer: AztecAddress, value: Field) { if (value != 0) { let loc = storage.notes.at(owner); @@ -50,8 +46,7 @@ contract StatefulTest { } #[private] - #['private] - #['noinitcheck] + #[noinitcheck] fn create_note_no_init_check(owner: AztecAddress, outgoing_viewer: AztecAddress, value: Field) { if (value != 0) { let loc = storage.notes.at(owner); @@ -60,7 +55,6 @@ contract StatefulTest { } #[private] - #['private] fn destroy_and_create(recipient: AztecAddress, amount: Field) { assert_is_initialized_private(&mut context); let sender = context.msg_sender(); @@ -73,8 +67,7 @@ contract StatefulTest { } #[private] - #['private] - #['noinitcheck] + #[noinitcheck] fn destroy_and_create_no_init_check(recipient: AztecAddress, amount: Field) { let sender = context.msg_sender(); @@ -86,15 +79,13 @@ contract StatefulTest { } #[public] - #['public] fn increment_public_value(owner: AztecAddress, value: Field) { let loc = storage.public_values.at(owner); loc.write(loc.read() + value); } #[public] - #['public] - #['noinitcheck] + #[noinitcheck] fn increment_public_value_no_init_check(owner: AztecAddress, value: Field) { let loc = storage.public_values.at(owner); loc.write(loc.read() + value); @@ -110,9 +101,8 @@ contract StatefulTest { } #[public] - #['public] - #['noinitcheck] - #['view] + #[noinitcheck] + #[view] fn get_public_value(owner: AztecAddress) -> pub Field { storage.public_values.at(owner).read() } diff --git a/noir-projects/noir-contracts/contracts/static_child_contract/src/main.nr b/noir-projects/noir-contracts/contracts/static_child_contract/src/main.nr index e7500389948..0ec1b4bce79 100644 --- a/noir-projects/noir-contracts/contracts/static_child_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/static_child_contract/src/main.nr @@ -21,8 +21,7 @@ contract StaticChild { // Returns base_value + chain_id + version + block_number + timestamp statically #[public] - #['public] - #['view] + #[view] fn pub_get_value(base_value: Field) -> Field { let return_value = base_value + context.chain_id() @@ -35,7 +34,6 @@ contract StaticChild { // Sets `current_value` to `new_value` #[public] - #['public] fn pub_set_value(new_value: Field) -> Field { storage.current_value.write(new_value); context.emit_unencrypted_log(new_value); @@ -44,8 +42,7 @@ contract StaticChild { // View function that attempts to modify state. Should always fail regardless how it's called. #[private] - #['private] - #['view] + #[view] fn private_illegal_set_value(new_value: Field, owner: AztecAddress) -> Field { let msg_sender_keys = get_public_keys(context.msg_sender()); let owner_keys = get_public_keys(owner); @@ -58,7 +55,6 @@ contract StaticChild { // Modify a note #[private] - #['private] fn private_set_value( new_value: Field, owner: AztecAddress, @@ -81,8 +77,7 @@ contract StaticChild { // Retrieve note value statically #[private] - #['private] - #['view] + #[view] fn private_get_value(amount: Field, owner: AztecAddress) -> Field { let owner_npk_m_hash = get_public_keys(owner).npk_m.hash(); let mut options = NoteGetterOptions::new(); @@ -97,7 +92,6 @@ contract StaticChild { // Increments `current_value` by `new_value` #[public] - #['public] fn pub_inc_value(new_value: Field) -> Field { let old_value = storage.current_value.read(); storage.current_value.write(old_value + new_value); @@ -107,8 +101,7 @@ contract StaticChild { // View function that attempts to modify state. Should always fail regardless how it's called. #[public] - #['public] - #['view] + #[view] fn pub_illegal_inc_value(new_value: Field) -> Field { let old_value = storage.current_value.read(); storage.current_value.write(old_value + new_value); diff --git a/noir-projects/noir-contracts/contracts/static_parent_contract/src/main.nr b/noir-projects/noir-contracts/contracts/static_parent_contract/src/main.nr index 7854861cbd9..fb2afc32df7 100644 --- a/noir-projects/noir-contracts/contracts/static_parent_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/static_parent_contract/src/main.nr @@ -10,7 +10,6 @@ contract StaticParent { // Public function to directly call another public function to the target_contract using the selector and value provided #[public] - #['public] fn public_call( target_contract: AztecAddress, target_selector: FunctionSelector, @@ -26,7 +25,6 @@ contract StaticParent { // Private function to directly call another private function to the target_contract using the selector and args provided #[private] - #['private] fn private_call( target_contract: AztecAddress, target_selector: FunctionSelector, @@ -37,7 +35,6 @@ contract StaticParent { // Just like function above but with 3 args. #[private] - #['private] fn private_call_3_args( target_contract: AztecAddress, target_selector: FunctionSelector, @@ -48,7 +45,6 @@ contract StaticParent { // Private function to enqueue a call to a public function of another contract, passing the target arguments provided #[private] - #['private] fn enqueue_call( target_contract: AztecAddress, target_selector: FunctionSelector, @@ -58,7 +54,6 @@ contract StaticParent { } #[private] - #['private] fn private_static_call( target_contract: AztecAddress, target_selector: FunctionSelector, @@ -69,7 +64,6 @@ contract StaticParent { // Private function to statically call another private function to the target_contract using the selector and values provided #[private] - #['private] fn private_static_call_3_args( target_contract: AztecAddress, target_selector: FunctionSelector, @@ -80,7 +74,6 @@ contract StaticParent { // Same as above but using a specific function from the interface #[private] - #['private] fn private_get_value_from_child( target_contract: AztecAddress, value: Field, @@ -91,7 +84,6 @@ contract StaticParent { // Private function to set a static context and verify correct propagation for nested private calls #[private] - #['private] fn private_nested_static_call( target_contract: AztecAddress, target_selector: FunctionSelector, @@ -102,7 +94,6 @@ contract StaticParent { // Just like function above but with 3 args. #[private] - #['private] fn private_nested_static_call_3_args( target_contract: AztecAddress, target_selector: FunctionSelector, @@ -113,7 +104,6 @@ contract StaticParent { // Public function to statically call another public function to the target_contract using the selector and value provided #[public] - #['public] fn public_static_call( target_contract: AztecAddress, target_selector: FunctionSelector, @@ -129,14 +119,12 @@ contract StaticParent { // Same as above but using a specific function from the interface #[public] - #['public] fn public_get_value_from_child(target_contract: AztecAddress, value: Field) -> Field { StaticChild::at(target_contract).pub_get_value(value).view(&mut context) } // Public function to set a static context and verify correct propagation for nested public calls #[public] - #['public] fn public_nested_static_call( target_contract: AztecAddress, target_selector: FunctionSelector, @@ -148,7 +136,6 @@ contract StaticParent { // Private function to enqueue a static call to a public function of another contract, passing the target arguments provided #[private] - #['private] fn enqueue_static_call_to_pub_function( target_contract: AztecAddress, target_selector: FunctionSelector, @@ -159,14 +146,12 @@ contract StaticParent { // Same as above but using a specific function from the interface #[private] - #['private] fn enqueue_public_get_value_from_child(target_contract: AztecAddress, value: Field) { StaticChild::at(target_contract).pub_get_value(value).enqueue_view(&mut context); } // Private function to set a static context and verify correct propagation of nested enqueuing of public calls #[private] - #['private] fn enqueue_static_nested_call_to_pub_function(target_contract: AztecAddress, target_selector: FunctionSelector, args: [Field; 1]) { // Call the target public function through the pub entrypoint statically StaticParent::at(context.this_address()).public_call(target_contract, target_selector, args[0]).enqueue_view(&mut context) diff --git a/noir-projects/noir-contracts/contracts/test_contract/src/main.nr b/noir-projects/noir-contracts/contracts/test_contract/src/main.nr index 0759e75860c..f5d73e42292 100644 --- a/noir-projects/noir-contracts/contracts/test_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/test_contract/src/main.nr @@ -53,13 +53,11 @@ contract Test { } #[private] - #['private] fn get_ovsk_app(ovpk_m_hash: Field) -> Field { context.request_ovsk_app(ovpk_m_hash) } #[private] - #['private] fn get_master_incoming_viewing_public_key(address: AztecAddress) -> [Field; 2] { let ivpk_m = get_public_keys(address).ivpk_m; @@ -68,13 +66,11 @@ contract Test { // Get the address of this contract (taken from the input context) #[private] - #['private] fn get_this_address() -> AztecAddress { context.this_address() } #[private] - #['private] fn set_tx_max_block_number(max_block_number: u32, enqueue_public_call: bool) { context.set_tx_max_block_number(max_block_number); @@ -84,12 +80,10 @@ contract Test { } #[public] - #['public] #['internal] fn dummy_public_call() {} #[private] - #['private] fn call_create_note( value: Field, owner: AztecAddress, @@ -115,7 +109,6 @@ contract Test { } #[private] - #['private] fn call_get_notes(storage_slot: Field, active_or_nullified: bool) -> Field { assert( storage_slot != storage.example_constant.get_storage_slot(), "this storage slot is reserved for example_constant" @@ -132,7 +125,6 @@ contract Test { } #[private] - #['private] fn call_get_notes_many(storage_slot: Field, active_or_nullified: bool) -> [Field; 2] { assert( storage_slot != storage.example_constant.get_storage_slot(), "this storage slot is reserved for example_constant" @@ -179,7 +171,6 @@ contract Test { } #[private] - #['private] fn call_destroy_note(storage_slot: Field) { assert( storage_slot != storage.example_constant.get_storage_slot(), "this storage slot is reserved for example_constant" @@ -195,7 +186,6 @@ contract Test { } #[private] - #['private] fn test_code_gen( a_field: Field, a_bool: bool, @@ -223,7 +213,6 @@ contract Test { } #[private] - #['private] fn test_setting_teardown() { context.set_public_teardown_function( context.this_address(), @@ -235,14 +224,12 @@ contract Test { } #[private] - #['private] fn test_setting_fee_payer() { context.set_as_fee_payer(); } // Purely exists for testing #[public] - #['public] fn create_l2_to_l1_message_public(amount: Field, secret_hash: Field, portal_address: EthAddress) { // Create a commitment to the amount let note = DummyNote::new(amount, secret_hash); @@ -252,14 +239,12 @@ contract Test { } #[public] - #['public] fn create_l2_to_l1_message_arbitrary_recipient_public(content: Field, recipient: EthAddress) { // Public oracle call to emit new commitment. context.message_portal(recipient, content); } #[private] - #['private] fn create_l2_to_l1_message_arbitrary_recipient_private(content: Field, recipient: EthAddress) { // Public oracle call to emit new commitment. context.message_portal(recipient, content); @@ -267,21 +252,18 @@ contract Test { // Purely exists for testing #[public] - #['public] fn emit_nullifier_public(nullifier: Field) { context.push_nullifier(nullifier); } // Forcefully emits a nullifier (for testing purposes) #[private] - #['private] fn emit_nullifier(nullifier: Field) { context.push_nullifier(nullifier); } // For testing non-note encrypted logs #[private] - #['private] fn emit_array_as_encrypted_log( fields: [Field; 5], owner: AztecAddress, @@ -325,7 +307,6 @@ contract Test { } #[private] - #['private] fn emit_encrypted_logs_nested(value: Field, owner: AztecAddress, outgoing_viewer: AztecAddress) { let mut storage_slot = storage.example_constant.get_storage_slot() + 1; Test::at(context.this_address()).call_create_note(value, owner, outgoing_viewer, storage_slot).call(&mut context); @@ -342,7 +323,6 @@ contract Test { // docs:start:is-time-equal #[public] - #['public] fn is_time_equal(time: u64) -> u64 { assert(context.timestamp() == time); time @@ -350,7 +330,6 @@ contract Test { // docs:end:is-time-equal #[public] - #['public] fn emit_unencrypted(value: Field) { // docs:start:emit_unencrypted context.emit_unencrypted_log(/*message=*/ value); @@ -360,7 +339,6 @@ contract Test { } #[public] - #['public] fn consume_mint_public_message( to: AztecAddress, amount: Field, @@ -374,7 +352,6 @@ contract Test { } #[private] - #['private] fn consume_mint_private_message( secret_hash_for_redeeming_minted_notes: Field, amount: Field, @@ -391,7 +368,6 @@ contract Test { } #[public] - #['public] fn consume_message_from_arbitrary_sender_public( content: Field, secret: Field, @@ -403,7 +379,6 @@ contract Test { } #[private] - #['private] fn consume_message_from_arbitrary_sender_private( content: Field, secret: Field, @@ -414,21 +389,18 @@ contract Test { } #[private] - #['private] fn set_constant(value: Field) { let mut note = TestNote::new(value); storage.example_constant.initialize(&mut note).discard(); } #[private] - #['private] fn assert_private_global_vars(chain_id: Field, version: Field) { assert(context.chain_id() == chain_id, "Invalid chain id"); assert(context.version() == version, "Invalid version"); } #[public] - #['public] fn assert_public_global_vars( chain_id: Field, version: Field, @@ -446,7 +418,6 @@ contract Test { } #[private] - #['private] fn assert_header_private(header_hash: Field) { assert(context.historical_header.hash() == header_hash, "Invalid header hash"); } @@ -459,13 +430,11 @@ contract Test { //} #[private] - #['private] fn deploy_contract(target: AztecAddress) { aztec_deploy_contract(&mut context, target); } #[private] - #['private] // Adapted from TokenContract#redeem_shield but without an initcheck so it can be run in simulator/src/client/private_execution.test.ts fn consume_note_from_secret(secret: Field) { let notes_set = storage.example_set; @@ -482,7 +451,6 @@ contract Test { } #[private] - #['private] fn test_nullifier_key_freshness(address: AztecAddress, public_nullifying_key: Point) { assert_eq(get_public_keys(address).npk_m.inner, public_nullifying_key); } diff --git a/noir-projects/noir-contracts/contracts/test_log_contract/src/main.nr b/noir-projects/noir-contracts/contracts/test_log_contract/src/main.nr index 8a6f0731877..4c685a0a93c 100644 --- a/noir-projects/noir-contracts/contracts/test_log_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/test_log_contract/src/main.nr @@ -36,7 +36,6 @@ contract TestLog { global EXAMPLE_EVENT_0_CIPHERTEXT_BYTES_LEN = 144; #[private] - #['private] fn emit_encrypted_events(other: AztecAddress, randomness: [Field; 2], preimages: [Field; 4]) { let event0 = ExampleEvent0 { value0: preimages[0], value1: preimages[1] }; @@ -81,7 +80,6 @@ contract TestLog { } #[public] - #['public] fn emit_unencrypted_events(preimages: [Field; 4]) { let event0 = ExampleEvent0 { value0: preimages[0], value1: preimages[1] }; diff --git a/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/main.nr b/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/main.nr index 3f8afba77d6..e9a024c4e06 100644 --- a/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/main.nr @@ -40,36 +40,31 @@ contract TokenBlacklist { // docs:start:constructor #[public] - #['public] - #['initializer] + #[initializer] fn constructor(admin: AztecAddress) { let admin_roles = UserFlags { is_admin: true, is_minter: false, is_blacklisted: false }; storage.roles.at(admin).schedule_value_change(admin_roles); } #[public] - #['public] - #['view] + #[view] fn total_supply() -> pub Field { storage.total_supply.read().to_field() } #[public] - #['public] - #['view] + #[view] fn balance_of_public(owner: AztecAddress) -> pub Field { storage.public_balances.at(owner).read().to_field() } #[public] - #['public] - #['view] + #[view] fn get_roles(user: AztecAddress) -> UserFlags { storage.roles.at(user).get_current_value_in_public() } #[public] - #['public] fn update_roles(user: AztecAddress, roles: UserFlags) { let caller_roles = storage.roles.at(context.msg_sender()).get_current_value_in_public(); assert(caller_roles.is_admin, "caller is not admin"); @@ -78,7 +73,6 @@ contract TokenBlacklist { } #[public] - #['public] fn mint_public(to: AztecAddress, amount: Field) { let to_roles = storage.roles.at(to).get_current_value_in_public(); assert(!to_roles.is_blacklisted, "Blacklisted: Recipient"); @@ -95,7 +89,6 @@ contract TokenBlacklist { } #[public] - #['public] fn mint_private(amount: Field, secret_hash: Field) { let caller_roles = storage.roles.at(context.msg_sender()).get_current_value_in_public(); assert(caller_roles.is_minter, "caller is not minter"); @@ -109,7 +102,6 @@ contract TokenBlacklist { } #[public] - #['public] fn shield(from: AztecAddress, amount: Field, secret_hash: Field, nonce: Field) { let from_roles = storage.roles.at(from).get_current_value_in_public(); assert(!from_roles.is_blacklisted, "Blacklisted: Sender"); @@ -132,7 +124,6 @@ contract TokenBlacklist { } #[public] - #['public] fn transfer_public(from: AztecAddress, to: AztecAddress, amount: Field, nonce: Field) { let from_roles = storage.roles.at(from).get_current_value_in_public(); assert(!from_roles.is_blacklisted, "Blacklisted: Sender"); @@ -154,7 +145,6 @@ contract TokenBlacklist { } #[public] - #['public] fn burn_public(from: AztecAddress, amount: Field, nonce: Field) { let from_roles = storage.roles.at(from).get_current_value_in_public(); assert(!from_roles.is_blacklisted, "Blacklisted: Sender"); @@ -174,7 +164,6 @@ contract TokenBlacklist { } #[private] - #['private] fn redeem_shield(to: AztecAddress, amount: Field, secret: Field) { let to_roles = storage.roles.at(to).get_current_value_in_private(); assert(!to_roles.is_blacklisted, "Blacklisted: Recipient"); @@ -200,7 +189,6 @@ contract TokenBlacklist { } #[private] - #['private] fn unshield(from: AztecAddress, to: AztecAddress, amount: Field, nonce: Field) { let from_roles = storage.roles.at(from).get_current_value_in_private(); assert(!from_roles.is_blacklisted, "Blacklisted: Sender"); @@ -221,7 +209,6 @@ contract TokenBlacklist { // docs:start:transfer_private #[private] - #['private] fn transfer(from: AztecAddress, to: AztecAddress, amount: Field, nonce: Field) { let from_roles = storage.roles.at(from).get_current_value_in_private(); assert(!from_roles.is_blacklisted, "Blacklisted: Sender"); @@ -245,7 +232,6 @@ contract TokenBlacklist { } #[private] - #['private] fn burn(from: AztecAddress, amount: Field, nonce: Field) { let from_roles = storage.roles.at(from).get_current_value_in_private(); assert(!from_roles.is_blacklisted, "Blacklisted: Sender"); @@ -264,7 +250,6 @@ contract TokenBlacklist { /// Internal /// #[public] - #['public] #['internal] fn _increase_public_balance(to: AztecAddress, amount: Field) { let new_balance = storage.public_balances.at(to).read().add(U128::from_integer(amount)); @@ -272,7 +257,6 @@ contract TokenBlacklist { } #[public] - #['public] #['internal] fn _reduce_total_supply(amount: Field) { // Only to be called from burn. diff --git a/noir-projects/noir-contracts/contracts/token_bridge_contract/src/main.nr b/noir-projects/noir-contracts/contracts/token_bridge_contract/src/main.nr index ee6be4f8ea7..279121518c2 100644 --- a/noir-projects/noir-contracts/contracts/token_bridge_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/token_bridge_contract/src/main.nr @@ -28,8 +28,7 @@ contract TokenBridge { // Constructs the contract. #[public] - #['public] - #['initializer] + #[initializer] fn constructor(token: AztecAddress, portal_address: EthAddress) { storage.token.write(token); storage.portal_address.initialize(portal_address); @@ -37,13 +36,11 @@ contract TokenBridge { // docs:end:token_bridge_storage_and_constructor #[private] - #['private] fn get_portal_address() -> EthAddress { storage.portal_address.read_private() } #[public] - #['public] fn get_portal_address_public() -> EthAddress { storage.portal_address.read_public() } @@ -51,7 +48,6 @@ contract TokenBridge { // docs:start:claim_public // Consumes a L1->L2 message and calls the token contract to mint the appropriate amount publicly #[public] - #['public] fn claim_public(to: AztecAddress, amount: Field, secret: Field, message_leaf_index: Field) { let content_hash = get_mint_public_content_hash(to, amount); @@ -72,7 +68,6 @@ contract TokenBridge { // Burns the appropriate amount of tokens and creates a L2 to L1 withdraw message publicly // Requires `msg.sender` to give approval to the bridge to burn tokens on their behalf using witness signatures #[public] - #['public] fn exit_to_l1_public( recipient: EthAddress, // ethereum address to withdraw to amount: Field, @@ -92,7 +87,6 @@ contract TokenBridge { // User needs to call token.redeem_shield() to get the private assets // TODO(#8416): Consider creating a truly private claim flow. #[private] - #['private] fn claim_private( secret_hash_for_redeeming_minted_notes: Field, // secret hash used to redeem minted notes at a later time. This enables anyone to call this function and mint tokens to a user on their behalf amount: Field, @@ -118,7 +112,6 @@ contract TokenBridge { // Burns the appropriate amount of tokens and creates a L2 to L1 withdraw message privately // Requires `msg.sender` (caller of the method) to give approval to the bridge to burn tokens on their behalf using witness signatures #[private] - #['private] fn exit_to_l1_private( token: AztecAddress, recipient: EthAddress, // ethereum address to withdraw to @@ -141,8 +134,7 @@ contract TokenBridge { /// docs:end:exit_to_l1_private // docs:start:get_token #[public] - #['public] - #['view] + #[view] fn get_token() -> AztecAddress { storage.token.read() } @@ -153,7 +145,6 @@ contract TokenBridge { // Also, note that user hashes their secret in private and only sends the hash in public // meaning only user can `redeem_shield` at a later time with their secret. #[public] - #['public] #['internal] fn _call_mint_on_token(amount: Field, secret_hash: Field) { Token::at(storage.token.read()).mint_private(amount, secret_hash).call(&mut context); @@ -162,7 +153,6 @@ contract TokenBridge { // docs:start:assert_token_is_same #[public] - #['public] #['internal] fn _assert_token_is_same(token: AztecAddress) { assert(storage.token.read().eq(token), "Token address is not the same as seen in storage"); 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 8097676dfe9..330664e4dde 100644 --- a/noir-projects/noir-contracts/contracts/token_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/token_contract/src/main.nr @@ -83,8 +83,7 @@ contract Token { // docs:start:constructor #[public] - #['public] - #['initializer] + #[initializer] fn constructor(admin: AztecAddress, name: str<31>, symbol: str<31>, decimals: u8) { assert(!admin.is_zero(), "invalid admin"); storage.admin.write(admin); @@ -98,7 +97,6 @@ contract Token { // docs:end:constructor // docs:start:set_admin #[public] - #['public] fn set_admin(new_admin: AztecAddress) { assert(storage.admin.read().eq(context.msg_sender()), "caller is not admin"); // docs:start:write_admin @@ -107,41 +105,35 @@ contract Token { } // docs:end:set_admin #[public] - #['public] - #['view] + #[view] fn public_get_name() -> FieldCompressedString { storage.name.read_public() } #[private] - #['private] - #['view] + #[view] fn private_get_name() -> FieldCompressedString { storage.name.read_private() } #[public] - #['public] - #['view] + #[view] fn public_get_symbol() -> pub FieldCompressedString { storage.symbol.read_public() } #[private] - #['private] - #['view] + #[view] fn private_get_symbol() -> pub FieldCompressedString { storage.symbol.read_private() } #[public] - #['public] - #['view] + #[view] fn public_get_decimals() -> pub u8 { // docs:start:read_decimals_public storage.decimals.read_public() // docs:end:read_decimals_public } #[private] - #['private] - #['view] + #[view] fn private_get_decimals() -> pub u8 { // docs:start:read_decimals_private storage.decimals.read_private() @@ -149,39 +141,34 @@ contract Token { } // docs:start:admin #[public] - #['public] - #['view] + #[view] fn get_admin() -> Field { storage.admin.read().to_field() } // docs:end:admin // docs:start:is_minter #[public] - #['public] - #['view] + #[view] fn is_minter(minter: AztecAddress) -> bool { storage.minters.at(minter).read() } // docs:end:is_minter // docs:start:total_supply #[public] - #['public] - #['view] + #[view] fn total_supply() -> Field { storage.total_supply.read().to_integer() } // docs:end:total_supply // docs:start:balance_of_public #[public] - #['public] - #['view] + #[view] fn balance_of_public(owner: AztecAddress) -> Field { storage.public_balances.at(owner).read().to_integer() } // docs:end:balance_of_public // docs:start:set_minter #[public] - #['public] fn set_minter(minter: AztecAddress, approve: bool) { // docs:start:read_admin assert(storage.admin.read().eq(context.msg_sender()), "caller is not admin"); @@ -193,7 +180,6 @@ contract Token { // docs:end:set_minter // docs:start:mint_public #[public] - #['public] fn mint_public(to: AztecAddress, amount: Field) { // docs:start:read_minter assert(storage.minters.at(context.msg_sender()).read(), "caller is not minter"); @@ -207,7 +193,6 @@ contract Token { // docs:end:mint_public // docs:start:mint_private #[public] - #['public] fn mint_private(amount: Field, secret_hash: Field) { assert(storage.minters.at(context.msg_sender()).read(), "caller is not minter"); let pending_shields = storage.pending_shields; @@ -221,7 +206,6 @@ contract Token { // docs:end:mint_private // TODO: Nuke this - test functions do not belong to token contract! #[private] - #['private] fn privately_mint_private_note(amount: Field) { let caller = context.msg_sender(); let caller_keys = get_public_keys(caller); @@ -229,7 +213,6 @@ contract Token { Token::at(context.this_address()).assert_minter_and_mint(context.msg_sender(), amount).enqueue(&mut context); } #[public] - #['public] #['internal] fn assert_minter_and_mint(minter: AztecAddress, amount: Field) { assert(storage.minters.at(minter).read(), "caller is not minter"); @@ -238,7 +221,6 @@ contract Token { } // docs:start:shield #[public] - #['public] fn shield(from: AztecAddress, amount: Field, secret_hash: Field, nonce: Field) { if (!from.eq(context.msg_sender())) { // The redeem is only spendable once, so we need to ensure that you cannot insert multiple shields from the same message. @@ -256,7 +238,6 @@ contract Token { // docs:end:shield // docs:start:transfer_public #[public] - #['public] fn transfer_public(from: AztecAddress, to: AztecAddress, amount: Field, nonce: Field) { if (!from.eq(context.msg_sender())) { assert_current_call_valid_authwit_public(&mut context, from); @@ -272,7 +253,6 @@ contract Token { // docs:end:transfer_public // docs:start:burn_public #[public] - #['public] fn burn_public(from: AztecAddress, amount: Field, nonce: Field) { // docs:start:assert_current_call_valid_authwit_public if (!from.eq(context.msg_sender())) { @@ -290,7 +270,6 @@ contract Token { // docs:end:burn_public // docs:start:redeem_shield #[private] - #['private] fn redeem_shield(to: AztecAddress, amount: Field, secret: Field) { let secret_hash = compute_secret_hash(secret); // Pop 1 note (set_limit(1)) which has an amount stored in a field with index 0 (select(0, amount)) and @@ -314,7 +293,6 @@ contract Token { // docs:end:redeem_shield // docs:start:unshield #[private] - #['private] fn unshield(from: AztecAddress, to: AztecAddress, amount: Field, nonce: Field) { if (!from.eq(context.msg_sender())) { assert_current_call_valid_authwit(&mut context, from); @@ -329,7 +307,6 @@ contract Token { // docs:end:unshield // docs:start:transfer #[private] - #['private] fn transfer(to: AztecAddress, amount: Field) { let from = context.msg_sender(); @@ -400,7 +377,6 @@ contract Token { // serialization issues. #['internal] #[private] - #['private] fn _recurse_subtract_balance(account: AztecAddress, amount: Field) -> U128 { subtract_balance( &mut context, @@ -416,7 +392,6 @@ contract Token { */ // docs:start:cancel_authwit #[private] - #['private] fn cancel_authwit(inner_hash: Field) { let on_behalf_of = context.msg_sender(); let nullifier = compute_authwit_nullifier(on_behalf_of, inner_hash); @@ -425,7 +400,6 @@ contract Token { // docs:end:cancel_authwit // docs:start:transfer_from #[private] - #['private] fn transfer_from(from: AztecAddress, to: AztecAddress, amount: Field, nonce: Field) { // docs:start:assert_current_call_valid_authwit if (!from.eq(context.msg_sender())) { @@ -449,7 +423,6 @@ contract Token { // docs:end:transfer_from // docs:start:burn #[private] - #['private] fn burn(from: AztecAddress, amount: Field, nonce: Field) { if (!from.eq(context.msg_sender())) { assert_current_call_valid_authwit(&mut context, from); @@ -482,7 +455,6 @@ contract Token { /// the public `complete_refund(...)` function. // docs:start:setup_refund #[private] - #['private] fn setup_refund( fee_payer: AztecAddress, // Address of the entity which will receive the fee note. user: AztecAddress, // A user for which we are setting up the fee refund. @@ -568,7 +540,6 @@ contract Token { // to serialization issues. // docs:start:complete_refund #[public] - #['public] #['internal] fn complete_refund(fee_payer_point: Point, user_point: Point, funded_amount: Field) { // TODO(#7728): Remove the next line @@ -602,7 +573,6 @@ contract Token { /// Internal /// // docs:start:increase_public_balance #[public] - #['public] #['internal] fn _increase_public_balance(to: AztecAddress, amount: Field) { let new_balance = storage.public_balances.at(to).read().add(U128::from_integer(amount)); @@ -611,7 +581,6 @@ contract Token { // docs:end:increase_public_balance // docs:start:reduce_total_supply #[public] - #['public] #['internal] fn _reduce_total_supply(amount: Field) { // Only to be called from burn. diff --git a/noir-projects/noir-contracts/contracts/uniswap_contract/src/main.nr b/noir-projects/noir-contracts/contracts/uniswap_contract/src/main.nr index 4eedebb2a91..a1d5cb9c65d 100644 --- a/noir-projects/noir-contracts/contracts/uniswap_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/uniswap_contract/src/main.nr @@ -23,8 +23,7 @@ contract Uniswap { } #[public] - #['public] - #['initializer] + #[initializer] fn constructor(portal_address: EthAddress) { storage.portal_address.initialize(portal_address); } @@ -32,7 +31,6 @@ contract Uniswap { // docs:start:swap_public #[public] - #['public] fn swap_public( sender: AztecAddress, input_asset_bridge: AztecAddress, @@ -94,7 +92,6 @@ contract Uniswap { // docs:start:swap_private #[private] - #['private] fn swap_private( input_asset: AztecAddress, // since private, we pass here and later assert that this is as expected by input_bridge input_asset_bridge: AztecAddress, @@ -158,7 +155,6 @@ contract Uniswap { // Note that private can't read public return values so created an internal public that handles everything // this method is used for both private and public swaps. #[public] - #['public] #['internal] fn _approve_bridge_and_exit_input_asset_to_L1( token: AztecAddress, @@ -190,9 +186,8 @@ contract Uniswap { // docs:start:assert_token_is_same #[public] - #['public] #['internal] - #['view] + #[view] fn _assert_token_is_same(token: AztecAddress, token_bridge: AztecAddress) { assert( token.eq(TokenBridge::at(token_bridge).get_token().view(&mut context)), "input_asset address is not the same as seen in the bridge contract" From b61c48eb94621d027571c50151a6e090dbc17213 Mon Sep 17 00:00:00 2001 From: TomAFrench Date: Tue, 15 Oct 2024 08:26:10 +0000 Subject: [PATCH 02/14] fix: add missing imports --- .../noir-contracts/contracts/auth_registry_contract/src/main.nr | 2 +- .../noir-contracts/contracts/lending_contract/src/main.nr | 2 +- .../noir-contracts/contracts/token_bridge_contract/src/main.nr | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/noir-projects/noir-contracts/contracts/auth_registry_contract/src/main.nr b/noir-projects/noir-contracts/contracts/auth_registry_contract/src/main.nr index 6293a1967de..9db9c7b8d71 100644 --- a/noir-projects/noir-contracts/contracts/auth_registry_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/auth_registry_contract/src/main.nr @@ -4,7 +4,7 @@ use dep::aztec::macros::aztec; contract AuthRegistry { use dep::aztec::{ state_vars::{PublicMutable, Map}, protocol_types::address::AztecAddress, - macros::{storage::storage, functions::{private, public, internal}} + macros::{storage::storage, functions::{private, public, internal, view}} }; use dep::authwit::auth::{IS_VALID_SELECTOR, compute_authwit_message_hash, assert_current_call_valid_authwit}; diff --git a/noir-projects/noir-contracts/contracts/lending_contract/src/main.nr b/noir-projects/noir-contracts/contracts/lending_contract/src/main.nr index 664499acb2d..8c81ade4d9b 100644 --- a/noir-projects/noir-contracts/contracts/lending_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/lending_contract/src/main.nr @@ -23,7 +23,7 @@ contract Lending { use dep::token::Token; use dep::price_feed::PriceFeed; - use dep::aztec::macros::{storage::storage, functions::{private, public, initializer, internal}}; + use dep::aztec::macros::{storage::storage, functions::{private, public, initializer, internal, view}}; // Storage structure, containing all storage, and specifying what slots they use. #[storage] diff --git a/noir-projects/noir-contracts/contracts/token_bridge_contract/src/main.nr b/noir-projects/noir-contracts/contracts/token_bridge_contract/src/main.nr index 279121518c2..30267cb9491 100644 --- a/noir-projects/noir-contracts/contracts/token_bridge_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/token_bridge_contract/src/main.nr @@ -15,7 +15,7 @@ contract TokenBridge { use dep::token::Token; - use dep::aztec::macros::{storage::storage, functions::{public, initializer, private, internal}}; + use dep::aztec::macros::{storage::storage, functions::{public, initializer, private, internal, view}}; // docs:end:token_bridge_imports // docs:start:token_bridge_storage_and_constructor From b1241b949add804738a68017ef7ae912554e470b Mon Sep 17 00:00:00 2001 From: TomAFrench Date: Tue, 15 Oct 2024 08:51:46 +0000 Subject: [PATCH 03/14] . --- .../aztec-nr/aztec/src/macros/dispatch/mod.nr | 1 - noir-projects/aztec-nr/aztec/src/macros/storage/mod.nr | 4 +++- .../contracts/auth_registry_contract/src/main.nr | 2 +- .../contracts/card_game_contract/src/main.nr | 6 +++--- .../contracts/child_contract/src/main.nr | 4 ++-- .../contracts/crowdfunding_contract/src/main.nr | 2 +- .../contracts/docs_example_contract/src/main.nr | 4 ++-- .../contracts/easy_private_voting_contract/src/main.nr | 2 +- .../contracts/fee_juice_contract/src/main.nr | 2 +- .../noir-contracts/contracts/fpc_contract/src/main.nr | 6 +++--- .../contracts/lending_contract/src/main.nr | 8 ++++---- .../noir-contracts/contracts/nft_contract/src/main.nr | 4 ++-- .../contracts/pending_note_hashes_contract/src/main.nr | 1 - .../contracts/router_contract/src/main.nr | 4 ++-- .../noir-contracts/contracts/spam_contract/src/main.nr | 2 +- .../noir-contracts/contracts/test_contract/src/main.nr | 3 +-- .../contracts/token_blacklist_contract/src/main.nr | 4 ++-- .../contracts/token_bridge_contract/src/main.nr | 4 ++-- .../contracts/token_contract/src/main.nr | 10 +++++----- .../contracts/uniswap_contract/src/main.nr | 4 ++-- 20 files changed, 38 insertions(+), 39 deletions(-) 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 47172e72d7f..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,6 @@ 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] - #['public] pub unconstrained fn public_dispatch(selector: Field) { $dispatch } diff --git a/noir-projects/aztec-nr/aztec/src/macros/storage/mod.nr b/noir-projects/aztec-nr/aztec/src/macros/storage/mod.nr index 391f6cc874b..54211986ad2 100644 --- a/noir-projects/aztec-nr/aztec/src/macros/storage/mod.nr +++ b/noir-projects/aztec-nr/aztec/src/macros/storage/mod.nr @@ -87,7 +87,9 @@ pub comptime fn storage(s: StructDefinition) -> Quoted { /// with signature `fn init(context: Context) -> Self`, which allows for manual control of storage slot /// allocation. Similarly, no `StorageLayout` struct will be created. /// Only a single struct in the entire contract should have this macro (or `storage`) applied to it. -pub comptime fn storage_no_init(_s: StructDefinition) { +pub comptime fn storage_no_init(s: StructDefinition) { + s.add_attribute("storage_no_init"); + // All `storage` does is provide the `init` implementation, so we don't need to do anything here. Applying this // macro however will cause for `macros::utils::module_has_storage` to return true, resulting in the injection of // the `storage` variable. diff --git a/noir-projects/noir-contracts/contracts/auth_registry_contract/src/main.nr b/noir-projects/noir-contracts/contracts/auth_registry_contract/src/main.nr index 9db9c7b8d71..74e7e14cd0e 100644 --- a/noir-projects/noir-contracts/contracts/auth_registry_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/auth_registry_contract/src/main.nr @@ -93,7 +93,7 @@ contract AuthRegistry { * @param authorize True if the caller is authorized to perform the message hash, false otherwise */ #[public] - #['internal] + #[internal] fn _set_authorized(approver: AztecAddress, message_hash: Field, authorize: bool) { storage.approved_actions.at(approver).at(message_hash).write(authorize); } diff --git a/noir-projects/noir-contracts/contracts/card_game_contract/src/main.nr b/noir-projects/noir-contracts/contracts/card_game_contract/src/main.nr index 0b28831ae34..095f870193b 100644 --- a/noir-projects/noir-contracts/contracts/card_game_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/card_game_contract/src/main.nr @@ -46,7 +46,7 @@ contract CardGame { } #[public] - #['internal] + #[internal] fn on_game_joined(game: u32, player: AztecAddress, deck_strength: u32) { let game_storage = storage.games.at(game as Field); @@ -78,7 +78,7 @@ contract CardGame { } #[public] - #['internal] + #[internal] fn on_card_played(game: u32, player: AztecAddress, card_as_field: Field) { let game_storage = storage.games.at(game as Field); @@ -103,7 +103,7 @@ contract CardGame { } #[public] - #['internal] + #[internal] fn on_cards_claimed(game: u32, player: AztecAddress, cards_hash: Field) { let game_storage = storage.games.at(game as Field); let mut game_data = game_storage.read(); diff --git a/noir-projects/noir-contracts/contracts/child_contract/src/main.nr b/noir-projects/noir-contracts/contracts/child_contract/src/main.nr index 9e595672b2e..04a90c9a08d 100644 --- a/noir-projects/noir-contracts/contracts/child_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/child_contract/src/main.nr @@ -27,7 +27,7 @@ contract Child { // Returns a sum of the input and the chain id and version of the contract in private circuit public input's return_values. // Can only be called from this contract. #[private] - #['internal] + #[internal] fn value_internal(input: Field) -> Field { input + context.chain_id() + context.version() } @@ -82,7 +82,7 @@ contract Child { // Increments `current_value` by `new_value`. Can only be called from this contract. #[public] - #['internal] + #[internal] fn pub_inc_value_internal(new_value: Field) -> Field { let old_value = storage.current_value.read(); storage.current_value.write(old_value + new_value); diff --git a/noir-projects/noir-contracts/contracts/crowdfunding_contract/src/main.nr b/noir-projects/noir-contracts/contracts/crowdfunding_contract/src/main.nr index 6b5ff5b4887..a6c6b183041 100644 --- a/noir-projects/noir-contracts/contracts/crowdfunding_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/crowdfunding_contract/src/main.nr @@ -100,7 +100,7 @@ contract Crowdfunding { // docs:end:operator-withdrawals #[public] - #['internal] + #[internal] fn _publish_donation_receipts(amount: u64, to: AztecAddress) { WithdrawalProcessed { amount, who: to }.emit(encode_event(&mut context)); } diff --git a/noir-projects/noir-contracts/contracts/docs_example_contract/src/main.nr b/noir-projects/noir-contracts/contracts/docs_example_contract/src/main.nr index bf0e71e558b..c62ddf6663d 100644 --- a/noir-projects/noir-contracts/contracts/docs_example_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/docs_example_contract/src/main.nr @@ -29,7 +29,7 @@ contract DocsExample { // how to import methods from other files/folders within your workspace use crate::types::{card_note::CardNote, leader::Leader}; - #['storage_no_init] + #[storage_no_init] struct Storage { // Shows how to create a custom struct in PublicMutable // docs:start:storage-leader-declaration @@ -290,7 +290,7 @@ contract DocsExample { 1 } #[public] - #['internal] + #[internal] fn update_leader(account: AztecAddress, points: u8) { let new_leader = Leader { account, points }; storage.leader.write(new_leader); diff --git a/noir-projects/noir-contracts/contracts/easy_private_voting_contract/src/main.nr b/noir-projects/noir-contracts/contracts/easy_private_voting_contract/src/main.nr index 8d5a4997b0f..5d65675ab8a 100644 --- a/noir-projects/noir-contracts/contracts/easy_private_voting_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/easy_private_voting_contract/src/main.nr @@ -45,7 +45,7 @@ contract EasyPrivateVoting { // docs:start:add_to_tally_public #[public] - #['internal] + #[internal] fn add_to_tally_public(candidate: Field) { assert(storage.vote_ended.read() == false, "Vote has ended"); // assert that vote has not ended let new_tally = storage.tally.at(candidate).read() + 1; diff --git a/noir-projects/noir-contracts/contracts/fee_juice_contract/src/main.nr b/noir-projects/noir-contracts/contracts/fee_juice_contract/src/main.nr index ea9b1923be4..910cd957ca8 100644 --- a/noir-projects/noir-contracts/contracts/fee_juice_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/fee_juice_contract/src/main.nr @@ -61,7 +61,7 @@ contract FeeJuice { } #[public] - #['internal] + #[internal] fn _increase_public_balance(to: AztecAddress, amount: Field) { let new_balance = storage.balances.at(to).read().add(U128::from_integer(amount)); storage.balances.at(to).write(new_balance); diff --git a/noir-projects/noir-contracts/contracts/fpc_contract/src/main.nr b/noir-projects/noir-contracts/contracts/fpc_contract/src/main.nr index d70c897e75e..33c966b0c45 100644 --- a/noir-projects/noir-contracts/contracts/fpc_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/fpc_contract/src/main.nr @@ -55,7 +55,7 @@ contract FPC { } #[public] - #['internal] + #[internal] fn prepare_fee(from: AztecAddress, amount: Field, asset: AztecAddress, nonce: Field) { // docs:start:public_call Token::at(asset).transfer_public(from, context.this_address(), amount, nonce).call(&mut context); @@ -63,7 +63,7 @@ contract FPC { } #[public] - #['internal] + #[internal] fn pay_refund(refund_address: AztecAddress, amount: Field, asset: AztecAddress) { // Just do public refunds for the present let refund = compute_rebate(context, amount); @@ -71,7 +71,7 @@ contract FPC { } #[public] - #['internal] + #[internal] fn pay_refund_with_shielded_rebate(amount: Field, asset: AztecAddress, secret_hash: Field) { let refund = compute_rebate(context, amount); Token::at(asset).shield(context.this_address(), refund, secret_hash, 0).call(&mut context); diff --git a/noir-projects/noir-contracts/contracts/lending_contract/src/main.nr b/noir-projects/noir-contracts/contracts/lending_contract/src/main.nr index 8c81ade4d9b..a9619d6782a 100644 --- a/noir-projects/noir-contracts/contracts/lending_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/lending_contract/src/main.nr @@ -124,7 +124,7 @@ contract Lending { } #[public] - #['internal] + #[internal] fn _deposit(owner: AztecAddress, amount: Field, collateral_asset: AztecAddress) { let _asset = Lending::at(context.this_address()).update_accumulator().call(&mut context); @@ -148,7 +148,7 @@ contract Lending { } #[public] - #['internal] + #[internal] fn _withdraw(owner: AztecAddress, recipient: AztecAddress, amount: Field) { let asset = Lending::at(context.this_address()).update_accumulator().call(&mut context); let price = PriceFeed::at(asset.oracle).get_price(0).view(&mut context).price; @@ -196,7 +196,7 @@ contract Lending { } #[public] - #['internal] + #[internal] fn _borrow(owner: AztecAddress, to: AztecAddress, amount: Field) { let asset = Lending::at(context.this_address()).update_accumulator().call(&mut context); let price = PriceFeed::at(asset.oracle).get_price(0).view(&mut context).price; @@ -251,7 +251,7 @@ contract Lending { } #[public] - #['internal] + #[internal] fn _repay(owner: AztecAddress, amount: Field, stable_coin: AztecAddress) { let asset = Lending::at(context.this_address()).update_accumulator().call(&mut context); diff --git a/noir-projects/noir-contracts/contracts/nft_contract/src/main.nr b/noir-projects/noir-contracts/contracts/nft_contract/src/main.nr index 3f5a9eaf6cc..6ec923ba8c2 100644 --- a/noir-projects/noir-contracts/contracts/nft_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/nft_contract/src/main.nr @@ -176,7 +176,7 @@ contract NFT { } #[public] - #['internal] + #[internal] fn _store_point_in_transient_storage(point: Point, slot: Field) { // We don't perform check for the overwritten value to be non-zero because the slots are siloed to `to` // and hence `to` can interfere only with his own execution. @@ -276,7 +276,7 @@ contract NFT { } #[public] - #['internal] + #[internal] fn _finish_transfer_to_public(to: AztecAddress, token_id: Field) { storage.public_owners.at(token_id).write(to); } diff --git a/noir-projects/noir-contracts/contracts/pending_note_hashes_contract/src/main.nr b/noir-projects/noir-contracts/contracts/pending_note_hashes_contract/src/main.nr index dcd8391242f..b70a5b5243a 100644 --- a/noir-projects/noir-contracts/contracts/pending_note_hashes_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/pending_note_hashes_contract/src/main.nr @@ -325,7 +325,6 @@ contract PendingNoteHashes { // it being present at that stage in the kernel. // If we can somehow force the simulator to allow execution to succeed can ensure that this test fails in the kernel // #[private] - // #['private] // fn test_bad_get_in_nested_call_then_insert( // amount: Field, // owner: AztecAddress, diff --git a/noir-projects/noir-contracts/contracts/router_contract/src/main.nr b/noir-projects/noir-contracts/contracts/router_contract/src/main.nr index 9414e1b4962..914b3829f75 100644 --- a/noir-projects/noir-contracts/contracts/router_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/router_contract/src/main.nr @@ -19,7 +19,7 @@ contract Router { } #[public] - #['internal] + #[internal] #[view] fn _check_timestamp(operation: u8, value: u64) { let lhs_field = context.timestamp() as Field; @@ -36,7 +36,7 @@ contract Router { } #[public] - #['internal] + #[internal] #[view] fn _check_block_number(operation: u8, value: Field) { assert(compare(context.block_number(), operation, value), "Block number mismatch."); diff --git a/noir-projects/noir-contracts/contracts/spam_contract/src/main.nr b/noir-projects/noir-contracts/contracts/spam_contract/src/main.nr index c55a5d10a75..e6206501fee 100644 --- a/noir-projects/noir-contracts/contracts/spam_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/spam_contract/src/main.nr @@ -61,7 +61,7 @@ contract Spam { } #[public] - #['internal] + #[internal] fn public_spam(start: u32, end: u32) { let one = U128::from_integer(1); for i in start..end { diff --git a/noir-projects/noir-contracts/contracts/test_contract/src/main.nr b/noir-projects/noir-contracts/contracts/test_contract/src/main.nr index f5d73e42292..d0e6b602575 100644 --- a/noir-projects/noir-contracts/contracts/test_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/test_contract/src/main.nr @@ -80,7 +80,7 @@ contract Test { } #[public] - #['internal] + #[internal] fn dummy_public_call() {} #[private] @@ -424,7 +424,6 @@ contract Test { // TODO(4840): add AVM opcodes for getting header (members) //#[public] - //#['public] //fn assert_header_public(header_hash: Field) { // assert(context.historical_header.hash() == header_hash, "Invalid header hash"); //} diff --git a/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/main.nr b/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/main.nr index e9a024c4e06..7640690f749 100644 --- a/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/token_blacklist_contract/src/main.nr @@ -250,14 +250,14 @@ contract TokenBlacklist { /// Internal /// #[public] - #['internal] + #[internal] fn _increase_public_balance(to: AztecAddress, amount: Field) { let new_balance = storage.public_balances.at(to).read().add(U128::from_integer(amount)); storage.public_balances.at(to).write(new_balance); } #[public] - #['internal] + #[internal] fn _reduce_total_supply(amount: Field) { // Only to be called from burn. let new_supply = storage.total_supply.read().sub(U128::from_integer(amount)); diff --git a/noir-projects/noir-contracts/contracts/token_bridge_contract/src/main.nr b/noir-projects/noir-contracts/contracts/token_bridge_contract/src/main.nr index 30267cb9491..a15be88cb4c 100644 --- a/noir-projects/noir-contracts/contracts/token_bridge_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/token_bridge_contract/src/main.nr @@ -145,7 +145,7 @@ contract TokenBridge { // Also, note that user hashes their secret in private and only sends the hash in public // meaning only user can `redeem_shield` at a later time with their secret. #[public] - #['internal] + #[internal] fn _call_mint_on_token(amount: Field, secret_hash: Field) { Token::at(storage.token.read()).mint_private(amount, secret_hash).call(&mut context); } @@ -153,7 +153,7 @@ contract TokenBridge { // docs:start:assert_token_is_same #[public] - #['internal] + #[internal] fn _assert_token_is_same(token: AztecAddress) { assert(storage.token.read().eq(token), "Token address is not the same as seen in storage"); } 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 330664e4dde..fe056215b44 100644 --- a/noir-projects/noir-contracts/contracts/token_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/token_contract/src/main.nr @@ -213,7 +213,7 @@ contract Token { Token::at(context.this_address()).assert_minter_and_mint(context.msg_sender(), amount).enqueue(&mut context); } #[public] - #['internal] + #[internal] fn assert_minter_and_mint(minter: AztecAddress, amount: Field) { assert(storage.minters.at(minter).read(), "caller is not minter"); let supply = storage.total_supply.read() + U128::from_integer(amount); @@ -375,7 +375,7 @@ contract Token { } // TODO(#7728): even though the amount should be a U128, we can't have that type in a contract interface due to // serialization issues. - #['internal] + #[internal] #[private] fn _recurse_subtract_balance(account: AztecAddress, amount: Field) -> U128 { subtract_balance( @@ -540,7 +540,7 @@ contract Token { // to serialization issues. // docs:start:complete_refund #[public] - #['internal] + #[internal] fn complete_refund(fee_payer_point: Point, user_point: Point, funded_amount: Field) { // TODO(#7728): Remove the next line let funded_amount = U128::from_integer(funded_amount); @@ -573,7 +573,7 @@ contract Token { /// Internal /// // docs:start:increase_public_balance #[public] - #['internal] + #[internal] fn _increase_public_balance(to: AztecAddress, amount: Field) { let new_balance = storage.public_balances.at(to).read().add(U128::from_integer(amount)); storage.public_balances.at(to).write(new_balance); @@ -581,7 +581,7 @@ contract Token { // docs:end:increase_public_balance // docs:start:reduce_total_supply #[public] - #['internal] + #[internal] fn _reduce_total_supply(amount: Field) { // Only to be called from burn. let new_supply = storage.total_supply.read().sub(U128::from_integer(amount)); diff --git a/noir-projects/noir-contracts/contracts/uniswap_contract/src/main.nr b/noir-projects/noir-contracts/contracts/uniswap_contract/src/main.nr index a1d5cb9c65d..66b5f4f60b9 100644 --- a/noir-projects/noir-contracts/contracts/uniswap_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/uniswap_contract/src/main.nr @@ -155,7 +155,7 @@ contract Uniswap { // Note that private can't read public return values so created an internal public that handles everything // this method is used for both private and public swaps. #[public] - #['internal] + #[internal] fn _approve_bridge_and_exit_input_asset_to_L1( token: AztecAddress, token_bridge: AztecAddress, @@ -186,7 +186,7 @@ contract Uniswap { // docs:start:assert_token_is_same #[public] - #['internal] + #[internal] #[view] fn _assert_token_is_same(token: AztecAddress, token_bridge: AztecAddress) { assert( From 528037b2a7d06f22b8034b5cbaee7b576beb8ed8 Mon Sep 17 00:00:00 2001 From: TomAFrench Date: Tue, 15 Oct 2024 08:55:13 +0000 Subject: [PATCH 04/14] . --- .../noir-contracts/contracts/docs_example_contract/src/main.nr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/noir-projects/noir-contracts/contracts/docs_example_contract/src/main.nr b/noir-projects/noir-contracts/contracts/docs_example_contract/src/main.nr index c62ddf6663d..99d6bb7a666 100644 --- a/noir-projects/noir-contracts/contracts/docs_example_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/docs_example_contract/src/main.nr @@ -23,7 +23,7 @@ contract DocsExample { use dep::aztec::{ encrypted_logs::encrypted_note_emission::encode_and_encrypt_note, keys::getters::get_public_keys, - macros::{storage::storage, functions::{public, private, internal, view}} + macros::{storage::{storage, storage_no_init}, functions::{public, private, internal, view}} }; // how to import methods from other files/folders within your workspace From d9f6a2da8b9c5b52b160b281a18e6a42af436fb6 Mon Sep 17 00:00:00 2001 From: TomAFrench Date: Tue, 15 Oct 2024 13:19:03 +0000 Subject: [PATCH 05/14] . --- noir-projects/noir-contracts/contracts/fpc_contract/src/main.nr | 2 +- .../noir-contracts/contracts/token_contract/src/main.nr | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/noir-projects/noir-contracts/contracts/fpc_contract/src/main.nr b/noir-projects/noir-contracts/contracts/fpc_contract/src/main.nr index 33c966b0c45..aee2342072e 100644 --- a/noir-projects/noir-contracts/contracts/fpc_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/fpc_contract/src/main.nr @@ -7,7 +7,7 @@ contract FPC { use dep::aztec::{ protocol_types::{abis::function_selector::FunctionSelector, address::AztecAddress}, state_vars::SharedImmutable, - macros::{storage::storage, functions::{private, public, initializer}} + macros::{storage::storage, functions::{private, public, initializer, internal}} }; use dep::token::Token; use crate::lib::compute_rebate; 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 fe056215b44..ae6c9c5b828 100644 --- a/noir-projects/noir-contracts/contracts/token_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/token_contract/src/main.nr @@ -27,7 +27,7 @@ contract Token { encrypted_event_emission::encode_and_encrypt_event_unconstrained }, keys::getters::get_public_keys, - macros::{storage::storage, events::event, functions::{initializer, private, view, public}}, + macros::{storage::storage, events::event, functions::{initializer, private, view, public, internal}}, utils::comparison::Comparator, protocol_types::{point::Point, traits::Serialize} }; From 9ec508568e2c387c29f0ef25bca6e3f8f9725809 Mon Sep 17 00:00:00 2001 From: TomAFrench Date: Tue, 15 Oct 2024 16:18:21 +0000 Subject: [PATCH 06/14] chore: force `contract_library_method` as custom tag --- noir/noir-repo/compiler/noirc_driver/src/lib.rs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/noir/noir-repo/compiler/noirc_driver/src/lib.rs b/noir/noir-repo/compiler/noirc_driver/src/lib.rs index 64cb6083c7c..b4a9d5aea25 100644 --- a/noir/noir-repo/compiler/noirc_driver/src/lib.rs +++ b/noir/noir-repo/compiler/noirc_driver/src/lib.rs @@ -450,14 +450,16 @@ fn compile_contract_inner( .attributes .secondary .iter() - .filter_map(|attr| { - if let SecondaryAttribute::Tag(attribute) = attr { - Some(&attribute.contents) - } else { - None - } + .filter_map(|attr| + match attr { + SecondaryAttribute::Tag(attribute) => { + Some(attribute.contents.clone()) + }, + SecondaryAttribute::ContractLibraryMethod => { + Some("contract_library_method".to_string()) + }, + _ => None }) - .cloned() .collect(); functions.push(ContractFunction { From 3b8bfd18983f1aa863f0d8853af5a79bc485bff1 Mon Sep 17 00:00:00 2001 From: TomAFrench Date: Thu, 17 Oct 2024 18:47:20 +0000 Subject: [PATCH 07/14] fix: add meta attributes to `custom_attributes` --- .../noirc_frontend/src/hir/comptime/interpreter/builtin.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/noir/noir-repo/compiler/noirc_frontend/src/hir/comptime/interpreter/builtin.rs b/noir/noir-repo/compiler/noirc_frontend/src/hir/comptime/interpreter/builtin.rs index 15ceffa3e97..eb514103103 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/hir/comptime/interpreter/builtin.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/hir/comptime/interpreter/builtin.rs @@ -2252,7 +2252,7 @@ fn function_def_add_attribute( } } - if let Attribute::Secondary(SecondaryAttribute::Tag(attribute)) = attribute { + if let Attribute::Secondary(SecondaryAttribute::Tag(attribute)| SecondaryAttribute::Meta(attribute)) = attribute { let func_meta = interpreter.elaborator.interner.function_meta_mut(&func_id); func_meta.custom_attributes.push(attribute); } From c7c10a01fdc4c6dd088953a9ebf887b99f716988 Mon Sep 17 00:00:00 2001 From: TomAFrench Date: Thu, 17 Oct 2024 18:49:56 +0000 Subject: [PATCH 08/14] chore: revert useless bodies of macros --- .../aztec-nr/aztec/src/macros/functions/mod.nr | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr b/noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr index 7a8112fed78..fe27f19efae 100644 --- a/noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr +++ b/noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr @@ -22,8 +22,8 @@ use interfaces::{create_fn_abi_export, register_stub, stub_fn}; // Therefore, the execution order of `#[internal]` and `#[private]` is irrelevant. /// Internal functions can only be called by the contract itself, typically from private into public. -pub comptime fn internal(f: FunctionDefinition) { - f.add_attribute("internal") +pub comptime fn internal(_f: FunctionDefinition) { + // Marker attribute } comptime fn create_internal_check(f: FunctionDefinition) -> Quoted { @@ -33,8 +33,8 @@ comptime fn create_internal_check(f: FunctionDefinition) -> Quoted { } /// View functions can only be called in a static execution context. -pub comptime fn view(f: FunctionDefinition) { - f.add_attribute("view") +pub comptime fn view(_f: FunctionDefinition) { + // Marker attribute } comptime fn create_view_check(f: FunctionDefinition) -> Quoted { @@ -53,13 +53,13 @@ comptime fn create_view_check(f: FunctionDefinition) -> Quoted { /// - it can only be called once /// - if there are multiple initializer functions, only one of them can be called /// - no non-initializer functions can be called until an initializer has ben called (except `noinitcheck` functions) -pub comptime fn initializer(f: FunctionDefinition) { - f.add_attribute("initializer") +pub comptime fn initializer(_f: FunctionDefinition) { + // Marker attribute } /// Functions with noinitcheck can be called before contract initialization. -pub comptime fn noinitcheck(f: FunctionDefinition) { - f.add_attribute("noinitcheck") +pub comptime fn noinitcheck(_f: FunctionDefinition) { + // Marker attribute } comptime fn create_assert_correct_initializer_args(f: FunctionDefinition) -> Quoted { From 8815a338d1b39e77c79c415fc656b4eada082ef2 Mon Sep 17 00:00:00 2001 From: TomAFrench Date: Thu, 17 Oct 2024 18:50:54 +0000 Subject: [PATCH 09/14] . --- noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr | 4 ---- noir-projects/aztec-nr/aztec/src/macros/storage/mod.nr | 2 -- 2 files changed, 6 deletions(-) diff --git a/noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr b/noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr index fe27f19efae..e46eecab75b 100644 --- a/noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr +++ b/noir-projects/aztec-nr/aztec/src/macros/functions/mod.nr @@ -79,8 +79,6 @@ comptime fn create_init_check(f: FunctionDefinition) -> Quoted { /// Private functions are executed client-side and preserve privacy. pub comptime fn private(f: FunctionDefinition) -> Quoted { - f.add_attribute("private"); - let fn_abi = create_fn_abi_export(f); let fn_stub = stub_fn(f); register_stub(f.module(), fn_stub); @@ -227,8 +225,6 @@ pub comptime fn private(f: FunctionDefinition) -> Quoted { /// Public functions are executed sequencer-side and do not preserve privacy, similar to the EVM. pub comptime fn public(f: FunctionDefinition) -> Quoted { - f.add_attribute("public"); - // We don't want to transform the public_dispatch function. if f.name() == quote { public_dispatch } { quote {} diff --git a/noir-projects/aztec-nr/aztec/src/macros/storage/mod.nr b/noir-projects/aztec-nr/aztec/src/macros/storage/mod.nr index 54211986ad2..8821ff18373 100644 --- a/noir-projects/aztec-nr/aztec/src/macros/storage/mod.nr +++ b/noir-projects/aztec-nr/aztec/src/macros/storage/mod.nr @@ -88,8 +88,6 @@ pub comptime fn storage(s: StructDefinition) -> Quoted { /// allocation. Similarly, no `StorageLayout` struct will be created. /// Only a single struct in the entire contract should have this macro (or `storage`) applied to it. pub comptime fn storage_no_init(s: StructDefinition) { - s.add_attribute("storage_no_init"); - // All `storage` does is provide the `init` implementation, so we don't need to do anything here. Applying this // macro however will cause for `macros::utils::module_has_storage` to return true, resulting in the injection of // the `storage` variable. From 98abe475b211d713e30c5c5e6c13931131e48af9 Mon Sep 17 00:00:00 2001 From: TomAFrench Date: Thu, 17 Oct 2024 18:54:14 +0000 Subject: [PATCH 10/14] . --- noir/noir-repo/compiler/noirc_driver/src/lib.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/noir/noir-repo/compiler/noirc_driver/src/lib.rs b/noir/noir-repo/compiler/noirc_driver/src/lib.rs index b4a9d5aea25..c302964b434 100644 --- a/noir/noir-repo/compiler/noirc_driver/src/lib.rs +++ b/noir/noir-repo/compiler/noirc_driver/src/lib.rs @@ -452,13 +452,10 @@ fn compile_contract_inner( .iter() .filter_map(|attr| match attr { - SecondaryAttribute::Tag(attribute) => { + SecondaryAttribute::Tag(attribute) | SecondaryAttribute::Meta(attribute) => { Some(attribute.contents.clone()) }, - SecondaryAttribute::ContractLibraryMethod => { - Some("contract_library_method".to_string()) - }, - _ => None + _ => None }) .collect(); From 15d2984e8693b08192c798ffed1c8304fdb7210c Mon Sep 17 00:00:00 2001 From: TomAFrench Date: Thu, 17 Oct 2024 18:55:08 +0000 Subject: [PATCH 11/14] . --- noir-projects/aztec-nr/aztec/src/macros/storage/mod.nr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/noir-projects/aztec-nr/aztec/src/macros/storage/mod.nr b/noir-projects/aztec-nr/aztec/src/macros/storage/mod.nr index 8821ff18373..391f6cc874b 100644 --- a/noir-projects/aztec-nr/aztec/src/macros/storage/mod.nr +++ b/noir-projects/aztec-nr/aztec/src/macros/storage/mod.nr @@ -87,7 +87,7 @@ pub comptime fn storage(s: StructDefinition) -> Quoted { /// with signature `fn init(context: Context) -> Self`, which allows for manual control of storage slot /// allocation. Similarly, no `StorageLayout` struct will be created. /// Only a single struct in the entire contract should have this macro (or `storage`) applied to it. -pub comptime fn storage_no_init(s: StructDefinition) { +pub comptime fn storage_no_init(_s: StructDefinition) { // All `storage` does is provide the `init` implementation, so we don't need to do anything here. Applying this // macro however will cause for `macros::utils::module_has_storage` to return true, resulting in the injection of // the `storage` variable. From 475f0763ed01f5b2a044d3cbce2cd70a6108eae3 Mon Sep 17 00:00:00 2001 From: TomAFrench Date: Thu, 17 Oct 2024 19:17:10 +0000 Subject: [PATCH 12/14] . --- .../acvm_js/test/shared/complex_foreign_call.ts | 11 ++++++++++- .../acvm-repo/acvm_js/test/shared/foreign_call.ts | 8 +++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/noir/noir-repo/acvm-repo/acvm_js/test/shared/complex_foreign_call.ts b/noir/noir-repo/acvm-repo/acvm_js/test/shared/complex_foreign_call.ts index 3048b74e51f..8eb7b7d5059 100644 --- a/noir/noir-repo/acvm-repo/acvm_js/test/shared/complex_foreign_call.ts +++ b/noir/noir-repo/acvm-repo/acvm_js/test/shared/complex_foreign_call.ts @@ -1,7 +1,16 @@ import { WitnessMap } from '@noir-lang/acvm_js'; // See `complex_brillig_foreign_call` integration test in `acir/tests/test_program_serialization.rs`. -export const bytecode = Uint8Array.from([31, 139, 8, 0, 0, 0, 0, 0, 0, 255, 213, 85, 93, 10, 194, 48, 12, 78, 155, 233, 54, 240, 205, 11, 8, 122, 128, 76, 47, 176, 187, 136, 111, 138, 62, 122, 124, 45, 75, 88, 23, 139, 19, 76, 64, 63, 24, 89, 75, 242, 229, 159, 6, 24, 208, 60, 191, 192, 255, 11, 150, 145, 101, 186, 71, 152, 66, 116, 123, 150, 244, 29, 186, 96, 199, 69, 94, 49, 198, 63, 136, 17, 29, 98, 132, 172, 255, 63, 216, 111, 203, 190, 152, 214, 15, 11, 251, 83, 193, 176, 95, 75, 62, 215, 44, 27, 93, 232, 100, 20, 225, 117, 241, 38, 144, 233, 105, 149, 4, 229, 185, 183, 201, 232, 208, 42, 191, 198, 252, 36, 213, 216, 192, 103, 249, 250, 228, 185, 39, 225, 71, 23, 126, 234, 132, 191, 114, 234, 83, 173, 234, 149, 231, 146, 251, 93, 193, 56, 129, 199, 235, 229, 118, 62, 221, 177, 96, 170, 205, 19, 182, 234, 188, 43, 148, 108, 142, 67, 144, 63, 52, 239, 244, 67, 65, 127, 206, 102, 13, 227, 56, 201, 195, 246, 0, 155, 0, 46, 128, 245, 6, 0, 0]); +export const bytecode = Uint8Array.from([ + 31, 139, 8, 0, 0, 0, 0, 0, 0, 255, 213, 85, 93, 10, 194, 48, 12, 78, 155, 233, 54, 240, 205, 11, 8, 122, 128, 76, 47, + 176, 187, 136, 111, 138, 62, 122, 124, 45, 75, 88, 23, 139, 19, 76, 64, 63, 24, 89, 75, 242, 229, 159, 6, 24, 208, 60, + 191, 192, 255, 11, 150, 145, 101, 186, 71, 152, 66, 116, 123, 150, 244, 29, 186, 96, 199, 69, 94, 49, 198, 63, 136, + 17, 29, 98, 132, 172, 255, 63, 216, 111, 203, 190, 152, 214, 15, 11, 251, 83, 193, 176, 95, 75, 62, 215, 44, 27, 93, + 232, 100, 20, 225, 117, 241, 38, 144, 233, 105, 149, 4, 229, 185, 183, 201, 232, 208, 42, 191, 198, 252, 36, 213, 216, + 192, 103, 249, 250, 228, 185, 39, 225, 71, 23, 126, 234, 132, 191, 114, 234, 83, 173, 234, 149, 231, 146, 251, 93, + 193, 56, 129, 199, 235, 229, 118, 62, 221, 177, 96, 170, 205, 19, 182, 234, 188, 43, 148, 108, 142, 67, 144, 63, 52, + 239, 244, 67, 65, 127, 206, 102, 13, 227, 56, 201, 195, 246, 0, 155, 0, 46, 128, 245, 6, 0, 0, +]); export const initialWitnessMap: WitnessMap = new Map([ [1, '0x0000000000000000000000000000000000000000000000000000000000000001'], [2, '0x0000000000000000000000000000000000000000000000000000000000000002'], diff --git a/noir/noir-repo/acvm-repo/acvm_js/test/shared/foreign_call.ts b/noir/noir-repo/acvm-repo/acvm_js/test/shared/foreign_call.ts index 08123c01c2f..dc3c6f23f6f 100644 --- a/noir/noir-repo/acvm-repo/acvm_js/test/shared/foreign_call.ts +++ b/noir/noir-repo/acvm-repo/acvm_js/test/shared/foreign_call.ts @@ -1,7 +1,13 @@ import { WitnessMap } from '@noir-lang/acvm_js'; // See `simple_brillig_foreign_call` integration test in `acir/tests/test_program_serialization.rs`. -export const bytecode = Uint8Array.from([31, 139, 8, 0, 0, 0, 0, 0, 0, 255, 173, 79, 73, 10, 128, 48, 12, 204, 40, 46, 5, 111, 126, 36, 254, 192, 207, 120, 240, 226, 65, 196, 247, 91, 48, 129, 80, 218, 122, 48, 3, 33, 147, 9, 89, 6, 244, 98, 140, 1, 225, 157, 100, 173, 45, 84, 91, 37, 243, 63, 44, 240, 219, 197, 246, 223, 38, 37, 176, 34, 85, 156, 169, 251, 144, 233, 183, 142, 206, 67, 114, 215, 121, 63, 15, 84, 135, 222, 157, 98, 244, 194, 247, 227, 222, 206, 11, 31, 19, 165, 186, 164, 207, 153, 222, 3, 91, 101, 84, 220, 120, 2, 0, 0]); +export const bytecode = Uint8Array.from([ + 31, 139, 8, 0, 0, 0, 0, 0, 0, 255, 173, 79, 73, 10, 128, 48, 12, 204, 40, 46, 5, 111, 126, 36, 254, 192, 207, 120, + 240, 226, 65, 196, 247, 91, 48, 129, 80, 218, 122, 48, 3, 33, 147, 9, 89, 6, 244, 98, 140, 1, 225, 157, 100, 173, 45, + 84, 91, 37, 243, 63, 44, 240, 219, 197, 246, 223, 38, 37, 176, 34, 85, 156, 169, 251, 144, 233, 183, 142, 206, 67, + 114, 215, 121, 63, 15, 84, 135, 222, 157, 98, 244, 194, 247, 227, 222, 206, 11, 31, 19, 165, 186, 164, 207, 153, 222, + 3, 91, 101, 84, 220, 120, 2, 0, 0, +]); export const initialWitnessMap: WitnessMap = new Map([ [1, '0x0000000000000000000000000000000000000000000000000000000000000005'], ]); From 3353cee6b5e442826a389a533b87f97e94958f57 Mon Sep 17 00:00:00 2001 From: TomAFrench Date: Thu, 17 Oct 2024 19:40:34 +0000 Subject: [PATCH 13/14] . --- noir/noir-repo/compiler/noirc_driver/src/lib.rs | 9 ++++----- .../src/hir/comptime/interpreter/builtin.rs | 5 ++++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/noir/noir-repo/compiler/noirc_driver/src/lib.rs b/noir/noir-repo/compiler/noirc_driver/src/lib.rs index c302964b434..62b8226029f 100644 --- a/noir/noir-repo/compiler/noirc_driver/src/lib.rs +++ b/noir/noir-repo/compiler/noirc_driver/src/lib.rs @@ -450,12 +450,11 @@ fn compile_contract_inner( .attributes .secondary .iter() - .filter_map(|attr| - match attr { - SecondaryAttribute::Tag(attribute) | SecondaryAttribute::Meta(attribute) => { + .filter_map(|attr| match attr { + SecondaryAttribute::Tag(attribute) | SecondaryAttribute::Meta(attribute) => { Some(attribute.contents.clone()) - }, - _ => None + } + _ => None, }) .collect(); diff --git a/noir/noir-repo/compiler/noirc_frontend/src/hir/comptime/interpreter/builtin.rs b/noir/noir-repo/compiler/noirc_frontend/src/hir/comptime/interpreter/builtin.rs index eb514103103..622ec8650df 100644 --- a/noir/noir-repo/compiler/noirc_frontend/src/hir/comptime/interpreter/builtin.rs +++ b/noir/noir-repo/compiler/noirc_frontend/src/hir/comptime/interpreter/builtin.rs @@ -2252,7 +2252,10 @@ fn function_def_add_attribute( } } - if let Attribute::Secondary(SecondaryAttribute::Tag(attribute)| SecondaryAttribute::Meta(attribute)) = attribute { + if let Attribute::Secondary( + SecondaryAttribute::Tag(attribute) | SecondaryAttribute::Meta(attribute), + ) = attribute + { let func_meta = interpreter.elaborator.interner.function_meta_mut(&func_id); func_meta.custom_attributes.push(attribute); } From c4710894898ab108b913f619dfadaa1d9039ebb2 Mon Sep 17 00:00:00 2001 From: TomAFrench Date: Thu, 17 Oct 2024 20:35:57 +0000 Subject: [PATCH 14/14] . --- .../src/main.nr | 6 +----- .../easy_private_token_contract/src/main.nr | 7 ++++++- .../contracts/parent_contract/src/main.nr | 16 +++++++++++++--- .../pending_note_hashes_contract/src/main.nr | 12 ++++++++++-- .../contracts/static_parent_contract/src/main.nr | 6 +++++- .../contracts/test_contract/src/main.nr | 6 +----- .../contracts/uniswap_contract/src/main.nr | 6 +----- 7 files changed, 37 insertions(+), 22 deletions(-) diff --git a/noir-projects/noir-contracts/contracts/contract_class_registerer_contract/src/main.nr b/noir-projects/noir-contracts/contracts/contract_class_registerer_contract/src/main.nr index 030354ca07b..3112cd5dbcf 100644 --- a/noir-projects/noir-contracts/contracts/contract_class_registerer_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/contract_class_registerer_contract/src/main.nr @@ -32,11 +32,7 @@ contract ContractClassRegisterer { // docs:end:import_pop_capsule #[private] - fn register( - artifact_hash: Field, - private_functions_root: Field, - public_bytecode_commitment: Field - ) { + fn register(artifact_hash: Field, private_functions_root: Field, public_bytecode_commitment: Field) { // TODO: Validate public_bytecode_commitment is the correct commitment of packed_public_bytecode // TODO: Validate packed_public_bytecode is legit public bytecode diff --git a/noir-projects/noir-contracts/contracts/easy_private_token_contract/src/main.nr b/noir-projects/noir-contracts/contracts/easy_private_token_contract/src/main.nr index ef7c89c22a0..8e118629ed8 100644 --- a/noir-projects/noir-contracts/contracts/easy_private_token_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/easy_private_token_contract/src/main.nr @@ -34,7 +34,12 @@ contract EasyPrivateToken { // Transfers `amount` of tokens from `sender` to a `recipient`. #[private] - fn transfer(amount: u64, sender: AztecAddress, recipient: AztecAddress, outgoing_viewer: AztecAddress) { + fn transfer( + amount: u64, + sender: AztecAddress, + recipient: AztecAddress, + outgoing_viewer: AztecAddress + ) { let balances = storage.balances; balances.at(sender).sub(amount, sender, outgoing_viewer); diff --git a/noir-projects/noir-contracts/contracts/parent_contract/src/main.nr b/noir-projects/noir-contracts/contracts/parent_contract/src/main.nr index 9d44bf56cae..ac1526eca14 100644 --- a/noir-projects/noir-contracts/contracts/parent_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/parent_contract/src/main.nr @@ -59,7 +59,10 @@ contract Parent { // - one through a nested call to enqueue_call_to_child with value 10, // - followed by one issued directly from this function with value 20. #[private] - fn enqueue_calls_to_child_with_nested_first(target_contract: AztecAddress, target_selector: FunctionSelector) { + fn enqueue_calls_to_child_with_nested_first( + target_contract: AztecAddress, + target_selector: FunctionSelector + ) { let enqueue_call_to_child_selector = comptime { FunctionSelector::from_signature("enqueue_call_to_child((Field),(u32),Field)") }; @@ -74,7 +77,10 @@ contract Parent { // - one issued directly from this function with value 20, // - followed by one through a nested call to enqueue_call_to_child with value 10. #[private] - fn enqueue_calls_to_child_with_nested_last(target_contract: AztecAddress, target_selector: FunctionSelector) { + fn enqueue_calls_to_child_with_nested_last( + target_contract: AztecAddress, + target_selector: FunctionSelector + ) { context.call_public_function(target_contract, target_selector, [20]); let enqueue_call_to_child_selector = comptime { FunctionSelector::from_signature("enqueue_call_to_child((Field),(u32),Field)") @@ -205,7 +211,11 @@ contract Parent { } // Private function to enqueue a static call to the pub_entry_point function of another contract, passing the target arguments provided #[private] - fn enqueue_static_nested_call_to_pub_function(target_contract: AztecAddress, target_selector: FunctionSelector, args: [Field; 1]) { + fn enqueue_static_nested_call_to_pub_function( + target_contract: AztecAddress, + target_selector: FunctionSelector, + args: [Field; 1] + ) { // Call the target public function through the pub entrypoint statically let pub_entry_point_selector = FunctionSelector::from_signature("pub_entry_point((Field),(u32),Field)"); let this_address = context.this_address(); diff --git a/noir-projects/noir-contracts/contracts/pending_note_hashes_contract/src/main.nr b/noir-projects/noir-contracts/contracts/pending_note_hashes_contract/src/main.nr index b70a5b5243a..2d3a33b808d 100644 --- a/noir-projects/noir-contracts/contracts/pending_note_hashes_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/pending_note_hashes_contract/src/main.nr @@ -27,7 +27,11 @@ contract PendingNoteHashes { // getting / reading that note all in the same contract function // Realistic way to describe this test is "Mint note A, then burn note A in the same transaction" #[private] - fn test_insert_then_get_then_nullify_flat(amount: Field, owner: AztecAddress, outgoing_viewer: AztecAddress) -> Field { + fn test_insert_then_get_then_nullify_flat( + amount: Field, + owner: AztecAddress, + outgoing_viewer: AztecAddress + ) -> Field { let owner_balance = storage.balances.at(owner); let owner_keys = get_public_keys(owner); @@ -344,7 +348,11 @@ contract PendingNoteHashes { } #[private] - fn recursively_destroy_and_create_notes(owner: AztecAddress, outgoing_viewer: AztecAddress, executions_left: u64) { + fn recursively_destroy_and_create_notes( + owner: AztecAddress, + outgoing_viewer: AztecAddress, + executions_left: u64 + ) { assert(executions_left > 0); destroy_max_notes(owner, storage); diff --git a/noir-projects/noir-contracts/contracts/static_parent_contract/src/main.nr b/noir-projects/noir-contracts/contracts/static_parent_contract/src/main.nr index fb2afc32df7..d363d073fb0 100644 --- a/noir-projects/noir-contracts/contracts/static_parent_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/static_parent_contract/src/main.nr @@ -152,7 +152,11 @@ contract StaticParent { // Private function to set a static context and verify correct propagation of nested enqueuing of public calls #[private] - fn enqueue_static_nested_call_to_pub_function(target_contract: AztecAddress, target_selector: FunctionSelector, args: [Field; 1]) { + fn enqueue_static_nested_call_to_pub_function( + target_contract: AztecAddress, + target_selector: FunctionSelector, + args: [Field; 1] + ) { // Call the target public function through the pub entrypoint statically StaticParent::at(context.this_address()).public_call(target_contract, target_selector, args[0]).enqueue_view(&mut context) } diff --git a/noir-projects/noir-contracts/contracts/test_contract/src/main.nr b/noir-projects/noir-contracts/contracts/test_contract/src/main.nr index d0e6b602575..111f8fad6db 100644 --- a/noir-projects/noir-contracts/contracts/test_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/test_contract/src/main.nr @@ -379,11 +379,7 @@ contract Test { } #[private] - fn consume_message_from_arbitrary_sender_private( - content: Field, - secret: Field, - sender: EthAddress - ) { + fn consume_message_from_arbitrary_sender_private(content: Field, secret: Field, sender: EthAddress) { // Consume message and emit nullifier context.consume_l1_to_l2_message(content, secret, sender); } diff --git a/noir-projects/noir-contracts/contracts/uniswap_contract/src/main.nr b/noir-projects/noir-contracts/contracts/uniswap_contract/src/main.nr index 66b5f4f60b9..0b1aeb7cd55 100644 --- a/noir-projects/noir-contracts/contracts/uniswap_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/uniswap_contract/src/main.nr @@ -156,11 +156,7 @@ contract Uniswap { // this method is used for both private and public swaps. #[public] #[internal] - fn _approve_bridge_and_exit_input_asset_to_L1( - token: AztecAddress, - token_bridge: AztecAddress, - amount: Field - ) { + fn _approve_bridge_and_exit_input_asset_to_L1(token: AztecAddress, token_bridge: AztecAddress, amount: Field) { // Since we will authorize and instantly spend the funds, all in public, we can use the same nonce // every interaction. In practice, the authwit should be squashed, so this is also cheap! let nonce = 0xdeadbeef;