@aztec/end-to-end 0.82.2 → 0.82.3-nightly.20250403

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/dest/bench/client_flows/client_flows_benchmark.d.ts +66 -0
  2. package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -0
  3. package/dest/bench/client_flows/client_flows_benchmark.js +281 -0
  4. package/dest/bench/client_flows/config.d.ts +14 -0
  5. package/dest/bench/client_flows/config.d.ts.map +1 -0
  6. package/dest/bench/client_flows/config.js +85 -0
  7. package/dest/bench/client_flows/data_extractor.d.ts +23 -0
  8. package/dest/bench/client_flows/data_extractor.d.ts.map +1 -0
  9. package/dest/bench/client_flows/data_extractor.js +198 -0
  10. package/dest/bench/utils.d.ts +0 -12
  11. package/dest/bench/utils.d.ts.map +1 -1
  12. package/dest/bench/utils.js +2 -28
  13. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +0 -12
  14. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts.map +1 -1
  15. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.js +1 -13
  16. package/dest/e2e_fees/fees_test.d.ts.map +1 -1
  17. package/dest/e2e_fees/fees_test.js +3 -14
  18. package/dest/e2e_p2p/p2p_network.d.ts +5 -0
  19. package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
  20. package/dest/e2e_p2p/p2p_network.js +13 -4
  21. package/dest/e2e_p2p/shared.d.ts.map +1 -1
  22. package/dest/e2e_p2p/shared.js +1 -0
  23. package/dest/fixtures/l1_to_l2_messaging.d.ts +2 -2
  24. package/dest/fixtures/l1_to_l2_messaging.d.ts.map +1 -1
  25. package/dest/fixtures/l1_to_l2_messaging.js +2 -1
  26. package/dest/fixtures/setup_l1_contracts.d.ts.map +1 -1
  27. package/dest/fixtures/setup_l1_contracts.js +1 -2
  28. package/dest/fixtures/snapshot_manager.d.ts.map +1 -1
  29. package/dest/fixtures/snapshot_manager.js +7 -2
  30. package/dest/fixtures/token_utils.d.ts +2 -1
  31. package/dest/fixtures/token_utils.d.ts.map +1 -1
  32. package/dest/fixtures/token_utils.js +14 -1
  33. package/dest/fixtures/utils.d.ts +0 -4
  34. package/dest/fixtures/utils.d.ts.map +1 -1
  35. package/dest/fixtures/utils.js +216 -238
  36. package/dest/sample-dapp/contracts.js +4 -4
  37. package/dest/shared/capture_private_execution_steps.d.ts +2 -2
  38. package/dest/shared/capture_private_execution_steps.d.ts.map +1 -1
  39. package/dest/shared/capture_private_execution_steps.js +24 -6
  40. package/dest/shared/cross_chain_test_harness.d.ts +12 -1
  41. package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
  42. package/dest/shared/cross_chain_test_harness.js +14 -3
  43. package/dest/shared/uniswap_l1_l2.js +8 -6
  44. package/package.json +32 -32
  45. package/src/bench/client_flows/client_flows_benchmark.ts +395 -0
  46. package/src/bench/client_flows/config.ts +53 -0
  47. package/src/bench/client_flows/data_extractor.ts +217 -0
  48. package/src/bench/utils.ts +2 -30
  49. package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +1 -25
  50. package/src/e2e_fees/fees_test.ts +2 -15
  51. package/src/e2e_p2p/p2p_network.ts +10 -6
  52. package/src/e2e_p2p/shared.ts +1 -0
  53. package/src/fixtures/l1_to_l2_messaging.ts +12 -3
  54. package/src/fixtures/setup_l1_contracts.ts +1 -2
  55. package/src/fixtures/snapshot_manager.ts +7 -2
  56. package/src/fixtures/token_utils.ts +22 -2
  57. package/src/fixtures/utils.ts +235 -261
  58. package/src/sample-dapp/contracts.mjs +4 -4
  59. package/src/shared/capture_private_execution_steps.ts +43 -6
  60. package/src/shared/cross_chain_test_harness.ts +26 -2
  61. package/src/shared/uniswap_l1_l2.ts +8 -8
@@ -1,16 +1,12 @@
1
1
  import type { AztecNodeService } from '@aztec/aztec-node';
2
2
  import { type AztecNode, BatchCall, INITIAL_L2_BLOCK_NUM, type SentTx, type WaitOpts } from '@aztec/aztec.js';
3
3
  import { mean, stdDev, times } from '@aztec/foundation/collection';
4
- import { randomInt } from '@aztec/foundation/crypto';
5
4
  import { BenchmarkingContract } from '@aztec/noir-contracts.js/Benchmarking';
