From eea711f974f3bbe5d170d6a0dc84943ee30505be Mon Sep 17 00:00:00 2001 From: esau <152162806+sklppy88@users.noreply.github.com> Date: Fri, 22 Mar 2024 19:16:25 +0100 Subject: [PATCH] refactor: camelCase in noir-projects -> snake_case (#5381) Can we add a ci check for style on noir code so this doesn't creep back in again? Resolves #1928. --- .../writing_private_voting_contract.md | 6 +- .../aztec-nr/aztec/src/context/avm_context.nr | 16 +- .../aztec-nr/aztec/src/note/lifecycle.nr | 4 +- .../aztec-nr/aztec/src/note/note_getter.nr | 16 +- .../aztec-nr/aztec/src/note/utils.nr | 2 +- .../aztec-nr/aztec/src/oracle/notes.nr | 2 +- .../contracts/avm_test_contract/src/main.nr | 46 ++-- .../contracts/child_contract/src/main.nr | 30 +-- .../contracts/delegator_contract/src/main.nr | 18 +- .../easy_private_token_contract/src/main.nr | 2 +- .../easy_private_voting_contract/src/main.nr | 8 +- .../contracts/fpc_contract/src/main.nr | 4 +- .../import_test_contract/src/main.nr | 14 +- .../contracts/lending_contract/src/main.nr | 4 +- .../contracts/parent_contract/src/main.nr | 222 +++++++++--------- .../contracts/price_feed_contract/src/main.nr | 4 +- .../contracts/test_contract/src/main.nr | 4 +- .../token_bridge_contract/src/main.nr | 8 +- .../token_portal_content_hash_lib/src/lib.nr | 6 +- .../uniswap_contract/src/interfaces.nr | 4 +- .../crates/rollup-lib/src/components.nr | 12 +- .../types/src/abis/combined_constant_data.nr | 2 +- .../types/src/merkle_tree/append_only_tree.nr | 26 +- yarn-project/aztec.js/README.md | 2 +- .../end-to-end/src/docs_examples.test.ts | 2 +- .../end-to-end/src/e2e_2_pxes.test.ts | 2 +- .../src/e2e_account_contracts.test.ts | 2 +- .../src/e2e_nested_contract.test.ts | 38 +-- .../end-to-end/src/e2e_ordering.test.ts | 20 +- .../end-to-end/src/e2e_static_calls.test.ts | 36 +-- .../src/client/private_execution.test.ts | 6 +- .../simulator/src/public/index.test.ts | 4 +- 32 files changed, 292 insertions(+), 280 deletions(-) diff --git a/docs/docs/developers/tutorials/writing_private_voting_contract.md b/docs/docs/developers/tutorials/writing_private_voting_contract.md index f64a16526e8..685b89a9412 100644 --- a/docs/docs/developers/tutorials/writing_private_voting_contract.md +++ b/docs/docs/developers/tutorials/writing_private_voting_contract.md @@ -89,7 +89,7 @@ In this contract, we will store three vars: 1. admin, as an Aztec address held in public state 2. tally, as a map with key as the persona and value as the number (in Field) held in public state -3. voteEnded, as a boolean held in public state +3. vote_ended, as a boolean held in public state ## Constructor @@ -97,7 +97,7 @@ The next step is to initialize the contract with a constructor. The constructor #include_code constructor noir-projects/noir-contracts/contracts/easy_private_voting_contract/src/main.nr rust -This function takes the admin argument and writes it to the storage. We are also using this function to set the `voteEnded` boolean as false in the same way. +This function takes the admin argument and writes it to the storage. We are also using this function to set the `vote_ended` boolean as false in the same way. ## Casting a vote privately @@ -125,7 +125,7 @@ Create this new public function like this: The first thing we do here is assert that the vote has not ended. -`assert()` takes two arguments: the assertion, in this case that `storage.voteEnded` is not false, and the error thrown if the assertion fails. +`assert()` takes two arguments: the assertion, in this case that `storage.vote_ended` is not false, and the error thrown if the assertion fails. The code after the assertion will only run if the assertion is true. In this snippet, we read the current vote tally at the voteId, add 1 to it, and write this new number to the voteId. The `Field` element allows us to use `+` to add to an integer. diff --git a/noir-projects/aztec-nr/aztec/src/context/avm_context.nr b/noir-projects/aztec-nr/aztec/src/context/avm_context.nr index 803d1e92935..4f72dad449b 100644 --- a/noir-projects/aztec-nr/aztec/src/context/avm_context.nr +++ b/noir-projects/aztec-nr/aztec/src/context/avm_context.nr @@ -121,7 +121,7 @@ impl PublicContextInterface for AVMContext { temporary_function_selector: FunctionSelector, args: [Field; ARGS_COUNT] ) -> [Field; RETURN_VALUES_LENGTH] { - let gas = [/*l1Gas*/42, /*l2Gas*/24, /*daGas*/420]; + let gas = [/*l1_gas*/42, /*l2_gas*/24, /*da_gas*/420]; let results = call( gas, @@ -129,11 +129,11 @@ impl PublicContextInterface for AVMContext { args, temporary_function_selector.to_field() ); - let returnData: [Field; RETURN_VALUES_LENGTH] = results.0; + let data_to_return: [Field; RETURN_VALUES_LENGTH] = results.0; let success: u8 = results.1; assert(success == 1, "Nested call failed!"); - returnData + data_to_return } fn static_call_public_function( @@ -142,9 +142,9 @@ impl PublicContextInterface for AVMContext { temporary_function_selector: FunctionSelector, args: [Field; ARGS_COUNT] ) -> [Field; RETURN_VALUES_LENGTH] { - let gas = [/*l1Gas*/42, /*l2Gas*/24, /*daGas*/420]; + let gas = [/*l1_gas*/42, /*l2_gas*/24, /*da_gas*/420]; - let (returnData, success): ([Field; RETURN_VALUES_LENGTH], u8) = call_static( + let (data_to_return, success): ([Field; RETURN_VALUES_LENGTH], u8) = call_static( gas, contract_address, args, @@ -152,7 +152,7 @@ impl PublicContextInterface for AVMContext { ); assert(success == 1, "Nested static call failed!"); - returnData + data_to_return } fn delegate_call_public_function( @@ -263,7 +263,7 @@ fn send_l2_to_l1_msg(recipient: EthAddress, content: Field) {} #[oracle(avmOpcodeCall)] fn call( - gas: [Field; 3], // gas allocation: [l1Gas, l2Gas, daGas] + gas: [Field; 3], // gas allocation: [l1_gas, l2_gas, da_gas] address: AztecAddress, args: [Field; ARGS_COUNT], // TODO(5110): consider passing in calldata directly @@ -273,7 +273,7 @@ fn call( #[oracle(avmOpcodeStaticCall)] fn call_static( - gas: [Field; 3], // gas allocation: [l1Gas, l2Gas, daGas] + gas: [Field; 3], // gas allocation: [l1_gas, l2_gas, da_gas] address: AztecAddress, args: [Field; ARGS_COUNT], // TODO(5110): consider passing in calldata directly diff --git a/noir-projects/aztec-nr/aztec/src/note/lifecycle.nr b/noir-projects/aztec-nr/aztec/src/note/lifecycle.nr index dfad659a717..2991d385290 100644 --- a/noir-projects/aztec-nr/aztec/src/note/lifecycle.nr +++ b/noir-projects/aztec-nr/aztec/src/note/lifecycle.nr @@ -14,7 +14,7 @@ pub fn create_note( let contract_address = (*context).this_address(); let header = NoteHeader { contract_address, storage_slot, nonce: 0, is_transient: true }; - // TODO: change this to note.setHeader(header) once https://github.com/noir-lang/noir/issues/4095 is fixed + // TODO: change this to note.set_header(header) once https://github.com/noir-lang/noir/issues/4095 is fixed Note::set_header(note, header); // As `is_transient` is true, this will compute the inner note hsah let inner_note_hash = compute_note_hash_for_insertion(*note); @@ -46,7 +46,7 @@ pub fn create_note_hash_from_public( let contract_address = (*context).this_address(); let header = NoteHeader { contract_address, storage_slot, nonce: 0, is_transient: true }; - // TODO: change this to note.setHeader(header) once https://github.com/noir-lang/noir/issues/4095 is fixed + // TODO: change this to note.set_header(header) once https://github.com/noir-lang/noir/issues/4095 is fixed Note::set_header(note, header); let inner_note_hash = compute_note_hash_for_insertion(*note); diff --git a/noir-projects/aztec-nr/aztec/src/note/note_getter.nr b/noir-projects/aztec-nr/aztec/src/note/note_getter.nr index a2f1b30f6bc..2cc23242238 100644 --- a/noir-projects/aztec-nr/aztec/src/note/note_getter.nr +++ b/noir-projects/aztec-nr/aztec/src/note/note_getter.nr @@ -43,21 +43,21 @@ fn check_note_fields(serialized_note: [Field; N], selects: BoundedVec( serialized_note: [Field; S] // docs:end:compute_note_hash_and_nullifier_args ) -> [Field; 4] where T: NoteInterface { let mut note = deserialize_content(arr_copy_slice(serialized_note, [0; N], 0)); - // TODO: change this to note.setHeader(header) once https://github.com/noir-lang/noir/issues/4095 is fixed + // TODO: change this to note.set_header(header) once https://github.com/noir-lang/noir/issues/4095 is fixed T::set_header((&mut note), note_header); let inner_note_hash = compute_inner_note_hash(note); diff --git a/noir-projects/aztec-nr/aztec/src/oracle/notes.nr b/noir-projects/aztec-nr/aztec/src/oracle/notes.nr index 50ee2367f0a..d4c5d75eec6 100644 --- a/noir-projects/aztec-nr/aztec/src/oracle/notes.nr +++ b/noir-projects/aztec-nr/aztec/src/oracle/notes.nr @@ -133,7 +133,7 @@ unconstrained pub fn get_notes( let header = NoteHeader { contract_address, nonce, storage_slot, is_transient }; let serialized_note = arr_copy_slice(fields, [0; N], read_offset + 2); let mut note = Note::deserialize_content(serialized_note); - // TODO: change this to note.setHeader(header) once https://github.com/noir-lang/noir/issues/4095 is fixed + // TODO: change this to note.set_header(header) once https://github.com/noir-lang/noir/issues/4095 is fixed Note::set_header(&mut note, header); placeholder_opt_notes[i] = Option::some(note); }; 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 1bed81cb60b..43a150ae1f8 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 @@ -291,68 +291,68 @@ contract AvmTest { // Directly call the external call opcode to initiate a nested call to the add function #[aztec(public-vm)] - fn raw_nested_call_to_add(argA: Field, argB: Field) -> pub Field { + fn raw_nested_call_to_add(arg_a: Field, arg_b: Field) -> pub Field { let selector = FunctionSelector::from_signature("add_args_return(Field,Field)").to_field(); - let gas = [/*l1Gas*/42, /*l2Gas*/24, /*daGas*/420]; + let gas = [/*l1_gas*/42, /*l2_gas*/24, /*da_gas*/420]; // Nested call - let results = context.call_public_function_raw(gas, context.this_address(), selector, [argA, argB]); - let returnData: [Field; 1] = results.0; - // this explicit size ^ is necessary to ensure that retSize is compile-time - // (ensure the returnData is in a HeapArray not a HeapVector) + let results = context.call_public_function_raw(gas, context.this_address(), selector, [arg_a, arg_b]); + let data_to_return: [Field; 1] = results.0; + // this explicit size ^ is necessary to ensure that ret_size is compile-time + // (ensure the data_to_return is in a HeapArray not a HeapVector) let success: u8 = results.1; assert(success == 1, "Call failed"); - let addResult = returnData[0]; - addResult + let add_result = data_to_return[0]; + add_result } // Use the `call_public_function` wrapper to initiate a nested call to the add function #[aztec(public-vm)] - fn nested_call_to_add(argA: Field, argB: Field) -> pub Field { + fn nested_call_to_add(arg_a: Field, arg_b: Field) -> pub Field { let selector = FunctionSelector::from_signature("add_args_return(Field,Field)"); // Nested call using standard context interface function - let returnData: [Field; RETURN_VALUES_LENGTH] = context.call_public_function(context.this_address(), selector, [argA, argB]); - // this explicit size ^ is necessary to ensure that retSize is compile-time - // (ensure the returnData is in a HeapArray not a HeapVector) + let data_to_return: [Field; RETURN_VALUES_LENGTH] = context.call_public_function(context.this_address(), selector, [arg_a, arg_b]); + // this explicit size ^ is necessary to ensure that ret_size is compile-time + // (ensure the data_to_return is in a HeapArray not a HeapVector) - let addResult = returnData[0]; - addResult + let add_result = data_to_return[0]; + add_result } // Directly call_static the external call opcode to initiate a nested call to the add function #[aztec(public-vm)] - fn raw_nested_static_call_to_add(argA: Field, argB: Field) -> pub (Field, u8) { + fn raw_nested_static_call_to_add(arg_a: Field, arg_b: Field) -> pub (Field, u8) { let selector = FunctionSelector::from_signature("add_args_return(Field,Field)").to_field(); - let gas = [/*l1Gas*/42, /*l2Gas*/24, /*daGas*/420]; + let gas = [/*l1_gas*/42, /*l2_gas*/24, /*da_gas*/420]; - let (resultData, success): ([Field; 1], u8) = context.static_call_public_function_raw(gas, context.this_address(), selector, [argA, argB]); + let (result_data, success): ([Field; 1], u8) = context.static_call_public_function_raw(gas, context.this_address(), selector, [arg_a, arg_b]); - (resultData[0], success) + (result_data[0], success) } // Directly call_static `set_storage_single`. Should fail since it's accessing storage. #[aztec(public-vm)] fn raw_nested_static_call_to_set_storage() -> pub u8 { let selector = FunctionSelector::from_signature("set_storage_single(Field)").to_field(); - let gas = [/*l1Gas*/42, /*l2Gas*/24, /*daGas*/420]; + let gas = [/*l1_gas*/42, /*l2_gas*/24, /*da_gas*/420]; let calldata: [Field; 1] = [20]; - let (_returnData, success): ([Field; 0], u8) = context.static_call_public_function_raw(gas, context.this_address(), selector, calldata); + let (_data_to_return, success): ([Field; 0], u8) = context.static_call_public_function_raw(gas, context.this_address(), selector, calldata); success } // Indirectly call_static the external call opcode to initiate a nested call to the add function #[aztec(public-vm)] - fn nested_static_call_to_add(argA: Field, argB: Field) -> pub Field { + fn nested_static_call_to_add(arg_a: Field, arg_b: Field) -> pub Field { let selector = FunctionSelector::from_signature("add_args_return(Field,Field)"); - let resultData: [Field; RETURN_VALUES_LENGTH] = context.static_call_public_function(context.this_address(), selector, [argA, argB]); + let result_data: [Field; RETURN_VALUES_LENGTH] = context.static_call_public_function(context.this_address(), selector, [arg_a, arg_b]); - resultData[0] + result_data[0] } // Indirectly call_static `set_storage_single`. Should revert since it's accessing storage. 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 101a96a066a..e9fdcc07ad8 100644 --- a/noir-projects/noir-contracts/contracts/child_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/child_contract/src/main.nr @@ -22,25 +22,25 @@ contract Child { // Can only be called from this contract. #[aztec(private)] #[aztec(internal)] - fn valueInternal(input: Field) -> Field { + fn value_internal(input: Field) -> Field { input + context.chain_id() + context.version() } // Returns base_value + chain_id + version + block_number + timestamp #[aztec(public)] - fn pubGetValue(base_value: Field) -> Field { - let returnValue = base_value + fn pub_get_value(base_value: Field) -> Field { + let return_value = base_value + context.chain_id() + context.version() + context.block_number() + context.timestamp(); - returnValue + return_value } // Sets `current_value` to `new_value` #[aztec(public)] - fn pubSetValue(new_value: Field) -> Field { + fn pub_set_value(new_value: Field) -> Field { storage.current_value.write(new_value); emit_unencrypted_log(&mut context, new_value); @@ -48,14 +48,14 @@ contract Child { } #[aztec(private)] - fn privateSetValue(new_value: Field, owner: AztecAddress) -> Field { + fn private_set_value(new_value: Field, owner: AztecAddress) -> Field { let mut note = ValueNote::new(new_value, owner); storage.a_private_value.insert(&mut note, true); new_value } #[aztec(private)] - fn privateGetValue(amount: Field, owner: AztecAddress) -> Field { + fn private_get_value(amount: Field, owner: AztecAddress) -> Field { let options = NoteGetterOptions::new().select(ValueNote::properties().value, amount, Option::none()).select( ValueNote::properties().owner, owner.to_field(), @@ -67,7 +67,7 @@ contract Child { // Increments `current_value` by `new_value` #[aztec(public)] - fn pubIncValue(new_value: Field) -> Field { + fn pub_inc_value(new_value: Field) -> Field { let old_value = storage.current_value.read(); storage.current_value.write(old_value + new_value); emit_unencrypted_log(&mut context, new_value); @@ -78,7 +78,7 @@ contract Child { // Increments `current_value` by `new_value`. Can only be called from this contract. #[aztec(public)] #[aztec(internal)] - fn pubIncValueInternal(new_value: Field) -> Field { + fn pub_inc_value_internal(new_value: Field) -> Field { let old_value = storage.current_value.read(); storage.current_value.write(old_value + new_value); emit_unencrypted_log(&mut context, new_value); @@ -87,20 +87,20 @@ contract Child { } #[aztec(public)] - fn setValueTwiceWithNestedFirst() { - let pubSetValueSelector = FunctionSelector::from_signature("pubSetValue(Field)"); - let _ret = context.call_public_function(context.this_address(), pubSetValueSelector, [10]); + fn set_value_twice_with_nested_first() { + let pub_set_value_selector = FunctionSelector::from_signature("pub_set_value(Field)"); + let _ret = context.call_public_function(context.this_address(), pub_set_value_selector, [10]); storage.current_value.write(20); emit_unencrypted_log(&mut context, 20); } #[aztec(public)] - fn setValueTwiceWithNestedLast() { + fn set_value_twice_with_nested_last() { storage.current_value.write(20); emit_unencrypted_log(&mut context, 20); - let pubSetValueSelector = FunctionSelector::from_signature("pubSetValue(Field)"); - let _ret = context.call_public_function(context.this_address(), pubSetValueSelector, [10]); + let pub_set_value_selector = FunctionSelector::from_signature("pub_set_value(Field)"); + let _ret = context.call_public_function(context.this_address(), pub_set_value_selector, [10]); } } 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 14751ae8102..46417912fa1 100644 --- a/noir-projects/noir-contracts/contracts/delegator_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/delegator_contract/src/main.nr @@ -13,32 +13,32 @@ contract Delegator { #[aztec(private)] fn private_delegate_set_value( - targetContract: AztecAddress, - targetSelector: FunctionSelector, + target_contract: AztecAddress, + target_selector: FunctionSelector, args: [Field; 2] ) { // Call the target private function - let return_values = context.delegate_call_private_function(targetContract, targetSelector, args); + let return_values = context.delegate_call_private_function(target_contract, target_selector, args); // Copy the return value from the call to this function's return values return_values[0] } #[aztec(private)] fn enqueued_delegate_set_value( - targetContract: AztecAddress, - targetSelector: FunctionSelector, + target_contract: AztecAddress, + target_selector: FunctionSelector, args: [Field; 1] ) { - context.delegate_call_public_function(targetContract, targetSelector, args); + context.delegate_call_public_function(target_contract, target_selector, args); } #[aztec(public)] fn public_delegate_set_value( - targetContract: AztecAddress, - targetSelector: FunctionSelector, + target_contract: AztecAddress, + target_selector: FunctionSelector, args: [Field; 1] ) { - let _ = context.delegate_call_public_function(targetContract, targetSelector, args); + let _ = context.delegate_call_public_function(target_contract, target_selector, args); } unconstrained fn view_private_value(amount: Field, owner: AztecAddress) -> pub Field { 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 12261322cf0..6d398f9fb2a 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 @@ -37,7 +37,7 @@ contract EasyPrivateToken { } // Helper function to get the balance of a user ("unconstrained" is a Noir alternative of Solidity's "view" function). - unconstrained fn getBalance(owner: AztecAddress) -> pub Field { + unconstrained fn get_balance(owner: AztecAddress) -> pub Field { let balances = storage.balances; // Return the sum of all notes in the set. 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 8417feced27..ddcfcb3bcc9 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 @@ -10,7 +10,7 @@ contract EasyPrivateVoting { struct Storage { admin: PublicMutable, // admin can end vote tally: Map>, // we will store candidate as key and number of votes as value - voteEnded: PublicMutable, // voteEnded is boolean + vote_ended: PublicMutable, // vote_ended is boolean } // docs:end:storage_struct @@ -19,7 +19,7 @@ contract EasyPrivateVoting { #[aztec(initializer)] // annotation to mark function as a constructor fn constructor(admin: AztecAddress) { storage.admin.write(admin); - storage.voteEnded.write(false); + storage.vote_ended.write(false); } // docs:end:constructor @@ -41,7 +41,7 @@ contract EasyPrivateVoting { #[aztec(public)] #[aztec(internal)] fn add_to_tally_public(candidate: Field) { - assert(storage.voteEnded.read() == false, "Vote has ended"); // assert that vote has not ended + assert(storage.vote_ended.read() == false, "Vote has ended"); // assert that vote has not ended let new_tally = storage.tally.at(candidate).read() + 1; storage.tally.at(candidate).write(new_tally); } @@ -51,7 +51,7 @@ contract EasyPrivateVoting { #[aztec(public)] fn end_vote() { assert(storage.admin.read().eq(context.msg_sender()), "Only admin can end votes"); // assert that caller is admin - storage.voteEnded.write(true); + storage.vote_ended.write(true); } // docs:end:end_vote // docs:start:get_vote 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 476b2bdbd67..da3f517b69a 100644 --- a/noir-projects/noir-contracts/contracts/fpc_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/fpc_contract/src/main.nr @@ -73,13 +73,13 @@ contract FPC { #[aztec(public)] #[aztec(internal)] - fn pay_fee_with_shielded_rebate(amount: Field, asset: AztecAddress, secretHash: Field) { + fn pay_fee_with_shielded_rebate(amount: Field, asset: AztecAddress, secret_hash: Field) { let refund = context.call_public_function( storage.gas_token_address.read_public(), FunctionSelector::from_signature("pay_fee(Field)"), [amount] )[0]; - Token::at(asset).shield(&mut context, context.this_address(), refund, secretHash, 0); + Token::at(asset).shield(&mut context, context.this_address(), refund, secret_hash, 0); } } 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 8b5d9dec486..d7bccb32375 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 @@ -11,7 +11,7 @@ contract ImportTest { ManyNotesADeepStructTestCodeGenStruct }; - // Calls the testCodeGen on the Test contract at the target address + // Calls the test_code_gen on the Test contract at the target address // Used for testing calling a function with arguments of multiple types // See yarn-project/simulator/src/client/private_execution.ts // See yarn-project/end-to-end/src/e2e_nested_contract.test.ts @@ -40,31 +40,31 @@ contract ImportTest { return_values[0] } - // Calls the getThisAddress on the Test contract at the target address + // Calls the get_this_address on the Test contract at the target address // Used for testing calling a function with no arguments // See yarn-project/end-to-end/src/e2e_nested_contract.test.ts #[aztec(private)] - fn callNoArgs(target: AztecAddress) -> Field { + fn call_no_args(target: AztecAddress) -> Field { let test_contract_instance = TestPrivateContextInterface::at(target); let return_values = test_contract_instance.get_this_address(&mut context); return_values[0] } - // Calls the createNullifierPublic on the Test contract at the target address + // Calls the create_nullifier_public on the Test contract at the target address // Used for testing calling an open function // See yarn-project/end-to-end/src/e2e_nested_contract.test.ts #[aztec(private)] - fn callOpenFn(target: AztecAddress) { + fn call_open_fn(target: AztecAddress) { let test_contract_instance = TestPrivateContextInterface::at(target); test_contract_instance.create_nullifier_public(&mut context, 1, 2); } - // Calls the createNullifierPublic on the Test contract at the target address + // Calls the create_nullifier_public on the Test contract at the target address // Used for testing calling an open function from another open function // See yarn-project/end-to-end/src/e2e_nested_contract.test.ts #[aztec(public)] - fn pubCallOpenFn(target: AztecAddress) -> Field { + fn pub_call_open_fn(target: AztecAddress) -> Field { let test_contract_instance = TestPublicContextInterface::at(target); let ret = test_contract_instance.create_nullifier_public(&mut context, 1, 2); 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 721c3d149ab..63e568edacd 100644 --- a/noir-projects/noir-contracts/contracts/lending_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/lending_contract/src/main.nr @@ -303,8 +303,8 @@ contract Lending { storage.static_debt.at(owner).write(debt_returns.static_debt.to_integer()); } - unconstrained fn get_asset(assetId: Field) -> pub Asset { - storage.assets.at(assetId).read() + unconstrained fn get_asset(asset_id: Field) -> pub Asset { + storage.assets.at(asset_id).read() } unconstrained fn get_position(owner: AztecAddress) -> pub Position { 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 4c7f8ea594c..472159dfe2c 100644 --- a/noir-projects/noir-contracts/contracts/parent_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/parent_contract/src/main.nr @@ -2,158 +2,158 @@ contract Parent { use dep::aztec::prelude::{AztecAddress, FunctionSelector}; - // Private function to call another private function in the targetContract using the provided selector + // Private function to call another private function in the target_contract using the provided selector #[aztec(private)] - fn entryPoint(targetContract: AztecAddress, targetSelector: FunctionSelector) -> Field { + fn entry_point(target_contract: AztecAddress, target_selector: FunctionSelector) -> Field { // Call the target private function - let return_values = context.call_private_function(targetContract, targetSelector, [0]); + let return_values = context.call_private_function(target_contract, target_selector, [0]); // Copy the return value from the call to this function's return values return_values[0] } - // Public function to directly call another public function to the targetContract using the selector and value provided + // Public function to directly call another public function to the target_contract using the selector and value provided #[aztec(public)] - fn pubEntryPoint( - targetContract: AztecAddress, - targetSelector: FunctionSelector, - initValue: Field + fn pub_entry_point( + target_contract: AztecAddress, + target_selector: FunctionSelector, + init_value: Field ) -> Field { - let return_values = context.call_public_function(targetContract, targetSelector, [initValue]); + let return_values = context.call_public_function(target_contract, target_selector, [init_value]); return_values[0] } - // Same as pubEntryPoint, but calls the target contract twice, using the return value from the first invocation as the argument for the second. + // 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. #[aztec(public)] - fn pubEntryPointTwice( - targetContract: AztecAddress, - targetSelector: FunctionSelector, - initValue: Field + fn pub_entry_point_twice( + target_contract: AztecAddress, + target_selector: FunctionSelector, + init_value: Field ) -> Field { - let returnValue = context.call_public_function(targetContract, targetSelector, [initValue])[0]; - let return_values = context.call_public_function(targetContract, targetSelector, [returnValue]); + let return_value = context.call_public_function(target_contract, target_selector, [init_value])[0]; + let return_values = context.call_public_function(target_contract, target_selector, [return_value]); return_values[0] } - // Private function to enqueue a call to the targetContract address using the selector and argument provided + // Private function to enqueue a call to the target_contract address using the selector and argument provided #[aztec(private)] - fn enqueueCallToChild( - targetContract: AztecAddress, - targetSelector: FunctionSelector, - targetValue: Field + fn enqueue_call_to_child( + target_contract: AztecAddress, + target_selector: FunctionSelector, + target_value: Field ) { - context.call_public_function(targetContract, targetSelector, [targetValue]); + context.call_public_function(target_contract, target_selector, [target_value]); } // Private function that enqueues two calls to a child contract: - // - one through a nested call to enqueueCallToChild with value 10, + // - one through a nested call to enqueue_call_to_child with value 10, // - followed by one issued directly from this function with value 20. #[aztec(private)] - fn enqueueCallsToChildWithNestedFirst( - targetContract: AztecAddress, - targetSelector: FunctionSelector + fn enqueue_calls_to_child_with_nested_first( + target_contract: AztecAddress, + target_selector: FunctionSelector ) { - let enqueueCallToChildSelector = FunctionSelector::from_signature("enqueueCallToChild((Field),(u32),Field)"); + let enqueue_call_to_child_selector = FunctionSelector::from_signature("enqueue_call_to_child((Field),(u32),Field)"); let _ret = context.call_private_function( context.this_address(), - enqueueCallToChildSelector, - [targetContract.to_field(), targetSelector.to_field(), 10] + enqueue_call_to_child_selector, + [target_contract.to_field(), target_selector.to_field(), 10] ); - context.call_public_function(targetContract, targetSelector, [20]); + context.call_public_function(target_contract, target_selector, [20]); } // Private function that enqueues two calls to a child contract: // - one issued directly from this function with value 20, - // - followed by one through a nested call to enqueueCallToChild with value 10. + // - followed by one through a nested call to enqueue_call_to_child with value 10. #[aztec(private)] - fn enqueueCallsToChildWithNestedLast( - targetContract: AztecAddress, - targetSelector: FunctionSelector + fn enqueue_calls_to_child_with_nested_last( + target_contract: AztecAddress, + target_selector: FunctionSelector ) { - context.call_public_function(targetContract, targetSelector, [20]); - let enqueueCallToChildSelector = FunctionSelector::from_signature("enqueueCallToChild((Field),(u32),Field)"); + context.call_public_function(target_contract, target_selector, [20]); + let enqueue_call_to_child_selector = FunctionSelector::from_signature("enqueue_call_to_child((Field),(u32),Field)"); let _ret = context.call_private_function( context.this_address(), - enqueueCallToChildSelector, - [targetContract.to_field(), targetSelector.to_field(), 10] + enqueue_call_to_child_selector, + [target_contract.to_field(), target_selector.to_field(), 10] ); } - // Private function to enqueue a call to the targetContract address using the selector and argument provided + // Private function to enqueue a call to the target_contract address using the selector and argument provided #[aztec(private)] - fn enqueueCallToChildTwice( - targetContract: AztecAddress, - targetSelector: FunctionSelector, - targetValue: Field + fn enqueue_call_to_child_twice( + target_contract: AztecAddress, + target_selector: FunctionSelector, + target_value: Field ) { // Enqueue the first public call - context.call_public_function(targetContract, targetSelector, [targetValue]); + context.call_public_function(target_contract, target_selector, [target_value]); // Enqueue the second public call - context.call_public_function(targetContract, targetSelector, [targetValue + 1]); + context.call_public_function(target_contract, target_selector, [target_value + 1]); } - // Private function to enqueue a call to the pubEntryPoint function of this same contract, passing the target arguments provided + // Private function to enqueue a call to the pub_entry_point function of this same contract, passing the target arguments provided #[aztec(private)] - fn enqueueCallToPubEntryPoint( - targetContract: AztecAddress, - targetSelector: FunctionSelector, - targetValue: Field + fn enqueue_call_to_pub_entry_point( + target_contract: AztecAddress, + target_selector: FunctionSelector, + target_value: Field ) { - let pubEntryPointSelector = FunctionSelector::from_signature("pubEntryPoint((Field),(u32),Field)"); - let thisAddress = context.this_address(); + let pub_entry_point_selector = FunctionSelector::from_signature("pub_entry_point((Field),(u32),Field)"); + let this_address = context.this_address(); let _void = context.call_public_function( - thisAddress, - pubEntryPointSelector, - [targetContract.to_field(), targetSelector.to_field(), targetValue] + this_address, + pub_entry_point_selector, + [target_contract.to_field(), target_selector.to_field(), target_value] ); } - // Private function to enqueue two calls to the pubEntryPoint function of this same contract, passing the target arguments provided + // Private function to enqueue two calls to the pub_entry_point function of this same contract, passing the target arguments provided #[aztec(private)] - fn enqueueCallsToPubEntryPoint( - targetContract: AztecAddress, - targetSelector: FunctionSelector, - targetValue: Field + fn enqueue_calls_to_pub_entry_point( + target_contract: AztecAddress, + target_selector: FunctionSelector, + target_value: Field ) { - let pubEntryPointSelector = FunctionSelector::from_signature("pubEntryPoint((Field),(u32),Field)"); - let thisAddress = context.this_address(); + let pub_entry_point_selector = FunctionSelector::from_signature("pub_entry_point((Field),(u32),Field)"); + let this_address = context.this_address(); context.call_public_function( - thisAddress, - pubEntryPointSelector, - [targetContract.to_field(), targetSelector.to_field(), targetValue] + this_address, + pub_entry_point_selector, + [target_contract.to_field(), target_selector.to_field(), target_value] ); context.call_public_function( - thisAddress, - pubEntryPointSelector, - [targetContract.to_field(), targetSelector.to_field(), targetValue + 1] + this_address, + pub_entry_point_selector, + [target_contract.to_field(), target_selector.to_field(), target_value + 1] ); } #[aztec(private)] - fn privateStaticCall( - targetContract: AztecAddress, - targetSelector: FunctionSelector, + fn private_static_call( + target_contract: AztecAddress, + target_selector: FunctionSelector, args: [Field; 2] ) -> Field { // Call the target private function - let return_values = context.static_call_private_function(targetContract, targetSelector, args); + let return_values = context.static_call_private_function(target_contract, target_selector, args); // Copy the return value from the call to this function's return values return_values[0] } #[aztec(private)] - fn privateCall( - targetContract: AztecAddress, - targetSelector: FunctionSelector, + fn private_call( + target_contract: AztecAddress, + target_selector: FunctionSelector, args: [Field; 2] ) -> Field { // Call the target private function - let return_values = context.call_private_function(targetContract, targetSelector, args); + let return_values = context.call_private_function(target_contract, target_selector, args); // Copy the return value from the call to this function's return values return_values[0] @@ -161,79 +161,79 @@ contract Parent { // Private function to set a static context and verify correct propagation for nested private calls #[aztec(private)] - fn privateStaticCallNested( - targetContract: AztecAddress, - targetSelector: FunctionSelector, + fn private_nested_static_call( + target_contract: AztecAddress, + target_selector: FunctionSelector, args: [Field; 2] ) -> Field { // Call the target private function statically - let privateCallSelector = FunctionSelector::from_signature("privateCall((Field),(u32),[Field;2])"); - let thisAddress = context.this_address(); + let private_call_selector = FunctionSelector::from_signature("private_call((Field),(u32),[Field;2])"); + let this_address = context.this_address(); let return_values = context.static_call_private_function( - thisAddress, - privateCallSelector, - [targetContract.to_field(), targetSelector.to_field(), args[0], args[1]] + this_address, + private_call_selector, + [target_contract.to_field(), target_selector.to_field(), args[0], args[1]] ); // Copy the return value from the call to this function's return values return_values[0] } - // Public function to directly call another public function to the targetContract using the selector and value provided + // Public function to directly call another public function to the target_contract using the selector and value provided #[aztec(public)] - fn publicStaticCall( - targetContract: AztecAddress, - targetSelector: FunctionSelector, + fn public_static_call( + target_contract: AztecAddress, + target_selector: FunctionSelector, args: [Field; 1] ) -> Field { - let return_values = context.static_call_public_function(targetContract, targetSelector, args); + let return_values = context.static_call_public_function(target_contract, target_selector, args); return_values[0] } // Public function to set a static context and verify correct propagation for nested public calls #[aztec(public)] - fn publicNestedStaticCall( - targetContract: AztecAddress, - targetSelector: FunctionSelector, + fn public_nested_static_call( + target_contract: AztecAddress, + target_selector: FunctionSelector, args: [Field; 1] ) -> Field { // Call the target public function through the pub entrypoint statically - let pubEntryPointSelector = FunctionSelector::from_signature("pubEntryPoint((Field),(u32),Field)"); - let thisAddress = context.this_address(); + let pub_entry_point_selector = FunctionSelector::from_signature("pub_entry_point((Field),(u32),Field)"); + let this_address = context.this_address(); let return_values = context.static_call_public_function( - thisAddress, - pubEntryPointSelector, - [targetContract.to_field(), targetSelector.to_field(), args[0]] + this_address, + pub_entry_point_selector, + [target_contract.to_field(), target_selector.to_field(), args[0]] ); return_values[0] } - // Private function to enqueue a static call to the pubEntryPoint function of another contract, passing the target arguments provided + // Private function to enqueue a static call to the pub_entry_point function of another contract, passing the target arguments provided #[aztec(private)] - fn enqueueStaticNestedCallToPubFunction( - targetContract: AztecAddress, - targetSelector: FunctionSelector, + 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 pubEntryPointSelector = FunctionSelector::from_signature("pubEntryPoint((Field),(u32),Field)"); - let thisAddress = context.this_address(); + let pub_entry_point_selector = FunctionSelector::from_signature("pub_entry_point((Field),(u32),Field)"); + let this_address = context.this_address(); context.static_call_public_function( - thisAddress, - pubEntryPointSelector, - [targetContract.to_field(), targetSelector.to_field(), args[0]] + this_address, + pub_entry_point_selector, + [target_contract.to_field(), target_selector.to_field(), args[0]] ); } - // Private function to enqueue a static call to the pubEntryPoint function of another contract, passing the target arguments provided + // Private function to enqueue a static call to the pub_entry_point function of another contract, passing the target arguments provided #[aztec(private)] - fn enqueueStaticCallToPubFunction( - targetContract: AztecAddress, - targetSelector: FunctionSelector, + fn enqueue_static_call_to_pub_function( + target_contract: AztecAddress, + target_selector: FunctionSelector, args: [Field; 1] ) { // Call the target private function - context.static_call_public_function(targetContract, targetSelector, args); + context.static_call_public_function(target_contract, target_selector, args); } } 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 c18c6628c85..31cfcb9fe70 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 @@ -21,7 +21,7 @@ contract PriceFeed { storage.assets.at(asset_id).read() } - unconstrained fn fetch_price(assetId: Field) -> pub Asset { - storage.assets.at(assetId).read() + unconstrained fn fetch_price(asset_id: Field) -> pub Asset { + storage.assets.at(asset_id).read() } } 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 f5139cf61dc..f721d48fd90 100644 --- a/noir-projects/noir-contracts/contracts/test_contract/src/main.nr +++ b/noir-projects/noir-contracts/contracts/test_contract/src/main.nr @@ -359,8 +359,8 @@ contract Test { } // Purely exists for testing - unconstrained fn get_random(kindaSeed: Field) -> pub Field { - kindaSeed * rand() + unconstrained fn get_random(kinda_seed: Field) -> pub Field { + kinda_seed * rand() } struct DummyNote { 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 9611aa25d6f..c02dbe0fd4d 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 @@ -52,11 +52,11 @@ contract TokenBridge { fn exit_to_l1_public( recipient: EthAddress, // ethereum address to withdraw to amount: Field, - callerOnL1: EthAddress, // ethereum address that can call this function on the L1 portal (0x0 if anyone can call) + caller_on_l1: EthAddress, // ethereum address that can call this function on the L1 portal (0x0 if anyone can call) nonce: Field // nonce used in the approval message by `msg.sender` to let bridge burn their tokens on L2 ) { // Send an L2 to L1 message - let content = get_withdraw_content_hash(recipient, amount, callerOnL1); + let content = get_withdraw_content_hash(recipient, amount, caller_on_l1); context.message_portal(context.this_portal_address(), content); // Burn tokens @@ -100,11 +100,11 @@ contract TokenBridge { token: AztecAddress, recipient: EthAddress, // ethereum address to withdraw to amount: Field, - callerOnL1: EthAddress, // ethereum address that can call this function on the L1 portal (0x0 if anyone can call) + caller_on_l1: EthAddress, // ethereum address that can call this function on the L1 portal (0x0 if anyone can call) nonce: Field // nonce used in the approval message by `msg.sender` to let bridge burn their tokens on L2 ) { // Send an L2 to L1 message - let content = get_withdraw_content_hash(recipient, amount, callerOnL1); + let content = get_withdraw_content_hash(recipient, amount, caller_on_l1); context.message_portal(context.this_portal_address(), content); // docs:start:call_assert_token_is_same diff --git a/noir-projects/noir-contracts/contracts/token_portal_content_hash_lib/src/lib.nr b/noir-projects/noir-contracts/contracts/token_portal_content_hash_lib/src/lib.nr index 399baa4001e..cba27bb6ef9 100644 --- a/noir-projects/noir-contracts/contracts/token_portal_content_hash_lib/src/lib.nr +++ b/noir-projects/noir-contracts/contracts/token_portal_content_hash_lib/src/lib.nr @@ -54,7 +54,7 @@ pub fn get_mint_private_content_hash( // docs:start:get_withdraw_content_hash // Computes a content hash of a withdraw message. -pub fn get_withdraw_content_hash(recipient: EthAddress, amount: Field, callerOnL1: EthAddress) -> Field { +pub fn get_withdraw_content_hash(recipient: EthAddress, amount: Field, caller_on_l1: EthAddress) -> Field { // Compute the content hash // Compute sha256(selector || amount || recipient) // then convert to a single field element @@ -62,7 +62,7 @@ pub fn get_withdraw_content_hash(recipient: EthAddress, amount: Field, callerOnL let mut hash_bytes: [u8; 100] = [0; 100]; let recipient_bytes = recipient.to_field().to_be_bytes(32); let amount_bytes = amount.to_be_bytes(32); - let callerOnL1_bytes = callerOnL1.to_field().to_be_bytes(32); + let caller_on_l1_bytes = caller_on_l1.to_field().to_be_bytes(32); // 0x69328dec, selector for "withdraw(address,uint256,address)" hash_bytes[0] = 0x69; @@ -73,7 +73,7 @@ pub fn get_withdraw_content_hash(recipient: EthAddress, amount: Field, callerOnL for i in 0..32 { hash_bytes[i + 4] = recipient_bytes[i]; hash_bytes[i + 36] = amount_bytes[i]; - hash_bytes[i + 68] = callerOnL1_bytes[i]; + hash_bytes[i + 68] = caller_on_l1_bytes[i]; } let content_hash = sha256_to_field(hash_bytes); content_hash diff --git a/noir-projects/noir-contracts/contracts/uniswap_contract/src/interfaces.nr b/noir-projects/noir-contracts/contracts/uniswap_contract/src/interfaces.nr index 69972b4fb7a..81bf1824bfb 100644 --- a/noir-projects/noir-contracts/contracts/uniswap_contract/src/interfaces.nr +++ b/noir-projects/noir-contracts/contracts/uniswap_contract/src/interfaces.nr @@ -65,13 +65,13 @@ impl TokenBridge { context: &mut PublicContext, recipient: EthAddress, amount: Field, - callerOnL1: EthAddress, + caller_on_l1: EthAddress, nonce: Field ) { let _ = context.call_public_function( self.address, FunctionSelector::from_signature("exit_to_l1_public((Field),Field,(Field),Field)"), - [recipient.to_field(), amount, callerOnL1.to_field(), nonce] + [recipient.to_field(), amount, caller_on_l1.to_field(), nonce] ); } } diff --git a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/components.nr b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/components.nr index 72e2c47b46c..40b95332811 100644 --- a/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/components.nr +++ b/noir-projects/noir-protocol-circuits/crates/rollup-lib/src/components.nr @@ -145,10 +145,10 @@ pub fn compute_tx_effects_hash(combined: CombinedAccumulatedData) -> [Field; NUM let revert_code = combined.revert_code; let new_note_hashes = combined.new_note_hashes; let new_nullifiers = combined.new_nullifiers; - let newL2ToL1msgs = combined.new_l2_to_l1_msgs; + let new_l2_to_l1_msgs = combined.new_l2_to_l1_msgs; let public_data_update_requests = combined.public_data_update_requests; - let encryptedLogsHash = combined.encrypted_logs_hash; - let unencryptedLogsHash = combined.unencrypted_logs_hash; + let encrypted_logs_hash = combined.encrypted_logs_hash; + let unencrypted_logs_hash = combined.unencrypted_logs_hash; let mut offset = 0; @@ -167,7 +167,7 @@ pub fn compute_tx_effects_hash(combined: CombinedAccumulatedData) -> [Field; NUM offset += MAX_NEW_NULLIFIERS_PER_TX ; for j in 0..MAX_NEW_L2_TO_L1_MSGS_PER_TX { - txs_effects_hash_input[offset + j] = newL2ToL1msgs[j]; + txs_effects_hash_input[offset + j] = new_l2_to_l1_msgs[j]; } offset += MAX_NEW_L2_TO_L1_MSGS_PER_TX; @@ -180,13 +180,13 @@ pub fn compute_tx_effects_hash(combined: CombinedAccumulatedData) -> [Field; NUM offset += MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX * 2; for j in 0..NUM_FIELDS_PER_SHA256 { - txs_effects_hash_input[offset + j] = encryptedLogsHash[j]; + txs_effects_hash_input[offset + j] = encrypted_logs_hash[j]; } offset += NUM_ENCRYPTED_LOGS_HASHES_PER_TX * NUM_FIELDS_PER_SHA256; for j in 0..NUM_FIELDS_PER_SHA256 { - txs_effects_hash_input[offset + j] = unencryptedLogsHash[j]; + txs_effects_hash_input[offset + j] = unencrypted_logs_hash[j]; } offset += NUM_UNENCRYPTED_LOGS_HASHES_PER_TX * NUM_FIELDS_PER_SHA256; diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/abis/combined_constant_data.nr b/noir-projects/noir-protocol-circuits/crates/types/src/abis/combined_constant_data.nr index 1ae4ba6ce50..9dc4974700f 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/abis/combined_constant_data.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/abis/combined_constant_data.nr @@ -3,7 +3,7 @@ use crate::header::Header; struct CombinedConstantData { historical_header: Header, - // Note: `chainId` and `version` in txContext are not redundant to the values in + // Note: `chain_id` and `version` in tx_context are not redundant to the values in // self.historical_header.global_variables because they can be different in case of a protocol upgrade. In such // a situation we could be using header from a block before the upgrade took place but be using the updated // protocol to execute and prove the transaction. diff --git a/noir-projects/noir-protocol-circuits/crates/types/src/merkle_tree/append_only_tree.nr b/noir-projects/noir-protocol-circuits/crates/types/src/merkle_tree/append_only_tree.nr index b1faf2c06c7..b8ddea2a984 100644 --- a/noir-projects/noir-protocol-circuits/crates/types/src/merkle_tree/append_only_tree.nr +++ b/noir-projects/noir-protocol-circuits/crates/types/src/merkle_tree/append_only_tree.nr @@ -5,28 +5,28 @@ use crate::{ pub fn insert_subtree_to_snapshot_tree( snapshot: AppendOnlyTreeSnapshot, - siblingPath: [Field; N], - emptySubtreeRoot: Field, - subtreeRootToInsert: Field, - subtreeDepth: u8 + sibling_path: [Field; N], + empty_subtree_root: Field, + subtree_root_to_insert: Field, + subtree_depth: u8 ) -> AppendOnlyTreeSnapshot { - // TODO(Lasse): Sanity check len of siblingPath > height of subtree + // TODO(Lasse): Sanity check len of sibling_path > height of subtree // TODO(Lasse): Ensure height of subtree is correct (eg 3 for commitments, 1 for contracts) - let leafIndexAtDepth = snapshot.next_available_leaf_index >> (subtreeDepth as u32); + let leaf_index_at_depth = snapshot.next_available_leaf_index >> (subtree_depth as u32); // Check that the current root is correct and that there is an empty subtree at the insertion location assert_check_membership( - emptySubtreeRoot, - leafIndexAtDepth as Field, - siblingPath, + empty_subtree_root, + leaf_index_at_depth as Field, + sibling_path, snapshot.root ); - // if index of leaf is x, index of its parent is x/2 or x >> 1. We need to find the parent `subtreeDepth` levels up. - let new_root = root_from_sibling_path(subtreeRootToInsert, leafIndexAtDepth as Field, siblingPath); + // if index of leaf is x, index of its parent is x/2 or x >> 1. We need to find the parent `subtree_depth` levels up. + let new_root = root_from_sibling_path(subtree_root_to_insert, leaf_index_at_depth as Field, sibling_path); - // 2^subtreeDepth is the number of leaves added. 2^x = 1 << x - let new_next_available_leaf_index = (snapshot.next_available_leaf_index as u64) + (1 << (subtreeDepth as u64)); + // 2^subtree_depth is the number of leaves added. 2^x = 1 << x + let new_next_available_leaf_index = (snapshot.next_available_leaf_index as u64) + (1 << (subtree_depth as u64)); AppendOnlyTreeSnapshot { root: new_root, next_available_leaf_index: new_next_available_leaf_index as u32 } } diff --git a/yarn-project/aztec.js/README.md b/yarn-project/aztec.js/README.md index 46f84df88f8..294667159a8 100644 --- a/yarn-project/aztec.js/README.md +++ b/yarn-project/aztec.js/README.md @@ -37,6 +37,6 @@ console.log(`Transferred ${amount} to ${recipientAddress} on block ${tx.blockNum import { Contract } from '@aztec/aztec.js'; const contract = await Contract.at(contractAddress, MyContractArtifact, wallet); -const balance = await contract.methods.getBalance(wallet.getAddress()).view(); +const balance = await contract.methods.get_balance(wallet.getAddress()).view(); console.log(`Account balance is ${balance}`); ``` diff --git a/yarn-project/end-to-end/src/docs_examples.test.ts b/yarn-project/end-to-end/src/docs_examples.test.ts index 93eab76cfcb..c09c088bd40 100644 --- a/yarn-project/end-to-end/src/docs_examples.test.ts +++ b/yarn-project/end-to-end/src/docs_examples.test.ts @@ -42,5 +42,5 @@ const _tx = await contract.methods.transfer(1, wallet).send().wait(); // docs:end:send_transaction // docs:start:call_view_function -const _balance = await contract.methods.getBalance(wallet.getAddress()).view(); +const _balance = await contract.methods.get_balance(wallet.getAddress()).view(); // docs:end:call_view_function diff --git a/yarn-project/end-to-end/src/e2e_2_pxes.test.ts b/yarn-project/end-to-end/src/e2e_2_pxes.test.ts index 06e3a3f4f44..80f970483b1 100644 --- a/yarn-project/end-to-end/src/e2e_2_pxes.test.ts +++ b/yarn-project/end-to-end/src/e2e_2_pxes.test.ts @@ -194,7 +194,7 @@ describe('e2e_2_pxes', () => { const newValueToSet = new Fr(256n); const childContractWithWalletB = await ChildContract.at(childCompleteAddress.address, walletB); - await childContractWithWalletB.methods.pubIncValue(newValueToSet).send().wait({ interval: 0.1 }); + await childContractWithWalletB.methods.pub_inc_value(newValueToSet).send().wait({ interval: 0.1 }); await awaitServerSynchronized(pxeA); diff --git a/yarn-project/end-to-end/src/e2e_account_contracts.test.ts b/yarn-project/end-to-end/src/e2e_account_contracts.test.ts index 90807e53ee9..beb19f2ef51 100644 --- a/yarn-project/end-to-end/src/e2e_account_contracts.test.ts +++ b/yarn-project/end-to-end/src/e2e_account_contracts.test.ts @@ -51,7 +51,7 @@ function itShouldBehaveLikeAnAccountContract( it('calls a public function', async () => { const { logger, pxe } = context; logger('Calling public function...'); - await child.methods.pubIncValue(42).send().wait({ interval: 0.1 }); + await child.methods.pub_inc_value(42).send().wait({ interval: 0.1 }); const storedValue = await pxe.getPublicStorageAt(child.address, new Fr(1)); expect(storedValue).toEqual(new Fr(42n)); }, 60_000); diff --git a/yarn-project/end-to-end/src/e2e_nested_contract.test.ts b/yarn-project/end-to-end/src/e2e_nested_contract.test.ts index 9a520f6a210..8582ae4ecde 100644 --- a/yarn-project/end-to-end/src/e2e_nested_contract.test.ts +++ b/yarn-project/end-to-end/src/e2e_nested_contract.test.ts @@ -31,7 +31,7 @@ describe('e2e_nested_contract', () => { it('performs nested calls', async () => { await parentContract.methods - .entryPoint(childContract.address, childContract.methods.value.selector) + .entry_point(childContract.address, childContract.methods.value.selector) .send() .wait(); @@ -68,21 +68,21 @@ describe('e2e_nested_contract', () => { it('fails simulation if calling a function not allowed to be called externally', async () => { await expect( parentContract.methods - .entryPoint(childContract.address, (childContract.methods as any).valueInternal.selector) + .entry_point(childContract.address, (childContract.methods as any).value_internal.selector) .simulate(), - ).rejects.toThrow(/Assertion failed: Function valueInternal can only be called internally/); + ).rejects.toThrow(/Assertion failed: Function value_internal can only be called internally/); }, 100_000); it('performs public nested calls', async () => { await parentContract.methods - .pubEntryPoint(childContract.address, childContract.methods.pubGetValue.selector, 42n) + .pub_entry_point(childContract.address, childContract.methods.pub_get_value.selector, 42n) .send() .wait(); }, 100_000); it('enqueues a single public call', async () => { await parentContract.methods - .enqueueCallToChild(childContract.address, childContract.methods.pubIncValue.selector, 42n) + .enqueue_call_to_child(childContract.address, childContract.methods.pub_inc_value.selector, 42n) .send() .wait(); expect(await getChildStoredValue(childContract)).toEqual(new Fr(42n)); @@ -91,14 +91,18 @@ describe('e2e_nested_contract', () => { it('fails simulation if calling a public function not allowed to be called externally', async () => { await expect( parentContract.methods - .enqueueCallToChild(childContract.address, (childContract.methods as any).pubIncValueInternal.selector, 42n) + .enqueue_call_to_child( + childContract.address, + (childContract.methods as any).pub_inc_value_internal.selector, + 42n, + ) .simulate(), - ).rejects.toThrow(/Assertion failed: Function pubIncValueInternal can only be called internally/); + ).rejects.toThrow(/Assertion failed: Function pub_inc_value_internal can only be called internally/); }, 100_000); it('enqueues multiple public calls', async () => { await parentContract.methods - .enqueueCallToChildTwice(childContract.address, childContract.methods.pubIncValue.selector, 42n) + .enqueue_call_to_child_twice(childContract.address, childContract.methods.pub_inc_value.selector, 42n) .send() .wait(); expect(await getChildStoredValue(childContract)).toEqual(new Fr(85n)); @@ -106,7 +110,7 @@ describe('e2e_nested_contract', () => { it('enqueues a public call with nested public calls', async () => { await parentContract.methods - .enqueueCallToPubEntryPoint(childContract.address, childContract.methods.pubIncValue.selector, 42n) + .enqueue_call_to_pub_entry_point(childContract.address, childContract.methods.pub_inc_value.selector, 42n) .send() .wait(); expect(await getChildStoredValue(childContract)).toEqual(new Fr(42n)); @@ -114,7 +118,7 @@ describe('e2e_nested_contract', () => { it('enqueues multiple public calls with nested public calls', async () => { await parentContract.methods - .enqueueCallsToPubEntryPoint(childContract.address, childContract.methods.pubIncValue.selector, 42n) + .enqueue_calls_to_pub_entry_point(childContract.address, childContract.methods.pub_inc_value.selector, 42n) .send() .wait(); expect(await getChildStoredValue(childContract)).toEqual(new Fr(85n)); @@ -123,7 +127,7 @@ describe('e2e_nested_contract', () => { // Regression for https://github.com/AztecProtocol/aztec-packages/issues/640 it('reads fresh value after write within the same tx', async () => { await parentContract.methods - .pubEntryPointTwice(childContract.address, childContract.methods.pubIncValue.selector, 42n) + .pub_entry_point_twice(childContract.address, childContract.methods.pub_inc_value.selector, 42n) .send() .wait(); expect(await getChildStoredValue(childContract)).toEqual(new Fr(84n)); @@ -134,10 +138,10 @@ describe('e2e_nested_contract', () => { // through the account contract, if the account entrypoint behaves properly, it will honor // this order and not run the private call first which results in the public calls being inverted. it('executes public calls in expected order', async () => { - const pubSetValueSelector = childContract.methods.pubSetValue.selector; + const pubSetValueSelector = childContract.methods.pub_set_value.selector; const actions = [ - childContract.methods.pubSetValue(20n).request(), - parentContract.methods.enqueueCallToChild(childContract.address, pubSetValueSelector, 40n).request(), + childContract.methods.pub_set_value(20n).request(), + parentContract.methods.enqueue_call_to_child(childContract.address, pubSetValueSelector, 40n).request(), ]; const tx = await new BatchCall(wallet, actions).send().wait(); @@ -170,17 +174,17 @@ describe('e2e_nested_contract', () => { it('calls a method no arguments', async () => { logger(`Calling noargs on importer contract`); - await importerContract.methods.callNoArgs(testContract.address).send().wait(); + await importerContract.methods.call_no_args(testContract.address).send().wait(); }, 30_000); it('calls an open function', async () => { logger(`Calling openfn on importer contract`); - await importerContract.methods.callOpenFn(testContract.address).send().wait(); + await importerContract.methods.call_open_fn(testContract.address).send().wait(); }, 30_000); it('calls an open function from an open function', async () => { logger(`Calling pub openfn on importer contract`); - await importerContract.methods.pubCallOpenFn(testContract.address).send().wait(); + await importerContract.methods.pub_call_open_fn(testContract.address).send().wait(); }, 30_000); }); }); diff --git a/yarn-project/end-to-end/src/e2e_ordering.test.ts b/yarn-project/end-to-end/src/e2e_ordering.test.ts index 68836b1b2e3..450bc0eb214 100644 --- a/yarn-project/end-to-end/src/e2e_ordering.test.ts +++ b/yarn-project/end-to-end/src/e2e_ordering.test.ts @@ -41,7 +41,7 @@ describe('e2e_ordering', () => { beforeEach(async () => { parent = await ParentContract.deploy(wallet).send().deployed(); child = await ChildContract.deploy(wallet).send().deployed(); - pubSetValueSelector = child.methods.pubSetValue.selector; + pubSetValueSelector = child.methods.pub_set_value.selector; }); describe('enqueued public calls ordering', () => { @@ -49,11 +49,11 @@ describe('e2e_ordering', () => { const directValue = 20n; const expectedOrders = { - enqueueCallsToChildWithNestedFirst: [nestedValue, directValue] as bigint[], - enqueueCallsToChildWithNestedLast: [directValue, nestedValue] as bigint[], + enqueue_calls_to_child_with_nested_first: [nestedValue, directValue] as bigint[], // eslint-disable-line camelcase + enqueue_calls_to_child_with_nested_last: [directValue, nestedValue] as bigint[], // eslint-disable-line camelcase } as const; - it.each(['enqueueCallsToChildWithNestedFirst', 'enqueueCallsToChildWithNestedLast'] as const)( + it.each(['enqueue_calls_to_child_with_nested_first', 'enqueue_calls_to_child_with_nested_last'] as const)( 'orders public function execution in %s', async method => { const expectedOrder = expectedOrders[method]; @@ -91,11 +91,11 @@ describe('e2e_ordering', () => { const directValue = 20n; const expectedOrders = { - setValueTwiceWithNestedFirst: [nestedValue, directValue] as bigint[], - setValueTwiceWithNestedLast: [directValue, nestedValue] as bigint[], + set_value_twice_with_nested_first: [nestedValue, directValue] as bigint[], // eslint-disable-line camelcase + set_value_twice_with_nested_last: [directValue, nestedValue] as bigint[], // eslint-disable-line camelcase } as const; - it.each(['setValueTwiceWithNestedFirst', 'setValueTwiceWithNestedLast'] as const)( + it.each(['set_value_twice_with_nested_first', 'set_value_twice_with_nested_last'] as const)( 'orders public state updates in %s (and ensures final state value is correct)', async method => { const expectedOrder = expectedOrders[method]; @@ -112,9 +112,9 @@ describe('e2e_ordering', () => { // Emitting logs twice (first in a nested call, then directly) leads // to a misordering of them by the public kernel because it sees them // in reverse order. More info in this thread: https://discourse.aztec.network/t/identifying-the-ordering-of-state-access-across-contract-calls/382/12#transition-counters-for-private-calls-2 - // Once fixed, re-include the `setValueTwiceWithNestedFirst` test - //it.each(['setValueTwiceWithNestedFirst', 'setValueTwiceWithNestedLast'] as const)( - it.each(['setValueTwiceWithNestedLast'] as const)('orders unencrypted logs in %s', async method => { + // Once fixed, re-include the `set_value_twice_with_nested_first` test + //it.each(['set_value_twice_with_nested_first', 'set_value_twice_with_nested_last'] as const)( + it.each(['set_value_twice_with_nested_last'] as const)('orders unencrypted logs in %s', async method => { const expectedOrder = expectedOrders[method]; await child.methods[method]().send().wait(); diff --git a/yarn-project/end-to-end/src/e2e_static_calls.test.ts b/yarn-project/end-to-end/src/e2e_static_calls.test.ts index 6461ce22a6f..458ca88a76a 100644 --- a/yarn-project/end-to-end/src/e2e_static_calls.test.ts +++ b/yarn-project/end-to-end/src/e2e_static_calls.test.ts @@ -26,7 +26,7 @@ describe('e2e_static_calls', () => { await childContract.methods.privateSetValue(42n, wallet.getCompleteAddress().address).send().wait(); // ...this call doesn't fail due to get_notes returning 0 notes await parentContract.methods - .privateStaticCall(childContract.address, childContract.methods.privateGetValue.selector, [ + .private_static_call(childContract.address, childContract.methods.private_get_value.selector, [ 42n, wallet.getCompleteAddress().address, ]) @@ -39,7 +39,7 @@ describe('e2e_static_calls', () => { await childContract.methods.privateSetValue(42n, wallet.getCompleteAddress().address).send().wait(); // ...this call doesn't fail due to get_notes returning 0 notes await parentContract.methods - .privateStaticCallNested(childContract.address, childContract.methods.privateGetValue.selector, [ + .private_nested_static_call(childContract.address, childContract.methods.private_get_value.selector, [ 42n, wallet.getCompleteAddress().address, ]) @@ -49,28 +49,32 @@ describe('e2e_static_calls', () => { it('performs legal public to public static calls', async () => { await parentContract.methods - .publicStaticCall(childContract.address, childContract.methods.pubGetValue.selector, [42n]) + .public_static_call(childContract.address, childContract.methods.pub_get_value.selector, [42n]) .send() .wait(); }, 100_000); it('performs legal (nested) public to public static calls', async () => { await parentContract.methods - .publicNestedStaticCall(childContract.address, childContract.methods.pubGetValue.selector, [42n]) + .public_nested_static_call(childContract.address, childContract.methods.pub_get_value.selector, [42n]) .send() .wait(); }, 100_000); it('performs legal enqueued public static calls', async () => { await parentContract.methods - .enqueueStaticCallToPubFunction(childContract.address, childContract.methods.pubGetValue.selector, [42n]) + .enqueue_static_call_to_pub_function(childContract.address, childContract.methods.pub_get_value.selector, [42n]) .send() .wait(); }, 100_000); it('performs legal (nested) enqueued public static calls', async () => { await parentContract.methods - .enqueueStaticNestedCallToPubFunction(childContract.address, childContract.methods.pubGetValue.selector, [42n]) + .enqueue_static_nested_call_to_pub_function( + childContract.address, + childContract.methods.pub_get_value.selector, + [42n], + ) .send() .wait(); }, 100_000); @@ -78,7 +82,7 @@ describe('e2e_static_calls', () => { it('fails when performing illegal private to private static calls', async () => { await expect( parentContract.methods - .privateStaticCall(childContract.address, childContract.methods.privateSetValue.selector, [ + .private_static_call(childContract.address, childContract.methods.private_set_value.selector, [ 42n, wallet.getCompleteAddress().address, ]) @@ -90,7 +94,7 @@ describe('e2e_static_calls', () => { it('fails when performing illegal (nested) private to private static calls', async () => { await expect( parentContract.methods - .privateStaticCallNested(childContract.address, childContract.methods.privateSetValue.selector, [ + .private_nested_static_call(childContract.address, childContract.methods.private_set_value.selector, [ 42n, wallet.getCompleteAddress().address, ]) @@ -102,7 +106,7 @@ describe('e2e_static_calls', () => { it('fails when performing illegal public to public static calls', async () => { await expect( parentContract.methods - .publicStaticCall(childContract.address, childContract.methods.pubSetValue.selector, [42n]) + .public_static_call(childContract.address, childContract.methods.pub_set_value.selector, [42n]) .send() .wait(), ).rejects.toThrow('Static call cannot update the state, emit L2->L1 messages or generate logs'); @@ -111,7 +115,7 @@ describe('e2e_static_calls', () => { it('fails when performing illegal (nested) public to public static calls', async () => { await expect( parentContract.methods - .publicNestedStaticCall(childContract.address, childContract.methods.pubSetValue.selector, [42n]) + .public_nested_static_call(childContract.address, childContract.methods.pub_set_value.selector, [42n]) .send() .wait(), ).rejects.toThrow('Static call cannot update the state, emit L2->L1 messages or generate logs'); @@ -120,7 +124,9 @@ describe('e2e_static_calls', () => { it('fails when performing illegal enqueued public static calls', async () => { await expect( parentContract.methods - .enqueueStaticCallToPubFunction(childContract.address, childContract.methods.pubSetValue.selector, [42n]) + .enqueue_static_call_to_pub_function(childContract.address, childContract.methods.pub_set_value.selector, [ + 42n, + ]) .send() .wait(), ).rejects.toThrow('Static call cannot update the state, emit L2->L1 messages or generate logs'); @@ -129,9 +135,11 @@ describe('e2e_static_calls', () => { it('fails when performing illegal (nested) enqueued public static calls', async () => { await expect( parentContract.methods - .enqueueStaticNestedCallToPubFunction(childContract.address, childContract.methods.pubSetValue.selector, [ - 42n, - ]) + .enqueue_static_nested_call_to_pub_function( + childContract.address, + childContract.methods.pub_set_value.selector, + [42n], + ) .send() .wait(), ).rejects.toThrow('Static call cannot update the state, emit L2->L1 messages or generate logs'); diff --git a/yarn-project/simulator/src/client/private_execution.test.ts b/yarn-project/simulator/src/client/private_execution.test.ts index 32b6d1f8b86..6a938252408 100644 --- a/yarn-project/simulator/src/client/private_execution.test.ts +++ b/yarn-project/simulator/src/client/private_execution.test.ts @@ -438,7 +438,7 @@ describe('Private Execution test suite', () => { it('parent should call child', async () => { const childArtifact = getFunctionArtifact(ChildContractArtifact, 'value'); - const parentArtifact = getFunctionArtifact(ParentContractArtifact, 'entryPoint'); + const parentArtifact = getFunctionArtifact(ParentContractArtifact, 'entry_point'); const parentAddress = AztecAddress.random(); const childAddress = AztecAddress.random(); const childSelector = FunctionSelector.fromNameAndParameters(childArtifact.name, childArtifact.parameters); @@ -770,8 +770,8 @@ describe('Private Execution test suite', () => { describe('enqueued calls', () => { it.each([false, true])('parent should enqueue call to child (internal %p)', async isInternal => { - const parentArtifact = getFunctionArtifact(ParentContractArtifact, 'enqueueCallToChild'); - const childContractArtifact = ChildContractArtifact.functions.find(fn => fn.name === 'pubSetValue')!; + const parentArtifact = getFunctionArtifact(ParentContractArtifact, 'enqueue_call_to_child'); + const childContractArtifact = ChildContractArtifact.functions.find(fn => fn.name === 'pub_set_value')!; expect(childContractArtifact).toBeDefined(); const childAddress = AztecAddress.random(); const childPortalContractAddress = EthAddress.random(); diff --git a/yarn-project/simulator/src/public/index.test.ts b/yarn-project/simulator/src/public/index.test.ts index 01a2cbe946a..e232b2ecd01 100644 --- a/yarn-project/simulator/src/public/index.test.ts +++ b/yarn-project/simulator/src/public/index.test.ts @@ -247,14 +247,14 @@ describe('ACIR public execution simulator', () => { describe('Parent/Child contracts', () => { it('calls the public entry point in the parent', async () => { const parentContractAddress = AztecAddress.random(); - const parentEntryPointFn = ParentContractArtifact.functions.find(f => f.name === 'pubEntryPoint')!; + const parentEntryPointFn = ParentContractArtifact.functions.find(f => f.name === 'pub_entry_point')!; const parentEntryPointFnSelector = FunctionSelector.fromNameAndParameters( parentEntryPointFn.name, parentEntryPointFn.parameters, ); const childContractAddress = AztecAddress.random(); - const childValueFn = ChildContractArtifact.functions.find(f => f.name === 'pubGetValue')!; + const childValueFn = ChildContractArtifact.functions.find(f => f.name === 'pub_get_value')!; const childValueFnSelector = FunctionSelector.fromNameAndParameters(childValueFn.name, childValueFn.parameters); const initialValue = 3n;