@aztec/end-to-end 3.0.0-canary.a9708bd → 3.0.0-devnet.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 (137) hide show
  1. package/dest/bench/client_flows/benchmark.d.ts +3 -2
  2. package/dest/bench/client_flows/benchmark.d.ts.map +1 -1
  3. package/dest/bench/client_flows/client_flows_benchmark.d.ts +16 -12
  4. package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
  5. package/dest/bench/client_flows/client_flows_benchmark.js +54 -58
  6. package/dest/bench/utils.d.ts +2 -11
  7. package/dest/bench/utils.d.ts.map +1 -1
  8. package/dest/bench/utils.js +10 -34
  9. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +7 -7
  10. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +1 -1
  11. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.js +42 -42
  12. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +10 -8
  13. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts.map +1 -1
  14. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.js +31 -33
  15. package/dest/e2e_deploy_contract/deploy_test.d.ts +10 -4
  16. package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
  17. package/dest/e2e_deploy_contract/deploy_test.js +9 -18
  18. package/dest/e2e_epochs/epochs_test.d.ts +9 -3
  19. package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
  20. package/dest/e2e_epochs/epochs_test.js +19 -13
  21. package/dest/e2e_fees/bridging_race.notest.js +12 -9
  22. package/dest/e2e_fees/fees_test.d.ts +5 -5
  23. package/dest/e2e_fees/fees_test.d.ts.map +1 -1
  24. package/dest/e2e_fees/fees_test.js +26 -33
  25. package/dest/e2e_l1_publisher/write_json.d.ts +3 -1
  26. package/dest/e2e_l1_publisher/write_json.d.ts.map +1 -1
  27. package/dest/e2e_l1_publisher/write_json.js +5 -5
  28. package/dest/e2e_multi_validator/utils.d.ts +1 -1
  29. package/dest/e2e_multi_validator/utils.d.ts.map +1 -1
  30. package/dest/e2e_multi_validator/utils.js +3 -9
  31. package/dest/e2e_nested_contract/nested_contract_test.d.ts +6 -3
  32. package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
  33. package/dest/e2e_nested_contract/nested_contract_test.js +7 -9
  34. package/dest/e2e_p2p/inactivity_slash_test.d.ts +31 -0
  35. package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +1 -0
  36. package/dest/e2e_p2p/inactivity_slash_test.js +135 -0
  37. package/dest/e2e_p2p/p2p_network.d.ts +22 -8
  38. package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
  39. package/dest/e2e_p2p/p2p_network.js +36 -15
  40. package/dest/e2e_p2p/shared.d.ts +12 -13
  41. package/dest/e2e_p2p/shared.d.ts.map +1 -1
  42. package/dest/e2e_p2p/shared.js +54 -54
  43. package/dest/e2e_token_contract/token_contract_test.d.ts +5 -4
  44. package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
  45. package/dest/e2e_token_contract/token_contract_test.js +14 -17
  46. package/dest/fixtures/e2e_prover_test.d.ts +8 -6
  47. package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
  48. package/dest/fixtures/e2e_prover_test.js +42 -51
  49. package/dest/fixtures/get_acvm_config.d.ts +1 -1
  50. package/dest/fixtures/get_acvm_config.d.ts.map +1 -1
  51. package/dest/fixtures/get_bb_config.d.ts +1 -1
  52. package/dest/fixtures/get_bb_config.d.ts.map +1 -1
  53. package/dest/fixtures/get_bb_config.js +2 -2
  54. package/dest/fixtures/setup_l1_contracts.d.ts +1 -1
  55. package/dest/fixtures/setup_l1_contracts.d.ts.map +1 -1
  56. package/dest/fixtures/setup_l1_contracts.js +2 -2
  57. package/dest/fixtures/setup_p2p_test.d.ts +10 -9
  58. package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
  59. package/dest/fixtures/setup_p2p_test.js +38 -20
  60. package/dest/fixtures/snapshot_manager.d.ts +10 -7
  61. package/dest/fixtures/snapshot_manager.d.ts.map +1 -1
  62. package/dest/fixtures/snapshot_manager.js +60 -47
  63. package/dest/fixtures/token_utils.d.ts +6 -4
  64. package/dest/fixtures/token_utils.d.ts.map +1 -1
  65. package/dest/fixtures/token_utils.js +11 -15
  66. package/dest/fixtures/utils.d.ts +26 -28
  67. package/dest/fixtures/utils.d.ts.map +1 -1
  68. package/dest/fixtures/utils.js +83 -109
  69. package/dest/fixtures/web3signer.d.ts +5 -0
  70. package/dest/fixtures/web3signer.d.ts.map +1 -0
  71. package/dest/fixtures/web3signer.js +53 -0
  72. package/dest/quality_of_service/alert_checker.d.ts +1 -1
  73. package/dest/quality_of_service/alert_checker.d.ts.map +1 -1
  74. package/dest/shared/cross_chain_test_harness.d.ts +16 -10
  75. package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
  76. package/dest/shared/cross_chain_test_harness.js +13 -15
  77. package/dest/shared/gas_portal_test_harness.d.ts +9 -6
  78. package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
  79. package/dest/shared/gas_portal_test_harness.js +10 -7
  80. package/dest/shared/jest_setup.js +1 -1
  81. package/dest/shared/submit-transactions.d.ts +5 -3
  82. package/dest/shared/submit-transactions.d.ts.map +1 -1
  83. package/dest/shared/submit-transactions.js +8 -7
  84. package/dest/shared/uniswap_l1_l2.d.ts +9 -6
  85. package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
  86. package/dest/shared/uniswap_l1_l2.js +29 -45
  87. package/dest/simulators/lending_simulator.d.ts +2 -1
  88. package/dest/simulators/lending_simulator.d.ts.map +1 -1
  89. package/dest/simulators/lending_simulator.js +3 -2
  90. package/dest/simulators/token_simulator.d.ts +3 -1
  91. package/dest/simulators/token_simulator.d.ts.map +1 -1
  92. package/dest/simulators/token_simulator.js +2 -2
  93. package/dest/spartan/setup_test_wallets.d.ts +19 -13
  94. package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
  95. package/dest/spartan/setup_test_wallets.js +108 -85
  96. package/dest/spartan/utils.d.ts +68 -3
  97. package/dest/spartan/utils.d.ts.map +1 -1
  98. package/dest/spartan/utils.js +312 -49
  99. package/package.json +39 -38
  100. package/src/bench/client_flows/benchmark.ts +6 -6
  101. package/src/bench/client_flows/client_flows_benchmark.ts +62 -82
  102. package/src/bench/client_flows/data_extractor.ts +1 -1
  103. package/src/bench/utils.ts +9 -37
  104. package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +46 -63
  105. package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +33 -47
  106. package/src/e2e_deploy_contract/deploy_test.ts +17 -35
  107. package/src/e2e_epochs/epochs_test.ts +22 -19
  108. package/src/e2e_fees/bridging_race.notest.ts +14 -9
  109. package/src/e2e_fees/fees_test.ts +29 -40
  110. package/src/e2e_l1_publisher/write_json.ts +8 -6
  111. package/src/e2e_multi_validator/utils.ts +4 -10
  112. package/src/e2e_nested_contract/nested_contract_test.ts +11 -10
  113. package/src/e2e_p2p/inactivity_slash_test.ts +178 -0
  114. package/src/e2e_p2p/p2p_network.ts +110 -71
  115. package/src/e2e_p2p/shared.ts +57 -56
  116. package/src/e2e_token_contract/token_contract_test.ts +17 -17
  117. package/src/fixtures/e2e_prover_test.ts +52 -88
  118. package/src/fixtures/get_acvm_config.ts +1 -1
  119. package/src/fixtures/get_bb_config.ts +3 -2
  120. package/src/fixtures/setup_l1_contracts.ts +3 -3
  121. package/src/fixtures/setup_p2p_test.ts +60 -27
  122. package/src/fixtures/snapshot_manager.ts +80 -72
  123. package/src/fixtures/token_utils.ts +13 -21
  124. package/src/fixtures/utils.ts +95 -145
  125. package/src/fixtures/web3signer.ts +63 -0
  126. package/src/guides/up_quick_start.sh +2 -10
  127. package/src/quality_of_service/alert_checker.ts +1 -1
  128. package/src/shared/cross_chain_test_harness.ts +18 -29
  129. package/src/shared/gas_portal_test_harness.ts +12 -19
  130. package/src/shared/jest_setup.ts +1 -1
  131. package/src/shared/submit-transactions.ts +12 -8
  132. package/src/shared/uniswap_l1_l2.ts +61 -67
  133. package/src/simulators/lending_simulator.ts +3 -2
  134. package/src/simulators/token_simulator.ts +5 -2
  135. package/src/spartan/DEVELOP.md +8 -3
  136. package/src/spartan/setup_test_wallets.ts +133 -126
  137. package/src/spartan/utils.ts +373 -48
