@aztec/end-to-end 0.0.1-commit.21ecf947b → 0.0.1-commit.2448fdb

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 +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 +18 -11
  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 +58 -36
  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.d.ts +1 -1
  21. package/dest/e2e_p2p/inactivity_slash_test.d.ts.map +1 -1
  22. package/dest/e2e_p2p/inactivity_slash_test.js +1 -0
  23. package/dest/e2e_p2p/p2p_network.d.ts +3 -2
  24. package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
  25. package/dest/e2e_p2p/p2p_network.js +23 -6
  26. package/dest/e2e_p2p/reqresp/utils.d.ts +3 -3
  27. package/dest/e2e_p2p/reqresp/utils.d.ts.map +1 -1
  28. package/dest/e2e_p2p/reqresp/utils.js +32 -8
  29. package/dest/e2e_p2p/shared.d.ts +33 -1
  30. package/dest/e2e_p2p/shared.d.ts.map +1 -1
  31. package/dest/e2e_p2p/shared.js +56 -2
  32. package/dest/e2e_token_contract/token_contract_test.d.ts +1 -1
  33. package/dest/e2e_token_contract/token_contract_test.d.ts.map +1 -1
  34. package/dest/e2e_token_contract/token_contract_test.js +11 -11
  35. package/dest/fixtures/authwit_proxy.d.ts +3 -3
  36. package/dest/fixtures/authwit_proxy.d.ts.map +1 -1
  37. package/dest/fixtures/authwit_proxy.js +4 -0
  38. package/dest/fixtures/e2e_prover_test.d.ts +3 -3
  39. package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
  40. package/dest/fixtures/e2e_prover_test.js +33 -40
  41. package/dest/fixtures/fixtures.d.ts +5 -1
  42. package/dest/fixtures/fixtures.d.ts.map +1 -1
  43. package/dest/fixtures/fixtures.js +6 -0
  44. package/dest/fixtures/setup.d.ts +32 -12
  45. package/dest/fixtures/setup.d.ts.map +1 -1
  46. package/dest/fixtures/setup.js +62 -89
  47. package/dest/fixtures/setup_p2p_test.d.ts +6 -3
  48. package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
  49. package/dest/fixtures/setup_p2p_test.js +12 -9
  50. package/dest/fixtures/token_utils.d.ts +2 -2
  51. package/dest/fixtures/token_utils.d.ts.map +1 -1
  52. package/dest/fixtures/token_utils.js +5 -4
  53. package/dest/forward-compatibility/wallet_rpc_client.d.ts +7 -0
  54. package/dest/forward-compatibility/wallet_rpc_client.d.ts.map +1 -0
  55. package/dest/forward-compatibility/wallet_rpc_client.js +15 -0
  56. package/dest/forward-compatibility/wallet_service.d.ts +3 -0
  57. package/dest/forward-compatibility/wallet_service.d.ts.map +1 -0
  58. package/dest/forward-compatibility/wallet_service.js +109 -0
  59. package/dest/install_legacy_contracts.d.cts +10 -0
  60. package/dest/install_legacy_contracts.d.cts.map +1 -0
  61. package/dest/legacy-jest-resolver.d.cts +3 -0
  62. package/dest/legacy-jest-resolver.d.cts.map +1 -0
  63. package/dest/shared/cross_chain_test_harness.d.ts +1 -1
  64. package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
  65. package/dest/shared/cross_chain_test_harness.js +13 -13
  66. package/dest/shared/gas_portal_test_harness.js +2 -2
  67. package/dest/shared/submit-transactions.d.ts +1 -1
  68. package/dest/shared/submit-transactions.d.ts.map +1 -1
  69. package/dest/shared/submit-transactions.js +1 -1
  70. package/dest/shared/uniswap_l1_l2.d.ts +1 -1
  71. package/dest/shared/uniswap_l1_l2.d.ts.map +1 -1
  72. package/dest/shared/uniswap_l1_l2.js +14 -17
  73. package/dest/simulators/lending_simulator.d.ts +1 -1
  74. package/dest/simulators/lending_simulator.d.ts.map +1 -1
  75. package/dest/simulators/lending_simulator.js +4 -4
  76. package/dest/simulators/token_simulator.d.ts +1 -1
  77. package/dest/simulators/token_simulator.d.ts.map +1 -1
  78. package/dest/simulators/token_simulator.js +2 -2
  79. package/dest/spartan/setup_test_wallets.d.ts +11 -2
  80. package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
  81. package/dest/spartan/setup_test_wallets.js +56 -15
  82. package/dest/spartan/utils/bot.d.ts +3 -2
  83. package/dest/spartan/utils/bot.d.ts.map +1 -1
  84. package/dest/spartan/utils/bot.js +2 -1
  85. package/dest/spartan/utils/index.d.ts +3 -2
  86. package/dest/spartan/utils/index.d.ts.map +1 -1
  87. package/dest/spartan/utils/index.js +3 -1
  88. package/dest/spartan/utils/k8s.d.ts +3 -1
  89. package/dest/spartan/utils/k8s.d.ts.map +1 -1
  90. package/dest/spartan/utils/k8s.js +6 -0
  91. package/dest/test-wallet/test_wallet.d.ts +24 -23
  92. package/dest/test-wallet/test_wallet.d.ts.map +1 -1
  93. package/dest/test-wallet/test_wallet.js +116 -81
  94. package/dest/test-wallet/wallet_worker_script.d.ts +2 -0
  95. package/dest/test-wallet/wallet_worker_script.d.ts.map +1 -0
  96. package/dest/test-wallet/wallet_worker_script.js +48 -0
  97. package/dest/test-wallet/worker_wallet.d.ts +52 -0
  98. package/dest/test-wallet/worker_wallet.d.ts.map +1 -0
  99. package/dest/test-wallet/worker_wallet.js +151 -0
  100. package/dest/test-wallet/worker_wallet_schema.d.ts +274 -0
  101. package/dest/test-wallet/worker_wallet_schema.d.ts.map +1 -0
  102. package/dest/test-wallet/worker_wallet_schema.js +10 -0
  103. package/package.json +41 -40
  104. package/src/bench/client_flows/client_flows_benchmark.ts +40 -32
  105. package/src/bench/utils.ts +7 -2
  106. package/src/e2e_blacklist_token_contract/blacklist_token_contract_test.ts +21 -20
  107. package/src/e2e_epochs/epochs_test.ts +76 -64
  108. package/src/e2e_fees/fees_test.ts +14 -7
  109. package/src/e2e_nested_contract/nested_contract_test.ts +6 -4
  110. package/src/e2e_p2p/inactivity_slash_test.ts +1 -0
  111. package/src/e2e_p2p/p2p_network.ts +30 -4
  112. package/src/e2e_p2p/reqresp/utils.ts +36 -8
  113. package/src/e2e_p2p/shared.ts +97 -2
  114. package/src/e2e_token_contract/token_contract_test.ts +16 -8
  115. package/src/fixtures/authwit_proxy.ts +4 -0
  116. package/src/fixtures/e2e_prover_test.ts +36 -40
  117. package/src/fixtures/fixtures.ts +10 -0
  118. package/src/fixtures/setup.ts +86 -120
  119. package/src/fixtures/setup_p2p_test.ts +9 -17
  120. package/src/fixtures/token_utils.ts +6 -3
  121. package/src/forward-compatibility/wallet_rpc_client.ts +14 -0
  122. package/src/forward-compatibility/wallet_service.ts +104 -0
  123. package/src/install_legacy_contracts.cjs +71 -0
  124. package/src/legacy-jest-resolver.cjs +101 -0
  125. package/src/shared/cross_chain_test_harness.ts +13 -9
  126. package/src/shared/gas_portal_test_harness.ts +1 -1
  127. package/src/shared/submit-transactions.ts +4 -1
  128. package/src/shared/uniswap_l1_l2.ts +35 -28
  129. package/src/simulators/lending_simulator.ts +8 -4
  130. package/src/simulators/token_simulator.ts +6 -2
  131. package/src/spartan/setup_test_wallets.ts +101 -17
  132. package/src/spartan/utils/bot.ts +3 -0
  133. package/src/spartan/utils/index.ts +4 -0
  134. package/src/spartan/utils/k8s.ts +8 -0
  135. package/src/test-wallet/test_wallet.ts +145 -100
  136. package/src/test-wallet/wallet_worker_script.ts +60 -0
  137. package/src/test-wallet/worker_wallet.ts +214 -0
  138. package/src/test-wallet/worker_wallet_schema.ts +13 -0
