@aztec/end-to-end 0.75.0-commit.c03ba01a2a4122e43e90d5133ba017e54b90e9d2 → 0.77.0-testnet-ignition.21

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 (138) hide show
  1. package/README.md +2 -0
  2. package/dest/bench/utils.d.ts +70 -0
  3. package/dest/bench/utils.d.ts.map +1 -0
  4. package/dest/bench/utils.js +24 -8
  5. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +46 -0
  6. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +1 -0
  7. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.js +17 -17
  8. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts +47 -0
  9. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.d.ts.map +1 -0
  10. package/dest/e2e_cross_chain_messaging/cross_chain_messaging_test.js +27 -16
  11. package/dest/e2e_deploy_contract/deploy_test.d.ts +28 -0
  12. package/dest/e2e_deploy_contract/deploy_test.d.ts.map +1 -0
  13. package/dest/e2e_deploy_contract/deploy_test.js +4 -7
  14. package/dest/e2e_epochs/epochs_test.d.ts +51 -0
  15. package/dest/e2e_epochs/epochs_test.d.ts.map +1 -0
  16. package/dest/e2e_epochs/epochs_test.js +155 -0
  17. package/dest/e2e_fees/fees_test.d.ts +73 -0
  18. package/dest/e2e_fees/fees_test.d.ts.map +1 -0
  19. package/dest/e2e_fees/fees_test.js +75 -32
  20. package/dest/e2e_nested_contract/nested_contract_test.d.ts +26 -0
  21. package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -0
  22. package/dest/e2e_nested_contract/nested_contract_test.js +14 -12
  23. package/dest/e2e_p2p/p2p_network.d.ts +61 -0
  24. package/dest/e2e_p2p/p2p_network.d.ts.map +1 -0
  25. package/dest/e2e_p2p/p2p_network.js +54 -30
  26. package/dest/e2e_p2p/shared.d.ts +10 -0
  27. package/dest/e2e_p2p/shared.d.ts.map +1 -0
  28. package/dest/e2e_p2p/shared.js +7 -8
  29. package/dest/e2e_prover/e2e_prover_test.d.ts +56 -0
  30. package/dest/e2e_prover/e2e_prover_test.d.ts.map +1 -0
  31. package/dest/e2e_prover/e2e_prover_test.js +20 -24
  32. package/dest/e2e_token_contract/token_contract_test.d.ts +29 -0
  33. package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -0
  34. package/dest/e2e_token_contract/token_contract_test.js +4 -7
  35. package/dest/fixtures/fixtures.d.ts +17 -0
  36. package/dest/fixtures/fixtures.d.ts.map +1 -0
  37. package/dest/fixtures/fixtures.js +2 -2
  38. package/dest/fixtures/get_acvm_config.d.ts +8 -0
  39. package/dest/fixtures/get_acvm_config.d.ts.map +1 -0
  40. package/dest/fixtures/get_acvm_config.js +10 -5
  41. package/dest/fixtures/get_bb_config.d.ts +6 -0
  42. package/dest/fixtures/get_bb_config.d.ts.map +1 -0
  43. package/dest/fixtures/get_bb_config.js +9 -4
  44. package/dest/fixtures/index.d.ts +6 -0
  45. package/dest/fixtures/index.d.ts.map +1 -0
  46. package/dest/fixtures/l1_to_l2_messaging.d.ts +13 -0
  47. package/dest/fixtures/l1_to_l2_messaging.d.ts.map +1 -0
  48. package/dest/fixtures/l1_to_l2_messaging.js +1 -1
  49. package/dest/fixtures/logging.d.ts +8 -0
  50. package/dest/fixtures/logging.d.ts.map +1 -0
  51. package/dest/fixtures/setup_l1_contracts.d.ts +6 -0
  52. package/dest/fixtures/setup_l1_contracts.d.ts.map +1 -0
  53. package/dest/fixtures/setup_l1_contracts.js +6 -4
  54. package/dest/fixtures/setup_p2p_test.d.ts +22 -0
  55. package/dest/fixtures/setup_p2p_test.d.ts.map +1 -0
  56. package/dest/fixtures/setup_p2p_test.js +5 -3
  57. package/dest/fixtures/snapshot_manager.d.ts +87 -0
  58. package/dest/fixtures/snapshot_manager.d.ts.map +1 -0
  59. package/dest/fixtures/snapshot_manager.js +67 -74
  60. package/dest/fixtures/token_utils.d.ts +6 -0
  61. package/dest/fixtures/token_utils.d.ts.map +1 -0
  62. package/dest/fixtures/token_utils.js +1 -1
  63. package/dest/fixtures/utils.d.ts +155 -0
  64. package/dest/fixtures/utils.d.ts.map +1 -0
  65. package/dest/fixtures/utils.js +97 -71
  66. package/dest/fixtures/with_telemetry_utils.d.ts +3 -0
  67. package/dest/fixtures/with_telemetry_utils.d.ts.map +1 -0
  68. package/dest/index.d.ts +2 -0
  69. package/dest/index.d.ts.map +1 -0
  70. package/dest/quality_of_service/alert_checker.d.ts +41 -0
  71. package/dest/quality_of_service/alert_checker.d.ts.map +1 -0
  72. package/dest/quality_of_service/alert_checker.js +4 -1
  73. package/dest/sample-dapp/index.js +1 -1
  74. package/dest/shared/cross_chain_test_harness.d.ts +124 -0
  75. package/dest/shared/cross_chain_test_harness.d.ts.map +1 -0
  76. package/dest/shared/cross_chain_test_harness.js +6 -17
  77. package/dest/shared/gas_portal_test_harness.d.ts +80 -0
  78. package/dest/shared/gas_portal_test_harness.d.ts.map +1 -0
  79. package/dest/shared/gas_portal_test_harness.js +11 -4
  80. package/dest/shared/index.d.ts +2 -0
  81. package/dest/shared/index.d.ts.map +1 -0
  82. package/dest/shared/index.js +0 -1
  83. package/dest/shared/jest_setup.d.ts +2 -0
  84. package/dest/shared/jest_setup.d.ts.map +1 -0
  85. package/dest/shared/submit-transactions.d.ts +4 -0
  86. package/dest/shared/submit-transactions.d.ts.map +1 -0
  87. package/dest/shared/submit-transactions.js +9 -17
  88. package/dest/shared/uniswap_l1_l2.d.ts +25 -0
  89. package/dest/shared/uniswap_l1_l2.d.ts.map +1 -0
  90. package/dest/shared/uniswap_l1_l2.js +5 -10
  91. package/dest/simulators/index.d.ts +3 -0
  92. package/dest/simulators/index.d.ts.map +1 -0
  93. package/dest/simulators/lending_simulator.d.ts +69 -0
  94. package/dest/simulators/lending_simulator.d.ts.map +1 -0
  95. package/dest/simulators/lending_simulator.js +1 -3
  96. package/dest/simulators/token_simulator.d.ts +29 -0
  97. package/dest/simulators/token_simulator.d.ts.map +1 -0
  98. package/dest/spartan/setup_test_wallets.d.ts +20 -0
  99. package/dest/spartan/setup_test_wallets.d.ts.map +1 -0
  100. package/dest/spartan/setup_test_wallets.js +72 -38
  101. package/dest/spartan/utils.d.ts +415 -0
  102. package/dest/spartan/utils.d.ts.map +1 -0
  103. package/dest/spartan/utils.js +169 -43
  104. package/package.json +35 -40
  105. package/src/bench/utils.ts +30 -13
  106. package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +40 -30
  107. package/src/e2e_cross_chain_messaging/cross_chain_messaging_test.ts +34 -18
  108. package/src/e2e_deploy_contract/deploy_test.ts +6 -11
  109. package/src/e2e_epochs/epochs_test.ts +217 -0
  110. package/src/e2e_fees/fees_test.ts +84 -38
  111. package/src/e2e_nested_contract/nested_contract_test.ts +14 -16
  112. package/src/e2e_p2p/p2p_network.ts +67 -47
  113. package/src/e2e_p2p/shared.ts +16 -10
  114. package/src/e2e_prover/e2e_prover_test.ts +56 -37
  115. package/src/e2e_token_contract/token_contract_test.ts +10 -11
  116. package/src/fixtures/fixtures.ts +2 -2
  117. package/src/fixtures/get_acvm_config.ts +7 -3
  118. package/src/fixtures/get_bb_config.ts +6 -2
  119. package/src/fixtures/l1_to_l2_messaging.ts +6 -13
  120. package/src/fixtures/setup_l1_contracts.ts +8 -7
  121. package/src/fixtures/setup_p2p_test.ts +8 -6
  122. package/src/fixtures/snapshot_manager.ts +72 -79
  123. package/src/fixtures/token_utils.ts +2 -2
  124. package/src/fixtures/utils.ts +135 -97
  125. package/src/guides/up_quick_start.sh +10 -5
  126. package/src/quality_of_service/alert_checker.ts +6 -2
  127. package/src/sample-dapp/index.mjs +1 -1
  128. package/src/shared/cross_chain_test_harness.ts +17 -35
  129. package/src/shared/gas_portal_test_harness.ts +21 -11
  130. package/src/shared/index.ts +0 -1
  131. package/src/shared/submit-transactions.ts +16 -20
  132. package/src/shared/uniswap_l1_l2.ts +35 -26
  133. package/src/simulators/lending_simulator.ts +5 -6
  134. package/src/simulators/token_simulator.ts +1 -1
  135. package/src/spartan/setup_test_wallets.ts +111 -37
  136. package/src/spartan/utils.ts +161 -54
  137. package/dest/shared/browser.js +0 -163
  138. package/src/shared/browser.ts +0 -272
