@aztec/end-to-end 2.1.0-rc.9 → 3.0.0-devnet.2

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 (135) 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 +3 -1
  19. package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
  20. package/dest/e2e_epochs/epochs_test.js +10 -9
  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 +23 -31
  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_nested_contract/nested_contract_test.d.ts +6 -3
  31. package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
  32. package/dest/e2e_nested_contract/nested_contract_test.js +7 -9
  33. package/dest/e2e_p2p/inactivity_slash_test.d.ts +2 -2
  34. package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +1 -1
  35. package/dest/e2e_p2p/inactivity_slash_test.js +5 -2
  36. package/dest/e2e_p2p/p2p_network.d.ts +16 -4
  37. package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
  38. package/dest/e2e_p2p/p2p_network.js +32 -10
  39. package/dest/e2e_p2p/shared.d.ts +11 -13
  40. package/dest/e2e_p2p/shared.d.ts.map +1 -1
  41. package/dest/e2e_p2p/shared.js +49 -45
  42. package/dest/e2e_token_contract/token_contract_test.d.ts +5 -4
  43. package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
  44. package/dest/e2e_token_contract/token_contract_test.js +14 -17
  45. package/dest/fixtures/e2e_prover_test.d.ts +8 -6
  46. package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
  47. package/dest/fixtures/e2e_prover_test.js +40 -50
  48. package/dest/fixtures/get_acvm_config.d.ts +1 -1
  49. package/dest/fixtures/get_acvm_config.d.ts.map +1 -1
  50. package/dest/fixtures/get_bb_config.d.ts +1 -1
  51. package/dest/fixtures/get_bb_config.d.ts.map +1 -1
  52. package/dest/fixtures/get_bb_config.js +2 -2
  53. package/dest/fixtures/setup_l1_contracts.d.ts +1 -1
  54. package/dest/fixtures/setup_l1_contracts.d.ts.map +1 -1
  55. package/dest/fixtures/setup_l1_contracts.js +2 -2
  56. package/dest/fixtures/setup_p2p_test.d.ts +0 -7
  57. package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
  58. package/dest/fixtures/snapshot_manager.d.ts +10 -7
  59. package/dest/fixtures/snapshot_manager.d.ts.map +1 -1
  60. package/dest/fixtures/snapshot_manager.js +44 -34
  61. package/dest/fixtures/token_utils.d.ts +6 -4
  62. package/dest/fixtures/token_utils.d.ts.map +1 -1
  63. package/dest/fixtures/token_utils.js +11 -15
  64. package/dest/fixtures/utils.d.ts +23 -27
  65. package/dest/fixtures/utils.d.ts.map +1 -1
  66. package/dest/fixtures/utils.js +76 -101
  67. package/dest/fixtures/web3signer.d.ts +1 -1
  68. package/dest/fixtures/web3signer.d.ts.map +1 -1
  69. package/dest/fixtures/web3signer.js +16 -5
  70. package/dest/quality_of_service/alert_checker.d.ts +1 -1
  71. package/dest/quality_of_service/alert_checker.d.ts.map +1 -1
  72. package/dest/shared/cross_chain_test_harness.d.ts +16 -10
  73. package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
  74. package/dest/shared/cross_chain_test_harness.js +13 -15
  75. package/dest/shared/gas_portal_test_harness.d.ts +9 -6
  76. package/dest/shared/gas_portal_test_harness.d.ts.map +1 -1
  77. package/dest/shared/gas_portal_test_harness.js +10 -7
  78. package/dest/shared/jest_setup.js +1 -1
  79. package/dest/shared/submit-transactions.d.ts +5 -3
  80. package/dest/shared/submit-transactions.d.ts.map +1 -1
  81. package/dest/shared/submit-transactions.js +8 -7
  82. package/dest/shared/uniswap_l1_l2.d.ts +9 -6
  83. package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
  84. package/dest/shared/uniswap_l1_l2.js +29 -45
  85. package/dest/simulators/lending_simulator.d.ts +2 -1
  86. package/dest/simulators/lending_simulator.d.ts.map +1 -1
  87. package/dest/simulators/lending_simulator.js +3 -2
  88. package/dest/simulators/token_simulator.d.ts +3 -1
  89. package/dest/simulators/token_simulator.d.ts.map +1 -1
  90. package/dest/simulators/token_simulator.js +2 -2
  91. package/dest/spartan/setup_test_wallets.d.ts +19 -13
  92. package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
  93. package/dest/spartan/setup_test_wallets.js +108 -85
  94. package/dest/spartan/utils.d.ts +44 -0
  95. package/dest/spartan/utils.d.ts.map +1 -1
  96. package/dest/spartan/utils.js +212 -20
  97. package/package.json +38 -37
  98. package/src/bench/client_flows/benchmark.ts +6 -6
  99. package/src/bench/client_flows/client_flows_benchmark.ts +62 -82
  100. package/src/bench/client_flows/data_extractor.ts +1 -1
  101. package/src/bench/utils.ts +9 -37
  102. package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +46 -63
  103. package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +33 -47
  104. package/src/e2e_deploy_contract/deploy_test.ts +17 -35
  105. package/src/e2e_epochs/epochs_test.ts +12 -14
  106. package/src/e2e_fees/bridging_race.notest.ts +14 -9
  107. package/src/e2e_fees/fees_test.ts +26 -38
  108. package/src/e2e_l1_publisher/write_json.ts +8 -6
  109. package/src/e2e_multi_validator/utils.ts +1 -1
  110. package/src/e2e_nested_contract/nested_contract_test.ts +11 -10
  111. package/src/e2e_p2p/inactivity_slash_test.ts +7 -3
  112. package/src/e2e_p2p/p2p_network.ts +105 -67
  113. package/src/e2e_p2p/shared.ts +50 -55
  114. package/src/e2e_token_contract/token_contract_test.ts +17 -17
  115. package/src/fixtures/e2e_prover_test.ts +51 -88
  116. package/src/fixtures/get_acvm_config.ts +1 -1
  117. package/src/fixtures/get_bb_config.ts +3 -2
  118. package/src/fixtures/setup_l1_contracts.ts +3 -3
  119. package/src/fixtures/setup_p2p_test.ts +0 -8
  120. package/src/fixtures/snapshot_manager.ts +61 -61
  121. package/src/fixtures/token_utils.ts +13 -21
  122. package/src/fixtures/utils.ts +87 -138
  123. package/src/fixtures/web3signer.ts +22 -5
  124. package/src/guides/up_quick_start.sh +2 -10
  125. package/src/quality_of_service/alert_checker.ts +1 -1
  126. package/src/shared/cross_chain_test_harness.ts +18 -29
  127. package/src/shared/gas_portal_test_harness.ts +12 -19
  128. package/src/shared/jest_setup.ts +1 -1
  129. package/src/shared/submit-transactions.ts +12 -8
  130. package/src/shared/uniswap_l1_l2.ts +61 -67
  131. package/src/simulators/lending_simulator.ts +3 -2
  132. package/src/simulators/token_simulator.ts +5 -2
  133. package/src/spartan/DEVELOP.md +8 -3
  134. package/src/spartan/setup_test_wallets.ts +133 -126
  135. package/src/spartan/utils.ts +268 -18
