@aztec/end-to-end 3.0.0-canary.a9708bd → 3.0.0-manual.20251030

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 (139) 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/benchmark.js +2 -2
  4. package/dest/bench/client_flows/client_flows_benchmark.d.ts +16 -12
  5. package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
  6. package/dest/bench/client_flows/client_flows_benchmark.js +54 -58
  7. package/dest/bench/client_flows/data_extractor.js +3 -3
  8. package/dest/bench/utils.d.ts +2 -11
  9. package/dest/bench/utils.d.ts.map +1 -1
  10. package/dest/bench/utils.js +10 -34
  11. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +7 -7
  12. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +1 -1
  13. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.js +42 -42
  14. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +10 -8
  15. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts.map +1 -1
  16. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.js +31 -33
  17. package/dest/e2e_deploy_contract/deploy_test.d.ts +10 -4
  18. package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -1
  19. package/dest/e2e_deploy_contract/deploy_test.js +9 -18
  20. package/dest/e2e_epochs/epochs_test.d.ts +9 -3
  21. package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
  22. package/dest/e2e_epochs/epochs_test.js +19 -13
  23. package/dest/e2e_fees/bridging_race.notest.js +12 -9
  24. package/dest/e2e_fees/fees_test.d.ts +5 -5
  25. package/dest/e2e_fees/fees_test.d.ts.map +1 -1
  26. package/dest/e2e_fees/fees_test.js +26 -33
  27. package/dest/e2e_l1_publisher/write_json.d.ts +3 -1
  28. package/dest/e2e_l1_publisher/write_json.d.ts.map +1 -1
  29. package/dest/e2e_l1_publisher/write_json.js +5 -5
  30. package/dest/e2e_multi_validator/utils.d.ts +1 -1
  31. package/dest/e2e_multi_validator/utils.d.ts.map +1 -1
  32. package/dest/e2e_multi_validator/utils.js +3 -9
  33. package/dest/e2e_nested_contract/nested_contract_test.d.ts +6 -3
  34. package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
  35. package/dest/e2e_nested_contract/nested_contract_test.js +7 -9
  36. package/dest/e2e_p2p/inactivity_slash_test.d.ts +31 -0
  37. package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +1 -0
  38. package/dest/e2e_p2p/inactivity_slash_test.js +135 -0
  39. package/dest/e2e_p2p/p2p_network.d.ts +22 -8
  40. package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
  41. package/dest/e2e_p2p/p2p_network.js +36 -15
  42. package/dest/e2e_p2p/shared.d.ts +12 -13
  43. package/dest/e2e_p2p/shared.d.ts.map +1 -1
  44. package/dest/e2e_p2p/shared.js +54 -54
  45. package/dest/e2e_token_contract/token_contract_test.d.ts +5 -4
  46. package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
  47. package/dest/e2e_token_contract/token_contract_test.js +14 -17
  48. package/dest/fixtures/e2e_prover_test.d.ts +8 -6
  49. package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
  50. package/dest/fixtures/e2e_prover_test.js +42 -51
  51. package/dest/fixtures/get_acvm_config.d.ts +1 -1
  52. package/dest/fixtures/get_acvm_config.d.ts.map +1 -1
  53. package/dest/fixtures/get_bb_config.d.ts +1 -1
  54. package/dest/fixtures/get_bb_config.d.ts.map +1 -1
  55. package/dest/fixtures/get_bb_config.js +2 -2
  56. package/dest/fixtures/setup_l1_contracts.d.ts +1 -1
  57. package/dest/fixtures/setup_l1_contracts.d.ts.map +1 -1
  58. package/dest/fixtures/setup_l1_contracts.js +2 -2
  59. package/dest/fixtures/setup_p2p_test.d.ts +10 -9
  60. package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
  61. package/dest/fixtures/setup_p2p_test.js +38 -20
  62. package/dest/fixtures/snapshot_manager.d.ts +10 -7
  63. package/dest/fixtures/snapshot_manager.d.ts.map +1 -1
  64. package/dest/fixtures/snapshot_manager.js +60 -47
  65. package/dest/fixtures/token_utils.d.ts +6 -4
  66. package/dest/fixtures/token_utils.d.ts.map +1 -1
  67. package/dest/fixtures/token_utils.js +11 -15
  68. package/dest/fixtures/utils.d.ts +26 -28
  69. package/dest/fixtures/utils.d.ts.map +1 -1
  70. package/dest/fixtures/utils.js +83 -109
  71. package/dest/fixtures/web3signer.d.ts +5 -0
  72. package/dest/fixtures/web3signer.d.ts.map +1 -0
  73. package/dest/fixtures/web3signer.js +53 -0
  74. package/dest/quality_of_service/alert_checker.d.ts +1 -1
  75. package/dest/quality_of_service/alert_checker.d.ts.map +1 -1
  76. package/dest/shared/cross_chain_test_harness.d.ts +16 -10
  77. package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
  78. package/dest/shared/cross_chain_test_harness.js +13 -15
  79. package/dest/shared/gas_portal_test_harness.d.ts +9 -6
  80. package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
  81. package/dest/shared/gas_portal_test_harness.js +10 -7
  82. package/dest/shared/jest_setup.js +1 -1
  83. package/dest/shared/submit-transactions.d.ts +5 -3
  84. package/dest/shared/submit-transactions.d.ts.map +1 -1
  85. package/dest/shared/submit-transactions.js +8 -7
  86. package/dest/shared/uniswap_l1_l2.d.ts +9 -6
  87. package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
  88. package/dest/shared/uniswap_l1_l2.js +29 -45
  89. package/dest/simulators/lending_simulator.d.ts +2 -1
  90. package/dest/simulators/lending_simulator.d.ts.map +1 -1
  91. package/dest/simulators/lending_simulator.js +3 -2
  92. package/dest/simulators/token_simulator.d.ts +3 -1
  93. package/dest/simulators/token_simulator.d.ts.map +1 -1
  94. package/dest/simulators/token_simulator.js +2 -2
  95. package/dest/spartan/setup_test_wallets.d.ts +19 -13
  96. package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
  97. package/dest/spartan/setup_test_wallets.js +108 -85
  98. package/dest/spartan/utils.d.ts +68 -3
  99. package/dest/spartan/utils.d.ts.map +1 -1
  100. package/dest/spartan/utils.js +312 -49
  101. package/package.json +39 -38
  102. package/src/bench/client_flows/benchmark.ts +8 -8
  103. package/src/bench/client_flows/client_flows_benchmark.ts +62 -82
  104. package/src/bench/client_flows/data_extractor.ts +4 -4
  105. package/src/bench/utils.ts +9 -37
  106. package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +46 -63
  107. package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +33 -47
  108. package/src/e2e_deploy_contract/deploy_test.ts +17 -35
  109. package/src/e2e_epochs/epochs_test.ts +22 -19
  110. package/src/e2e_fees/bridging_race.notest.ts +14 -9
  111. package/src/e2e_fees/fees_test.ts +29 -40
  112. package/src/e2e_l1_publisher/write_json.ts +8 -6
  113. package/src/e2e_multi_validator/utils.ts +4 -10
  114. package/src/e2e_nested_contract/nested_contract_test.ts +11 -10
  115. package/src/e2e_p2p/inactivity_slash_test.ts +178 -0
  116. package/src/e2e_p2p/p2p_network.ts +110 -71
  117. package/src/e2e_p2p/shared.ts +57 -56
  118. package/src/e2e_token_contract/token_contract_test.ts +17 -17
  119. package/src/fixtures/e2e_prover_test.ts +52 -88
  120. package/src/fixtures/get_acvm_config.ts +1 -1
  121. package/src/fixtures/get_bb_config.ts +3 -2
  122. package/src/fixtures/setup_l1_contracts.ts +3 -3
  123. package/src/fixtures/setup_p2p_test.ts +60 -27
  124. package/src/fixtures/snapshot_manager.ts +80 -72
  125. package/src/fixtures/token_utils.ts +13 -21
  126. package/src/fixtures/utils.ts +95 -145
  127. package/src/fixtures/web3signer.ts +63 -0
  128. package/src/guides/up_quick_start.sh +2 -10
  129. package/src/quality_of_service/alert_checker.ts +1 -1
  130. package/src/shared/cross_chain_test_harness.ts +18 -29
  131. package/src/shared/gas_portal_test_harness.ts +12 -19
  132. package/src/shared/jest_setup.ts +1 -1
  133. package/src/shared/submit-transactions.ts +12 -8
  134. package/src/shared/uniswap_l1_l2.ts +61 -67
  135. package/src/simulators/lending_simulator.ts +3 -2
  136. package/src/simulators/token_simulator.ts +5 -2
  137. package/src/spartan/DEVELOP.md +8 -3
  138. package/src/spartan/setup_test_wallets.ts +133 -126
  139. package/src/spartan/utils.ts +373 -48
