Skip to content

Commit 67f6a41

Browse files
committed
feat: add fee funding constant
1 parent 624145c commit 67f6a41

File tree

10 files changed

+62
-41
lines changed

10 files changed

+62
-41
lines changed

l1-contracts/src/core/libraries/ConstantsGen.sol

+1
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ library Constants {
9898
uint256 internal constant GENESIS_ARCHIVE_ROOT =
9999
19007378675971183768036762391356802220352606103602592933942074152320327194720;
100100
uint256 internal constant FEE_JUICE_INITIAL_MINT = 20000000000000000000;
101+
uint256 internal constant FEE_FUNDING_FOR_TESTER_ACCOUNT = 100000000000000000000;
101102
uint256 internal constant PUBLIC_DISPATCH_SELECTOR = 3578010381;
102103
uint256 internal constant MAX_PACKED_PUBLIC_BYTECODE_SIZE_IN_FIELDS = 3000;
103104
uint256 internal constant MAX_PACKED_BYTECODE_SIZE_PER_PRIVATE_FUNCTION_IN_FIELDS = 3000;

noir-projects/noir-protocol-circuits/crates/types/src/constants.nr

+1
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ pub global GENESIS_ARCHIVE_ROOT: Field =
139139
// The following and the value in `deploy_l1_contracts` must match. We should not have the code both places, but
140140
// we are running into circular dependency issues. #3342
141141
global FEE_JUICE_INITIAL_MINT: Field = 20000000000000000000;
142+
global FEE_FUNDING_FOR_TESTER_ACCOUNT: Field = 100000000000000000000; // 100e18
142143
// Last 4 bytes of the Poseidon2 hash of 'public_dispatch(Field)'.
143144
pub global PUBLIC_DISPATCH_SELECTOR: Field = 0xd5441b0d;
144145

yarn-project/circuits.js/src/constants.gen.ts

+1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ export const BLOB_SIZE_IN_BYTES = 126976;
8484
export const AZTEC_MAX_EPOCH_DURATION = 32;
8585
export const GENESIS_ARCHIVE_ROOT = 19007378675971183768036762391356802220352606103602592933942074152320327194720n;
8686
export const FEE_JUICE_INITIAL_MINT = 20000000000000000000n;
87+
export const FEE_FUNDING_FOR_TESTER_ACCOUNT = 100000000000000000000n;
8788
export const PUBLIC_DISPATCH_SELECTOR = 3578010381;
8889
export const MAX_PACKED_PUBLIC_BYTECODE_SIZE_IN_FIELDS = 3000;
8990
export const MAX_PACKED_BYTECODE_SIZE_PER_PRIVATE_FUNCTION_IN_FIELDS = 3000;

yarn-project/cli/src/cmds/devnet/bootstrap_network.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { getSchnorrAccount } from '@aztec/accounts/schnorr';
22
import { BatchCall, type PXE, type Wallet, createCompatibleClient } from '@aztec/aztec.js';
33
import { L1FeeJuicePortalManager } from '@aztec/aztec.js';
4-
import { type AztecAddress, type EthAddress, Fq, Fr } from '@aztec/circuits.js';
4+
import { type AztecAddress, type EthAddress, FEE_FUNDING_FOR_TESTER_ACCOUNT, Fq, Fr } from '@aztec/circuits.js';
55
import {
66
type ContractArtifacts,
77
type L1Clients,
@@ -252,7 +252,7 @@ async function fundFPC(
252252
debugLog,
253253
);
254254

255-
const amount = 10n ** 21n;
255+
const amount = FEE_FUNDING_FOR_TESTER_ACCOUNT;
256256
const { claimAmount, claimSecret, messageLeafIndex } = await feeJuicePortal.bridgeTokensPublic(
257257
fpcAddress,
258258
amount,

yarn-project/end-to-end/src/benchmarks/bench_prover.test.ts

+20-12
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { getSchnorrAccount, getSchnorrWallet } from '@aztec/accounts/schnorr';
22
import { PublicFeePaymentMethod, TxStatus, sleep } from '@aztec/aztec.js';
33
import { type AccountWallet } from '@aztec/aztec.js/wallet';
44
import { BBCircuitVerifier } from '@aztec/bb-prover';
5-
import { CompleteAddress, Fq, Fr, GasSettings } from '@aztec/circuits.js';
5+
import { CompleteAddress, FEE_FUNDING_FOR_TESTER_ACCOUNT, Fq, Fr, GasSettings } from '@aztec/circuits.js';
66
import { FPCContract, FeeJuiceContract, TestContract, TokenContract } from '@aztec/noir-contracts.js';
77
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
88
import { type PXEService, type PXEServiceConfig, createPXEService } from '@aztec/pxe';
@@ -108,15 +108,24 @@ describe('benchmarks/proving', () => {
108108
});
109109

110110
const { claimSecret, messageLeafIndex } = await feeJuiceBridgeTestHarness.prepareTokensOnL1(
111-
1_000_000_000_000n,
111+
FEE_FUNDING_FOR_TESTER_ACCOUNT,
112112
initialFpContract.address,
113113
);
114114

115115
const from = initialSchnorrWallet.getAddress(); // we are setting from to initial schnorr wallet here because of TODO(#9887)
116116
await Promise.all([
117-
initialGasContract.methods.claim(initialFpContract.address, 1e12, claimSecret, messageLeafIndex).send().wait(),
118-
initialTokenContract.methods.mint_to_public(initialSchnorrWallet.getAddress(), 1e12).send().wait(),
119-
initialTokenContract.methods.mint_to_private(from, initialSchnorrWallet.getAddress(), 1e12).send().wait(),
117+
initialGasContract.methods
118+
.claim(initialFpContract.address, FEE_FUNDING_FOR_TESTER_ACCOUNT, claimSecret, messageLeafIndex)
119+
.send()
120+
.wait(),
121+
initialTokenContract.methods
122+
.mint_to_public(initialSchnorrWallet.getAddress(), FEE_FUNDING_FOR_TESTER_ACCOUNT)
123+
.send()
124+
.wait(),
125+
initialTokenContract.methods
126+
.mint_to_private(from, initialSchnorrWallet.getAddress(), FEE_FUNDING_FOR_TESTER_ACCOUNT)
127+
.send()
128+
.wait(),
120129
]);
121130
});
122131

@@ -190,17 +199,16 @@ describe('benchmarks/proving', () => {
190199
// (await getTestContractOnPXE(3)).methods.create_l2_to_l1_message_public(45, 46, EthAddress.random()),
191200
];
192201

202+
const wallet = await getWalletOnPxe(0);
203+
const gasSettings = GasSettings.default({ maxFeesPerGas: await wallet.getCurrentBaseFees() });
204+
193205
const feeFnCall0 = {
194-
gasSettings: GasSettings.default(),
195-
paymentMethod: new PublicFeePaymentMethod(
196-
initialTokenContract.address,
197-
initialFpContract.address,
198-
await getWalletOnPxe(0),
199-
),
206+
gasSettings,
207+
paymentMethod: new PublicFeePaymentMethod(initialTokenContract.address, initialFpContract.address, wallet),
200208
};
201209

202210
// const feeFnCall1 = {
203-
// gasSettings: GasSettings.default(),
211+
// gasSettings,
204212
// paymentMethod: new PrivateFeePaymentMethod(
205213
// initialTokenContract.address,
206214
// initialFpContract.address,

yarn-project/end-to-end/src/benchmarks/bench_tx_size_fees.test.ts

+11-8
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
PublicFeePaymentMethod,
88
TxStatus,
99
} from '@aztec/aztec.js';
10-
import { GasSettings } from '@aztec/circuits.js';
10+
import { FEE_FUNDING_FOR_TESTER_ACCOUNT, GasSettings } from '@aztec/circuits.js';
1111
import { FPCContract, FeeJuiceContract, TokenContract } from '@aztec/noir-contracts.js';
1212
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
1313

@@ -62,18 +62,21 @@ describe('benchmarks/tx_size_fees', () => {
6262
});
6363

6464
const { claimSecret: fpcSecret, messageLeafIndex: fpcLeafIndex } =
65-
await feeJuiceBridgeTestHarness.prepareTokensOnL1(100_000_000_000n, fpc.address);
65+
await feeJuiceBridgeTestHarness.prepareTokensOnL1(FEE_FUNDING_FOR_TESTER_ACCOUNT, fpc.address);
6666

6767
const { claimSecret: aliceSecret, messageLeafIndex: aliceLeafIndex } =
68-
await feeJuiceBridgeTestHarness.prepareTokensOnL1(100_000_000_000n, aliceWallet.getAddress());
68+
await feeJuiceBridgeTestHarness.prepareTokensOnL1(FEE_FUNDING_FOR_TESTER_ACCOUNT, aliceWallet.getAddress());
6969

7070
await Promise.all([
71-
feeJuice.methods.claim(fpc.address, 100e9, fpcSecret, fpcLeafIndex).send().wait(),
72-
feeJuice.methods.claim(aliceWallet.getAddress(), 100e9, aliceSecret, aliceLeafIndex).send().wait(),
71+
feeJuice.methods.claim(fpc.address, FEE_FUNDING_FOR_TESTER_ACCOUNT, fpcSecret, fpcLeafIndex).send().wait(),
72+
feeJuice.methods
73+
.claim(aliceWallet.getAddress(), FEE_FUNDING_FOR_TESTER_ACCOUNT, aliceSecret, aliceLeafIndex)
74+
.send()
75+
.wait(),
7376
]);
7477
const from = aliceWallet.getAddress(); // we are setting from to Alice here because of TODO(#9887)
75-
await token.methods.mint_to_private(from, aliceWallet.getAddress(), 100e9).send().wait();
76-
await token.methods.mint_to_public(aliceWallet.getAddress(), 100e9).send().wait();
78+
await token.methods.mint_to_private(from, aliceWallet.getAddress(), FEE_FUNDING_FOR_TESTER_ACCOUNT).send().wait();
79+
await token.methods.mint_to_public(aliceWallet.getAddress(), FEE_FUNDING_FOR_TESTER_ACCOUNT).send().wait();
7780
});
7881