6
5
  import { type PXEService, type PXEServiceConfig, createPXEService } from '@aztec/pxe/server';
7
6
  import type { MetricsType } from '@aztec/telemetry-client';
8
7
  import type { BenchmarkDataPoint, BenchmarkMetricsType, BenchmarkTelemetryClient } from '@aztec/telemetry-client/bench';
9
8
 
10
9
  import { writeFileSync } from 'fs';
11
- import { mkdirpSync } from 'fs-extra';
12
- import { globSync } from 'glob';
13
- import { join } from 'path';
14
10
 
15
11
  import { type EndToEndContext, type SetupOptions, setup } from '../fixtures/utils.js';
16
12
 
@@ -94,30 +90,6 @@ function getMetricValues(points: BenchmarkDataPoint[]) {
94
90
  }
95
91
  }
96
92
 
97
- /**
98
- * Creates and returns a directory with the current job name and a random number.
99
- * @param index - Index to merge into the dir path.
100
- * @returns A path to a created dir.
101
- */
102
- export function makeDataDirectory(index: number) {
103
- const testName = expect.getState().currentTestName!.split(' ')[0].replaceAll('/', '_');
104
- const db = join('data', testName, index.toString(), `${randomInt(99)}`);
105
- mkdirpSync(db);
106
- return db;
107
- }
108
-
109
- /**
110
- * Returns the size in disk of a folder.
111
- * @param path - Path to the folder.
112
- * @returns Size in bytes.
113
- */
114
- export function getFolderSize(path: string): number {
115
- return globSync('**', { stat: true, cwd: path, nodir: true, withFileTypes: true }).reduce(
116
- (accum, file) => accum + (file as any as { /** Size */ size: number }).size,
117
- 0,
118
- );
119
- }
120
-
121
93
  /**
122
94
  * Returns a call to the benchmark contract. Each call has a private execution (account entrypoint),
123
95
  * a nested private call (create_note), a public call (increment_balance), and a nested public
@@ -188,7 +160,7 @@ export async function createNewPXE(
188
160
  startingBlock: number = INITIAL_L2_BLOCK_NUM,
189
161
  ): Promise<PXEService> {
190
162
  const l1Contracts = await node.getL1ContractAddresses();
191
- const { l1ChainId, protocolVersion } = await node.getNodeInfo();
163
+ const { l1ChainId, rollupVersion } = await node.getNodeInfo();
192
164
  const pxeConfig = {
193
165
  l2StartingBlock: startingBlock,
194
166
  l2BlockPollingIntervalMS: 100,
@@ -196,7 +168,7 @@ export async function createNewPXE(
196
168
  dataStoreMapSizeKB: 1024 * 1024,
197
169
  l1Contracts,
198
170
  l1ChainId,
199
- version: protocolVersion,
171
+ rollupVersion,
200
172
  } as PXEServiceConfig;
201
173
  const pxe = await createPXEService(node, pxeConfig);
202
174
  await pxe.registerContract(contract);
@@ -132,7 +132,7 @@ export class CrossChainMessagingTest {
132
132
 
133
133
  this.logger.verbose(`L2 token deployed to: ${this.crossChainTestHarness.l2Token.address}`);
134
134
 
135
- return this.toCrossChainContext();
135
+ return this.crossChainTestHarness.toCrossChainContext();
136
136
  },
137
137
  async crossChainContext => {
138
138
  this.l2Token = await TokenContract.at(crossChainContext.l2Token, this.user1Wallet);
@@ -177,28 +177,4 @@ export class CrossChainMessagingTest {
177
177
  },
178
178
  );
179
179
  }
180
-
181
- toCrossChainContext(): CrossChainContext {
182
- return {
183
- l2Token: this.crossChainTestHarness.l2Token.address,
184
- l2Bridge: this.crossChainTestHarness.l2Bridge.address,
185
- tokenPortal: this.crossChainTestHarness.tokenPortalAddress,
186
- underlying: this.crossChainTestHarness.underlyingERC20Address,
187
- ethAccount: this.crossChainTestHarness.ethAccount,
188
- ownerAddress: this.crossChainTestHarness.ownerAddress,
189
- inbox: this.crossChainTestHarness.l1ContractAddresses.inboxAddress,
190
- outbox: this.crossChainTestHarness.l1ContractAddresses.outboxAddress,
191
- };
192
- }
193
180
  }
194
-
195
- type CrossChainContext = {
196
- l2Token: AztecAddress;
197
- l2Bridge: AztecAddress;
198
- tokenPortal: EthAddress;
199
- underlying: EthAddress;
200
- ethAccount: EthAddress;
201
- ownerAddress: AztecAddress;
202
- inbox: EthAddress;
203
- outbox: EthAddress;
204
- };
@@ -39,7 +39,6 @@ import {
39
39
  type SetupOptions,
40
40
  ensureAccountsPubliclyDeployed,
41
41
  getBalancesFn,
42
- setupCanonicalFeeJuice,
43
42
  setupSponsoredFPC,
44
43
  } from '../fixtures/utils.js';
45
44
  import { FeeJuicePortalTestingHarnessFactory, type GasBridgingTestHarness } from '../shared/gas_portal_test_harness.js';
@@ -168,7 +167,7 @@ export class FeesTest {
168
167
  await this.snapshotManager.snapshot(
169
168
  'initial_accounts',
170
169
  deployAccounts(this.numberOfAccounts, this.logger),
171
- async ({ deployedAccounts }, { pxe, aztecNode, aztecNodeConfig, deployL1ContractsValues }) => {
170
+ async ({ deployedAccounts }, { pxe, aztecNode, aztecNodeConfig }) => {
172
171
  this.pxe = pxe;
173
172
 
174
173
  this.aztecNode = aztecNode;
@@ -185,16 +184,6 @@ export class FeesTest {
185
184
  const canonicalFeeJuice = await getCanonicalFeeJuice();
186
185
  this.feeJuiceContract = await FeeJuiceContract.at(canonicalFeeJuice.address, this.aliceWallet);
187
186
  this.coinbase = EthAddress.random();
188
-
189
- this.feeJuiceBridgeTestHarness = await FeeJuicePortalTestingHarnessFactory.create({
190
- aztecNode,
191
- aztecNodeAdmin: aztecNode,
192
- pxeService: pxe,
193
- publicClient: deployL1ContractsValues.publicClient,
194
- walletClient: deployL1ContractsValues.walletClient,
195
- wallet: this.aliceWallet,
196
- logger: this.logger,
197
- });
198
187
  },
199
188
  );
200
189
  }
@@ -208,9 +197,7 @@ export class FeesTest {
208
197
  async applySetupFeeJuiceSnapshot() {
209
198
  await this.snapshotManager.snapshot(
210
199
  'setup_fee_juice',
211
- async context => {
212
- await setupCanonicalFeeJuice(context.pxe);
213
- },
200
+ async () => {},
214
201
  async (_data, context) => {
215
202
  this.context = context;
216
203
 
@@ -29,7 +29,7 @@ import {
29
29
  createSnapshotManager,
30
30
  deployAccounts,
31
31
  } from '../fixtures/snapshot_manager.js';
32
- import { getPrivateKeyFromIndex } from '../fixtures/utils.js';
32
+ import { getPrivateKeyFromIndex, getSponsoredFPCAddress } from '../fixtures/utils.js';
33
33
  import { getEndToEndTestTelemetryClient } from '../fixtures/with_telemetry_utils.js';
34
34
 
35
35
  // Use a fixed bootstrap node private key so that we can re-use the same snapshot and the nodes can find each other
@@ -54,6 +54,7 @@ export class P2PNetworkTest {
54
54
  public attesterPublicKeys: string[] = [];
55
55
  public proposerPrivateKeys: `0x${string}`[] = [];
56
56
  public peerIdPrivateKeys: string[] = [];
57
+ public validators: { attester: `0x${string}`; proposer: `0x${string}`; withdrawer: `0x${string}` }[] = [];
57
58
 
58
59
  public deployedAccounts: InitialAccountData[] = [];
59
60
  public prefilledPublicData: PublicDataTreeLeaf[] = [];
@@ -96,7 +97,7 @@ export class P2PNetworkTest {
96
97
  initialValidatorConfig.aztecProofSubmissionWindow ?? l1ContractsConfig.aztecProofSubmissionWindow,
97
98
  salt: 420,
98
99
  metricsPort: metricsPort,
99
- numberOfInitialFundedAccounts: 1,
100
+ numberOfInitialFundedAccounts: 2,
100
101
  },
101
102
  {
102
103
  aztecEpochDuration: initialValidatorConfig.aztecEpochDuration ?? l1ContractsConfig.aztecEpochDuration,
@@ -230,9 +231,10 @@ export class P2PNetworkTest {
230
231
  amount: l1ContractsConfig.minimumStake,
231
232
  } as const);
232
233
 
233
- this.logger.verbose(`Adding (attester, proposer) pair: (${attester.address}, ${forwarder}) as validator`);
234
+ this.logger.info(`Adding attester ${attester.address} proposer ${forwarder} as validator`);
234
235
  }
235
236
 
237
+ this.validators = validators;
236
238
  await deployL1ContractsValues.publicClient.waitForTransactionReceipt({
237
239
  hash: await rollup.write.cheat__InitialiseValidatorSet([validators]),
238
240
  });
@@ -319,9 +321,11 @@ export class P2PNetworkTest {
319
321
  async setup() {
320
322
  this.ctx = await this.snapshotManager.setup();
321
323
 
322
- this.prefilledPublicData = (
323
- await getGenesisValues(this.ctx.initialFundedAccounts.map(a => a.address))
324
- ).prefilledPublicData;
324
+ const sponsoredFPCAddress = await getSponsoredFPCAddress();
325
+ const initialFundedAccounts = [...this.ctx.initialFundedAccounts.map(a => a.address), sponsoredFPCAddress];
326
+
327
+ const { prefilledPublicData } = await getGenesisValues(initialFundedAccounts);
328
+ this.prefilledPublicData = prefilledPublicData;
325
329
 
326
330
  this.startSyncMockSystemTimeInterval();
327
331
 
@@ -47,6 +47,7 @@ export const createPXEServiceAndSubmitTransactions = async (
47
47
  fundedAccount: InitialAccountData,
48
48
  ): Promise<NodeContext> => {
49
49
  const rpcConfig = getRpcConfig();
50
+ rpcConfig.proverEnabled = false;
50
51
  const pxeService = await createPXEService(node, rpcConfig, true);
51
52
 
52
53
  const account = await getSchnorrAccount(
@@ -1,4 +1,9 @@
1
- import type { L1ContractAddresses, ViemPublicClient, ViemWalletClient } from '@aztec/ethereum';
1
+ import {
2
+ type L1ContractAddresses,
3
+ RollupContract,
4
+ type ViemPublicClient,
5
+ type ViemWalletClient,
6
+ } from '@aztec/ethereum';
2
7
  import { Fr } from '@aztec/foundation/fields';
3
8
  import { InboxAbi } from '@aztec/l1-artifacts';
4
9
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
@@ -11,7 +16,7 @@ export async function sendL1ToL2Message(
11
16
  ctx: {
12
17
  walletClient: ViemWalletClient;
13
18
  publicClient: ViemPublicClient;
14
- l1ContractAddresses: Pick<L1ContractAddresses, 'inboxAddress'>;
19
+ l1ContractAddresses: Pick<L1ContractAddresses, 'inboxAddress' | 'rollupAddress'>;
15
20
  },
16
21
  ) {
17
22
  const inbox = getContract({
@@ -21,7 +26,11 @@ export async function sendL1ToL2Message(
21
26
  });
22
27
 
23
28
  const { recipient, content, secretHash } = message;
24
- const version = 1;
29
+
30
+ const version = await new RollupContract(
31
+ ctx.publicClient,
32
+ ctx.l1ContractAddresses.rollupAddress.toString(),
33
+ ).getVersion();
25
34
 
26
35
  // We inject the message to Inbox
27
36
  const txHash = await inbox.write.sendL2Message([
@@ -1,7 +1,7 @@
1
1
  import type { Logger } from '@aztec/aztec.js';
2
2
  import { type DeployL1ContractsArgs, type L1ContractsConfig, deployL1Contracts } from '@aztec/ethereum';
3
3
  import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
4
- import { ProtocolContractAddress, protocolContractTreeRoot } from '@aztec/protocol-contracts';
4
+ import { protocolContractTreeRoot } from '@aztec/protocol-contracts';
5
5
 
6
6
  import type { HDAccount, PrivateKeyAccount } from 'viem';
7
7
  import { foundry } from 'viem/chains';
@@ -16,7 +16,6 @@ export const setupL1Contracts = async (
16
16
  L1ContractsConfig,
17
17
  ) => {
18
18
  const l1Data = await deployL1Contracts([l1RpcUrl], account, foundry, logger, {
19
- l2FeeJuiceAddress: ProtocolContractAddress.FeeJuice.toField(),
20
19
  vkTreeRoot: getVKTreeRoot(),
21
20
  protocolContractTreeRoot,
22
21
  salt: undefined,
@@ -308,6 +308,9 @@ async function setupFromFresh(
308
308
  aztecNodeConfig.peerCheckIntervalMS = TEST_PEER_CHECK_INTERVAL_MS;
309
309
  // Only enable proving if specifically requested.
310
310
  aztecNodeConfig.realProofs = !!opts.realProofs;
311
+ // Only enforce the time table if requested
312
+ aztecNodeConfig.enforceTimeTable = !!opts.enforceTimeTable;
313
+ aztecNodeConfig.listenAddress = '127.0.0.1';
311
314
 
312
315
  // Create a temp directory for all ephemeral state and cleanup afterwards
313
316
  const directoryToCleanup = path.join(tmpdir(), randomBytes(8).toString('hex'));
@@ -317,7 +320,7 @@ async function setupFromFresh(
317
320
  } else {
318
321
  aztecNodeConfig.dataDirectory = statePath;
319
322
  }
320
- aztecNodeConfig.blobSinkUrl = `http://localhost:${blobSinkPort}`;
323
+ aztecNodeConfig.blobSinkUrl = `http://127.0.0.1:${blobSinkPort}`;
321
324
 
322
325
  // Start anvil. We go via a wrapper script to ensure if the parent dies, anvil dies.
323
326
  logger.verbose('Starting anvil...');
@@ -345,7 +348,7 @@ async function setupFromFresh(
345
348
 
346
349
  const initialFundedAccounts = await generateSchnorrAccounts(numberOfInitialFundedAccounts);
347
350
  const sponsoredFPCAddress = await getSponsoredFPCAddress();
348
- const { genesisArchiveRoot, genesisBlockHash, prefilledPublicData } = await getGenesisValues(
351
+ const { genesisArchiveRoot, genesisBlockHash, prefilledPublicData, fundingNeeded } = await getGenesisValues(
349
352
  initialFundedAccounts.map(a => a.address).concat(sponsoredFPCAddress),
350
353
  opts.initialAccountFeeJuice,
351
354
  );
@@ -354,6 +357,7 @@ async function setupFromFresh(
354
357
  ...getL1ContractsConfigEnvVars(),
355
358
  genesisArchiveRoot,
356
359
  genesisBlockHash,
360
+ feeJuicePortalInitialBalance: fundingNeeded,
357
361
  salt: opts.salt,
358
362
  ...deployL1ContractsArgs,
359
363
  initialValidators: opts.initialValidators,
@@ -490,6 +494,7 @@ async function setupFromState(statePath: string, logger: Logger): Promise<Subsys
490
494
  );
491
495
  aztecNodeConfig.dataDirectory = statePath;
492
496
  aztecNodeConfig.blobSinkUrl = `http://127.0.0.1:${blobSinkPort}`;
497
+ aztecNodeConfig.listenAddress = '127.0.0.1';
493
498
 
494
499
  const initialFundedAccounts: InitialAccountData[] =
495
500
  JSON.parse(readFileSync(`${statePath}/accounts.json`, 'utf-8'), reviver) || [];
@@ -1,7 +1,8 @@
1
- // docs:start:token_utils
2
- import type { AztecAddress, Logger, Wallet } from '@aztec/aztec.js';
1
+ import { type AztecAddress, BatchCall, type Logger, type Wallet } from '@aztec/aztec.js';
3
2
  import { TokenContract } from '@aztec/noir-contracts.js/Token';
4
3
 
4
+ // docs:start:token_utils
5
+
5
6
  export async function deployToken(adminWallet: Wallet, initialAdminBalance: bigint, logger: Logger) {
6
7
  logger.info(`Deploying Token contract...`);
7
8
  const contract = await TokenContract.deploy(adminWallet, adminWallet.getAddress(), 'TokenName', 'TokenSymbol', 18)
@@ -43,3 +44,22 @@ export async function expectTokenBalance(
43
44
  logger.info(`Account ${owner} balance: ${balance}`);
44
45
  expect(balance).toBe(expectedBalance);
45
46
  }
47
+
48
+ export async function mintNotes(
49
+ sender: Wallet,
50
+ recipient: AztecAddress,
51
+ asset: TokenContract,
52
+ noteAmounts: bigint[],
53
+ ): Promise<bigint> {
54
+ // We can only mint 4 notes at a time, since that's the maximum number of calls our entrypoints allow
55
+ // TODO(#13024): mint as many notes as possible in a single tx
56
+ const notesPerIteration = 4;
57
+ for (let mintedNotes = 0; mintedNotes < noteAmounts.length; mintedNotes += notesPerIteration) {
58
+ const toMint = noteAmounts.slice(mintedNotes, mintedNotes + notesPerIteration);
59
+ const from = sender.getAddress(); // we are setting from to sender here because we need a sender to calculate the tag
60
+ const actions = toMint.map(amt => asset.methods.mint_to_private(from, recipient, amt));
61
+ await new BatchCall(sender, actions).send().wait();
62
+ }
63
+
64
+ return noteAmounts.reduce((prev, curr) => prev + curr, 0n);
65
+ }