Skip to content

Commit 8a8acdf

Browse files
author
AztecBot
committed
Merge branch 'next' into merge-train/barretenberg
2 parents b5f7017 + dddbaab commit 8a8acdf

File tree

53 files changed

+572
-443
lines changed

Some content is hidden

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

53 files changed

+572
-443
lines changed
Binary file not shown.

boxes/boxes/vanilla/app/embedded-wallet.ts

Lines changed: 20 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,19 @@ import { Fr } from '@aztec/aztec.js/fields';
88
import { createLogger } from '@aztec/aztec.js/log';
99
import { DeployAccountOptions } from '@aztec/aztec.js/wallet';
1010
import type { AztecNode } from '@aztec/aztec.js/node';
11-
import { type FeeOptions } from '@aztec/wallet-sdk/base-wallet';
11+
import {
12+
type CompleteFeeOptionsConfig,
13+
type FeeOptions,
14+
} from '@aztec/wallet-sdk/base-wallet';
1215
import { SPONSORED_FPC_SALT } from '@aztec/constants';
13-
import type { FieldsOf } from '@aztec/foundation/types';
1416
import { randomBytes } from '@aztec/foundation/crypto/random';
1517
import { getInitialTestAccountsData } from '@aztec/accounts/testing/lazy';
16-
import { GasSettings } from '@aztec/stdlib/gas';
1718
import { AccountFeePaymentMethodOptions } from '@aztec/entrypoints/account';
1819
import {
1920
EmbeddedWallet as EmbeddedWalletBase,
2021
type EmbeddedWalletOptions,
2122
} from '@aztec/wallets/embedded';
22-
import { NO_FROM, NoFrom } from '@aztec/aztec.js/account';
23+
import { NO_FROM } from '@aztec/aztec.js/account';
2324

