Skip to content
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
15 changes: 8 additions & 7 deletions yarn-project/aztec-node/src/aztec-node/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -330,13 +330,21 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
log.info('Starting in prover-only mode: skipping validator, sequencer, sentinel, and slasher subsystems');
}

const globalVariableBuilder = new GlobalVariableBuilder({
...config,
rollupVersion: BigInt(config.rollupVersion),
l1GenesisTime,
slotDuration: Number(slotDuration),
});

// create the tx pool and the p2p client, which will need the l2 block source
const p2pClient = await createP2PClient(
config,
archiver,
proofVerifier,
worldStateSynchronizer,
epochCache,
globalVariableBuilder,
packageVersion,
dateProvider,
telemetry,
Expand Down Expand Up @@ -550,13 +558,6 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
}
}

const globalVariableBuilder = new GlobalVariableBuilder({
...config,
rollupVersion: BigInt(config.rollupVersion),
l1GenesisTime,
slotDuration: Number(slotDuration),
});

const node = new AztecNodeService(
config,
p2pClient,
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/cli-wallet/src/utils/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const MIN_FEE_PADDING = 0.5;
export const MIN_FEE_PADDING = 10;

export const AccountTypes = ['schnorr', 'ecdsasecp256r1', 'ecdsasecp256r1ssh', 'ecdsasecp256k1'] as const;
export type AccountType = (typeof AccountTypes)[number];
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
import { GasSettings } from '@aztec/stdlib/gas';
import { deriveSigningKey } from '@aztec/stdlib/keys';

import { MNEMONIC } from '../../fixtures/fixtures.js';
import { E2E_DEFAULT_MIN_FEE_PADDING, MNEMONIC } from '../../fixtures/fixtures.js';
import { type EndToEndContext, type SetupOptions, deployAccounts, setup, teardown } from '../../fixtures/setup.js';
import { mintTokensToPrivate } from '../../fixtures/token_utils.js';
import { setupSponsoredFPC } from '../../fixtures/utils.js';
Expand Down Expand Up @@ -377,7 +377,7 @@ export class ClientFlowsBenchmark {
public async getPrivateFPCPaymentMethodForWallet(wallet: Wallet, sender: AztecAddress) {
// The private fee paying method assembled on the app side requires knowledge of the maximum
// fee the user is willing to pay
const maxFeesPerGas = (await this.aztecNode.getCurrentMinFees()).mul(1.5);
const maxFeesPerGas = (await this.aztecNode.getCurrentMinFees()).mul(E2E_DEFAULT_MIN_FEE_PADDING);
const gasSettings = GasSettings.default({ maxFeesPerGas });
return new PrivateFeePaymentMethod(this.bananaFPC.address, sender, wallet, gasSettings);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { registerInitialLocalNetworkAccountsInWallet } from '@aztec/wallets/test

import { format } from 'util';

import { E2E_DEFAULT_MIN_FEE_PADDING } from '../fixtures/fixtures.js';
import { deployToken, mintTokensToPrivate } from '../fixtures/token_utils.js';
import { TestWallet } from '../test-wallet/test_wallet.js';

Expand Down Expand Up @@ -185,7 +186,7 @@ describe('e2e_local_network_example', () => {
// docs:start:private_fpc_payment
// The private fee paying method assembled on the app side requires knowledge of the maximum
// fee the user is willing to pay
const maxFeesPerGas = (await node.getCurrentMinFees()).mul(1.5);
const maxFeesPerGas = (await node.getCurrentMinFees()).mul(E2E_DEFAULT_MIN_FEE_PADDING);
const gasSettings = GasSettings.default({ maxFeesPerGas });
const paymentMethod = new PrivateFeePaymentMethod(bananaFPCAddress, alice, wallet, gasSettings);
const { receipt: receiptForAlice } = await bananaCoin.methods
Expand Down
7 changes: 4 additions & 3 deletions yarn-project/end-to-end/src/e2e_fees/account_init.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { GasSettings } from '@aztec/stdlib/gas';

import { jest } from '@jest/globals';

import { E2E_DEFAULT_MIN_FEE_PADDING } from '../fixtures/fixtures.js';
import type { TestWallet } from '../test-wallet/test_wallet.js';
import { FeesTest } from './fees_test.js';

Expand Down Expand Up @@ -115,7 +116,7 @@ describe('e2e_fees account_init', () => {
// Bob deploys his account through the private FPC
// The private fee paying method assembled on the app side requires knowledge of the maximum
// fee the user is willing to pay
const maxFeesPerGas = (await aztecNode.getCurrentMinFees()).mul(1.5);
const maxFeesPerGas = (await aztecNode.getCurrentMinFees()).mul(E2E_DEFAULT_MIN_FEE_PADDING);
const gasSettings = GasSettings.default({ maxFeesPerGas });
const paymentMethod = new PrivateFeePaymentMethod(bananaFPC.address, bobsAddress, wallet, gasSettings);
const { receipt: tx } = await bobsDeployMethod.send({
Expand Down Expand Up @@ -144,7 +145,7 @@ describe('e2e_fees account_init', () => {

// The public fee paying method assembled on the app side requires knowledge of the maximum
// fee the user is willing to pay
const maxFeesPerGas = (await aztecNode.getCurrentMinFees()).mul(1.5);
const maxFeesPerGas = (await aztecNode.getCurrentMinFees()).mul(E2E_DEFAULT_MIN_FEE_PADDING);
const gasSettings = GasSettings.default({ maxFeesPerGas });
const paymentMethod = new PublicFeePaymentMethod(bananaFPC.address, bobsAddress, wallet, gasSettings);
const { receipt: tx } = await bobsDeployMethod.send({
Expand Down Expand Up @@ -203,7 +204,7 @@ describe('e2e_fees account_init', () => {
expect(aliceBalanceAfter).toBe(aliceBalanceBefore - tx.transactionFee!);

// bob can now use his wallet for sending txs
const maxFeesPerGas = (await aztecNode.getCurrentMinFees()).mul(1.5);
const maxFeesPerGas = (await aztecNode.getCurrentMinFees()).mul(E2E_DEFAULT_MIN_FEE_PADDING);
const gasSettings = GasSettings.default({ maxFeesPerGas });
const bobPaymentMethod = new PrivateFeePaymentMethod(bananaFPC.address, bobsAddress, wallet, gasSettings);
await bananaCoin.methods
Expand Down
6 changes: 4 additions & 2 deletions yarn-project/end-to-end/src/e2e_fees/fees_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';

import { getContract } from 'viem';

import { MNEMONIC } from '../fixtures/fixtures.js';
import { E2E_DEFAULT_MIN_FEE_PADDING, MNEMONIC } from '../fixtures/fixtures.js';
import {
type EndToEndContext,
type SetupOptions,
Expand Down Expand Up @@ -193,7 +193,9 @@ export class FeesTest {
this.wallet = this.context.wallet;
this.aztecNode = this.context.aztecNodeService;
this.aztecNodeAdmin = this.context.aztecNodeService;
this.gasSettings = GasSettings.default({ maxFeesPerGas: (await this.aztecNode.getCurrentMinFees()).mul(2) });
this.gasSettings = GasSettings.default({
maxFeesPerGas: (await this.aztecNode.getCurrentMinFees()).mul(E2E_DEFAULT_MIN_FEE_PADDING),
});
this.cheatCodes = this.context.cheatCodes;
this.accounts = deployedAccounts.map(a => a.address);
this.accounts.forEach((a, i) => this.logger.verbose(`Account ${i} address: ${a}`));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,13 @@ describe('e2e_p2p_network', () => {
// blocks without them (since targetCommitteeSize is set to the number of nodes)
await t.setupAccount();

// Wait for the next L1 block so that all nodes' getCurrentMinFees() caches are
// refreshed after the first L2 checkpoint is published. Without this, some wallets
// may estimate fees based on pre-checkpoint values (very low due to fee decay),
// while receiving nodes already see the post-checkpoint fees (much higher).
const ethereumSlotDuration = t.ctx.aztecNodeConfig.ethereumSlotDuration ?? 4;
await sleep((ethereumSlotDuration + 1) * 1000);

t.logger.info('Submitting transactions');
for (const node of nodes) {
const txs = await submitTransactions(t.logger, node, NUM_TXS_PER_NODE, t.fundedAccount);
Expand Down
1 change: 0 additions & 1 deletion yarn-project/end-to-end/src/e2e_p2p/p2p_network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ export class P2PNetworkTest {
metricsPort: metricsPort,
numberOfInitialFundedAccounts: 2,
startProverNode,
walletMinFeePadding: 2.0,
};

this.deployL1ContractsArgs = {
Expand Down
3 changes: 3 additions & 0 deletions yarn-project/end-to-end/src/fixtures/fixtures.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
export const METRICS_PORT = 4318;

/** Default fee multiplier applied to getCurrentMinFees in e2e tests to cover fee decay between blocks. */
export const E2E_DEFAULT_MIN_FEE_PADDING = 15;

export const shouldCollectMetrics = () => {
if (process.env.COLLECT_METRICS) {
return METRICS_PORT;
Expand Down
2 changes: 1 addition & 1 deletion yarn-project/end-to-end/src/fixtures/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ export type SetupOptions = {
skipAccountDeployment?: boolean;
/** L1 contracts deployment arguments. */
l1ContractsArgs?: Partial<DeployAztecL1ContractsArgs>;
/** Wallet minimum fee padding multiplier (defaults to 0.5, which is 50% padding). */
/** Wallet minimum fee padding multiplier */
walletMinFeePadding?: number;
} & Partial<AztecNodeConfig>;

Expand Down
5 changes: 3 additions & 2 deletions yarn-project/end-to-end/src/spartan/block_capacity.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { jest } from '@jest/globals';
import { mkdir, writeFile } from 'fs/promises';
import { dirname } from 'path';

import { E2E_DEFAULT_MIN_FEE_PADDING } from '../fixtures/fixtures.js';
import { getSponsoredFPCAddress, registerSponsoredFPC } from '../fixtures/utils.js';
import type { WorkerWallet } from '../test-wallet/worker_wallet.js';
import { type WorkerWalletWrapper, createWorkerWalletClient } from './setup_test_wallets.js';
Expand Down Expand Up @@ -447,9 +448,9 @@ describe('block capacity benchmark', () => {
async function cloneTx(tx: Tx, aztecNode: AztecNode): Promise<Tx> {
const clonedTx = Tx.clone(tx, false);

// Fetch current minimum fees and apply 50% buffer for safety
// Fetch current minimum fees and apply 15x buffer to cover fee decay between blocks
const currentFees = await aztecNode.getCurrentMinFees();
const paddedFees = currentFees.mul(1.5);
const paddedFees = currentFees.mul(E2E_DEFAULT_MIN_FEE_PADDING);

// Update gas settings with current fees
(clonedTx.data.constants.txContext.gasSettings as any).maxFeesPerGas = paddedFees;
Expand Down
5 changes: 3 additions & 2 deletions yarn-project/end-to-end/src/spartan/n_tps_prove.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import type { ChildProcess } from 'child_process';
import { mkdir, writeFile } from 'fs/promises';
import { dirname } from 'path';

import { E2E_DEFAULT_MIN_FEE_PADDING } from '../fixtures/fixtures.js';
import { getSponsoredFPCAddress, registerSponsoredFPC } from '../fixtures/utils.js';
import { PrometheusClient } from '../quality_of_service/prometheus_client.js';
import type { WorkerWallet } from '../test-wallet/worker_wallet.js';
Expand Down Expand Up @@ -647,9 +648,9 @@ async function createTx(
async function cloneTx(tx: Tx, aztecNode: AztecNode): Promise<Tx> {
const clonedTx = Tx.clone(tx, false);

// Fetch current minimum fees and apply 50% buffer for safety
// Fetch current minimum fees and apply 15x buffer to cover fee decay between blocks
const currentFees = await aztecNode.getCurrentMinFees();
const paddedFees = currentFees.mul(1.5);
const paddedFees = currentFees.mul(E2E_DEFAULT_MIN_FEE_PADDING);

// Update gas settings with current fees
(clonedTx.data.constants.txContext.gasSettings as any).maxFeesPerGas = paddedFees;
Expand Down
5 changes: 4 additions & 1 deletion yarn-project/end-to-end/src/test-wallet/test_wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ export interface AccountData {
contract: AccountContract;
}

const TEST_DEFAULT_MIN_FEE_PADDING = 10;

/**
* Wallet implementation that stores accounts in memory and provides extra debugging
* utilities
Expand All @@ -50,6 +52,7 @@ export class TestWallet extends BaseWallet {
private readonly nodeRef: AztecNodeProxy,
) {
super(pxe, nodeRef);
this.minFeePadding = TEST_DEFAULT_MIN_FEE_PADDING;
}

static async create(
Expand Down Expand Up @@ -143,7 +146,7 @@ export class TestWallet extends BaseWallet {
}

setMinFeePadding(value?: number) {
this.minFeePadding = value ?? 0.5;
this.minFeePadding = value ?? TEST_DEFAULT_MIN_FEE_PADDING;
}

protected getAccountFromAddress(address: AztecAddress): Promise<Account> {
Expand Down
5 changes: 5 additions & 0 deletions yarn-project/p2p/src/client/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { AztecLMDBStoreV2, createStore } from '@aztec/kv-store/lmdb-v2';
import type { L2BlockSource } from '@aztec/stdlib/block';
import type { ChainConfig } from '@aztec/stdlib/config';
import type { ContractDataSource } from '@aztec/stdlib/contract';
import type { BlockMinFeesProvider } from '@aztec/stdlib/gas';
import type { AztecNode, ClientProtocolCircuitVerifier, WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
import type { DataStoreConfig } from '@aztec/stdlib/kv-store';
import { type TelemetryClient, getTelemetryClient } from '@aztec/telemetry-client';
Expand Down Expand Up @@ -47,6 +48,7 @@ export async function createP2PClient(
proofVerifier: ClientProtocolCircuitVerifier,
worldStateSynchronizer: WorldStateSynchronizer,
epochCache: EpochCacheInterface,
blockMinFeesProvider: BlockMinFeesProvider,
packageVersion: string,
dateProvider: DateProvider = new DateProvider(),
telemetry: TelemetryClient = getTelemetryClient(),
Expand Down Expand Up @@ -88,6 +90,7 @@ export async function createP2PClient(
const currentBlockNumber = await archiver.getBlockNumber();
const { ts: nextSlotTimestamp } = epochCache.getEpochAndSlotInNextL1Slot();
const l1Constants = await archiver.getL1Constants();
const gasFees = await blockMinFeesProvider.getCurrentMinFees();
return createTxValidatorForTransactionsEnteringPendingTxPool(
worldStateSynchronizer,
nextSlotTimestamp,
Expand All @@ -97,8 +100,10 @@ export async function createP2PClient(
maxBlockL2Gas: config.validateMaxL2BlockGas,
maxBlockDAGas: config.validateMaxDABlockGas,
},
gasFees,
);
},
blockMinFeesProvider,
},
telemetry,
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { DateProvider, Timer, executeTimeout } from '@aztec/foundation/timer';
import { openTmpStore } from '@aztec/kv-store/lmdb-v2';
import type { L2BlockSource } from '@aztec/stdlib/block';
import type { ContractDataSource } from '@aztec/stdlib/contract';
import { GasFees } from '@aztec/stdlib/gas';
import type { ClientProtocolCircuitVerifier } from '@aztec/stdlib/interfaces/server';
import type { DataStoreConfig } from '@aztec/stdlib/kv-store';
import { PeerErrorSeverity } from '@aztec/stdlib/p2p';
Expand Down Expand Up @@ -119,6 +120,7 @@ async function startClient(config: P2PConfig, clientIndex: number) {
proofVerifier as ClientProtocolCircuitVerifier,
worldState,
epochCache,
{ getCurrentMinFees: () => Promise.resolve(GasFees.empty()) },
'proposal-tx-collector-bench-worker',
new DateProvider(),
telemetry as TelemetryClient,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export { FeePayerBalancePreAddRule } from './fee_payer_balance_pre_add_rule.js';
export { LowPriorityPreAddRule } from './low_priority_pre_add_rule.js';

// Post-event eviction rules
export { InsufficientFeePerGasEvictionRule } from './insufficient_fee_per_gas_eviction_rule.js';
export { InvalidTxsAfterMiningRule } from './invalid_txs_after_mining_rule.js';
export { InvalidTxsAfterReorgRule } from './invalid_txs_after_reorg_rule.js';
export { FeePayerBalanceEvictionRule } from './fee_payer_balance_eviction_rule.js';
Expand Down
Loading
Loading