7982
it.each<[string, () => FeePaymentMethod | undefined /*bigint*/]>([
@@ -106,7 +109,7 @@ describe('benchmarks/tx_size_fees', () => {
106109
'sends a tx with a fee with %s payment method',
107110
async (_name, createPaymentMethod /*expectedTransactionFee*/) => {
108111
const paymentMethod = createPaymentMethod();
109-
const gasSettings = GasSettings.default();
112+
const gasSettings = GasSettings.default({ maxFeesPerGas: await aliceWallet.getCurrentBaseFees() });
110113
const tx = await token.methods
111114
.transfer(bobAddress, 1n)
112115
.send({ fee: paymentMethod ? { gasSettings, paymentMethod } : undefined })

yarn-project/end-to-end/src/e2e_fees/account_init.test.ts

+16-8
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@ import {
1313
type Wallet,
1414
deriveKeys,
1515
} from '@aztec/aztec.js';
16-
import { type AztecAddress, type CompleteAddress, Fq, GasSettings } from '@aztec/circuits.js';
16+
import {
17+
type AztecAddress,
18+
type CompleteAddress,
19+
FEE_FUNDING_FOR_TESTER_ACCOUNT,
20+
Fq,
21+
GasSettings,
22+
} from '@aztec/circuits.js';
1723
import { type TokenContract as BananaCoin, type FPCContract, SchnorrAccountContract } from '@aztec/noir-contracts.js';
1824

1925
import { jest } from '@jest/globals';
@@ -87,9 +93,9 @@ describe('e2e_fees account_init', () => {
8793

8894
describe('account pays its own fee', () => {
8995
it('pays natively in the Fee Juice after Alice bridges funds', async () => {
90-
await t.mintAndBridgeFeeJuice(bobsAddress, t.INITIAL_GAS_BALANCE);
96+
await t.mintAndBridgeFeeJuice(bobsAddress, FEE_FUNDING_FOR_TESTER_ACCOUNT);
9197
const [bobsInitialGas] = await t.getGasBalanceFn(bobsAddress);
92-
expect(bobsInitialGas).toEqual(t.INITIAL_GAS_BALANCE);
98+
expect(bobsInitialGas).toEqual(FEE_FUNDING_FOR_TESTER_ACCOUNT);
9399

94100
const paymentMethod = new FeeJuicePaymentMethod(bobsAddress);
95101
const tx = await bobsAccountManager.deploy({ fee: { gasSettings, paymentMethod } }).wait();
@@ -99,16 +105,18 @@ describe('e2e_fees account_init', () => {
99105
});
100106

101107
it('pays natively in the Fee Juice by bridging funds themselves', async () => {
102-
const claim = await t.feeJuiceBridgeTestHarness.prepareTokensOnL1(t.INITIAL_GAS_BALANCE, bobsAddress);
108+
const claim = await t.feeJuiceBridgeTestHarness.prepareTokensOnL1(FEE_FUNDING_FOR_TESTER_ACCOUNT, bobsAddress);
103109
const paymentMethod = new FeeJuicePaymentMethodWithClaim(bobsAddress, claim);
104110
const tx = await bobsAccountManager.deploy({ fee: { gasSettings, paymentMethod } }).wait();
105111
expect(tx.transactionFee!).toBeGreaterThan(0n);
106-
await expect(t.getGasBalanceFn(bobsAddress)).resolves.toEqual([t.INITIAL_GAS_BALANCE - tx.transactionFee!]);
112+
await expect(t.getGasBalanceFn(bobsAddress)).resolves.toEqual([
113+
FEE_FUNDING_FOR_TESTER_ACCOUNT - tx.transactionFee!,
114+
]);
107115
});
108116

109117
it('pays privately through an FPC', async () => {
110118
// Alice mints bananas to Bob
111-
const mintedBananas = t.INITIAL_GAS_BALANCE;
119+
const mintedBananas = FEE_FUNDING_FOR_TESTER_ACCOUNT;
112120
await t.mintPrivateBananas(mintedBananas, bobsAddress);
113121

114122
// Bob deploys his account through the private FPC
@@ -136,7 +144,7 @@ describe('e2e_fees account_init', () => {
136144
});
137145

138146
it('pays publicly through an FPC', async () => {
139-
const mintedBananas = t.INITIAL_GAS_BALANCE;
147+
const mintedBananas = FEE_FUNDING_FOR_TESTER_ACCOUNT;
140148
await bananaCoin.methods.mint_to_public(bobsAddress, mintedBananas).send().wait();
141149

142150
const paymentMethod = new PublicFeePaymentMethod(bananaCoin.address, bananaFPC.address, bobsWallet);
@@ -164,7 +172,7 @@ describe('e2e_fees account_init', () => {
164172
describe('another account pays the fee', () => {
165173
it('pays natively in the Fee Juice', async () => {
166174
// mint Fee Juice to alice
167-
await t.mintAndBridgeFeeJuice(aliceAddress, t.INITIAL_GAS_BALANCE);
175+
await t.mintAndBridgeFeeJuice(aliceAddress, FEE_FUNDING_FOR_TESTER_ACCOUNT);
168176
const [alicesInitialGas] = await t.getGasBalanceFn(aliceAddress);
169177

170178
// bob generates the private keys for his account on his own

yarn-project/end-to-end/src/e2e_fees/dapp_subscription.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
PublicFeePaymentMethod,
99
SentTx,
1010
} from '@aztec/aztec.js';
11-
import { GasSettings } from '@aztec/circuits.js';
11+
import { FEE_FUNDING_FOR_TESTER_ACCOUNT, GasSettings } from '@aztec/circuits.js';
1212
import { DefaultDappEntrypoint } from '@aztec/entrypoints/dapp';
1313
import {
1414
type AppSubscriptionContract,
@@ -75,7 +75,7 @@ describe('e2e_fees dapp_subscription', () => {
7575
await expectMapping(
7676
t.getGasBalanceFn,
7777
[aliceAddress, sequencerAddress, subscriptionContract.address, bananaFPC.address],
78-
[0n, 0n, t.INITIAL_GAS_BALANCE, t.INITIAL_GAS_BALANCE],
78+
[0n, 0n, FEE_FUNDING_FOR_TESTER_ACCOUNT, FEE_FUNDING_FOR_TESTER_ACCOUNT],
7979
);
8080

8181
await expectMapping(

yarn-project/end-to-end/src/e2e_fees/fee_juice_payments.test.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
FeeJuicePaymentMethod,
55
FeeJuicePaymentMethodWithClaim,
66
} from '@aztec/aztec.js';
7-
import { type GasSettings } from '@aztec/circuits.js';
7+
import { FEE_FUNDING_FOR_TESTER_ACCOUNT, type GasSettings } from '@aztec/circuits.js';
88
import { type TokenContract as BananaCoin, type FeeJuiceContract } from '@aztec/noir-contracts.js';
99

1010
import { FeesTest } from './fees_test.js';
@@ -50,7 +50,7 @@ describe('e2e_fees Fee Juice payments', () => {
5050
});
5151

5252
it('claims bridged funds and pays with them on the same tx', async () => {
53-
const claim = await t.feeJuiceBridgeTestHarness.prepareTokensOnL1(t.INITIAL_GAS_BALANCE, aliceAddress);
53+
const claim = await t.feeJuiceBridgeTestHarness.prepareTokensOnL1(FEE_FUNDING_FOR_TESTER_ACCOUNT, aliceAddress);
5454
const paymentMethod = new FeeJuicePaymentMethodWithClaim(aliceAddress, claim);
5555
const receipt = await bananaCoin.methods
5656
.transfer_in_public(aliceAddress, bobAddress, 1n, 0n)
@@ -59,8 +59,8 @@ describe('e2e_fees Fee Juice payments', () => {
5959
const endBalance = await feeJuiceContract.methods.balance_of_public(aliceAddress).simulate();
6060

6161
expect(endBalance).toBeGreaterThan(0n);
62-
expect(endBalance).toBeLessThan(t.INITIAL_GAS_BALANCE);
63-
expect(endBalance).toEqual(t.INITIAL_GAS_BALANCE - receipt.transactionFee!);
62+
expect(endBalance).toBeLessThan(FEE_FUNDING_FOR_TESTER_ACCOUNT);
63+
expect(endBalance).toEqual(FEE_FUNDING_FOR_TESTER_ACCOUNT - receipt.transactionFee!);
6464
});
6565
});
6666

yarn-project/end-to-end/src/e2e_fees/fees_test.ts

+4-5
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
sleep,
1111
} from '@aztec/aztec.js';
1212
import { DefaultMultiCallEntrypoint } from '@aztec/aztec.js/entrypoint';
13-
import { EthAddress, GasSettings, computePartialAddress } from '@aztec/circuits.js';
13+
import { EthAddress, FEE_FUNDING_FOR_TESTER_ACCOUNT, GasSettings, computePartialAddress } from '@aztec/circuits.js';
1414
import { createL1Clients } from '@aztec/ethereum';
1515
import { TestERC20Abi } from '@aztec/l1-artifacts';
1616
import {
@@ -79,7 +79,6 @@ export class FeesTest {
7979
public getBananaPublicBalanceFn!: BalancesFn;
8080
public getBananaPrivateBalanceFn!: BalancesFn;
8181

82-
public readonly INITIAL_GAS_BALANCE = BigInt(1e22);
8382
public readonly ALICE_INITIAL_BANANAS = BigInt(1e22);
8483
public readonly SUBSCRIPTION_AMOUNT = BigInt(1e19);
8584
public readonly APP_SPONSORED_TX_GAS_LIMIT = BigInt(10e9);
@@ -232,7 +231,7 @@ export class FeesTest {
232231

233232
this.logger.info(`BananaPay deployed at ${bananaFPC.address}`);
234233

235-
await this.feeJuiceBridgeTestHarness.bridgeFromL1ToL2(this.INITIAL_GAS_BALANCE, bananaFPC.address);
234+
await this.feeJuiceBridgeTestHarness.bridgeFromL1ToL2(FEE_FUNDING_FOR_TESTER_ACCOUNT, bananaFPC.address);
236235

237236
return {
238237
bananaFPCAddress: bananaFPC.address,
@@ -290,7 +289,7 @@ export class FeesTest {
290289
await this.snapshotManager.snapshot(
291290
'fund_alice_with_fee_juice',
292291
async () => {
293-
await this.mintAndBridgeFeeJuice(this.aliceAddress, this.INITIAL_GAS_BALANCE);
292+
await this.mintAndBridgeFeeJuice(this.aliceAddress, FEE_FUNDING_FOR_TESTER_ACCOUNT);
294293
},
295294
() => Promise.resolve(),
296295
);
@@ -320,7 +319,7 @@ export class FeesTest {
320319

321320
// Mint some Fee Juice to the subscription contract
322321
// Could also use bridgeFromL1ToL2 from the harness, but this is more direct
323-
await this.mintAndBridgeFeeJuice(subscriptionContract.address, this.INITIAL_GAS_BALANCE);
322+
await this.mintAndBridgeFeeJuice(subscriptionContract.address, FEE_FUNDING_FOR_TESTER_ACCOUNT);
324323
return {
325324
counterContractAddress: counterContract.address,
326325
subscriptionContractAddress: subscriptionContract.address,

0 commit comments

Comments
 (0)