@@ -2,13 +2,11 @@
2
2
  * Test fixtures and utilities to set up and run a test using multiple validators
3
3
  */
4
4
  import { type AztecNodeConfig, AztecNodeService } from '@aztec/aztec-node';
5
- import type { SentTx } from '@aztec/aztec.js';
6
5
  import { SecretValue } from '@aztec/foundation/config';
7
6
  import { addLogNameHandler, removeLogNameHandler } from '@aztec/foundation/log';
8
7
  import { bufferToHex } from '@aztec/foundation/string';
9
8
  import type { DateProvider } from '@aztec/foundation/timer';
10
9
  import type { ProverNodeConfig, ProverNodeDeps } from '@aztec/prover-node';
11
- import type { PXEService } from '@aztec/pxe/server';
12
10
  import type { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
13
11
 
14
12
  import getPort from 'get-port';
@@ -23,12 +21,6 @@ import { getEndToEndTestTelemetryClient } from './with_telemetry_utils.js';
23
21
  // to avoid running validators with the same key
24
22
  export const ATTESTER_PRIVATE_KEYS_START_INDEX = 3;
25
23
 
26
- export interface NodeContext {
27
- node: AztecNodeService;
28
- pxeService: PXEService;
29
- txs: SentTx[];
30
- }
31
-
32
24
  export function generatePrivateKeys(startIndex: number, numberOfKeys: number): `0x${string}`[] {
33
25
  const privateKeys: `0x${string}`[] = [];
34
26
  // Do not start from 0 as it is used during setup
@@ -39,7 +31,7 @@ export function generatePrivateKeys(startIndex: number, numberOfKeys: number): `
39
31
  }
40
32
 
41
33
  export async function createNodes(
42
- config: AztecNodeConfig,
34
+ config: AztecNodeConfig & { dontStartSequencer?: boolean },
43
35
  dateProvider: DateProvider,
44
36
  bootstrapNodeEnr: string,
45
37
  numNodes: number,
@@ -86,9 +78,9 @@ export async function createNodes(
86
78
  return nodes;
87
79
  }
88
80
 
89
- // creates a P2P enabled instance of Aztec Node Service
81
+ /** Creates a P2P enabled instance of Aztec Node Service with a validator */
90
82
  export async function createNode(
91
- config: AztecNodeConfig,
83
+ config: AztecNodeConfig & { dontStartSequencer?: boolean },
92
84
  dateProvider: DateProvider,
93
85
  tcpPort: number,
94
86
  bootstrapNode: string | undefined,
@@ -101,7 +93,36 @@ export async function createNode(
101
93
  const createNode = async () => {
102
94
  const validatorConfig = await createValidatorConfig(config, bootstrapNode, tcpPort, addressIndex, dataDirectory);
103
95
  const telemetry = getEndToEndTestTelemetryClient(metricsPort);
104
- return await AztecNodeService.createAndSync(validatorConfig, { telemetry, dateProvider }, { prefilledPublicData });
96
+ return await AztecNodeService.createAndSync(
97
+ validatorConfig,
98
+ { telemetry, dateProvider },
99
+ { prefilledPublicData, dontStartSequencer: config.dontStartSequencer },
100
+ );
101
+ };
102
+ return loggerIdStorage ? await loggerIdStorage.run(tcpPort.toString(), createNode) : createNode();
103
+ }
104
+
105
+ /** Creates a P2P enabled instance of Aztec Node Service without a validator */
106
+ export async function createNonValidatorNode(
107
+ baseConfig: AztecNodeConfig,
108
+ dateProvider: DateProvider,
109
+ tcpPort: number,
110
+ bootstrapNode: string | undefined,
111
+ prefilledPublicData?: PublicDataTreeLeaf[],
112
+ dataDirectory?: string,
113
+ metricsPort?: number,
114
+ loggerIdStorage?: AsyncLocalStorage<string>,
115
+ ) {
116
+ const createNode = async () => {
117
+ const p2pConfig = await createP2PConfig(baseConfig, bootstrapNode, tcpPort, dataDirectory);
118
+ const config: AztecNodeConfig = {
119
+ ...p2pConfig,
120
+ disableValidator: true,
121
+ validatorPrivateKeys: undefined,
122
+ publisherPrivateKeys: [],
123
+ };
124
+ const telemetry = getEndToEndTestTelemetryClient(metricsPort);
125
+ return await AztecNodeService.createAndSync(config, { telemetry, dateProvider }, { prefilledPublicData });
105
126
  };
106
127
  return loggerIdStorage ? await loggerIdStorage.run(tcpPort.toString(), createNode) : createNode();
107
128
  }
@@ -121,14 +142,13 @@ export async function createProverNode(
121
142
  const proverNodePrivateKey = getPrivateKeyFromIndex(ATTESTER_PRIVATE_KEYS_START_INDEX + addressIndex)!;
122
143
  const telemetry = getEndToEndTestTelemetryClient(metricsPort);
123
144
 
124
- const proverConfig: Partial<ProverNodeConfig> = {
125
- p2pIp: `127.0.0.1`,
126
- p2pPort: tcpPort ?? (await getPort()),
127
- p2pEnabled: true,
128
- peerCheckIntervalMS: TEST_PEER_CHECK_INTERVAL_MS,
129
- blockCheckIntervalMS: 1000,
130
- bootstrapNodes: bootstrapNode ? [bootstrapNode] : [],
131
- };
145
+ const proverConfig: Partial<ProverNodeConfig> = await createP2PConfig(
146
+ config,
147
+ bootstrapNode,
148
+ tcpPort,
149
+ dataDirectory,
150
+ );
151
+
132
152
  const aztecNodeRpcTxProvider = undefined;
133
153
  return await createAndSyncProverNode(
134
154
  bufferToHex(proverNodePrivateKey),
@@ -142,20 +162,14 @@ export async function createProverNode(
142
162
  return loggerIdStorage ? await loggerIdStorage.run(tcpPort.toString(), createProverNode) : createProverNode();
143
163
  }
144
164
 
145
- export async function createValidatorConfig(
165
+ export async function createP2PConfig(
146
166
  config: AztecNodeConfig,
147
167
  bootstrapNodeEnr?: string,
148
168
  port?: number,
149
- addressIndex: number = 1,
150
169
  dataDirectory?: string,
151
170
  ) {
152
171
  port = port ?? (await getPort());
153
172
 
154
- const attesterPrivateKey = bufferToHex(getPrivateKeyFromIndex(ATTESTER_PRIVATE_KEYS_START_INDEX + addressIndex)!);
155
-
156
- config.validatorPrivateKeys = new SecretValue([attesterPrivateKey]);
157
- config.publisherPrivateKeys = [new SecretValue(attesterPrivateKey)];
158
-
159
173
  const nodeConfig: AztecNodeConfig = {
160
174
  ...config,
161
175
  p2pIp: `127.0.0.1`,
@@ -169,3 +183,22 @@ export async function createValidatorConfig(
169
183
 
170
184
  return nodeConfig;
171
185
  }
186
+
187
+ export async function createValidatorConfig(
188
+ config: AztecNodeConfig,
189
+ bootstrapNodeEnr?: string,
190
+ port?: number,
191
+ addressIndex: number = 1,
192
+ dataDirectory?: string,
193
+ ) {
194
+ const attesterPrivateKey = bufferToHex(getPrivateKeyFromIndex(ATTESTER_PRIVATE_KEYS_START_INDEX + addressIndex)!);
195
+ const p2pConfig = await createP2PConfig(config, bootstrapNodeEnr, port, dataDirectory);
196
+ const nodeConfig: AztecNodeConfig = {
197
+ ...config,
198
+ ...p2pConfig,
199
+ validatorPrivateKeys: new SecretValue([attesterPrivateKey]),
200
+ publisherPrivateKeys: [new SecretValue(attesterPrivateKey)],
201
+ };
202
+
203
+ return nodeConfig;
204
+ }
@@ -1,21 +1,13 @@
1
1
  import { SchnorrAccountContractArtifact } from '@aztec/accounts/schnorr';
2
- import { type InitialAccountData, deployFundedSchnorrAccounts, generateSchnorrAccounts } from '@aztec/accounts/testing';
2
+ import { type InitialAccountData, generateSchnorrAccounts } from '@aztec/accounts/testing';
3
3
  import { type AztecNodeConfig, AztecNodeService, getConfigEnvVars } from '@aztec/aztec-node';
4
- import {
5
- type AztecAddress,
6
- type AztecNode,
7
- BatchCall,
8
- type CompleteAddress,
9
- type ContractFunctionInteraction,
10
- DefaultWaitForProvenOpts,
11
- EthAddress,
12
- type Logger,
13
- type PXE,
14
- type Wallet,
15
- getContractClassFromArtifact,
16
- waitForProven,
17
- } from '@aztec/aztec.js';
4
+ import { AztecAddress, EthAddress } from '@aztec/aztec.js/addresses';
5
+ import { getContractClassFromArtifact } from '@aztec/aztec.js/contracts';
6
+ import { BatchCall, type ContractFunctionInteraction, waitForProven } from '@aztec/aztec.js/contracts';
18
7
  import { publishContractClass, publishInstance } from '@aztec/aztec.js/deployment';
8
+ import type { Logger } from '@aztec/aztec.js/log';
9
+ import type { AztecNode } from '@aztec/aztec.js/node';
10
+ import type { Wallet } from '@aztec/aztec.js/wallet';
19
11
  import { AnvilTestWatcher, CheatCodes } from '@aztec/aztec/testing';
20
12
  import { type BlobSinkServer, createBlobSinkServer } from '@aztec/blob-sink/server';
21
13
  import {
@@ -34,10 +26,11 @@ import { createLogger } from '@aztec/foundation/log';
34
26
  import { resolver, reviver } from '@aztec/foundation/serialize';
35
27
  import { TestDateProvider } from '@aztec/foundation/timer';
36
28
  import type { ProverNode } from '@aztec/prover-node';
37
- import { type PXEService, createPXEService, getPXEServiceConfig } from '@aztec/pxe/server';
29
+ import { getPXEConfig } from '@aztec/pxe/server';
38
30
  import type { SequencerClient } from '@aztec/sequencer-client';
39
31
  import { tryStop } from '@aztec/stdlib/interfaces/server';
40
32
  import { getConfigEnvVars as getTelemetryConfig, initTelemetryClient } from '@aztec/telemetry-client';
33
+ import { TestWallet } from '@aztec/test-wallet/server';
41
34
  import { getGenesisValues } from '@aztec/world-state/testing';
42
35
 
43
36
  import type { Anvil } from '@viem/anvil';
@@ -70,7 +63,7 @@ export type SubsystemsContext = {
70
63
  bbConfig: any;
71
64
  aztecNode: AztecNodeService;
72
65
  aztecNodeConfig: AztecNodeConfig;
73
- pxe: PXEService;
66
+ wallet: TestWallet;
74
67
  deployL1ContractsValues: DeployL1ContractsReturnType;
75
68
  proverNode?: ProverNode;
76
69
  watcher: AnvilTestWatcher;
@@ -206,7 +199,7 @@ class SnapshotManager implements ISnapshotManager {
206
199
  await restore(snapshotData, context);
207
200
 
208
201
  // Save the snapshot data.
209
- const ethCheatCodes = new EthCheatCodesWithState(context.aztecNodeConfig.l1RpcUrls);
202
+ const ethCheatCodes = new EthCheatCodesWithState(context.aztecNodeConfig.l1RpcUrls, context.dateProvider);
210
203
  const anvilStateFile = `${this.livePath}/anvil.dat`;
211
204
  await ethCheatCodes.dumpChainState(anvilStateFile);
212
205
  writeFileSync(`${this.livePath}/${name}.json`, JSON.stringify(snapshotData || {}, resolver));
@@ -333,14 +326,6 @@ async function setupFromFresh(
333
326
  }
334
327
  aztecNodeConfig.blobSinkUrl = `http://127.0.0.1:${blobSinkPort}`;
335
328
 
336
- // Start anvil. We go via a wrapper script to ensure if the parent dies, anvil dies.
337
- logger.verbose('Starting anvil...');
338
- const res = await startAnvil({ l1BlockTime: opts.ethereumSlotDuration });
339
- const anvil = res.anvil;
340
- aztecNodeConfig.l1RpcUrls = [res.rpcUrl];
341
-
342
- // Deploy our L1 contracts.
343
- logger.verbose('Deploying L1 contracts...');
344
329
  const hdAccount = mnemonicToAccount(MNEMONIC, { addressIndex: 0 });
345
330
  const publisherPrivKeyRaw = hdAccount.getHdKey().privateKey;
346
331
  const publisherPrivKey = publisherPrivKeyRaw === null ? null : Buffer.from(publisherPrivKeyRaw);
@@ -354,8 +339,19 @@ async function setupFromFresh(
354
339
  aztecNodeConfig.validatorPrivateKeys = new SecretValue([`0x${validatorPrivKey!.toString('hex')}`]);
355
340
  aztecNodeConfig.coinbase = opts.coinbase ?? EthAddress.fromString(`${hdAccount.address}`);
356
341
 
357
- const ethCheatCodes = new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrls);
342
+ logger.info(`Setting up environment with config`, aztecNodeConfig);
343
+
344
+ // Start anvil. We go via a wrapper script to ensure if the parent dies, anvil dies.
345
+ logger.verbose('Starting anvil...');
346
+ const res = await startAnvil({ l1BlockTime: opts.ethereumSlotDuration });
347
+ const anvil = res.anvil;
348
+ aztecNodeConfig.l1RpcUrls = [res.rpcUrl];
358
349
 
350
+ const dateProvider = new TestDateProvider();
351
+ const ethCheatCodes = new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrls, dateProvider);
352
+
353
+ // Deploy our L1 contracts.
354
+ logger.verbose('Deploying L1 contracts...');
359
355
  if (opts.l1StartTime) {
360
356
  await ethCheatCodes.warp(opts.l1StartTime, { resetBlockInterval: true });
361
357
  }
@@ -379,12 +375,9 @@ async function setupFromFresh(
379
375
  });