@@ -1,19 +1,8 @@
1
- import {
2
- SchnorrAccountContractArtifact,
3
- getSchnorrAccount,
4
- getSchnorrWalletWithSecretKey,
5
- } from '@aztec/accounts/schnorr';
6
1
  import type { InitialAccountData } from '@aztec/accounts/testing';
7
2
  import { type Archiver, createArchiver } from '@aztec/archiver';
8
- import {
9
- type AccountWalletWithSecretKey,
10
- type AztecNode,
11
- type CompleteAddress,
12
- EthAddress,
13
- type Logger,
14
- type PXE,
15
- createLogger,
16
- } from '@aztec/aztec.js';
3
+ import { AztecAddress, EthAddress } from '@aztec/aztec.js/addresses';
4
+ import { type Logger, createLogger } from '@aztec/aztec.js/log';
5
+ import type { AztecNode } from '@aztec/aztec.js/node';
17
6
  import { CheatCodes } from '@aztec/aztec/testing';
18
7
  import {
19
8
  BBCircuitVerifier,
@@ -29,8 +18,8 @@ import { SecretValue } from '@aztec/foundation/config';
29
18
  import { FeeAssetHandlerAbi } from '@aztec/l1-artifacts';
30
19
  import { TokenContract } from '@aztec/noir-contracts.js/Token';
31
20
  import { type ProverNode, type ProverNodeConfig, createProverNode } from '@aztec/prover-node';
32
- import type { PXEService } from '@aztec/pxe/server';
33
21
  import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
22
+ import { TestWallet } from '@aztec/test-wallet/server';
34
23
  import { getGenesisValues } from '@aztec/world-state/testing';
35
24
 
36
25
  import { type Hex, getContract } from 'viem';
@@ -46,12 +35,12 @@ import {
46
35
  deployAccounts,
47
36
  publicDeployAccounts,
48
37
  } from './snapshot_manager.js';
49
- import { getPrivateKeyFromIndex, getSponsoredFPCAddress, setupPXEService } from './utils.js';
38
+ import { getPrivateKeyFromIndex, getSponsoredFPCAddress, setupPXEAndGetWallet } from './utils.js';
50
39
 
51
40
  const { E2E_DATA_PATH: dataPath } = process.env;
52
41
 
53
42
  type ProvenSetup = {
54
- pxe: PXE;
43
+ wallet: TestWallet;
55
44
  teardown: () => Promise<void>;
56
45
  };
57
46
 
@@ -68,21 +57,21 @@ export class FullProverTest {
68
57
  static TOKEN_DECIMALS = 18n;
69
58
  private snapshotManager: ISnapshotManager;
70
59
  logger: Logger;
71
- deployedAccounts: InitialAccountData[] = [];
72
- wallets: AccountWalletWithSecretKey[] = [];
73
- accounts: CompleteAddress[] = [];
60
+ wallet!: TestWallet;
61
+ provenWallet!: TestWallet;
62
+ accounts: AztecAddress[] = [];
63
+ deployedAccounts!: InitialAccountData[];
74
64
  fakeProofsAsset!: TokenContract;
75
65
  tokenSim!: TokenSimulator;
76
66
  aztecNode!: AztecNode;
77
67
  aztecNodeAdmin!: AztecNodeAdmin;
78
- pxe!: PXEService;
79
68
  cheatCodes!: CheatCodes;
80
69
  blobSink!: BlobSinkServer;
81
70
  private provenComponents: ProvenSetup[] = [];
82
71
  private bbConfigCleanup?: () => Promise<void>;
83
72
  private acvmConfigCleanup?: () => Promise<void>;
84
73
  circuitProofVerifier?: ClientProtocolCircuitVerifier;
85
- provenAssets: TokenContract[] = [];
74
+ provenAsset!: TokenContract;
86
75
  private context!: SubsystemsContext;
87
76
  private proverNode!: ProverNode;
88
77
  private simulatedProverNode!: ProverNode;
@@ -115,13 +104,11 @@ export class FullProverTest {
115
104
  await this.snapshotManager.snapshot(
116
105
  '2_accounts',
117
106
  deployAccounts(2, this.logger),
118
- async ({ deployedAccounts }, { pxe }) => {
107
+ ({ deployedAccounts }, { wallet }) => {
119
108
  this.deployedAccounts = deployedAccounts;
120
- this.wallets = await Promise.all(
121
- deployedAccounts.map(a => getSchnorrWalletWithSecretKey(pxe, a.secret, a.signingKey, a.salt)),
122
- );
123
- this.accounts = this.wallets.map(w => w.getCompleteAddress());
124
- this.wallets.forEach((w, i) => this.logger.verbose(`Wallet ${i} address: ${w.getAddress()}`));
109
+ this.accounts = deployedAccounts.map(a => a.address);
110
+ this.wallet = wallet;
111
+ return Promise.resolve();
125
112
  },
126
113
  );
127
114
 
@@ -131,17 +118,17 @@ export class FullProverTest {
131
118
  // Create the token contract state.
132
119
  // Move this account thing to addAccounts above?
133
120
  this.logger.verbose(`Public deploy accounts...`);
134
- await publicDeployAccounts(this.wallets[0], this.accounts.slice(0, 2));
121
+ await publicDeployAccounts(this.wallet, this.accounts.slice(0, 2));
135
122
 
136
123
  this.logger.verbose(`Deploying TokenContract...`);
137
124
  const asset = await TokenContract.deploy(
138
- this.wallets[0],
125
+ this.wallet,
139
126
  this.accounts[0],
140
127
  FullProverTest.TOKEN_NAME,
141
128
  FullProverTest.TOKEN_SYMBOL,
142
129
  FullProverTest.TOKEN_DECIMALS,
143
130
  )
144
- .send({ from: this.wallets[0].getAddress() })
131
+ .send({ from: this.accounts[0] })
145
132
  .deployed();
146
133
  this.logger.verbose(`Token deployed to ${asset.address}`);
147
134
 
@@ -149,19 +136,19 @@ export class FullProverTest {
149
136
  },
150
137
  async ({ tokenContractAddress }) => {
151
138
  // Restore the token contract state.
152
- this.fakeProofsAsset = await TokenContract.at(tokenContractAddress, this.wallets[0]);
139
+ this.fakeProofsAsset = await TokenContract.at(tokenContractAddress, this.wallet);
153
140
  this.logger.verbose(`Token contract address: ${this.fakeProofsAsset.address}`);
154
141
 
155
142
  this.tokenSim = new TokenSimulator(
156
143
  this.fakeProofsAsset,
157
- this.wallets[0],
158
- this.wallets[0].getAddress(),
144
+ this.wallet,
145
+ this.accounts[0],
159
146
  this.logger,
160
- this.accounts.map(a => a.address),
147
+ this.accounts,
161
148
  );
162
149
 
163
- expect(await this.fakeProofsAsset.methods.get_admin().simulate({ from: this.accounts[0].address })).toBe(
164
- this.accounts[0].address.toBigInt(),
150
+ expect(await this.fakeProofsAsset.methods.get_admin().simulate({ from: this.accounts[0] })).toBe(
151
+ this.accounts[0].toBigInt(),
165
152
  );
166
153
  },
167
154
  );
@@ -175,7 +162,6 @@ export class FullProverTest {
175
162
 
176
163
  this.simulatedProverNode = this.context.proverNode!;
177
164
  ({
178
- pxe: this.pxe,
179
165
  aztecNode: this.aztecNode,
180
166
  deployL1ContractsValues: this.l1Contracts,
181
167
  cheatCodes: this.cheatCodes,
@@ -224,51 +210,31 @@ export class FullProverTest {
224
210
  await this.context.cheatCodes.rollup.markAsProven();
225
211
 
226
212
  this.logger.verbose(`Main setup completed, initializing full prover PXE, Node, and Prover Node`);
227
- for (let i = 0; i < 2; i++) {
228
- const result = await setupPXEService(
229
- this.aztecNode,
230
- {
231
- proverEnabled: this.realProofs,
232
- bbBinaryPath: bbConfig?.bbBinaryPath,
233
- bbWorkingDirectory: bbConfig?.bbWorkingDirectory,
234
- },
235
- undefined,
236
- true,
237
- );
238
- this.logger.debug(`Contract address ${this.fakeProofsAsset.address}`);
239
- await result.pxe.registerContract(this.fakeProofsAsset);
240
-
241
- for (let i = 0; i < 2; i++) {
242
- await result.pxe.registerAccount(
243
- this.deployedAccounts[i].secret,
244
- this.wallets[i].getCompleteAddress().partialAddress,
245
- );
246
- await this.pxe.registerAccount(
247
- this.deployedAccounts[i].secret,
248
- this.wallets[i].getCompleteAddress().partialAddress,
249
- );
250
- }
251
-
252
- const account = await getSchnorrAccount(
253
- result.pxe,
254
- this.deployedAccounts[0].secret,
255
- this.deployedAccounts[0].signingKey,
256
- this.deployedAccounts[0].salt,
257
- );
258
-
259
- await result.pxe.registerContract({
260
- instance: account.getInstance(),
261
- artifact: SchnorrAccountContractArtifact,
262
- });
213
+ const { wallet: provenWallet, teardown: provenTeardown } = await setupPXEAndGetWallet(
214
+ this.aztecNode,
215
+ {
216
+ proverEnabled: this.realProofs,
217
+ bbBinaryPath: bbConfig?.bbBinaryPath,
218
+ bbWorkingDirectory: bbConfig?.bbWorkingDirectory,
219
+ },
220
+ undefined,
221
+ true,
222
+ );
223
+ this.logger.debug(`Contract address ${this.fakeProofsAsset.address}`);
224
+ await provenWallet.registerContract(this.fakeProofsAsset);
263
225
 
264
- const provenWallet = await account.getWallet();
265
- const asset = await TokenContract.at(this.fakeProofsAsset.address, provenWallet);
266
- this.provenComponents.push({
267
- pxe: result.pxe,
268
- teardown: result.teardown,
269
- });
270
- this.provenAssets.push(asset);
226
+ for (let i = 0; i < 2; i++) {
227
+ await provenWallet.createSchnorrAccount(this.deployedAccounts[i].secret, this.deployedAccounts[i].salt);
228
+ await this.wallet.createSchnorrAccount(this.deployedAccounts[i].secret, this.deployedAccounts[i].salt);
271
229
  }
230
+
231
+ const asset = await TokenContract.at(this.fakeProofsAsset.address, provenWallet);
232
+ this.provenComponents.push({
233
+ wallet: provenWallet,
234
+ teardown: provenTeardown,
235
+ });
236
+ this.provenAsset = asset;
237
+ this.provenWallet = provenWallet;
272
238
  this.logger.info(`Full prover PXE started`);
273
239
 
274
240
  // Shutdown the current, simulated prover node
@@ -369,15 +335,12 @@ export class FullProverTest {
369
335
 
370
336
  this.logger.verbose(`Minting ${privateAmount + publicAmount} publicly...`);
371
337
  await asset.methods
372
- .mint_to_public(accounts[0].address, privateAmount + publicAmount)
373
- .send({ from: accounts[0].address })
338
+ .mint_to_public(accounts[0], privateAmount + publicAmount)
339
+ .send({ from: accounts[0] })
374
340
  .wait();
375
341
 
376
342
  this.logger.verbose(`Transferring ${privateAmount} to private...`);
377
- await asset.methods
378
- .transfer_to_private(accounts[0].address, privateAmount)
379
- .send({ from: accounts[0].address })
380
- .wait();
343
+ await asset.methods.transfer_to_private(accounts[0], privateAmount).send({ from: accounts[0] }).wait();
381
344
 
382
345
  this.logger.verbose(`Minting complete.`);
383
346
 
@@ -386,7 +349,7 @@ export class FullProverTest {
386
349
  async ({ amount }) => {
387
350
  const {
388
351
  fakeProofsAsset: asset,
389
- accounts: [{ address }],
352
+ accounts: [address],
390
353
  tokenSim,
391
354
  } = this;
392
355
  tokenSim.mintPublic(address, amount);
@@ -1,4 +1,4 @@
1
- import type { Logger } from '@aztec/aztec.js';
1
+ import type { Logger } from '@aztec/aztec.js/log';
2
2
  import { parseBooleanEnv } from '@aztec/foundation/config';
3
3
  import { randomBytes } from '@aztec/foundation/crypto';
4
4
  import { tryRmDir } from '@aztec/foundation/fs';
@@ -1,10 +1,11 @@
1
- import { type Logger, fileURLToPath } from '@aztec/aztec.js';
1
+ import type { Logger } from '@aztec/aztec.js/log';
2
2
  import type { BBConfig } from '@aztec/bb-prover';
3
3
  import { tryRmDir } from '@aztec/foundation/fs';
4
4
 
5
5
  import fs from 'node:fs/promises';
6
6
  import { tmpdir } from 'node:os';
7
7
  import path from 'path';
8
+ import { fileURLToPath } from 'url';
8
9
 
9
10
  const {
10
11
  BB_RELEASE_DIR = 'barretenberg/cpp/build/bin',
@@ -22,7 +23,7 @@ export const getBBConfig = async (
22
23
  try {
23
24
  const bbBinaryPath =
24
25
  BB_BINARY_PATH ??
25
- path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../../../', BB_RELEASE_DIR, 'bb');
26
+ path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../../../', BB_RELEASE_DIR, 'bb-avm');
26
27
  await fs.access(bbBinaryPath, fs.constants.R_OK);
27
28
 
28
29
  let bbWorkingDirectory: string;
@@ -1,7 +1,7 @@
1
- import type { Logger } from '@aztec/aztec.js';
1
+ import type { Logger } from '@aztec/aztec.js/log';
2
2
  import { type DeployL1ContractsArgs, type L1ContractsConfig, deployL1Contracts } from '@aztec/ethereum';
3
3
  import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
4
- import { protocolContractTreeRoot } from '@aztec/protocol-contracts';
4
+ import { protocolContractsHash } from '@aztec/protocol-contracts';
5
5
 
6
6
  import type { HDAccount, PrivateKeyAccount } from 'viem';
7
7
  import { foundry } from 'viem/chains';
@@ -16,7 +16,7 @@ export const setupL1Contracts = async (
16
16
  ) => {
17
17
  const l1Data = await deployL1Contracts([l1RpcUrl], account, foundry, logger, {
18
18
  vkTreeRoot: getVKTreeRoot(),
19
- protocolContractTreeRoot,
19
+ protocolContractsHash,
20
20
  salt: undefined,
21
21
  realVerifier: false,
22
22
  ...args,
@@ -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
@@ -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));
@@ -353,7 +346,9 @@ async function setupFromFresh(
353
346
  const res = await startAnvil({ l1BlockTime: opts.ethereumSlotDuration });
354
347
  const anvil = res.anvil;
355
348
  aztecNodeConfig.l1RpcUrls = [res.rpcUrl];
356
- const ethCheatCodes = new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrls);
349
+
350
+ const dateProvider = new TestDateProvider();
351
+ const ethCheatCodes = new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrls, dateProvider);
357
352
 
358
353
  // Deploy our L1 contracts.
359
354
  logger.verbose('Deploying L1 contracts...');
@@ -381,10 +376,8 @@ async function setupFromFresh(
381
376
  aztecNodeConfig.l1Contracts = deployL1ContractsValues.l1ContractAddresses;
382
377
  aztecNodeConfig.rollupVersion = deployL1ContractsValues.rollupVersion;
383
378
 
384
- const dateProvider = new TestDateProvider();
385
-
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
  );
@@ -443,13 +436,12 @@ async function setupFromFresh(
443
436
  }
444
437
 
445
438
  logger.verbose('Creating pxe...');
446
- const pxeConfig = getPXEServiceConfig();
439
+ const pxeConfig = getPXEConfig();
447
440
  pxeConfig.dataDirectory = statePath ?? path.join(directoryToCleanup, randomBytes(8).toString('hex'));
448
441
  // Only enable proving if specifically requested.
449
442
  pxeConfig.proverEnabled = !!opts.realProofs;
450
- const pxe = await createPXEService(aztecNode, pxeConfig);
451
-
452
- 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);
453
445
 
454
446
  if (statePath) {
455
447
  writeFileSync(`${statePath}/aztec_node_config.json`, JSON.stringify(aztecNodeConfig, resolver));
@@ -460,7 +452,7 @@ async function setupFromFresh(
460
452
  aztecNodeConfig,
461
453
  anvil,
462
454
  aztecNode,
463
- pxe,
455
+ wallet,
464
456
  sequencer: aztecNode.getSequencer()!,
465
457
  acvmConfig,
466
458
  bbConfig,
@@ -505,7 +497,9 @@ async function setupFromState(statePath: string, logger: Logger): Promise<Subsys
505
497
  aztecNodeConfig.l1RpcUrls = [rpcUrl];
506
498
  // Load anvil state.
507
499
  const anvilStateFile = `${statePath}/anvil.dat`;
508
- const ethCheatCodes = new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrls);
500
+
501
+ const dateProvider = new TestDateProvider();
502
+ const ethCheatCodes = new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrls, dateProvider);
509
503
  await ethCheatCodes.loadChainState(anvilStateFile);
510
504
 
511
505
  // TODO: Encapsulate this in a NativeAcvm impl.
@@ -524,9 +518,8 @@ async function setupFromState(statePath: string, logger: Logger): Promise<Subsys
524
518
  logger.verbose('Creating ETH clients...');
525
519
  const l1Client = createExtendedL1Client(aztecNodeConfig.l1RpcUrls, mnemonicToAccount(MNEMONIC));
526
520
 
527
- const dateProvider = new TestDateProvider();
528
521
  const watcher = new AnvilTestWatcher(
529
- new EthCheatCodesWithState(aztecNodeConfig.l1RpcUrls),
522
+ ethCheatCodes,
530
523
  aztecNodeConfig.l1Contracts.rollupAddress,
531
524
  l1Client,
532
525
  dateProvider,
@@ -541,7 +534,7 @@ async function setupFromState(statePath: string, logger: Logger): Promise<Subsys
541
534
  l1Contracts: aztecNodeConfig.l1Contracts,
542
535
  port: blobSinkPort,
543
536
  dataDirectory: statePath,
544
- dataStoreMapSizeKB: aztecNodeConfig.dataStoreMapSizeKB,
537
+ dataStoreMapSizeKb: aztecNodeConfig.dataStoreMapSizeKb,
545
538
  },
546
539
  telemetry,
547
540
  );
@@ -573,17 +566,16 @@ async function setupFromState(statePath: string, logger: Logger): Promise<Subsys
573
566
  }
574
567
 
575
568
  logger.verbose('Creating pxe...');
576
- const pxeConfig = getPXEServiceConfig();
569
+ const pxeConfig = getPXEConfig();
577
570
  pxeConfig.dataDirectory = statePath;
578
- const pxe = await createPXEService(aztecNode, pxeConfig);
579
-
580
- 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);
581
573
 
582
574
  return {
583
575
  aztecNodeConfig,
584
576
  anvil,
585
577
  aztecNode,
586
- pxe,
578
+ wallet,
587
579
  sequencer: aztecNode.getSequencer()!,
588
580
  acvmConfig,
589
581
  bbConfig,
@@ -607,20 +599,29 @@ async function setupFromState(statePath: string, logger: Logger): Promise<Subsys
607
599
  * The 'restore' function is not provided, as it must be a closure within the test context to capture the results.
608
600
  */
609
601
  export const deployAccounts =
610
- (numberOfAccounts: number, logger: Logger, waitUntilProven = false) =>
611
- async ({ pxe, initialFundedAccounts }: { pxe: PXE; initialFundedAccounts: InitialAccountData[] }) => {
602
+ (numberOfAccounts: number, logger: Logger) =>
603
+ async ({ wallet, initialFundedAccounts }: { wallet: TestWallet; initialFundedAccounts: InitialAccountData[] }) => {
612
604
  if (initialFundedAccounts.length < numberOfAccounts) {
613
605
  throw new Error(`Cannot deploy more than ${initialFundedAccounts.length} initial accounts.`);
614
606
  }
615
607
 
616
608
  logger.verbose('Deploying accounts funded with fee juice...');
617
609
  const deployedAccounts = initialFundedAccounts.slice(0, numberOfAccounts);
618
- await deployFundedSchnorrAccounts(
619
- pxe,
620
- deployedAccounts,
621
- undefined,
622
- waitUntilProven ? DefaultWaitForProvenOpts : undefined,
623
- );
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
+ }
624
625
 
625
626
  return { deployedAccounts };
626
627
  };
@@ -631,35 +632,34 @@ export const deployAccounts =
631
632
  * @param sender - Wallet to send the deployment tx.
632
633
  * @param accountsToDeploy - Which accounts to publicly deploy.
633
634
  * @param waitUntilProven - Whether to wait for the tx to be proven.
634
- * @param pxeOrNode - PXE or AztecNode to wait for proven.
635
+ * @param node - AztecNode used to wait for proven tx.
635
636
  */
636
637
  export async function publicDeployAccounts(
637
- sender: Wallet,
638
- accountsToDeploy: (CompleteAddress | AztecAddress)[],
638
+ wallet: Wallet,
639
+ accountsToDeploy: AztecAddress[],
639
640
  waitUntilProven = false,
640
- pxeOrNode?: PXE | AztecNode,
641
+ node?: AztecNode,
641
642
  ) {
642
- const accountAddressesToDeploy = accountsToDeploy.map(a => ('address' in a ? a.address : a));
643
- const instances = (
644
- await Promise.all(accountAddressesToDeploy.map(account => sender.getContractMetadata(account)))
645
- ).map(metadata => metadata.contractInstance);
643
+ const instances = (await Promise.all(accountsToDeploy.map(account => wallet.getContractMetadata(account)))).map(
644
+ metadata => metadata.contractInstance,
645
+ );
646
646
 
647
647
  const contractClass = await getContractClassFromArtifact(SchnorrAccountContractArtifact);
648
- const alreadyRegistered = (await sender.getContractClassMetadata(contractClass.id)).isContractClassPubliclyRegistered;
648
+ const alreadyRegistered = (await wallet.getContractClassMetadata(contractClass.id)).isContractClassPubliclyRegistered;
649
649
 
650
650
  const calls: ContractFunctionInteraction[] = await Promise.all([
651
- ...(!alreadyRegistered ? [publishContractClass(sender, SchnorrAccountContractArtifact)] : []),
652
- ...instances.map(instance => publishInstance(sender, instance!)),
651
+ ...(!alreadyRegistered ? [publishContractClass(wallet, SchnorrAccountContractArtifact)] : []),
652
+ ...instances.map(instance => publishInstance(wallet, instance!)),
653
653
  ]);
654
654
 
655
- const batch = new BatchCall(sender, calls);
655
+ const batch = new BatchCall(wallet, calls);
656
656
 
657
- const txReceipt = await batch.send({ from: accountAddressesToDeploy[0] }).wait();
657
+ const txReceipt = await batch.send({ from: accountsToDeploy[0] }).wait();
658
658
  if (waitUntilProven) {
659
- if (!pxeOrNode) {
660
- 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.');
661
661
  } else {
662
- await waitForProven(pxeOrNode, txReceipt);
662
+ await waitForProven(node, txReceipt);
663
663
  }
664
664
  }
665
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);