2425
const logger = createLogger('wallet');
2526
const LocalStorageKey = 'aztec-account';
@@ -38,49 +39,26 @@ export class EmbeddedWallet extends EmbeddedWalletBase {
3839
/**
3940
* Completes partial user-provided fee options with wallet defaults.
4041
* This wallet will use the sponsoredFPC payment method unless otherwise stated.
41-
* @param from - The address where the transaction is being sent from
42-
* @param feePayer - The address paying for fees (if any fee payment method is embedded in the execution payload)
43-
* @param gasSettings - User-provided partial gas settings
44-
* @returns - Complete fee options that can be used to create a transaction execution request
4542
*/
4643
override async completeFeeOptions(
47-
from: AztecAddress | NoFrom,
48-
feePayer?: AztecAddress,
49-
gasSettings?: Partial<FieldsOf<GasSettings>>
44+
config: CompleteFeeOptionsConfig
5045
): Promise<FeeOptions> {
51-
const maxFeesPerGas =
52-
gasSettings?.maxFeesPerGas ??
53-
(await this.aztecNode.getCurrentMinFees()).mul(1 + this.minFeePadding);
54-
let accountFeePaymentMethodOptions;
55-
let walletFeePaymentMethod;
56-
// If from is an address, we need to determine the appropriate fee payment method options for the
57-
// account contract entrypoint to use
58-
if (from !== NO_FROM) {
59-
// The transaction does not include a fee payment method, so we
60-
// use the sponsoredFPC
61-
if (!feePayer) {
62-
accountFeePaymentMethodOptions =
63-
AccountFeePaymentMethodOptions.EXTERNAL;
64-
const sponsoredFPCAddress = await this.#getSponsoredFPCAddress();
65-
66-
walletFeePaymentMethod = new SponsoredFeePaymentMethod(
67-
sponsoredFPCAddress
68-
);
69-
} else {
70-
// The transaction includes fee payment method, so we check if we are the fee payer for it
71-
// (this can only happen if the embedded payment method is FeeJuiceWithClaim)
72-
accountFeePaymentMethodOptions = from.equals(feePayer)
73-
? AccountFeePaymentMethodOptions.FEE_JUICE_WITH_CLAIM
74-
: AccountFeePaymentMethodOptions.EXTERNAL;
75-
}
46+
const { from, feePayer } = config;
47+
// Delegate to base for gas settings, then override with sponsored FPC if needed
48+
const baseFeeOptions = await super.completeFeeOptions(config);
49+
let { accountFeePaymentMethodOptions, walletFeePaymentMethod } =
50+
baseFeeOptions;
51+
// If from is and address and the transaction does not include a fee payment
52+
// method, we use the sponsoredFPC
53+
if (from !== NO_FROM && !feePayer) {
54+
accountFeePaymentMethodOptions = AccountFeePaymentMethodOptions.EXTERNAL;
55+
const sponsoredFPCAddress = await this.#getSponsoredFPCAddress();
56+
walletFeePaymentMethod = new SponsoredFeePaymentMethod(
57+
sponsoredFPCAddress
58+
);
7659
}
77-
const fullGasSettings: GasSettings = GasSettings.default({
78-
...gasSettings,
79-
maxFeesPerGas,
80-
});
81-
this.log.debug(`Using L2 gas settings`, fullGasSettings);
8260
return {
83-
gasSettings: fullGasSettings,
61+
...baseFeeOptions,
8462
walletFeePaymentMethod,
8563
accountFeePaymentMethodOptions,
8664
};

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

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

1010
## TBD
1111

12+
### [Aztec.js] `GasSettings.default()` renamed to `GasSettings.fallback()`
13+
14+
`GasSettings.default()` has been renamed to `GasSettings.fallback()` to clarify that these gas limits are not protocol defaults — the protocol has no concept of "default" gas settings. `fallback()` is a convenience for cases where gas estimation is not being used, but callers should prefer estimating gas via simulation for accurate limits.
15+
16+
The old `DEFAULT_GAS_LIMIT` and `DEFAULT_TEARDOWN_GAS_LIMIT` constants have been removed. Gas limits are now derived from protocol-level maximums (`MAX_PROCESSABLE_L2_GAS`, `MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT`) rather than arbitrary fixed values.
17+
18+
A new `GasSettings.forEstimation()` method provides intentionally high gas limits for use during simulation. These limits exceed protocol maximums so the simulation doesn't hit gas caps — you must pass `skipTxValidation: true` when simulating with them, then use the results to set accurate gas limits on the actual transaction. `EmbeddedWallet` does this by default.
19+
20+
**Migration:**
21+
22+
```diff
23+
- import { DEFAULT_GAS_LIMIT, DEFAULT_TEARDOWN_GAS_LIMIT } from '@aztec/constants';
24+
- const settings = GasSettings.default({ maxFeesPerGas });
25+
+ const settings = GasSettings.fallback({ maxFeesPerGas });
26+
```
27+
28+
**Impact**: Any code referencing `GasSettings.default()`, `DEFAULT_GAS_LIMIT`, or `DEFAULT_TEARDOWN_GAS_LIMIT` will fail to compile.
29+
1230
### [PXE] `simulateTx`, `executeUtility`, `profileTx`, and `proveTx` no longer accept `scopes: 'ALL_SCOPES'`
1331

1432
The `AccessScopes` type (`'ALL_SCOPES' | AztecAddress[]`) has been removed. The `scopes` field in `SimulateTxOpts`,
@@ -162,6 +180,7 @@ The `CustomMessageHandler` function type now receives an additional `scope: Azte
162180
```
163181

164182
**Impact**: Contracts that implement a custom message handler must update the function signature.
183+
165184
### [aztec.js] `DeployMethod.send()` always returns `{ contract, receipt, instance }`
166185

167186
The `returnReceipt` option in deploy wait options has been removed. `DeployMethod.send()` now always returns an object with `contract`, `receipt`, and `instance` at the top level, provided the user waits for the transaction to be included.

noir-projects/aztec-nr/aztec/src/authwit/authorization_selector.nr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::protocol::{hash::poseidon2_hash_bytes, traits::{Deserialize, Empty, F
22

33
#[derive(Eq, Serialize, Deserialize)]
44
pub struct AuthorizationSelector {
5-
// 1st 4-bytes (big-endian leftmost) of abi-encoding of an event.
5+
// Low 32 bits of the poseidon2 hash of the function signature.
66
inner: u32,
77
}
88

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
use crate::protocol::{abis::function_selector::FunctionSelector, address::AztecAddress, traits::{Serialize, ToField}};
1+
use crate::protocol::{abis::function_selector::FunctionSelector, address::AztecAddress, traits::Serialize};
22
use std::meta::derive;
33

4-
// 3 * 32 + 3
5-
global FUNCTION_CALL_SIZE_IN_BYTES: u32 = 99;
6-
74
// @dev: If you change the following struct you have to update:
85
// - account_entrypoint.ts (specifically `getEntrypointAbi()`)
96
// - default_multi_call_entrypoint.ts (specifically `getEntrypointAbi()`)
@@ -21,25 +18,3 @@ pub struct FunctionCall {
2118
pub hide_msg_sender: bool,
2219
pub is_static: bool,
2320
}
24-
25-
impl FunctionCall {
26-
pub fn to_be_bytes(self) -> [u8; FUNCTION_CALL_SIZE_IN_BYTES] {
27-
let mut bytes: [u8; FUNCTION_CALL_SIZE_IN_BYTES] = [0; FUNCTION_CALL_SIZE_IN_BYTES];
28-
let args_hash_bytes: [u8; 32] = self.args_hash.to_be_bytes();
29-
for i in 0..32 {
30-
bytes[i] = args_hash_bytes[i];
31-
}
32-
let function_selector_bytes: [u8; 32] = self.function_selector.to_field().to_be_bytes();
33-
for i in 0..32 {
34-
bytes[i + 32] = function_selector_bytes[i];
35-
}
36-
let target_address_bytes: [u8; 32] = self.target_address.to_field().to_be_bytes();
37-
for i in 0..32 {
38-
bytes[i + 64] = target_address_bytes[i];
39-
}
40-
bytes[96] = self.is_public as u8;
41-
bytes[97] = self.hide_msg_sender as u8;
42-
bytes[98] = self.is_static as u8;
43-
bytes
44-
}
45-
}

noir-projects/aztec-nr/aztec/src/context/globals/mod.nr

Lines changed: 0 additions & 1 deletion
This file was deleted.

noir-projects/aztec-nr/aztec/src/context/globals/public_global_variables.nr

Lines changed: 0 additions & 2 deletions
This file was deleted.

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
//! Private, public and utility execution contexts.
22

3-
pub mod globals;
43
pub mod inputs;
54

65
mod returns_hash;

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ use crate::protocol::{
3939
MAX_PRIVATE_CALL_STACK_LENGTH_PER_CALL, MAX_PRIVATE_LOGS_PER_CALL, MAX_TX_LIFETIME,
4040
NULL_MSG_SENDER_CONTRACT_ADDRESS, PRIVATE_LOG_CIPHERTEXT_LEN,
4141
},
42-
hash::poseidon2_hash,
42+
hash::compute_contract_class_log_hash,
4343
messaging::l2_to_l1_message::L2ToL1Message,
4444
side_effect::{Counted, scoped::Scoped},
4545
traits::{Empty, Hash, ToField},
@@ -942,6 +942,13 @@ impl PrivateContext {
942942
self.private_logs.push(private_log.count(counter));
943943
}
944944

945+
/// Emits large data blobs.
946+
///
947+
/// This reuses the Contract Class Log channel to emit blobs of up to [`CONTRACT_CLASS_LOG_SIZE_IN_FIELDS`].
948+
///
949+
/// ## Privacy
950+
///
951+
/// The address of the contract emitting these blobs is revelead.
945952
pub fn emit_contract_class_log<let N: u32>(&mut self, log: [Field; N]) {
946953
let contract_address = self.this_address();
947954
let counter = self.next_counter();
@@ -953,10 +960,10 @@ impl PrivateContext {
953960
// Safety: The below length is constrained in the base rollup, which will make sure that all the fields beyond
954961
// length are zero. However, it won't be able to check that we didn't add extra padding (trailing zeroes) or
955962
// that we cut trailing zeroes from the end.
956-
let length = unsafe { trimmed_array_length_hint(log_to_emit) };
963+
let length = unsafe { trimmed_array_length_hint(log) };
957964
// We hash the entire padded log to ensure a user cannot pass a shorter length and so emit incorrect shorter
958965
// bytecode.
959-
let log_hash = poseidon2_hash(log_to_emit);
966+
let log_hash = compute_contract_class_log_hash(log_to_emit);
960967
// Safety: the below only exists to broadcast the raw log, so we can provide it to the base rollup later to be
961968
// constrained.
962969
unsafe {

noir-projects/aztec-nr/aztec/src/event/event_selector.nr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::protocol::{hash::poseidon2_hash_bytes, traits::{Deserialize, Empty, F
22

33
#[derive(Deserialize, Eq, Serialize)]
44
pub struct EventSelector {
5-
// 1st 4-bytes (big-endian leftmost) of abi-encoding of an event.
5+
// Low 32 bits of the poseidon2 hash of the event signature.
66
inner: u32,
77
}
88

0 commit comments

Comments
 (0)