@@ -1,31 +1,13 @@
1
1
  import { SchnorrAccountContractArtifact } from '@aztec/accounts/schnorr';
2
- import {
3
- type InitialAccountData,
4
- deployFundedSchnorrAccounts,
5
- generateSchnorrAccounts,
6
- getDeployedTestAccounts,
7
- getDeployedTestAccountsWallets,
8
- } from '@aztec/accounts/testing';
2
+ import { type InitialAccountData, generateSchnorrAccounts, getInitialTestAccountsData } from '@aztec/accounts/testing';
9
3
  import { type Archiver, createArchiver } from '@aztec/archiver';
10
4
  import { type AztecNodeConfig, AztecNodeService, getConfigEnvVars } from '@aztec/aztec-node';
11
- import {
12
- AccountManager,
13
- type AccountWalletWithSecretKey,
14
- type AztecAddress,
15
- type AztecNode,
16
- BatchCall,
17
- type ContractMethod,
18
- type Logger,
19
- type PXE,
20
- type Wallet,
21
- createAztecNodeClient,
22
- createLogger,
23
- createPXEClient,
24
- makeFetch,
25
- sleep,
26
- waitForPXE,
27
- } from '@aztec/aztec.js';
5
+ import { AztecAddress } from '@aztec/aztec.js/addresses';
6
+ import { BatchCall, type ContractMethod } from '@aztec/aztec.js/contracts';
28
7
  import { publishContractClass, publishInstance } from '@aztec/aztec.js/deployment';
8
+ import { type Logger, createLogger } from '@aztec/aztec.js/log';
9
+ import { type AztecNode, createAztecNodeClient, waitForNode } from '@aztec/aztec.js/node';
10
+ import type { Wallet } from '@aztec/aztec.js/wallet';
29
11
  import { AnvilTestWatcher, CheatCodes } from '@aztec/aztec/testing';
30
12
  import { createBlobSinkClient } from '@aztec/blob-sink/client';
31
13
  import { type BlobSinkServer, createBlobSinkServer } from '@aztec/blob-sink/server';
@@ -57,24 +39,18 @@ import { Fr } from '@aztec/foundation/fields';
57
39
  import { tryRmDir } from '@aztec/foundation/fs';
58
40
  import { withLogNameSuffix } from '@aztec/foundation/log';
