@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
@@ -2,7 +2,12 @@
2
2
  * This module exposes the ability to capture the private exection steps that go into our "Client IVC" prover.
3
3
  * These are used for debugging and benchmarking barretenberg (the prover component).
4
4
  */
5
- import type { ContractFunctionInteraction } from '@aztec/aztec.js/contracts';
5
+ import type {
6
+ ContractFunctionInteraction,
7
+ DeployMethod,
8
+ DeployOptions,
9
+ ProfileMethodOptions,
10
+ } from '@aztec/aztec.js/contracts';
6
11
  import { createLogger } from '@aztec/foundation/log';
7
12
  import { serializeWitness } from '@aztec/noir-noirc_abi';
8
13
  import type { PrivateExecutionStep } from '@aztec/stdlib/kernel';
@@ -17,27 +22,59 @@ const logger = createLogger('e2e:capture-private-execution-steps');
17
22
  // Longer term we won't use this hacked together msgpack format
18
23
  // Leaving duplicated as this eventually bb will provide a serialization
19
24
  // helper for passing to a generic msgpack RPC endpoint.
20
- async function _createClientIvcProofFiles(directory: string, executionSteps: PrivateExecutionStep[]) {
25
+ async function _createClientIvcProofFiles(
26
+ directory: string,
27
+ executionSteps: PrivateExecutionStep[],
28
+ rawWitnesses: boolean = false,
29
+ ) {
21
30
  const acirPath = path.join(directory, 'acir.msgpack');
22
31
  const witnessPath = path.join(directory, 'witnesses.msgpack');
23
32
  await fs.writeFile(acirPath, encode(executionSteps.map(map => map.bytecode)));
24
33
  await fs.writeFile(witnessPath, encode(executionSteps.map(map => serializeWitness(map.witness))));
34
+ let rawWitnessesPath;
35
+ if (rawWitnesses) {
36
+ rawWitnessesPath = path.join(directory, 'witnesses.json');
37
+ await fs.writeFile(rawWitnessesPath, JSON.stringify(executionSteps.map(step => Object.fromEntries(step.witness))));
38
+ }
25
39
  return {
26
40
  acirPath,
27
41
  witnessPath,
42
+ rawWitnessesPath,
28
43
  };
29
44
  }
30
45
 
31
- export async function capturePrivateExecutionStepsIfEnvSet(label: string, interaction: ContractFunctionInteraction) {
46
+ export async function capturePrivateExecutionStepsIfEnvSet(
47
+ label: string,
48
+ interaction: ContractFunctionInteraction | DeployMethod,
49
+ opts?: Omit<ProfileMethodOptions & DeployOptions, 'profileMode'>,
50
+ expectedSteps?: number,
51
+ ) {
32
52
  // Not included in env_var.ts as internal to e2e tests.
33
53
  const ivcFolder = process.env.CAPTURE_IVC_FOLDER;
34
54
  if (ivcFolder) {
35
- logger.info(`Capturing client ivc execution steps for ${label}`);
36
- const result = await interaction.profile({ profileMode: 'execution-steps' });
55
+ const profileMode = ['execution-steps', 'full'].includes(process.env.PROFILE_MODE ?? '')
56
+ ? (process.env.PROFILE_MODE as 'full' | 'execution-steps')
57
+ : 'execution-steps';
58
+ logger.info(`Capturing client ivc execution profile for ${label} in mode ${profileMode}`);
59
+ const result = await interaction.profile({
60
+ ...opts,
61
+ profileMode: profileMode,
62
+ });
63
+ if (expectedSteps !== undefined && result.executionSteps.length !== expectedSteps) {
64
+ throw new Error(`Expected ${expectedSteps} execution steps, got ${result.executionSteps.length}`);
65
+ }
37
66
  const resultsDirectory = path.join(ivcFolder, label);
38
67
  logger.info(`Writing private execution steps to ${resultsDirectory}`);
39
68
  await fs.mkdir(resultsDirectory, { recursive: true });
40
- await _createClientIvcProofFiles(resultsDirectory, result.executionSteps);
69
+ await fs.writeFile(
70
+ path.join(resultsDirectory, 'steps.json'),
71
+ JSON.stringify(
72
+ result.executionSteps.map(step => ({ fnName: step.functionName, gateCount: step.gateCount })),
73
+ null,
74
+ 2,
75
+ ),
76
+ );
77
+ await _createClientIvcProofFiles(resultsDirectory, result.executionSteps, profileMode === 'full');
41
78
  logger.info(`Wrote private execution steps to ${resultsDirectory}`);
42
79
  }
43
80
  }
@@ -121,6 +121,17 @@ export async function deployAndInitializeTokenAndBridgeContracts(
121
121
  }
122
122
  // docs:end:deployAndInitializeTokenAndBridgeContracts
123
123
 
124
+ export type CrossChainContext = {
125
+ l2Token: AztecAddress;
126
+ l2Bridge: AztecAddress;
127
+ tokenPortal: EthAddress;
128
+ underlying: EthAddress;
129
+ ethAccount: EthAddress;
130
+ ownerAddress: AztecAddress;
131
+ inbox: EthAddress;
132
+ outbox: EthAddress;
133
+ };
134
+
124
135
  /**
125
136
  * A Class for testing cross chain interactions, contains common interactions
126
137
  * shared between cross chain tests.
@@ -314,8 +325,8 @@ export class CrossChainTestHarness {
314
325
  expect(balance).toBe(expectedBalance);
315
326
  }
316
327
 
317
- getL2ToL1MessageLeaf(withdrawAmount: bigint, callerOnL1: EthAddress = EthAddress.ZERO): Fr {
318
- return this.l1TokenPortalManager.getL2ToL1MessageLeaf(
328
+ async getL2ToL1MessageLeaf(withdrawAmount: bigint, callerOnL1: EthAddress = EthAddress.ZERO): Promise<Fr> {
329
+ return await this.l1TokenPortalManager.getL2ToL1MessageLeaf(
319
330
  withdrawAmount,
320
331
  this.ethAccount,
321
332
  this.l2Bridge.address,
@@ -363,5 +374,18 @@ export class CrossChainTestHarness {
363
374
  await this.mintTokensPublicOnL2(0n);
364
375
  await this.mintTokensPublicOnL2(0n);
365
376
  }
377
+
378
+ toCrossChainContext(): CrossChainContext {
379
+ return {
380
+ l2Token: this.l2Token.address,
381
+ l2Bridge: this.l2Bridge.address,
382
+ tokenPortal: this.tokenPortalAddress,
383
+ underlying: this.underlyingERC20Address,
384
+ ethAccount: this.ethAccount,
385
+ ownerAddress: this.ownerAddress,
386
+ inbox: this.l1ContractAddresses.inboxAddress,
387
+ outbox: this.l1ContractAddresses.outboxAddress,
388
+ };
389
+ }
366
390
  }
367
391
  // docs:end:cross_chain_test_harness
@@ -101,7 +101,7 @@ export const uniswapL1L2TestSuite = (
101
101
  const minimumOutputAmount = 0n;
102
102
 
103
103
  let cheatCodes: CheatCodes;
104
-
104
+ let version: number;
105
105
  beforeAll(async () => {
106
106
  ({
107
107
  aztecNode,
@@ -123,7 +123,7 @@ export const uniswapL1L2TestSuite = (
123
123
  deployL1ContractsValues.publicClient,
124
124
  deployL1ContractsValues.l1ContractAddresses.rollupAddress,
125
125
  );
126
-
126
+ version = Number(await rollup.getVersion());
127
127
  ownerAddress = ownerWallet.getAddress();
128
128
  // sponsorAddress = sponsorWallet.getAddress();
129
129
  ownerEthAddress = EthAddress.fromString((await walletClient.getAddresses())[0]);
@@ -261,7 +261,7 @@ export const uniswapL1L2TestSuite = (
261
261
 
262
262
  const swapPrivateLeaf = sha256ToField([
263
263
  uniswapL2Contract.address,
264
- new Fr(1), // aztec version
264
+ new Fr(version), // aztec version
265
265
  EthAddress.fromString(uniswapPortal.address).toBuffer32(),
266
266
  new Fr(publicClient.chain.id), // chain id
267
267
  swapPrivateContent,
@@ -276,7 +276,7 @@ export const uniswapL1L2TestSuite = (
276
276
 
277
277
  const withdrawLeaf = sha256ToField([
278
278
  wethCrossChainHarness.l2Bridge.address,
279
- new Fr(1), // aztec version
279
+ new Fr(version), // aztec version
280
280
  wethCrossChainHarness.tokenPortalAddress.toBuffer32(),
281
281
  new Fr(publicClient.chain.id), // chain id
282
282
  withdrawContent,
@@ -849,7 +849,7 @@ export const uniswapL1L2TestSuite = (
849
849
 
850
850
  const swapPrivateLeaf = sha256ToField([
851
851
  uniswapL2Contract.address,
852
- new Fr(1), // aztec version
852
+ new Fr(version), // aztec version
853
853
  EthAddress.fromString(uniswapPortal.address).toBuffer32(),
854
854
  new Fr(publicClient.chain.id), // chain id
855
855
  swapPrivateContent,
@@ -864,7 +864,7 @@ export const uniswapL1L2TestSuite = (
864
864
 
865
865
  const withdrawLeaf = sha256ToField([
866
866
  wethCrossChainHarness.l2Bridge.address,
867
- new Fr(1), // aztec version
867
+ new Fr(version), // aztec version
868
868
  wethCrossChainHarness.tokenPortalAddress.toBuffer32(),
869
869
  new Fr(publicClient.chain.id), // chain id
870
870
  withdrawContent,
@@ -979,7 +979,7 @@ export const uniswapL1L2TestSuite = (
979
979
 
980
980
  const swapPublicLeaf = sha256ToField([
981
981
  uniswapL2Contract.address,
982
- new Fr(1), // aztec version
982
+ new Fr(version), // aztec version
983
983
  EthAddress.fromString(uniswapPortal.address).toBuffer32(),
984
984
  new Fr(publicClient.chain.id), // chain id
985
985
  swapPublicContent,
@@ -994,7 +994,7 @@ export const uniswapL1L2TestSuite = (
994
994
 
995
995
  const withdrawLeaf = sha256ToField([
996
996
  wethCrossChainHarness.l2Bridge.address,
997
- new Fr(1), // aztec version
997
+ new Fr(version), // aztec version
998
998
  wethCrossChainHarness.tokenPortalAddress.toBuffer32(),
999
999
  new Fr(publicClient.chain.id), // chain id
1000
1000
  withdrawContent,