@@ -1,7 +1,7 @@
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,
@@ -16,7 +16,6 @@ import { type Logger, createLogger } from '@aztec/aztec.js/log';
16
16
  import type { AztecNode } from '@aztec/aztec.js/node';
17
17
  import type { Wallet } from '@aztec/aztec.js/wallet';
18
18
  import { AnvilTestWatcher, CheatCodes } from '@aztec/aztec/testing';
19
- import { createBlobClientWithFileStores } from '@aztec/blob-client/client';
20
19
  import { SPONSORED_FPC_SALT } from '@aztec/constants';
21
20
  import { isAnvilTestChain } from '@aztec/ethereum/chain';
22
21
  import { createExtendedL1Client } from '@aztec/ethereum/client';
@@ -30,13 +29,8 @@ import {
30
29
  type ZKPassportArgs,
31
30
  deployAztecL1Contracts,
32
31
  } from '@aztec/ethereum/deploy-aztec-l1-contracts';
33
- import {
34
- DelayedTxUtils,
35
- EthCheatCodes,
36
- EthCheatCodesWithState,
37
- createDelayedL1TxUtilsFromViemWallet,
38
- startAnvil,
39
- } from '@aztec/ethereum/test';
32
+ import type { Delayer } from '@aztec/ethereum/l1-tx-utils';
33
+ import { type Anvil, EthCheatCodes, EthCheatCodesWithState, startAnvil } from '@aztec/ethereum/test';
40
34
  import { BlockNumber, EpochNumber } from '@aztec/foundation/branded-types';
