@aztec/end-to-end 0.0.1-fake-c83136db25 → 0.0.1-fake-ceab37513c

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