380
376
  aztecNodeConfig.l1Contracts = deployL1ContractsValues.l1ContractAddresses;
381
377
  aztecNodeConfig.rollupVersion = deployL1ContractsValues.rollupVersion;
382
- aztecNodeConfig.l1PublishRetryIntervalMS = 100;
383
-
384
- const dateProvider = new TestDateProvider();
385
378
 
386
379
  const watcher = new AnvilTestWatcher(
387
- new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrls),
380
+ new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrls, dateProvider),
388
381
  deployL1ContractsValues.l1ContractAddresses.rollupAddress,
389
382
  deployL1ContractsValues.l1Client,
390
383
  dateProvider,
@@ -413,7 +406,7 @@ async function setupFromFresh(
413
406
  l1Contracts: aztecNodeConfig.l1Contracts,
414
407
  port: blobSinkPort,
415
408
  dataDirectory: aztecNodeConfig.dataDirectory,
416
- dataStoreMapSizeKB: aztecNodeConfig.dataStoreMapSizeKB,
409
+ dataStoreMapSizeKb: aztecNodeConfig.dataStoreMapSizeKb,
417
410
  },
418
411
  telemetry,
419
412
  );
@@ -432,20 +425,23 @@ async function setupFromFresh(
432
425
  proverNode = await createAndSyncProverNode(
433
426
  `0x${proverNodePrivateKey!.toString('hex')}`,
434
427
  aztecNodeConfig,
435
- { dataDirectory: path.join(directoryToCleanup, randomBytes(8).toString('hex')), p2pEnabled: false },
428
+ {
429
+ ...aztecNodeConfig.proverNodeConfig,
430
+ dataDirectory: path.join(directoryToCleanup, randomBytes(8).toString('hex')),
431
+ p2pEnabled: false,
432
+ },
436
433
  aztecNode,
437
434
  prefilledPublicData,
438
435
  );
439
436
  }