41
35
  import { SecretValue } from '@aztec/foundation/config';
42
36
  import { randomBytes } from '@aztec/foundation/crypto/random';
@@ -45,20 +39,17 @@ import { withLoggerBindings } from '@aztec/foundation/log/server';
45
39
  import { retryUntil } from '@aztec/foundation/retry';
46
40
  import { sleep } from '@aztec/foundation/sleep';
47
41
  import { DateProvider, TestDateProvider } from '@aztec/foundation/timer';
48
- import type { DataStoreConfig } from '@aztec/kv-store/config';
49
42
  import { SponsoredFPCContract } from '@aztec/noir-contracts.js/SponsoredFPC';
50
43
  import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
51
44
  import type { P2PClientDeps } from '@aztec/p2p';
52
45
  import { MockGossipSubNetwork, getMockPubSubP2PServiceFactory } from '@aztec/p2p/test-helpers';
53
46
  import { protocolContractsHash } from '@aztec/protocol-contracts';
54
- import { type ProverNode, type ProverNodeConfig, type ProverNodeDeps, createProverNode } from '@aztec/prover-node';
47
+ import type { ProverNodeConfig } from '@aztec/prover-node';
55
48
  import { type PXEConfig, getPXEConfig } from '@aztec/pxe/server';
56
49
  import type { SequencerClient } from '@aztec/sequencer-client';
57
- import type { TestSequencerClient } from '@aztec/sequencer-client/test';
58
50
  import { type ContractInstanceWithAddress, getContractInstanceFromInstantiationParams } from '@aztec/stdlib/contract';
59
- import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
51
+ import type { AztecNodeAdmin, AztecNodeDebug } from '@aztec/stdlib/interfaces/client';
60
52
  import { tryStop } from '@aztec/stdlib/interfaces/server';
