@aztec/end-to-end 0.0.1-commit.1bb068fb5 → 0.0.1-commit.1dcfe2301

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 (156) hide show
  1. package/README.md +27 -0
  2. package/dest/bench/client_flows/client_flows_benchmark.d.ts +1 -1
  3. package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
  4. package/dest/bench/client_flows/client_flows_benchmark.js +19 -26
  5. package/dest/bench/utils.d.ts +1 -1
  6. package/dest/bench/utils.d.ts.map +1 -1
  7. package/dest/bench/utils.js +6 -3
  8. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts +3 -2
  9. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.d.ts.map +1 -1
  10. package/dest/e2e_blacklist_token_contract/blacklist_token_contract_test.js +15 -15
  11. package/dest/e2e_epochs/epochs_test.d.ts +11 -7
  12. package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
  13. package/dest/e2e_epochs/epochs_test.js +60 -38
  14. package/dest/e2e_fees/fees_test.d.ts +1 -1
  15. package/dest/e2e_fees/fees_test.d.ts.map +1 -1
  16. package/dest/e2e_fees/fees_test.js +14 -7
  17. package/dest/e2e_nested_contract/nested_contract_test.d.ts +1 -1
  18. package/dest/e2e_nested_contract/nested_contract_test.d.ts.map +1 -1
  19. package/dest/e2e_nested_contract/nested_contract_test.js +4 -6
  20. package/dest/e2e_p2p/inactivity_slash_test.js +3 -3
  21. package/dest/e2e_p2p/p2p_network.d.ts +8 -9
  22. package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
  23. package/dest/e2e_p2p/p2p_network.js +38 -20
  24. package/dest/e2e_p2p/reqresp/utils.d.ts +3 -3
  25. package/dest/e2e_p2p/reqresp/utils.d.ts.map +1 -1
  26. package/dest/e2e_p2p/reqresp/utils.js +46 -9
  27. package/dest/e2e_p2p/shared.d.ts +25 -7
  28. package/dest/e2e_p2p/shared.d.ts.map +1 -1
  29. package/dest/e2e_p2p/shared.js +49 -44
  30. package/dest/e2e_token_contract/token_contract_test.d.ts +1 -1
  31. package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
  32. package/dest/e2e_token_contract/token_contract_test.js +11 -11
  33. package/dest/fixtures/authwit_proxy.d.ts +3 -3
  34. package/dest/fixtures/authwit_proxy.d.ts.map +1 -1
  35. package/dest/fixtures/authwit_proxy.js +4 -0
  36. package/dest/fixtures/e2e_prover_test.d.ts +6 -5
  37. package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
  38. package/dest/fixtures/e2e_prover_test.js +37 -49
  39. package/dest/fixtures/elu_monitor.d.ts +21 -0
  40. package/dest/fixtures/elu_monitor.d.ts.map +1 -0
  41. package/dest/fixtures/elu_monitor.js +102 -0
  42. package/dest/fixtures/fixtures.d.ts +5 -1
  43. package/dest/fixtures/fixtures.d.ts.map +1 -1
  44. package/dest/fixtures/fixtures.js +6 -0
  45. package/dest/fixtures/get_bb_config.d.ts +1 -1
  46. package/dest/fixtures/get_bb_config.d.ts.map +1 -1
  47. package/dest/fixtures/get_bb_config.js +5 -5
  48. package/dest/fixtures/setup.d.ts +39 -15
  49. package/dest/fixtures/setup.d.ts.map +1 -1
  50. package/dest/fixtures/setup.js +71 -96
  51. package/dest/fixtures/setup_p2p_test.d.ts +10 -7
  52. package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
  53. package/dest/fixtures/setup_p2p_test.js +18 -15
  54. package/dest/fixtures/token_utils.d.ts +2 -2
  55. package/dest/fixtures/token_utils.d.ts.map +1 -1
  56. package/dest/fixtures/token_utils.js +5 -7
  57. package/dest/forward-compatibility/wallet_rpc_client.d.ts +7 -0
  58. package/dest/forward-compatibility/wallet_rpc_client.d.ts.map +1 -0
  59. package/dest/forward-compatibility/wallet_rpc_client.js +15 -0
  60. package/dest/forward-compatibility/wallet_service.d.ts +3 -0
  61. package/dest/forward-compatibility/wallet_service.d.ts.map +1 -0
  62. package/dest/forward-compatibility/wallet_service.js +109 -0
  63. package/dest/legacy-jest-resolver.d.cts +3 -0
  64. package/dest/legacy-jest-resolver.d.cts.map +1 -0
  65. package/dest/shared/cross_chain_test_harness.d.ts +1 -1
  66. package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
  67. package/dest/shared/cross_chain_test_harness.js +13 -13
  68. package/dest/shared/gas_portal_test_harness.js +2 -2
  69. package/dest/shared/jest_setup.js +41 -1
  70. package/dest/shared/submit-transactions.js +1 -1
  71. package/dest/shared/uniswap_l1_l2.d.ts +1 -1
  72. package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
  73. package/dest/shared/uniswap_l1_l2.js +14 -17
  74. package/dest/simulators/lending_simulator.d.ts +1 -1
  75. package/dest/simulators/lending_simulator.d.ts.map +1 -1
  76. package/dest/simulators/lending_simulator.js +4 -4
  77. package/dest/simulators/token_simulator.d.ts +1 -1
  78. package/dest/simulators/token_simulator.d.ts.map +1 -1
  79. package/dest/simulators/token_simulator.js +2 -2
  80. package/dest/spartan/setup_test_wallets.d.ts +11 -2
  81. package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
  82. package/dest/spartan/setup_test_wallets.js +97 -38
  83. package/dest/spartan/tx_metrics.js +1 -1
  84. package/dest/spartan/utils/bot.d.ts +3 -2
  85. package/dest/spartan/utils/bot.d.ts.map +1 -1
  86. package/dest/spartan/utils/bot.js +2 -1
  87. package/dest/spartan/utils/config.d.ts +7 -1
  88. package/dest/spartan/utils/config.d.ts.map +1 -1
  89. package/dest/spartan/utils/config.js +3 -1
  90. package/dest/spartan/utils/index.d.ts +4 -2
  91. package/dest/spartan/utils/index.d.ts.map +1 -1
  92. package/dest/spartan/utils/index.js +5 -1
  93. package/dest/spartan/utils/k8s.d.ts +3 -1
  94. package/dest/spartan/utils/k8s.d.ts.map +1 -1
  95. package/dest/spartan/utils/k8s.js +6 -0
  96. package/dest/spartan/utils/nodes.d.ts +4 -5
  97. package/dest/spartan/utils/nodes.d.ts.map +1 -1
  98. package/dest/spartan/utils/nodes.js +9 -9
  99. package/dest/spartan/utils/pod_logs.d.ts +25 -0
  100. package/dest/spartan/utils/pod_logs.d.ts.map +1 -0
  101. package/dest/spartan/utils/pod_logs.js +74 -0
  102. package/dest/test-wallet/test_wallet.d.ts +24 -23
  103. package/dest/test-wallet/test_wallet.d.ts.map +1 -1
  104. package/dest/test-wallet/test_wallet.js +116 -81
  105. package/dest/test-wallet/wallet_worker_script.d.ts +2 -0
  106. package/dest/test-wallet/wallet_worker_script.d.ts.map +1 -0
  107. package/dest/test-wallet/wallet_worker_script.js +48 -0
  108. package/dest/test-wallet/worker_wallet.d.ts +52 -0
  109. package/dest/test-wallet/worker_wallet.d.ts.map +1 -0
  110. package/dest/test-wallet/worker_wallet.js +151 -0
  111. package/dest/test-wallet/worker_wallet_schema.d.ts +279 -0
  112. package/dest/test-wallet/worker_wallet_schema.d.ts.map +1 -0
  113. package/dest/test-wallet/worker_wallet_schema.js +10 -0
  114. package/package.json +43 -44
  115. package/src/bench/client_flows/client_flows_benchmark.ts +27 -10
  116. package/src/bench/utils.ts +7 -2
  117. package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +21 -20
  118. package/src/e2e_epochs/epochs_test.ts +78 -66
  119. package/src/e2e_fees/fees_test.ts +14 -7
  120. package/src/e2e_nested_contract/nested_contract_test.ts +6 -4
  121. package/src/e2e_p2p/inactivity_slash_test.ts +3 -3
  122. package/src/e2e_p2p/p2p_network.ts +53 -32
  123. package/src/e2e_p2p/reqresp/utils.ts +58 -9
  124. package/src/e2e_p2p/shared.ts +71 -59
  125. package/src/e2e_token_contract/token_contract_test.ts +16 -8
  126. package/src/fixtures/authwit_proxy.ts +4 -0
  127. package/src/fixtures/dumps/epoch_proof_result.json +1 -1
  128. package/src/fixtures/e2e_prover_test.ts +43 -52
  129. package/src/fixtures/elu_monitor.ts +126 -0
  130. package/src/fixtures/fixtures.ts +10 -0
  131. package/src/fixtures/get_bb_config.ts +7 -6
  132. package/src/fixtures/setup.ts +103 -132
  133. package/src/fixtures/setup_p2p_test.ts +17 -25
  134. package/src/fixtures/token_utils.ts +3 -3
  135. package/src/forward-compatibility/wallet_rpc_client.ts +14 -0
  136. package/src/forward-compatibility/wallet_service.ts +104 -0
  137. package/src/legacy-jest-resolver.cjs +135 -0
  138. package/src/shared/cross_chain_test_harness.ts +13 -9
  139. package/src/shared/gas_portal_test_harness.ts +1 -1
  140. package/src/shared/jest_setup.ts +51 -1
  141. package/src/shared/submit-transactions.ts +1 -1
  142. package/src/shared/uniswap_l1_l2.ts +35 -28
  143. package/src/simulators/lending_simulator.ts +8 -4
  144. package/src/simulators/token_simulator.ts +6 -2
  145. package/src/spartan/setup_test_wallets.ts +138 -31
  146. package/src/spartan/tx_metrics.ts +1 -1
  147. package/src/spartan/utils/bot.ts +3 -0
  148. package/src/spartan/utils/config.ts +2 -0
  149. package/src/spartan/utils/index.ts +7 -0
  150. package/src/spartan/utils/k8s.ts +8 -0
  151. package/src/spartan/utils/nodes.ts +15 -10
  152. package/src/spartan/utils/pod_logs.ts +99 -0
  153. package/src/test-wallet/test_wallet.ts +145 -100
  154. package/src/test-wallet/wallet_worker_script.ts +60 -0
  155. package/src/test-wallet/worker_wallet.ts +214 -0
  156. package/src/test-wallet/worker_wallet_schema.ts +13 -0