440
437
 
441
438
  logger.verbose('Creating pxe...');
442
- const pxeConfig = getPXEServiceConfig();
439
+ const pxeConfig = getPXEConfig();
443
440
  pxeConfig.dataDirectory = statePath ?? path.join(directoryToCleanup, randomBytes(8).toString('hex'));
444
441
  // Only enable proving if specifically requested.
445
442
  pxeConfig.proverEnabled = !!opts.realProofs;
446
- const pxe = await createPXEService(aztecNode, pxeConfig);
447
-
448
- const cheatCodes = await CheatCodes.create(aztecNodeConfig.l1RpcUrls, pxe);
443
+ const wallet = await TestWallet.create(aztecNode, pxeConfig);
444
+ const cheatCodes = await CheatCodes.create(aztecNodeConfig.l1RpcUrls, aztecNode, dateProvider);
449
445
 
450
446
  if (statePath) {
451
447
  writeFileSync(`${statePath}/aztec_node_config.json`, JSON.stringify(aztecNodeConfig, resolver));
@@ -456,7 +452,7 @@ async function setupFromFresh(
456
452
  aztecNodeConfig,
457
453
  anvil,
458
454
  aztecNode,
459
- pxe,
455
+ wallet,
460
456
  sequencer: aztecNode.getSequencer()!,
461
457
  acvmConfig,
462
458
  bbConfig,
@@ -501,7 +497,9 @@ async function setupFromState(statePath: string, logger: Logger): Promise<Subsys
501
497
  aztecNodeConfig.l1RpcUrls = [rpcUrl];
502
498
  // Load anvil state.
503
499
  const anvilStateFile = `${statePath}/anvil.dat`;
504
- const ethCheatCodes = new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrls);
500
+
501
+ const dateProvider = new TestDateProvider();
502
+ const ethCheatCodes = new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrls, dateProvider);
505
503
  await ethCheatCodes.loadChainState(anvilStateFile);