@@ -1,5 +1,11 @@
1
1
  import { SchnorrAccountContractArtifact } from '@aztec/accounts/schnorr';
2
- import { createAccounts, getDeployedTestAccountsWallets } 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
11
  import {
@@ -10,9 +16,9 @@ import {
10
16
  BatchCall,
11
17
  CheatCodes,
12
18
  type ContractMethod,
13
- type DeployL1Contracts,
19
+ type DeployL1ContractsReturnType,
20
+ FeeJuicePaymentMethod,
14
21
  type Logger,
15
- NoFeePaymentMethod,
16
22
  type PXE,
17
23
  SignerlessWallet,
18
24
  type Wallet,
@@ -24,11 +30,10 @@ import {
24
30
  waitForPXE,
25
31
  } from '@aztec/aztec.js';
26
32
  import { deployInstance, registerContractClass } from '@aztec/aztec.js/deployment';
27
- import { DefaultMultiCallEntrypoint } from '@aztec/aztec.js/entrypoint';
28
- import { type BBNativePrivateKernelProver } from '@aztec/bb-prover';
33
+ import type { BBNativePrivateKernelProver } from '@aztec/bb-prover';
29
34
  import { createBlobSinkClient } from '@aztec/blob-sink/client';
30
35
  import { type BlobSinkServer, createBlobSinkServer } from '@aztec/blob-sink/server';
31
- import { FEE_JUICE_INITIAL_MINT, Fr, Gas, getContractClassFromArtifact } from '@aztec/circuits.js';
36
+ import { FEE_JUICE_INITIAL_MINT, GENESIS_ARCHIVE_ROOT, GENESIS_BLOCK_HASH } from '@aztec/constants';
32
37
  import {
33
38
  type DeployL1ContractsArgs,
34
39
  ForwarderContract,
@@ -41,15 +46,19 @@ import {
41
46
  import { DelayedTxUtils, EthCheatCodesWithState, startAnvil } from '@aztec/ethereum/test';
42
47
  import { randomBytes } from '@aztec/foundation/crypto';
43
48
  import { EthAddress } from '@aztec/foundation/eth-address';
49
+ import { Fr } from '@aztec/foundation/fields';
44
50
  import { retryUntil } from '@aztec/foundation/retry';
45
51
  import { TestDateProvider } from '@aztec/foundation/timer';
46
52
  import { FeeJuiceContract } from '@aztec/noir-contracts.js/FeeJuice';
47
- import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vks';
53
+ import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
48
54
  import { ProtocolContractAddress, protocolContractTreeRoot } from '@aztec/protocol-contracts';
49
55
  import { type ProverNode, type ProverNodeConfig, createProverNode } from '@aztec/prover-node';
50
56
  import { type PXEService, type PXEServiceConfig, createPXEService, getPXEServiceConfig } from '@aztec/pxe';
51
- import { type SequencerClient } from '@aztec/sequencer-client';
52
- import { type TestSequencerClient } from '@aztec/sequencer-client/test';
57
+ import type { SequencerClient } from '@aztec/sequencer-client';
58
+ import type { TestSequencerClient } from '@aztec/sequencer-client/test';
59
+ import { getContractClassFromArtifact } from '@aztec/stdlib/contract';
60
+ import { Gas } from '@aztec/stdlib/gas';
61
+ import type { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
53
62
  import {
54
63
  type TelemetryClient,
55
64
  type TelemetryClientConfig,
@@ -57,25 +66,15 @@ import {
57
66
  initTelemetryClient,
58
67
  } from '@aztec/telemetry-client';
59
68
  import { BenchmarkTelemetryClient } from '@aztec/telemetry-client/bench';
69
+ import { getGenesisValues } from '@aztec/world-state/testing';
60
70
 
61
- import { type Anvil } from '@viem/anvil';
71
+ import type { Anvil } from '@viem/anvil';
62
72
  import fs from 'fs/promises';
63
73
  import getPort from 'get-port';
64
74
  import { tmpdir } from 'os';
65
75
  import * as path from 'path';
66
76
  import { inspect } from 'util';
67
- import {
68
- type Account,
69
- type Chain,
70
- type HDAccount,
71
- type Hex,
72
- type HttpTransport,
73
- type PrivateKeyAccount,
74
- createPublicClient,
75
- createWalletClient,
76
- getContract,
77
- http,
78
- } from 'viem';
77
+ import { type Chain, type HDAccount, type Hex, type PrivateKeyAccount, getContract } from 'viem';
79
78
  import { mnemonicToAccount, privateKeyToAccount } from 'viem/accounts';
80
79
  import { foundry } from 'viem/chains';
81
80
 
@@ -111,19 +110,20 @@ export const getPrivateKeyFromIndex = (index: number): Buffer | null => {
111
110
  };
112
111
 
113
112
  export const setupL1Contracts = async (
114
- l1RpcUrl: string,
113
+ l1RpcUrls: string[],
115
114
  account: HDAccount | PrivateKeyAccount,
116
115
  logger: Logger,
117
116
  args: Partial<DeployL1ContractsArgs> = {},
118
117
  chain: Chain = foundry,
119
118
  ) => {
120
- const l1Data = await deployL1Contracts(l1RpcUrl, account, chain, logger, {
121
- l2FeeJuiceAddress: ProtocolContractAddress.FeeJuice,
122
- vkTreeRoot: await getVKTreeRoot(),
119
+ const l1Data = await deployL1Contracts(l1RpcUrls, account, chain, logger, {
120
+ l2FeeJuiceAddress: ProtocolContractAddress.FeeJuice.toField(),
121
+ vkTreeRoot: getVKTreeRoot(),
123
122
  protocolContractTreeRoot,
123
+ genesisArchiveRoot: args.genesisArchiveRoot ?? new Fr(GENESIS_ARCHIVE_ROOT),
124
+ genesisBlockHash: args.genesisBlockHash ?? new Fr(GENESIS_BLOCK_HASH),
124
125
  salt: args.salt,
125
126
  initialValidators: args.initialValidators,
126
- assumeProvenThrough: args.assumeProvenThrough,
127
127
  ...getL1ContractsConfigEnvVars(),
128
128
  ...args,
129
129
  });
@@ -173,7 +173,11 @@ export async function setupPXEService(
173
173
 
174
174
  const teardown = async () => {
175
175
  if (!configuredDataDirectory) {
176
- await fs.rm(pxeServiceConfig.dataDirectory!, { recursive: true, force: true });
176
+ try {
177
+ await fs.rm(pxeServiceConfig.dataDirectory!, { recursive: true, force: true, maxRetries: 3 });
178
+ } catch (err) {
179
+ logger.warn(`Failed to delete tmp PXE data directory ${pxeServiceConfig.dataDirectory}: ${err}`);
180
+ }
177
181
  }
178
182
  };
179
183
 
@@ -194,7 +198,7 @@ export async function setupPXEService(
194
198
  * @returns Private eXecution Environment (PXE) client, viem wallets, contract addresses etc.
195
199
  */
196
200
  async function setupWithRemoteEnvironment(
197
- account: Account,
201
+ account: HDAccount | PrivateKeyAccount,
198
202
  config: AztecNodeConfig,
199
203
  logger: Logger,
200
204
  numberOfAccounts: number,
@@ -204,41 +208,31 @@ async function setupWithRemoteEnvironment(
204
208
  logger.verbose(`Creating Aztec Node client to remote host ${aztecNodeUrl}`);
205
209
  const aztecNode = createAztecNodeClient(aztecNodeUrl);
206
210
  logger.verbose(`Creating PXE client to remote host ${PXE_URL}`);
207
- const pxeClient = createPXEClient(PXE_URL, makeFetch([1, 2, 3], true));
211
+ const pxeClient = createPXEClient(PXE_URL, {}, makeFetch([1, 2, 3], true));
208
212
  await waitForPXE(pxeClient, logger);
209
213
  logger.verbose('JSON RPC client connected to PXE');
210
214
  logger.verbose(`Retrieving contract addresses from ${PXE_URL}`);
211
215
  const l1Contracts = (await pxeClient.getNodeInfo()).l1ContractAddresses;
212
216
 
213
- const walletClient = createWalletClient<HttpTransport, Chain, HDAccount>({
214
- account,
215
- chain: foundry,
216
- transport: http(config.l1RpcUrl),
217
- });
218
- const publicClient = createPublicClient({
219
- chain: foundry,
220
- transport: http(config.l1RpcUrl),
221
- });
222
- const deployL1ContractsValues: DeployL1Contracts = {
217
+ const { walletClient, publicClient } = createL1Clients(config.l1RpcUrls, account, foundry);
218
+
219
+ const deployL1ContractsValues: DeployL1ContractsReturnType = {
223
220
  l1ContractAddresses: l1Contracts,
224
221
  walletClient,
225
222
  publicClient,
226
223
  };
227
- const cheatCodes = await CheatCodes.create(config.l1RpcUrl, pxeClient!);
224
+ const cheatCodes = await CheatCodes.create(config.l1RpcUrls, pxeClient!);
228
225
  const teardown = () => Promise.resolve();
229
226
 
230
- const { l1ChainId: chainId, protocolVersion } = await pxeClient.getNodeInfo();
231
- await setupCanonicalFeeJuice(
232
- new SignerlessWallet(pxeClient, new DefaultMultiCallEntrypoint(chainId, protocolVersion)),
233
- );
227
+ await setupCanonicalFeeJuice(pxeClient);
234
228
 
235
229
  logger.verbose('Constructing available wallets from already registered accounts...');
230
+ const initialFundedAccounts = await getDeployedTestAccounts(pxeClient);
236
231
  const wallets = await getDeployedTestAccountsWallets(pxeClient);
237
232
 
238
233
  if (wallets.length < numberOfAccounts) {
239
- const numNewAccounts = numberOfAccounts - wallets.length;
240
- logger.verbose(`Deploying ${numNewAccounts} accounts...`);
241
- wallets.push(...(await createAccounts(pxeClient, numNewAccounts)));
234
+ throw new Error(`Required ${numberOfAccounts} accounts. Found ${wallets.length}.`);
235
+ // Deploy new accounts if there's a test that requires more funded accounts in the remote environment.
242
236
  }
243
237
 
244
238
  return {
@@ -249,8 +243,9 @@ async function setupWithRemoteEnvironment(
249
243
  deployL1ContractsValues,
250
244
  accounts: await pxeClient!.getRegisteredAccounts(),
251
245
  config,
246
+ initialFundedAccounts,
252
247
  wallet: wallets[0],
253
- wallets,
248
+ wallets: wallets.slice(0, numberOfAccounts),
254
249
  logger,
255
250
  cheatCodes,
256
251
  watcher: undefined,
@@ -268,9 +263,15 @@ export type SetupOptions = {
268
263
  /** Whether to enable metrics collection, if undefined, metrics collection is disabled */
269
264
  metricsPort?: number | undefined;
270
265
  /** Previously deployed contracts on L1 */
271
- deployL1ContractsValues?: DeployL1Contracts;
266
+ deployL1ContractsValues?: DeployL1ContractsReturnType;
272
267
  /** Whether to skip deployment of protocol contracts (auth registry, etc) */
273
268
  skipProtocolContracts?: boolean;
269
+ /** Initial fee juice for default accounts */
270
+ initialAccountFeeJuice?: Fr;
271
+ /** Number of initial accounts funded with fee juice */
272
+ numberOfInitialFundedAccounts?: number;
273
+ /** Data of the initial funded accounts */
274
+ initialFundedAccounts?: InitialAccountData[];
274
275
  /** Salt to use in L1 contract deployment */
275
276
  salt?: number;
276
277
  /** An initial set of validators */
@@ -279,14 +280,14 @@ export type SetupOptions = {
279
280
  l1StartTime?: number;
280
281
  /** The anvil time where we should at the earliest be seeing L2 blocks */
281
282
  l2StartTime?: number;
282
- /** How far we should assume proven */
283
- assumeProvenThrough?: number;
284
283
  /** Whether to start a prover node */
285
284
  startProverNode?: boolean;
286
285
  /** Whether to fund the rewardDistributor */
287
286
  fundRewardDistributor?: boolean;
288
287
  /** Manual config for the telemetry client */
289
288
  telemetryConfig?: Partial<TelemetryClientConfig> & { benchmark?: boolean };
289
+ /** Public data that will be inserted in the tree in genesis */
290
+ genesisPublicData?: PublicDataTreeLeaf[];
290
291
  } & Partial<AztecNodeConfig>;
291
292
 
292
293
  /** Context for an end-to-end test as returned by the `setup` function */
@@ -300,9 +301,11 @@ export type EndToEndContext = {
300
301
  /** The Private eXecution Environment (PXE). */
301
302
  pxe: PXE;
302
303
  /** Return values from deployL1Contracts function. */
303
- deployL1ContractsValues: DeployL1Contracts;
304
+ deployL1ContractsValues: DeployL1ContractsReturnType;
304
305
  /** The Aztec Node configuration. */
305
306
  config: AztecNodeConfig;
307
+ /** The data for the initial funded accounts. */
308
+ initialFundedAccounts: InitialAccountData[];
306
309
  /** The first wallet to be used. */
307
310
  wallet: AccountWalletWithSecretKey;
308
311
  /** The wallets to be used. */
@@ -332,7 +335,6 @@ export type EndToEndContext = {
332
335
  export async function setup(
333
336
  numberOfAccounts = 1,
334
337
  opts: SetupOptions = {
335
- assumeProvenThrough: Number.MAX_SAFE_INTEGER,
336
338
  customForwarderContractAddress: EthAddress.ZERO,
337
339
  },
338
340
  pxeOpts: Partial<PXEServiceConfig> = {},
@@ -352,19 +354,19 @@ export async function setup(
352
354
 
353
355
  let anvil: Anvil | undefined;
354
356
 
355
- if (!config.l1RpcUrl) {
357
+ if (!config.l1RpcUrls?.length) {
356
358
  if (!isAnvilTestChain(chain.id)) {
357
- throw new Error(`No ETHEREUM_HOST set but non anvil chain requested`);
359
+ throw new Error(`No ETHEREUM_HOSTS set but non anvil chain requested`);
358
360
  }
359
361
  if (PXE_URL) {
360
362
  throw new Error(
361
- `PXE_URL provided but no ETHEREUM_HOST set. Refusing to run, please set both variables so tests can deploy L1 contracts to the same Anvil instance`,
363
+ `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`,
362
364
  );
363
365
  }
364
366
 
365
- const res = await startAnvil(opts.ethereumSlotDuration);
367
+ const res = await startAnvil({ l1BlockTime: opts.ethereumSlotDuration });
366
368
  anvil = res.anvil;
367
- config.l1RpcUrl = res.rpcUrl;
369
+ config.l1RpcUrls = [res.rpcUrl];
368
370
  }
369
371
 
370
372
  // Enable logging metrics to a local file named after the test suite
@@ -374,7 +376,7 @@ export async function setup(
374
376
  setupMetricsLogger(filename);
375
377
  }
376
378
 
377
- const ethCheatCodes = new EthCheatCodesWithState(config.l1RpcUrl);
379
+ const ethCheatCodes = new EthCheatCodesWithState(config.l1RpcUrls);
378
380
 
379
381
  if (opts.stateLoad) {
380
382
  await ethCheatCodes.loadChainState(opts.stateLoad);
@@ -412,8 +414,24 @@ export async function setup(
412
414
  await blobSink.start();
413
415
  config.blobSinkUrl = `http://localhost:${blobSinkPort}`;
414
416
 
417
+ const initialFundedAccounts =
418
+ opts.initialFundedAccounts ??
419
+ (await generateSchnorrAccounts(opts.numberOfInitialFundedAccounts ?? numberOfAccounts));
420
+ const { genesisBlockHash, genesisArchiveRoot, prefilledPublicData } = await getGenesisValues(
421
+ initialFundedAccounts.map(a => a.address),
422
+ opts.initialAccountFeeJuice,
423
+ opts.genesisPublicData,
424
+ );
425
+
415
426
  const deployL1ContractsValues =
416
- opts.deployL1ContractsValues ?? (await setupL1Contracts(config.l1RpcUrl, publisherHdAccount!, logger, opts, chain));
427
+ opts.deployL1ContractsValues ??
428
+ (await setupL1Contracts(
429
+ config.l1RpcUrls,
430
+ publisherHdAccount!,
431
+ logger,
432
+ { ...opts, genesisArchiveRoot, genesisBlockHash },
433
+ chain,
434
+ ));
417
435
 
418
436
  config.l1Contracts = deployL1ContractsValues.l1ContractAddresses;
419
437
 
@@ -449,7 +467,7 @@ export async function setup(
449
467
  const dateProvider = new TestDateProvider();
450
468
 
451
469
  const watcher = new AnvilTestWatcher(
452
- new EthCheatCodesWithState(config.l1RpcUrl),
470
+ new EthCheatCodesWithState(config.l1RpcUrls),
453
471
  deployL1ContractsValues.l1ContractAddresses.rollupAddress,
454
472
  deployL1ContractsValues.publicClient,
455
473
  dateProvider,
@@ -475,10 +493,14 @@ export async function setup(
475
493
  const telemetry = getTelemetryClient(opts.telemetryConfig);
476
494
 
477
495
  const blobSinkClient = createBlobSinkClient(config);
478
- const aztecNode = await AztecNodeService.createAndSync(config, {
479
- dateProvider,
480
- blobSinkClient,
481
- });
496
+ const aztecNode = await AztecNodeService.createAndSync(
497
+ config,
498
+ {
499
+ dateProvider,
500
+ blobSinkClient,
501
+ },
502
+ { prefilledPublicData },
503
+ );
482
504
  const sequencer = aztecNode.getSequencer();
483
505
 
484
506
  if (sequencer) {
@@ -504,13 +526,19 @@ export async function setup(
504
526
 
505
527
  if (!config.skipProtocolContracts) {
506
528
  logger.verbose('Setting up Fee Juice...');
507
- await setupCanonicalFeeJuice(
508
- new SignerlessWallet(pxe, new DefaultMultiCallEntrypoint(config.l1ChainId, config.version)),
529
+ await setupCanonicalFeeJuice(pxe);
530
+ }
531
+
532
+ const accountManagers = await deployFundedSchnorrAccounts(pxe, initialFundedAccounts.slice(0, numberOfAccounts));
533
+ const wallets = await Promise.all(accountManagers.map(account => account.getWallet()));
534
+ if (initialFundedAccounts.length < numberOfAccounts) {
535
+ // TODO: Create (numberOfAccounts - initialFundedAccounts.length) wallets without funds.
536
+ throw new Error(
537
+ `Unable to deploy ${numberOfAccounts} accounts. Only ${initialFundedAccounts.length} accounts were funded.`,
509
538
  );
510
539
  }
511
540
 
512
- const wallets = numberOfAccounts > 0 ? await createAccounts(pxe, numberOfAccounts) : [];
513
- const cheatCodes = await CheatCodes.create(config.l1RpcUrl, pxe!);
541
+ const cheatCodes = await CheatCodes.create(config.l1RpcUrls, pxe!);
514
542
 
515
543
  const teardown = async () => {
516
544
  await pxeTeardown();
@@ -519,6 +547,10 @@ export async function setup(
519
547
  await aztecNode?.stop();
520
548
  }
521
549
 
550
+ if (proverNode) {
551
+ await proverNode.stop();
552
+ }
553
+
522
554
  if (acvmConfig?.cleanup) {
523
555
  // remove the temp directory created for the acvm
524
556
  logger.verbose(`Cleaning up ACVM state`);
@@ -531,32 +563,37 @@ export async function setup(
531
563
  await bbConfig.cleanup();
532
564
  }
533
565
 
534
- await anvil?.stop();
566
+ await anvil?.stop().catch(err => getLogger().error(err));
535
567
  await watcher.stop();
536
568
  await blobSink?.stop();
537
569
 
538
570
  if (directoryToCleanup) {
539
- logger.verbose(`Cleaning up data directory at ${directoryToCleanup}`);
540
- await fs.rm(directoryToCleanup, { recursive: true, force: true });
571
+ try {
572
+ logger.verbose(`Cleaning up data directory at ${directoryToCleanup}`);
573
+ await fs.rm(directoryToCleanup, { recursive: true, force: true, maxRetries: 3 });
574
+ } catch (err) {
575
+ logger.warn(`Failed to delete data directory at ${directoryToCleanup}: ${err}`);
576
+ }
541
577
  }
542
578
  };
543
579
 
544
580
  return {
545
581
  aztecNode,
582
+ blobSink,
583
+ cheatCodes,
584
+ config,
585
+ dateProvider,
586
+ deployL1ContractsValues,
587
+ initialFundedAccounts,
588
+ logger,
546
589
  proverNode,
547
590
  pxe,
548
- deployL1ContractsValues,
549
- config,
591
+ sequencer,
592
+ teardown,
593
+ telemetryClient: telemetry,
550
594
  wallet: wallets[0],
551
595
  wallets,
552
- logger,
553
- cheatCodes,
554
- sequencer,
555
596
  watcher,
556
- dateProvider,
557
- blobSink,
558
- telemetryClient: telemetry,
559
- teardown,
560
597
  };
561
598
  }
562
599
 
@@ -684,9 +721,10 @@ export async function setupCanonicalFeeJuice(pxe: PXE) {
684
721
  const feeJuice = await FeeJuiceContract.at(ProtocolContractAddress.FeeJuice, wallet);
685
722
 
686
723
  try {
724
+ const paymentMethod = new FeeJuicePaymentMethod(ProtocolContractAddress.FeeJuice);
687
725
  await feeJuice.methods
688
726
  .initialize(feeJuicePortalAddress, FEE_JUICE_INITIAL_MINT)
689
- .send({ fee: { paymentMethod: new NoFeePaymentMethod(), gasSettings: { teardownGasLimits: Gas.empty() } } })
727
+ .send({ fee: { paymentMethod, gasSettings: { teardownGasLimits: Gas.empty() } } })
690
728
  .wait();
691
729
  getLogger().info(`Fee Juice successfully setup. Portal address: ${feeJuicePortalAddress}`);
692
730
  } catch (error) {
@@ -710,11 +748,11 @@ export async function createAndSyncProverNode(
710
748
  aztecNodeConfig: AztecNodeConfig,
711
749
  aztecNode: AztecNode,
712
750
  dataDirectory: string,
751
+ prefilledPublicData: PublicDataTreeLeaf[] = [],
713
752
  ) {
714
753
  // Disable stopping the aztec node as the prover coordination test will kill it otherwise
715
754
  // This is only required when stopping the prover node for testing
716
755
  const aztecNodeWithoutStop = {
717
- addEpochProofQuote: aztecNode.addEpochProofQuote.bind(aztecNode),
718
756
  getTxByHash: aztecNode.getTxByHash.bind(aztecNode),
719
757
  getTxsByHash: aztecNode.getTxsByHash.bind(aztecNode),
720
758
  stop: () => Promise.resolve(),
@@ -732,17 +770,12 @@ export async function createAndSyncProverNode(
732
770
  ...aztecNodeConfig,
733
771
  proverCoordinationNodeUrl: undefined,
734
772
  dataDirectory: undefined,
735
- proverId: new Fr(42),
736
773
  realProofs: false,
737
774
  proverAgentCount: 2,
738
775
  publisherPrivateKey: proverNodePrivateKey,
739
776
  proverNodeMaxPendingJobs: 10,
740
777
  proverNodeMaxParallelBlocksPerEpoch: 32,
741
778
  proverNodePollingIntervalMs: 200,
742
- quoteProviderBasisPointFee: 100,
743
- quoteProviderBondAmount: 1000n,
744
- proverMinimumEscrowAmount: 1000n,
745
- proverTargetEscrowAmount: 2000n,
746
779
  txGatheringTimeoutMs: 60000,
747
780
  txGatheringIntervalMs: 1000,
748
781
  txGatheringMaxParallelRequests: 100,
@@ -750,17 +783,22 @@ export async function createAndSyncProverNode(
750
783
 
751
784
  const l1TxUtils = createDelayedL1TxUtils(aztecNodeConfig, proverNodePrivateKey, 'prover-node');
752
785
 
753
- const proverNode = await createProverNode(proverConfig, {
754
- aztecNodeTxProvider: aztecNodeWithoutStop,
755
- archiver: archiver as Archiver,
756
- l1TxUtils,
757
- });
758
- await proverNode.start();
786
+ const proverNode = await createProverNode(
787
+ proverConfig,
788
+ {
789
+ aztecNodeTxProvider: aztecNodeWithoutStop,
790
+ archiver: archiver as Archiver,
791
+ l1TxUtils,
792
+ },
793
+ { prefilledPublicData },
794
+ );
795
+ getLogger().info(`Created and synced prover node`, { publisherAddress: l1TxUtils.walletClient.account.address });
796
+ proverNode.start();
759
797
  return proverNode;
760
798
  }
761
799
 
762
800
  function createDelayedL1TxUtils(aztecNodeConfig: AztecNodeConfig, privateKey: `0x${string}`, logName: string) {
763
- const { publicClient, walletClient } = createL1Clients(aztecNodeConfig.l1RpcUrl, privateKey, foundry);
801
+ const { publicClient, walletClient } = createL1Clients(aztecNodeConfig.l1RpcUrls, privateKey, foundry);
764
802
 
765
803
  const log = createLogger(logName);
766
804
  const l1TxUtils = new DelayedTxUtils(publicClient, walletClient, log, aztecNodeConfig);
@@ -773,7 +811,7 @@ export async function createForwarderContract(
773
811
  privateKey: `0x${string}`,
774
812
  rollupAddress: Hex,
775
813
  ) {
776
- const { walletClient, publicClient } = createL1Clients(aztecNodeConfig.l1RpcUrl, privateKey, foundry);
814
+ const { walletClient, publicClient } = createL1Clients(aztecNodeConfig.l1RpcUrls, privateKey, foundry);
777
815
  const forwarderContract = await ForwarderContract.create(
778
816
  walletClient.account.address,
779
817
  walletClient,
@@ -15,20 +15,22 @@ aztec-wallet() {
15
15
  node --no-warnings ../cli-wallet/dest/bin/index.js "$@"
16
16
  }
17
17
 
18
+ aztec-wallet import-test-accounts
19
+
18
20
  # docs:start:declare-accounts
19
- aztec-wallet create-account -a alice
20
- aztec-wallet create-account -a bob
21
+ aztec-wallet create-account -a alice --payment method=fee_juice,feePayer=test0
22
+ aztec-wallet create-account -a bob --payment method=fee_juice,feePayer=test0
21
23
  # docs:end:declare-accounts
22
24
 
23
25
  # docs:start:deploy
24
- DEPLOY_OUTPUT=$(aztec-wallet deploy ../noir-contracts.js/artifacts/token_contract-Token.json --args accounts:alice Test TST 18 -f alice)
26
+ DEPLOY_OUTPUT=$(aztec-wallet deploy ../noir-contracts.js/artifacts/token_contract-Token.json --args accounts:test0 Test TST 18 -f test0)
25
27
  TOKEN_ADDRESS=$(echo "$DEPLOY_OUTPUT" | grep -oE 'Contract deployed at 0x[0-9a-fA-F]+' | cut -d ' ' -f4)
26
28
  echo "Deployed contract at $TOKEN_ADDRESS"
27
29
  # docs:end:deploy
28
30
 
29
31
  # docs:start:mint-private
30
32
  MINT_AMOUNT=69
31
- aztec-wallet send mint_to_private -ca last --args accounts:alice accounts:alice $MINT_AMOUNT -f alice
33
+ aztec-wallet send mint_to_private -ca last --args accounts:test0 accounts:alice $MINT_AMOUNT -f test0
32
34
  # docs:end:mint-private
33
35
 
34
36
  # docs:start:get-balance
@@ -42,7 +44,10 @@ fi
42
44
  # docs:start:transfer
43
45
  TRANSFER_AMOUNT=42
44
46
 
45
- aztec-wallet send transfer -ca last --args accounts:bob $TRANSFER_AMOUNT -f alice
47
+ aztec-wallet create-authwit transfer_in_private accounts:test0 -ca last --args accounts:alice accounts:bob $TRANSFER_AMOUNT 1 -f alice
48
+ aztec-wallet add-authwit authwits:last alice -f test0
49
+
50
+ aztec-wallet send transfer_in_private -ca last --args accounts:alice accounts:bob $TRANSFER_AMOUNT 1 -f test0
46
51
  # docs:end:transfer
47
52
 
48
53
  # Test end result
@@ -1,4 +1,4 @@
1
- import { type Logger } from '@aztec/aztec.js';
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';
@@ -98,7 +98,7 @@ export class AlertChecker {
98
98
  }
99
99
 
100
100
  if (alertTriggered) {
101
- throw new Error('Test failed due to triggered alert');
101
+ throw new AlertTriggeredError('Test failed due to triggered alert');
102
102
  }
103
103
  }
104
104
 
@@ -125,3 +125,7 @@ export class AlertChecker {
125
125
  await this.checkAlerts(alerts);
126
126
  }
127
127
  }
128
+
129
+ export class AlertTriggeredError extends Error {
130
+ override name = 'AlertTriggeredError';
131
+ }
@@ -40,7 +40,7 @@ async function mintPrivateFunds(pxe) {
40
40
 
41
41
  // We mint tokens to the owner
42
42
  const mintAmount = 20n;
43
- const from = ownerWallet.getAddress(); // we are setting from to owner here because of TODO(#9887)
43
+ const from = ownerWallet.getAddress(); // we are setting from to owner here because we need a sender to calculate the tag
44
44
  await token.methods.mint_to_private(from, ownerWallet.getAddress(), mintAmount).send().wait();
45
45
 
46
46
  await showPrivateBalances(pxe);
@@ -18,20 +18,12 @@ import {
18
18
  deployL1Contract,
19
19
  retryUntil,
20
20
  } from '@aztec/aztec.js';
21
- import { type L1ContractAddresses } from '@aztec/ethereum';
22
- import { TestERC20Abi, TestERC20Bytecode, TokenPortalAbi, TokenPortalBytecode } from '@aztec/l1-artifacts';
21
+ import type { L1ContractAddresses, ViemPublicClient, ViemWalletClient } from '@aztec/ethereum';
22
+ import { TestERC20Abi, TokenPortalAbi, TokenPortalBytecode } from '@aztec/l1-artifacts';
23
23
  import { TokenContract } from '@aztec/noir-contracts.js/Token';
24
24
  import { TokenBridgeContract } from '@aztec/noir-contracts.js/TokenBridge';
25
25
 
26
- import {
27
- type Account,
28
- type Chain,
29
- type Hex,
30
- type HttpTransport,
31
- type PublicClient,
32
- type WalletClient,
33
- getContract,
34
- } from 'viem';
26
+ import { type Hex, getContract } from 'viem';
35
27
 
36
28
  import { mintTokensToPrivate } from '../fixtures/token_utils.js';
37
29
 
@@ -48,11 +40,11 @@ import { mintTokensToPrivate } from '../fixtures/token_utils.js';
48
40
  */
49
41
  export async function deployAndInitializeTokenAndBridgeContracts(
50
42
  wallet: Wallet,
51
- walletClient: WalletClient<HttpTransport, Chain, Account>,
52
- publicClient: PublicClient<HttpTransport, Chain>,
43
+ walletClient: ViemWalletClient,
44
+ publicClient: ViemPublicClient,
53
45
  rollupRegistryAddress: EthAddress,
54
46
  owner: AztecAddress,
55
- underlyingERC20Address?: EthAddress,
47
+ underlyingERC20Address: EthAddress,
56
48
  ): Promise<{
57
49
  /**
58
50
  * The L2 token contract instance.
@@ -75,22 +67,6 @@ export async function deployAndInitializeTokenAndBridgeContracts(
75
67
  */
76
68
  underlyingERC20: any;
77
69
  }> {
78
- if (!underlyingERC20Address) {
79
- underlyingERC20Address = await deployL1Contract(walletClient, publicClient, TestERC20Abi, TestERC20Bytecode, [
80
- 'Underlying',
81
- 'UND',
82
- walletClient.account.address,
83
- ]).then(({ address }) => address);
84
- }
85
- const underlyingERC20 = getContract({
86
- address: underlyingERC20Address!.toString(),
87
- abi: TestERC20Abi,
88
- client: walletClient,
89
- });
90
-
91
- // allow anyone to mint
92
- await underlyingERC20.write.setFreeForAll([true], {} as any);
93
-
94
70
  // deploy the token portal
95
71
  const { address: tokenPortalAddress } = await deployL1Contract(
96
72
  walletClient,
@@ -130,6 +106,12 @@ export async function deployAndInitializeTokenAndBridgeContracts(
130
106
  {} as any,
131
107
  );
132
108
 
109
+ const underlyingERC20 = getContract({
110
+ address: underlyingERC20Address.toString(),
111
+ abi: TestERC20Abi,
112
+ client: walletClient,
113
+ });
114
+
133
115
  return { token, bridge, tokenPortalAddress, tokenPortal, underlyingERC20 };
134
116
  }
135
117
  // docs:end:deployAndInitializeTokenAndBridgeContracts
@@ -142,11 +124,11 @@ export class CrossChainTestHarness {
142
124
  static async new(
143
125
  aztecNode: AztecNode,
144
126
  pxeService: PXE,
145
- publicClient: PublicClient<HttpTransport, Chain>,
146
- walletClient: WalletClient<HttpTransport, Chain, Account>,
127
+ publicClient: ViemPublicClient,
128
+ walletClient: ViemWalletClient,
147
129
  wallet: AccountWallet,
148
130
  logger: Logger,
149
- underlyingERC20Address?: EthAddress,
131
+ underlyingERC20Address: EthAddress,
150
132
  ): Promise<CrossChainTestHarness> {
151
133
  const ethAccount = EthAddress.fromString((await walletClient.getAddresses())[0]);
152
134
  const l1ContractAddresses = (await pxeService.getNodeInfo()).l1ContractAddresses;
@@ -205,9 +187,9 @@ export class CrossChainTestHarness {
205
187
  /** Underlying token for portal tests. */
206
188
  public underlyingERC20Address: EthAddress,
207
189
  /** Viem Public client instance. */
208
- public publicClient: PublicClient<HttpTransport, Chain>,
190
+ public publicClient: ViemPublicClient,
209
191
  /** Viem Wallet Client instance. */
210
- public walletClient: WalletClient<HttpTransport, Chain, Account>,
192
+ public walletClient: ViemWalletClient,
211
193
 
212
194
  /** Deployment addresses for all L1 contracts */
213
195
  public readonly l1ContractAddresses: L1ContractAddresses,