59
41
  import { retryUntil } from '@aztec/foundation/retry';
42
+ import { sleep } from '@aztec/foundation/sleep';
60
43
  import { DateProvider, TestDateProvider } from '@aztec/foundation/timer';
61
44
  import type { DataStoreConfig } from '@aztec/kv-store/config';
62
45
  import { SponsoredFPCContract } from '@aztec/noir-contracts.js/SponsoredFPC';
63
46
  import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
64
47
  import type { P2PClientDeps } from '@aztec/p2p';
65
48
  import { MockGossipSubNetwork, getMockPubSubP2PServiceFactory } from '@aztec/p2p/test-helpers';
66
- import { protocolContractTreeRoot } from '@aztec/protocol-contracts';
49
+ import { protocolContractsHash } from '@aztec/protocol-contracts';
67
50
  import { type ProverNode, type ProverNodeConfig, type ProverNodeDeps, createProverNode } from '@aztec/prover-node';
68
- import {
69
- type PXEService,
70
- type PXEServiceConfig,
71
- createPXEServiceWithSimulator,
72
- getPXEServiceConfig,
73
- } from '@aztec/pxe/server';
51
+ import { type PXEConfig, getPXEConfig } from '@aztec/pxe/server';
74
52
  import type { SequencerClient } from '@aztec/sequencer-client';
75
53
  import type { TestSequencerClient } from '@aztec/sequencer-client/test';