@@ -1,12 +1,14 @@
1
1
  import { SchnorrAccountContractArtifact } from '@aztec/accounts/schnorr';
2
2
  import { type InitialAccountData, generateSchnorrAccounts } from '@aztec/accounts/testing';
3
- import { type Archiver, createArchiver } from '@aztec/archiver';
4
3
  import { type AztecNodeConfig, AztecNodeService, getConfigEnvVars } from '@aztec/aztec-node';
4
+ import { NO_FROM } from '@aztec/aztec.js/account';
5
5
  import { AztecAddress, EthAddress } from '@aztec/aztec.js/addresses';
6
6
  import {
7
7
  BatchCall,
8
8
  type ContractFunctionInteraction,
9
9
  type ContractMethod,
10
+ type DeployInteractionWaitOptions,
11
+ type DeployOptions,
10
12
  getContractClassFromArtifact,
11
13
  waitForProven,
12
14
  } from '@aztec/aztec.js/contracts';
@@ -16,7 +18,6 @@ import { type Logger, createLogger } from '@aztec/aztec.js/log';
16
18
  import type { AztecNode } from '@aztec/aztec.js/node';
17
19
  import type { Wallet } from '@aztec/aztec.js/wallet';
18
20
  import { AnvilTestWatcher, CheatCodes } from '@aztec/aztec/testing';