506
504
 
507
505
  // TODO: Encapsulate this in a NativeAcvm impl.
@@ -520,9 +518,8 @@ async function setupFromState(statePath: string, logger: Logger): Promise<Subsys
520
518
  logger.verbose('Creating ETH clients...');
521
519
  const l1Client = createExtendedL1Client(aztecNodeConfig.l1RpcUrls, mnemonicToAccount(MNEMONIC));
522
520
 
523
- const dateProvider = new TestDateProvider();
524
521
  const watcher = new AnvilTestWatcher(
525
- new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrls),
522
+ ethCheatCodes,
526
523
  aztecNodeConfig.l1Contracts.rollupAddress,
527
524
  l1Client,
528
525
  dateProvider,
@@ -537,7 +534,7 @@ async function setupFromState(statePath: string, logger: Logger): Promise<Subsys
537
534
  l1Contracts: aztecNodeConfig.l1Contracts,
538
535
  port: blobSinkPort,
539
536
  dataDirectory: statePath,
540
- dataStoreMapSizeKB: aztecNodeConfig.dataStoreMapSizeKB,
537
+ dataStoreMapSizeKb: aztecNodeConfig.dataStoreMapSizeKb,
541
538
  },
542
539
  telemetry,
543
540
  );
@@ -558,24 +555,27 @@ async function setupFromState(statePath: string, logger: Logger): Promise<Subsys
558
555
  proverNode = await createAndSyncProverNode(
559
556
  proverNodePrivateKeyHex,
560
557
  aztecNodeConfig,
561
- { dataDirectory: path.join(directoryToCleanup, randomBytes(8).toString('hex')) },
558
+ {
559
+ ...aztecNodeConfig.proverNodeConfig,
560
+ dataDirectory: path.join(directoryToCleanup, randomBytes(8).toString('hex')),
561
+ p2pEnabled: false,
562
+ },
562
563
  aztecNode,
563
564
  prefilledPublicData,
564
565
  );
