diff --git a/circuits/cpp/src/aztec3/circuits/apps/.test.cpp b/circuits/cpp/src/aztec3/circuits/apps/.test.cpp index d2bbc2cbd9d..9d841a0cebc 100644 --- a/circuits/cpp/src/aztec3/circuits/apps/.test.cpp +++ b/circuits/cpp/src/aztec3/circuits/apps/.test.cpp @@ -208,7 +208,7 @@ TEST_F(state_var_tests, circuit_utxo_of_default_private_note_fr) .creator_address = msg_sender, .memo = 1234 }); - exec_ctx.finalise(); + exec_ctx.finalize(); // Here, we test that the shared_ptr of a note, stored within the exec_ctx, works. TODO: put this in its own little // test, instead of this ever-growing beast test. @@ -270,7 +270,7 @@ TEST_F(state_var_tests, circuit_utxo_set_of_default_private_notes_fr) .memo = 1234, }); - exec_ctx.finalise(); + exec_ctx.finalize(); // Here, we test that the shared_ptr of a note, stored within the exec_ctx, works. TODO: put this in its own little // test, instead of this ever-growing beast test. @@ -318,7 +318,7 @@ TEST_F(state_var_tests, circuit_initialise_utxo_of_default_singleton_private_not my_utxo.initialise({ .value = 100, .owner = owner_of_initialised_note }); - exec_ctx.finalise(); + exec_ctx.finalize(); // Here, we test that the shared_ptr of a note, stored within the exec_ctx, works. TODO: put this in its own little // test, instead of this ever-growing beast test. @@ -367,7 +367,7 @@ TEST_F(state_var_tests, circuit_modify_utxo_of_default_singleton_private_note_fr .owner = msg_sender, }); - exec_ctx.finalise(); + exec_ctx.finalize(); // Here, we test that the shared_ptr of a note, stored within the exec_ctx, works. TODO: put this in its own little // test, instead of this ever-growing beast test. diff --git a/circuits/cpp/src/aztec3/circuits/apps/function_execution_context.hpp b/circuits/cpp/src/aztec3/circuits/apps/function_execution_context.hpp index ad1b597f4ba..ab48743b119 100644 --- a/circuits/cpp/src/aztec3/circuits/apps/function_execution_context.hpp +++ b/circuits/cpp/src/aztec3/circuits/apps/function_execution_context.hpp @@ -67,7 +67,7 @@ template class FunctionExecutionContext { PrivateCircuitPublicInputs final_private_circuit_public_inputs{}; - bool is_finalised = false; + bool is_finalized = false; public: FunctionExecutionContext(Builder& builder, OracleWrapperInterface& oracle) @@ -101,8 +101,8 @@ template class FunctionExecutionContext { PrivateCircuitPublicInputs get_final_private_circuit_public_inputs() { // For safety, only return this if the circuit is complete. - if (!is_finalised) { - throw_or_abort("You need to call exec_ctx.finalise() in your circuit first."); + if (!is_finalized) { + throw_or_abort("You need to call exec_ctx.finalize() in your circuit first."); } return final_private_circuit_public_inputs; } @@ -287,7 +287,7 @@ template class FunctionExecutionContext { * TODO: Might need some refactoring. Roles between: Opcodes modifying exec_ctx members; and the exec_ctx directly * modifying its members, are somewhat blurred at the moment. */ - void finalise_utxos() + void finalize_utxos() { // Copy some vectors, as we can't control whether they'll be pushed-to further, when we call Note methods. auto new_nullifiers_copy = new_nullifiers; @@ -319,16 +319,16 @@ template class FunctionExecutionContext { std::copy(new_nonces.begin(), new_nonces.end(), std::back_inserter(new_nullifiers)); } - void finalise() + void finalize() { - finalise_utxos(); + finalize_utxos(); private_circuit_public_inputs.set_commitments(new_commitments); private_circuit_public_inputs.set_nullifiers(new_nullifiers); private_circuit_public_inputs.set_nullified_commitments(nullified_commitments); private_circuit_public_inputs.set_public(builder); final_private_circuit_public_inputs = private_circuit_public_inputs.remove_optionality().template to_native_type(); - is_finalised = true; + is_finalized = true; } }; diff --git a/circuits/cpp/src/aztec3/circuits/apps/test_apps/basic_contract_deployment/basic_contract_deployment.cpp b/circuits/cpp/src/aztec3/circuits/apps/test_apps/basic_contract_deployment/basic_contract_deployment.cpp index 2aff1c41490..5a9e39fe27f 100644 --- a/circuits/cpp/src/aztec3/circuits/apps/test_apps/basic_contract_deployment/basic_contract_deployment.cpp +++ b/circuits/cpp/src/aztec3/circuits/apps/test_apps/basic_contract_deployment/basic_contract_deployment.cpp @@ -43,7 +43,7 @@ OptionalPrivateCircuitPublicInputs constructor(FunctionExecutionContext& exe auto& public_inputs = exec_ctx.private_circuit_public_inputs; public_inputs.args_hash = compute_var_args_hash({ arg0, arg1, arg2 }); - exec_ctx.finalise(); + exec_ctx.finalize(); // info("public inputs: ", public_inputs); diff --git a/circuits/cpp/src/aztec3/circuits/apps/test_apps/escrow/deposit.cpp b/circuits/cpp/src/aztec3/circuits/apps/test_apps/escrow/deposit.cpp index 59d2ccb50d6..61703be8a8c 100644 --- a/circuits/cpp/src/aztec3/circuits/apps/test_apps/escrow/deposit.cpp +++ b/circuits/cpp/src/aztec3/circuits/apps/test_apps/escrow/deposit.cpp @@ -55,7 +55,7 @@ OptionalPrivateCircuitPublicInputs deposit(FunctionExecutionContext& exec_ct auto& public_inputs = exec_ctx.private_circuit_public_inputs; public_inputs.args_hash = compute_var_args_hash({ amount, asset_id, memo }); - exec_ctx.finalise(); + exec_ctx.finalize(); // info("public inputs: ", public_inputs); diff --git a/circuits/cpp/src/aztec3/circuits/apps/test_apps/escrow/transfer.cpp b/circuits/cpp/src/aztec3/circuits/apps/test_apps/escrow/transfer.cpp index 51e1a0be733..241fa2f5de1 100644 --- a/circuits/cpp/src/aztec3/circuits/apps/test_apps/escrow/transfer.cpp +++ b/circuits/cpp/src/aztec3/circuits/apps/test_apps/escrow/transfer.cpp @@ -95,7 +95,7 @@ OptionalPrivateCircuitPublicInputs transfer(FunctionExecutionContext& exec_c /// TODO: merkle membership check // public_inputs.historic_private_data_tree_root - exec_ctx.finalise(); + exec_ctx.finalize(); // info("public inputs: ", public_inputs); diff --git a/circuits/cpp/src/aztec3/circuits/apps/test_apps/escrow/withdraw.cpp b/circuits/cpp/src/aztec3/circuits/apps/test_apps/escrow/withdraw.cpp index fdba8ab35e1..1e586bc242c 100644 --- a/circuits/cpp/src/aztec3/circuits/apps/test_apps/escrow/withdraw.cpp +++ b/circuits/cpp/src/aztec3/circuits/apps/test_apps/escrow/withdraw.cpp @@ -83,7 +83,7 @@ OptionalPrivateCircuitPublicInputs withdraw(FunctionExecutionContext& exec_c auto& public_inputs = exec_ctx.private_circuit_public_inputs; public_inputs.args_hash = compute_var_args_hash({ amount, asset_id, memo, l1_withdrawal_address, fee }); - exec_ctx.finalise(); + exec_ctx.finalize(); /// TODO: merkle membership check // public_inputs.historic_private_data_tree_root diff --git a/circuits/cpp/src/aztec3/circuits/apps/test_apps/private_to_private_function_call/function_1_1.cpp b/circuits/cpp/src/aztec3/circuits/apps/test_apps/private_to_private_function_call/function_1_1.cpp index 4377da64a9b..13507d6b83c 100644 --- a/circuits/cpp/src/aztec3/circuits/apps/test_apps/private_to_private_function_call/function_1_1.cpp +++ b/circuits/cpp/src/aztec3/circuits/apps/test_apps/private_to_private_function_call/function_1_1.cpp @@ -80,7 +80,7 @@ void function_1_1(FunctionExecutionContext& exec_ctx, std::vector const& auto& public_inputs = exec_ctx.private_circuit_public_inputs; public_inputs.args_hash = compute_var_args_hash({ a, b, c }); - exec_ctx.finalise(); + exec_ctx.finalize(); }; } // namespace aztec3::circuits::apps::test_apps::private_to_private_function_call \ No newline at end of file diff --git a/circuits/cpp/src/aztec3/circuits/apps/test_apps/private_to_private_function_call/function_2_1.cpp b/circuits/cpp/src/aztec3/circuits/apps/test_apps/private_to_private_function_call/function_2_1.cpp index ac424411667..ba5f5197e59 100644 --- a/circuits/cpp/src/aztec3/circuits/apps/test_apps/private_to_private_function_call/function_2_1.cpp +++ b/circuits/cpp/src/aztec3/circuits/apps/test_apps/private_to_private_function_call/function_2_1.cpp @@ -63,7 +63,7 @@ void function_2_1(FunctionExecutionContext& exec_ctx, std::vector const& public_inputs.return_values[0] = product; - exec_ctx.finalise(); + exec_ctx.finalize(); // info("public inputs: ", public_inputs); diff --git a/docs/docs/concepts/foundation/communication/cross_chain_calls.md b/docs/docs/concepts/foundation/communication/cross_chain_calls.md index 4daf9672a05..86554a82090 100644 --- a/docs/docs/concepts/foundation/communication/cross_chain_calls.md +++ b/docs/docs/concepts/foundation/communication/cross_chain_calls.md @@ -77,7 +77,7 @@ The L2 -> L1 pending messages set only exist logically, as it is practically unn ### Rollup Contract -The rollup contract has a few very important responsibilities. The contract must keep track of the _L2 rollup state root_, perform _state transitions_ and ensure that the data is available for anyone else to synchronise to the current state. +The rollup contract has a few very important responsibilities. The contract must keep track of the _L2 rollup state root_, perform _state transitions_ and ensure that the data is available for anyone else to synchronize to the current state. To ensure that _state transitions_ are performed correctly, the contract will derive public inputs for the **rollup circuit** based on the input data, and then use a _verifier_ contract to validate that inputs correctly transition the current state to the next. All data needed for the public inputs to the circuit must be from the rollup block, ensuring that the block is available. For a valid proof, the _rollup state root_ is updated and it will emit an _event_ to make it easy for anyone to find the data by event spotting. diff --git a/docs/docs/dev_docs/cli/main.md b/docs/docs/dev_docs/cli/main.md index 3bcf02ead78..363677b4c2e 100644 --- a/docs/docs/dev_docs/cli/main.md +++ b/docs/docs/dev_docs/cli/main.md @@ -79,7 +79,7 @@ Let's double check that the accounts have been registered with the sandbox using #include_code get-accounts yarn-project/end-to-end/src/cli_docs_sandbox.test.ts bash -You will see a that a number of accounts exist that we did not create. The Sandbox initialises itself with 3 default accounts. Save one of the printed accounts (not the one that you generated above) in an environment variable. We will use it later. +You will see a that a number of accounts exist that we did not create. The Sandbox initializes itself with 3 default accounts. Save one of the printed accounts (not the one that you generated above) in an environment variable. We will use it later. ```bash export ADDRESS2= diff --git a/docs/docs/dev_docs/contracts/compiling.md b/docs/docs/dev_docs/contracts/compiling.md index e9c62495470..ac14588acfb 100644 --- a/docs/docs/dev_docs/contracts/compiling.md +++ b/docs/docs/dev_docs/contracts/compiling.md @@ -102,25 +102,25 @@ impl PrivateTokenPrivateContextInterface { fn mint( self, context: &mut PrivateContext, amount: Field, owner: Field ) -> [Field; RETURN_VALUES_LENGTH] { - let mut serialised_args = [0; 2]; - serialised_args[0] = amount; - serialised_args[1] = owner; + let mut serialized_args = [0; 2]; + serialized_args[0] = amount; + serialized_args[1] = owner; // 0x1dc9c3c0 is the function selector for `mint(field,field)` - context.call_private_function(self.address, 0x1dc9c3c0, serialised_args) + context.call_private_function(self.address, 0x1dc9c3c0, serialized_args) } fn transfer( self, context: &mut PrivateContext, amount: Field, sender: Field, recipient: Field ) -> [Field; RETURN_VALUES_LENGTH] { - let mut serialised_args = [0; 3]; - serialised_args[0] = amount; - serialised_args[1] = sender; - serialised_args[2] = recipient; + let mut serialized_args = [0; 3]; + serialized_args[0] = amount; + serialized_args[1] = sender; + serialized_args[2] = recipient; // 0xdcd4c318 is the function selector for `transfer(field,field,field)` - context.call_private_function(self.address, 0xdcd4c318, serialised_args) + context.call_private_function(self.address, 0xdcd4c318, serialized_args) } } ``` diff --git a/docs/docs/dev_docs/contracts/syntax/functions.md b/docs/docs/dev_docs/contracts/syntax/functions.md index 93e2f0a5887..da39abcdef8 100644 --- a/docs/docs/dev_docs/contracts/syntax/functions.md +++ b/docs/docs/dev_docs/contracts/syntax/functions.md @@ -38,7 +38,7 @@ While `staticcall` and `delegatecall` both have flags in the call context, they ## `constructor` - A special `constructor` function MUST be declared within a contract's scope. -- A constructor doesn't have a name, because its purpose is clear: to initialise contract state. +- A constructor doesn't have a name, because its purpose is clear: to initialize contract state. - In Aztec terminology, a constructor is always a '`private` function' (i.e. it cannot be a `public` function, in the current version of the sandbox it cannot call public functions either). - A constructor behaves almost identically to any other function. It's just important for Aztec to be able to identify this function as special: it may only be called once, and will not be deployed as part of the contract. diff --git a/docs/docs/dev_docs/contracts/syntax/state_variables.md b/docs/docs/dev_docs/contracts/syntax/state_variables.md index c9868cc47bf..830d3538824 100644 --- a/docs/docs/dev_docs/contracts/syntax/state_variables.md +++ b/docs/docs/dev_docs/contracts/syntax/state_variables.md @@ -2,9 +2,9 @@ title: State Variables --- -State variables come in two flavours: [**public** state](#publicstatet-t_serialised_len) and [**private** state](#private-state-variables). +State variables come in two flavours: [**public** state](#publicstatet-t_serialized_len) and [**private** state](#private-state-variables). -## `PublicState` +## `PublicState` Public state is persistent state that is _publicly visible_ to anyone in the world. @@ -12,7 +12,7 @@ For developers coming from other blockchain ecosystems (such as Ethereum), this Aztec public state follows an account-based model. That is, each state occupies a leaf in an account-based merkle tree: the public state tree. See [here](/concepts/advanced/data_structures/trees#public-state-tree) for more of the technical details. -The `PublicState` struct serves as a wrapper around conventional Noir types `T`, allowing these types to be written to and read from the public state tree. +The `PublicState` struct serves as a wrapper around conventional Noir types `T`, allowing these types to be written to and read from the public state tree. ### `::new` @@ -22,13 +22,13 @@ In the following example, we define a public state with a boolean type: #include_code state_vars-PublicState /yarn-project/noir-contracts/src/contracts/docs_example_contract/src/main.nr rust -The BoolSerialisationMethods is part of the Aztec stdlib: +The BoolSerializationMethods is part of the Aztec stdlib: #include_code state_vars-PublicStateBoolImport /yarn-project/noir-contracts/src/contracts/docs_example_contract/src/main.nr rust -It contains methods that instruct its PublicState wrapper how to serialise and deserialise a boolean to and from a Field, which is the data type being saved in the public state tree. +It contains methods that instruct its PublicState wrapper how to serialize and deserialize a boolean to and from a Field, which is the data type being saved in the public state tree. -The Aztec stdlib provides serialization methods for various common types. Check [here](https://github.com/AztecProtocol/aztec-packages/blob/master/yarn-project/aztec-nr/aztec/src/types/type_serialisation) for the complete list. +The Aztec stdlib provides serialization methods for various common types. Check [here](https://github.com/AztecProtocol/aztec-packages/blob/master/yarn-project/aztec-nr/aztec/src/types/type_serialization) for the complete list. ### Custom types @@ -36,17 +36,17 @@ It's possible to create a public state for any types. Simply define methods that The methods should be implemented in a struct that conforms to the following interface: -#include_code TypeSerialisationInterface /yarn-project/aztec-nr/aztec/src/types/type_serialisation.nr rust +#include_code TypeSerializationInterface /yarn-project/aztec-nr/aztec/src/types/type_serialization.nr rust For example, to create a public state for the following type: #include_code state_vars-CustomStruct /yarn-project/noir-contracts/src/contracts/docs_example_contract/src/types/queen.nr rust -First, define how to serialise and deserialise the custom type: +First, define how to serialize and deserialize the custom type: #include_code state_vars-PublicStateCustomStruct /yarn-project/noir-contracts/src/contracts/docs_example_contract/src/types/queen.nr rust -And then initialise the PublicState with it: +And then initialize the PublicState with it: #include_code state_vars-PublicStateCustomStruct /yarn-project/noir-contracts/src/contracts/docs_example_contract/src/main.nr rust @@ -66,7 +66,7 @@ Every public state can be read before its value is written. The default value is The currently-stored value of a private state variable can be overwritten with `.write()`. -Due to the way public states are [declared](#new), a public state knows how to serialise a given value and store it in the protocol's public state tree. +Due to the way public states are [declared](#new), a public state knows how to serialize a given value and store it in the protocol's public state tree. We can pass the associated type directly to the `write()` method: @@ -133,7 +133,7 @@ The interplay between a private state variable and its notes can be confusing. H ## `Singleton` -Singleton is a private state variable that is unique in a way. When a Singleton is initialised, a note is created to represent its value. And the way to update the value is to destroy the current note, and create a new one with the updated value. +Singleton is a private state variable that is unique in a way. When a Singleton is initialized, a note is created to represent its value. And the way to update the value is to destroy the current note, and create a new one with the updated value. ### `::new` @@ -141,15 +141,15 @@ Here we define a Singleton for storing a `CardNote`: #include_code state_vars-Singleton /yarn-project/noir-contracts/src/contracts/docs_example_contract/src/main.nr rust -### `.initialise` +### `.initialize` -The initial value of a Singleton is set via calling `initialise`: +The initial value of a Singleton is set via calling `initialize`: #include_code state_vars-SingletonInit /yarn-project/noir-contracts/src/contracts/docs_example_contract/src/actions.nr rust -When this function is called, a nullifier of the storage slot is created, preventing this Singleton from being initialised again. +When this function is called, a nullifier of the storage slot is created, preventing this Singleton from being initialized again. -Unlike public states, which have a default initial value of `0` (or many zeros, in the case of a struct, array or map), a private state (of type `Singleton`, `ImmutableSingleton` or `Set`) does not have a default initial value. The `initialise` method (or `insert`, in the case of a `Set`) must be called. +Unlike public states, which have a default initial value of `0` (or many zeros, in the case of a struct, array or map), a private state (of type `Singleton`, `ImmutableSingleton` or `Set`) does not have a default initial value. The `initialize` method (or `insert`, in the case of a `Set`) must be called. ### `.replace` @@ -179,9 +179,9 @@ In the following example, we define an ImmutableSingleton that utilises the `Rul #include_code state_vars-ImmutableSingleton /yarn-project/noir-contracts/src/contracts/docs_example_contract/src/main.nr rust -### `.initialise` +### `.initialize` -Set the initial value of an ImmutableSingleton by calling the `initialise` method: +Set the initial value of an ImmutableSingleton by calling the `initialize` method: #include_code state_vars-ImmutableSingletonInit /yarn-project/noir-contracts/src/contracts/docs_example_contract/src/actions.nr rust @@ -195,7 +195,7 @@ Use this method to retrieve the value of an initialized ImmutableSingleton: Unlike a [`singleton`](#get_note-1), the `get_note` function for an ImmutableSingleton doesn't destroy the current note in the background. This means that multiple accounts can concurrently call this function to read the value. -This function will throw if the ImmutableSingleton hasn't been initialised. +This function will throw if the ImmutableSingleton hasn't been initialized. ## `Set` @@ -269,11 +269,11 @@ Several methods are available on `NoteGetterOptions` to construct the options in #### `fn new() -> NoteGetterOptions` -This function initialises a `NoteGetterOptions` that simply returns the maximum number of notes allowed in a call. +This function initializes a `NoteGetterOptions` that simply returns the maximum number of notes allowed in a call. #### `fn with_filter(filter, filter_args) -> NoteGetterOptions` -This function initialises a `NoteGetterOptions` with a [`filter`](#filter-fn-optionnote-max_read_requests_per_call-filter_args---optionnote-max_read_requests_per_call) and [`filter_args`](#filter_args-filter_args). +This function initializes a `NoteGetterOptions` with a [`filter`](#filter-fn-optionnote-max_read_requests_per_call-filter_args---optionnote-max_read_requests_per_call) and [`filter_args`](#filter_args-filter_args). #### `.select` @@ -347,7 +347,7 @@ The `NoteViewerOptions` is essentially similar to the [`NoteGetterOptions`](#not ## `Map` -`Map` is a state variable that maps a `Field` to another state variable, which can be [`PublicState`](#publicstatet-t_serialised_len), all the [private state variables](#private-state-variables), and even another Map. +`Map` is a state variable that maps a `Field` to another state variable, which can be [`PublicState`](#publicstatet-t_serialized_len), all the [private state variables](#private-state-variables), and even another Map. > `Map` can map from `Field` or any native Noir type which is convertible to `Field`. diff --git a/docs/docs/dev_docs/sandbox_errors/main.md b/docs/docs/dev_docs/sandbox_errors/main.md index c13345e00dd..1c6561d02ca 100644 --- a/docs/docs/dev_docs/sandbox_errors/main.md +++ b/docs/docs/dev_docs/sandbox_errors/main.md @@ -31,7 +31,7 @@ You cannot execute a public Aztec.nr function in the private kernel #### 2011 - PRIVATE_KERNEL__UNSUPPORTED_OP You are trying to do something that is currently unsupported in the private kernel. If this is a blocker feel free to open up an issue on our monorepo [aztec3-packages](https://github.com/AztecProtocol/aztec3-packages/tree/master) or reach out to us on discord -Note that certain operations are unsupported on certain versions of the private kernel. Eg static calls are allowed for all but the initial iteration of the private kernel (which initialises the kernel for subsequent function calls). +Note that certain operations are unsupported on certain versions of the private kernel. Eg static calls are allowed for all but the initial iteration of the private kernel (which initializes the kernel for subsequent function calls). #### 2012 - PRIVATE_KERNEL__CONTRACT_ADDRESS_MISMATCH For the initial iteration of the private kernel, only the expected Aztec.nr contract should be the entrypoint. Static and delegate calls are not allowed in the initial iteration. diff --git a/docs/docs/dev_docs/testing/cheat_codes.md b/docs/docs/dev_docs/testing/cheat_codes.md index 4e2ca1ac099..3fd12b18325 100644 --- a/docs/docs/dev_docs/testing/cheat_codes.md +++ b/docs/docs/dev_docs/testing/cheat_codes.md @@ -458,13 +458,13 @@ The baseSlot is specified in the Aztec.nr contract. ```rust struct Storage { - balances: Map>, + balances: Map>, } impl Storage { fn init() -> Self { Storage { - balances: Map::new(1, |slot| PublicState::new(slot, FieldSerialisationMethods)), + balances: Map::new(1, |slot| PublicState::new(slot, FieldSerializationMethods)), } } } @@ -496,13 +496,13 @@ Note: One Field element occupies a storage slot. Hence, structs with multiple fi ```rust struct Storage { - balances: Map>, + balances: Map>, } impl Storage { fn init() -> Self { Storage { - balances: Map::new(1, |slot| PublicState::new(slot, FieldSerialisationMethods)), + balances: Map::new(1, |slot| PublicState::new(slot, FieldSerializationMethods)), } } } diff --git a/docs/docs/dev_docs/tutorials/writing_dapp/contract_deployment.md b/docs/docs/dev_docs/tutorials/writing_dapp/contract_deployment.md index 033f155ccfd..34ce039738d 100644 --- a/docs/docs/dev_docs/tutorials/writing_dapp/contract_deployment.md +++ b/docs/docs/dev_docs/tutorials/writing_dapp/contract_deployment.md @@ -6,9 +6,9 @@ To add contracts to your application, we'll start by creating a new `nargo` proj Follow the instructions [here](../../contracts/setup.md) to install `nargo` if you haven't done so already. ::: -## Initialise nargo project +## initialize nargo project -Create a new `contracts` folder, and from there, initialise a new project called `token`: +Create a new `contracts` folder, and from there, initialize a new project called `token`: ```sh mkdir contracts && cd contracts diff --git a/docs/docs/dev_docs/tutorials/writing_dapp/contract_interaction.md b/docs/docs/dev_docs/tutorials/writing_dapp/contract_interaction.md index 545cc827100..c33fc40d16c 100644 --- a/docs/docs/dev_docs/tutorials/writing_dapp/contract_interaction.md +++ b/docs/docs/dev_docs/tutorials/writing_dapp/contract_interaction.md @@ -12,7 +12,7 @@ Let's start by showing our user's private balance for the token across their acc Note that this function will only return a valid response for accounts registered in the RPC Server, since it requires access to the [user's private state](../../wallets/main.md#private-state). In other words, you cannot query the private balance of another user for the token contract. ::: -To do this, let's first initialise a new `Contract` instance using `aztec.js` that represents our deployed token contracts. Create a new `src/contracts.mjs` file with the imports for our artifacts and other dependencies: +To do this, let's first initialize a new `Contract` instance using `aztec.js` that represents our deployed token contracts. Create a new `src/contracts.mjs` file with the imports for our artifacts and other dependencies: ```js // src/contracts.mjs @@ -45,7 +45,7 @@ Balance of 0x0e1f60e8566e2c6d32378bdcadb7c63696e853281be798c107266b8c3a88ea9b: 0 Now that we can see the balance for each user, let's transfer tokens from one account to another. To do this, we will first need access to a `Wallet` object. This wraps access to an RPC Server and also provides an interface to craft and sign transactions on behalf of one of the user accounts. -We can initialise a wallet using one of the `getAccount` methods from `aztec.js`, along with the corresponding signing and encryption keys: +We can initialize a wallet using one of the `getAccount` methods from `aztec.js`, along with the corresponding signing and encryption keys: ```js import { getSchnorrAccount } from "@aztec/aztec.js"; @@ -56,17 +56,17 @@ const wallet = await getSchnorrAccount( ).getWallet(); ``` -For ease of use, `aztec.js` also ships with a helper `getSandboxAccountsWallets` method that returns a wallet for each of the pre-initialised accounts in the Sandbox, so you can send transactions as any of them. +For ease of use, `aztec.js` also ships with a helper `getSandboxAccountsWallets` method that returns a wallet for each of the pre-initialized accounts in the Sandbox, so you can send transactions as any of them. ```js import { getSandboxAccountsWallets } from '@aztec/aztec.js'; ``` -We'll use one of these wallets to initialise the `Contract` instance that represents our private token contract, so every transaction sent through it will be sent through that wallet. +We'll use one of these wallets to initialize the `Contract` instance that represents our private token contract, so every transaction sent through it will be sent through that wallet. #include_code transferPrivateFunds yarn-project/end-to-end/src/sample-dapp/index.mjs javascript -Let's go step-by-step on this snippet. We first get wallets for two of the Sandbox accounts, and name them `owner` and `recipient`. Then, we initialise the private token `Contract` instance using the `owner` wallet, meaning that any transactions sent through it will have the `owner` as sender. +Let's go step-by-step on this snippet. We first get wallets for two of the Sandbox accounts, and name them `owner` and `recipient`. Then, we initialize the private token `Contract` instance using the `owner` wallet, meaning that any transactions sent through it will have the `owner` as sender. Next, we send a transfer transaction, moving 1 unit of balance to the `recipient` account address. This has no immediate effect, since the transaction first needs to be simulated locally and then submitted and mined. Only once this has finished we can query the balances again and see the effect of our transaction. We are using a `showPrivateBalances` helper function here which has the code we wrote in the section above. diff --git a/docs/docs/dev_docs/tutorials/writing_dapp/rpc_server.md b/docs/docs/dev_docs/tutorials/writing_dapp/rpc_server.md index 23767890cb9..407295dca70 100644 --- a/docs/docs/dev_docs/tutorials/writing_dapp/rpc_server.md +++ b/docs/docs/dev_docs/tutorials/writing_dapp/rpc_server.md @@ -2,7 +2,7 @@ As an app developer, the [Aztec RPC Server](https://github.com/AztecProtocol/aztec-packages/tree/master/yarn-project/aztec-rpc) interface provides you with access to the user's accounts and their private state, as well as a connection to the network for accessing public global state. -During the Sandbox phase, this role is fulfilled by the [Aztec Sandbox](../../getting_started/sandbox.md), which runs a local RPC Server and an Aztec Node, both connected to a local Ethereum development node like Anvil. The Sandbox also includes a set of pre-initialised accounts that you can use from your app. +During the Sandbox phase, this role is fulfilled by the [Aztec Sandbox](../../getting_started/sandbox.md), which runs a local RPC Server and an Aztec Node, both connected to a local Ethereum development node like Anvil. The Sandbox also includes a set of pre-initialized accounts that you can use from your app. In this section, we'll connect to the Sandbox from our project. @@ -26,7 +26,7 @@ Should the above fail due to a connection error, make sure the Sandbox is runnin ## Load user accounts -With our connection to the RPC server, let's try loading the accounts that are pre-initialised in the Sandbox: +With our connection to the RPC server, let's try loading the accounts that are pre-initialized in the Sandbox: #include_code showAccounts yarn-project/end-to-end/src/sample-dapp/index.mjs javascript diff --git a/docs/docs/dev_docs/tutorials/writing_token_contract.md b/docs/docs/dev_docs/tutorials/writing_token_contract.md index 018592b978f..44acee30adb 100644 --- a/docs/docs/dev_docs/tutorials/writing_token_contract.md +++ b/docs/docs/dev_docs/tutorials/writing_token_contract.md @@ -256,7 +256,7 @@ Below the dependencies, paste the following Storage struct: Reading through the storage variables: -- `admin` a single Field value stored in public state. `FIELD_SERIALISED_LEN` indicates the length of the variable, which is 1 in this case because it's a single Field element. A `Field` is basically an unsigned integer with a maximum value determined by the underlying cryptographic curve. +- `admin` a single Field value stored in public state. `FIELD_SERIALIZED_LEN` indicates the length of the variable, which is 1 in this case because it's a single Field element. A `Field` is basically an unsigned integer with a maximum value determined by the underlying cryptographic curve. - `minters` is a mapping of Fields in public state. This will store whether an account is an approved minter on the contract. - `balances` is a mapping of private balances. Private balances are stored in a `Set` of `ValueNote`s. The balance is the sum of all of an account's `ValueNote`s. - `total_supply` is a Field value stored in public state and represents the total number of tokens minted. @@ -269,7 +269,7 @@ You can read more about it [here](../contracts/syntax/storage.md). Once we have Storage defined, we need to specify how to initialize it. The `init` method creates and initializes an instance of `Storage`. We define an initialization method for each of the storage variables defined above. Storage initialization is generic and can largely be reused for similar types, across different contracts, but it is important to note that each storage variable specifies it's storage slot, starting at 1. -Also, the public storage variables define the type that they store by passing the methods by which they are serialized. Because all `PublicState` in this contract is storing Field elements, each storage variable takes `FieldSerialisationMethods`. +Also, the public storage variables define the type that they store by passing the methods by which they are serialized. Because all `PublicState` in this contract is storing Field elements, each storage variable takes `FieldSerializationMethods`. #include_code storage_init /yarn-project/noir-contracts/src/contracts/token_contract/src/main.nr rust diff --git a/docs/internal_notes/dev_docs/sandbox/components.md b/docs/internal_notes/dev_docs/sandbox/components.md index cb07a4b6139..0db084b6508 100644 --- a/docs/internal_notes/dev_docs/sandbox/components.md +++ b/docs/internal_notes/dev_docs/sandbox/components.md @@ -223,7 +223,7 @@ Implementation notes for this milestone: Responsibilities: -- Wins a period of time to become the sequencer (depending on finalised protocol). +- Wins a period of time to become the sequencer (depending on finalized protocol). - Chooses a set of txs from the tx pool to be in the rollup. - Simulate the rollup of txs. - Adds proof requests to the request pool (not for this milestone). diff --git a/yarn-project/acir-simulator/src/client/private_execution.test.ts b/yarn-project/acir-simulator/src/client/private_execution.test.ts index ad155199005..59c3993460d 100644 --- a/yarn-project/acir-simulator/src/client/private_execution.test.ts +++ b/yarn-project/acir-simulator/src/client/private_execution.test.ts @@ -644,8 +644,8 @@ describe('Private Execution test suite', () => { const deepStruct = { aField: 1, aBool: true, aNote: dummyNote, manyNotes: [dummyNote, dummyNote, dummyNote] }; args = [1, true, 1, [1, 2], dummyNote, deepStruct]; testCodeGenAbi = TestContractAbi.functions.find(f => f.name === 'testCodeGen')!; - const serialisedArgs = encodeArguments(testCodeGenAbi, args); - argsHash = await computeVarArgsHash(await CircuitsWasm.get(), serialisedArgs); + const serializedArgs = encodeArguments(testCodeGenAbi, args); + argsHash = await computeVarArgsHash(await CircuitsWasm.get(), serializedArgs); }); it('test function should be directly callable', async () => { diff --git a/yarn-project/aztec-node/src/aztec-node/server.ts b/yarn-project/aztec-node/src/aztec-node/server.ts index a2b3720b0a3..4c07e444bee 100644 --- a/yarn-project/aztec-node/src/aztec-node/server.ts +++ b/yarn-project/aztec-node/src/aztec-node/server.ts @@ -38,9 +38,9 @@ import { } from '@aztec/types'; import { MerkleTrees, - ServerWorldStateSynchroniser, + ServerWorldStateSynchronizer, WorldStateConfig, - WorldStateSynchroniser, + WorldStateSynchronizer, computePublicDataTreeLeafIndex, getConfigEnvVars as getWorldStateConfig, } from '@aztec/world-state'; @@ -63,7 +63,7 @@ export class AztecNodeService implements AztecNode { protected unencryptedLogsSource: L2LogsSource, protected contractDataSource: ContractDataSource, protected l1ToL2MessageSource: L1ToL2MessageSource, - protected worldStateSynchroniser: WorldStateSynchroniser, + protected worldStateSynchronizer: WorldStateSynchronizer, protected sequencer: SequencerClient, protected chainId: number, protected version: number, @@ -73,7 +73,7 @@ export class AztecNodeService implements AztecNode { ) {} /** - * Initialises the Aztec Node, wait for component to sync. + * initializes the Aztec Node, wait for component to sync. * @param config - The configuration to be used by the aztec node. * @returns - A fully synced Aztec Node for use in development/testing. */ @@ -92,16 +92,16 @@ export class AztecNodeService implements AztecNode { const merkleTreesDb = levelup(createMemDown()); const merkleTrees = await MerkleTrees.new(merkleTreesDb, await CircuitsWasm.get()); const worldStateConfig: WorldStateConfig = getWorldStateConfig(); - const worldStateSynchroniser = new ServerWorldStateSynchroniser(merkleTrees, archiver, worldStateConfig); + const worldStateSynchronizer = new ServerWorldStateSynchronizer(merkleTrees, archiver, worldStateConfig); // start both and wait for them to sync from the block source - await Promise.all([p2pClient.start(), worldStateSynchroniser.start()]); + await Promise.all([p2pClient.start(), worldStateSynchronizer.start()]); // now create the sequencer const sequencer = await SequencerClient.new( config, p2pClient, - worldStateSynchroniser, + worldStateSynchronizer, archiver, archiver, archiver, @@ -113,7 +113,7 @@ export class AztecNodeService implements AztecNode { archiver, archiver, archiver, - worldStateSynchroniser, + worldStateSynchronizer, sequencer, config.chainId, config.version, @@ -235,7 +235,7 @@ export class AztecNodeService implements AztecNode { public async stop() { await this.sequencer.stop(); await this.p2pClient.stop(); - await this.worldStateSynchroniser.stop(); + await this.worldStateSynchronizer.stop(); await this.blockSource.stop(); this.log.info(`Stopped`); } @@ -424,7 +424,7 @@ export class AztecNodeService implements AztecNode { } catch (err) { this.log.error(`Error getting world state: ${err}`); } - return this.worldStateSynchroniser.getCommitted(); + return this.worldStateSynchronizer.getCommitted(); } /** @@ -433,6 +433,6 @@ export class AztecNodeService implements AztecNode { */ async #syncWorldState() { const blockSourceHeight = await this.blockSource.getBlockNumber(); - await this.worldStateSynchroniser.syncImmediate(blockSourceHeight); + await this.worldStateSynchronizer.syncImmediate(blockSourceHeight); } } diff --git a/yarn-project/aztec-nr/aztec/src/account.nr b/yarn-project/aztec-nr/aztec/src/account.nr index c0bfc739e35..3437dbd8519 100644 --- a/yarn-project/aztec-nr/aztec/src/account.nr +++ b/yarn-project/aztec-nr/aztec/src/account.nr @@ -2,13 +2,13 @@ use crate::entrypoint::EntrypointPayload; use crate::context::{PrivateContext, PublicContext, Context}; use crate::oracle::compute_selector::compute_selector; use crate::state_vars::{map::Map, public_state::PublicState}; -use crate::types::type_serialisation::bool_serialisation::{BoolSerialisationMethods,BOOL_SERIALISED_LEN}; +use crate::types::type_serialization::bool_serialization::{BoolSerializationMethods,BOOL_SERIALIZED_LEN}; use crate::auth::IS_VALID_SELECTOR; struct AccountActions { context: Context, is_valid_impl: fn(&mut PrivateContext, Field) -> bool, - approved_action: Map>, + approved_action: Map>, } impl AccountActions { @@ -20,7 +20,7 @@ impl AccountActions { context, approved_action_storage_slot, |context, slot| { - PublicState::new(context, slot, BoolSerialisationMethods) + PublicState::new(context, slot, BoolSerializationMethods) }, ), } diff --git a/yarn-project/aztec-nr/aztec/src/note/lifecycle.nr b/yarn-project/aztec-nr/aztec/src/note/lifecycle.nr index 43ccdfad556..5f4c6b2e8f9 100644 --- a/yarn-project/aztec-nr/aztec/src/note/lifecycle.nr +++ b/yarn-project/aztec-nr/aztec/src/note/lifecycle.nr @@ -25,8 +25,8 @@ fn create_note( set_header(note, header); let inner_note_hash = compute_inner_note_hash(note_interface, *note); - let serialise = note_interface.serialise; - let preimage = serialise(*note); + let serialize = note_interface.serialize; + let preimage = serialize(*note); assert(notify_created_note(storage_slot, preimage, inner_note_hash) == 0); context.push_new_note_hash(inner_note_hash); diff --git a/yarn-project/aztec-nr/aztec/src/note/note_getter_options.nr b/yarn-project/aztec-nr/aztec/src/note/note_getter_options.nr index 092249a218a..f927cebd85a 100644 --- a/yarn-project/aztec-nr/aztec/src/note/note_getter_options.nr +++ b/yarn-project/aztec-nr/aztec/src/note/note_getter_options.nr @@ -60,7 +60,7 @@ struct NoteGetterOptions { // `selects` to specify fields, `sorts` to establish sorting criteria, `offset` to skip items, and `limit` to cap the result size. // And finally, a custom filter to refine the outcome further. impl NoteGetterOptions { - // This function initialises a NoteGetterOptions that simply returns the maximum number of notes allowed in a call. + // This function initializes a NoteGetterOptions that simply returns the maximum number of notes allowed in a call. fn new() -> NoteGetterOptions { NoteGetterOptions { selects: BoundedVec::new(Option::none()), @@ -72,7 +72,7 @@ impl NoteGetterOptions { } } - // This function initialises a NoteGetterOptions with a filter, which takes the notes returned from the database and filter_args as its parameters. + // This function initializes a NoteGetterOptions with a filter, which takes the notes returned from the database and filter_args as its parameters. // `filter_args` allows you to provide additional data or context to the custom filter. fn with_filter( filter: fn ([Option; MAX_READ_REQUESTS_PER_CALL], FILTER_ARGS) -> [Option; MAX_READ_REQUESTS_PER_CALL], diff --git a/yarn-project/aztec-nr/aztec/src/note/note_interface.nr b/yarn-project/aztec-nr/aztec/src/note/note_interface.nr index 84d171fd5ba..a98d3f49954 100644 --- a/yarn-project/aztec-nr/aztec/src/note/note_interface.nr +++ b/yarn-project/aztec-nr/aztec/src/note/note_interface.nr @@ -2,9 +2,9 @@ use crate::note::note_header::NoteHeader; // docs:start:NoteInterface struct NoteInterface { - deserialise: fn ([Field; N]) -> Note, + deserialize: fn ([Field; N]) -> Note, - serialise: fn (Note) -> [Field; N], + serialize: fn (Note) -> [Field; N], compute_note_hash: fn (Note) -> Field, diff --git a/yarn-project/aztec-nr/aztec/src/note/utils.nr b/yarn-project/aztec-nr/aztec/src/note/utils.nr index d8a459286f2..2c9e49efa32 100644 --- a/yarn-project/aztec-nr/aztec/src/note/utils.nr +++ b/yarn-project/aztec-nr/aztec/src/note/utils.nr @@ -68,9 +68,9 @@ fn compute_note_hash_and_nullifier( note_header: NoteHeader, preimage: [Field; S], ) -> [Field; 4] { - let deserialise = note_interface.deserialise; + let deserialize = note_interface.deserialize; let set_header = note_interface.set_header; - let mut note = deserialise(arr_copy_slice(preimage, [0; N], 0)); + let mut note = deserialize(arr_copy_slice(preimage, [0; N], 0)); set_header(&mut note, note_header); let compute_note_hash = note_interface.compute_note_hash; diff --git a/yarn-project/aztec-nr/aztec/src/oracle/notes.nr b/yarn-project/aztec-nr/aztec/src/oracle/notes.nr index 356cf5de4aa..efae0ed9e2f 100644 --- a/yarn-project/aztec-nr/aztec/src/oracle/notes.nr +++ b/yarn-project/aztec-nr/aztec/src/oracle/notes.nr @@ -85,13 +85,13 @@ unconstrained fn get_notes( sort_order: [u2; M], limit: u32, offset: u32, - mut placeholder_opt_notes: [Option; S], // TODO: Remove it and use `limit` to initialise the note array. - placeholder_fields: [Field; NS], // TODO: Remove it and use `limit` to initialise the note array. + mut placeholder_opt_notes: [Option; S], // TODO: Remove it and use `limit` to initialize the note array. + placeholder_fields: [Field; NS], // TODO: Remove it and use `limit` to initialize the note array. ) -> [Option; S] { let fields = get_notes_oracle_wrapper(storage_slot, num_selects, select_by, select_values, sort_by, sort_order, limit, offset, placeholder_fields); let num_notes = fields[0] as u32; let contract_address = fields[1]; - let deserialise = note_interface.deserialise; + let deserialize = note_interface.deserialize; let set_header = note_interface.set_header; for i in 0..placeholder_opt_notes.len() { if i as u32 < num_notes { @@ -104,7 +104,7 @@ unconstrained fn get_notes( let is_some = fields[read_offset + 1] as bool; if is_some { let preimage = arr_copy_slice(fields, [0; N], read_offset + 2); - let mut note = deserialise(preimage); + let mut note = deserialize(preimage); set_header(&mut note, header); placeholder_opt_notes[i] = Option::some(note); } diff --git a/yarn-project/aztec-nr/aztec/src/oracle/storage.nr b/yarn-project/aztec-nr/aztec/src/oracle/storage.nr index 78c3869f2b1..7b367360cd4 100644 --- a/yarn-project/aztec-nr/aztec/src/oracle/storage.nr +++ b/yarn-project/aztec-nr/aztec/src/oracle/storage.nr @@ -11,10 +11,10 @@ unconstrained fn storage_read_oracle_wrapper(_storage_slot: Field)-> [Field; fn storage_read( storage_slot: Field, - deserialise: fn ([Field; N]) -> T, + deserialize: fn ([Field; N]) -> T, ) -> T { let fields = storage_read_oracle_wrapper(storage_slot); - deserialise(fields) + deserialize(fields) } #[oracle(storageWrite)] diff --git a/yarn-project/aztec-nr/aztec/src/state_vars/immutable_singleton.nr b/yarn-project/aztec-nr/aztec/src/state_vars/immutable_singleton.nr index f419e7a0c32..5581c60868e 100644 --- a/yarn-project/aztec-nr/aztec/src/state_vars/immutable_singleton.nr +++ b/yarn-project/aztec-nr/aztec/src/state_vars/immutable_singleton.nr @@ -30,12 +30,12 @@ impl ImmutableSingleton { } } - unconstrained fn is_initialised(self) -> bool { + unconstrained fn is_initialized(self) -> bool { let nullifier = self.compute_initialisation_nullifier(); oracle::notes::is_nullifier_emitted(nullifier) } - fn initialise(self, note: &mut Note) { + fn initialize(self, note: &mut Note) { // Nullify the storage slot. let nullifier = self.compute_initialisation_nullifier(); self.context.private diff --git a/yarn-project/aztec-nr/aztec/src/state_vars/public_state.nr b/yarn-project/aztec-nr/aztec/src/state_vars/public_state.nr index 5216ae906f3..41dfdaf261e 100644 --- a/yarn-project/aztec-nr/aztec/src/state_vars/public_state.nr +++ b/yarn-project/aztec-nr/aztec/src/state_vars/public_state.nr @@ -1,35 +1,35 @@ use crate::context::{Context}; use crate::oracle::storage::storage_read; use crate::oracle::storage::storage_write; -use crate::types::type_serialisation::TypeSerialisationInterface; +use crate::types::type_serialization::TypeSerializationInterface; use dep::std::option::Option; -struct PublicState { +struct PublicState { storage_slot: Field, - serialisation_methods: TypeSerialisationInterface, + serialization_methods: TypeSerializationInterface, } -impl PublicState { +impl PublicState { fn new( // Note: Passing the contexts to new(...) just to have an interface compatible with a Map. _: Context, storage_slot: Field, - serialisation_methods: TypeSerialisationInterface, + serialization_methods: TypeSerializationInterface, ) -> Self { assert(storage_slot != 0, "Storage slot 0 not allowed. Storage slots must start from 1."); PublicState { storage_slot, - serialisation_methods, + serialization_methods, } } fn read(self) -> T { - storage_read(self.storage_slot, self.serialisation_methods.deserialise) + storage_read(self.storage_slot, self.serialization_methods.deserialize) } fn write(self, value: T) { - let serialise = self.serialisation_methods.serialise; - let fields = serialise(value); + let serialize = self.serialization_methods.serialize; + let fields = serialize(value); storage_write(self.storage_slot, fields); } } diff --git a/yarn-project/aztec-nr/aztec/src/state_vars/singleton.nr b/yarn-project/aztec-nr/aztec/src/state_vars/singleton.nr index 6b7afcba2ce..dd12110fab9 100644 --- a/yarn-project/aztec-nr/aztec/src/state_vars/singleton.nr +++ b/yarn-project/aztec-nr/aztec/src/state_vars/singleton.nr @@ -30,12 +30,12 @@ impl Singleton { } } - unconstrained fn is_initialised(self) -> bool { + unconstrained fn is_initialized(self) -> bool { let nullifier = self.compute_initialisation_nullifier(); oracle::notes::is_nullifier_emitted(nullifier) } - fn initialise(self, note: &mut Note) { + fn initialize(self, note: &mut Note) { let context = self.context.unwrap(); // Nullify the storage slot. let nullifier = self.compute_initialisation_nullifier(); diff --git a/yarn-project/aztec-nr/aztec/src/types.nr b/yarn-project/aztec-nr/aztec/src/types.nr index 802ce648c49..a93267973be 100644 --- a/yarn-project/aztec-nr/aztec/src/types.nr +++ b/yarn-project/aztec-nr/aztec/src/types.nr @@ -1,4 +1,4 @@ mod address; mod point; mod vec; // This can/should be moved out into an official noir library -mod type_serialisation; \ No newline at end of file +mod type_serialization; \ No newline at end of file diff --git a/yarn-project/aztec-nr/aztec/src/types/point.nr b/yarn-project/aztec-nr/aztec/src/types/point.nr index 47ea73ffcde..6b391354874 100644 --- a/yarn-project/aztec-nr/aztec/src/types/point.nr +++ b/yarn-project/aztec-nr/aztec/src/types/point.nr @@ -1,4 +1,4 @@ -use crate::types::type_serialisation::TypeSerialisationInterface; +use crate::types::type_serialization::TypeSerializationInterface; struct Point { x: Field, @@ -11,20 +11,20 @@ impl Point { } } -global POINT_SERIALISED_LEN: Field = 2; +global POINT_SERIALIZED_LEN: Field = 2; -fn deserialisePoint(fields: [Field; POINT_SERIALISED_LEN]) -> Point { +fn deserializePoint(fields: [Field; POINT_SERIALIZED_LEN]) -> Point { Point { x: fields[0], y: fields[1], } } -fn serialisePoint(point: Point) -> [Field; POINT_SERIALISED_LEN] { +fn serializePoint(point: Point) -> [Field; POINT_SERIALIZED_LEN] { [point.x, point.y] } -global PointSerialisationMethods = TypeSerialisationInterface { - deserialise: deserialisePoint, - serialise: serialisePoint, +global PointSerializationMethods = TypeSerializationInterface { + deserialize: deserializePoint, + serialize: serializePoint, }; \ No newline at end of file diff --git a/yarn-project/aztec-nr/aztec/src/types/type_serialisation.nr b/yarn-project/aztec-nr/aztec/src/types/type_serialisation.nr deleted file mode 100644 index e1ccdde98f9..00000000000 --- a/yarn-project/aztec-nr/aztec/src/types/type_serialisation.nr +++ /dev/null @@ -1,13 +0,0 @@ -mod bool_serialisation; -mod field_serialisation; -mod u32_serialisation; - -/** - * Before Noir supports traits, a way of specifying the serialisation and deserialisation methods for a type. - */ -// docs:start:TypeSerialisationInterface -struct TypeSerialisationInterface { - deserialise: fn ([Field; N]) -> T, - serialise: fn (T) -> [Field; N], -} -// docs:end:TypeSerialisationInterface \ No newline at end of file diff --git a/yarn-project/aztec-nr/aztec/src/types/type_serialisation/bool_serialisation.nr b/yarn-project/aztec-nr/aztec/src/types/type_serialisation/bool_serialisation.nr deleted file mode 100644 index 734f725f35b..00000000000 --- a/yarn-project/aztec-nr/aztec/src/types/type_serialisation/bool_serialisation.nr +++ /dev/null @@ -1,16 +0,0 @@ -use crate::types::type_serialisation::TypeSerialisationInterface; - -global BOOL_SERIALISED_LEN: Field = 1; - -fn deserialiseBool(fields: [Field; BOOL_SERIALISED_LEN]) -> bool { - fields[0] as bool -} - -fn serialiseBool(value: bool) -> [Field; BOOL_SERIALISED_LEN] { - [value as Field] -} - -global BoolSerialisationMethods = TypeSerialisationInterface { - deserialise: deserialiseBool, - serialise: serialiseBool, -}; \ No newline at end of file diff --git a/yarn-project/aztec-nr/aztec/src/types/type_serialisation/field_serialisation.nr b/yarn-project/aztec-nr/aztec/src/types/type_serialisation/field_serialisation.nr deleted file mode 100644 index 5fcaf370523..00000000000 --- a/yarn-project/aztec-nr/aztec/src/types/type_serialisation/field_serialisation.nr +++ /dev/null @@ -1,16 +0,0 @@ -use crate::types::type_serialisation::TypeSerialisationInterface; - -global FIELD_SERIALISED_LEN: Field = 1; - -fn deserialiseField(fields: [Field; FIELD_SERIALISED_LEN]) -> Field { - fields[0] -} - -fn serialiseField(value: Field) -> [Field; FIELD_SERIALISED_LEN] { - [value] -} - -global FieldSerialisationMethods = TypeSerialisationInterface { - deserialise: deserialiseField, - serialise: serialiseField, -}; \ No newline at end of file diff --git a/yarn-project/aztec-nr/aztec/src/types/type_serialisation/u32_serialisation.nr b/yarn-project/aztec-nr/aztec/src/types/type_serialisation/u32_serialisation.nr deleted file mode 100644 index dd00ebfedfd..00000000000 --- a/yarn-project/aztec-nr/aztec/src/types/type_serialisation/u32_serialisation.nr +++ /dev/null @@ -1,16 +0,0 @@ -use crate::types::type_serialisation::TypeSerialisationInterface; - -global U32_SERIALISED_LEN: Field = 1; - -fn deserialiseU32(fields: [Field; U32_SERIALISED_LEN]) -> u32 { - fields[0] as u32 -} - -fn serialiseU32(value: u32) -> [Field; U32_SERIALISED_LEN] { - [value as Field] -} - -global U32SerialisationMethods = TypeSerialisationInterface { - deserialise: deserialiseU32, - serialise: serialiseU32, -}; \ No newline at end of file diff --git a/yarn-project/aztec-nr/aztec/src/types/type_serialization.nr b/yarn-project/aztec-nr/aztec/src/types/type_serialization.nr new file mode 100644 index 00000000000..b45dcd7c855 --- /dev/null +++ b/yarn-project/aztec-nr/aztec/src/types/type_serialization.nr @@ -0,0 +1,13 @@ +mod bool_serialization; +mod field_serialization; +mod u32_serialization; + +/** + * Before Noir supports traits, a way of specifying the serialization and deserialization methods for a type. + */ +// docs:start:TypeSerializationInterface +struct TypeSerializationInterface { + deserialize: fn ([Field; N]) -> T, + serialize: fn (T) -> [Field; N], +} +// docs:end:TypeSerializationInterface \ No newline at end of file diff --git a/yarn-project/aztec-nr/aztec/src/types/type_serialization/bool_serialization.nr b/yarn-project/aztec-nr/aztec/src/types/type_serialization/bool_serialization.nr new file mode 100644 index 00000000000..ac9829ecfb0 --- /dev/null +++ b/yarn-project/aztec-nr/aztec/src/types/type_serialization/bool_serialization.nr @@ -0,0 +1,16 @@ +use crate::types::type_serialization::TypeSerializationInterface; + +global BOOL_SERIALIZED_LEN: Field = 1; + +fn deserializeBool(fields: [Field; BOOL_SERIALIZED_LEN]) -> bool { + fields[0] as bool +} + +fn serializeBool(value: bool) -> [Field; BOOL_SERIALIZED_LEN] { + [value as Field] +} + +global BoolSerializationMethods = TypeSerializationInterface { + deserialize: deserializeBool, + serialize: serializeBool, +}; \ No newline at end of file diff --git a/yarn-project/aztec-nr/aztec/src/types/type_serialization/field_serialization.nr b/yarn-project/aztec-nr/aztec/src/types/type_serialization/field_serialization.nr new file mode 100644 index 00000000000..4fd3ee5d350 --- /dev/null +++ b/yarn-project/aztec-nr/aztec/src/types/type_serialization/field_serialization.nr @@ -0,0 +1,16 @@ +use crate::types::type_serialization::TypeSerializationInterface; + +global FIELD_SERIALIZED_LEN: Field = 1; + +fn deserializeField(fields: [Field; FIELD_SERIALIZED_LEN]) -> Field { + fields[0] +} + +fn serializeField(value: Field) -> [Field; FIELD_SERIALIZED_LEN] { + [value] +} + +global FieldSerializationMethods = TypeSerializationInterface { + deserialize: deserializeField, + serialize: serializeField, +}; \ No newline at end of file diff --git a/yarn-project/aztec-nr/aztec/src/types/type_serialization/u32_serialization.nr b/yarn-project/aztec-nr/aztec/src/types/type_serialization/u32_serialization.nr new file mode 100644 index 00000000000..e04cf948a53 --- /dev/null +++ b/yarn-project/aztec-nr/aztec/src/types/type_serialization/u32_serialization.nr @@ -0,0 +1,16 @@ +use crate::types::type_serialization::TypeSerializationInterface; + +global U32_SERIALIZED_LEN: Field = 1; + +fn deserializeU32(fields: [Field; U32_SERIALIZED_LEN]) -> u32 { + fields[0] as u32 +} + +fn serializeU32(value: u32) -> [Field; U32_SERIALIZED_LEN] { + [value as Field] +} + +global U32SerializationMethods = TypeSerializationInterface { + deserialize: deserializeU32, + serialize: serializeU32, +}; \ No newline at end of file diff --git a/yarn-project/aztec-nr/aztec/src/types/vec.nr b/yarn-project/aztec-nr/aztec/src/types/vec.nr index 9442f977439..38fafa05d84 100644 --- a/yarn-project/aztec-nr/aztec/src/types/vec.nr +++ b/yarn-project/aztec-nr/aztec/src/types/vec.nr @@ -92,7 +92,7 @@ fn test_vec_get_not_declared() { } #[test(should_fail)] -fn test_vec_get_uninitialised() { +fn test_vec_get_uninitialized() { let mut vec: BoundedVec = BoundedVec::new(0); let _x = vec.get(0); } diff --git a/yarn-project/aztec-nr/easy-private-state/src/easy_private_state.nr b/yarn-project/aztec-nr/easy-private-state/src/easy_private_state.nr index 62f6e85d6e0..005c8990f6f 100644 --- a/yarn-project/aztec-nr/easy-private-state/src/easy_private_state.nr +++ b/yarn-project/aztec-nr/easy-private-state/src/easy_private_state.nr @@ -52,7 +52,7 @@ impl EasyPrivateUint { (*context).this_address(), self.set.storage_slot, owner_key, - addend_note.serialise(), + addend_note.serialize(), ); } @@ -87,7 +87,7 @@ impl EasyPrivateUint { // Emit the newly created encrypted note preimages via oracle calls. let mut encrypted_data = [0; VALUE_NOTE_LEN]; if result_value != 0 { - encrypted_data = result_note.serialise(); + encrypted_data = result_note.serialize(); }; let owner_key = get_public_key(owner); diff --git a/yarn-project/aztec-nr/value-note/src/utils.nr b/yarn-project/aztec-nr/value-note/src/utils.nr index 4b7fcebd127..56204cdd97a 100644 --- a/yarn-project/aztec-nr/value-note/src/utils.nr +++ b/yarn-project/aztec-nr/value-note/src/utils.nr @@ -98,7 +98,7 @@ fn create_note( let application_contract_address = (*context).this_address(); let note_storage_slot = balance.storage_slot; let encryption_pub_key = get_public_key(owner); - let encrypted_data = (*note).serialise(); + let encrypted_data = (*note).serialize(); emit_encrypted_log( context, diff --git a/yarn-project/aztec-nr/value-note/src/value_note.nr b/yarn-project/aztec-nr/value-note/src/value_note.nr index 2f9ed483068..7b7855e37f3 100644 --- a/yarn-project/aztec-nr/value-note/src/value_note.nr +++ b/yarn-project/aztec-nr/value-note/src/value_note.nr @@ -31,11 +31,11 @@ impl ValueNote { } } - fn serialise(self) -> [Field; VALUE_NOTE_LEN] { + fn serialize(self) -> [Field; VALUE_NOTE_LEN] { [self.value, self.owner, self.randomness] } - fn deserialise(preimage: [Field; VALUE_NOTE_LEN]) -> Self { + fn deserialize(preimage: [Field; VALUE_NOTE_LEN]) -> Self { ValueNote { value: preimage[0], owner: preimage[1], @@ -73,12 +73,12 @@ impl ValueNote { } } -fn deserialise(preimage: [Field; VALUE_NOTE_LEN]) -> ValueNote { - ValueNote::deserialise(preimage) +fn deserialize(preimage: [Field; VALUE_NOTE_LEN]) -> ValueNote { + ValueNote::deserialize(preimage) } -fn serialise(note: ValueNote) -> [Field; VALUE_NOTE_LEN] { - note.serialise() +fn serialize(note: ValueNote) -> [Field; VALUE_NOTE_LEN] { + note.serialize() } fn compute_note_hash(note: ValueNote) -> Field { @@ -98,8 +98,8 @@ fn set_header(note: &mut ValueNote, header: NoteHeader) { } global ValueNoteMethods = NoteInterface { - deserialise, - serialise, + deserialize, + serialize, compute_note_hash, compute_nullifier, get_header, diff --git a/yarn-project/aztec-rpc/README.md b/yarn-project/aztec-rpc/README.md index dad598d665e..9f50fa1cf0f 100644 --- a/yarn-project/aztec-rpc/README.md +++ b/yarn-project/aztec-rpc/README.md @@ -8,4 +8,4 @@ - [Acir Simulator](../acir-simulator/) - [Key Store](../key-store/) -- [Account State](./src/account_state/account_state.ts): It coordinates other components to synchronise and decrypt data, simulate transactions, and generate kernel proofs, for a specific account. +- [Account State](./src/account_state/account_state.ts): It coordinates other components to synchronize and decrypt data, simulate transactions, and generate kernel proofs, for a specific account. diff --git a/yarn-project/aztec-rpc/src/aztec_rpc_server/aztec_rpc_server.ts b/yarn-project/aztec-rpc/src/aztec_rpc_server/aztec_rpc_server.ts index 86555d6392b..2dc0cedf2a7 100644 --- a/yarn-project/aztec-rpc/src/aztec_rpc_server/aztec_rpc_server.ts +++ b/yarn-project/aztec-rpc/src/aztec_rpc_server/aztec_rpc_server.ts @@ -58,13 +58,13 @@ import { Database } from '../database/index.js'; import { KernelOracle } from '../kernel_oracle/index.js'; import { KernelProver } from '../kernel_prover/kernel_prover.js'; import { getAcirSimulator } from '../simulator/index.js'; -import { Synchroniser } from '../synchroniser/index.js'; +import { Synchronizer } from '../synchronizer/index.js'; /** * A remote Aztec RPC Client implementation. */ export class AztecRPCServer implements AztecRPC { - private synchroniser: Synchroniser; + private synchronizer: Synchronizer; private contractDataOracle: ContractDataOracle; private simulator: AcirSimulator; private log: DebugLogger; @@ -78,7 +78,7 @@ export class AztecRPCServer implements AztecRPC { logSuffix?: string, ) { this.log = createDebugLogger(logSuffix ? `aztec:rpc_server_${logSuffix}` : `aztec:rpc_server`); - this.synchroniser = new Synchroniser(node, db, logSuffix); + this.synchronizer = new Synchronizer(node, db, logSuffix); this.contractDataOracle = new ContractDataOracle(db, node); this.simulator = getAcirSimulator(db, node, node, node, keyStore, this.contractDataOracle); @@ -91,7 +91,7 @@ export class AztecRPCServer implements AztecRPC { * @returns A promise that resolves when the server has started successfully. */ public async start() { - await this.synchroniser.start(INITIAL_L2_BLOCK_NUM, 1, this.config.l2BlockPollingIntervalMS); + await this.synchronizer.start(INITIAL_L2_BLOCK_NUM, 1, this.config.l2BlockPollingIntervalMS); const info = await this.getNodeInfo(); this.log.info(`Started RPC server connected to chain ${info.chainId} version ${info.protocolVersion}`); } @@ -104,7 +104,7 @@ export class AztecRPCServer implements AztecRPC { * @returns A Promise resolving once the server has been stopped successfully. */ public async stop() { - await this.synchroniser.stop(); + await this.synchronizer.stop(); this.log.info('Stopped'); } @@ -117,7 +117,7 @@ export class AztecRPCServer implements AztecRPC { const wasAdded = await this.db.addCompleteAddress(completeAddress); if (wasAdded) { const pubKey = this.keyStore.addAccount(privKey); - this.synchroniser.addAccount(pubKey, this.keyStore); + this.synchronizer.addAccount(pubKey, this.keyStore); this.log.info(`Registered account ${completeAddress.address.toString()}`); this.log.debug(`Registered account\n ${completeAddress.toReadableString()}`); } else { @@ -578,15 +578,15 @@ export class AztecRPCServer implements AztecRPC { ); } - public async isGlobalStateSynchronised() { - return await this.synchroniser.isGlobalStateSynchronised(); + public async isGlobalStateSynchronized() { + return await this.synchronizer.isGlobalStateSynchronized(); } - public async isAccountStateSynchronised(account: AztecAddress) { - return await this.synchroniser.isAccountStateSynchronised(account); + public async isAccountStateSynchronized(account: AztecAddress) { + return await this.synchronizer.isAccountStateSynchronized(account); } public getSyncStatus() { - return Promise.resolve(this.synchroniser.getSyncStatus()); + return Promise.resolve(this.synchronizer.getSyncStatus()); } } diff --git a/yarn-project/aztec-rpc/src/aztec_rpc_server/test/aztec_rpc_test_suite.ts b/yarn-project/aztec-rpc/src/aztec_rpc_server/test/aztec_rpc_test_suite.ts index 79f68176cb0..9698c1f08ac 100644 --- a/yarn-project/aztec-rpc/src/aztec_rpc_server/test/aztec_rpc_test_suite.ts +++ b/yarn-project/aztec-rpc/src/aztec_rpc_server/test/aztec_rpc_test_suite.ts @@ -138,7 +138,7 @@ export const aztecRpcTestSuite = (testName: string, aztecRpcSetup: () => Promise expect(nodeInfo.rollupAddress.toString()).toMatch(/0x[a-fA-F0-9]+/); }); - // Note: Not testing `isGlobalStateSynchronised`, `isAccountStateSynchronised` and `getSyncStatus` as these methods - // only call synchroniser. + // Note: Not testing `isGlobalStateSynchronized`, `isAccountStateSynchronized` and `getSyncStatus` as these methods + // only call synchronizer. }); }; diff --git a/yarn-project/aztec-rpc/src/note_processor/note_processor.ts b/yarn-project/aztec-rpc/src/note_processor/note_processor.ts index 1b1f3617cc0..f8a7c115eb1 100644 --- a/yarn-project/aztec-rpc/src/note_processor/note_processor.ts +++ b/yarn-project/aztec-rpc/src/note_processor/note_processor.ts @@ -45,13 +45,13 @@ export class NoteProcessor { ) {} /** - * Check if the NoteProcessor is synchronised with the remote block number. + * Check if the NoteProcessor is synchronized with the remote block number. * The function queries the remote block number from the AztecNode and compares it with the syncedToBlock value in the NoteProcessor. - * If the values are equal, then the NoteProcessor is considered to be synchronised, otherwise not. + * If the values are equal, then the NoteProcessor is considered to be synchronized, otherwise not. * - * @returns A boolean indicating whether the NoteProcessor is synchronised with the remote block number or not. + * @returns A boolean indicating whether the NoteProcessor is synchronized with the remote block number or not. */ - public async isSynchronised() { + public async isSynchronized() { const remoteBlockNumber = await this.node.getBlockNumber(); return this.syncedToBlock === remoteBlockNumber; } diff --git a/yarn-project/aztec-rpc/src/synchroniser/index.ts b/yarn-project/aztec-rpc/src/synchroniser/index.ts deleted file mode 100644 index bf023056508..00000000000 --- a/yarn-project/aztec-rpc/src/synchroniser/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './synchroniser.js'; diff --git a/yarn-project/aztec-rpc/src/synchronizer/index.ts b/yarn-project/aztec-rpc/src/synchronizer/index.ts new file mode 100644 index 00000000000..9bc27710e6f --- /dev/null +++ b/yarn-project/aztec-rpc/src/synchronizer/index.ts @@ -0,0 +1 @@ +export * from './synchronizer.js'; diff --git a/yarn-project/aztec-rpc/src/synchroniser/synchroniser.test.ts b/yarn-project/aztec-rpc/src/synchronizer/synchronizer.test.ts similarity index 82% rename from yarn-project/aztec-rpc/src/synchroniser/synchroniser.test.ts rename to yarn-project/aztec-rpc/src/synchronizer/synchronizer.test.ts index 631b294f3b3..1f16d15e4fc 100644 --- a/yarn-project/aztec-rpc/src/synchroniser/synchroniser.test.ts +++ b/yarn-project/aztec-rpc/src/synchronizer/synchronizer.test.ts @@ -7,12 +7,12 @@ import { MockProxy, mock } from 'jest-mock-extended'; import omit from 'lodash.omit'; import { Database, MemoryDB } from '../database/index.js'; -import { Synchroniser } from './synchroniser.js'; +import { Synchronizer } from './synchronizer.js'; -describe('Synchroniser', () => { +describe('Synchronizer', () => { let aztecNode: MockProxy; let database: Database; - let synchroniser: TestSynchroniser; + let synchronizer: TestSynchronizer; let roots: Record; let blockData: HistoricBlockData; @@ -29,14 +29,14 @@ describe('Synchroniser', () => { aztecNode = mock(); database = new MemoryDB(); - synchroniser = new TestSynchroniser(aztecNode, database); + synchronizer = new TestSynchronizer(aztecNode, database); }); it('sets tree roots from aztec node on initial sync', async () => { aztecNode.getBlockNumber.mockResolvedValue(3); aztecNode.getHistoricBlockData.mockResolvedValue(blockData); - await synchroniser.initialSync(); + await synchronizer.initialSync(); expect(database.getTreeRoots()).toEqual(roots); }); @@ -46,7 +46,7 @@ describe('Synchroniser', () => { aztecNode.getBlocks.mockResolvedValue([L2Block.fromFields(omit(block, 'newEncryptedLogs', 'newUnencryptedLogs'))]); aztecNode.getLogs.mockResolvedValueOnce([block.newEncryptedLogs!]).mockResolvedValue([block.newUnencryptedLogs!]); - await synchroniser.work(); + await synchronizer.work(); const roots = database.getTreeRoots(); expect(roots[MerkleTreeId.CONTRACT_TREE]).toEqual(block.endContractTreeSnapshot.root); @@ -57,7 +57,7 @@ describe('Synchroniser', () => { aztecNode.getBlockNumber.mockResolvedValue(3); aztecNode.getHistoricBlockData.mockResolvedValue(blockData); - await synchroniser.initialSync(); + await synchronizer.initialSync(); const roots0 = database.getTreeRoots(); expect(roots0[MerkleTreeId.CONTRACT_TREE]).toEqual(roots[MerkleTreeId.CONTRACT_TREE]); @@ -68,7 +68,7 @@ describe('Synchroniser', () => { ]); aztecNode.getLogs.mockResolvedValue([block1.newEncryptedLogs!]).mockResolvedValue([block1.newUnencryptedLogs!]); - await synchroniser.work(); + await synchronizer.work(); const roots1 = database.getTreeRoots(); expect(roots1[MerkleTreeId.CONTRACT_TREE]).toEqual(roots[MerkleTreeId.CONTRACT_TREE]); expect(roots1[MerkleTreeId.CONTRACT_TREE]).not.toEqual(block1.endContractTreeSnapshot.root); @@ -79,7 +79,7 @@ describe('Synchroniser', () => { L2Block.fromFields(omit(block5, 'newEncryptedLogs', 'newUnencryptedLogs')), ]); - await synchroniser.work(); + await synchronizer.work(); const roots5 = database.getTreeRoots(); expect(roots5[MerkleTreeId.CONTRACT_TREE]).not.toEqual(roots[MerkleTreeId.CONTRACT_TREE]); expect(roots5[MerkleTreeId.CONTRACT_TREE]).toEqual(block5.endContractTreeSnapshot.root); @@ -88,36 +88,36 @@ describe('Synchroniser', () => { it('note processor successfully catches up', async () => { const block = L2Block.random(1, 4); - // getBlocks is called by both synchroniser.work and synchroniser.workNoteProcessorCatchUp + // getBlocks is called by both synchronizer.work and synchronizer.workNoteProcessorCatchUp aztecNode.getBlocks.mockResolvedValue([L2Block.fromFields(omit(block, 'newEncryptedLogs', 'newUnencryptedLogs'))]); aztecNode.getLogs - .mockResolvedValueOnce([block.newEncryptedLogs!]) // called by synchroniser.work - .mockResolvedValueOnce([block.newUnencryptedLogs!]) // called by synchroniser.work - .mockResolvedValueOnce([block.newEncryptedLogs!]); // called by synchroniser.workNoteProcessorCatchUp + .mockResolvedValueOnce([block.newEncryptedLogs!]) // called by synchronizer.work + .mockResolvedValueOnce([block.newUnencryptedLogs!]) // called by synchronizer.work + .mockResolvedValueOnce([block.newEncryptedLogs!]); // called by synchronizer.workNoteProcessorCatchUp - // Sync the synchroniser so that note processor has something to catch up to - await synchroniser.work(); + // Sync the synchronizer so that note processor has something to catch up to + await synchronizer.work(); - // Used in synchroniser.isAccountStateSynchronised + // Used in synchronizer.isAccountStateSynchronized aztecNode.getBlockNumber.mockResolvedValueOnce(1); - // Manually adding account to database so that we can call synchroniser.isAccountStateSynchronised + // Manually adding account to database so that we can call synchronizer.isAccountStateSynchronized const keyStore = new TestKeyStore(await Grumpkin.new()); const privateKey = GrumpkinScalar.random(); keyStore.addAccount(privateKey); const completeAddress = await CompleteAddress.fromPrivateKeyAndPartialAddress(privateKey, Fr.random()); await database.addCompleteAddress(completeAddress); - // Add the account which will add the note processor to the synchroniser - synchroniser.addAccount(completeAddress.publicKey, keyStore); + // Add the account which will add the note processor to the synchronizer + synchronizer.addAccount(completeAddress.publicKey, keyStore); - await synchroniser.workNoteProcessorCatchUp(); + await synchronizer.workNoteProcessorCatchUp(); - expect(await synchroniser.isAccountStateSynchronised(completeAddress.address)).toBe(true); + expect(await synchronizer.isAccountStateSynchronized(completeAddress.address)).toBe(true); }); }); -class TestSynchroniser extends Synchroniser { +class TestSynchronizer extends Synchronizer { public work() { return super.work(); } diff --git a/yarn-project/aztec-rpc/src/synchroniser/synchroniser.ts b/yarn-project/aztec-rpc/src/synchronizer/synchronizer.ts similarity index 94% rename from yarn-project/aztec-rpc/src/synchroniser/synchroniser.ts rename to yarn-project/aztec-rpc/src/synchronizer/synchronizer.ts index 57a0471addb..b3cc55363a3 100644 --- a/yarn-project/aztec-rpc/src/synchroniser/synchroniser.ts +++ b/yarn-project/aztec-rpc/src/synchronizer/synchronizer.ts @@ -8,13 +8,13 @@ import { Database } from '../database/index.js'; import { NoteProcessor } from '../note_processor/index.js'; /** - * The Synchroniser class manages the synchronization of note processors and interacts with the Aztec node + * The Synchronizer class manages the synchronization of note processors and interacts with the Aztec node * to obtain encrypted logs, blocks, and other necessary information for the accounts. * It provides methods to start or stop the synchronization process, add new accounts, retrieve account - * details, and fetch transactions by hash. The Synchroniser ensures that it maintains the note processors + * details, and fetch transactions by hash. The Synchronizer ensures that it maintains the note processors * in sync with the blockchain while handling retries and errors gracefully. */ -export class Synchroniser { +export class Synchronizer { private runningPromise?: Promise; private noteProcessors: NoteProcessor[] = []; private interruptableSleep = new InterruptableSleep(); @@ -26,7 +26,7 @@ export class Synchroniser { constructor(private node: AztecNode, private db: Database, logSuffix = '') { this.log = createDebugLogger( - logSuffix ? `aztec:aztec_rpc_synchroniser_${logSuffix}` : 'aztec:aztec_rpc_synchroniser', + logSuffix ? `aztec:aztec_rpc_synchronizer_${logSuffix}` : 'aztec:aztec_rpc_synchronizer', ); } @@ -224,13 +224,13 @@ export class Synchroniser { } /** - * Add a new account to the Synchroniser with the specified private key. + * Add a new account to the Synchronizer with the specified private key. * Creates a NoteProcessor instance for the account and pushes it into the noteProcessors array. * The method resolves immediately after pushing the new note processor. * * @param publicKey - The public key for the account. * @param keyStore - The key store. - * @returns A promise that resolves once the account is added to the Synchroniser. + * @returns A promise that resolves once the account is added to the Synchronizer. */ public addAccount(publicKey: PublicKey, keyStore: KeyStore) { const processor = this.noteProcessors.find(x => x.publicKey.equals(publicKey)); @@ -242,13 +242,13 @@ export class Synchroniser { } /** - * Checks if the specified account is synchronised. + * Checks if the specified account is synchronized. * @param account - The aztec address for which to query the sync status. * @returns True if the account is fully synched, false otherwise. * @remarks Checks whether all the notes from all the blocks have been processed. If it is not the case, the * retrieved information from contracts might be old/stale (e.g. old token balance). */ - public async isAccountStateSynchronised(account: AztecAddress) { + public async isAccountStateSynchronized(account: AztecAddress) { const completeAddress = await this.db.getCompleteAddress(account); if (!completeAddress) { return false; @@ -257,7 +257,7 @@ export class Synchroniser { if (!processor) { return false; } - return await processor.isSynchronised(); + return await processor.isSynchronized(); } /** @@ -266,14 +266,14 @@ export class Synchroniser { * @remarks This indicates that blocks and transactions are synched even if notes are not. * @remarks Compares local block number with the block number from aztec node. */ - public async isGlobalStateSynchronised() { + public async isGlobalStateSynchronized() { const latest = await this.node.getBlockNumber(); return latest <= this.synchedToBlock; } /** - * Returns the latest block that has been synchronised by the synchronizer and each account. - * @returns The latest block synchronised for blocks, and the latest block synched for notes for each public key being tracked. + * Returns the latest block that has been synchronized by the synchronizer and each account. + * @returns The latest block synchronized for blocks, and the latest block synched for notes for each public key being tracked. */ public getSyncStatus() { return { diff --git a/yarn-project/aztec.js/src/wallet/base_wallet.ts b/yarn-project/aztec.js/src/wallet/base_wallet.ts index dac3fc0c818..cec54b0cb3d 100644 --- a/yarn-project/aztec.js/src/wallet/base_wallet.ts +++ b/yarn-project/aztec.js/src/wallet/base_wallet.ts @@ -91,11 +91,11 @@ export abstract class BaseWallet implements Wallet { getNodeInfo(): Promise { return this.rpc.getNodeInfo(); } - isGlobalStateSynchronised() { - return this.rpc.isGlobalStateSynchronised(); + isGlobalStateSynchronized() { + return this.rpc.isGlobalStateSynchronized(); } - isAccountStateSynchronised(account: AztecAddress) { - return this.rpc.isAccountStateSynchronised(account); + isAccountStateSynchronized(account: AztecAddress) { + return this.rpc.isAccountStateSynchronized(account); } getSyncStatus(): Promise { return this.rpc.getSyncStatus(); diff --git a/yarn-project/boxes/blank-react/src/app/contract.tsx b/yarn-project/boxes/blank-react/src/app/contract.tsx index 510aa16719f..04003d01c40 100644 --- a/yarn-project/boxes/blank-react/src/app/contract.tsx +++ b/yarn-project/boxes/blank-react/src/app/contract.tsx @@ -31,7 +31,7 @@ export function Contract({ wallet }: Props) { setResult(`Contract deployed at: ${address}`); }; const handleResult = (returnValues: any) => { - // TODO: Serialise returnValues to string according to the returnTypes defined in the function abi. + // TODO: serialize returnValues to string according to the returnTypes defined in the function abi. setResult(`Return values: ${returnValues}`); }; const handleClosePopup = () => { diff --git a/yarn-project/boxes/blank-react/src/contracts/src/interface.nr b/yarn-project/boxes/blank-react/src/contracts/src/interface.nr index 56314a40a7f..5e15a7765cc 100644 --- a/yarn-project/boxes/blank-react/src/contracts/src/interface.nr +++ b/yarn-project/boxes/blank-react/src/contracts/src/interface.nr @@ -23,10 +23,10 @@ impl BlankPrivateContextInterface { context: &mut PrivateContext, address: Field ) -> [Field; RETURN_VALUES_LENGTH] { - let mut serialised_args = [0; 1]; - serialised_args[0] = address; + let mut serialized_args = [0; 1]; + serialized_args[0] = address; - context.call_private_function(self.address, 0x88f0753b, serialised_args) + context.call_private_function(self.address, 0x88f0753b, serialized_args) } } diff --git a/yarn-project/boxes/blank/src/contracts/src/interface.nr b/yarn-project/boxes/blank/src/contracts/src/interface.nr index 56314a40a7f..5e15a7765cc 100644 --- a/yarn-project/boxes/blank/src/contracts/src/interface.nr +++ b/yarn-project/boxes/blank/src/contracts/src/interface.nr @@ -23,10 +23,10 @@ impl BlankPrivateContextInterface { context: &mut PrivateContext, address: Field ) -> [Field; RETURN_VALUES_LENGTH] { - let mut serialised_args = [0; 1]; - serialised_args[0] = address; + let mut serialized_args = [0; 1]; + serialized_args[0] = address; - context.call_private_function(self.address, 0x88f0753b, serialised_args) + context.call_private_function(self.address, 0x88f0753b, serialized_args) } } diff --git a/yarn-project/boxes/private-token/src/app/contract.tsx b/yarn-project/boxes/private-token/src/app/contract.tsx index 31664691187..96d013e11df 100644 --- a/yarn-project/boxes/private-token/src/app/contract.tsx +++ b/yarn-project/boxes/private-token/src/app/contract.tsx @@ -31,7 +31,7 @@ export function Contract({ wallet }: Props) { setResult(`Contract deployed at: ${address}`); }; const handleResult = (returnValues: any) => { - // TODO: Serialise returnValues to string according to the returnTypes defined in the function abi. + // TODO: serialize returnValues to string according to the returnTypes defined in the function abi. setResult(`Return values: ${returnValues}`); }; const handleClosePopup = () => { diff --git a/yarn-project/boxes/private-token/src/contracts/src/interface.nr b/yarn-project/boxes/private-token/src/contracts/src/interface.nr index 1eee266adcb..0f59f541a24 100644 --- a/yarn-project/boxes/private-token/src/contracts/src/interface.nr +++ b/yarn-project/boxes/private-token/src/contracts/src/interface.nr @@ -24,11 +24,11 @@ impl PrivateTokenPrivateContextInterface { amount: Field, owner: Field ) -> [Field; RETURN_VALUES_LENGTH] { - let mut serialised_args = [0; 2]; - serialised_args[0] = amount; - serialised_args[1] = owner; + let mut serialized_args = [0; 2]; + serialized_args[0] = amount; + serialized_args[1] = owner; - context.call_private_function(self.address, 0x1535439c, serialised_args) + context.call_private_function(self.address, 0x1535439c, serialized_args) } @@ -38,11 +38,11 @@ impl PrivateTokenPrivateContextInterface { amount: Field, recipient: Field ) -> [Field; RETURN_VALUES_LENGTH] { - let mut serialised_args = [0; 2]; - serialised_args[0] = amount; - serialised_args[1] = recipient; + let mut serialized_args = [0; 2]; + serialized_args[0] = amount; + serialized_args[1] = recipient; - context.call_private_function(self.address, 0xc0888d22, serialised_args) + context.call_private_function(self.address, 0xc0888d22, serialized_args) } } diff --git a/yarn-project/cli/src/unbox.ts b/yarn-project/cli/src/unbox.ts index 7adef2931f8..6c646586ae7 100644 --- a/yarn-project/cli/src/unbox.ts +++ b/yarn-project/cli/src/unbox.ts @@ -284,7 +284,7 @@ export async function unboxContract( await updatePackagingConfigurations(packageVersion, tag, outputPath, log); log(''); - log(`${contractName} has been successfully initialised!`); + log(`${contractName} has been successfully initialized!`); log('To get started, simply run the following commands:'); log(` cd ${outputDirectoryName}`); log(' yarn'); diff --git a/yarn-project/end-to-end/src/e2e_2_rpc_servers.test.ts b/yarn-project/end-to-end/src/e2e_2_rpc_servers.test.ts index 6b7f7e97b49..856b6c354da 100644 --- a/yarn-project/end-to-end/src/e2e_2_rpc_servers.test.ts +++ b/yarn-project/end-to-end/src/e2e_2_rpc_servers.test.ts @@ -54,11 +54,11 @@ describe('e2e_2_rpc_servers', () => { } }); - const awaitUserSynchronised = async (wallet: Wallet, owner: AztecAddress) => { - const isUserSynchronised = async () => { - return await wallet.isAccountStateSynchronised(owner); + const awaitUserSynchronized = async (wallet: Wallet, owner: AztecAddress) => { + const isUserSynchronized = async () => { + return await wallet.isAccountStateSynchronized(owner); }; - await retryUntil(isUserSynchronised, `synch of user ${owner.toString()}`, 10); + await retryUntil(isUserSynchronized, `synch of user ${owner.toString()}`, 10); }; const expectTokenBalance = async ( @@ -67,8 +67,8 @@ describe('e2e_2_rpc_servers', () => { owner: AztecAddress, expectedBalance: bigint, ) => { - // First wait until the corresponding RPC server has synchronised the account - await awaitUserSynchronised(wallet, owner); + // First wait until the corresponding RPC server has synchronized the account + await awaitUserSynchronized(wallet, owner); // Then check the balance const contractWithWallet = await TokenContract.at(tokenAddress, wallet); @@ -158,11 +158,11 @@ describe('e2e_2_rpc_servers', () => { return contract.completeAddress; }; - const awaitServerSynchronised = async (server: AztecRPC) => { - const isServerSynchronised = async () => { - return await server.isGlobalStateSynchronised(); + const awaitServerSynchronized = async (server: AztecRPC) => { + const isServerSynchronized = async () => { + return await server.isGlobalStateSynchronized(); }; - await retryUntil(isServerSynchronised, 'server sync', 10); + await retryUntil(isServerSynchronized, 'server sync', 10); }; const getChildStoredValue = (child: { address: AztecAddress }, aztecRpcServer: AztecRPC) => @@ -171,7 +171,7 @@ describe('e2e_2_rpc_servers', () => { it('user calls a public function on a contract deployed by a different user using a different RPC server', async () => { const childCompleteAddress = await deployChildContractViaServerA(); - await awaitServerSynchronised(aztecRpcServerA); + await awaitServerSynchronized(aztecRpcServerA); // Add Child to RPC server B await aztecRpcServerB.addContracts([ @@ -187,7 +187,7 @@ describe('e2e_2_rpc_servers', () => { const childContractWithWalletB = await ChildContract.at(childCompleteAddress.address, walletB); await childContractWithWalletB.methods.pubIncValue(newValueToSet).send().wait({ interval: 0.1 }); - await awaitServerSynchronised(aztecRpcServerA); + await awaitServerSynchronized(aztecRpcServerA); const storedValue = await getChildStoredValue(childCompleteAddress, aztecRpcServerB); expect(storedValue).toBe(newValueToSet); diff --git a/yarn-project/foundation/src/abi/encoder.test.ts b/yarn-project/foundation/src/abi/encoder.test.ts index 4d8a5de6027..67cb6223c42 100644 --- a/yarn-project/foundation/src/abi/encoder.test.ts +++ b/yarn-project/foundation/src/abi/encoder.test.ts @@ -128,7 +128,7 @@ describe('abi/encoder', () => { ]; expect(() => encodeArguments(testFunctionAbi, args)).toThrowError( - 'Argument for owner cannot be serialised to a field', + 'Argument for owner cannot be serialized to a field', ); }); }); diff --git a/yarn-project/foundation/src/abi/encoder.ts b/yarn-project/foundation/src/abi/encoder.ts index 9faa6213c1e..5f0c903b8b3 100644 --- a/yarn-project/foundation/src/abi/encoder.ts +++ b/yarn-project/foundation/src/abi/encoder.ts @@ -34,7 +34,7 @@ class ArgumentEncoder { } else if (typeof arg.toField === 'function') { this.flattened.push(arg.toField()); } else { - throw new Error(`Argument for ${name} cannot be serialised to a field`); + throw new Error(`Argument for ${name} cannot be serialized to a field`); } } else { throw new Error(`Invalid argument "${arg}" of type ${abiType.kind}`); diff --git a/yarn-project/foundation/src/abi/function_selector.ts b/yarn-project/foundation/src/abi/function_selector.ts index 236acfedd79..88c7919e4a5 100644 --- a/yarn-project/foundation/src/abi/function_selector.ts +++ b/yarn-project/foundation/src/abi/function_selector.ts @@ -99,7 +99,7 @@ export class FunctionSelector { static fromNameAndParameters(name: string, parameters: ABIParameter[]) { const signature = decodeFunctionSignature(name, parameters); const selector = FunctionSelector.fromSignature(signature); - // If using the debug logger here it kill the typing in the `server_world_state_synchroniser` and jest tests. + // If using the debug logger here it kill the typing in the `server_world_state_synchronizer` and jest tests. // console.log(`Function selector for ${signature} is ${selector}`); return selector; } diff --git a/yarn-project/foundation/src/fields/coordinate.ts b/yarn-project/foundation/src/fields/coordinate.ts index 33fb55f80e6..aada6d1ff80 100644 --- a/yarn-project/foundation/src/fields/coordinate.ts +++ b/yarn-project/foundation/src/fields/coordinate.ts @@ -8,7 +8,7 @@ import { Fr } from './fields.js'; * The coordinate value is split across 2 fields to ensure that the max size of a field is not breached. * This is achieved by placing the most significant byte of the lower field into the least significant byte of the higher field. * Calls to 'toBuffer' or 'toBigInt' undo this change and simply return the original 32 byte value. - * Calls to 'toFieldsBuffer' will return a 64 bytes buffer containing the serialised fields. + * Calls to 'toFieldsBuffer' will return a 64 bytes buffer containing the serialized fields. */ export class Coordinate { static ZERO = new Coordinate([Fr.ZERO, Fr.ZERO]); @@ -37,16 +37,16 @@ export class Coordinate { } /** - * Serialises the oblect to buffer of 2 fields. - * @returns A buffer serialisation of the object. + * serializes the oblect to buffer of 2 fields. + * @returns A buffer serialization of the object. */ toFieldsBuffer(): Buffer { return Buffer.concat([this.fields[0].toBuffer(), this.fields[1].toBuffer()]); } /** - * Serialises the coordinate to a single 32 byte buffer. - * @returns A buffer serialisation of the object. + * serializes the coordinate to a single 32 byte buffer. + * @returns A buffer serialization of the object. */ toBuffer(): Buffer { const buf0 = this.fields[0].toBuffer(); diff --git a/yarn-project/foundation/src/json-rpc/convert.test.ts b/yarn-project/foundation/src/json-rpc/convert.test.ts index 53b56776904..ddad7fa09bd 100644 --- a/yarn-project/foundation/src/json-rpc/convert.test.ts +++ b/yarn-project/foundation/src/json-rpc/convert.test.ts @@ -30,11 +30,11 @@ test('does not convert a string', () => { test('converts a registered class', () => { const cc = new ClassConverter({ ToStringClass: ToStringClassA }); const obj = { content: new ToStringClassA('a', 'b') }; - const serialised = convertToJsonObj(cc, obj); - const deserialised = convertFromJsonObj(cc, serialised) as { content: ToStringClassA }; - expect(deserialised.content).toBeInstanceOf(ToStringClassA); - expect(deserialised.content.x).toEqual('a'); - expect(deserialised.content.y).toEqual('b'); + const serialized = convertToJsonObj(cc, obj); + const deserialized = convertFromJsonObj(cc, serialized) as { content: ToStringClassA }; + expect(deserialized.content).toBeInstanceOf(ToStringClassA); + expect(deserialized.content.x).toEqual('a'); + expect(deserialized.content.y).toEqual('b'); }); test('converts a class by name in the event of duplicate modules being loaded', () => { @@ -42,21 +42,21 @@ test('converts a class by name in the event of duplicate modules being loaded', expect(ToStringClassB.prototype.constructor.name).toEqual('ToStringClass'); const cc = new ClassConverter({ ToStringClass: ToStringClassA }); const obj = { content: new ToStringClassB('a', 'b') }; - const serialised = convertToJsonObj(cc, obj); - const deserialised = convertFromJsonObj(cc, serialised) as { content: ToStringClassA }; - expect(deserialised.content).toBeInstanceOf(ToStringClassA); - expect(deserialised.content.x).toEqual('a'); - expect(deserialised.content.y).toEqual('b'); + const serialized = convertToJsonObj(cc, obj); + const deserialized = convertFromJsonObj(cc, serialized) as { content: ToStringClassA }; + expect(deserialized.content).toBeInstanceOf(ToStringClassA); + expect(deserialized.content.x).toEqual('a'); + expect(deserialized.content.y).toEqual('b'); }); test('converts a class by constructor instead of name in the event of minified bundle', () => { const cc = new ClassConverter({ NotMinifiedToStringClassName: ToStringClassA }); const obj = { content: new ToStringClassA('a', 'b') }; - const serialised = convertToJsonObj(cc, obj); - const deserialised = convertFromJsonObj(cc, serialised) as { content: ToStringClassA }; - expect(deserialised.content).toBeInstanceOf(ToStringClassA); - expect(deserialised.content.x).toEqual('a'); - expect(deserialised.content.y).toEqual('b'); + const serialized = convertToJsonObj(cc, obj); + const deserialized = convertFromJsonObj(cc, serialized) as { content: ToStringClassA }; + expect(deserialized.content).toBeInstanceOf(ToStringClassA); + expect(deserialized.content.x).toEqual('a'); + expect(deserialized.content.y).toEqual('b'); }); test('converts a plain object', () => { @@ -72,6 +72,6 @@ test('refuses to convert to json an unknown class', () => { test('refuses to convert from json an unknown class', () => { const cc = new ClassConverter({ ToStringClass: ToStringClassA }); - const serialised = convertToJsonObj(cc, { content: new ToStringClassA('a', 'b') }); - expect(() => convertFromJsonObj(new ClassConverter(), serialised)).toThrowError(/not registered/); + const serialized = convertToJsonObj(cc, { content: new ToStringClassA('a', 'b') }); + expect(() => convertFromJsonObj(new ClassConverter(), serialized)).toThrowError(/not registered/); }); diff --git a/yarn-project/foundation/src/json-rpc/convert.ts b/yarn-project/foundation/src/json-rpc/convert.ts index 53a3fe0d3b3..af378fa4cc1 100644 --- a/yarn-project/foundation/src/json-rpc/convert.ts +++ b/yarn-project/foundation/src/json-rpc/convert.ts @@ -88,7 +88,7 @@ export function convertFromJsonObj(cc: ClassConverter, obj: any): any { if (cc.isRegisteredClassName(obj.type)) { return cc.toClassObj(obj); } else { - throw new Error(`Object ${obj.type} not registered for serialisation FROM JSON`); + throw new Error(`Object ${obj.type} not registered for serialization FROM JSON`); } } @@ -154,7 +154,7 @@ export function convertToJsonObj(cc: ClassConverter, obj: any): any { return newObj; } else { // Throw if this is a non-primitive class that was not registered - throw new Error(`Object ${obj.constructor.name} not registered for serialisation TO JSON`); + throw new Error(`Object ${obj.constructor.name} not registered for serialization TO JSON`); } } diff --git a/yarn-project/merkle-tree/src/standard_indexed_tree/standard_indexed_tree.ts b/yarn-project/merkle-tree/src/standard_indexed_tree/standard_indexed_tree.ts index 743840fe217..93d88e71bef 100644 --- a/yarn-project/merkle-tree/src/standard_indexed_tree/standard_indexed_tree.ts +++ b/yarn-project/merkle-tree/src/standard_indexed_tree/standard_indexed_tree.ts @@ -552,12 +552,12 @@ export class StandardIndexedTree extends TreeBase implements IndexedTree { private async encodeAndAppendLeaves(leaves: LeafData[], hash0Leaf: boolean): Promise { const startInsertionIndex = Number(this.getNumLeaves(true)); - const serialisedLeaves = leaves.map((leaf, i) => { + const serializedLeaves = leaves.map((leaf, i) => { this.cachedLeaves[startInsertionIndex + i] = leaf; return this.encodeLeaf(leaf, hash0Leaf); }); - await super.appendLeaves(serialisedLeaves); + await super.appendLeaves(serializedLeaves); } /** diff --git a/yarn-project/noir-compiler/src/__snapshots__/index.test.ts.snap b/yarn-project/noir-compiler/src/__snapshots__/index.test.ts.snap index 5defbe9affe..eb6aa1b5ec7 100644 --- a/yarn-project/noir-compiler/src/__snapshots__/index.test.ts.snap +++ b/yarn-project/noir-compiler/src/__snapshots__/index.test.ts.snap @@ -223,9 +223,9 @@ impl TestContractPrivateContextInterface { self, context: &mut PrivateContext ) { - let mut serialised_args = [0; 0]; + let mut serialized_args = [0; 0]; - context.call_public_function(self.address, 0x46be982e, serialised_args) + context.call_public_function(self.address, 0x46be982e, serialized_args) } } @@ -249,9 +249,9 @@ impl TestContractPublicContextInterface { self, context: PublicContext ) -> [Field; RETURN_VALUES_LENGTH] { - let mut serialised_args = [0; 0]; + let mut serialized_args = [0; 0]; - context.call_public_function(self.address, 0x46be982e, serialised_args) + context.call_public_function(self.address, 0x46be982e, serialized_args) } } diff --git a/yarn-project/noir-compiler/src/contract-interface-gen/noir.ts b/yarn-project/noir-compiler/src/contract-interface-gen/noir.ts index 8f81f7697ba..d1fd96bea21 100644 --- a/yarn-project/noir-compiler/src/contract-interface-gen/noir.ts +++ b/yarn-project/noir-compiler/src/contract-interface-gen/noir.ts @@ -32,7 +32,7 @@ function isPrivateCall(functionType: FunctionType) { function generateCallStatement(selector: FunctionSelector, functionType: FunctionType) { const callMethod = isPrivateCall(functionType) ? 'call_private_function' : 'call_public_function'; return ` - context.${callMethod}(self.address, 0x${selector.toString()}, serialised_args)`; + context.${callMethod}(self.address, 0x${selector.toString()}, serialized_args)`; } /** @@ -91,23 +91,23 @@ function generateParameter(param: ABIParameter, functionData: FunctionAbi) { } /** - * Collects all parameters for a given function and flattens them according to how they should be serialised. + * Collects all parameters for a given function and flattens them according to how they should be serialized. * @param parameters - Parameters for a function. * @returns List of parameters flattened to basic data types. */ -function collectParametersForSerialisation(parameters: ABIVariable[]) { +function collectParametersForSerialization(parameters: ABIVariable[]) { const flattened: string[] = []; for (const parameter of parameters) { const { name } = parameter; if (parameter.type.kind === 'array') { const nestedType = parameter.type.type; const nested = times(parameter.type.length, i => - collectParametersForSerialisation([{ name: `${name}[${i}]`, type: nestedType }]), + collectParametersForSerialization([{ name: `${name}[${i}]`, type: nestedType }]), ); flattened.push(...nested.flat()); } else if (parameter.type.kind === 'struct') { const nested = parameter.type.fields.map(field => - collectParametersForSerialisation([{ name: `${name}.${field.name}`, type: field.type }]), + collectParametersForSerialization([{ name: `${name}.${field.name}`, type: field.type }]), ); flattened.push(...nested.flat()); } else if (parameter.type.kind === 'string') { @@ -123,13 +123,13 @@ function collectParametersForSerialisation(parameters: ABIVariable[]) { /** * Generates Noir code for serialising the parameters into an array of fields. - * @param parameters - Parameters to serialise. - * @returns The serialisation code. + * @param parameters - Parameters to serialize. + * @returns The serialization code. */ -function generateSerialisation(parameters: ABIParameter[]) { - const flattened = collectParametersForSerialisation(parameters); - const declaration = ` let mut serialised_args = [0; ${flattened.length}];`; - const lines = flattened.map((param, i) => ` serialised_args[${i}] = ${param};`); +function generateSerialization(parameters: ABIParameter[]) { + const flattened = collectParametersForSerialization(parameters); + const declaration = ` let mut serialized_args = [0; ${flattened.length}];`; + const lines = flattened.map((param, i) => ` serialized_args[${i}] = ${param};`); return [declaration, ...lines].join('\n'); } @@ -142,7 +142,7 @@ function generateSerialisation(parameters: ABIParameter[]) { function generateFunctionInterface(functionData: FunctionAbi, kind: 'private' | 'public') { const { name, parameters } = functionData; const selector = FunctionSelector.fromNameAndParameters(name, parameters); - const serialisation = generateSerialisation(parameters); + const serialization = generateSerialization(parameters); const contextType = kind === 'private' ? '&mut PrivateContext' : 'PublicContext'; const callStatement = generateCallStatement(selector, functionData.functionType); const allParams = ['self', `context: ${contextType}`, ...parameters.map(p => generateParameter(p, functionData))]; @@ -154,7 +154,7 @@ function generateFunctionInterface(functionData: FunctionAbi, kind: 'private' | fn ${name}( ${allParams.join(',\n ')} ) ${retType}{ -${serialisation} +${serialization} ${callStatement} } `; diff --git a/yarn-project/noir-contracts/src/contracts/card_game_contract/src/cards.nr b/yarn-project/noir-contracts/src/contracts/card_game_contract/src/cards.nr index d5698677b46..219728e3f90 100644 --- a/yarn-project/noir-contracts/src/contracts/card_game_contract/src/cards.nr +++ b/yarn-project/noir-contracts/src/contracts/card_game_contract/src/cards.nr @@ -145,7 +145,7 @@ impl Deck { (*context).this_address(), self.set.storage_slot, owner_key, - card_note.note.serialise(), + card_note.note.serialize(), ); inserted_cards = inserted_cards.push_back(card_note); } diff --git a/yarn-project/noir-contracts/src/contracts/card_game_contract/src/game.nr b/yarn-project/noir-contracts/src/contracts/card_game_contract/src/game.nr index e68e8799f6e..30a8c722bd1 100644 --- a/yarn-project/noir-contracts/src/contracts/card_game_contract/src/game.nr +++ b/yarn-project/noir-contracts/src/contracts/card_game_contract/src/game.nr @@ -1,4 +1,4 @@ -use dep::aztec::types::type_serialisation::TypeSerialisationInterface; +use dep::aztec::types::type_serialization::TypeSerializationInterface; use crate::cards::Card; global NUMBER_OF_PLAYERS = 2; @@ -11,7 +11,7 @@ struct PlayerEntry { } impl PlayerEntry { - fn is_initialised(self) -> bool { + fn is_initialized(self) -> bool { self.address != 0 } } @@ -28,9 +28,9 @@ struct Game { current_round: u32, } -global GAME_SERIALISED_LEN: Field = 15; +global GAME_SERIALIZED_LEN: Field = 15; -fn deserialiseGame(fields: [Field; GAME_SERIALISED_LEN]) -> Game { +fn deserializeGame(fields: [Field; GAME_SERIALIZED_LEN]) -> Game { let players = [ PlayerEntry { address: fields[0], @@ -58,7 +58,7 @@ fn deserialiseGame(fields: [Field; GAME_SERIALISED_LEN]) -> Game { } } -fn serialiseGame(game: Game) -> [Field; GAME_SERIALISED_LEN] { +fn serializeGame(game: Game) -> [Field; GAME_SERIALIZED_LEN] { [ game.players[0].address, game.players[0].deck_strength as Field, @@ -79,8 +79,8 @@ fn serialiseGame(game: Game) -> [Field; GAME_SERIALISED_LEN] { } impl Game { - fn serialize(self: Self) -> [Field; GAME_SERIALISED_LEN] { - serialiseGame(self) + fn serialize(self: Self) -> [Field; GAME_SERIALIZED_LEN] { + serializeGame(self) } fn add_player(&mut self, player_entry: PlayerEntry) -> bool { @@ -88,7 +88,7 @@ impl Game { for i in 0..NUMBER_OF_PLAYERS { let entry = self.players[i]; - if entry.is_initialised() { + if entry.is_initialized() { assert(entry.address != player_entry.address, "Player already in game"); } else if !added { self.players[i] = player_entry; @@ -103,7 +103,7 @@ impl Game { assert(!self.started, "Game already started"); for i in 0..NUMBER_OF_PLAYERS { let entry = self.players[i]; - assert(entry.is_initialised(), "Game not full"); + assert(entry.is_initialized(), "Game not full"); } let sorted_by_deck_strength = self.players.sort_via(|a: PlayerEntry, b: PlayerEntry| a.deck_strength < b.deck_strength); self.players = sorted_by_deck_strength; @@ -166,7 +166,7 @@ impl Game { } } -global GameSerialisationMethods = TypeSerialisationInterface { - deserialise: deserialiseGame, - serialise: serialiseGame, +global GameSerializationMethods = TypeSerializationInterface { + deserialize: deserializeGame, + serialize: serializeGame, }; \ No newline at end of file diff --git a/yarn-project/noir-contracts/src/contracts/card_game_contract/src/main.nr b/yarn-project/noir-contracts/src/contracts/card_game_contract/src/main.nr index 1d53056a5d1..b570ad3a42b 100644 --- a/yarn-project/noir-contracts/src/contracts/card_game_contract/src/main.nr +++ b/yarn-project/noir-contracts/src/contracts/card_game_contract/src/main.nr @@ -12,12 +12,12 @@ use dep::aztec::{ use dep::std::option::Option; use cards::{Deck}; -use game::{Game, GameSerialisationMethods, GAME_SERIALISED_LEN}; +use game::{Game, GameSerializationMethods, GAME_SERIALIZED_LEN}; struct Storage { collections: Map, game_decks: Map>, - games: Map>, + games: Map>, } impl Storage { @@ -58,7 +58,7 @@ impl Storage { PublicState::new( context, slot, - GameSerialisationMethods, + GameSerializationMethods, ) }, ) diff --git a/yarn-project/noir-contracts/src/contracts/child_contract/src/main.nr b/yarn-project/noir-contracts/src/contracts/child_contract/src/main.nr index 98641d7054d..84cc262c879 100644 --- a/yarn-project/noir-contracts/src/contracts/child_contract/src/main.nr +++ b/yarn-project/noir-contracts/src/contracts/child_contract/src/main.nr @@ -10,11 +10,11 @@ contract Child { compute_selector::compute_selector, }, state_vars::public_state::PublicState, - types::type_serialisation::field_serialisation::{FieldSerialisationMethods, FIELD_SERIALISED_LEN}, + types::type_serialization::field_serialization::{FieldSerializationMethods, FIELD_SERIALIZED_LEN}, }; struct Storage { - current_value: PublicState, + current_value: PublicState, } impl Storage { @@ -23,7 +23,7 @@ contract Child { current_value: PublicState::new( context, 1, - FieldSerialisationMethods, + FieldSerializationMethods, ), } } diff --git a/yarn-project/noir-contracts/src/contracts/docs_example_contract/src/actions.nr b/yarn-project/noir-contracts/src/contracts/docs_example_contract/src/actions.nr index 94b5981e1f3..28c43227c25 100644 --- a/yarn-project/noir-contracts/src/contracts/docs_example_contract/src/actions.nr +++ b/yarn-project/noir-contracts/src/contracts/docs_example_contract/src/actions.nr @@ -6,40 +6,40 @@ use dep::aztec::state_vars::{ immutable_singleton::ImmutableSingleton, map::Map, public_state::PublicState, set::Set, singleton::Singleton, }; -use dep::aztec::types::type_serialisation::bool_serialisation::BOOL_SERIALISED_LEN; +use dep::aztec::types::type_serialization::bool_serialization::BOOL_SERIALIZED_LEN; use dep::std::option::Option; use crate::types::{ card_note::{CardNote, CARD_NOTE_LEN}, profile_note::{ProfileNote, PROFILE_NOTE_LEN}, - queen::{Queen, QUEEN_SERIALISED_LEN}, + queen::{Queen, QUEEN_SERIALIZED_LEN}, rules_note::{RulesNote, RULES_NOTE_LEN}, }; // docs:start:state_vars-PublicStateRead -fn is_locked(state_var: PublicState) -> bool { +fn is_locked(state_var: PublicState) -> bool { state_var.read() } // docs:end:state_vars-PublicStateRead // docs:start:state_vars-PublicStateWrite -fn lock(state_var: PublicState) { +fn lock(state_var: PublicState) { state_var.write(true); } // docs:end:state_vars-PublicStateWrite -fn unlock(state_var: PublicState) { +fn unlock(state_var: PublicState) { state_var.write(false); } // docs:start:state_vars-PublicStateReadCustom -fn get_current_queen(state_var: PublicState) -> Queen { +fn get_current_queen(state_var: PublicState) -> Queen { state_var.read() } // docs:end:state_vars-PublicStateReadCustom fn can_replace_queen( - state_var: PublicState, + state_var: PublicState, new_queen: Queen, ) -> bool { let current_queen = get_current_queen(state_var); @@ -47,13 +47,13 @@ fn can_replace_queen( } // docs:start:state_vars-PublicStateWriteCustom -fn replace_queen(state_var: PublicState, new_queen: Queen) { +fn replace_queen(state_var: PublicState, new_queen: Queen) { state_var.write(new_queen); } // docs:end:state_vars-PublicStateWriteCustom // docs:start:state_vars-PublicStateReadWriteCustom -fn add_points_to_queen(state_var: PublicState, new_points: u8) { +fn add_points_to_queen(state_var: PublicState, new_points: u8) { let mut queen = state_var.read(); queen.points += new_points; state_var.write(queen); @@ -62,7 +62,7 @@ fn add_points_to_queen(state_var: PublicState, new_ // docs:start:state_vars-SingletonInit fn init_legendary_card(state_var: Singleton, card: &mut CardNote) { - state_var.initialise(card); + state_var.initialize(card); } // docs:end:state_vars-SingletonInit @@ -83,7 +83,7 @@ fn init_game_rules( state_var: ImmutableSingleton, rules: &mut RulesNote, ) { - state_var.initialise(rules); + state_var.initialize(rules); } // docs:end:state_vars-ImmutableSingletonInit @@ -161,7 +161,7 @@ fn add_new_profile( account: Field, profile: &mut ProfileNote, ) { - state_var.at(account).initialise(profile); + state_var.at(account).initialize(profile); } // docs:end:state_vars-MapAtSingletonInit diff --git a/yarn-project/noir-contracts/src/contracts/docs_example_contract/src/main.nr b/yarn-project/noir-contracts/src/contracts/docs_example_contract/src/main.nr index 961de5cc9ae..1bf53dc922d 100644 --- a/yarn-project/noir-contracts/src/contracts/docs_example_contract/src/main.nr +++ b/yarn-project/noir-contracts/src/contracts/docs_example_contract/src/main.nr @@ -13,8 +13,8 @@ contract DocsExample { }, }; // docs:start:state_vars-PublicStateBoolImport - use dep::aztec::types::type_serialisation::bool_serialisation::{ - BoolSerialisationMethods, BOOL_SERIALISED_LEN, + use dep::aztec::types::type_serialization::bool_serialization::{ + BoolSerializationMethods, BOOL_SERIALIZED_LEN, }; // docs:end:state_vars-PublicStateBoolImport use crate::account_contract_interface::AccountContractInterface; @@ -23,14 +23,14 @@ contract DocsExample { use crate::types::{ card_note::{CardNote, CardNoteMethods, CARD_NOTE_LEN}, profile_note::{ProfileNote, ProfileNoteMethods, PROFILE_NOTE_LEN}, - queen::{Queen, QueenSerialisationMethods, QUEEN_SERIALISED_LEN}, + queen::{Queen, QueenSerializationMethods, QUEEN_SERIALIZED_LEN}, rules_note::{RulesNote, RulesNoteMethods, RULES_NOTE_LEN}, }; // docs:start:storage-struct-declaration struct Storage { - locked: PublicState, - queen: PublicState, + locked: PublicState, + queen: PublicState, game_rules: ImmutableSingleton, legendary_card: Singleton, cards: Set, @@ -49,12 +49,12 @@ contract DocsExample { fn init(context: Context) -> pub Self { Storage { // highlight-next-line:state_vars-PublicState - locked: PublicState::new(context, 1, BoolSerialisationMethods), + locked: PublicState::new(context, 1, BoolSerializationMethods), // highlight-next-line:state_vars-PublicStateCustomStruct queen: PublicState::new( context, 2, - QueenSerialisationMethods, + QueenSerializationMethods, ), // highlight-next-line:state_vars-ImmutableSingleton game_rules: ImmutableSingleton::new(context, 3, RulesNoteMethods), diff --git a/yarn-project/noir-contracts/src/contracts/docs_example_contract/src/types/card_note.nr b/yarn-project/noir-contracts/src/contracts/docs_example_contract/src/types/card_note.nr index f5b526cb0d7..c193534e594 100644 --- a/yarn-project/noir-contracts/src/contracts/docs_example_contract/src/types/card_note.nr +++ b/yarn-project/noir-contracts/src/contracts/docs_example_contract/src/types/card_note.nr @@ -28,11 +28,11 @@ impl CardNote { } } - fn serialise(self) -> [Field; CARD_NOTE_LEN] { + fn serialize(self) -> [Field; CARD_NOTE_LEN] { [self.points as Field, self.secret, self.owner] } - fn deserialise(preimage: [Field; CARD_NOTE_LEN]) -> Self { + fn deserialize(preimage: [Field; CARD_NOTE_LEN]) -> Self { CardNote { points: preimage[0] as u8, secret: preimage[1], @@ -64,12 +64,12 @@ impl CardNote { } } -fn deserialise(preimage: [Field; CARD_NOTE_LEN]) -> CardNote { - CardNote::deserialise(preimage) +fn deserialize(preimage: [Field; CARD_NOTE_LEN]) -> CardNote { + CardNote::deserialize(preimage) } -fn serialise(note: CardNote) -> [Field; CARD_NOTE_LEN] { - note.serialise() +fn serialize(note: CardNote) -> [Field; CARD_NOTE_LEN] { + note.serialize() } fn compute_note_hash(note: CardNote) -> Field { @@ -89,8 +89,8 @@ fn set_header(note: &mut CardNote, header: NoteHeader) { } global CardNoteMethods = NoteInterface { - deserialise, - serialise, + deserialize, + serialize, compute_note_hash, compute_nullifier, get_header, diff --git a/yarn-project/noir-contracts/src/contracts/docs_example_contract/src/types/profile_note.nr b/yarn-project/noir-contracts/src/contracts/docs_example_contract/src/types/profile_note.nr index 9e8436e62c6..2a25e726bf2 100644 --- a/yarn-project/noir-contracts/src/contracts/docs_example_contract/src/types/profile_note.nr +++ b/yarn-project/noir-contracts/src/contracts/docs_example_contract/src/types/profile_note.nr @@ -21,11 +21,11 @@ impl ProfileNote { } } - fn serialise(self) -> [Field; PROFILE_NOTE_LEN] { + fn serialize(self) -> [Field; PROFILE_NOTE_LEN] { [self.avatar, self.xp] } - fn deserialise(preimage: [Field; PROFILE_NOTE_LEN]) -> Self { + fn deserialize(preimage: [Field; PROFILE_NOTE_LEN]) -> Self { ProfileNote { avatar: preimage[1], xp: preimage[0], @@ -50,12 +50,12 @@ impl ProfileNote { } } -fn deserialise(preimage: [Field; PROFILE_NOTE_LEN]) -> ProfileNote { - ProfileNote::deserialise(preimage) +fn deserialize(preimage: [Field; PROFILE_NOTE_LEN]) -> ProfileNote { + ProfileNote::deserialize(preimage) } -fn serialise(note: ProfileNote) -> [Field; PROFILE_NOTE_LEN] { - note.serialise() +fn serialize(note: ProfileNote) -> [Field; PROFILE_NOTE_LEN] { + note.serialize() } fn compute_note_hash(note: ProfileNote) -> Field { @@ -75,8 +75,8 @@ fn set_header(note: &mut ProfileNote, header: NoteHeader) { } global ProfileNoteMethods = NoteInterface { - deserialise, - serialise, + deserialize, + serialize, compute_note_hash, compute_nullifier, get_header, diff --git a/yarn-project/noir-contracts/src/contracts/docs_example_contract/src/types/queen.nr b/yarn-project/noir-contracts/src/contracts/docs_example_contract/src/types/queen.nr index eb85a5d11f2..635205ecd6f 100644 --- a/yarn-project/noir-contracts/src/contracts/docs_example_contract/src/types/queen.nr +++ b/yarn-project/noir-contracts/src/contracts/docs_example_contract/src/types/queen.nr @@ -1,4 +1,4 @@ -use dep::aztec::types::type_serialisation::TypeSerialisationInterface; +use dep::aztec::types::type_serialization::TypeSerializationInterface; // docs:start:state_vars-CustomStruct struct Queen { @@ -8,21 +8,21 @@ struct Queen { // docs:end:state_vars-CustomStruct // docs:start:state_vars-PublicStateCustomStruct -global QUEEN_SERIALISED_LEN: Field = 2; +global QUEEN_SERIALIZED_LEN: Field = 2; -fn deserialise(fields: [Field; QUEEN_SERIALISED_LEN]) -> Queen { +fn deserialize(fields: [Field; QUEEN_SERIALIZED_LEN]) -> Queen { Queen { account: fields[0], points: fields[1] as u8, } } -fn serialise(queen: Queen) -> [Field; QUEEN_SERIALISED_LEN] { +fn serialize(queen: Queen) -> [Field; QUEEN_SERIALIZED_LEN] { [queen.account, queen.points as Field] } -global QueenSerialisationMethods = TypeSerialisationInterface { - deserialise, - serialise, +global QueenSerializationMethods = TypeSerializationInterface { + deserialize, + serialize, }; // docs:end:state_vars-PublicStateCustomStruct \ No newline at end of file diff --git a/yarn-project/noir-contracts/src/contracts/docs_example_contract/src/types/rules_note.nr b/yarn-project/noir-contracts/src/contracts/docs_example_contract/src/types/rules_note.nr index c204842484e..1492f56127f 100644 --- a/yarn-project/noir-contracts/src/contracts/docs_example_contract/src/types/rules_note.nr +++ b/yarn-project/noir-contracts/src/contracts/docs_example_contract/src/types/rules_note.nr @@ -21,11 +21,11 @@ impl RulesNote { } } - fn serialise(self) -> [Field; RULES_NOTE_LEN] { + fn serialize(self) -> [Field; RULES_NOTE_LEN] { [self.min_points as Field, self.max_points as Field] } - fn deserialise(preimage: [Field; RULES_NOTE_LEN]) -> Self { + fn deserialize(preimage: [Field; RULES_NOTE_LEN]) -> Self { RulesNote { min_points: preimage[0] as u8, max_points: preimage[1] as u8, @@ -50,12 +50,12 @@ impl RulesNote { } } -fn deserialise(preimage: [Field; RULES_NOTE_LEN]) -> RulesNote { - RulesNote::deserialise(preimage) +fn deserialize(preimage: [Field; RULES_NOTE_LEN]) -> RulesNote { + RulesNote::deserialize(preimage) } -fn serialise(note: RulesNote) -> [Field; RULES_NOTE_LEN] { - note.serialise() +fn serialize(note: RulesNote) -> [Field; RULES_NOTE_LEN] { + note.serialize() } fn compute_note_hash(note: RulesNote) -> Field { @@ -75,8 +75,8 @@ fn set_header(note: &mut RulesNote, header: NoteHeader) { } global RulesNoteMethods = NoteInterface { - deserialise, - serialise, + deserialize, + serialize, compute_note_hash, compute_nullifier, get_header, diff --git a/yarn-project/noir-contracts/src/contracts/easy_private_token_contract/src/main.nr b/yarn-project/noir-contracts/src/contracts/easy_private_token_contract/src/main.nr index a4fdd1951ac..dd1cc316213 100644 --- a/yarn-project/noir-contracts/src/contracts/easy_private_token_contract/src/main.nr +++ b/yarn-project/noir-contracts/src/contracts/easy_private_token_contract/src/main.nr @@ -37,7 +37,7 @@ contract EasyPrivateToken { } /** - * Initialise the contract's initial state variables. + * initialize the contract's initial state variables. */ #[aztec(private)] fn constructor( diff --git a/yarn-project/noir-contracts/src/contracts/ecdsa_account_contract/src/ecdsa_public_key_note.nr b/yarn-project/noir-contracts/src/contracts/ecdsa_account_contract/src/ecdsa_public_key_note.nr index ccd5084d8fd..c80188fff21 100644 --- a/yarn-project/noir-contracts/src/contracts/ecdsa_account_contract/src/ecdsa_public_key_note.nr +++ b/yarn-project/noir-contracts/src/contracts/ecdsa_account_contract/src/ecdsa_public_key_note.nr @@ -24,13 +24,13 @@ impl EcdsaPublicKeyNote { } } - // Serialise the note as 5 fields where: + // serialize the note as 5 fields where: // [0] = x[0..31] (upper bound excluded) // [1] = x[31] // [2] = y[0..31] // [3] = y[31] // [4] = owner - fn serialise(self) -> [Field; ECDSA_PUBLIC_KEY_NOTE_LEN] { + fn serialize(self) -> [Field; ECDSA_PUBLIC_KEY_NOTE_LEN] { let mut x: Field = 0; let mut y: Field = 0; let mut mul: Field = 1; @@ -66,7 +66,7 @@ impl EcdsaPublicKeyNote { } } -fn deserialise(preimage: [Field; ECDSA_PUBLIC_KEY_NOTE_LEN]) -> EcdsaPublicKeyNote { +fn deserialize(preimage: [Field; ECDSA_PUBLIC_KEY_NOTE_LEN]) -> EcdsaPublicKeyNote { let mut x: [u8; 32] = [0;32]; let mut y: [u8; 32] = [0;32]; @@ -86,13 +86,13 @@ fn deserialise(preimage: [Field; ECDSA_PUBLIC_KEY_NOTE_LEN]) -> EcdsaPublicKeyNo } } -fn serialise(note: EcdsaPublicKeyNote) -> [Field; ECDSA_PUBLIC_KEY_NOTE_LEN] { - note.serialise() +fn serialize(note: EcdsaPublicKeyNote) -> [Field; ECDSA_PUBLIC_KEY_NOTE_LEN] { + note.serialize() } fn compute_note_hash(note: EcdsaPublicKeyNote) -> Field { // TODO(#1205) Should use a non-zero generator index. - dep::std::hash::pedersen(note.serialise())[0] + dep::std::hash::pedersen(note.serialize())[0] } fn compute_nullifier(note: EcdsaPublicKeyNote) -> Field { @@ -108,8 +108,8 @@ fn set_header(note: &mut EcdsaPublicKeyNote, header: NoteHeader) { } global EcdsaPublicKeyNoteInterface = NoteInterface { - deserialise, - serialise, + deserialize, + serialize, compute_note_hash, compute_nullifier, get_header, diff --git a/yarn-project/noir-contracts/src/contracts/ecdsa_account_contract/src/main.nr b/yarn-project/noir-contracts/src/contracts/ecdsa_account_contract/src/main.nr index 1b3f6c50993..7a460b87f0a 100644 --- a/yarn-project/noir-contracts/src/contracts/ecdsa_account_contract/src/main.nr +++ b/yarn-project/noir-contracts/src/contracts/ecdsa_account_contract/src/main.nr @@ -49,14 +49,14 @@ contract EcdsaAccount { let this = context.this_address(); let mut pub_key_note = EcdsaPublicKeyNote::new(signing_pub_key_x, signing_pub_key_y, this); - storage.public_key.initialise(&mut pub_key_note); + storage.public_key.initialize(&mut pub_key_note); emit_encrypted_log( &mut context, this, storage.public_key.storage_slot, get_public_key(this), - pub_key_note.serialise(), + pub_key_note.serialize(), ); } diff --git a/yarn-project/noir-contracts/src/contracts/escrow_contract/src/address_note.nr b/yarn-project/noir-contracts/src/contracts/escrow_contract/src/address_note.nr index 652c664dcb2..6d83dcff9f9 100644 --- a/yarn-project/noir-contracts/src/contracts/escrow_contract/src/address_note.nr +++ b/yarn-project/noir-contracts/src/contracts/escrow_contract/src/address_note.nr @@ -21,7 +21,7 @@ impl AddressNote { } } - fn serialise(self) -> [Field; ADDRESS_NOTE_LEN]{ + fn serialize(self) -> [Field; ADDRESS_NOTE_LEN]{ [self.address, self.owner] } @@ -41,7 +41,7 @@ impl AddressNote { } } -fn deserialise(preimage: [Field; ADDRESS_NOTE_LEN]) -> AddressNote { +fn deserialize(preimage: [Field; ADDRESS_NOTE_LEN]) -> AddressNote { AddressNote { address: preimage[0], owner: preimage[1], @@ -49,13 +49,13 @@ fn deserialise(preimage: [Field; ADDRESS_NOTE_LEN]) -> AddressNote { } } -fn serialise(note: AddressNote) -> [Field; ADDRESS_NOTE_LEN]{ - note.serialise() +fn serialize(note: AddressNote) -> [Field; ADDRESS_NOTE_LEN]{ + note.serialize() } fn compute_note_hash(note: AddressNote) -> Field { // TODO(#1205) Should use a non-zero generator index. - dep::std::hash::pedersen(note.serialise())[0] + dep::std::hash::pedersen(note.serialize())[0] } fn compute_nullifier(note: AddressNote) -> Field { @@ -71,8 +71,8 @@ fn set_header(note: &mut AddressNote, header: NoteHeader) { } global AddressNoteMethods = NoteInterface { - deserialise, - serialise, + deserialize, + serialize, compute_note_hash, compute_nullifier, get_header, diff --git a/yarn-project/noir-contracts/src/contracts/escrow_contract/src/main.nr b/yarn-project/noir-contracts/src/contracts/escrow_contract/src/main.nr index 6d70728eac4..0a9fd70c492 100644 --- a/yarn-project/noir-contracts/src/contracts/escrow_contract/src/main.nr +++ b/yarn-project/noir-contracts/src/contracts/escrow_contract/src/main.nr @@ -55,7 +55,7 @@ contract Escrow { this, storage.owners.storage_slot, get_public_key(this), - note.serialise(), + note.serialize(), ); } // docs:end:constructor diff --git a/yarn-project/noir-contracts/src/contracts/lending_contract/src/asset.nr b/yarn-project/noir-contracts/src/contracts/lending_contract/src/asset.nr index 5fbc903abca..76a6744c9e3 100644 --- a/yarn-project/noir-contracts/src/contracts/lending_contract/src/asset.nr +++ b/yarn-project/noir-contracts/src/contracts/lending_contract/src/asset.nr @@ -1,4 +1,4 @@ -use dep::aztec::types::type_serialisation::TypeSerialisationInterface; +use dep::aztec::types::type_serialization::TypeSerializationInterface; // Struct to be used to represent "totals". Generally, there should be one per asset. // It stores the global values that are shared among all users, such as an accumulator @@ -12,11 +12,11 @@ struct Asset { oracle_address: Field, } -global ASSET_SERIALISED_LEN: Field = 4; +global ASSET_SERIALIZED_LEN: Field = 4; // Right now we are wasting so many writes. If changing last_updated_ts // we will end up rewriting all of them, wasting writes. -fn deserialiseAsset(fields: [Field; ASSET_SERIALISED_LEN]) -> Asset { +fn deserializeAsset(fields: [Field; ASSET_SERIALIZED_LEN]) -> Asset { Asset { interest_accumulator: fields[0] as u120, last_updated_ts: fields[1] as u120, @@ -25,7 +25,7 @@ fn deserialiseAsset(fields: [Field; ASSET_SERIALISED_LEN]) -> Asset { } } -fn serialiseAsset(asset: Asset) -> [Field; ASSET_SERIALISED_LEN] { +fn serializeAsset(asset: Asset) -> [Field; ASSET_SERIALIZED_LEN] { [ asset.interest_accumulator as Field, asset.last_updated_ts as Field, @@ -35,12 +35,12 @@ fn serialiseAsset(asset: Asset) -> [Field; ASSET_SERIALISED_LEN] { } impl Asset { - fn serialize(self: Self) -> [Field; ASSET_SERIALISED_LEN] { - serialiseAsset(self) + fn serialize(self: Self) -> [Field; ASSET_SERIALIZED_LEN] { + serializeAsset(self) } } -global AssetSerialisationMethods = TypeSerialisationInterface { - deserialise: deserialiseAsset, - serialise: serialiseAsset, +global AssetSerializationMethods = TypeSerializationInterface { + deserialize: deserializeAsset, + serialize: serializeAsset, }; diff --git a/yarn-project/noir-contracts/src/contracts/lending_contract/src/main.nr b/yarn-project/noir-contracts/src/contracts/lending_contract/src/main.nr index c26af11e340..bdb432e41b6 100644 --- a/yarn-project/noir-contracts/src/contracts/lending_contract/src/main.nr +++ b/yarn-project/noir-contracts/src/contracts/lending_contract/src/main.nr @@ -20,12 +20,12 @@ contract Lending { map::Map, public_state::PublicState, }, - types::type_serialisation::{ - field_serialisation::{FieldSerialisationMethods, FIELD_SERIALISED_LEN}, - TypeSerialisationInterface, + types::type_serialization::{ + field_serialization::{FieldSerializationMethods, FIELD_SERIALIZED_LEN}, + TypeSerializationInterface, }, }; - use crate::asset::{ASSET_SERIALISED_LEN, Asset, AssetSerialisationMethods}; + use crate::asset::{ASSET_SERIALIZED_LEN, Asset, AssetSerializationMethods}; use crate::interest_math::compute_multiplier; use crate::helpers::{covered_by_collateral, DebtReturn, debt_updates, debt_value, compute_identifier}; use crate::interfaces::{Token, Lending, PriceFeed}; @@ -34,9 +34,9 @@ contract Lending { struct Storage { collateral_asset: PublicState, stable_coin: PublicState, - assets: Map>, - collateral: Map>, - static_debt: Map>, // abusing keys very heavily + assets: Map>, + collateral: Map>, + static_debt: Map>, // abusing keys very heavily } impl Storage { @@ -45,12 +45,12 @@ contract Lending { collateral_asset: PublicState::new( context, 1, - FieldSerialisationMethods, + FieldSerializationMethods, ), stable_coin: PublicState::new( context, 2, - FieldSerialisationMethods, + FieldSerializationMethods, ), assets: Map::new( context, @@ -59,7 +59,7 @@ contract Lending { PublicState::new( context, slot, - AssetSerialisationMethods, + AssetSerializationMethods, ) }, ), @@ -70,7 +70,7 @@ contract Lending { PublicState::new( context, slot, - FieldSerialisationMethods, + FieldSerializationMethods, ) }, ), @@ -81,7 +81,7 @@ contract Lending { PublicState::new( context, slot, - FieldSerialisationMethods, + FieldSerializationMethods, ) }, ), diff --git a/yarn-project/noir-contracts/src/contracts/non_native_token_contract/src/interface.nr b/yarn-project/noir-contracts/src/contracts/non_native_token_contract/src/interface.nr index 21be69b3a1f..f81e987051a 100644 --- a/yarn-project/noir-contracts/src/contracts/non_native_token_contract/src/interface.nr +++ b/yarn-project/noir-contracts/src/contracts/non_native_token_contract/src/interface.nr @@ -24,11 +24,11 @@ impl NonNativeTokenPrivateContextInterface { amount: Field, recipient: Field ) { - let mut serialised_args = [0; 2]; - serialised_args[0] = amount; - serialised_args[1] = recipient; + let mut serialized_args = [0; 2]; + serialized_args[0] = amount; + serialized_args[1] = recipient; - context.call_public_function(self.address, 0x716a727f, serialised_args) + context.call_public_function(self.address, 0x716a727f, serialized_args) } @@ -41,14 +41,14 @@ impl NonNativeTokenPrivateContextInterface { secret: Field, canceller: Field ) -> [Field; RETURN_VALUES_LENGTH] { - let mut serialised_args = [0; 5]; - serialised_args[0] = amount; - serialised_args[1] = owner; - serialised_args[2] = msg_key; - serialised_args[3] = secret; - serialised_args[4] = canceller; - - context.call_private_function(self.address, 0x641662d1, serialised_args) + let mut serialized_args = [0; 5]; + serialized_args[0] = amount; + serialized_args[1] = owner; + serialized_args[2] = msg_key; + serialized_args[3] = secret; + serialized_args[4] = canceller; + + context.call_private_function(self.address, 0x641662d1, serialized_args) } @@ -61,14 +61,14 @@ impl NonNativeTokenPrivateContextInterface { secret: Field, canceller: Field ) { - let mut serialised_args = [0; 5]; - serialised_args[0] = amount; - serialised_args[1] = owner_address; - serialised_args[2] = msg_key; - serialised_args[3] = secret; - serialised_args[4] = canceller; - - context.call_public_function(self.address, 0x93343cc1, serialised_args) + let mut serialized_args = [0; 5]; + serialized_args[0] = amount; + serialized_args[1] = owner_address; + serialized_args[2] = msg_key; + serialized_args[3] = secret; + serialized_args[4] = canceller; + + context.call_public_function(self.address, 0x93343cc1, serialized_args) } @@ -79,12 +79,12 @@ impl NonNativeTokenPrivateContextInterface { secret: Field, owner: Field ) -> [Field; RETURN_VALUES_LENGTH] { - let mut serialised_args = [0; 3]; - serialised_args[0] = amount; - serialised_args[1] = secret; - serialised_args[2] = owner; + let mut serialized_args = [0; 3]; + serialized_args[0] = amount; + serialized_args[1] = secret; + serialized_args[2] = owner; - context.call_private_function(self.address, 0x8ecff612, serialised_args) + context.call_private_function(self.address, 0x8ecff612, serialized_args) } @@ -94,11 +94,11 @@ impl NonNativeTokenPrivateContextInterface { amount: Field, secretHash: Field ) { - let mut serialised_args = [0; 2]; - serialised_args[0] = amount; - serialised_args[1] = secretHash; + let mut serialized_args = [0; 2]; + serialized_args[0] = amount; + serialized_args[1] = secretHash; - context.call_public_function(self.address, 0x72451161, serialised_args) + context.call_public_function(self.address, 0x72451161, serialized_args) } @@ -108,11 +108,11 @@ impl NonNativeTokenPrivateContextInterface { amount: Field, recipient: Field ) -> [Field; RETURN_VALUES_LENGTH] { - let mut serialised_args = [0; 2]; - serialised_args[0] = amount; - serialised_args[1] = recipient; + let mut serialized_args = [0; 2]; + serialized_args[0] = amount; + serialized_args[1] = recipient; - context.call_private_function(self.address, 0xc0888d22, serialised_args) + context.call_private_function(self.address, 0xc0888d22, serialized_args) } @@ -122,11 +122,11 @@ impl NonNativeTokenPrivateContextInterface { amount: Field, recipient: Field ) -> [Field; RETURN_VALUES_LENGTH] { - let mut serialised_args = [0; 2]; - serialised_args[0] = amount; - serialised_args[1] = recipient; + let mut serialized_args = [0; 2]; + serialized_args[0] = amount; + serialized_args[1] = recipient; - context.call_private_function(self.address, 0x906b1f4f, serialised_args) + context.call_private_function(self.address, 0x906b1f4f, serialized_args) } @@ -138,13 +138,13 @@ impl NonNativeTokenPrivateContextInterface { recipient: Field, callerOnL1: Field ) -> [Field; RETURN_VALUES_LENGTH] { - let mut serialised_args = [0; 4]; - serialised_args[0] = amount; - serialised_args[1] = sender; - serialised_args[2] = recipient; - serialised_args[3] = callerOnL1; + let mut serialized_args = [0; 4]; + serialized_args[0] = amount; + serialized_args[1] = sender; + serialized_args[2] = recipient; + serialized_args[3] = callerOnL1; - context.call_private_function(self.address, 0x760d58ea, serialised_args) + context.call_private_function(self.address, 0x760d58ea, serialized_args) } @@ -155,12 +155,12 @@ impl NonNativeTokenPrivateContextInterface { recipient: Field, callerOnL1: Field ) { - let mut serialised_args = [0; 3]; - serialised_args[0] = amount; - serialised_args[1] = recipient; - serialised_args[2] = callerOnL1; + let mut serialized_args = [0; 3]; + serialized_args[0] = amount; + serialized_args[1] = recipient; + serialized_args[2] = callerOnL1; - context.call_public_function(self.address, 0xc80c80d3, serialised_args) + context.call_public_function(self.address, 0xc80c80d3, serialized_args) } } @@ -186,11 +186,11 @@ impl NonNativeTokenPublicContextInterface { amount: Field, recipient: Field ) -> [Field; RETURN_VALUES_LENGTH] { - let mut serialised_args = [0; 2]; - serialised_args[0] = amount; - serialised_args[1] = recipient; + let mut serialized_args = [0; 2]; + serialized_args[0] = amount; + serialized_args[1] = recipient; - context.call_public_function(self.address, 0x716a727f, serialised_args) + context.call_public_function(self.address, 0x716a727f, serialized_args) } @@ -203,14 +203,14 @@ impl NonNativeTokenPublicContextInterface { secret: Field, canceller: Field ) -> [Field; RETURN_VALUES_LENGTH] { - let mut serialised_args = [0; 5]; - serialised_args[0] = amount; - serialised_args[1] = owner_address; - serialised_args[2] = msg_key; - serialised_args[3] = secret; - serialised_args[4] = canceller; - - context.call_public_function(self.address, 0x93343cc1, serialised_args) + let mut serialized_args = [0; 5]; + serialized_args[0] = amount; + serialized_args[1] = owner_address; + serialized_args[2] = msg_key; + serialized_args[3] = secret; + serialized_args[4] = canceller; + + context.call_public_function(self.address, 0x93343cc1, serialized_args) } @@ -220,11 +220,11 @@ impl NonNativeTokenPublicContextInterface { amount: Field, secretHash: Field ) -> [Field; RETURN_VALUES_LENGTH] { - let mut serialised_args = [0; 2]; - serialised_args[0] = amount; - serialised_args[1] = secretHash; + let mut serialized_args = [0; 2]; + serialized_args[0] = amount; + serialized_args[1] = secretHash; - context.call_public_function(self.address, 0x72451161, serialised_args) + context.call_public_function(self.address, 0x72451161, serialized_args) } @@ -235,12 +235,12 @@ impl NonNativeTokenPublicContextInterface { recipient: Field, callerOnL1: Field ) -> [Field; RETURN_VALUES_LENGTH] { - let mut serialised_args = [0; 3]; - serialised_args[0] = amount; - serialised_args[1] = recipient; - serialised_args[2] = callerOnL1; + let mut serialized_args = [0; 3]; + serialized_args[0] = amount; + serialized_args[1] = recipient; + serialized_args[2] = callerOnL1; - context.call_public_function(self.address, 0xc80c80d3, serialised_args) + context.call_public_function(self.address, 0xc80c80d3, serialized_args) } } diff --git a/yarn-project/noir-contracts/src/contracts/non_native_token_contract/src/main.nr b/yarn-project/noir-contracts/src/contracts/non_native_token_contract/src/main.nr index 1f747faa89c..8c27d3c39f4 100644 --- a/yarn-project/noir-contracts/src/contracts/non_native_token_contract/src/main.nr +++ b/yarn-project/noir-contracts/src/contracts/non_native_token_contract/src/main.nr @@ -40,15 +40,15 @@ contract NonNativeToken { }, oracle::compute_selector::compute_selector, state_vars::{map::Map, public_state::PublicState, set::Set}, - types::type_serialisation::field_serialisation::{ - FieldSerialisationMethods, FIELD_SERIALISED_LEN, + types::type_serialization::field_serialization::{ + FieldSerializationMethods, FIELD_SERIALIZED_LEN, }, }; struct Storage { balances: Map>, pending_shields: Set, - public_balances: Map>, + public_balances: Map>, } impl Storage { @@ -69,7 +69,7 @@ contract NonNativeToken { PublicState::new( context, slot, - FieldSerialisationMethods, + FieldSerializationMethods, ) }, ), diff --git a/yarn-project/noir-contracts/src/contracts/non_native_token_contract/src/transparent_note.nr b/yarn-project/noir-contracts/src/contracts/non_native_token_contract/src/transparent_note.nr index 5d2feef509c..2c9bcbe2461 100644 --- a/yarn-project/noir-contracts/src/contracts/non_native_token_contract/src/transparent_note.nr +++ b/yarn-project/noir-contracts/src/contracts/non_native_token_contract/src/transparent_note.nr @@ -14,7 +14,7 @@ global TRANSPARENT_NOTE_LEN: Field = 2; struct TransparentNote { amount: Field, secret_hash: Field, - // the fields below are not serialised/deserialised + // the fields below are not serialized/deserialized secret: Field, header: NoteHeader, } @@ -46,11 +46,11 @@ impl TransparentNote { // STANDARD NOTE_INTERFACE FUNCTIONS - fn serialise(self) -> [Field; TRANSPARENT_NOTE_LEN] { + fn serialize(self) -> [Field; TRANSPARENT_NOTE_LEN] { [self.amount, self.secret_hash] } - fn deserialise(preimage: [Field; TRANSPARENT_NOTE_LEN]) -> Self { + fn deserialize(preimage: [Field; TRANSPARENT_NOTE_LEN]) -> Self { TransparentNote { amount: preimage[0], secret_hash: preimage[1], @@ -93,12 +93,12 @@ impl TransparentNote { } } -fn deserialise(preimage: [Field; TRANSPARENT_NOTE_LEN]) -> TransparentNote { - TransparentNote::deserialise(preimage) +fn deserialize(preimage: [Field; TRANSPARENT_NOTE_LEN]) -> TransparentNote { + TransparentNote::deserialize(preimage) } -fn serialise(note: TransparentNote) -> [Field; TRANSPARENT_NOTE_LEN] { - note.serialise() +fn serialize(note: TransparentNote) -> [Field; TRANSPARENT_NOTE_LEN] { + note.serialize() } fn compute_note_hash(note: TransparentNote) -> Field { @@ -118,8 +118,8 @@ fn set_header(note: &mut TransparentNote, header: NoteHeader) { } global TransparentNoteMethods = NoteInterface { - deserialise, - serialise, + deserialize, + serialize, compute_note_hash, compute_nullifier, get_header, diff --git a/yarn-project/noir-contracts/src/contracts/pending_commitments_contract/src/main.nr b/yarn-project/noir-contracts/src/contracts/pending_commitments_contract/src/main.nr index 85525a26448..145712b5fb7 100644 --- a/yarn-project/noir-contracts/src/contracts/pending_commitments_contract/src/main.nr +++ b/yarn-project/noir-contracts/src/contracts/pending_commitments_contract/src/main.nr @@ -67,7 +67,7 @@ contract PendingCommitments { context.inputs.call_context.storage_contract_address, owner_balance.storage_slot, get_public_key(owner), - note.serialise(), + note.serialize(), ); let options = NoteGetterOptions::with_filter(filter_notes_min_sum, amount); @@ -108,7 +108,7 @@ contract PendingCommitments { context.inputs.call_context.storage_contract_address, owner_balance.storage_slot, get_public_key(owner), - note.serialise(), + note.serialize(), ); 0 @@ -139,7 +139,7 @@ contract PendingCommitments { context.inputs.call_context.storage_contract_address, owner_balance.storage_slot, get_public_key(owner), - note.serialise(), + note.serialize(), ); } diff --git a/yarn-project/noir-contracts/src/contracts/pokeable_token_contract/src/address_note.nr b/yarn-project/noir-contracts/src/contracts/pokeable_token_contract/src/address_note.nr index 6801a040542..e931dcb04d1 100644 --- a/yarn-project/noir-contracts/src/contracts/pokeable_token_contract/src/address_note.nr +++ b/yarn-project/noir-contracts/src/contracts/pokeable_token_contract/src/address_note.nr @@ -18,7 +18,7 @@ impl AddressNote { } } - fn serialise(self) -> [Field; ADDRESS_NOTE_LEN] { + fn serialize(self) -> [Field; ADDRESS_NOTE_LEN] { let mut res: [Field; ADDRESS_NOTE_LEN] = [0; ADDRESS_NOTE_LEN]; res[0] = self.address; res @@ -40,20 +40,20 @@ impl AddressNote { } } -fn deserialise(preimage: [Field; ADDRESS_NOTE_LEN]) -> AddressNote { +fn deserialize(preimage: [Field; ADDRESS_NOTE_LEN]) -> AddressNote { AddressNote { address: preimage[0], header: NoteHeader::empty(), } } -fn serialise(note: AddressNote) -> [Field; ADDRESS_NOTE_LEN] { - note.serialise() +fn serialize(note: AddressNote) -> [Field; ADDRESS_NOTE_LEN] { + note.serialize() } fn compute_note_hash(note: AddressNote) -> Field { // TODO(#1205) Should use a non-zero generator index. - dep::std::hash::pedersen(note.serialise())[0] + dep::std::hash::pedersen(note.serialize())[0] } fn compute_nullifier(note: AddressNote) -> Field { @@ -69,8 +69,8 @@ fn set_header(note: &mut AddressNote, header: NoteHeader) { } global AddressNoteMethods = NoteInterface { - deserialise, - serialise, + deserialize, + serialize, compute_note_hash, compute_nullifier, get_header, diff --git a/yarn-project/noir-contracts/src/contracts/pokeable_token_contract/src/main.nr b/yarn-project/noir-contracts/src/contracts/pokeable_token_contract/src/main.nr index 706c734d602..7137c2920f6 100644 --- a/yarn-project/noir-contracts/src/contracts/pokeable_token_contract/src/main.nr +++ b/yarn-project/noir-contracts/src/contracts/pokeable_token_contract/src/main.nr @@ -55,8 +55,8 @@ contract PokeableToken { let mut sender_note = AddressNote::new(sender); let mut recipient_note = AddressNote::new(recipient); - storage.sender.initialise(&mut sender_note); - storage.recipient.initialise(&mut recipient_note); + storage.sender.initialize(&mut sender_note); + storage.recipient.initialize(&mut recipient_note); // Insert new note to a set of user notes and emit the newly created encrypted note preimage via oracle call. let sender_balance = storage.balances.at(sender); diff --git a/yarn-project/noir-contracts/src/contracts/price_feed_contract/src/asset.nr b/yarn-project/noir-contracts/src/contracts/price_feed_contract/src/asset.nr index dc942b40d8e..9686d74a28d 100644 --- a/yarn-project/noir-contracts/src/contracts/price_feed_contract/src/asset.nr +++ b/yarn-project/noir-contracts/src/contracts/price_feed_contract/src/asset.nr @@ -1,28 +1,28 @@ -use dep::aztec::types::type_serialisation::TypeSerialisationInterface; +use dep::aztec::types::type_serialization::TypeSerializationInterface; struct Asset { price: u120, } -global ASSET_SERIALISED_LEN: Field = 1; +global ASSET_SERIALIZED_LEN: Field = 1; -fn deserialiseAsset(fields: [Field; ASSET_SERIALISED_LEN]) -> Asset { +fn deserializeAsset(fields: [Field; ASSET_SERIALIZED_LEN]) -> Asset { Asset { price: fields[0] as u120, } } -fn serialiseAsset(asset: Asset) -> [Field; ASSET_SERIALISED_LEN] { +fn serializeAsset(asset: Asset) -> [Field; ASSET_SERIALIZED_LEN] { [asset.price as Field] } impl Asset { - fn serialize(self: Self) -> [Field; ASSET_SERIALISED_LEN] { - serialiseAsset(self) + fn serialize(self: Self) -> [Field; ASSET_SERIALIZED_LEN] { + serializeAsset(self) } } -global AssetSerialisationMethods = TypeSerialisationInterface { - deserialise: deserialiseAsset, - serialise: serialiseAsset, +global AssetSerializationMethods = TypeSerializationInterface { + deserialize: deserializeAsset, + serialize: serializeAsset, }; diff --git a/yarn-project/noir-contracts/src/contracts/price_feed_contract/src/main.nr b/yarn-project/noir-contracts/src/contracts/price_feed_contract/src/main.nr index 6adea42406b..565956e710b 100644 --- a/yarn-project/noir-contracts/src/contracts/price_feed_contract/src/main.nr +++ b/yarn-project/noir-contracts/src/contracts/price_feed_contract/src/main.nr @@ -9,11 +9,11 @@ contract PriceFeed { public_state::PublicState, }, }; - use crate::asset::{ASSET_SERIALISED_LEN, Asset, AssetSerialisationMethods}; + use crate::asset::{ASSET_SERIALIZED_LEN, Asset, AssetSerializationMethods}; // Storage structure, containing all storage, and specifying what slots they use. struct Storage { - assets: Map>, + assets: Map>, } impl Storage { @@ -26,7 +26,7 @@ contract PriceFeed { PublicState::new( context, slot, - AssetSerialisationMethods, + AssetSerializationMethods, ) }, ), diff --git a/yarn-project/noir-contracts/src/contracts/private_token_airdrop_contract/src/claim_note.nr b/yarn-project/noir-contracts/src/contracts/private_token_airdrop_contract/src/claim_note.nr index 49ed92e15b5..1126e440580 100644 --- a/yarn-project/noir-contracts/src/contracts/private_token_airdrop_contract/src/claim_note.nr +++ b/yarn-project/noir-contracts/src/contracts/private_token_airdrop_contract/src/claim_note.nr @@ -22,11 +22,11 @@ impl ClaimNote { } } - fn serialise(self) -> [Field; CLAIM_NOTE_LEN] { + fn serialize(self) -> [Field; CLAIM_NOTE_LEN] { [self.value, self.secret_hash] } - fn deserialise(preimage: [Field; CLAIM_NOTE_LEN]) -> Self { + fn deserialize(preimage: [Field; CLAIM_NOTE_LEN]) -> Self { ClaimNote { value: preimage[0], secret_hash: preimage[1], @@ -56,12 +56,12 @@ impl ClaimNote { } } -fn deserialise(preimage: [Field; CLAIM_NOTE_LEN]) -> ClaimNote { - ClaimNote::deserialise(preimage) +fn deserialize(preimage: [Field; CLAIM_NOTE_LEN]) -> ClaimNote { + ClaimNote::deserialize(preimage) } -fn serialise(note: ClaimNote) -> [Field; CLAIM_NOTE_LEN] { - note.serialise() +fn serialize(note: ClaimNote) -> [Field; CLAIM_NOTE_LEN] { + note.serialize() } fn compute_note_hash(note: ClaimNote) -> Field { @@ -81,8 +81,8 @@ fn set_header(note: &mut ClaimNote, header: NoteHeader) { } global ClaimNoteMethods = NoteInterface { - deserialise, - serialise, + deserialize, + serialize, compute_note_hash, compute_nullifier, get_header, diff --git a/yarn-project/noir-contracts/src/contracts/private_token_airdrop_contract/src/interface.nr b/yarn-project/noir-contracts/src/contracts/private_token_airdrop_contract/src/interface.nr index 9581bbd11cb..848c52b87ab 100644 --- a/yarn-project/noir-contracts/src/contracts/private_token_airdrop_contract/src/interface.nr +++ b/yarn-project/noir-contracts/src/contracts/private_token_airdrop_contract/src/interface.nr @@ -26,17 +26,17 @@ impl PrivateTokenAirdropPrivateContextInterface { recipients: [Field;3], spend_note_offset: u32 ) -> [Field; RETURN_VALUES_LENGTH] { - let mut serialised_args = [0; 8]; - serialised_args[0] = sender; - serialised_args[1] = amounts[0]; - serialised_args[2] = amounts[1]; - serialised_args[3] = amounts[2]; - serialised_args[4] = recipients[0]; - serialised_args[5] = recipients[1]; - serialised_args[6] = recipients[2]; - serialised_args[7] = spend_note_offset as Field; - - context.call_private_function(self.address, 0xbf748730, serialised_args) + let mut serialized_args = [0; 8]; + serialized_args[0] = sender; + serialized_args[1] = amounts[0]; + serialized_args[2] = amounts[1]; + serialized_args[3] = amounts[2]; + serialized_args[4] = recipients[0]; + serialized_args[5] = recipients[1]; + serialized_args[6] = recipients[2]; + serialized_args[7] = spend_note_offset as Field; + + context.call_private_function(self.address, 0xbf748730, serialized_args) } @@ -46,11 +46,11 @@ impl PrivateTokenAirdropPrivateContextInterface { amount: Field, owner: Field ) -> [Field; RETURN_VALUES_LENGTH] { - let mut serialised_args = [0; 2]; - serialised_args[0] = amount; - serialised_args[1] = owner; + let mut serialized_args = [0; 2]; + serialized_args[0] = amount; + serialized_args[1] = owner; - context.call_private_function(self.address, 0xa4fa3a6f, serialised_args) + context.call_private_function(self.address, 0xa4fa3a6f, serialized_args) } @@ -62,13 +62,13 @@ impl PrivateTokenAirdropPrivateContextInterface { owner: Field, nonce: Field ) -> [Field; RETURN_VALUES_LENGTH] { - let mut serialised_args = [0; 4]; - serialised_args[0] = amount; - serialised_args[1] = secret; - serialised_args[2] = owner; - serialised_args[3] = nonce; + let mut serialized_args = [0; 4]; + serialized_args[0] = amount; + serialized_args[1] = secret; + serialized_args[2] = owner; + serialized_args[3] = nonce; - context.call_private_function(self.address, 0xa9220f0f, serialised_args) + context.call_private_function(self.address, 0xa9220f0f, serialized_args) } @@ -78,41 +78,41 @@ impl PrivateTokenAirdropPrivateContextInterface { amounts: [Field;16], secrets: [Field;16] ) -> [Field; RETURN_VALUES_LENGTH] { - let mut serialised_args = [0; 32]; - serialised_args[0] = amounts[0]; - serialised_args[1] = amounts[1]; - serialised_args[2] = amounts[2]; - serialised_args[3] = amounts[3]; - serialised_args[4] = amounts[4]; - serialised_args[5] = amounts[5]; - serialised_args[6] = amounts[6]; - serialised_args[7] = amounts[7]; - serialised_args[8] = amounts[8]; - serialised_args[9] = amounts[9]; - serialised_args[10] = amounts[10]; - serialised_args[11] = amounts[11]; - serialised_args[12] = amounts[12]; - serialised_args[13] = amounts[13]; - serialised_args[14] = amounts[14]; - serialised_args[15] = amounts[15]; - serialised_args[16] = secrets[0]; - serialised_args[17] = secrets[1]; - serialised_args[18] = secrets[2]; - serialised_args[19] = secrets[3]; - serialised_args[20] = secrets[4]; - serialised_args[21] = secrets[5]; - serialised_args[22] = secrets[6]; - serialised_args[23] = secrets[7]; - serialised_args[24] = secrets[8]; - serialised_args[25] = secrets[9]; - serialised_args[26] = secrets[10]; - serialised_args[27] = secrets[11]; - serialised_args[28] = secrets[12]; - serialised_args[29] = secrets[13]; - serialised_args[30] = secrets[14]; - serialised_args[31] = secrets[15]; - - context.call_private_function(self.address, 0x2eebe7ab, serialised_args) + let mut serialized_args = [0; 32]; + serialized_args[0] = amounts[0]; + serialized_args[1] = amounts[1]; + serialized_args[2] = amounts[2]; + serialized_args[3] = amounts[3]; + serialized_args[4] = amounts[4]; + serialized_args[5] = amounts[5]; + serialized_args[6] = amounts[6]; + serialized_args[7] = amounts[7]; + serialized_args[8] = amounts[8]; + serialized_args[9] = amounts[9]; + serialized_args[10] = amounts[10]; + serialized_args[11] = amounts[11]; + serialized_args[12] = amounts[12]; + serialized_args[13] = amounts[13]; + serialized_args[14] = amounts[14]; + serialized_args[15] = amounts[15]; + serialized_args[16] = secrets[0]; + serialized_args[17] = secrets[1]; + serialized_args[18] = secrets[2]; + serialized_args[19] = secrets[3]; + serialized_args[20] = secrets[4]; + serialized_args[21] = secrets[5]; + serialized_args[22] = secrets[6]; + serialized_args[23] = secrets[7]; + serialized_args[24] = secrets[8]; + serialized_args[25] = secrets[9]; + serialized_args[26] = secrets[10]; + serialized_args[27] = secrets[11]; + serialized_args[28] = secrets[12]; + serialized_args[29] = secrets[13]; + serialized_args[30] = secrets[14]; + serialized_args[31] = secrets[15]; + + context.call_private_function(self.address, 0x2eebe7ab, serialized_args) } @@ -122,11 +122,11 @@ impl PrivateTokenAirdropPrivateContextInterface { amount: Field, owner: Field ) -> [Field; RETURN_VALUES_LENGTH] { - let mut serialised_args = [0; 2]; - serialised_args[0] = amount; - serialised_args[1] = owner; + let mut serialized_args = [0; 2]; + serialized_args[0] = amount; + serialized_args[1] = owner; - context.call_private_function(self.address, 0x1535439c, serialised_args) + context.call_private_function(self.address, 0x1535439c, serialized_args) } @@ -136,11 +136,11 @@ impl PrivateTokenAirdropPrivateContextInterface { amount: Field, recipient: Field ) -> [Field; RETURN_VALUES_LENGTH] { - let mut serialised_args = [0; 2]; - serialised_args[0] = amount; - serialised_args[1] = recipient; + let mut serialized_args = [0; 2]; + serialized_args[0] = amount; + serialized_args[1] = recipient; - context.call_private_function(self.address, 0xc0888d22, serialised_args) + context.call_private_function(self.address, 0xc0888d22, serialized_args) } } diff --git a/yarn-project/noir-contracts/src/contracts/private_token_contract/src/interface.nr b/yarn-project/noir-contracts/src/contracts/private_token_contract/src/interface.nr index 1eee266adcb..0f59f541a24 100644 --- a/yarn-project/noir-contracts/src/contracts/private_token_contract/src/interface.nr +++ b/yarn-project/noir-contracts/src/contracts/private_token_contract/src/interface.nr @@ -24,11 +24,11 @@ impl PrivateTokenPrivateContextInterface { amount: Field, owner: Field ) -> [Field; RETURN_VALUES_LENGTH] { - let mut serialised_args = [0; 2]; - serialised_args[0] = amount; - serialised_args[1] = owner; + let mut serialized_args = [0; 2]; + serialized_args[0] = amount; + serialized_args[1] = owner; - context.call_private_function(self.address, 0x1535439c, serialised_args) + context.call_private_function(self.address, 0x1535439c, serialized_args) } @@ -38,11 +38,11 @@ impl PrivateTokenPrivateContextInterface { amount: Field, recipient: Field ) -> [Field; RETURN_VALUES_LENGTH] { - let mut serialised_args = [0; 2]; - serialised_args[0] = amount; - serialised_args[1] = recipient; + let mut serialized_args = [0; 2]; + serialized_args[0] = amount; + serialized_args[1] = recipient; - context.call_private_function(self.address, 0xc0888d22, serialised_args) + context.call_private_function(self.address, 0xc0888d22, serialized_args) } } diff --git a/yarn-project/noir-contracts/src/contracts/public_token_contract/src/main.nr b/yarn-project/noir-contracts/src/contracts/public_token_contract/src/main.nr index 37ef09b7cb1..3b0babfb684 100644 --- a/yarn-project/noir-contracts/src/contracts/public_token_contract/src/main.nr +++ b/yarn-project/noir-contracts/src/contracts/public_token_contract/src/main.nr @@ -12,13 +12,13 @@ contract PublicToken { map::Map, public_state::PublicState, }, - types::type_serialisation::field_serialisation::{ - FieldSerialisationMethods, FIELD_SERIALISED_LEN, + types::type_serialization::field_serialization::{ + FieldSerializationMethods, FIELD_SERIALIZED_LEN, }, }; struct Storage { - balances: Map>, + balances: Map>, } impl Storage { @@ -28,7 +28,7 @@ contract PublicToken { context, 1, |context, slot| { - PublicState::new(context, slot, FieldSerialisationMethods) + PublicState::new(context, slot, FieldSerializationMethods) }, ), } diff --git a/yarn-project/noir-contracts/src/contracts/schnorr_account_contract/src/main.nr b/yarn-project/noir-contracts/src/contracts/schnorr_account_contract/src/main.nr index b20379efa5f..a26d6fe6de1 100644 --- a/yarn-project/noir-contracts/src/contracts/schnorr_account_contract/src/main.nr +++ b/yarn-project/noir-contracts/src/contracts/schnorr_account_contract/src/main.nr @@ -41,14 +41,14 @@ contract SchnorrAccount { let this = context.this_address(); let mut pub_key_note = PublicKeyNote::new(signing_pub_key_x, signing_pub_key_y, this); - storage.signing_public_key.initialise(&mut pub_key_note); + storage.signing_public_key.initialize(&mut pub_key_note); emit_encrypted_log( &mut context, this, storage.signing_public_key.storage_slot, get_public_key(this), - pub_key_note.serialise(), + pub_key_note.serialize(), ); } diff --git a/yarn-project/noir-contracts/src/contracts/schnorr_account_contract/src/public_key_note.nr b/yarn-project/noir-contracts/src/contracts/schnorr_account_contract/src/public_key_note.nr index 771ca860327..ceb64ac8cb4 100644 --- a/yarn-project/noir-contracts/src/contracts/schnorr_account_contract/src/public_key_note.nr +++ b/yarn-project/noir-contracts/src/contracts/schnorr_account_contract/src/public_key_note.nr @@ -24,8 +24,8 @@ impl PublicKeyNote { } } - // Serialise the note as 3 fields - fn serialise(self) -> [Field; PUBLIC_KEY_NOTE_LEN] { + // serialize the note as 3 fields + fn serialize(self) -> [Field; PUBLIC_KEY_NOTE_LEN] { [self.x, self.y, self.owner] } @@ -45,7 +45,7 @@ impl PublicKeyNote { } } -fn deserialise(preimage: [Field; PUBLIC_KEY_NOTE_LEN]) -> PublicKeyNote { +fn deserialize(preimage: [Field; PUBLIC_KEY_NOTE_LEN]) -> PublicKeyNote { PublicKeyNote { x: preimage[0], y: preimage[1], @@ -54,13 +54,13 @@ fn deserialise(preimage: [Field; PUBLIC_KEY_NOTE_LEN]) -> PublicKeyNote { } } -fn serialise(note: PublicKeyNote) -> [Field; PUBLIC_KEY_NOTE_LEN] { - note.serialise() +fn serialize(note: PublicKeyNote) -> [Field; PUBLIC_KEY_NOTE_LEN] { + note.serialize() } fn compute_note_hash(note: PublicKeyNote) -> Field { // TODO(#1205) Should use a non-zero generator index. - dep::std::hash::pedersen(note.serialise())[0] + dep::std::hash::pedersen(note.serialize())[0] } fn compute_nullifier(note: PublicKeyNote) -> Field { @@ -76,8 +76,8 @@ fn set_header(note: &mut PublicKeyNote, header: NoteHeader) { } global PublicKeyNoteMethods = NoteInterface { - deserialise, - serialise, + deserialize, + serialize, compute_note_hash, compute_nullifier, get_header, diff --git a/yarn-project/noir-contracts/src/contracts/stateful_test_contract/src/main.nr b/yarn-project/noir-contracts/src/contracts/stateful_test_contract/src/main.nr index e8bb13a2a66..56bb4634532 100644 --- a/yarn-project/noir-contracts/src/contracts/stateful_test_contract/src/main.nr +++ b/yarn-project/noir-contracts/src/contracts/stateful_test_contract/src/main.nr @@ -13,14 +13,14 @@ contract StatefulTest { utils as note_utils, }, state_vars::{map::Map, public_state::PublicState, set::Set}, - types::type_serialisation::field_serialisation::{ - FieldSerialisationMethods, FIELD_SERIALISED_LEN, + types::type_serialization::field_serialization::{ + FieldSerializationMethods, FIELD_SERIALIZED_LEN, }, }; struct Storage { notes: Map>, - public_values: Map>, + public_values: Map>, } impl Storage { @@ -40,7 +40,7 @@ contract StatefulTest { PublicState::new( context, slot, - FieldSerialisationMethods, + FieldSerializationMethods, ) }, ), diff --git a/yarn-project/noir-contracts/src/contracts/test_contract/src/interface.nr b/yarn-project/noir-contracts/src/contracts/test_contract/src/interface.nr index 1a11db0ac4f..e5e6ab61f64 100644 --- a/yarn-project/noir-contracts/src/contracts/test_contract/src/interface.nr +++ b/yarn-project/noir-contracts/src/contracts/test_contract/src/interface.nr @@ -45,11 +45,11 @@ impl TestPrivateContextInterface { amount: Field, secretHash: Field ) { - let mut serialised_args = [0; 2]; - serialised_args[0] = amount; - serialised_args[1] = secretHash; + let mut serialized_args = [0; 2]; + serialized_args[0] = amount; + serialized_args[1] = secretHash; - context.call_public_function(self.address, 0xbac98727, serialised_args) + context.call_public_function(self.address, 0xbac98727, serialized_args) } @@ -59,11 +59,11 @@ impl TestPrivateContextInterface { amount: Field, secretHash: Field ) { - let mut serialised_args = [0; 2]; - serialised_args[0] = amount; - serialised_args[1] = secretHash; + let mut serialized_args = [0; 2]; + serialized_args[0] = amount; + serialized_args[1] = secretHash; - context.call_public_function(self.address, 0x42040a24, serialised_args) + context.call_public_function(self.address, 0x42040a24, serialized_args) } @@ -72,10 +72,10 @@ impl TestPrivateContextInterface { context: &mut PrivateContext, value: Field ) { - let mut serialised_args = [0; 1]; - serialised_args[0] = value; + let mut serialized_args = [0; 1]; + serialized_args[0] = value; - context.call_public_function(self.address, 0x817a64cb, serialised_args) + context.call_public_function(self.address, 0x817a64cb, serialized_args) } @@ -84,10 +84,10 @@ impl TestPrivateContextInterface { context: &mut PrivateContext, aztec_address: Field ) -> [Field; RETURN_VALUES_LENGTH] { - let mut serialised_args = [0; 1]; - serialised_args[0] = aztec_address; + let mut serialized_args = [0; 1]; + serialized_args[0] = aztec_address; - context.call_private_function(self.address, 0xaf15a45f, serialised_args) + context.call_private_function(self.address, 0xaf15a45f, serialized_args) } @@ -96,10 +96,10 @@ impl TestPrivateContextInterface { context: &mut PrivateContext, address: Field ) -> [Field; RETURN_VALUES_LENGTH] { - let mut serialised_args = [0; 1]; - serialised_args[0] = address; + let mut serialized_args = [0; 1]; + serialized_args[0] = address; - context.call_private_function(self.address, 0x88f0753b, serialised_args) + context.call_private_function(self.address, 0x88f0753b, serialized_args) } @@ -107,9 +107,9 @@ impl TestPrivateContextInterface { self, context: &mut PrivateContext ) -> [Field; RETURN_VALUES_LENGTH] { - let mut serialised_args = [0; 0]; + let mut serialized_args = [0; 0]; - context.call_private_function(self.address, 0xd3953822, serialised_args) + context.call_private_function(self.address, 0xd3953822, serialized_args) } @@ -117,9 +117,9 @@ impl TestPrivateContextInterface { self, context: &mut PrivateContext ) -> [Field; RETURN_VALUES_LENGTH] { - let mut serialised_args = [0; 0]; + let mut serialized_args = [0; 0]; - context.call_private_function(self.address, 0x82cc9431, serialised_args) + context.call_private_function(self.address, 0x82cc9431, serialized_args) } @@ -128,10 +128,10 @@ impl TestPrivateContextInterface { context: &mut PrivateContext, time: Field ) { - let mut serialised_args = [0; 1]; - serialised_args[0] = time; + let mut serialized_args = [0; 1]; + serialized_args[0] = time; - context.call_public_function(self.address, 0xfff6026c, serialised_args) + context.call_public_function(self.address, 0xfff6026c, serialized_args) } @@ -145,26 +145,26 @@ impl TestPrivateContextInterface { aStruct: AStructTestCodeGenStruct, aDeepStruct: ADeepStructTestCodeGenStruct ) -> [Field; RETURN_VALUES_LENGTH] { - let mut serialised_args = [0; 17]; - serialised_args[0] = aField; - serialised_args[1] = aBool as Field; - serialised_args[2] = aNumber as Field; - serialised_args[3] = anArray[0]; - serialised_args[4] = anArray[1]; - serialised_args[5] = aStruct.amount; - serialised_args[6] = aStruct.secretHash; - serialised_args[7] = aDeepStruct.aField; - serialised_args[8] = aDeepStruct.aBool as Field; - serialised_args[9] = aDeepStruct.aNote.amount; - serialised_args[10] = aDeepStruct.aNote.secretHash; - serialised_args[11] = aDeepStruct.manyNotes[0].amount; - serialised_args[12] = aDeepStruct.manyNotes[0].secretHash; - serialised_args[13] = aDeepStruct.manyNotes[1].amount; - serialised_args[14] = aDeepStruct.manyNotes[1].secretHash; - serialised_args[15] = aDeepStruct.manyNotes[2].amount; - serialised_args[16] = aDeepStruct.manyNotes[2].secretHash; - - context.call_private_function(self.address, 0x81d7c118, serialised_args) + let mut serialized_args = [0; 17]; + serialized_args[0] = aField; + serialized_args[1] = aBool as Field; + serialized_args[2] = aNumber as Field; + serialized_args[3] = anArray[0]; + serialized_args[4] = anArray[1]; + serialized_args[5] = aStruct.amount; + serialized_args[6] = aStruct.secretHash; + serialized_args[7] = aDeepStruct.aField; + serialized_args[8] = aDeepStruct.aBool as Field; + serialized_args[9] = aDeepStruct.aNote.amount; + serialized_args[10] = aDeepStruct.aNote.secretHash; + serialized_args[11] = aDeepStruct.manyNotes[0].amount; + serialized_args[12] = aDeepStruct.manyNotes[0].secretHash; + serialized_args[13] = aDeepStruct.manyNotes[1].amount; + serialized_args[14] = aDeepStruct.manyNotes[1].secretHash; + serialized_args[15] = aDeepStruct.manyNotes[2].amount; + serialized_args[16] = aDeepStruct.manyNotes[2].secretHash; + + context.call_private_function(self.address, 0x81d7c118, serialized_args) } } @@ -190,11 +190,11 @@ impl TestPublicContextInterface { amount: Field, secretHash: Field ) -> [Field; RETURN_VALUES_LENGTH] { - let mut serialised_args = [0; 2]; - serialised_args[0] = amount; - serialised_args[1] = secretHash; + let mut serialized_args = [0; 2]; + serialized_args[0] = amount; + serialized_args[1] = secretHash; - context.call_public_function(self.address, 0xbac98727, serialised_args) + context.call_public_function(self.address, 0xbac98727, serialized_args) } @@ -204,11 +204,11 @@ impl TestPublicContextInterface { amount: Field, secretHash: Field ) -> [Field; RETURN_VALUES_LENGTH] { - let mut serialised_args = [0; 2]; - serialised_args[0] = amount; - serialised_args[1] = secretHash; + let mut serialized_args = [0; 2]; + serialized_args[0] = amount; + serialized_args[1] = secretHash; - context.call_public_function(self.address, 0x42040a24, serialised_args) + context.call_public_function(self.address, 0x42040a24, serialized_args) } @@ -217,10 +217,10 @@ impl TestPublicContextInterface { context: PublicContext, value: Field ) -> [Field; RETURN_VALUES_LENGTH] { - let mut serialised_args = [0; 1]; - serialised_args[0] = value; + let mut serialized_args = [0; 1]; + serialized_args[0] = value; - context.call_public_function(self.address, 0x817a64cb, serialised_args) + context.call_public_function(self.address, 0x817a64cb, serialized_args) } @@ -229,10 +229,10 @@ impl TestPublicContextInterface { context: PublicContext, time: Field ) -> [Field; RETURN_VALUES_LENGTH] { - let mut serialised_args = [0; 1]; - serialised_args[0] = time; + let mut serialized_args = [0; 1]; + serialized_args[0] = time; - context.call_public_function(self.address, 0xfff6026c, serialised_args) + context.call_public_function(self.address, 0xfff6026c, serialized_args) } } diff --git a/yarn-project/noir-contracts/src/contracts/token_bridge_contract/src/main.nr b/yarn-project/noir-contracts/src/contracts/token_bridge_contract/src/main.nr index 0b32db5f727..b760403b04a 100644 --- a/yarn-project/noir-contracts/src/contracts/token_bridge_contract/src/main.nr +++ b/yarn-project/noir-contracts/src/contracts/token_bridge_contract/src/main.nr @@ -10,8 +10,8 @@ contract TokenBridge { use dep::aztec::{ context::{Context}, state_vars::{public_state::PublicState}, - types::type_serialisation::field_serialisation::{ - FieldSerialisationMethods, FIELD_SERIALISED_LEN, + types::type_serialization::field_serialization::{ + FieldSerializationMethods, FIELD_SERIALIZED_LEN, }, types::address::{AztecAddress, EthereumAddress}, oracle::compute_selector::compute_selector, @@ -31,7 +31,7 @@ contract TokenBridge { token: PublicState::new( context, 1, - FieldSerialisationMethods, + FieldSerializationMethods, ), } } diff --git a/yarn-project/noir-contracts/src/contracts/token_contract/src/main.nr b/yarn-project/noir-contracts/src/contracts/token_contract/src/main.nr index 5bdd2bfbb68..7b67527fd68 100644 --- a/yarn-project/noir-contracts/src/contracts/token_contract/src/main.nr +++ b/yarn-project/noir-contracts/src/contracts/token_contract/src/main.nr @@ -29,8 +29,8 @@ contract Token { }, context::{PrivateContext, PublicContext, Context}, state_vars::{map::Map, public_state::PublicState, set::Set}, - types::type_serialisation::field_serialisation::{ - FieldSerialisationMethods, FIELD_SERIALISED_LEN, + types::type_serialization::field_serialization::{ + FieldSerializationMethods, FIELD_SERIALIZED_LEN, }, types::address::{AztecAddress}, oracle::compute_selector::compute_selector, @@ -43,12 +43,12 @@ contract Token { // docs:start:storage_struct struct Storage { - admin: PublicState, - minters: Map>, + admin: PublicState, + minters: Map>, balances: Map>, - total_supply: PublicState, + total_supply: PublicState, pending_shields: Set, - public_balances: Map>, + public_balances: Map>, } // docs:end:storage_struct @@ -59,7 +59,7 @@ contract Token { admin: PublicState::new( context, 1, - FieldSerialisationMethods, + FieldSerializationMethods, ), minters: Map::new( context, @@ -68,7 +68,7 @@ contract Token { PublicState::new( context, slot, - FieldSerialisationMethods, + FieldSerializationMethods, ) }, ), @@ -82,7 +82,7 @@ contract Token { total_supply: PublicState::new( context, 4, - FieldSerialisationMethods, + FieldSerializationMethods, ), pending_shields: Set::new(context, 5, TransparentNoteMethods), public_balances: Map::new( @@ -92,7 +92,7 @@ contract Token { PublicState::new( context, slot, - FieldSerialisationMethods, + FieldSerializationMethods, ) }, ), diff --git a/yarn-project/noir-contracts/src/contracts/token_contract/src/types.nr b/yarn-project/noir-contracts/src/contracts/token_contract/src/types.nr index 438f7ab53d4..8b7e250cec9 100644 --- a/yarn-project/noir-contracts/src/contracts/token_contract/src/types.nr +++ b/yarn-project/noir-contracts/src/contracts/token_contract/src/types.nr @@ -16,7 +16,7 @@ global TRANSPARENT_NOTE_LEN: Field = 2; struct TransparentNote { amount: Field, secret_hash: Field, - // the fields below are not serialised/deserialised + // the fields below are not serialized/deserialized secret: Field, header: NoteHeader, } @@ -48,11 +48,11 @@ impl TransparentNote { // STANDARD NOTE_INTERFACE FUNCTIONS - fn serialise(self) -> [Field; TRANSPARENT_NOTE_LEN] { + fn serialize(self) -> [Field; TRANSPARENT_NOTE_LEN] { [self.amount, self.secret_hash] } - fn deserialise(preimage: [Field; TRANSPARENT_NOTE_LEN]) -> Self { + fn deserialize(preimage: [Field; TRANSPARENT_NOTE_LEN]) -> Self { TransparentNote { amount: preimage[0], secret_hash: preimage[1], @@ -95,12 +95,12 @@ impl TransparentNote { } } -fn deserialise(preimage: [Field; TRANSPARENT_NOTE_LEN]) -> TransparentNote { - TransparentNote::deserialise(preimage) +fn deserialize(preimage: [Field; TRANSPARENT_NOTE_LEN]) -> TransparentNote { + TransparentNote::deserialize(preimage) } -fn serialise(note: TransparentNote) -> [Field; TRANSPARENT_NOTE_LEN] { - note.serialise() +fn serialize(note: TransparentNote) -> [Field; TRANSPARENT_NOTE_LEN] { + note.serialize() } fn compute_note_hash(note: TransparentNote) -> Field { @@ -120,8 +120,8 @@ fn set_header(note: &mut TransparentNote, header: NoteHeader) { } global TransparentNoteMethods = NoteInterface { - deserialise, - serialise, + deserialize, + serialize, compute_note_hash, compute_nullifier, get_header, diff --git a/yarn-project/p2p/src/service/tx_messages.test.ts b/yarn-project/p2p/src/service/tx_messages.test.ts index 80dc2eac333..cdbc0dc6353 100644 --- a/yarn-project/p2p/src/service/tx_messages.test.ts +++ b/yarn-project/p2p/src/service/tx_messages.test.ts @@ -32,14 +32,14 @@ const verifyTx = (actual: Tx, expected: Tx) => { }; describe('Messages', () => { - it('Correctly serialises and deserialises a single private transaction', () => { + it('Correctly serializes and deserializes a single private transaction', () => { const transaction = mockTx(); const message = toTxMessage(transaction); const decodedTransaction = fromTxMessage(message); verifyTx(decodedTransaction, transaction); }); - it('Correctly serialises and deserialises transactions messages', () => { + it('Correctly serializes and deserializes transactions messages', () => { const privateTransactions = [mockTx(), mockTx(), mockTx()]; const message = createTransactionsMessage(privateTransactions); expect(decodeMessageType(message)).toBe(Messages.POOLED_TRANSACTIONS); @@ -49,7 +49,7 @@ describe('Messages', () => { verifyTx(decodedTransactions[2], privateTransactions[2]); }); - it('Correctly serialises and deserialises transaction hashes message', () => { + it('Correctly serializes and deserializes transaction hashes message', () => { const txHashes = [makeTxHash(), makeTxHash(), makeTxHash()]; const message = createTransactionHashesMessage(txHashes); expect(decodeMessageType(message)).toEqual(Messages.POOLED_TRANSACTION_HASHES); @@ -57,7 +57,7 @@ describe('Messages', () => { expect(decodedHashes.map(x => x.toString())).toEqual(txHashes.map(x => x.toString())); }); - it('Correctly serialises and deserialises get transactions message', () => { + it('Correctly serializes and deserializes get transactions message', () => { const txHashes = [makeTxHash(), makeTxHash(), makeTxHash()]; const message = createGetTransactionsRequestMessage(txHashes); expect(decodeMessageType(message)).toEqual(Messages.GET_TRANSACTIONS); diff --git a/yarn-project/sequencer-client/README.md b/yarn-project/sequencer-client/README.md index d45011cd940..de825e7078e 100644 --- a/yarn-project/sequencer-client/README.md +++ b/yarn-project/sequencer-client/README.md @@ -2,7 +2,7 @@ The sequencer is a module responsible for creating and publishing new rollup blocks. This involves fetching txs from the P2P pool, ordering them, executing any public functions, running them through the rollup circuits, assembling the L2 block, and posting it to the L1 rollup contract along with any contract deployment public data. -The client itself is implemented as a continuous loop. After being started, it polls the P2P pool for new txs, assembles a new block if any is found, and goes back to sleep. On every new block assembled, it modifies the world state database to reflect the txs processed, but these changes are only committed once the world state synchroniser sees the new block on L1. +The client itself is implemented as a continuous loop. After being started, it polls the P2P pool for new txs, assembles a new block if any is found, and goes back to sleep. On every new block assembled, it modifies the world state database to reflect the txs processed, but these changes are only committed once the world state synchronizer sees the new block on L1. ## Components diff --git a/yarn-project/sequencer-client/src/client/sequencer-client.ts b/yarn-project/sequencer-client/src/client/sequencer-client.ts index 47d9b976df7..d049b30dc3e 100644 --- a/yarn-project/sequencer-client/src/client/sequencer-client.ts +++ b/yarn-project/sequencer-client/src/client/sequencer-client.ts @@ -1,6 +1,6 @@ import { P2P } from '@aztec/p2p'; import { ContractDataSource, L1ToL2MessageSource, L2BlockSource } from '@aztec/types'; -import { WorldStateSynchroniser } from '@aztec/world-state'; +import { WorldStateSynchronizer } from '@aztec/world-state'; import { SoloBlockBuilder } from '../block_builder/solo_block_builder.js'; import { SequencerClientConfig } from '../config.js'; @@ -20,7 +20,7 @@ export class SequencerClient { * Initializes and starts a new instance. * @param config - Configuration for the sequencer, publisher, and L1 tx sender. * @param p2pClient - P2P client that provides the txs to be sequenced. - * @param worldStateSynchroniser - Provides access to world state. + * @param worldStateSynchronizer - Provides access to world state. * @param contractDataSource - Provides access to contract bytecode for public executions. * @param l2BlockSource - Provides information about the previously published blocks. * @param l1ToL2MessageSource - Provides access to L1 to L2 messages. @@ -29,14 +29,14 @@ export class SequencerClient { public static async new( config: SequencerClientConfig, p2pClient: P2P, - worldStateSynchroniser: WorldStateSynchroniser, + worldStateSynchronizer: WorldStateSynchronizer, contractDataSource: ContractDataSource, l2BlockSource: L2BlockSource, l1ToL2MessageSource: L1ToL2MessageSource, ) { const publisher = getL1Publisher(config); const globalsBuilder = getGlobalVariableBuilder(config); - const merkleTreeDb = worldStateSynchroniser.getLatest(); + const merkleTreeDb = worldStateSynchronizer.getLatest(); const blockBuilder = new SoloBlockBuilder( merkleTreeDb, @@ -51,7 +51,7 @@ export class SequencerClient { publisher, globalsBuilder, p2pClient, - worldStateSynchroniser, + worldStateSynchronizer, blockBuilder, l2BlockSource, l1ToL2MessageSource, diff --git a/yarn-project/sequencer-client/src/sequencer/sequencer.test.ts b/yarn-project/sequencer-client/src/sequencer/sequencer.test.ts index 4d8483ee7a1..1f1c76cc2ac 100644 --- a/yarn-project/sequencer-client/src/sequencer/sequencer.test.ts +++ b/yarn-project/sequencer-client/src/sequencer/sequencer.test.ts @@ -7,7 +7,7 @@ import { } from '@aztec/circuits.js'; import { P2P, P2PClientState } from '@aztec/p2p'; import { L1ToL2MessageSource, L2Block, L2BlockSource, MerkleTreeId, Tx, TxHash, mockTx } from '@aztec/types'; -import { MerkleTreeOperations, WorldStateRunningState, WorldStateSynchroniser } from '@aztec/world-state'; +import { MerkleTreeOperations, WorldStateRunningState, WorldStateSynchronizer } from '@aztec/world-state'; import { MockProxy, mock } from 'jest-mock-extended'; import times from 'lodash.times'; @@ -23,7 +23,7 @@ describe('sequencer', () => { let publisher: MockProxy; let globalVariableBuilder: MockProxy; let p2p: MockProxy; - let worldState: MockProxy; + let worldState: MockProxy; let blockBuilder: MockProxy; let merkleTreeOps: MockProxy; let publicProcessor: MockProxy; @@ -50,7 +50,7 @@ describe('sequencer', () => { getStatus: () => Promise.resolve({ state: P2PClientState.IDLE, syncedToL2Block: lastBlockNumber }), }); - worldState = mock({ + worldState = mock({ getLatest: () => merkleTreeOps, status: () => Promise.resolve({ state: WorldStateRunningState.IDLE, syncedToL2Block: lastBlockNumber }), }); diff --git a/yarn-project/sequencer-client/src/sequencer/sequencer.ts b/yarn-project/sequencer-client/src/sequencer/sequencer.ts index 083df1ac5a2..e51a0d9595b 100644 --- a/yarn-project/sequencer-client/src/sequencer/sequencer.ts +++ b/yarn-project/sequencer-client/src/sequencer/sequencer.ts @@ -4,7 +4,7 @@ import { createDebugLogger } from '@aztec/foundation/log'; import { RunningPromise } from '@aztec/foundation/running-promise'; import { P2P } from '@aztec/p2p'; import { L1ToL2MessageSource, L2Block, L2BlockSource, MerkleTreeId, Tx } from '@aztec/types'; -import { WorldStateStatus, WorldStateSynchroniser } from '@aztec/world-state'; +import { WorldStateStatus, WorldStateSynchronizer } from '@aztec/world-state'; import times from 'lodash.times'; @@ -18,7 +18,7 @@ import { PublicProcessorFactory } from './public_processor.js'; /** * Sequencer client - * - Wins a period of time to become the sequencer (depending on finalised protocol). + * - Wins a period of time to become the sequencer (depending on finalized protocol). * - Chooses a set of txs from the tx pool to be in the rollup. * - Simulate the rollup of txs. * - Adds proof requests to the request pool (not for this milestone). @@ -39,7 +39,7 @@ export class Sequencer { private publisher: L1Publisher, private globalsBuilder: GlobalVariableBuilder, private p2pClient: P2P, - private worldState: WorldStateSynchroniser, + private worldState: WorldStateSynchronizer, private blockBuilder: BlockBuilder, private l2BlockSource: L2BlockSource, private l1ToL2MessageSource: L1ToL2MessageSource, diff --git a/yarn-project/types/src/interfaces/aztec_rpc.ts b/yarn-project/types/src/interfaces/aztec_rpc.ts index 0a5d1fdddd9..d362e4fc728 100644 --- a/yarn-project/types/src/interfaces/aztec_rpc.ts +++ b/yarn-project/types/src/interfaces/aztec_rpc.ts @@ -34,7 +34,7 @@ export interface AztecRPC { * * @param authWitness - The auth witness to insert. Composed of an identifier, which is the hash of * the action to be authorised, and the actual witness as an array of fields, which are to be - * deserialised and processed by the account contract. + * deserialized and processed by the account contract. */ addAuthWitness(authWitness: AuthWitness): Promise; @@ -232,23 +232,23 @@ export interface AztecRPC { * @remarks This indicates that blocks and transactions are synched even if notes are not. Compares local block number with the block number from aztec node. * @deprecated Use `getSyncStatus` instead. */ - isGlobalStateSynchronised(): Promise; + isGlobalStateSynchronized(): Promise; /** - * Checks if the specified account is synchronised. + * Checks if the specified account is synchronized. * @param account - The aztec address for which to query the sync status. * @returns True if the account is fully synched, false otherwise. * @deprecated Use `getSyncStatus` instead. * @remarks Checks whether all the notes from all the blocks have been processed. If it is not the case, the * retrieved information from contracts might be old/stale (e.g. old token balance). */ - isAccountStateSynchronised(account: AztecAddress): Promise; + isAccountStateSynchronized(account: AztecAddress): Promise; /** - * Returns the latest block that has been synchronised globally and for each account. The global block number + * Returns the latest block that has been synchronized globally and for each account. The global block number * indicates whether global state has been updated up to that block, whereas each address indicates up to which * block the private state has been synced for that account. - * @returns The latest block synchronised for blocks, and the latest block synched for notes for each public key being tracked. + * @returns The latest block synchronized for blocks, and the latest block synched for notes for each public key being tracked. */ getSyncStatus(): Promise; } diff --git a/yarn-project/types/src/logs/l2_block_l2_logs.test.ts b/yarn-project/types/src/logs/l2_block_l2_logs.test.ts index 755ab366e3e..d3a231c347f 100644 --- a/yarn-project/types/src/logs/l2_block_l2_logs.test.ts +++ b/yarn-project/types/src/logs/l2_block_l2_logs.test.ts @@ -19,7 +19,7 @@ describe('L2BlockL2Logs', () => { expect(recovered.getSerializedLength()).toEqual(buffer.length); }); - it('serialises to and from JSON', () => { + it('serializes to and from JSON', () => { const l2Logs = L2BlockL2Logs.random(3, 6, 2); const json = l2Logs.toJSON(); const recovered = L2BlockL2Logs.fromJSON(json); diff --git a/yarn-project/types/src/tx_execution_request.ts b/yarn-project/types/src/tx_execution_request.ts index 890314339ea..f9abc90104b 100644 --- a/yarn-project/types/src/tx_execution_request.ts +++ b/yarn-project/types/src/tx_execution_request.ts @@ -83,7 +83,7 @@ export class TxExecutionRequest { /** * Deserializes from a buffer or reader, corresponding to a write in cpp. * @param buffer - Buffer to read from. - * @returns The deserialised TxRequest object. + * @returns The deserialized TxRequest object. */ static fromBuffer(buffer: Buffer | BufferReader): TxExecutionRequest { const reader = BufferReader.asReader(buffer); @@ -100,7 +100,7 @@ export class TxExecutionRequest { /** * Deserializes from a string, corresponding to a write in cpp. * @param str - String to read from. - * @returns The deserialised TxRequest object. + * @returns The deserialized TxRequest object. */ static fromString(str: string): TxExecutionRequest { return TxExecutionRequest.fromBuffer(Buffer.from(str, 'hex')); diff --git a/yarn-project/world-state/README.md b/yarn-project/world-state/README.md index 86b16783bf6..b8704e8c54b 100644 --- a/yarn-project/world-state/README.md +++ b/yarn-project/world-state/README.md @@ -23,11 +23,11 @@ As of the time of writing the collection consisted of the following trees. - The Public Data Tree. A tree whose leaves are the current value of every item of public state in the system, addressed as `leaf_index = hash(contract_address, storage_slot_in_contract)` -### The Synchroniser +### The Synchronizer -The synchroniser's role is to periodically poll for new block information and reconcile that information with the current state of the Merkle Trees. +The synchronizer's role is to periodically poll for new block information and reconcile that information with the current state of the Merkle Trees. -Once a new block is received, the synchroniser checks the uncommitted root values of all of the trees against the roots published as part of the block. If they are all equal, the tree state is committed. If they are not equal, the tree states are rolled back to the last committed state before the published data is inserted and committed. +Once a new block is received, the synchronizer checks the uncommitted root values of all of the trees against the roots published as part of the block. If they are all equal, the tree state is committed. If they are not equal, the tree states are rolled back to the last committed state before the published data is inserted and committed. ### The Merkle Tree Interface diff --git a/yarn-project/world-state/src/index.ts b/yarn-project/world-state/src/index.ts index b373fe2a024..b0b168e54e5 100644 --- a/yarn-project/world-state/src/index.ts +++ b/yarn-project/world-state/src/index.ts @@ -1,4 +1,4 @@ -export * from './synchroniser/index.js'; +export * from './synchronizer/index.js'; export * from './world-state-db/index.js'; export * from './utils.js'; -export * from './synchroniser/config.js'; +export * from './synchronizer/config.js'; diff --git a/yarn-project/world-state/src/synchroniser/index.ts b/yarn-project/world-state/src/synchroniser/index.ts deleted file mode 100644 index b875061d458..00000000000 --- a/yarn-project/world-state/src/synchroniser/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './server_world_state_synchroniser.js'; -export * from './world_state_synchroniser.js'; diff --git a/yarn-project/world-state/src/synchroniser/config.ts b/yarn-project/world-state/src/synchronizer/config.ts similarity index 91% rename from yarn-project/world-state/src/synchroniser/config.ts rename to yarn-project/world-state/src/synchronizer/config.ts index 0c0e7a5718d..5d42930d5b7 100644 --- a/yarn-project/world-state/src/synchroniser/config.ts +++ b/yarn-project/world-state/src/synchronizer/config.ts @@ -1,5 +1,5 @@ /** - * World State synchroniser configuration values. + * World State synchronizer configuration values. */ export interface WorldStateConfig { /** @@ -14,8 +14,8 @@ export interface WorldStateConfig { } /** - * Returns the configuration values for the world state synchroniser. - * @returns The configuration values for the world state synchroniser. + * Returns the configuration values for the world state synchronizer. + * @returns The configuration values for the world state synchronizer. */ export function getConfigEnvVars(): WorldStateConfig { const { WS_BLOCK_CHECK_INTERVAL_MS, WS_L2_BLOCK_QUEUE_SIZE } = process.env; diff --git a/yarn-project/world-state/src/synchronizer/index.ts b/yarn-project/world-state/src/synchronizer/index.ts new file mode 100644 index 00000000000..c0c744ca7f9 --- /dev/null +++ b/yarn-project/world-state/src/synchronizer/index.ts @@ -0,0 +1,2 @@ +export * from './server_world_state_synchronizer.js'; +export * from './world_state_synchronizer.js'; diff --git a/yarn-project/world-state/src/synchroniser/server_world_state_synchroniser.test.ts b/yarn-project/world-state/src/synchronizer/server_world_state_synchronizer.test.ts similarity index 91% rename from yarn-project/world-state/src/synchroniser/server_world_state_synchroniser.test.ts rename to yarn-project/world-state/src/synchronizer/server_world_state_synchronizer.test.ts index d4fafd16e3d..c45e00903a1 100644 --- a/yarn-project/world-state/src/synchroniser/server_world_state_synchroniser.test.ts +++ b/yarn-project/world-state/src/synchronizer/server_world_state_synchronizer.test.ts @@ -27,8 +27,8 @@ import { jest } from '@jest/globals'; import times from 'lodash.times'; import { MerkleTreeDb, MerkleTrees, WorldStateConfig } from '../index.js'; -import { ServerWorldStateSynchroniser } from './server_world_state_synchroniser.js'; -import { WorldStateRunningState } from './world_state_synchroniser.js'; +import { ServerWorldStateSynchronizer } from './server_world_state_synchronizer.js'; +import { WorldStateRunningState } from './world_state_synchronizer.js'; /** * Generic mock implementation. @@ -96,17 +96,17 @@ const getMockBlock = (blockNumber: number, newContractsCommitments?: Buffer[]) = return block; }; -const createSynchroniser = (merkleTreeDb: any, rollupSource: any, blockCheckInterval = 100) => { +const createSynchronizer = (merkleTreeDb: any, rollupSource: any, blockCheckInterval = 100) => { const worldStateConfig: WorldStateConfig = { worldStateBlockCheckIntervalMS: blockCheckInterval, l2QueueSize: 1000, }; - return new ServerWorldStateSynchroniser(merkleTreeDb as MerkleTrees, rollupSource as L2BlockSource, worldStateConfig); + return new ServerWorldStateSynchronizer(merkleTreeDb as MerkleTrees, rollupSource as L2BlockSource, worldStateConfig); }; -const log = createDebugLogger('aztec:server_world_state_synchroniser_test'); +const log = createDebugLogger('aztec:server_world_state_synchronizer_test'); -describe('server_world_state_synchroniser', () => { +describe('server_world_state_synchronizer', () => { const rollupSource: Mockify> = { getBlockNumber: jest.fn().mockImplementation(getLatestBlockNumber), getL2Blocks: jest.fn().mockImplementation(consumeNextBlocks), @@ -134,7 +134,7 @@ describe('server_world_state_synchroniser', () => { stop: jest.fn().mockImplementation(() => Promise.resolve()), } as any; - const performInitialSync = async (server: ServerWorldStateSynchroniser) => { + const performInitialSync = async (server: ServerWorldStateSynchronizer) => { // test initial state let status = await server.status(); expect(status.syncedToL2Block).toEqual(0); @@ -153,11 +153,11 @@ describe('server_world_state_synchroniser', () => { }; it('can be constructed', () => { - expect(() => createSynchroniser(merkleTreeDb, rollupSource)).not.toThrow(); + expect(() => createSynchronizer(merkleTreeDb, rollupSource)).not.toThrow(); }); it('updates sync progress', async () => { - const server = createSynchroniser(merkleTreeDb, rollupSource); + const server = createSynchronizer(merkleTreeDb, rollupSource); // test initial state let status = await server.status(); @@ -196,7 +196,7 @@ describe('server_world_state_synchroniser', () => { expect(status.state).toEqual(WorldStateRunningState.RUNNING); expect(status.syncedToL2Block).toEqual(LATEST_BLOCK_NUMBER); - // stop the synchroniser + // stop the synchronizer await server.stop(); // check the final status @@ -206,7 +206,7 @@ describe('server_world_state_synchroniser', () => { }); it('enables blocking until synced', async () => { - const server = createSynchroniser(merkleTreeDb, rollupSource); + const server = createSynchronizer(merkleTreeDb, rollupSource); let currentBlockNumber = 0; const newBlocks = async () => { @@ -237,7 +237,7 @@ describe('server_world_state_synchroniser', () => { }); it('handles multiple calls to start', async () => { - const server = createSynchroniser(merkleTreeDb, rollupSource); + const server = createSynchronizer(merkleTreeDb, rollupSource); let currentBlockNumber = 0; const newBlocks = async () => { @@ -264,7 +264,7 @@ describe('server_world_state_synchroniser', () => { }); it('immediately syncs if no new blocks', async () => { - const server = createSynchroniser(merkleTreeDb, rollupSource); + const server = createSynchronizer(merkleTreeDb, rollupSource); rollupSource.getBlockNumber.mockImplementationOnce(() => { return Promise.resolve(0); }); @@ -282,7 +282,7 @@ describe('server_world_state_synchroniser', () => { }); it("can't be started if already stopped", async () => { - const server = createSynchroniser(merkleTreeDb, rollupSource); + const server = createSynchronizer(merkleTreeDb, rollupSource); rollupSource.getBlockNumber.mockImplementationOnce(() => { return Promise.resolve(0); }); @@ -297,7 +297,7 @@ describe('server_world_state_synchroniser', () => { it('adds the received L2 blocks', async () => { merkleTreeDb.handleL2Block.mockReset(); - const server = createSynchroniser(merkleTreeDb, rollupSource); + const server = createSynchronizer(merkleTreeDb, rollupSource); const totalBlocks = LATEST_BLOCK_NUMBER + 1; nextBlocks = Array(totalBlocks) .fill(0) @@ -310,7 +310,7 @@ describe('server_world_state_synchroniser', () => { }); it('can immediately sync to latest', async () => { - const server = createSynchroniser(merkleTreeDb, rollupSource, 10000); + const server = createSynchronizer(merkleTreeDb, rollupSource, 10000); await performInitialSync(server); @@ -328,7 +328,7 @@ describe('server_world_state_synchroniser', () => { status = await server.status(); expect(status.syncedToL2Block).toBe(LATEST_BLOCK_NUMBER + 3); - // stop the synchroniser + // stop the synchronizer await server.stop(); // check the final status @@ -338,7 +338,7 @@ describe('server_world_state_synchroniser', () => { }); it('can immediately sync to a minimum block number', async () => { - const server = createSynchroniser(merkleTreeDb, rollupSource, 10000); + const server = createSynchronizer(merkleTreeDb, rollupSource, 10000); await performInitialSync(server); @@ -353,7 +353,7 @@ describe('server_world_state_synchroniser', () => { let status = await server.status(); expect(status.syncedToL2Block).toBe(LATEST_BLOCK_NUMBER + 20); - // stop the synchroniser + // stop the synchronizer await server.stop(); // check the final status @@ -363,7 +363,7 @@ describe('server_world_state_synchroniser', () => { }); it('can immediately sync to a minimum block in the past', async () => { - const server = createSynchroniser(merkleTreeDb, rollupSource, 10000); + const server = createSynchronizer(merkleTreeDb, rollupSource, 10000); await performInitialSync(server); // syncing to a block in the past should succeed @@ -375,7 +375,7 @@ describe('server_world_state_synchroniser', () => { let status = await server.status(); expect(status.syncedToL2Block).toBe(LATEST_BLOCK_NUMBER); - // stop the synchroniser + // stop the synchronizer await server.stop(); // check the final status @@ -385,7 +385,7 @@ describe('server_world_state_synchroniser', () => { }); it('throws if you try to sync to an unavailable block', async () => { - const server = createSynchroniser(merkleTreeDb, rollupSource, 10000); + const server = createSynchronizer(merkleTreeDb, rollupSource, 10000); await performInitialSync(server); @@ -401,7 +401,7 @@ describe('server_world_state_synchroniser', () => { let status = await server.status(); expect(status.syncedToL2Block).toBe(LATEST_BLOCK_NUMBER + 2); - // stop the synchroniser + // stop the synchronizer await server.stop(); // check the final status @@ -411,7 +411,7 @@ describe('server_world_state_synchroniser', () => { }); it('throws if you try to immediate sync when not running', async () => { - const server = createSynchroniser(merkleTreeDb, rollupSource, 10000); + const server = createSynchronizer(merkleTreeDb, rollupSource, 10000); // test initial state const status = await server.status(); diff --git a/yarn-project/world-state/src/synchroniser/server_world_state_synchroniser.ts b/yarn-project/world-state/src/synchronizer/server_world_state_synchronizer.ts similarity index 95% rename from yarn-project/world-state/src/synchroniser/server_world_state_synchroniser.ts rename to yarn-project/world-state/src/synchronizer/server_world_state_synchronizer.ts index f96c432c05e..042a6b344ba 100644 --- a/yarn-project/world-state/src/synchroniser/server_world_state_synchroniser.ts +++ b/yarn-project/world-state/src/synchronizer/server_world_state_synchronizer.ts @@ -5,14 +5,14 @@ import { L2Block, L2BlockDownloader, L2BlockSource } from '@aztec/types'; import { MerkleTreeOperations, MerkleTrees } from '../index.js'; import { MerkleTreeOperationsFacade } from '../merkle-tree/merkle_tree_operations_facade.js'; import { WorldStateConfig } from './config.js'; -import { WorldStateRunningState, WorldStateStatus, WorldStateSynchroniser } from './world_state_synchroniser.js'; +import { WorldStateRunningState, WorldStateStatus, WorldStateSynchronizer } from './world_state_synchronizer.js'; /** - * Synchronises the world state with the L2 blocks from a L2BlockSource. - * The synchroniser will download the L2 blocks from the L2BlockSource and insert the new commitments into the merkle + * Synchronizes the world state with the L2 blocks from a L2BlockSource. + * The synchronizer will download the L2 blocks from the L2BlockSource and insert the new commitments into the merkle * tree. */ -export class ServerWorldStateSynchroniser implements WorldStateSynchroniser { +export class ServerWorldStateSynchronizer implements WorldStateSynchronizer { private currentL2BlockNum = 0; private latestBlockNumberAtStart = 0; @@ -47,7 +47,7 @@ export class ServerWorldStateSynchroniser implements WorldStateSynchroniser { public async start() { if (this.currentState === WorldStateRunningState.STOPPED) { - throw new Error('Synchroniser already stopped'); + throw new Error('Synchronizer already stopped'); } if (this.currentState !== WorldStateRunningState.IDLE) { return this.syncPromise; diff --git a/yarn-project/world-state/src/synchroniser/world_state_synchroniser.ts b/yarn-project/world-state/src/synchronizer/world_state_synchronizer.ts similarity index 70% rename from yarn-project/world-state/src/synchroniser/world_state_synchroniser.ts rename to yarn-project/world-state/src/synchronizer/world_state_synchronizer.ts index 8266e301611..39e75cb91cb 100644 --- a/yarn-project/world-state/src/synchroniser/world_state_synchroniser.ts +++ b/yarn-project/world-state/src/synchronizer/world_state_synchronizer.ts @@ -1,7 +1,7 @@ import { MerkleTreeOperations } from '../index.js'; /** - * Defines the possible states of the world state synchroniser. + * Defines the possible states of the world state synchronizer. */ export enum WorldStateRunningState { IDLE, @@ -11,37 +11,37 @@ export enum WorldStateRunningState { } /** - * Defines the status of the world state synchroniser. + * Defines the status of the world state synchronizer. */ export interface WorldStateStatus { /** - * The current state of the world state synchroniser. + * The current state of the world state synchronizer. */ state: WorldStateRunningState; /** - * The block number that the world state synchroniser is synced to. + * The block number that the world state synchronizer is synced to. */ syncedToL2Block: number; } /** - * Defines the interface for a world state synchroniser. + * Defines the interface for a world state synchronizer. */ -export interface WorldStateSynchroniser { +export interface WorldStateSynchronizer { /** - * Starts the synchroniser. + * Starts the synchronizer. * @returns A promise that resolves once the initial sync is completed. */ start(): void; /** - * Returns the current status of the synchroniser. - * @returns The current status of the synchroniser. + * Returns the current status of the synchronizer. + * @returns The current status of the synchronizer. */ status(): Promise; /** - * Stops the synchroniser. + * Stops the synchronizer. */ stop(): Promise; diff --git a/yarn-project/world-state/src/world-state-db/merkle_trees.ts b/yarn-project/world-state/src/world-state-db/merkle_trees.ts index 5d01d107f4b..0d04eee180a 100644 --- a/yarn-project/world-state/src/world-state-db/merkle_trees.ts +++ b/yarn-project/world-state/src/world-state-db/merkle_trees.ts @@ -45,7 +45,7 @@ import { } from './index.js'; /** - * Data necessary to reinitialise the merkle trees from Db. + * Data necessary to reinitialize the merkle trees from Db. */ interface FromDbOptions { /** @@ -67,24 +67,24 @@ export class MerkleTrees implements MerkleTreeDb { } /** - * Initialises the collection of Merkle Trees. + * initializes the collection of Merkle Trees. * @param optionalWasm - WASM instance to use for hashing (if not provided PrimitivesWasm will be used). - * @param fromDbOptions - Options to initialise the trees from the database. + * @param fromDbOptions - Options to initialize the trees from the database. */ public async init(optionalWasm?: IWasmModule, fromDbOptions?: FromDbOptions) { const fromDb = fromDbOptions !== undefined; - const initialiseTree = fromDb ? loadTree : newTree; + const initializeTree = fromDb ? loadTree : newTree; const wasm = optionalWasm ?? (await CircuitsWasm.get()); const hasher = new Pedersen(wasm); - const contractTree: AppendOnlyTree = await initialiseTree( + const contractTree: AppendOnlyTree = await initializeTree( StandardTree, this.db, hasher, `${MerkleTreeId[MerkleTreeId.CONTRACT_TREE]}`, CONTRACT_TREE_HEIGHT, ); - const nullifierTree = await initialiseTree( + const nullifierTree = await initializeTree( StandardIndexedTree, this.db, hasher, @@ -92,28 +92,28 @@ export class MerkleTrees implements MerkleTreeDb { NULLIFIER_TREE_HEIGHT, INITIAL_NULLIFIER_TREE_SIZE, ); - const privateDataTree: AppendOnlyTree = await initialiseTree( + const privateDataTree: AppendOnlyTree = await initializeTree( StandardTree, this.db, hasher, `${MerkleTreeId[MerkleTreeId.PRIVATE_DATA_TREE]}`, PRIVATE_DATA_TREE_HEIGHT, ); - const publicDataTree: UpdateOnlyTree = await initialiseTree( + const publicDataTree: UpdateOnlyTree = await initializeTree( SparseTree, this.db, hasher, `${MerkleTreeId[MerkleTreeId.PUBLIC_DATA_TREE]}`, PUBLIC_DATA_TREE_HEIGHT, ); - const l1Tol2MessagesTree: AppendOnlyTree = await initialiseTree( + const l1Tol2MessagesTree: AppendOnlyTree = await initializeTree( StandardTree, this.db, hasher, `${MerkleTreeId[MerkleTreeId.L1_TO_L2_MESSAGES_TREE]}`, L1_TO_L2_MSG_TREE_HEIGHT, ); - const historicBlocksTree: AppendOnlyTree = await initialiseTree( + const historicBlocksTree: AppendOnlyTree = await initializeTree( StandardTree, this.db, hasher, @@ -136,10 +136,10 @@ export class MerkleTrees implements MerkleTreeDb { } /** - * Method to asynchronously create and initialise a MerkleTrees instance. + * Method to asynchronously create and initialize a MerkleTrees instance. * @param db - The db instance to use for data persistance. * @param wasm - WASM instance to use for hashing (if not provided PrimitivesWasm will be used). - * @returns - A fully initialised MerkleTrees instance. + * @returns - A fully initialized MerkleTrees instance. */ public static async new(db: levelup.LevelUp, wasm?: IWasmModule) { const merkleTrees = new MerkleTrees(db); @@ -177,7 +177,7 @@ export class MerkleTrees implements MerkleTreeDb { * @param includeUncommitted - Indicates whether to include uncommitted data. */ public async updateHistoricBlocksTree(globalsHash: Fr, includeUncommitted: boolean) { - await this.synchronise(() => this._updateHistoricBlocksTree(globalsHash, includeUncommitted)); + await this.synchronize(() => this._updateHistoricBlocksTree(globalsHash, includeUncommitted)); } /** @@ -185,7 +185,7 @@ export class MerkleTrees implements MerkleTreeDb { * @param globalVariablesHash - The latest global variables hash */ public async updateLatestGlobalVariablesHash(globalVariablesHash: Fr) { - return await this.synchronise(() => this._updateLatestGlobalVariablesHash(globalVariablesHash)); + return await this.synchronize(() => this._updateLatestGlobalVariablesHash(globalVariablesHash)); } /** @@ -193,7 +193,7 @@ export class MerkleTrees implements MerkleTreeDb { * @param includeUncommitted - Indicates whether to include uncommitted data. */ public async getLatestGlobalVariablesHash(includeUncommitted: boolean): Promise { - return await this.synchronise(() => this._getGlobalVariablesHash(includeUncommitted)); + return await this.synchronize(() => this._getGlobalVariablesHash(includeUncommitted)); } /** @@ -203,7 +203,7 @@ export class MerkleTrees implements MerkleTreeDb { * @returns The tree info for the specified tree. */ public async getTreeInfo(treeId: MerkleTreeId, includeUncommitted: boolean): Promise { - return await this.synchronise(() => this._getTreeInfo(treeId, includeUncommitted)); + return await this.synchronize(() => this._getTreeInfo(treeId, includeUncommitted)); } /** @@ -212,7 +212,7 @@ export class MerkleTrees implements MerkleTreeDb { * @returns The current roots of the trees. */ public async getTreeRoots(includeUncommitted: boolean): Promise { - const roots = await this.synchronise(() => Promise.resolve(this._getAllTreeRoots(includeUncommitted))); + const roots = await this.synchronize(() => Promise.resolve(this._getAllTreeRoots(includeUncommitted))); return { privateDataTreeRoot: roots[0], @@ -255,7 +255,7 @@ export class MerkleTrees implements MerkleTreeDb { index: bigint, includeUncommitted: boolean, ): Promise { - return await this.synchronise(() => this.trees[treeId].getLeafValue(index, includeUncommitted)); + return await this.synchronize(() => this.trees[treeId].getLeafValue(index, includeUncommitted)); } /** @@ -270,7 +270,7 @@ export class MerkleTrees implements MerkleTreeDb { index: bigint, includeUncommitted: boolean, ): Promise> { - return await this.synchronise(() => this._getSiblingPath(treeId, index, includeUncommitted)); + return await this.synchronize(() => this._getSiblingPath(treeId, index, includeUncommitted)); } /** @@ -280,7 +280,7 @@ export class MerkleTrees implements MerkleTreeDb { * @returns Empty promise. */ public async appendLeaves(treeId: MerkleTreeId, leaves: Buffer[]): Promise { - return await this.synchronise(() => this._appendLeaves(treeId, leaves)); + return await this.synchronize(() => this._appendLeaves(treeId, leaves)); } /** @@ -288,7 +288,7 @@ export class MerkleTrees implements MerkleTreeDb { * @returns Empty promise. */ public async commit(): Promise { - return await this.synchronise(() => this._commit()); + return await this.synchronize(() => this._commit()); } /** @@ -296,7 +296,7 @@ export class MerkleTrees implements MerkleTreeDb { * @returns Empty promise. */ public async rollback(): Promise { - return await this.synchronise(() => this._rollback()); + return await this.synchronize(() => this._rollback()); } /** @@ -320,7 +320,7 @@ export class MerkleTrees implements MerkleTreeDb { */ alreadyPresent: boolean; }> { - return await this.synchronise(() => + return await this.synchronize(() => Promise.resolve(this._getIndexedTree(treeId).findIndexOfPreviousValue(value, includeUncommitted)), ); } @@ -337,7 +337,7 @@ export class MerkleTrees implements MerkleTreeDb { index: number, includeUncommitted: boolean, ): Promise { - return await this.synchronise(() => + return await this.synchronize(() => Promise.resolve(this._getIndexedTree(treeId).getLatestLeafDataCopy(index, includeUncommitted)), ); } @@ -354,7 +354,7 @@ export class MerkleTrees implements MerkleTreeDb { value: Buffer, includeUncommitted: boolean, ): Promise { - return await this.synchronise(async () => { + return await this.synchronize(async () => { const tree = this.trees[treeId]; for (let i = 0n; i < tree.getNumLeaves(includeUncommitted); i++) { const currentValue = await tree.getLeafValue(i, includeUncommitted); @@ -374,7 +374,7 @@ export class MerkleTrees implements MerkleTreeDb { * @returns Empty promise. */ public async updateLeaf(treeId: IndexedTreeId | PublicTreeId, leaf: LeafData | Buffer, index: bigint): Promise { - return await this.synchronise(() => this._updateLeaf(treeId, leaf, index)); + return await this.synchronize(() => this._updateLeaf(treeId, leaf, index)); } /** @@ -382,7 +382,7 @@ export class MerkleTrees implements MerkleTreeDb { * @param block - The L2 block to handle. */ public async handleL2Block(block: L2Block): Promise { - await this.synchronise(() => this._handleL2Block(block)); + await this.synchronize(() => this._handleL2Block(block)); } /** @@ -408,7 +408,7 @@ export class MerkleTrees implements MerkleTreeDb { if (!('batchInsert' in tree)) { throw new Error('Tree does not support `batchInsert` method'); } - return await this.synchronise(() => tree.batchInsert(leaves, subtreeHeight)); + return await this.synchronize(() => tree.batchInsert(leaves, subtreeHeight)); } /** @@ -416,7 +416,7 @@ export class MerkleTrees implements MerkleTreeDb { * @param fn - The function to execute. * @returns Promise containing the result of the function. */ - private async synchronise(fn: () => Promise): Promise { + private async synchronize(fn: () => Promise): Promise { return await this.jobQueue.put(fn); }