19
- import { createBlobClientWithFileStores } from '@aztec/blob-client/client';
20
21
  import { SPONSORED_FPC_SALT } from '@aztec/constants';
21
22
  import { isAnvilTestChain } from '@aztec/ethereum/chain';
22
23
  import { createExtendedL1Client } from '@aztec/ethereum/client';
@@ -30,13 +31,9 @@ import {
30
31
  type ZKPassportArgs,
31
32
  deployAztecL1Contracts,
32
33
  } from '@aztec/ethereum/deploy-aztec-l1-contracts';
33
- import {
34
- DelayedTxUtils,
35
- EthCheatCodes,
36
- EthCheatCodesWithState,
37
- createDelayedL1TxUtilsFromViemWallet,
38
- startAnvil,
39
- } from '@aztec/ethereum/test';
34
+ import type { Delayer } from '@aztec/ethereum/l1-tx-utils';
35
+ import { EthCheatCodes, EthCheatCodesWithState, startAnvil } from '@aztec/ethereum/test';
36
+ import type { Anvil } from '@aztec/ethereum/test';
40
37
  import { BlockNumber, EpochNumber } from '@aztec/foundation/branded-types';
41
38
  import { SecretValue } from '@aztec/foundation/config';
42
39
  import { randomBytes } from '@aztec/foundation/crypto/random';
@@ -45,21 +42,19 @@ import { withLoggerBindings } from '@aztec/foundation/log/server';
45
42
  import { retryUntil } from '@aztec/foundation/retry';
46
43
  import { sleep } from '@aztec/foundation/sleep';
47
44
  import { DateProvider, TestDateProvider } from '@aztec/foundation/timer';
48
- import type { DataStoreConfig } from '@aztec/kv-store/config';
49
45
  import { SponsoredFPCContract } from '@aztec/noir-contracts.js/SponsoredFPC';
50
46
  import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
51
47
  import type { P2PClientDeps } from '@aztec/p2p';
52
48
  import { MockGossipSubNetwork, getMockPubSubP2PServiceFactory } from '@aztec/p2p/test-helpers';
53
49
  import { protocolContractsHash } from '@aztec/protocol-contracts';
54
- import { type ProverNode, type ProverNodeConfig, type ProverNodeDeps, createProverNode } from '@aztec/prover-node';
50
+ import type { ProverNodeConfig } from '@aztec/prover-node';
55
51
  import { type PXEConfig, getPXEConfig } from '@aztec/pxe/server';
56
52
  import type { SequencerClient } from '@aztec/sequencer-client';
57
- import type { TestSequencerClient } from '@aztec/sequencer-client/test';
58
53
  import { type ContractInstanceWithAddress, getContractInstanceFromInstantiationParams } from '@aztec/stdlib/contract';
59
- import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
54
+ import type { AztecNodeAdmin, AztecNodeDebug } from '@aztec/stdlib/interfaces/client';
60
55
  import { tryStop } from '@aztec/stdlib/interfaces/server';