76
- import { MemoryCircuitRecorder, SimulatorRecorderWrapper, WASMSimulator } from '@aztec/simulator/client';
77
- import { FileCircuitRecorder } from '@aztec/simulator/testing';
78
54
  import {
79
55
  type ContractInstanceWithAddress,
80
56
  getContractClassFromArtifact,
@@ -91,6 +67,7 @@ import {
91
67
  initTelemetryClient,
92
68
  } from '@aztec/telemetry-client';
93
69
  import { BenchmarkTelemetryClient } from '@aztec/telemetry-client/bench';
70
+ import { TestWallet, deployFundedSchnorrAccounts } from '@aztec/test-wallet/server';
94
71
  import { getGenesisValues } from '@aztec/world-state/testing';
95
72
 
96
73
  import type { Anvil } from '@viem/anvil';
@@ -110,8 +87,8 @@ import { isMetricsLoggingRequested, setupMetricsLogger } from './logging.js';
110
87
  export { deployAndInitializeTokenAndBridgeContracts } from '../shared/cross_chain_test_harness.js';
111
88
  export { startAnvil };
112
89
 
113
- const { PXE_URL = '' } = process.env;
114
- const getAztecUrl = () => PXE_URL;
90
+ const { AZTEC_NODE_URL = '' } = process.env;
91
+ const getAztecUrl = () => AZTEC_NODE_URL;
115
92
 
116
93
  let telemetry: TelemetryClient | undefined = undefined;
117
94
  function getTelemetryClient(partialConfig: Partial<TelemetryClientConfig> & { benchmark?: boolean } = {}) {
@@ -142,7 +119,7 @@ export const setupL1Contracts = async (
142
119
  ) => {
143
120
  const l1Data = await deployL1Contracts(l1RpcUrls, account, chain, logger, {
144
121
  vkTreeRoot: getVKTreeRoot(),
145
- protocolContractTreeRoot,
122
+ protocolContractsHash,
146
123
  genesisArchiveRoot: args.genesisArchiveRoot ?? new Fr(GENESIS_ARCHIVE_ROOT),
147
124
  salt: args.salt,
148
125
  initialValidators: args.initialValidators,
@@ -155,23 +132,23 @@ export const setupL1Contracts = async (
155
132
  };
156
133
 
157
134
  /**
158
- * Sets up Private eXecution Environment (PXE).
135
+ * Sets up Private eXecution Environment (PXE) and returns the corresponding test wallet.
159
136
  * @param aztecNode - An instance of Aztec Node.
160
- * @param opts - Partial configuration for the PXE service.
137
+ * @param opts - Partial configuration for the PXE.
161
138
  * @param logger - The logger to be used.
162
139
  * @param useLogSuffix - Whether to add a randomly generated suffix to the PXE debug logs.
163
- * @returns Private eXecution Environment (PXE), logger and teardown function.
140
+ * @returns A test wallet, logger and teardown function.
164
141
  */
165
- export async function setupPXEService(
142
+ export async function setupPXEAndGetWallet(
166
143
  aztecNode: AztecNode,
167
- opts: Partial<PXEServiceConfig> = {},
144
+ opts: Partial<PXEConfig> = {},
168
145
  logger = getLogger(),
169
146
  useLogSuffix = false,
170
147
  ): Promise<{
171
148
  /**
172
- * The PXE instance.
149
+ * The wallet instance.
173
150
  */
174
- pxe: PXEService;
151
+ wallet: TestWallet;
175
152
  /**
176
153
  * Logger instance named as the current test.
177
154
  */
@@ -181,29 +158,24 @@ export async function setupPXEService(
181
158
  */
182
159
  teardown: () => Promise<void>;
183
160
  }> {
184
- const pxeServiceConfig = { ...getPXEServiceConfig(), ...opts };
161
+ const PXEConfig = { ...getPXEConfig(), ...opts };
185
162
  // For tests we only want proving enabled if specifically requested
186
- pxeServiceConfig.proverEnabled = !!opts.proverEnabled;
163
+ PXEConfig.proverEnabled = !!opts.proverEnabled;
187
164
 
188
165
  // If no data directory provided, create a temp directory and clean up afterwards
189
- const configuredDataDirectory = pxeServiceConfig.dataDirectory;
166
+ const configuredDataDirectory = PXEConfig.dataDirectory;
190
167
  if (!configuredDataDirectory) {
191
- pxeServiceConfig.dataDirectory = path.join(tmpdir(), randomBytes(8).toString('hex'));
168
+ PXEConfig.dataDirectory = path.join(tmpdir(), randomBytes(8).toString('hex'));
192
169
  }
193
170
 
194
- const simulator = new WASMSimulator();
195
- const recorder = process.env.CIRCUIT_RECORD_DIR
196
- ? new FileCircuitRecorder(process.env.CIRCUIT_RECORD_DIR)
197
- : new MemoryCircuitRecorder();
198
- const simulatorWithRecorder = new SimulatorRecorderWrapper(simulator, recorder);
199
- const pxe = await createPXEServiceWithSimulator(aztecNode, simulatorWithRecorder, pxeServiceConfig, {
171
+ const teardown = configuredDataDirectory ? () => Promise.resolve() : () => tryRmDir(PXEConfig.dataDirectory!);
172
+
173
+ const wallet = await TestWallet.create(aztecNode, PXEConfig, {
200
174
  useLogSuffix,
201
175
  });
202
176
 
203
- const teardown = configuredDataDirectory ? () => Promise.resolve() : () => tryRmDir(pxeServiceConfig.dataDirectory!);
204
-
205
177
  return {
206
- pxe,
178
+ wallet,
207
179
  logger,
208
180
  teardown,
209
181
  };
@@ -228,12 +200,10 @@ async function setupWithRemoteEnvironment(
228
200
  const aztecNodeUrl = getAztecUrl();
229
201
  logger.verbose(`Creating Aztec Node client to remote host ${aztecNodeUrl}`);
230
202
  const aztecNode = createAztecNodeClient(aztecNodeUrl);
231
- logger.verbose(`Creating PXE client to remote host ${PXE_URL}`);
232
- const pxeClient = createPXEClient(PXE_URL, {}, makeFetch([1, 2, 3], true));
233
- await waitForPXE(pxeClient, logger);
234
- logger.verbose('JSON RPC client connected to PXE');
235
- logger.verbose(`Retrieving contract addresses from ${PXE_URL}`);
236
- const { l1ContractAddresses, rollupVersion } = await pxeClient.getNodeInfo();
203
+ await waitForNode(aztecNode, logger);
204
+ logger.verbose('JSON RPC client connected to Aztec Node');
205
+ logger.verbose(`Retrieving contract addresses from ${aztecNodeUrl}`);
206
+ const { l1ContractAddresses, rollupVersion } = await aztecNode.getNodeInfo();
237
207
 
238
208
  const l1Client = createExtendedL1Client(config.l1RpcUrls, account, foundry);
239
209
 
@@ -242,31 +212,36 @@ async function setupWithRemoteEnvironment(
242
212
  l1Client,
243
213
  rollupVersion,
244
214
  };
245
- const ethCheatCodes = new EthCheatCodes(config.l1RpcUrls);
246
- const cheatCodes = await CheatCodes.create(config.l1RpcUrls, pxeClient!);
215
+ const ethCheatCodes = new EthCheatCodes(config.l1RpcUrls, new DateProvider());
216
+ const wallet = await TestWallet.create(aztecNode);
217
+ const cheatCodes = await CheatCodes.create(config.l1RpcUrls, aztecNode, new DateProvider());
247
218
  const teardown = () => Promise.resolve();
248
219
 
249
- logger.verbose('Constructing available wallets from already registered accounts...');
250
- const initialFundedAccounts = await getDeployedTestAccounts(pxeClient);
251
- const wallets = await getDeployedTestAccountsWallets(pxeClient);
220
+ logger.verbose('Populating wallet from already registered accounts...');
221
+ const initialFundedAccounts = await getInitialTestAccountsData();
252
222
 
253
- if (wallets.length < numberOfAccounts) {
254
- throw new Error(`Required ${numberOfAccounts} accounts. Found ${wallets.length}.`);
223
+ if (initialFundedAccounts.length < numberOfAccounts) {
224
+ throw new Error(`Required ${numberOfAccounts} accounts. Found ${initialFundedAccounts.length}.`);
255
225
  // Deploy new accounts if there's a test that requires more funded accounts in the remote environment.
256
226
  }
257
227
 
228
+ const testAccounts = await Promise.all(
229
+ initialFundedAccounts.slice(0, numberOfAccounts).map(async account => {
230
+ const accountManager = await wallet.createSchnorrAccount(account.secret, account.salt, account.signingKey);
231
+ return accountManager.address;
232
+ }),
233
+ );
234
+
258
235
  return {
259
236
  aztecNode,
260
237
  aztecNodeAdmin: undefined,
261
238
  sequencer: undefined,
262
239
  proverNode: undefined,
263
- pxe: pxeClient,
264
240
  deployL1ContractsValues,
265
241
  config,
266
242
  initialFundedAccounts,
267
- wallets,
268
- wallet: wallets[0],
269
- accounts: wallets.slice(0, numberOfAccounts).map(w => w.getAddress()),
243
+ wallet,
244
+ accounts: testAccounts,
270
245
  logger,
271
246
  cheatCodes,
272
247
  ethCheatCodes,
@@ -338,19 +313,15 @@ export type EndToEndContext = {
338
313
  proverNode: ProverNode | undefined;
339
314
  /** A client to the sequencer service (undefined if connected to remote environment) */
340
315
  sequencer: SequencerClient | undefined;
341
- /** The Private eXecution Environment (PXE). */
342
- pxe: PXE;
343
316
  /** Return values from deployL1Contracts function. */
344
317
  deployL1ContractsValues: DeployL1ContractsReturnType;
345
318
  /** The Aztec Node configuration. */
346
319
  config: AztecNodeConfig;
347
320
  /** The data for the initial funded accounts. */
348
321
  initialFundedAccounts: InitialAccountData[];
349
- /* Wallets created for the initial funded accounts, with secret keys. */
350
- wallets: AccountWalletWithSecretKey[];
351
- /** The first wallet to be used. */
352
- wallet: AccountWalletWithSecretKey;
353
- /** The accounts to be used. */
322
+ /** The wallet to be used. */
323
+ wallet: TestWallet;
324
+ /** The wallets to be used. */
354
325
  accounts: AztecAddress[];
355
326
  /** Logger instance named as the current test. */
356
327
  logger: Logger;
@@ -382,10 +353,8 @@ export type EndToEndContext = {
382
353
  */
383
354
  export async function setup(
384
355
  numberOfAccounts = 1,
385
- opts: SetupOptions = {
386
- customForwarderContractAddress: EthAddress.ZERO,
387
- },
388
- pxeOpts: Partial<PXEServiceConfig> = {},
356
+ opts: SetupOptions = {},
357
+ pxeOpts: Partial<PXEConfig> = {},
389
358
  chain: Chain = foundry,
390
359
  ): Promise<EndToEndContext> {
391
360
  let anvil: Anvil | undefined;
@@ -416,9 +385,9 @@ export async function setup(
416
385
  if (!isAnvilTestChain(chain.id)) {
417
386
  throw new Error(`No ETHEREUM_HOSTS set but non anvil chain requested`);
418
387
  }
419
- if (PXE_URL) {
388
+ if (AZTEC_NODE_URL) {
420
389
  throw new Error(
421
- `PXE_URL provided but no ETHEREUM_HOSTS set. Refusing to run, please set both variables so tests can deploy L1 contracts to the same Anvil instance`,
390
+ `AZTEC_NODE_URL provided but no ETHEREUM_HOSTS set. Refusing to run, please set both variables so tests can deploy L1 contracts to the same Anvil instance`,
422
391
  );
423
392
  }
424
393
 
@@ -438,7 +407,8 @@ export async function setup(
438
407
  setupMetricsLogger(filename);
439
408
  }
440
409
 
441
- const ethCheatCodes = new EthCheatCodesWithState(config.l1RpcUrls);
410
+ const dateProvider = new TestDateProvider();
411
+ const ethCheatCodes = new EthCheatCodesWithState(config.l1RpcUrls, dateProvider);
442
412
 
443
413
  if (opts.stateLoad) {
444
414
  await ethCheatCodes.loadChainState(opts.stateLoad);
@@ -470,7 +440,7 @@ export async function setup(
470
440
 
471
441
  config.coinbase = EthAddress.fromString(publisherHdAccount.address);
472
442
 
473
- if (PXE_URL) {
443
+ if (AZTEC_NODE_URL) {
474
444
  // we are setting up against a remote environment, l1 contracts are assumed to already be deployed
475
445
  return await setupWithRemoteEnvironment(publisherHdAccount!, config, logger, numberOfAccounts);
476
446
  }
@@ -539,6 +509,7 @@ export async function setup(
539
509
  if (enableAutomine) {
540
510
  await ethCheatCodes.setAutomine(false);
541
511
  await ethCheatCodes.setIntervalMining(config.ethereumSlotDuration);
512
+ dateProvider.setTime((await ethCheatCodes.timestamp()) * 1000);
542
513
  }
543
514
 
544
515
  if (opts.l2StartTime) {
@@ -547,11 +518,8 @@ export async function setup(
547
518
  await ethCheatCodes.warp(opts.l2StartTime, { resetBlockInterval: true });
548
519
  }
549
520
 
550
- const dateProvider = new TestDateProvider();
551
- dateProvider.setTime((await ethCheatCodes.timestamp()) * 1000);
552
-
553
521
  const watcher = new AnvilTestWatcher(
554
- new EthCheatCodesWithState(config.l1RpcUrls),
522
+ new EthCheatCodesWithState(config.l1RpcUrls, dateProvider),
555
523
  deployL1ContractsValues.l1ContractAddresses.rollupAddress,
556
524
  deployL1ContractsValues.l1Client,
557
525
  dateProvider,
@@ -571,14 +539,14 @@ export async function setup(
571
539
  l1Contracts: config.l1Contracts,
572
540
  port: blobSinkPort,
573
541
  dataDirectory: config.dataDirectory,
574
- dataStoreMapSizeKB: config.dataStoreMapSizeKB,
542
+ dataStoreMapSizeKb: config.dataStoreMapSizeKb,
575
543
  },
576
544
  telemetry,
577
545
  );
578
546
  await blobSink.start();
579
547
  config.blobSinkUrl = `http://localhost:${blobSinkPort}`;
580
548
 
581
- logger.verbose('Creating and synching an aztec node...');
549
+ logger.verbose('Creating and synching an aztec node', config);
582
550
 
583
551
  const acvmConfig = await getACVMConfig(logger);
584
552
  if (acvmConfig) {
@@ -591,7 +559,6 @@ export async function setup(
591
559
  config.bbBinaryPath = bbConfig.bbBinaryPath;
592
560
  config.bbWorkingDirectory = bbConfig.bbWorkingDirectory;
593
561
  }
594
- config.l1PublishRetryIntervalMS = 100;
595
562
 
596
563
  const blobSinkClient = createBlobSinkClient(config, { logger: createLogger('node:blob-sink:client') });
597
564
 
@@ -660,39 +627,38 @@ export async function setup(
660
627
  }
661
628
 
662
629
  logger.verbose('Creating a pxe...');
663
- const { pxe, teardown: pxeTeardown } = await setupPXEService(aztecNode!, pxeOpts, logger);
630
+ const { wallet, teardown: pxeTeardown } = await setupPXEAndGetWallet(aztecNode!, pxeOpts, logger);
664
631
 
665
- const cheatCodes = await CheatCodes.create(config.l1RpcUrls, pxe!);
632
+ const cheatCodes = await CheatCodes.create(config.l1RpcUrls, aztecNode, dateProvider);
666
633
 
667
634
  if (
668
635
  (opts.aztecTargetCommitteeSize && opts.aztecTargetCommitteeSize > 0) ||
669
636
  (opts.initialValidators && opts.initialValidators.length > 0)
670
637
  ) {
671
- // We need to advance to epoch 2 such that the committee is set up.
672
- logger.info(`Advancing to epoch 2`);
673
- await cheatCodes.rollup.advanceToEpoch(2n, { updateDateProvider: dateProvider });
638
+ // We need to advance such that the committee is set up.
639
+ await cheatCodes.rollup.advanceToEpoch((await cheatCodes.rollup.getEpoch()) + BigInt(config.lagInEpochs + 1));
674
640
  await cheatCodes.rollup.setupEpoch();
675
641
  await cheatCodes.rollup.debugRollup();
676
642
  }
677
-
643
+ let accounts: AztecAddress[] = [];
678
644
  // Below we continue with what we described in the long comment on line 571.
679
- let accountManagers: AccountManager[] = [];
680
645
  if (numberOfAccounts === 0) {
681
646
  logger.info('No accounts are being deployed, waiting for an empty block 1 to be mined');
682
- while ((await pxe.getBlockNumber()) === 0) {
647
+ while ((await aztecNode.getBlockNumber()) === 0) {
683
648
  await sleep(2000);
684
649
  }
685
650
  } else {
686
651
  logger.info(
687
652
  `${numberOfAccounts} accounts are being deployed. Reliably progressing past genesis by setting minTxsPerBlock to 1 and waiting for the accounts to be deployed`,
688
653
  );
689
- accountManagers = await deployFundedSchnorrAccounts(pxe, initialFundedAccounts.slice(0, numberOfAccounts));
654
+ const accountsData = initialFundedAccounts.slice(0, numberOfAccounts);
655
+ const accountManagers = await deployFundedSchnorrAccounts(wallet, aztecNode, accountsData);
656
+ accounts = accountManagers.map(accountManager => accountManager.address);
690
657
  }
691
658
 
692
659
  // Now we restore the original minTxsPerBlock setting.
693
660
  sequencerClient!.getSequencer().updateConfig({ minTxsPerBlock: originalMinTxsPerBlock });
694
661
 
695
- const wallets = await Promise.all(accountManagers.map(account => account.getWallet()));
696
662
  if (initialFundedAccounts.length < numberOfAccounts) {
697
663
  // TODO: Create (numberOfAccounts - initialFundedAccounts.length) wallets without funds.
698
664
  throw new Error(
@@ -739,13 +705,11 @@ export async function setup(
739
705
  mockGossipSubNetwork,
740
706
  prefilledPublicData,
741
707
  proverNode,
742
- pxe,
743
708
  sequencer: sequencerClient,
744
709
  teardown,
745
710
  telemetryClient: telemetry,
746
- wallets,
747
- wallet: wallets[0],
748
- accounts: wallets.map(w => w.getAddress()),
711
+ wallet,
712
+ accounts,
749
713
  watcher,
750
714
  };
751
715
  } catch (err) {
@@ -762,16 +726,14 @@ export async function setup(
762
726
  * @param accountsToDeploy - Which accounts to publicly deploy.
763
727
  */
764
728
 
765
- // docs:start:public_deploy_accounts
766
- export async function ensureAccountContractsPublished(sender: Wallet, accountsToDeploy: Wallet[]) {
729
+ export async function ensureAccountContractsPublished(wallet: Wallet, accountsToDeploy: AztecAddress[]) {
767
730
  // We have to check whether the accounts are already deployed. This can happen if the test runs against
768
731
  // the sandbox and the test accounts exist
769
732
  const accountsAndAddresses = await Promise.all(
770
- accountsToDeploy.map(async account => {
771
- const address = account.getAddress();
733
+ accountsToDeploy.map(async address => {
772
734
  return {
773
735
  address,
774
- deployed: (await sender.getContractMetadata(address)).isContractPublished,
736
+ deployed: (await wallet.getContractMetadata(address)).isContractPublished,
775
737
  };
776
738
  }),
777
739
  );
@@ -779,33 +741,18 @@ export async function ensureAccountContractsPublished(sender: Wallet, accountsTo
779
741
  await Promise.all(
780
742
  accountsAndAddresses
781
743
  .filter(({ deployed }) => !deployed)
782
- .map(({ address }) => sender.getContractMetadata(address)),
744
+ .map(({ address }) => wallet.getContractMetadata(address)),
783
745
  )
784
746
  ).map(contractMetadata => contractMetadata.contractInstance);
785
747
  const contractClass = await getContractClassFromArtifact(SchnorrAccountContractArtifact);
786
- if (!(await sender.getContractClassMetadata(contractClass.id, true)).isContractClassPubliclyRegistered) {
787
- await (await publishContractClass(sender, SchnorrAccountContractArtifact))
788
- .send({ from: accountsToDeploy[0].getAddress() })
748
+ if (!(await wallet.getContractClassMetadata(contractClass.id, true)).isContractClassPubliclyRegistered) {
749
+ await (await publishContractClass(wallet, SchnorrAccountContractArtifact))
750
+ .send({ from: accountsToDeploy[0] })
789
751
  .wait();
790
752
  }
791
- const requests = await Promise.all(instances.map(async instance => await publishInstance(sender, instance!)));
792
- const batch = new BatchCall(sender, requests);
793
- await batch.send({ from: accountsToDeploy[0].getAddress() }).wait();
794
- }
795
- // docs:end:public_deploy_accounts
796
-
797
- /**
798
- * Sets the timestamp of the next block.
799
- * @param rpcUrl - rpc url of the blockchain instance to connect to
800
- * @param timestamp - the timestamp for the next block
801
- */
802
- export async function setNextBlockTimestamp(rpcUrl: string, timestamp: number) {
803
- const params = `[${timestamp}]`;
804
- await fetch(rpcUrl, {
805
- body: `{"jsonrpc":"2.0", "method": "evm_setNextBlockTimestamp", "params": ${params}, "id": 1}`,
806
- method: 'POST',
807
- headers: { 'Content-Type': 'application/json' },
808
- });
753
+ const requests = await Promise.all(instances.map(async instance => await publishInstance(wallet, instance!)));
754
+ const batch = new BatchCall(wallet, requests);
755
+ await batch.send({ from: accountsToDeploy[0] }).wait();
809
756
  }
810
757
 
811
758
  /** Returns the job name for the current test. */
@@ -871,7 +818,7 @@ export async function expectMappingDelta<K, V extends number | bigint>(
871
818
  }
872
819
 
873
820
  /**
874
- * Computes the address of the "canonical" SponosoredFPCContract. This is not a protocol contract
821
+ * Computes the address of the "canonical" SponsoredFPCContract. This is not a protocol contract
875
822
  * but by conventions its address is computed with a salt of 0.
876
823
  * @returns The address of the sponsored FPC contract
877
824
  */
@@ -884,7 +831,7 @@ export function getSponsoredFPCInstance(): Promise<ContractInstanceWithAddress>
884
831
  }
885
832
 
886
833
  /**
887
- * Computes the address of the "canonical" SponosoredFPCContract. This is not a protocol contract
834
+ * Computes the address of the "canonical" SponsoredFPCContract. This is not a protocol contract
888
835
  * but by conventions its address is computed with a salt of 0.
889
836
  * @returns The address of the sponsored FPC contract
890
837
  */
@@ -896,22 +843,22 @@ export async function getSponsoredFPCAddress() {
896
843
  /**
897
844
  * Deploy a sponsored FPC contract to a running instance.
898
845
  */
899
- export async function setupSponsoredFPC(pxe: PXE) {
846
+ export async function setupSponsoredFPC(wallet: Wallet) {
900
847
  const instance = await getContractInstanceFromInstantiationParams(SponsoredFPCContract.artifact, {
901
848
  salt: new Fr(SPONSORED_FPC_SALT),
902
849
  });
903
850
 
904
- await pxe.registerContract({ instance, artifact: SponsoredFPCContract.artifact });
851
+ await wallet.registerContract({ instance, artifact: SponsoredFPCContract.artifact });
905
852
  getLogger().info(`SponsoredFPC: ${instance.address}`);
906
853
  return instance;
907
854
  }
908
855
 
909
856
  /**
910
857
  * Registers the SponsoredFPC in this PXE instance
911
- * @param pxe - The pxe client
858
+ * @param wallet - The wallet
912
859
  */
913
- export async function registerSponsoredFPC(pxe: PXE): Promise<void> {
914
- await pxe.registerContract({ instance: await getSponsoredFPCInstance(), artifact: SponsoredFPCContract.artifact });
860
+ export async function registerSponsoredFPC(wallet: Wallet): Promise<void> {
861
+ await wallet.registerContract({ instance: await getSponsoredFPCInstance(), artifact: SponsoredFPCContract.artifact });
915
862
  }
916
863
 
917
864
  export async function waitForProvenChain(node: AztecNode, targetBlock?: number, timeoutSec = 60, intervalSec = 1) {
@@ -928,7 +875,7 @@ export async function waitForProvenChain(node: AztecNode, targetBlock?: number,
928
875
  export function createAndSyncProverNode(
929
876
  proverNodePrivateKey: `0x${string}`,
930
877
  aztecNodeConfig: AztecNodeConfig,
931
- proverNodeConfig: Partial<ProverNodeConfig> & Pick<DataStoreConfig, 'dataDirectory'>,
878
+ proverNodeConfig: Partial<ProverNodeConfig> & Pick<DataStoreConfig, 'dataDirectory'> & { dontStart?: boolean },
932
879
  aztecNode: AztecNode | undefined,
933
880
  prefilledPublicData: PublicDataTreeLeaf[] = [],
934
881
  proverNodeDeps: ProverNodeDeps = {},
@@ -964,6 +911,7 @@ export function createAndSyncProverNode(
964
911
  txGatheringTimeoutMs: 24_000,
965
912
  proverNodeFailedEpochStore: undefined,
966
913
  proverId: EthAddress.fromNumber(1),
914
+ proverNodeEpochProvingDelayMs: undefined,
967
915
  ...proverNodeConfig,
968
916
  };
969
917
 
@@ -980,7 +928,9 @@ export function createAndSyncProverNode(
980
928
  { prefilledPublicData },
981
929
  );
982
930
  getLogger().info(`Created and synced prover node`, { publisherAddress: l1TxUtils.client.account!.address });
983
- await proverNode.start();
931
+ if (!proverNodeConfig.dontStart) {
932
+ await proverNode.start();
933
+ }
984
934
  return proverNode;
985
935
  });
986
936
  }
@@ -0,0 +1,63 @@
1
+ import { randomBytes } from '@aztec/foundation/crypto';
2
+ import { retryUntil } from '@aztec/foundation/retry';
3
+ import { sleep } from '@aztec/foundation/sleep';
4
+ import { RemoteSigner } from '@aztec/node-keystore';
5
+
6
+ import { mkdirSync } from 'node:fs';
7
+ import { writeFile } from 'node:fs/promises';
8
+ import { join } from 'node:path';
9
+
10
+ export async function createWeb3SignerKeystore(dir: string, ...privateKeys: string[]) {
11
+ const yaml = privateKeys
12
+ .map(
13
+ pk => `\
14
+ type: file-raw
15
+ keyType: SECP256K1
16
+ privateKey: ${pk}`,
17
+ )
18
+ .join('\n---\n');
19
+
20
+ // NOTE: nodejs stdlib can only create temp directories, not temp files!
21
+ // this write uses wx (write-exclusive) so it'll throw if the file already exists
22
+ const path = join(dir, `keystore-${randomBytes(4).toString('hex')}.yaml`);
23
+ await writeFile(path, yaml, { flag: 'wx' });
24
+ }
25
+
26
+ export async function refreshWeb3Signer(url: string, ...expectedAddresses: string[]) {
27
+ await fetch(new URL('reload', url), { method: 'POST' });
28
+
29
+ if (expectedAddresses.length > 0) {
30
+ await retryUntil(
31
+ async () => {
32
+ try {
33
+ await RemoteSigner.validateAccess(url, expectedAddresses);
34
+ return true;
35
+ } catch {
36
+ return false;
37
+ }
38
+ },
39
+ 'web3signer refresh',
40
+ 10,
41
+ 0.5,
42
+ );
43
+ } else {
44
+ await sleep(1000);
45
+ }
46
+ }
47
+
48
+ export function getWeb3SignerTestKeystoreDir(): string {
49
+ if (process.env.WEB3_SIGNER_TEST_KEYSTORE_DIR) {
50
+ mkdirSync(process.env.WEB3_SIGNER_TEST_KEYSTORE_DIR, { recursive: true });
51
+ return process.env.WEB3_SIGNER_TEST_KEYSTORE_DIR;
52
+ } else {
53
+ throw new Error('Web3signer not running');
54
+ }
55
+ }
56
+
57
+ export function getWeb3SignerUrl(): string {
58
+ if (process.env.WEB3_SIGNER_URL) {
59
+ return process.env.WEB3_SIGNER_URL;
60
+ } else {
61
+ throw new Error('Web3signer not running');
62
+ }
63
+ }
@@ -19,36 +19,28 @@ aztec-wallet() {
19
19
  aztec-wallet import-test-accounts
20
20
 
21
21
  # docs:start:declare-accounts
22
- aztec-wallet create-account -a alice --payment method=fee_juice,feePayer=test0
23
- aztec-wallet create-account -a bob --payment method=fee_juice,feePayer=test0
22
+ aztec-wallet create-account -a alice -f test0
23
+ aztec-wallet create-account -a bob -f test0
24
24
  # docs:end:declare-accounts
25
25
 
26
- # docs:start:deploy
27
26
  DEPLOY_OUTPUT=$(aztec-wallet deploy ../noir-contracts.js/artifacts/token_contract-Token.json --args accounts:test0 Test TST 18 -f test0)
28
27
  TOKEN_ADDRESS=$(echo "$DEPLOY_OUTPUT" | grep -oE 'Contract deployed at 0x[0-9a-fA-F]+' | cut -d ' ' -f4)
29
28
  echo "Deployed contract at $TOKEN_ADDRESS"
30
- # docs:end:deploy
31
29
 
32
- # docs:start:mint-private
33
30
  MINT_AMOUNT=69
34
31
  aztec-wallet send mint_to_private -ca last --args accounts:alice $MINT_AMOUNT -f test0
35
- # docs:end:mint-private
36
32
 
37
- # docs:start:get-balance
38
33
  ALICE_BALANCE=$(aztec-wallet simulate balance_of_private -ca last --args accounts:alice -f alice)
39
34
  if ! echo $ALICE_BALANCE | grep -q $MINT_AMOUNT; then
40
35
  echo "Incorrect Alice balance after transaction (expected $MINT_AMOUNT but got $ALICE_BALANCE)"
41
36
  exit 1
42
37
  fi
43
- # docs:end:get-balance
44
38
 
45
- # docs:start:transfer
46
39
  TRANSFER_AMOUNT=42
47
40
 
48
41
  aztec-wallet create-authwit transfer_in_private accounts:test0 -ca last --args accounts:alice accounts:bob $TRANSFER_AMOUNT 1 -f alice
49
42
 
50
43
  aztec-wallet send transfer_in_private -ca last --args accounts:alice accounts:bob $TRANSFER_AMOUNT 1 -aw authwits:last -f test0
51
- # docs:end:transfer
52
44
 
53
45
  # Test end result
54
46
  ALICE_BALANCE=$(aztec-wallet simulate balance_of_private -ca last --args accounts:alice -f alice)
@@ -1,4 +1,4 @@
1
- import type { Logger } from '@aztec/aztec.js';
1
+ import type { Logger } from '@aztec/aztec.js/log';
2
2
 
3
3
  import * as fs from 'fs';
4
4
  import * as yaml from 'js-yaml';