@aztec/end-to-end 0.82.2 → 0.82.3

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 (41) hide show
  1. package/dest/bench/client_flows/client_flows_benchmark.d.ts +52 -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 +236 -0
  4. package/dest/bench/client_flows/data_extractor.d.ts +23 -0
  5. package/dest/bench/client_flows/data_extractor.d.ts.map +1 -0
  6. package/dest/bench/client_flows/data_extractor.js +199 -0
  7. package/dest/bench/utils.d.ts +0 -12
  8. package/dest/bench/utils.d.ts.map +1 -1
  9. package/dest/bench/utils.js +0 -26
  10. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +0 -12
  11. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts.map +1 -1
  12. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.js +1 -13
  13. package/dest/e2e_fees/fees_test.d.ts.map +1 -1
  14. package/dest/e2e_fees/fees_test.js +1 -10
  15. package/dest/e2e_p2p/p2p_network.d.ts +5 -0
  16. package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
  17. package/dest/e2e_p2p/p2p_network.js +12 -3
  18. package/dest/e2e_p2p/shared.d.ts.map +1 -1
  19. package/dest/e2e_p2p/shared.js +1 -0
  20. package/dest/fixtures/token_utils.d.ts +2 -1
  21. package/dest/fixtures/token_utils.d.ts.map +1 -1
  22. package/dest/fixtures/token_utils.js +14 -1
  23. package/dest/sample-dapp/contracts.js +4 -4
  24. package/dest/shared/capture_private_execution_steps.d.ts +2 -2
  25. package/dest/shared/capture_private_execution_steps.d.ts.map +1 -1
  26. package/dest/shared/capture_private_execution_steps.js +24 -6
  27. package/dest/shared/cross_chain_test_harness.d.ts +11 -0
  28. package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
  29. package/dest/shared/cross_chain_test_harness.js +12 -1
  30. package/package.json +32 -32
  31. package/src/bench/client_flows/client_flows_benchmark.ts +331 -0
  32. package/src/bench/client_flows/data_extractor.ts +217 -0
  33. package/src/bench/utils.ts +0 -28
  34. package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +1 -25
  35. package/src/e2e_fees/fees_test.ts +1 -11
  36. package/src/e2e_p2p/p2p_network.ts +9 -5
  37. package/src/e2e_p2p/shared.ts +1 -0
  38. package/src/fixtures/token_utils.ts +22 -2
  39. package/src/sample-dapp/contracts.mjs +4 -4
  40. package/src/shared/capture_private_execution_steps.ts +43 -6
  41. package/src/shared/cross_chain_test_harness.ts +24 -0
@@ -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[] = [];
@@ -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,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
+ }
@@ -1,14 +1,14 @@
1
- // docs:start:imports
2
- import { AztecAddress } from '@aztec/aztec.js';
1
+ import { AztecAddress, Contract } from '@aztec/aztec.js';
3
2
  import { TokenContract } from '@aztec/noir-contracts.js/Token';
4
3
 
5
4
  import { readFileSync } from 'fs';
6
5
 
7
- // docs:end:imports
6
+ // This syntax is helpful for the referencing tutorial
7
+ const TokenContractArtifact = TokenContract.artifact;
8
8
 
9
9
  // docs:start:get-tokens
10
10
  export async function getToken(wallet) {
11
11
  const addresses = JSON.parse(readFileSync('addresses.json'));
12
- return TokenContract.at(AztecAddress.fromString(addresses.token), wallet);
12
+ return Contract.at(AztecAddress.fromString(addresses.token), TokenContractArtifact, wallet);
13
13
  }
14
14
  // docs:end:get-tokens
@@ -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.
@@ -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