565
566
  }
566
567
 
567
568
  logger.verbose('Creating pxe...');
568
- const pxeConfig = getPXEServiceConfig();
569
+ const pxeConfig = getPXEConfig();
569
570
  pxeConfig.dataDirectory = statePath;
570
- const pxe = await createPXEService(aztecNode, pxeConfig);
571
-
572
- const cheatCodes = await CheatCodes.create(aztecNodeConfig.l1RpcUrls, pxe);
571
+ const wallet = await TestWallet.create(aztecNode, pxeConfig);
572
+ const cheatCodes = await CheatCodes.create(aztecNodeConfig.l1RpcUrls, aztecNode, dateProvider);
573
573
 
574
574
  return {
575
575
  aztecNodeConfig,
576
576
  anvil,
577
577
  aztecNode,
578
- pxe,
578
+ wallet,
579
579
  sequencer: aztecNode.getSequencer()!,
580
580
  acvmConfig,
581
581
  bbConfig,
@@ -599,20 +599,29 @@ async function setupFromState(statePath: string, logger: Logger): Promise<Subsys
599
599
  * The 'restore' function is not provided, as it must be a closure within the test context to capture the results.
600
600
  */
601
601
  export const deployAccounts =
602
- (numberOfAccounts: number, logger: Logger, waitUntilProven = false) =>
603
- async ({ pxe, initialFundedAccounts }: { pxe: PXE; initialFundedAccounts: InitialAccountData[] }) => {
602
+ (numberOfAccounts: number, logger: Logger) =>
603
+ async ({ wallet, initialFundedAccounts }: { wallet: TestWallet; initialFundedAccounts: InitialAccountData[] }) => {
604
604
  if (initialFundedAccounts.length < numberOfAccounts) {
605
605
  throw new Error(`Cannot deploy more than ${initialFundedAccounts.length} initial accounts.`);
606
606
  }
607
607
 
608
608
  logger.verbose('Deploying accounts funded with fee juice...');
609
609
  const deployedAccounts = initialFundedAccounts.slice(0, numberOfAccounts);
610
- await deployFundedSchnorrAccounts(
611
- pxe,
612
- deployedAccounts,
613
- undefined,
614
- waitUntilProven ? DefaultWaitForProvenOpts : undefined,
615
- );
610
+ // Serial due to https://github.com/AztecProtocol/aztec-packages/issues/12045
611
+ for (let i = 0; i < deployedAccounts.length; i++) {
612
+ const accountManager = await wallet.createSchnorrAccount(
613
+ deployedAccounts[i].secret,
614
+ deployedAccounts[i].salt,
615
+ deployedAccounts[i].signingKey,
616
+ );
617
+ const deployMethod = await accountManager.getDeployMethod();
618
+ await deployMethod
619
+ .send({
620
+ from: AztecAddress.ZERO,
621
+ skipClassPublication: i !== 0, // Publish the contract class at most once.
622
+ })
623
+ .wait();
624
+ }
616
625
 
617
626
  return { deployedAccounts };
618
627
  };
@@ -623,35 +632,34 @@ export const deployAccounts =
623
632
  * @param sender - Wallet to send the deployment tx.
624
633
  * @param accountsToDeploy - Which accounts to publicly deploy.
625
634
  * @param waitUntilProven - Whether to wait for the tx to be proven.
626
- * @param pxeOrNode - PXE or AztecNode to wait for proven.
635
+ * @param node - AztecNode used to wait for proven tx.
627
636
  */
628
637
  export async function publicDeployAccounts(
629
- sender: Wallet,
630
- accountsToDeploy: (CompleteAddress | AztecAddress)[],
638
+ wallet: Wallet,
639
+ accountsToDeploy: AztecAddress[],
631
640
  waitUntilProven = false,
632
- pxeOrNode?: PXE | AztecNode,
641
+ node?: AztecNode,
633
642
  ) {
634
- const accountAddressesToDeploy = accountsToDeploy.map(a => ('address' in a ? a.address : a));
635
- const instances = (
636
- await Promise.all(accountAddressesToDeploy.map(account => sender.getContractMetadata(account)))
637
- ).map(metadata => metadata.contractInstance);
643
+ const instances = (await Promise.all(accountsToDeploy.map(account => wallet.getContractMetadata(account)))).map(
644
+ metadata => metadata.contractInstance,
645
+ );
638
646
 
639
647
  const contractClass = await getContractClassFromArtifact(SchnorrAccountContractArtifact);
640
- const alreadyRegistered = (await sender.getContractClassMetadata(contractClass.id)).isContractClassPubliclyRegistered;
648
+ const alreadyRegistered = (await wallet.getContractClassMetadata(contractClass.id)).isContractClassPubliclyRegistered;
641
649
 
642
650
  const calls: ContractFunctionInteraction[] = await Promise.all([
643
- ...(!alreadyRegistered ? [publishContractClass(sender, SchnorrAccountContractArtifact)] : []),
644
- ...instances.map(instance => publishInstance(sender, instance!)),
651
+ ...(!alreadyRegistered ? [publishContractClass(wallet, SchnorrAccountContractArtifact)] : []),
652
+ ...instances.map(instance => publishInstance(wallet, instance!)),
645
653
  ]);
646
654
 
647
- const batch = new BatchCall(sender, calls);
655
+ const batch = new BatchCall(wallet, calls);
648
656
 
649
- const txReceipt = await batch.send({ from: accountAddressesToDeploy[0] }).wait();
657
+ const txReceipt = await batch.send({ from: accountsToDeploy[0] }).wait();
650
658
  if (waitUntilProven) {
651
- if (!pxeOrNode) {
652
- throw new Error('Need to provide a PXE or AztecNode to wait for proven.');
659
+ if (!node) {
660
+ throw new Error('Need to provide an AztecNode to wait for proven.');
653
661
  } else {
654
- await waitForProven(pxeOrNode, txReceipt);
662
+ await waitForProven(node, txReceipt);
655
663
  }
656
664
  }
657
665
  }
@@ -1,22 +1,17 @@
1
- import { type AztecAddress, BatchCall, type Logger, type Wallet } from '@aztec/aztec.js';
1
+ import type { AztecAddress } from '@aztec/aztec.js/addresses';
2
+ import { BatchCall } from '@aztec/aztec.js/contracts';
3
+ import type { Logger } from '@aztec/aztec.js/log';
4
+ import type { Wallet } from '@aztec/aztec.js/wallet';
2
5
  import { TokenContract } from '@aztec/noir-contracts.js/Token';
3
6
 
4
- // docs:start:token_utils
5
-
6
- export async function deployToken(
7
- adminWallet: Wallet,
8
- deployerAddress: AztecAddress,
9
- initialAdminBalance: bigint,
10
- logger: Logger,
11
- ) {
7
+ export async function deployToken(wallet: Wallet, admin: AztecAddress, initialAdminBalance: bigint, logger: Logger) {
12
8
  logger.info(`Deploying Token contract...`);
13
- const contract = await TokenContract.deploy(adminWallet, deployerAddress, 'TokenName', 'TokenSymbol', 18)
14
- .send({ from: deployerAddress })
9
+ const contract = await TokenContract.deploy(wallet, admin, 'TokenName', 'TokenSymbol', 18)
10
+ .send({ from: admin })
15
11
  .deployed();
16
12
 
17
13
  if (initialAdminBalance > 0n) {
18
- // Minter is minting to herself so contract as minter is the same as contract as recipient
19
- await mintTokensToPrivate(contract, deployerAddress, adminWallet, deployerAddress, initialAdminBalance);
14
+ await mintTokensToPrivate(contract, admin, admin, initialAdminBalance);
20
15
  }
21
16
 
22
17
  logger.info('L2 contract deployed');
@@ -27,14 +22,11 @@ export async function deployToken(
27
22
  export async function mintTokensToPrivate(
28
23
  token: TokenContract,
29
24
  minter: AztecAddress,
30
- minterWallet: Wallet,
31
25
  recipient: AztecAddress,
32
26
  amount: bigint,
33
27
  ) {
34
- const tokenAsMinter = await TokenContract.at(token.address, minterWallet);
35
- await tokenAsMinter.methods.mint_to_private(recipient, amount).send({ from: minter }).wait();
28
+ await token.methods.mint_to_private(recipient, amount).send({ from: minter }).wait();
36
29
  }
37
- // docs:end:token_utils
38
30
 
39
31
  export async function expectTokenBalance(
40
32
  wallet: Wallet,
@@ -51,19 +43,19 @@ export async function expectTokenBalance(
51
43
  }
52
44
 
53
45
  export async function mintNotes(
54
- sender: Wallet,
46
+ wallet: Wallet,
55
47
  minter: AztecAddress,
56
48
  recipient: AztecAddress,
57
49
  asset: TokenContract,
58
50
  noteAmounts: bigint[],
59
51
  ): Promise<bigint> {
60
- // We can only mint 4 notes at a time, since that's the maximum number of calls our entrypoints allow
52
+ // We can only mint 5 notes at a time, since that's the maximum number of calls our entrypoints allow
61
53
  // TODO(#13024): mint as many notes as possible in a single tx
62
- const notesPerIteration = 4;
54
+ const notesPerIteration = 5;
63
55
  for (let mintedNotes = 0; mintedNotes < noteAmounts.length; mintedNotes += notesPerIteration) {
64
56
  const toMint = noteAmounts.slice(mintedNotes, mintedNotes + notesPerIteration);
65
57
  const actions = toMint.map(amt => asset.methods.mint_to_private(recipient, amt));
66
- await new BatchCall(sender, actions).send({ from: minter }).wait();
58
+ await new BatchCall(wallet, actions).send({ from: minter }).wait();
67
59
  }
68
60
 
69
61
  return noteAmounts.reduce((prev, curr) => prev + curr, 0n);