61
- import type { P2PClientType } from '@aztec/stdlib/p2p';
62
56
  import type { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
57
+ import type { GenesisData } from '@aztec/stdlib/world-state';
63
58
  import {
64
59
  type TelemetryClient,
65
60
  type TelemetryClientConfig,
@@ -70,7 +65,6 @@ import { BenchmarkTelemetryClient } from '@aztec/telemetry-client/bench';
70
65
  import { deployFundedSchnorrAccounts } from '@aztec/wallets/testing';
71
66
  import { getGenesisValues } from '@aztec/world-state/testing';
72
67
 
73
- import type { Anvil } from '@viem/anvil';
74
68
  import fs from 'fs/promises';
75
69
  import { tmpdir } from 'os';
76
70
  import path from 'path';
@@ -187,6 +181,8 @@ export type SetupOptions = {
187
181
  proverNodeConfig?: Partial<ProverNodeConfig>;
188
182
  /** Whether to use a mock gossip sub network for p2p clients. */
189
183
  mockGossipSubNetwork?: boolean;
184
+ /** Whether to add simulated latency to the mock gossipsub network (in ms) */
185
+ mockGossipSubNetworkLatency?: number;
190
186
  /** Whether to disable the anvil test watcher (can still be manually started) */
191
187
  disableAnvilTestWatcher?: boolean;
192
188
  /** Whether to enable anvil automine during deployment of L1 contracts (consider defaulting this to true). */
@@ -195,6 +191,11 @@ export type SetupOptions = {
195
191
  anvilAccounts?: number;
196
192
  /** Port to start anvil (defaults to 8545) */
197
193
  anvilPort?: number;
194
+ /**
195
+ * Number of slots per epoch for Anvil's finality simulation.
196
+ * Anvil reports `finalized = latest - slotsInAnEpoch * 2`.
197
+ */
198
+ anvilSlotsInAnEpoch?: number;
198
199
  /** Key to use for publishing L1 contracts */
199
200
  l1PublisherKey?: SecretValue<`0x${string}`>;
200
201
  /** ZkPassport configuration (domain, scope, mock verifier) */
@@ -214,13 +215,13 @@ export type EndToEndContext = {
214
215
  /** The Anvil instance (only set if anvil was started locally). */
215
216
  anvil: Anvil | undefined;
216
217
  /** The Aztec Node service or client a connected to it. */
217
- aztecNode: AztecNode;
218
+ aztecNode: AztecNode & AztecNodeDebug;
218
219
  /** The Aztec Node as a service. */
219
220
  aztecNodeService: AztecNodeService;
220
221
  /** Client to the Aztec Node admin interface. */
221
222
  aztecNodeAdmin: AztecNodeAdmin;
222
- /** The prover node service (only set if startProverNode is true) */
223
- proverNode: ProverNode | undefined;
223
+ /** The aztec node running the prover node subsystem (only set if startProverNode is true). */
224
+ proverNode: AztecNodeService | undefined;
224
225
  /** A client to the sequencer service. */
225
226
  sequencer: SequencerClient | undefined;
226
227
  /** Return values from deployAztecL1Contracts function. */
@@ -249,8 +250,12 @@ export type EndToEndContext = {
249
250
  telemetryClient: TelemetryClient;
250
251
  /** Mock gossip sub network used for gossipping messages (only if mockGossipSubNetwork was set to true in opts) */
251
252
  mockGossipSubNetwork: MockGossipSubNetwork | undefined;
252
- /** Prefilled public data used for setting up nodes. */
253
- prefilledPublicData: PublicDataTreeLeaf[] | undefined;
253
+ /** Delayer for sequencer L1 txs (only when enableDelayer is true). */
254
+ sequencerDelayer: Delayer | undefined;
255
+ /** Delayer for prover node L1 txs (only when enableDelayer and startProverNode are true). */
256
+ proverDelayer: Delayer | undefined;
257
+ /** Genesis data used for setting up nodes. */
258
+ genesis: GenesisData | undefined;
254
259
  /** ACVM config (only set if running locally). */
255
260
  acvmConfig: Awaited<ReturnType<typeof getACVMConfig>>;
256
261
  /** BB config (only set if running locally). */
@@ -276,7 +281,7 @@ export async function setup(
276
281
  let anvil: Anvil | undefined;
277
282
  try {
278
283
  opts.aztecTargetCommitteeSize ??= 0;
279
- opts.slasherFlavor ??= 'none';
284
+ opts.slasherEnabled ??= false;
280
285
 
281
286
  const config: AztecNodeConfig & SetupOptions = { ...getConfigEnvVars(), ...opts };
282
287
  // use initialValidators for the node config
@@ -288,6 +293,8 @@ export async function setup(
288
293
  config.realProofs = !!opts.realProofs;
289
294
  // Only enforce the time table if requested
290
295
  config.enforceTimeTable = !!opts.enforceTimeTable;
296
+ // Enable the tx delayer for tests (default config has it disabled, so we force-enable it here)
297
+ config.enableDelayer = true;
291
298
  config.listenAddress = '127.0.0.1';
292
299
 
293
300
  config.minTxPoolAgeMs = opts.minTxPoolAgeMs ?? 0;
@@ -301,6 +308,8 @@ export async function setup(
301
308
  config.dataDirectory = directoryToCleanup;
302
309
  }
303
310
 
311
+ const dateProvider = new TestDateProvider();
312
+
304
313
  if (!config.l1RpcUrls?.length) {
305
314
  if (!isAnvilTestChain(chain.id)) {
306
315
  throw new Error(`No ETHEREUM_HOSTS set but non anvil chain requested`);
@@ -309,6 +318,8 @@ export async function setup(
309
318
  l1BlockTime: opts.ethereumSlotDuration,
310
319
  accounts: opts.anvilAccounts,
311
320
  port: opts.anvilPort ?? (process.env.ANVIL_PORT ? parseInt(process.env.ANVIL_PORT) : undefined),
321
+ slotsInAnEpoch: opts.anvilSlotsInAnEpoch,
322
+ dateProvider,
312
323
  });
313
324
  anvil = res.anvil;
314
325
  config.l1RpcUrls = [res.rpcUrl];
@@ -320,8 +331,6 @@ export async function setup(
320
331
  logger.info(`Logging metrics to ${filename}`);
321
332
  setupMetricsLogger(filename);
322
333
  }
323
-
324
- const dateProvider = new TestDateProvider();
325
334
  const ethCheatCodes = new EthCheatCodesWithState(config.l1RpcUrls, dateProvider);
326
335
 
327
336
  if (opts.stateLoad) {
@@ -339,11 +348,11 @@ export async function setup(
339
348
  publisherPrivKeyHex = opts.l1PublisherKey.getValue();
340
349
  publisherHdAccount = privateKeyToAccount(publisherPrivKeyHex);
341
350
  } else if (
342
- config.publisherPrivateKeys &&
343
- config.publisherPrivateKeys.length > 0 &&
344
- config.publisherPrivateKeys[0].getValue() != NULL_KEY
351
+ config.sequencerPublisherPrivateKeys &&
352
+ config.sequencerPublisherPrivateKeys.length > 0 &&
353
+ config.sequencerPublisherPrivateKeys[0].getValue() != NULL_KEY
345
354
  ) {
346
- publisherPrivKeyHex = config.publisherPrivateKeys[0].getValue();
355
+ publisherPrivKeyHex = config.sequencerPublisherPrivateKeys[0].getValue();
347
356
  publisherHdAccount = privateKeyToAccount(publisherPrivKeyHex);
348
357
  } else if (!MNEMONIC) {
349
358
  throw new Error(`Mnemonic not provided and no publisher private key`);
@@ -352,7 +361,7 @@ export async function setup(
352
361
  const publisherPrivKeyRaw = publisherHdAccount.getHdKey().privateKey;
353
362
  const publisherPrivKey = publisherPrivKeyRaw === null ? null : Buffer.from(publisherPrivKeyRaw);
354
363
  publisherPrivKeyHex = `0x${publisherPrivKey!.toString('hex')}` as const;
355
- config.publisherPrivateKeys = [new SecretValue(publisherPrivKeyHex)];
364
+ config.sequencerPublisherPrivateKeys = [new SecretValue(publisherPrivKeyHex)];
356
365
  }
357
366
 
358
367
  if (config.coinbase === undefined) {
@@ -371,10 +380,12 @@ export async function setup(
371
380
  addressesToFund.push(sponsoredFPCAddress);
372
381
  }
373
382
 
374
- const { genesisArchiveRoot, prefilledPublicData, fundingNeeded } = await getGenesisValues(
383
+ const genesisTimestamp = BigInt(Math.floor(Date.now() / 1000));
384
+ const { genesisArchiveRoot, genesis, fundingNeeded } = await getGenesisValues(
375
385
  addressesToFund,
376
386
  opts.initialAccountFeeJuice,
377
387
  opts.genesisPublicData,
388
+ genesisTimestamp,
378
389
  );
379
390
 
380
391
  const wasAutomining = await ethCheatCodes.isAutoMining();
@@ -417,11 +428,12 @@ export async function setup(
417
428
  await ethCheatCodes.setIntervalMining(config.ethereumSlotDuration);
418
429
  }
419
430
 
420
- // Always sync dateProvider to L1 time after deploying L1 contracts, regardless of mining mode.
421
- // In compose mode, L1 time may have drifted ahead of system time due to the local-network watcher
422
- // warping time forward on each filled slot. Without this sync, the sequencer computes the wrong
423
- // slot from its dateProvider and cannot propose blocks.
424
- dateProvider.setTime((await ethCheatCodes.timestamp()) * 1000);
431
+ // In compose mode (no local anvil), sync dateProvider to L1 time since it may have drifted
432
+ // ahead of system time due to the local-network watcher warping time forward on each filled slot.
433
+ // When running with a local anvil, the dateProvider is kept in sync via the stdout listener.
434
+ if (!anvil) {
435
+ dateProvider.setTime((await ethCheatCodes.lastBlockTimestamp()) * 1000);
436
+ }
425
437
 
426
438
  if (opts.l2StartTime) {
427
439
  await ethCheatCodes.warp(opts.l2StartTime, { resetBlockInterval: true });
@@ -459,10 +471,10 @@ export async function setup(
459
471
  }
460
472
 
461
473
  let mockGossipSubNetwork: MockGossipSubNetwork | undefined;
462
- let p2pClientDeps: P2PClientDeps<P2PClientType.Full> | undefined = undefined;
474
+ let p2pClientDeps: P2PClientDeps | undefined = undefined;
463
475
 
464
476
  if (opts.mockGossipSubNetwork) {
465
- mockGossipSubNetwork = new MockGossipSubNetwork();
477
+ mockGossipSubNetwork = new MockGossipSubNetwork(opts.mockGossipSubNetworkLatency);
466
478
  p2pClientDeps = { p2pServiceFactory: getMockPubSubP2PServiceFactory(mockGossipSubNetwork) };
467
479
  }
468
480
 
@@ -491,44 +503,37 @@ export async function setup(
491
503
  }
492
504
 
493
505
  const aztecNodeService = await withLoggerBindings({ actor: 'node-0' }, () =>
494
- AztecNodeService.createAndSync(
495
- config,
496
- { dateProvider, telemetry: telemetryClient, p2pClientDeps },
497
- { prefilledPublicData },
498
- ),
506
+ AztecNodeService.createAndSync(config, { dateProvider, telemetry: telemetryClient, p2pClientDeps }, { genesis }),
499
507
  );
500
508
  const sequencerClient = aztecNodeService.getSequencer();
501
509
 
502
- if (sequencerClient) {
503
- const publisher = (sequencerClient as TestSequencerClient).sequencer.publisher;
504
- publisher.l1TxUtils = DelayedTxUtils.fromL1TxUtils(publisher.l1TxUtils, config.ethereumSlotDuration, l1Client);
505
- }
506
-
507
- let proverNode: ProverNode | undefined = undefined;
510
+ let proverNode: AztecNodeService | undefined = undefined;
508
511
  if (opts.startProverNode) {
509
512
  logger.verbose('Creating and syncing a simulated prover node...');
510
513
  const proverNodePrivateKey = getPrivateKeyFromIndex(2);
511
514
  const proverNodePrivateKeyHex: Hex = `0x${proverNodePrivateKey!.toString('hex')}`;
512
515
  const proverNodeDataDirectory = path.join(directoryToCleanup, randomBytes(8).toString('hex'));
513
- const proverNodeConfig = {
514
- ...config.proverNodeConfig,
515
- dataDirectory: proverNodeDataDirectory,
516
- p2pEnabled: !!mockGossipSubNetwork,
516
+
517
+ const p2pClientDeps: Partial<P2PClientDeps> = {
518
+ p2pServiceFactory: mockGossipSubNetwork && getMockPubSubP2PServiceFactory(mockGossipSubNetwork!),
519
+ rpcTxProviders: [aztecNodeService],
517
520
  };
518
- proverNode = await createAndSyncProverNode(
521
+
522
+ ({ proverNode } = await createAndSyncProverNode(
519
523
  proverNodePrivateKeyHex,
520
524
  config,
521
- proverNodeConfig,
522
- aztecNodeService,
523
- prefilledPublicData,
524
525
  {
525
- p2pClientDeps: mockGossipSubNetwork
526
- ? { p2pServiceFactory: getMockPubSubP2PServiceFactory(mockGossipSubNetwork) }
527
- : undefined,
526
+ ...config.proverNodeConfig,
527
+ dataDirectory: proverNodeDataDirectory,
528
528
  },
529
- );
529
+ { dateProvider, p2pClientDeps, telemetry: telemetryClient },
530
+ { genesis },
531
+ ));
530
532
  }
531
533
 
534
+ const sequencerDelayer = sequencerClient?.getDelayer();
535
+ const proverDelayer = proverNode?.getProverNode()?.getDelayer();
536
+
532
537
  logger.verbose('Creating a pxe...');
533
538
  const pxeConfig = { ...getPXEConfig(), ...pxeOpts };
534
539
  pxeConfig.dataDirectory = path.join(directoryToCleanup, randomBytes(8).toString('hex'));
@@ -627,8 +632,10 @@ export async function setup(
627
632
  initialFundedAccounts,
628
633
  logger,
629
634
  mockGossipSubNetwork,
630
- prefilledPublicData,
635
+ genesis,
631
636
  proverNode,
637
+ sequencerDelayer,
638
+ proverDelayer,
632
639
  sequencer: sequencerClient,
633
640
  teardown,
634
641
  telemetryClient,
@@ -712,81 +719,42 @@ export async function waitForProvenChain(node: AztecNode, targetBlock?: BlockNum
712
719
  );
713
720
  }
714
721
 
722
+ /**
723
+ * Creates an AztecNodeService with the prover node enabled as a subsystem.
724
+ * Returns both the aztec node service (for lifecycle management) and the prover node (for test internals access).
725
+ */
715
726
  export function createAndSyncProverNode(
716
727
  proverNodePrivateKey: `0x${string}`,
717
- aztecNodeConfig: AztecNodeConfig,
718
- proverNodeConfig: Partial<ProverNodeConfig> & Pick<DataStoreConfig, 'dataDirectory'> & { dontStart?: boolean },
719
- aztecNode: AztecNode | undefined,
720
- prefilledPublicData: PublicDataTreeLeaf[] = [],
721
- proverNodeDeps: ProverNodeDeps = {},
722
- ) {
728
+ baseConfig: AztecNodeConfig,
729
+ configOverrides: Pick<AztecNodeConfig, 'dataDirectory'>,
730
+ deps: {
731
+ telemetry?: TelemetryClient;
732
+ dateProvider: DateProvider;
733
+ p2pClientDeps?: P2PClientDeps;
734
+ },
735
+ options: { genesis?: GenesisData; dontStart?: boolean },
736
+ ): Promise<{ proverNode: AztecNodeService }> {
723
737
  return withLoggerBindings({ actor: 'prover-0' }, async () => {
724
- const aztecNodeTxProvider = aztecNode && {
725
- getTxByHash: aztecNode.getTxByHash.bind(aztecNode),
726
- getTxsByHash: aztecNode.getTxsByHash.bind(aztecNode),
727
- stop: () => Promise.resolve(),
728
- };
729
-
730
- const blobClient = await createBlobClientWithFileStores(aztecNodeConfig, createLogger('blob-client:prover-node'));
731
-
732
- const archiverConfig = { ...aztecNodeConfig, dataDirectory: proverNodeConfig.dataDirectory };
733
- const archiver = await createArchiver(
734
- archiverConfig,
735
- { blobClient, dateProvider: proverNodeDeps.dateProvider },
736
- { blockUntilSync: true },
737
- );
738
-
739
- const proverConfig: ProverNodeConfig = {
740
- ...aztecNodeConfig,
741
- txCollectionNodeRpcUrls: [],
742
- realProofs: false,
743
- proverAgentCount: 2,
744
- publisherPrivateKeys: [new SecretValue(proverNodePrivateKey)],
745
- proverNodeMaxPendingJobs: 10,
746
- proverNodeMaxParallelBlocksPerEpoch: 32,
747
- proverNodePollingIntervalMs: 200,
748
- txGatheringIntervalMs: 1000,
749
- txGatheringBatchSize: 10,
750
- txGatheringMaxParallelRequestsPerNode: 10,
751
- txGatheringTimeoutMs: 24_000,
752
- proverNodeFailedEpochStore: undefined,
753
- proverId: EthAddress.fromNumber(1),
754
- proverNodeEpochProvingDelayMs: undefined,
755
- ...proverNodeConfig,
756
- };
757
-
758
- const l1TxUtils = createDelayedL1TxUtils(
759
- aztecNodeConfig,
760
- proverNodePrivateKey,
761
- 'prover-node',
762
- proverNodeDeps.dateProvider,
738
+ const proverNode = await AztecNodeService.createAndSync(
739
+ {
740
+ ...baseConfig,
741
+ ...configOverrides,
742
+ p2pPort: 0,
743
+ enableProverNode: true,
744
+ disableValidator: true,
745
+ proverPublisherPrivateKeys: [new SecretValue(proverNodePrivateKey)],
746
+ },
747
+ deps,
748
+ { genesis: options.genesis, dontStartProverNode: options.dontStart },
763
749
  );
764
750
 
765
- const proverNode = await createProverNode(
766
- proverConfig,
767
- { ...proverNodeDeps, aztecNodeTxProvider, archiver: archiver as Archiver, l1TxUtils },
768
- { prefilledPublicData },
769
- );
770
- getLogger().info(`Created and synced prover node`, { publisherAddress: l1TxUtils.client.account!.address });
771
- if (!proverNodeConfig.dontStart) {
772
- await proverNode.start();
751
+ if (!proverNode.getProverNode()) {
752
+ throw new Error('Prover node subsystem was not created despite enableProverNode being set');
773
753
  }
774
- return proverNode;
775
- });
776
- }
777
754
 
778
- function createDelayedL1TxUtils(
779
- aztecNodeConfig: AztecNodeConfig,
780
- privateKey: `0x${string}`,
781
- logName: string,
782
- dateProvider?: DateProvider,
783
- ) {
784
- const l1Client = createExtendedL1Client(aztecNodeConfig.l1RpcUrls, privateKey, foundry);
785
-
786
- const log = createLogger(logName);
787
- const l1TxUtils = createDelayedL1TxUtilsFromViemWallet(l1Client, log, dateProvider, aztecNodeConfig);
788
- l1TxUtils.enableDelayer(aztecNodeConfig.ethereumSlotDuration);
789
- return l1TxUtils;
755
+ getLogger().info(`Created and synced prover node`);
756
+ return { proverNode };
757
+ });
790
758
  }
791
759
 
792
760
  export type BalancesFn = ReturnType<typeof getBalancesFn>;
@@ -797,7 +765,9 @@ export function getBalancesFn(
797
765
  ): (...addresses: (AztecAddress | { address: AztecAddress })[]) => Promise<bigint[]> {
798
766
  const balances = async (...addressLikes: (AztecAddress | { address: AztecAddress })[]) => {
799
767
  const addresses = addressLikes.map(addressLike => ('address' in addressLike ? addressLike.address : addressLike));
800
- const b = await Promise.all(addresses.map(address => method(address).simulate({ from: address })));
768
+ const b = await Promise.all(
769
+ addresses.map(async address => (await method(address).simulate({ from: address })).result),
770
+ );
801
771
  const debugString = `${symbol} balances: ${addresses.map((address, i) => `${address}: ${b[i]}`).join(', ')}`;
802
772
  logger.verbose(debugString);
803
773
  return b;
@@ -866,7 +836,7 @@ export async function ensureAccountContractsPublished(wallet: Wallet, accountsTo
866
836
  * Returns deployed account data that can be used by tests.
867
837
  */
868
838
  export const deployAccounts =
869
- (numberOfAccounts: number, logger: Logger) =>
839
+ (numberOfAccounts: number, logger: Logger, deployOptions?: Partial<DeployOptions<DeployInteractionWaitOptions>>) =>
870
840
  async ({ wallet, initialFundedAccounts }: { wallet: TestWallet; initialFundedAccounts: InitialAccountData[] }) => {
871
841
  if (initialFundedAccounts.length < numberOfAccounts) {
872
842
  throw new Error(`Cannot deploy more than ${initialFundedAccounts.length} initial accounts.`);
@@ -883,8 +853,9 @@ export const deployAccounts =
883
853
  );
884
854
  const deployMethod = await accountManager.getDeployMethod();
885
855
  await deployMethod.send({
886
- from: AztecAddress.ZERO,
856
+ from: NO_FROM,
887
857
  skipClassPublication: i !== 0, // Publish the contract class at most once.
858
+ ...deployOptions,
888
859
  });
889
860
  }
890
861
 
@@ -915,7 +886,7 @@ export async function publicDeployAccounts(
915
886
 
916
887
  const batch = new BatchCall(wallet, calls);
917
888
 
918
- const txReceipt = await batch.send({ from: accountsToDeploy[0] });
889
+ const { receipt: txReceipt } = await batch.send({ from: accountsToDeploy[0] });
919
890
  if (waitUntilProven) {
920
891
  if (!node) {
921
892
  throw new Error('Need to provide an AztecNode to wait for proven.');
@@ -7,8 +7,7 @@ import { SecretValue } from '@aztec/foundation/config';
7
7
  import { withLoggerBindings } from '@aztec/foundation/log/server';
8
8
  import { bufferToHex } from '@aztec/foundation/string';
9
9
  import type { DateProvider } from '@aztec/foundation/timer';
10
- import type { ProverNodeConfig, ProverNodeDeps } from '@aztec/prover-node';
11
- import type { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
10
+ import type { GenesisData } from '@aztec/stdlib/world-state';
12
11
 
13
12
  import getPort from 'get-port';
14
13
 
@@ -41,7 +40,7 @@ export async function createNodes(
41
40
  bootstrapNodeEnr: string,
42
41
  numNodes: number,
43
42
  bootNodePort: number,
44
- prefilledPublicData?: PublicDataTreeLeaf[],
43
+ genesis?: GenesisData,
45
44
  dataDirectory?: string,
46
45
  metricsPort?: number,
47
46
  indexOffset = 0,
@@ -66,7 +65,7 @@ export async function createNodes(
66
65
  port,
67
66
  bootstrapNodeEnr,
68
67
  validatorIndices,
69
- prefilledPublicData,
68
+ genesis,
70
69
  dataDir,
71
70
  metricsPort,
72
71
  );
@@ -98,7 +97,7 @@ export async function createNode(
98
97
  tcpPort: number,
99
98
  bootstrapNode: string | undefined,
100
99
  addressIndex: number | number[],
101
- prefilledPublicData?: PublicDataTreeLeaf[],
100
+ genesis?: GenesisData,
102
101
  dataDirectory?: string,
103
102
  metricsPort?: number,
104
103
  ) {
@@ -109,7 +108,7 @@ export async function createNode(
109
108
  return await AztecNodeService.createAndSync(
110
109
  validatorConfig,
111
110
  { telemetry, dateProvider },
112
- { prefilledPublicData, dontStartSequencer: config.dontStartSequencer },
111
+ { genesis, dontStartSequencer: config.dontStartSequencer },
113
112
  );
114
113
  });
115
114
  }
@@ -120,7 +119,7 @@ export async function createNonValidatorNode(
120
119
  dateProvider: DateProvider,
121
120
  tcpPort: number,
122
121
  bootstrapNode: string | undefined,
123
- prefilledPublicData?: PublicDataTreeLeaf[],
122
+ genesis?: GenesisData,
124
123
  dataDirectory?: string,
125
124
  metricsPort?: number,
126
125
  ) {
@@ -131,10 +130,10 @@ export async function createNonValidatorNode(
131
130
  ...p2pConfig,
132
131
  disableValidator: true,
133
132
  validatorPrivateKeys: undefined,
134
- publisherPrivateKeys: [],
133
+ sequencerPublisherPrivateKeys: [],
135
134
  };
136
135
  const telemetry = await getEndToEndTestTelemetryClient(metricsPort);
137
- return await AztecNodeService.createAndSync(config, { telemetry, dateProvider }, { prefilledPublicData });
136
+ return await AztecNodeService.createAndSync(config, { telemetry, dateProvider }, { genesis });
138
137
  });
139
138
  }
140
139
 
@@ -143,31 +142,24 @@ export async function createProverNode(
143
142
  tcpPort: number,
144
143
  bootstrapNode: string | undefined,
145
144
  addressIndex: number,
146
- proverNodeDeps: ProverNodeDeps & Required<Pick<ProverNodeDeps, 'dateProvider'>>,
147
- prefilledPublicData?: PublicDataTreeLeaf[],
145
+ deps: { dateProvider: DateProvider },
146
+ genesis?: GenesisData,
148
147
  dataDirectory?: string,
149
148
  metricsPort?: number,
150
- ) {
149
+ ): Promise<{ proverNode: AztecNodeService }> {
151
150
  const actorIndex = proverCounter++;
152
151
  return await withLoggerBindings({ actor: `prover-${actorIndex}` }, async () => {
153
152
  const proverNodePrivateKey = getPrivateKeyFromIndex(ATTESTER_PRIVATE_KEYS_START_INDEX + addressIndex)!;
154
153
  const telemetry = await getEndToEndTestTelemetryClient(metricsPort);
155
154
 
156
- const proverConfig: Partial<ProverNodeConfig> = await createP2PConfig(
157
- config,
158
- bootstrapNode,
159
- tcpPort,
160
- dataDirectory,
161
- );
155
+ const p2pConfig = await createP2PConfig(config, bootstrapNode, tcpPort, dataDirectory);
162
156
 
163
- const aztecNodeRpcTxProvider = undefined;
164
157
  return await createAndSyncProverNode(
165
158
  bufferToHex(proverNodePrivateKey),
166
- config,
167
- { ...proverConfig, dataDirectory },
168
- aztecNodeRpcTxProvider,
169
- prefilledPublicData,
170
- { ...proverNodeDeps, telemetry },
159
+ { ...config, ...p2pConfig },
160
+ { dataDirectory },
161
+ { ...deps, telemetry },
162
+ { genesis },
171
163
  );
172
164
  });
173
165
  }
@@ -215,7 +207,7 @@ export async function createValidatorConfig(
215
207
  ...config,
216
208
  ...p2pConfig,
217
209
  validatorPrivateKeys: new SecretValue(attesterPrivateKeys),
218
- publisherPrivateKeys: [new SecretValue(attesterPrivateKeys[0])],
210
+ sequencerPublisherPrivateKeys: [new SecretValue(attesterPrivateKeys[0])],
219
211
  };
220
212
 
221
213
  return nodeConfig;
@@ -8,7 +8,6 @@ export async function deployToken(wallet: Wallet, admin: AztecAddress, initialAd
8
8
  logger.info(`Deploying Token contract...`);
9
9
  const { contract, instance } = await TokenContract.deploy(wallet, admin, 'TokenName', 'TokenSymbol', 18).send({
10
10
  from: admin,
11
- wait: { returnReceipt: true },
12
11
  });
13
12
 
14
13
  if (initialAdminBalance > 0n) {
@@ -25,8 +24,9 @@ export async function mintTokensToPrivate(
25
24
  minter: AztecAddress,
26
25
  recipient: AztecAddress,
27
26
  amount: bigint,
27
+ additionalScopes?: AztecAddress[],
28
28
  ) {
29
- await token.methods.mint_to_private(recipient, amount).send({ from: minter });
29
+ await token.methods.mint_to_private(recipient, amount).send({ from: minter, additionalScopes });
30
30
  }
31
31
 
32
32
  export async function expectTokenBalance(
@@ -38,7 +38,7 @@ export async function expectTokenBalance(
38
38
  ) {
39
39
  // Then check the balance
40
40
  const contractWithWallet = TokenContract.at(token.address, wallet);
41
- const balance = await contractWithWallet.methods.balance_of_private(owner).simulate({ from: owner });
41
+ const { result: balance } = await contractWithWallet.methods.balance_of_private(owner).simulate({ from: owner });
42
42
  logger.info(`Account ${owner} balance: ${balance}`);
43
43
  expect(balance).toBe(expectedBalance);
44
44
  }
@@ -0,0 +1,14 @@
1
+ import type { Wallet } from '@aztec/aztec.js/wallet';
2
+ import { WalletSchema } from '@aztec/aztec.js/wallet';
3
+ import { createSafeJsonRpcClient, makeFetch } from '@aztec/foundation/json-rpc/client';
4
+
5
+ /**
6
+ * Creates a JSON-RPC client that connects to a remote wallet service.
7
+ * The returned object implements the {@link Wallet} interface, proxying all calls over HTTP to the specified URL.
8
+ */
9
+ export function createWalletClient(url: string): Wallet {
10
+ return createSafeJsonRpcClient<Wallet>(url, WalletSchema, {
11
+ namespaceMethods: 'wallet',
12
+ fetch: makeFetch([1, 2, 3], false),
13
+ });
14
+ }