Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Use US spelling #2475

Merged
merged 6 commits into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions circuits/cpp/src/aztec3/circuits/apps/.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ template <typename Builder> class FunctionExecutionContext {

PrivateCircuitPublicInputs<NT> final_private_circuit_public_inputs{};

bool is_finalised = false;
bool is_finalized = false;

public:
FunctionExecutionContext(Builder& builder, OracleWrapperInterface<Builder>& oracle)
Expand Down Expand Up @@ -101,8 +101,8 @@ template <typename Builder> class FunctionExecutionContext {
PrivateCircuitPublicInputs<NT> 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;
}
Expand Down Expand Up @@ -287,7 +287,7 @@ template <typename Builder> 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;
Expand Down Expand Up @@ -319,16 +319,16 @@ template <typename Builder> 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<Builder>();
is_finalised = true;
is_finalized = true;
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ OptionalPrivateCircuitPublicInputs<NT> constructor(FunctionExecutionContext& exe
auto& public_inputs = exec_ctx.private_circuit_public_inputs;
public_inputs.args_hash = compute_var_args_hash<CT>({ arg0, arg1, arg2 });

exec_ctx.finalise();
exec_ctx.finalize();

// info("public inputs: ", public_inputs);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ OptionalPrivateCircuitPublicInputs<NT> deposit(FunctionExecutionContext& exec_ct
auto& public_inputs = exec_ctx.private_circuit_public_inputs;
public_inputs.args_hash = compute_var_args_hash<CT>({ amount, asset_id, memo });

exec_ctx.finalise();
exec_ctx.finalize();

// info("public inputs: ", public_inputs);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ OptionalPrivateCircuitPublicInputs<NT> 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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ OptionalPrivateCircuitPublicInputs<NT> withdraw(FunctionExecutionContext& exec_c
auto& public_inputs = exec_ctx.private_circuit_public_inputs;
public_inputs.args_hash = compute_var_args_hash<CT>({ 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ void function_1_1(FunctionExecutionContext& exec_ctx, std::vector<NT::fr> const&
auto& public_inputs = exec_ctx.private_circuit_public_inputs;
public_inputs.args_hash = compute_var_args_hash<CT>({ a, b, c });

exec_ctx.finalise();
exec_ctx.finalize();
};

} // namespace aztec3::circuits::apps::test_apps::private_to_private_function_call
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void function_2_1(FunctionExecutionContext& exec_ctx, std::vector<NT::fr> const&

public_inputs.return_values[0] = product;

exec_ctx.finalise();
exec_ctx.finalize();

// info("public inputs: ", public_inputs);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/dev_docs/cli/main.md
Original file line number Diff line number Diff line change
Expand Up @@ -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=<Account address printed by the above command>
Expand Down
18 changes: 9 additions & 9 deletions docs/docs/dev_docs/contracts/compiling.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
```
Expand Down
2 changes: 1 addition & 1 deletion docs/docs/dev_docs/contracts/syntax/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
42 changes: 21 additions & 21 deletions docs/docs/dev_docs/contracts/syntax/state_variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
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<T, T_SERIALISED_LEN>`
## `PublicState<T, T_SERIALIZED_LEN>`

Public state is persistent state that is _publicly visible_ to anyone in the world.

For developers coming from other blockchain ecosystems (such as Ethereum), this will be a familiar concept, because there, _all_ state is _publicly visible_.

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<T, T_SERIALISED_LEN>` 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<T, T_SERIALIZED_LEN>` 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`

Expand All @@ -22,31 +22,31 @@ 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

It's possible to create a public state for any types. Simply define methods that guide the PublicState wrapper in serialising the custom type to field(s) to store in the public state tree, and deserialising the field(s) retrieved from the tree back to the custom type.

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

Expand All @@ -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:

Expand Down Expand Up @@ -133,23 +133,23 @@ The interplay between a private state variable and its notes can be confusing. H

## `Singleton<NoteType>`

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`

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`

Expand Down Expand Up @@ -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

Expand All @@ -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<NoteType>`

Expand Down Expand Up @@ -269,11 +269,11 @@ Several methods are available on `NoteGetterOptions` to construct the options in

#### `fn new() -> NoteGetterOptions<Note, N, Field>`

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<Note, N, FILTER_ARGS>`

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`

Expand Down Expand Up @@ -347,7 +347,7 @@ The `NoteViewerOptions` is essentially similar to the [`NoteGetterOptions`](#not

## `Map<T>`

`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`.

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/dev_docs/sandbox_errors/main.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading