Skip to content

Commit 5fb142a

Browse files
authored
feat: merge-train/fairies (#20586)
BEGIN_COMMIT_OVERRIDE chore: reverting accidental de-macroifycation of AuthRegistry (#20532) docs: add delayedpublicmutable apiref, fix misc docs (#20512) chore: rename simulateUtility -> executeUtility (#20572) fix: enable contract debug logs in `aztec test` (#20580) chore: merging next to merge-train/fairies (#20622) END_COMMIT_OVERRIDE
2 parents 6246b21 + 0b306b2 commit 5fb142a

File tree

48 files changed

+921
-656
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+921
-656
lines changed

docs/docs-developers/docs/resources/migration_notes.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,27 @@ Aztec is in active development. Each version may introduce breaking changes that
99

1010
## TBD
1111

12+
### `simulateUtility` renamed to `executeUtility`
13+
14+
The `simulateUtility` method and related types have been renamed to `executeUtility` across the entire stack to better reflect that utility functions are executed, not simulated.
15+
16+
**TypeScript:**
17+
18+
```diff
19+
- import { SimulateUtilityOptions, UtilitySimulationResult } from '@aztec/aztec.js';
20+
+ import { ExecuteUtilityOptions, UtilityExecutionResult } from '@aztec/aztec.js';
21+
22+
- const result: UtilitySimulationResult = await wallet.simulateUtility(functionCall, opts);
23+
+ const result: UtilityExecutionResult = await wallet.executeUtility(functionCall, opts);
24+
```
25+
26+
**Noir (test environment):**
27+
28+
```diff
29+
- let result = env.simulate_utility(my_contract_address, selector);
30+
+ let result = env.execute_utility(my_contract_address, selector);
31+
```
32+
1233
### [Protocol] `include_by_timestamp` renamed to `expiration_timestamp`
1334

1435
The `include_by_timestamp` field has been renamed to `expiration_timestamp` across the protocol to better convey its meaning.
@@ -266,8 +287,6 @@ For this reason we've created place holder protocol contracts in `noir-projects/
266287
On your side all you need to do is update the dependency in `Nargo.toml`:
267288

268289
```diff
269-
-auth_contract = { path = "../../protocol/auth_registry_contract" }
270-
+auth_contract = { path = "../../protocol_interface/auth_registry_interface" }
271290
-instance_contract = { path = "../../protocol/contract_instance_registry" }
272291
+instance_contract = { path = "../../protocol_interface/contract_instance_registry_interface" }
273292
```

noir-projects/aztec-nr/aztec/src/context/private_context.nr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ impl PrivateContext {
611611
/// network as a whole. For example, if a contract interaction sets include-by to some publicly-known value (e.g.
612612
/// the time when a contract upgrades), then the wallet might wish to set an even lower one to avoid revealing that
613613
/// this tx is interacting with said contract. Ideally, all wallets should standardize on an approach in order to
614-
/// provide users with a large anonymity set -- although the exact approach
614+
/// provide users with a large privacy set -- although the exact approach
615615
/// will need to be discussed. Wallets that deviate from a standard might accidentally reveal which wallet each
616616
/// transaction originates from.
617617
///

noir-projects/aztec-nr/aztec/src/history/nullifier.nr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ mod test;
2626
///
2727
/// ## Cost
2828
///
29-
/// This function performs a full merkle tree inclusion proof, which is in the order of 4k gates.
29+
/// This function performs a single merkle tree inclusion proof, which is in the order of 4k gates.
3030
///
3131
/// If you don't need to assert existence at a _specific_ past block, consider using
3232
/// [`PrivateContext::assert_nullifier_exists`](crate::context::PrivateContext::assert_nullifier_exists) instead, which
@@ -82,7 +82,7 @@ pub fn assert_nullifier_existed_by(block_header: BlockHeader, siloed_nullifier:
8282
///
8383
/// ## Cost
8484
///
85-
/// This function performs a full merkle tree inclusion proof, which is in the order of 4k gates.
85+
/// This function performs a single merkle tree inclusion proof, which is in the order of 4k gates.
8686
pub fn assert_nullifier_did_not_exist_by(block_header: BlockHeader, siloed_nullifier: Field) {
8787
// 1) Get the membership witness of a low nullifier of the nullifier.
8888
// Safety: The witness is only used as a "magical value" that makes the proof below pass. Hence it's safe.

noir-projects/aztec-nr/aztec/src/macros/notes.nr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ pub comptime fn custom_note(s: TypeDefinition) -> Quoted {
280280
}
281281
}
282282

283-
/// Asserts that the given note implements the `Packable` trait.
283+
/// Asserts that the given note implements the [`Packable`](crate::protocol::traits::Packable) trait.
284284
///
285285
/// We require that notes have the `Packable` trait implemented because it is used when emitting a note in a log or as
286286
/// an offchain message.

noir-projects/aztec-nr/aztec/src/state_vars/delayed_public_mutable.nr

Lines changed: 323 additions & 18 deletions
Large diffs are not rendered by default.

noir-projects/aztec-nr/aztec/src/state_vars/public_immutable.nr

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,9 @@ mod test;
2828
/// A value stored in a `PublicImmutable` can be read and initialized from public contract functions.
2929
///
3030
/// Unlike [`PublicMutable`](crate::state_vars::PublicMutable) it is **also** possible to read a `PublicImmutable` from
31-
/// a
32-
/// private contract function, though it is not possible to initialize one. A common pattern is to have these functions
33-
/// [enqueue a public self calls](crate::contract_self::ContractSelf::enqueue_self) in which the initialization
34-
/// operation is performed.
31+
/// a private contract function, though it is not possible to initialize one. A common pattern is to have these
32+
/// functions [enqueue a public self calls](crate::contract_self::ContractSelf::enqueue_self) in which the
33+
/// initialization operation is performed.
3534
///
3635
/// For a mutable (with restrictions) variant which also can be read from private functions see
3736
/// [`DelayedPublicMutable`](crate::state_vars::DelayedPublicMutable).
@@ -54,26 +53,26 @@ mod test;
5453
///
5554
/// `PublicImmutable`'s main limitation is the immutability, which in many cases leads to
5655
/// [`DelayedPublicMutable`](crate::state_vars::DelayedPublicMutable) being used instead. But in those cases where
57-
/// fixed
58-
/// values are not a problem, this is a fine choice for storage.
56+
/// fixed values are not a problem, this is a fine choice for storage.
5957
///
6058
/// ## Examples
6159
///
62-
/// Declaring a `PublicImmutable` in the the contract's [`storage`](crate::macros::storage::storage) struct requires
60+
/// Declaring a `PublicImmutable` in the contract's [`storage`](crate::macros::storage::storage) struct requires
6361
/// specifying the type `T` that is stored in the variable:
6462
///
6563
/// ```noir
6664
/// #[storage]
67-
/// struct Storage<Context> {
68-
/// decimals: PublicImmutable<u8, Context>,
65+
/// struct Storage<C> {
66+
/// decimals: PublicImmutable<u8, C>,
6967
///
70-
/// account_types: Map<AztecAddress, PublicImmutable<AccountType, Context>, Context>,
68+
/// account_types: Map<AztecAddress, PublicImmutable<AccountType, C>, C>,
7169
/// }
7270
/// ```
7371
///
7472
/// ## Requirements
7573
///
76-
/// The type `T` stored in the `PublicImmutable` must implement the `Packable` trait.
74+
/// The type `T` stored in the `PublicImmutable` must implement the `Eq` and
75+
/// [`Packable`](crate::protocol::traits::Packable) traits.
7776
///
7877
/// ## Implementation Details
7978
///
@@ -130,7 +129,7 @@ impl<T> PublicImmutable<T, PublicContext> {
130129
/// #[external("public")]
131130
/// #[initializer]
132131
/// fn initialize(decimals: u8) {
133-
/// self.storage.decimals.iniitalize(decimals);
132+
/// self.storage.decimals.initialize(decimals);
134133
/// }
135134
/// ```
136135
///
@@ -139,7 +138,7 @@ impl<T> PublicImmutable<T, PublicContext> {
139138
/// // Can only be called once per account
140139
/// #[external("public")]
141140
/// fn set_account_type(account_type: AccountType) {
142-
/// self.storage.account_types.at(self.msg_sender()).iniitalize(account_type);
141+
/// self.storage.account_types.at(self.msg_sender()).initialize(account_type);
143142
/// }
144143
/// ```
145144
///
@@ -223,7 +222,7 @@ impl<T> PublicImmutable<T, PublicContext> {
223222
/// #[external("public")]
224223
/// fn set_account_type_if_not_set(account_type: AccountType) {
225224
/// if !self.storage.account_types.at(self.msg_sender()).is_initialized() {
226-
/// self.storage.account_types.at(self.msg_sender()).iniitalize(account_type);
225+
/// self.storage.account_types.at(self.msg_sender()).initialize(account_type);
227226
/// }
228227
/// }
229228
/// ```
@@ -301,7 +300,7 @@ impl<T> PublicImmutable<T, &mut PrivateContext> {
301300
/// #[storage]
302301
/// struct Storage<Context> {
303302
/// decimals: PublicImmutable<u8, Context>,
304-
/// symbol: PubicImmutable<FieldCompressedString, Context>,
303+
/// symbol: PublicImmutable<FieldCompressedString, Context>,
305304
/// }
306305
///
307306
/// // Good: both `decimals` and `symbol` are retrieved in a single historical public storage read

noir-projects/aztec-nr/aztec/src/state_vars/public_mutable.nr

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ use crate::state_vars::StateVariable;
3434
/// This is suitable for any kind of global state that needs to be accessible by everyone. For example, a token may
3535
/// have a public total supply, or a voting contract may have public vote tallies.
3636
///
37-
/// Note that contracts having public values does not necessarily mean the the actions that update these values must
37+
/// Note that contracts having public values does not necessarily mean the actions that update these values must
3838
/// themselves be wholly public. For example, the token could allow for private minting and burning, and casting a vote
3939
/// could be kept private: these private functions would enqueue a public function that writes to the `PublicMutable`.
4040
///
@@ -49,22 +49,23 @@ use crate::state_vars::StateVariable;
4949
///
5050
/// ## Examples
5151
///
52-
/// Declaring a `PublicMutable` in the the contract's [`storage`](crate::macros::storage::storage) struct requires
52+
/// Declaring a `PublicMutable` in the contract's [`storage`](crate::macros::storage::storage) struct requires
5353
/// specifying the type `T` that is stored in the variable:
5454
///
5555
/// ```noir
5656
/// #[storage]
57-
/// struct Storage<Context> {
58-
/// total_supply: PublicMutable<u128, Context>,
59-
/// public_balances: Map<AztecAddress, PublicMutable<u128, Context>, Context>,
57+
/// struct Storage<C> {
58+
/// total_supply: PublicMutable<u128, C>,
59+
/// public_balances: Map<AztecAddress, PublicMutable<u128, C>, C>,
6060
///
61-
/// vote_tallies: Map<ElectionId, PublicMutable<u128, Context>, Context>,
61+
/// vote_tallies: Map<ElectionId, PublicMutable<u128, C>, C>,
6262
/// }
6363
/// ```
6464
///
6565
/// ## Requirements
6666
///
67-
/// The type `T` stored in the `PublicMutable` must implement the `Packable` trait.
67+
/// The type `T` stored in the `PublicMutable` must implement the [`Packable`](crate::protocol::traits::Packable)
68+
/// trait.
6869
///
6970
/// ## Implementation Details
7071
///
@@ -161,7 +162,7 @@ impl<T> PublicMutable<T, PublicContext> {
161162
/// }
162163
/// ```
163164
///
164-
/// An [`only_self`](crate::macros::functions::only_self) helper that updates public state trigered by a private
165+
/// An [`only_self`](crate::macros::functions::only_self) helper that updates public state triggered by a private
165166
/// function:
166167
/// ```noir
167168
/// #[external("private")]
@@ -174,8 +175,8 @@ impl<T> PublicMutable<T, PublicContext> {
174175
/// #[external("public")]
175176
/// #[only_self]
176177
/// fn _tally_vote(election_id: ElectionId, votes: u128) {
177-
/// let current = self.storage.vote_tallies.read();
178-
/// self.storage.vote_tallies.write(current + votes);
178+
/// let current = self.storage.vote_tallies.at(election_id).read();
179+
/// self.storage.vote_tallies.at(election_id).write(current + votes);
179180
/// }
180181
/// ```
181182
///

noir-projects/aztec-nr/aztec/src/test/helpers/test_environment.nr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -550,14 +550,14 @@ impl TestEnvironment {
550550
/// ```noir
551551
/// let caller = env.create_light_account();
552552
/// let contract_addr = env.deploy("SampleContract").without_initializer();
553-
/// let return_value = env.simulate_utility(SampleContract::at(contract_addr).sample_utility_function());
553+
/// let return_value = env.execute_utility(SampleContract::at(contract_addr).sample_utility_function());
554554
/// ```
555-
pub unconstrained fn simulate_utility<let M: u32, let N: u32, T>(_self: Self, call: UtilityCall<M, N, T>) -> T
555+
pub unconstrained fn execute_utility<let M: u32, let N: u32, T>(_self: Self, call: UtilityCall<M, N, T>) -> T
556556
where
557557
T: Deserialize,
558558
{
559559
let serialized_return_values =
560-
txe_oracles::simulate_utility_function(call.target_contract, call.selector, call.args);
560+
txe_oracles::execute_utility_function(call.target_contract, call.selector, call.args);
561561

562562
T::deserialize(serialized_return_values)
563563
}

noir-projects/aztec-nr/aztec/src/test/helpers/txe_oracles.nr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ pub unconstrained fn public_call_new_flow<let M: u32, let N: u32>(
5555
public_call_new_flow_oracle(from, contract_address, calldata, is_static_call)
5656
}
5757

58-
pub unconstrained fn simulate_utility_function<let M: u32, let N: u32>(
58+
pub unconstrained fn execute_utility_function<let M: u32, let N: u32>(
5959
contract_address: AztecAddress,
6060
function_selector: FunctionSelector,
6161
args: [Field; M],
6262
) -> [Field; N] {
63-
simulate_utility_function_oracle(contract_address, function_selector, args)
63+
execute_utility_function_oracle(contract_address, function_selector, args)
6464
}
6565

6666
#[oracle(txeGetNextBlockNumber)]
@@ -145,8 +145,8 @@ unconstrained fn public_call_new_flow_oracle<let M: u32, let N: u32>(
145145
is_static_call: bool,
146146
) -> [Field; N] {}
147147

148-
#[oracle(txeSimulateUtilityFunction)]
149-
unconstrained fn simulate_utility_function_oracle<let M: u32, let N: u32>(
148+
#[oracle(txeExecuteUtilityFunction)]
149+
unconstrained fn execute_utility_function_oracle<let M: u32, let N: u32>(
150150
contract_address: AztecAddress,
151151
function_selector: FunctionSelector,
152152
args: [Field; M],

noir-projects/noir-contracts/Nargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ members = [
3232
"contracts/protocol/fee_juice_contract",
3333
"contracts/protocol/multi_call_entrypoint_contract",
3434
"contracts/protocol/public_checks_contract",
35-
"contracts/protocol_interface/auth_registry_interface",
3635
"contracts/protocol_interface/contract_instance_registry_interface",
3736
"contracts/protocol_interface/fee_juice_interface",
3837
"contracts/test/generic_proxy_contract",

0 commit comments

Comments
 (0)