61
- import type { P2PClientType } from '@aztec/stdlib/p2p';
62
53
  import type { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
63
54
  import {
64
55
  type TelemetryClient,
@@ -70,7 +61,6 @@ import { BenchmarkTelemetryClient } from '@aztec/telemetry-client/bench';
70
61
  import { deployFundedSchnorrAccounts } from '@aztec/wallets/testing';
71
62
  import { getGenesisValues } from '@aztec/world-state/testing';
72
63
 
73
- import type { Anvil } from '@viem/anvil';
74
64
  import fs from 'fs/promises';
75
65
  import { tmpdir } from 'os';
76
66
  import path from 'path';
@@ -195,6 +185,11 @@ export type SetupOptions = {
195
185
  anvilAccounts?: number;
196
186
  /** Port to start anvil (defaults to 8545) */
197
187
  anvilPort?: number;
188
+ /**
189
+ * Number of slots per epoch for Anvil's finality simulation.
190
+ * Anvil reports `finalized = latest - slotsInAnEpoch * 2`.
191
+ */
192
+ anvilSlotsInAnEpoch?: number;
198
193
  /** Key to use for publishing L1 contracts */
199
194
  l1PublisherKey?: SecretValue<`0x${string}`>;
200
195
  /** ZkPassport configuration (domain, scope, mock verifier) */
@@ -214,13 +209,13 @@ export type EndToEndContext = {
214
209
  /** The Anvil instance (only set if anvil was started locally). */
215
210
  anvil: Anvil | undefined;
216
211
  /** The Aztec Node service or client a connected to it. */
217
- aztecNode: AztecNode;
212
+ aztecNode: AztecNode & AztecNodeDebug;
218
213
  /** The Aztec Node as a service. */
219
214
  aztecNodeService: AztecNodeService;
220
215
  /** Client to the Aztec Node admin interface. */
221
216
  aztecNodeAdmin: AztecNodeAdmin;
222
- /** The prover node service (only set if startProverNode is true) */
223
- proverNode: ProverNode | undefined;
217
+ /** The aztec node running the prover node subsystem (only set if startProverNode is true). */
218
+ proverNode: AztecNodeService | undefined;
224
219
  /** A client to the sequencer service. */
225
220
  sequencer: SequencerClient | undefined;
226
221
  /** Return values from deployAztecL1Contracts function. */
@@ -249,6 +244,10 @@ export type EndToEndContext = {
249
244
  telemetryClient: TelemetryClient;
250
245
  /** Mock gossip sub network used for gossipping messages (only if mockGossipSubNetwork was set to true in opts) */
251
246
  mockGossipSubNetwork: MockGossipSubNetwork | undefined;
247
+ /** Delayer for sequencer L1 txs (only when enableDelayer is true). */
248
+ sequencerDelayer: Delayer | undefined;
249
+ /** Delayer for prover node L1 txs (only when enableDelayer and startProverNode are true). */
250
+ proverDelayer: Delayer | undefined;
252
251
  /** Prefilled public data used for setting up nodes. */
253
252
  prefilledPublicData: PublicDataTreeLeaf[] | undefined;
254
253
  /** ACVM config (only set if running locally). */
@@ -288,6 +287,8 @@ export async function setup(
288
287
  config.realProofs = !!opts.realProofs;
289
288
  // Only enforce the time table if requested
290
289
  config.enforceTimeTable = !!opts.enforceTimeTable;
290
+ // Enable the tx delayer for tests (default config has it disabled, so we force-enable it here)
291
+ config.enableDelayer = true;
291
292
  config.listenAddress = '127.0.0.1';
292
293
 
293
294
  config.minTxPoolAgeMs = opts.minTxPoolAgeMs ?? 0;
@@ -301,6 +302,8 @@ export async function setup(
301
302
  config.dataDirectory = directoryToCleanup;
302
303
  }
303
304
 
305
+ const dateProvider = new TestDateProvider();
306
+
304
307
  if (!config.l1RpcUrls?.length) {
305
308
  if (!isAnvilTestChain(chain.id)) {
306
309
  throw new Error(`No ETHEREUM_HOSTS set but non anvil chain requested`);
@@ -309,6 +312,8 @@ export async function setup(
309
312
  l1BlockTime: opts.ethereumSlotDuration,
310
313
  accounts: opts.anvilAccounts,
311
314
  port: opts.anvilPort ?? (process.env.ANVIL_PORT ? parseInt(process.env.ANVIL_PORT) : undefined),
315
+ slotsInAnEpoch: opts.anvilSlotsInAnEpoch,
316
+ dateProvider,
312
317
  });
313
318
  anvil = res.anvil;
314
319
  config.l1RpcUrls = [res.rpcUrl];
@@ -320,8 +325,6 @@ export async function setup(
320
325
  logger.info(`Logging metrics to ${filename}`);
321
326
  setupMetricsLogger(filename);
322
327
  }
323
-
324
- const dateProvider = new TestDateProvider();
325
328
  const ethCheatCodes = new EthCheatCodesWithState(config.l1RpcUrls, dateProvider);
326
329
 
327
330
  if (opts.stateLoad) {
@@ -339,11 +342,11 @@ export async function setup(
339
342
  publisherPrivKeyHex = opts.l1PublisherKey.getValue();
340
343
  publisherHdAccount = privateKeyToAccount(publisherPrivKeyHex);
341
344
  } else if (
342
- config.publisherPrivateKeys &&
343
- config.publisherPrivateKeys.length > 0 &&
344
- config.publisherPrivateKeys[0].getValue() != NULL_KEY
345
+ config.sequencerPublisherPrivateKeys &&
346
+ config.sequencerPublisherPrivateKeys.length > 0 &&
347
+ config.sequencerPublisherPrivateKeys[0].getValue() != NULL_KEY
345
348
  ) {
346
- publisherPrivKeyHex = config.publisherPrivateKeys[0].getValue();
349
+ publisherPrivKeyHex = config.sequencerPublisherPrivateKeys[0].getValue();
347
350
  publisherHdAccount = privateKeyToAccount(publisherPrivKeyHex);
348
351
  } else if (!MNEMONIC) {
349
352
  throw new Error(`Mnemonic not provided and no publisher private key`);
@@ -352,7 +355,7 @@ export async function setup(
352
355
  const publisherPrivKeyRaw = publisherHdAccount.getHdKey().privateKey;
353
356
  const publisherPrivKey = publisherPrivKeyRaw === null ? null : Buffer.from(publisherPrivKeyRaw);
354
357
  publisherPrivKeyHex = `0x${publisherPrivKey!.toString('hex')}` as const;
355
- config.publisherPrivateKeys = [new SecretValue(publisherPrivKeyHex)];
358
+ config.sequencerPublisherPrivateKeys = [new SecretValue(publisherPrivKeyHex)];
356
359
  }
357
360
 
358
361
  if (config.coinbase === undefined) {
@@ -417,11 +420,12 @@ export async function setup(
417
420
  await ethCheatCodes.setIntervalMining(config.ethereumSlotDuration);
418
421
  }
419
422
 
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);
423
+ // In compose mode (no local anvil), sync dateProvider to L1 time since it may have drifted
424
+ // ahead of system time due to the local-network watcher warping time forward on each filled slot.
425
+ // When running with a local anvil, the dateProvider is kept in sync via the stdout listener.
426
+ if (!anvil) {
427
+ dateProvider.setTime((await ethCheatCodes.lastBlockTimestamp()) * 1000);
428
+ }
425
429
 
426
430
  if (opts.l2StartTime) {
427
431
  await ethCheatCodes.warp(opts.l2StartTime, { resetBlockInterval: true });
@@ -459,7 +463,7 @@ export async function setup(
459
463
  }
460
464
 
461
465
  let mockGossipSubNetwork: MockGossipSubNetwork | undefined;
462
- let p2pClientDeps: P2PClientDeps<P2PClientType.Full> | undefined = undefined;
466
+ let p2pClientDeps: P2PClientDeps | undefined = undefined;
463
467
 
464
468
  if (opts.mockGossipSubNetwork) {
465
469
  mockGossipSubNetwork = new MockGossipSubNetwork();
@@ -499,36 +503,33 @@ export async function setup(
499
503
  );
500
504
  const sequencerClient = aztecNodeService.getSequencer();
501
505
 
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;
506
+ let proverNode: AztecNodeService | undefined = undefined;
508
507
  if (opts.startProverNode) {
509
508
  logger.verbose('Creating and syncing a simulated prover node...');
510
509
  const proverNodePrivateKey = getPrivateKeyFromIndex(2);
511
510
  const proverNodePrivateKeyHex: Hex = `0x${proverNodePrivateKey!.toString('hex')}`;
512
511
  const proverNodeDataDirectory = path.join(directoryToCleanup, randomBytes(8).toString('hex'));
513
- const proverNodeConfig = {
514
- ...config.proverNodeConfig,
515
- dataDirectory: proverNodeDataDirectory,
516
- p2pEnabled: !!mockGossipSubNetwork,
512
+
513
+ const p2pClientDeps: Partial<P2PClientDeps> = {
514
+ p2pServiceFactory: mockGossipSubNetwork && getMockPubSubP2PServiceFactory(mockGossipSubNetwork!),
515
+ rpcTxProviders: [aztecNodeService],
517
516
  };
518
- proverNode = await createAndSyncProverNode(
517
+
518
+ ({ proverNode } = await createAndSyncProverNode(
519
519
  proverNodePrivateKeyHex,
520
520
  config,
521
- proverNodeConfig,
522
- aztecNodeService,
523
- prefilledPublicData,
524
521
  {
525
- p2pClientDeps: mockGossipSubNetwork
526
- ? { p2pServiceFactory: getMockPubSubP2PServiceFactory(mockGossipSubNetwork) }
527
- : undefined,
522
+ ...config.proverNodeConfig,
523
+ dataDirectory: proverNodeDataDirectory,
528
524
  },
529
- );
525
+ { dateProvider, p2pClientDeps, telemetry: telemetryClient },
526
+ { prefilledPublicData },
527
+ ));
530
528
  }
531
529
 
530
+ const sequencerDelayer = sequencerClient?.getDelayer();
531
+ const proverDelayer = proverNode?.getProverNode()?.getDelayer();
532
+
532
533
  logger.verbose('Creating a pxe...');
533
534
  const pxeConfig = { ...getPXEConfig(), ...pxeOpts };
534
535
  pxeConfig.dataDirectory = path.join(directoryToCleanup, randomBytes(8).toString('hex'));
@@ -629,6 +630,8 @@ export async function setup(
629
630
  mockGossipSubNetwork,
630
631
  prefilledPublicData,
631
632
  proverNode,
633
+ sequencerDelayer,
634
+ proverDelayer,
632
635
  sequencer: sequencerClient,
633
636
  teardown,
634
637
  telemetryClient,
@@ -712,81 +715,42 @@ export async function waitForProvenChain(node: AztecNode, targetBlock?: BlockNum
712
715
  );
713
716
  }
714
717
 
718
+ /**
719
+ * Creates an AztecNodeService with the prover node enabled as a subsystem.
720
+ * Returns both the aztec node service (for lifecycle management) and the prover node (for test internals access).
721
+ */
715
722
  export function createAndSyncProverNode(
716
723
  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
- ) {
724
+ baseConfig: AztecNodeConfig,
725
+ configOverrides: Pick<AztecNodeConfig, 'dataDirectory'>,
726
+ deps: {
727
+ telemetry?: TelemetryClient;
728
+ dateProvider: DateProvider;
729
+ p2pClientDeps?: P2PClientDeps;
730
+ },
731
+ options: { prefilledPublicData: PublicDataTreeLeaf[]; dontStart?: boolean },
732
+ ): Promise<{ proverNode: AztecNodeService }> {
723
733
  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,
734
+ const proverNode = await AztecNodeService.createAndSync(
735
+ {
736
+ ...baseConfig,
737
+ ...configOverrides,
738
+ p2pPort: 0,
739
+ enableProverNode: true,
740
+ disableValidator: true,
741
+ proverPublisherPrivateKeys: [new SecretValue(proverNodePrivateKey)],
742
+ },
743
+ deps,
744
+ { ...options, dontStartProverNode: options.dontStart },
763
745
  );
764
746
 
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();
747
+ if (!proverNode.getProverNode()) {
748
+ throw new Error('Prover node subsystem was not created despite enableProverNode being set');
773
749
  }
774
- return proverNode;
775
- });
776
- }
777
750
 
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;
751
+ getLogger().info(`Created and synced prover node`);
752
+ return { proverNode };
753
+ });
790
754
  }
791
755
 
792
756
  export type BalancesFn = ReturnType<typeof getBalancesFn>;
@@ -797,7 +761,9 @@ export function getBalancesFn(
797
761
  ): (...addresses: (AztecAddress | { address: AztecAddress })[]) => Promise<bigint[]> {
798
762
  const balances = async (...addressLikes: (AztecAddress | { address: AztecAddress })[]) => {
799
763
  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 })));
764
+ const b = await Promise.all(
765
+ addresses.map(async address => (await method(address).simulate({ from: address })).result),
766
+ );
801
767
  const debugString = `${symbol} balances: ${addresses.map((address, i) => `${address}: ${b[i]}`).join(', ')}`;
802
768
  logger.verbose(debugString);
803
769
  return b;
@@ -883,7 +849,7 @@ export const deployAccounts =
883
849
  );
884
850
  const deployMethod = await accountManager.getDeployMethod();
885
851
  await deployMethod.send({
886
- from: AztecAddress.ZERO,
852
+ from: NO_FROM,
887
853
  skipClassPublication: i !== 0, // Publish the contract class at most once.
888
854
  });
889
855
  }
@@ -915,7 +881,7 @@ export async function publicDeployAccounts(
915
881
 
916
882
  const batch = new BatchCall(wallet, calls);
917
883
 
918
- const txReceipt = await batch.send({ from: accountsToDeploy[0] });
884
+ const { receipt: txReceipt } = await batch.send({ from: accountsToDeploy[0] });
919
885
  if (waitUntilProven) {
920
886
  if (!node) {
921
887
  throw new Error('Need to provide an AztecNode to wait for proven.');
@@ -7,7 +7,6 @@ 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
10
  import type { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
12
11
 
13
12
  import getPort from 'get-port';
@@ -131,7 +130,7 @@ 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
136
  return await AztecNodeService.createAndSync(config, { telemetry, dateProvider }, { prefilledPublicData });
@@ -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'>>,
145
+ deps: { dateProvider: DateProvider },
147
146
  prefilledPublicData?: PublicDataTreeLeaf[],
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
+ { prefilledPublicData: prefilledPublicData ?? [] },
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;
@@ -6,7 +6,9 @@ import { TokenContract } from '@aztec/noir-contracts.js/Token';
6
6
 
7
7
  export async function deployToken(wallet: Wallet, admin: AztecAddress, initialAdminBalance: bigint, logger: Logger) {
8
8
  logger.info(`Deploying Token contract...`);
9
- const { contract, instance } = await TokenContract.deploy(wallet, admin, 'TokenName', 'TokenSymbol', 18).send({
9
+ const {
10
+ receipt: { contract, instance },
11
+ } = await TokenContract.deploy(wallet, admin, 'TokenName', 'TokenSymbol', 18).send({
10
12
  from: admin,
11
13
  wait: { returnReceipt: true },
12
14
  });
@@ -25,8 +27,9 @@ export async function mintTokensToPrivate(
25
27
  minter: AztecAddress,
26
28
  recipient: AztecAddress,
27
29
  amount: bigint,
30
+ additionalScopes?: AztecAddress[],
28
31
  ) {
29
- await token.methods.mint_to_private(recipient, amount).send({ from: minter });
32
+ await token.methods.mint_to_private(recipient, amount).send({ from: minter, additionalScopes });
30
33
  }
31
34
 
32
35
  export async function expectTokenBalance(
@@ -38,7 +41,7 @@ export async function expectTokenBalance(
38
41
  ) {
39
42
  // Then check the balance
40
43
  const contractWithWallet = TokenContract.at(token.address, wallet);
41
- const balance = await contractWithWallet.methods.balance_of_private(owner).simulate({ from: owner });
44
+ const { result: balance } = await contractWithWallet.methods.balance_of_private(owner).simulate({ from: owner });
42
45
  logger.info(`Account ${owner} balance: ${balance}`);
43
46
  expect(balance).toBe(expectedBalance);
44
47
  }
@@ -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
+ }
@@ -0,0 +1,104 @@
1
+ #!/usr/bin/env -S node --no-warnings
2
+ /**
3
+ * Standalone entrypoint that spins up a local Aztec network (L1 + node) and exposes a {@link NodeEmbeddedWallet} over
4
+ * JSON-RPC.
5
+ *
6
+ * Intended for forward-compatibility testing: an **old** release image runs this script so that **new** tests can send
7
+ * new artifacts to old runtime code (loadContractArtifact, ACIR simulator, class-ID computation, entrypoint encoding,
8
+ * etc.).
9
+ */
10
+ import { getSchnorrAccountContractAddress } from '@aztec/accounts/schnorr';
11
+ import { getInitialTestAccountsData } from '@aztec/accounts/testing';
12
+ import { createLocalNetwork } from '@aztec/aztec';
13
+ import { Fr } from '@aztec/aztec.js/fields';
14
+ import { WalletSchema } from '@aztec/aztec.js/wallet';
15
+ import { GrumpkinScalar } from '@aztec/foundation/curves/grumpkin';
16
+ import { createNamespacedSafeJsonRpcServer, startHttpRpcServer } from '@aztec/foundation/json-rpc/server';
17
+ import { createLogger } from '@aztec/foundation/log';
18
+ import { AztecNodeApiSchema } from '@aztec/stdlib/interfaces/client';
19
+ import { EmbeddedWallet } from '@aztec/wallets/embedded';
20
+
21
+ const logger = createLogger('wallet-service');
22
+
23
+ const { ETHEREUM_HOSTS = 'http://localhost:8545', NODE_PORT = '8080', WALLET_PORT = '8081' } = process.env;
24
+
25
+ async function main() {
26
+ const l1RpcUrls = ETHEREUM_HOSTS.split(',').map(url => url.trim());
27
+
28
+ // Some tests (e.g. AMM) need 4 accounts but only 3 are funded via genesis. Generate deterministic keys for a 4th
29
+ // account so we can compute its address before network startup and include it in genesis funding. We cannot do this
30
+ // in the test because Wallet interface does not expose account creation functionality (only TestWallet exposes that
31
+ // but that's not used in forward compatibility testing).
32
+ const extraAccountSecret = Fr.fromHexString('0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef');
33
+ const extraAccountSalt = Fr.ZERO;
34
+ const extraAccountSigningKey = GrumpkinScalar.random();
35
+ const extraAccountAddress = await getSchnorrAccountContractAddress(
36
+ extraAccountSecret,
37
+ extraAccountSalt,
38
+ extraAccountSigningKey,
39
+ );
40
+
41
+ logger.info('Starting wallet service...', { l1RpcUrls });
42
+
43
+ // createLocalNetwork deploys L1 contracts, starts the node, and optionally deploys funded test accounts (when
44
+ // TEST_ACCOUNTS=true via env). We are not proving anything just like is done when local network is started by
45
+ // the `aztecStart` function. The extra account address is passed via prefundAddresses so it gets fee juice at genesis.
46
+ const { node, stop: stopNetwork } = await createLocalNetwork(
47
+ { l1RpcUrls, realProofs: false, prefundAddresses: [extraAccountAddress.toString()] },
48
+ logger.info,
49
+ );
50
+
51
+ // Create an ephemeral embedded wallet backed by the local node.
52
+ const wallet = await EmbeddedWallet.create(node, { ephemeral: true });
53
+
54
+ // Re-register the initial test accounts so they are available via wallet.getAccounts(). createLocalNetwork deploys
55
+ // them onchain but uses a temporary wallet that is then stopped.
56
+ //
57
+ // We use the non-lazy import path (@aztec/accounts/testing, not /lazy) to avoid the dynamic JSON import that is
58
+ // incompatible with Node.js import attribute enforcement.
59
+ const testAccountsData = await getInitialTestAccountsData();
60
+ const accounts = await Promise.all(
61
+ testAccountsData.map(({ secret, salt, signingKey }) => wallet.createSchnorrAccount(secret, salt, signingKey)),
62
+ );
63
+
64
+ // Register and deploy the 4th account.
65
+ const extraAccount = await wallet.createSchnorrAccount(extraAccountSecret, extraAccountSalt, extraAccountSigningKey);
66
+ const deployMethod = await extraAccount.getDeployMethod();
67
+ await deployMethod.send({ from: accounts[0].address });
68
+
69
+ logger.info('Embedded wallet created', {
70
+ accounts: [...accounts, extraAccount].map(a => a.address.toString()),
71
+ });
72
+
73
+ // Contract artifacts are large, so allow generous body sizes for RPC requests.
74
+ const rpcOptions = { maxBodySizeBytes: '50mb' };
75
+
76
+ // Serve node RPC
77
+ const nodeRpcServer = createNamespacedSafeJsonRpcServer({ node: [node, AztecNodeApiSchema] }, rpcOptions);
78
+ const nodeHttpServer = await startHttpRpcServer(nodeRpcServer, { port: NODE_PORT });
79
+ logger.info(`Node JSON-RPC server listening on port ${nodeHttpServer.port}`);
80
+
81
+ // Serve wallet RPC
82
+ const walletRpcServer = createNamespacedSafeJsonRpcServer({ wallet: [wallet, WalletSchema] }, rpcOptions);
83
+ const walletHttpServer = await startHttpRpcServer(walletRpcServer, { port: WALLET_PORT });
84
+ logger.info(`Wallet JSON-RPC server listening on port ${walletHttpServer.port}`);
85
+
86
+ const shutdown = async () => {
87
+ logger.info('Shutting down...');
88
+ nodeHttpServer.close();
89
+ walletHttpServer.close();
90
+ await wallet.stop();
91
+ await stopNetwork();
92
+ process.exit(0);
93
+ };
94
+
95
+ // eslint-disable-next-line @typescript-eslint/no-misused-promises
96
+ process.once('SIGINT', shutdown);
97
+ // eslint-disable-next-line @typescript-eslint/no-misused-promises
98
+ process.once('SIGTERM', shutdown);
99
+ }
100
+
101
+ main().catch(err => {
102
+ logger.error('Wallet service failed to start', err);
103
+ process.exit(1);
104
+ });