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

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 (71) hide show
  1. package/dest/e2e_epochs/epochs_test.d.ts +9 -7
  2. package/dest/e2e_epochs/epochs_test.d.ts.map +1 -1
  3. package/dest/e2e_epochs/epochs_test.js +53 -34
  4. package/dest/e2e_p2p/p2p_network.d.ts +1 -1
  5. package/dest/e2e_p2p/p2p_network.d.ts.map +1 -1
  6. package/dest/e2e_p2p/p2p_network.js +16 -2
  7. package/dest/e2e_p2p/reqresp/utils.d.ts +3 -3
  8. package/dest/e2e_p2p/reqresp/utils.d.ts.map +1 -1
  9. package/dest/e2e_p2p/reqresp/utils.js +32 -8
  10. package/dest/fixtures/e2e_prover_test.d.ts +3 -3
  11. package/dest/fixtures/e2e_prover_test.d.ts.map +1 -1
  12. package/dest/fixtures/e2e_prover_test.js +27 -34
  13. package/dest/fixtures/fixtures.d.ts +5 -1
  14. package/dest/fixtures/fixtures.d.ts.map +1 -1
  15. package/dest/fixtures/fixtures.js +6 -0
  16. package/dest/fixtures/setup.d.ts +25 -8
  17. package/dest/fixtures/setup.d.ts.map +1 -1
  18. package/dest/fixtures/setup.js +46 -77
  19. package/dest/fixtures/setup_p2p_test.d.ts +6 -3
  20. package/dest/fixtures/setup_p2p_test.d.ts.map +1 -1
  21. package/dest/fixtures/setup_p2p_test.js +12 -9
  22. package/dest/fixtures/token_utils.d.ts +2 -2
  23. package/dest/fixtures/token_utils.d.ts.map +1 -1
  24. package/dest/fixtures/token_utils.js +3 -2
  25. package/dest/shared/submit-transactions.d.ts +1 -1
  26. package/dest/shared/submit-transactions.d.ts.map +1 -1
  27. package/dest/spartan/setup_test_wallets.d.ts +8 -1
  28. package/dest/spartan/setup_test_wallets.d.ts.map +1 -1
  29. package/dest/spartan/setup_test_wallets.js +28 -0
  30. package/dest/spartan/utils/bot.d.ts +3 -2
  31. package/dest/spartan/utils/bot.d.ts.map +1 -1
  32. package/dest/spartan/utils/bot.js +2 -1
  33. package/dest/spartan/utils/index.d.ts +2 -2
  34. package/dest/spartan/utils/index.d.ts.map +1 -1
  35. package/dest/spartan/utils/index.js +1 -1
  36. package/dest/spartan/utils/k8s.d.ts +3 -1
  37. package/dest/spartan/utils/k8s.d.ts.map +1 -1
  38. package/dest/spartan/utils/k8s.js +6 -0
  39. package/dest/spartan/utils/nodes.d.ts +4 -5
  40. package/dest/spartan/utils/nodes.d.ts.map +1 -1
  41. package/dest/spartan/utils/nodes.js +4 -5
  42. package/dest/test-wallet/test_wallet.js +1 -1
  43. package/dest/test-wallet/wallet_worker_script.d.ts +2 -0
  44. package/dest/test-wallet/wallet_worker_script.d.ts.map +1 -0
  45. package/dest/test-wallet/wallet_worker_script.js +40 -0
  46. package/dest/test-wallet/worker_wallet.d.ts +52 -0
  47. package/dest/test-wallet/worker_wallet.d.ts.map +1 -0
  48. package/dest/test-wallet/worker_wallet.js +103 -0
  49. package/dest/test-wallet/worker_wallet_schema.d.ts +274 -0
  50. package/dest/test-wallet/worker_wallet_schema.d.ts.map +1 -0
  51. package/dest/test-wallet/worker_wallet_schema.js +10 -0
  52. package/package.json +40 -40
  53. package/src/e2e_epochs/epochs_test.ts +66 -66
  54. package/src/e2e_p2p/p2p_network.ts +24 -2
  55. package/src/e2e_p2p/reqresp/utils.ts +36 -8
  56. package/src/fixtures/dumps/epoch_proof_result.json +1 -1
  57. package/src/fixtures/e2e_prover_test.ts +25 -35
  58. package/src/fixtures/fixtures.ts +10 -0
  59. package/src/fixtures/setup.ts +62 -105
  60. package/src/fixtures/setup_p2p_test.ts +9 -17
  61. package/src/fixtures/token_utils.ts +2 -1
  62. package/src/shared/submit-transactions.ts +4 -1
  63. package/src/spartan/setup_test_wallets.ts +55 -3
  64. package/src/spartan/utils/bot.ts +3 -0
  65. package/src/spartan/utils/index.ts +1 -0
  66. package/src/spartan/utils/k8s.ts +8 -0
  67. package/src/spartan/utils/nodes.ts +3 -6
  68. package/src/test-wallet/test_wallet.ts +1 -1
  69. package/src/test-wallet/wallet_worker_script.ts +43 -0
  70. package/src/test-wallet/worker_wallet.ts +165 -0
  71. package/src/test-wallet/worker_wallet_schema.ts +13 -0
@@ -1,6 +1,5 @@
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';
5
4
  import { AztecAddress, EthAddress } from '@aztec/aztec.js/addresses';
6
5
  import {
@@ -16,7 +15,6 @@ import { type Logger, createLogger } from '@aztec/aztec.js/log';
16
15
  import type { AztecNode } from '@aztec/aztec.js/node';
17
16
  import type { Wallet } from '@aztec/aztec.js/wallet';
18
17
  import { AnvilTestWatcher, CheatCodes } from '@aztec/aztec/testing';
19
- import { createBlobClientWithFileStores } from '@aztec/blob-client/client';
20
18
  import { SPONSORED_FPC_SALT } from '@aztec/constants';
21
19
  import { isAnvilTestChain } from '@aztec/ethereum/chain';
22
20
  import { createExtendedL1Client } from '@aztec/ethereum/client';
@@ -30,13 +28,8 @@ import {
30
28
  type ZKPassportArgs,
31
29
  deployAztecL1Contracts,
32
30
  } from '@aztec/ethereum/deploy-aztec-l1-contracts';
33
- import {
34
- DelayedTxUtils,
35
- EthCheatCodes,
36
- EthCheatCodesWithState,
37
- createDelayedL1TxUtilsFromViemWallet,
38
- startAnvil,
39
- } from '@aztec/ethereum/test';
31
+ import type { Delayer } from '@aztec/ethereum/l1-tx-utils';
32
+ import { EthCheatCodes, EthCheatCodesWithState, startAnvil } from '@aztec/ethereum/test';
40
33
  import { BlockNumber, EpochNumber } from '@aztec/foundation/branded-types';
41
34
  import { SecretValue } from '@aztec/foundation/config';
42
35
  import { randomBytes } from '@aztec/foundation/crypto/random';
@@ -45,16 +38,14 @@ import { withLoggerBindings } from '@aztec/foundation/log/server';
45
38
  import { retryUntil } from '@aztec/foundation/retry';
46
39
  import { sleep } from '@aztec/foundation/sleep';
47
40
  import { DateProvider, TestDateProvider } from '@aztec/foundation/timer';
48
- import type { DataStoreConfig } from '@aztec/kv-store/config';
49
41
  import { SponsoredFPCContract } from '@aztec/noir-contracts.js/SponsoredFPC';
50
42
  import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
51
43
  import type { P2PClientDeps } from '@aztec/p2p';
52
44
  import { MockGossipSubNetwork, getMockPubSubP2PServiceFactory } from '@aztec/p2p/test-helpers';
53
45
  import { protocolContractsHash } from '@aztec/protocol-contracts';
54
- import { type ProverNode, type ProverNodeConfig, type ProverNodeDeps, createProverNode } from '@aztec/prover-node';
46
+ import type { ProverNodeConfig } from '@aztec/prover-node';
55
47
  import { type PXEConfig, getPXEConfig } from '@aztec/pxe/server';
56
48
  import type { SequencerClient } from '@aztec/sequencer-client';
57
- import type { TestSequencerClient } from '@aztec/sequencer-client/test';
58
49
  import { type ContractInstanceWithAddress, getContractInstanceFromInstantiationParams } from '@aztec/stdlib/contract';
59
50
  import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
60
51
  import { tryStop } from '@aztec/stdlib/interfaces/server';
@@ -219,8 +210,8 @@ export type EndToEndContext = {
219
210
  aztecNodeService: AztecNodeService;
220
211
  /** Client to the Aztec Node admin interface. */
221
212
  aztecNodeAdmin: AztecNodeAdmin;
222
- /** The prover node service (only set if startProverNode is true) */
223
- proverNode: ProverNode | undefined;
213
+ /** The aztec node running the prover node subsystem (only set if startProverNode is true). */
214
+ proverNode: AztecNodeService | undefined;
224
215
  /** A client to the sequencer service. */
225
216
  sequencer: SequencerClient | undefined;
226
217
  /** Return values from deployAztecL1Contracts function. */
@@ -249,6 +240,10 @@ export type EndToEndContext = {
249
240
  telemetryClient: TelemetryClient;
250
241
  /** Mock gossip sub network used for gossipping messages (only if mockGossipSubNetwork was set to true in opts) */
251
242
  mockGossipSubNetwork: MockGossipSubNetwork | undefined;
243
+ /** Delayer for sequencer L1 txs (only when enableDelayer is true). */
244
+ sequencerDelayer: Delayer | undefined;
245
+ /** Delayer for prover node L1 txs (only when enableDelayer and startProverNode are true). */
246
+ proverDelayer: Delayer | undefined;
252
247
  /** Prefilled public data used for setting up nodes. */
253
248
  prefilledPublicData: PublicDataTreeLeaf[] | undefined;
254
249
  /** ACVM config (only set if running locally). */
@@ -288,6 +283,8 @@ export async function setup(
288
283
  config.realProofs = !!opts.realProofs;
289
284
  // Only enforce the time table if requested
290
285
  config.enforceTimeTable = !!opts.enforceTimeTable;
286
+ // Enable the tx delayer for tests (default config has it disabled, so we force-enable it here)
287
+ config.enableDelayer = true;
291
288
  config.listenAddress = '127.0.0.1';
292
289
 
293
290
  config.minTxPoolAgeMs = opts.minTxPoolAgeMs ?? 0;
@@ -339,11 +336,11 @@ export async function setup(
339
336
  publisherPrivKeyHex = opts.l1PublisherKey.getValue();
340
337
  publisherHdAccount = privateKeyToAccount(publisherPrivKeyHex);
341
338
  } else if (
342
- config.publisherPrivateKeys &&
343
- config.publisherPrivateKeys.length > 0 &&
344
- config.publisherPrivateKeys[0].getValue() != NULL_KEY
339
+ config.sequencerPublisherPrivateKeys &&
340
+ config.sequencerPublisherPrivateKeys.length > 0 &&
341
+ config.sequencerPublisherPrivateKeys[0].getValue() != NULL_KEY
345
342
  ) {
346
- publisherPrivKeyHex = config.publisherPrivateKeys[0].getValue();
343
+ publisherPrivKeyHex = config.sequencerPublisherPrivateKeys[0].getValue();
347
344
  publisherHdAccount = privateKeyToAccount(publisherPrivKeyHex);
348
345
  } else if (!MNEMONIC) {
349
346
  throw new Error(`Mnemonic not provided and no publisher private key`);
@@ -352,7 +349,7 @@ export async function setup(
352
349
  const publisherPrivKeyRaw = publisherHdAccount.getHdKey().privateKey;
353
350
  const publisherPrivKey = publisherPrivKeyRaw === null ? null : Buffer.from(publisherPrivKeyRaw);
354
351
  publisherPrivKeyHex = `0x${publisherPrivKey!.toString('hex')}` as const;
355
- config.publisherPrivateKeys = [new SecretValue(publisherPrivKeyHex)];
352
+ config.sequencerPublisherPrivateKeys = [new SecretValue(publisherPrivKeyHex)];
356
353
  }
357
354
 
358
355
  if (config.coinbase === undefined) {
@@ -499,36 +496,33 @@ export async function setup(
499
496
  );
500
497
  const sequencerClient = aztecNodeService.getSequencer();
501
498
 
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;
499
+ let proverNode: AztecNodeService | undefined = undefined;
508
500
  if (opts.startProverNode) {
509
501
  logger.verbose('Creating and syncing a simulated prover node...');
510
502
  const proverNodePrivateKey = getPrivateKeyFromIndex(2);
511
503
  const proverNodePrivateKeyHex: Hex = `0x${proverNodePrivateKey!.toString('hex')}`;
512
504
  const proverNodeDataDirectory = path.join(directoryToCleanup, randomBytes(8).toString('hex'));
513
- const proverNodeConfig = {
514
- ...config.proverNodeConfig,
515
- dataDirectory: proverNodeDataDirectory,
516
- p2pEnabled: !!mockGossipSubNetwork,
505
+
506
+ const p2pClientDeps: Partial<P2PClientDeps<P2PClientType.Full>> = {
507
+ p2pServiceFactory: mockGossipSubNetwork && getMockPubSubP2PServiceFactory(mockGossipSubNetwork!),
508
+ rpcTxProviders: [aztecNodeService],
517
509
  };
518
- proverNode = await createAndSyncProverNode(
510
+
511
+ ({ proverNode } = await createAndSyncProverNode(
519
512
  proverNodePrivateKeyHex,
520
513
  config,
521
- proverNodeConfig,
522
- aztecNodeService,
523
- prefilledPublicData,
524
514
  {
525
- p2pClientDeps: mockGossipSubNetwork
526
- ? { p2pServiceFactory: getMockPubSubP2PServiceFactory(mockGossipSubNetwork) }
527
- : undefined,
515
+ ...config.proverNodeConfig,
516
+ dataDirectory: proverNodeDataDirectory,
528
517
  },
529
- );
518
+ { dateProvider, p2pClientDeps, telemetry: telemetryClient },
519
+ { prefilledPublicData },
520
+ ));
530
521
  }
531
522
 
523
+ const sequencerDelayer = sequencerClient?.getDelayer();
524
+ const proverDelayer = proverNode?.getProverNode()?.getDelayer();
525
+
532
526
  logger.verbose('Creating a pxe...');
533
527
  const pxeConfig = { ...getPXEConfig(), ...pxeOpts };
534
528
  pxeConfig.dataDirectory = path.join(directoryToCleanup, randomBytes(8).toString('hex'));
@@ -629,6 +623,8 @@ export async function setup(
629
623
  mockGossipSubNetwork,
630
624
  prefilledPublicData,
631
625
  proverNode,
626
+ sequencerDelayer,
627
+ proverDelayer,
632
628
  sequencer: sequencerClient,
633
629
  teardown,
634
630
  telemetryClient,
@@ -712,81 +708,42 @@ export async function waitForProvenChain(node: AztecNode, targetBlock?: BlockNum
712
708
  );
713
709
  }
714
710
 
711
+ /**
712
+ * Creates an AztecNodeService with the prover node enabled as a subsystem.
713
+ * Returns both the aztec node service (for lifecycle management) and the prover node (for test internals access).
714
+ */
715
715
  export function createAndSyncProverNode(
716
716
  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
- ) {
717
+ baseConfig: AztecNodeConfig,
718
+ configOverrides: Pick<AztecNodeConfig, 'dataDirectory'>,
719
+ deps: {
720
+ telemetry?: TelemetryClient;
721
+ dateProvider: DateProvider;
722
+ p2pClientDeps?: P2PClientDeps<P2PClientType.Full>;
723
+ },
724
+ options: { prefilledPublicData: PublicDataTreeLeaf[]; dontStart?: boolean },
725
+ ): Promise<{ proverNode: AztecNodeService }> {
723
726
  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,
727
+ const proverNode = await AztecNodeService.createAndSync(
728
+ {
729
+ ...baseConfig,
730
+ ...configOverrides,
731
+ p2pPort: 0,
732
+ enableProverNode: true,
733
+ disableValidator: true,
734
+ proverPublisherPrivateKeys: [new SecretValue(proverNodePrivateKey)],
735
+ },
736
+ deps,
737
+ { ...options, dontStartProverNode: options.dontStart },
763
738
  );
764
739
 
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();
740
+ if (!proverNode.getProverNode()) {
741
+ throw new Error('Prover node subsystem was not created despite enableProverNode being set');
773
742
  }
774
- return proverNode;
775
- });
776
- }
777
743
 
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;
744
+ getLogger().info(`Created and synced prover node`);
745
+ return { proverNode };
746
+ });
790
747
  }
791
748
 
792
749
  export type BalancesFn = ReturnType<typeof getBalancesFn>;
@@ -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;
@@ -25,8 +25,9 @@ export async function mintTokensToPrivate(
25
25
  minter: AztecAddress,
26
26
  recipient: AztecAddress,
27
27
  amount: bigint,
28
+ additionalScopes?: AztecAddress[],
28
29
  ) {
29
- await token.methods.mint_to_private(recipient, amount).send({ from: minter });
30
+ await token.methods.mint_to_private(recipient, amount).send({ from: minter, additionalScopes });
30
31
  }
31
32
 
32
33
  export async function expectTokenBalance(
@@ -19,7 +19,10 @@ export const submitTxsTo = async (
19
19
  times(numTxs, async () => {
20
20
  const accountManager = await wallet.createSchnorrAccount(Fr.random(), Fr.random(), GrumpkinScalar.random());
21
21
  const deployMethod = await accountManager.getDeployMethod();
22
- const txHash = await deployMethod.send({ from: submitter, wait: NO_WAIT });
22
+ const txHash = await deployMethod.send({
23
+ from: submitter,
24
+ wait: NO_WAIT,
25
+ });
23
26
 
24
27
  logger.info(`Tx sent with hash ${txHash}`);
25
28
  const receipt: TxReceipt = await wallet.getTxReceipt(txHash);
@@ -20,6 +20,7 @@ import { getBBConfig } from '../fixtures/get_bb_config.js';
20
20
  import { getSponsoredFPCAddress, registerSponsoredFPC } from '../fixtures/utils.js';
21
21
  import { TestWallet } from '../test-wallet/test_wallet.js';
22
22
  import { proveInteraction } from '../test-wallet/utils.js';
23
+ import { WorkerWallet } from '../test-wallet/worker_wallet.js';
23
24
 
24
25
  export interface TestAccounts {
25
26
  aztecNode: AztecNode;
@@ -87,11 +88,19 @@ export async function deploySponsoredTestAccountsWithTokens(
87
88
 
88
89
  const paymentMethod = new SponsoredFeePaymentMethod(await getSponsoredFPCAddress());
89
90
  const recipientDeployMethod = await recipientAccount.getDeployMethod();
90
- await recipientDeployMethod.send({ from: AztecAddress.ZERO, fee: { paymentMethod }, wait: { timeout: 2400 } });
91
+ await recipientDeployMethod.send({
92
+ from: AztecAddress.ZERO,
93
+ fee: { paymentMethod },
94
+ wait: { timeout: 2400 },
95
+ });
91
96
  await Promise.all(
92
97
  fundedAccounts.map(async a => {
93
98
  const deployMethod = await a.getDeployMethod();
94
- await deployMethod.send({ from: AztecAddress.ZERO, fee: { paymentMethod }, wait: { timeout: 2400 } }); // increase timeout on purpose in order to account for two empty epochs
99
+ await deployMethod.send({
100
+ from: AztecAddress.ZERO,
101
+ fee: { paymentMethod },
102
+ wait: { timeout: 2400 },
103
+ }); // increase timeout on purpose in order to account for two empty epochs
95
104
  logger.info(`Account deployed at ${a.address}`);
96
105
  }),
97
106
  );
@@ -129,7 +138,11 @@ async function deployAccountWithDiagnostics(
129
138
  const deployMethod = await account.getDeployMethod();
130
139
  let txHash;
131
140
  try {
132
- txHash = await deployMethod.send({ from: AztecAddress.ZERO, fee: { paymentMethod }, wait: NO_WAIT });
141
+ txHash = await deployMethod.send({
142
+ from: AztecAddress.ZERO,
143
+ fee: { paymentMethod },
144
+ wait: NO_WAIT,
145
+ });
133
146
  await waitForTx(aztecNode, txHash, { timeout: 2400 });
134
147
  logger.info(`${accountLabel} deployed at ${account.address}`);
135
148
  } catch (error) {
@@ -397,3 +410,42 @@ export async function createWalletAndAztecNodeClient(
397
410
  },
398
411
  };
399
412
  }
413
+
414
+ export type WorkerWalletWrapper = {
415
+ wallet: WorkerWallet;
416
+ aztecNode: AztecNode;
417
+ cleanup: () => Promise<void>;
418
+ };
419
+
420
+ export async function createWorkerWalletClient(
421
+ nodeUrl: string,
422
+ proverEnabled: boolean,
423
+ logger: Logger,
424
+ ): Promise<WorkerWalletWrapper> {
425
+ const aztecNode = createAztecNodeClient(nodeUrl);
426
+ const [bbConfig, acvmConfig] = await Promise.all([getBBConfig(logger), getACVMConfig(logger)]);
427
+
428
+ // Strip cleanup functions — they can't be structured-cloned for worker transfer
429
+ const { cleanup: bbCleanup, ...bbPaths } = bbConfig ?? {};
430
+ const { cleanup: acvmCleanup, ...acvmPaths } = acvmConfig ?? {};
431
+
432
+ const pxeConfig = {
433
+ dataDirectory: undefined,
434
+ dataStoreMapSizeKb: 1024 * 1024,
435
+ ...bbPaths,
436
+ ...acvmPaths,
437
+ proverEnabled,
438
+ };
439
+
440
+ const wallet = await WorkerWallet.create(nodeUrl, pxeConfig);
441
+
442
+ return {
443
+ wallet,
444
+ aztecNode,
445
+ async cleanup() {
446
+ await wallet.stop();
447
+ await bbCleanup?.();
448
+ await acvmCleanup?.();
449
+ },
450
+ };
451
+ }
@@ -35,6 +35,7 @@ export async function installTransferBot({
35
35
  replicas = 1,
36
36
  txIntervalSeconds = 10,
37
37
  followChain = 'CHECKPOINTED',
38
+ pxeSyncChainTip = 'proposed',
38
39
  mnemonic = process.env.LABS_INFRA_MNEMONIC ?? 'test test test test test test test test test test test junk',
39
40
  mnemonicStartIndex,
40
41
  botPrivateKey = process.env.BOT_TRANSFERS_L2_PRIVATE_KEY ?? '0xcafe01',
@@ -49,6 +50,7 @@ export async function installTransferBot({
49
50
  replicas?: number;
50
51
  txIntervalSeconds?: number;
51
52
  followChain?: string;
53
+ pxeSyncChainTip?: string;
52
54
  mnemonic?: string;
53
55
  mnemonicStartIndex?: number | string;
54
56
  botPrivateKey?: string;
@@ -67,6 +69,7 @@ export async function installTransferBot({
67
69
  'bot.replicaCount': replicas,
68
70
  'bot.txIntervalSeconds': txIntervalSeconds,
69
71
  'bot.followChain': followChain,
72
+ 'bot.pxeSyncChainTip': pxeSyncChainTip,
70
73
  'bot.botPrivateKey': botPrivateKey,
71
74
  'bot.nodeUrl': resolvedNodeUrl,
72
75
  'bot.mnemonic': mnemonic,
@@ -25,6 +25,7 @@ export {
25
25
  getRPCEndpoint,
26
26
  getEthereumEndpoint,
27
27
  createResilientPrometheusConnection,
28
+ scaleProverAgents,
28
29
  } from './k8s.js';
29
30
 
30
31
  // Chaos Mesh
@@ -522,6 +522,14 @@ export function createResilientPrometheusConnection(
522
522
  return { connect, runAlertCheck };
523
523
  }
524
524
 
525
+ /** Scales the prover-agent Deployment to the given number of replicas. */
526
+ export async function scaleProverAgents(namespace: string, replicas: number, log: Logger): Promise<void> {
527
+ const label = 'app.kubernetes.io/component=prover-agent';
528
+ const command = `kubectl scale deployment -l ${label} -n ${namespace} --replicas=${replicas} --timeout=2m`;
529
+ log.info(`Scaling prover agents to ${replicas}: ${command}`);
530
+ await execAsync(command);
531
+ }
532
+
525
533
  export function getChartDir(spartanDir: string, chartName: string) {
526
534
  return path.join(spartanDir.trim(), chartName);
527
535
  }
@@ -255,21 +255,18 @@ export async function initHADb(namespace: string): Promise<void> {
255
255
  }
256
256
 
257
257
  /**
258
- * Enables or disables probabilistic transaction dropping on validators and waits for rollout.
259
- * Wired to env vars P2P_DROP_TX and P2P_DROP_TX_CHANCE via Helm values.
258
+ * Sets probabilistic transaction dropping on validators and waits for rollout.
259
+ * Use probability=0 to disable. Wired to env var P2P_DROP_TX_CHANCE via Helm values.
260
260
  */
261
261
  export async function setValidatorTxDrop({
262
262
  namespace,
263
- enabled,
264
263
  probability,
265
264
  logger: log,
266
265
  }: {
267
266
  namespace: string;
268
- enabled: boolean;
269
267
  probability: number;
270
268
  logger: Logger;
271
269
  }) {
272
- const drop = enabled ? 'true' : 'false';
273
270
  const prob = String(probability);
274
271
 
275
272
  const selectors = ['app.kubernetes.io/name=validator', 'app.kubernetes.io/component=validator', 'app=validator'];
@@ -284,7 +281,7 @@ export async function setValidatorTxDrop({
284
281
  if (names.length === 0) {
285
282
  continue;
286
283
  }
287
- const cmd = `kubectl set env statefulset -l ${selector} -n ${namespace} P2P_DROP_TX=${drop} P2P_DROP_TX_CHANCE=${prob}`;
284
+ const cmd = `kubectl set env statefulset -l ${selector} -n ${namespace} P2P_DROP_TX_CHANCE=${prob}`;
288
285
  log.info(`command: ${cmd}`);
289
286
  await execAsync(cmd);
290
287
  updated = true;
@@ -275,7 +275,7 @@ export class TestWallet extends BaseWallet {
275
275
  async proveTx(exec: ExecutionPayload, opts: Omit<SendOptions, 'wait'>): Promise<ProvenTx> {
276
276
  const fee = await this.completeFeeOptions(opts.from, exec.feePayer, opts.fee?.gasSettings);
277
277
  const txRequest = await this.createTxExecutionRequestFromPayloadAndFee(exec, opts.from, fee);
278
- const txProvingResult = await this.pxe.proveTx(txRequest, this.scopesFor(opts.from));
278
+ const txProvingResult = await this.pxe.proveTx(txRequest, this.scopesFrom(opts.from, opts.additionalScopes));
279
279
  return new ProvenTx(
280
280
  this.aztecNode,
281
281
  await txProvingResult.toTx(),
@@ -0,0 +1,43 @@
1
+ import { createAztecNodeClient } from '@aztec/aztec.js/node';
2
+ import { jsonStringify } from '@aztec/foundation/json-rpc';
3
+ import type { ApiSchema } from '@aztec/foundation/schemas';
4
+ import { parseWithOptionals, schemaHasMethod } from '@aztec/foundation/schemas';
5
+ import { NodeListener, TransportServer } from '@aztec/foundation/transport';
6
+
7
+ import { workerData } from 'worker_threads';
8
+
9
+ import { TestWallet } from './test_wallet.js';
10
+ import { WorkerWalletSchema } from './worker_wallet_schema.js';
11
+
12
+ const { nodeUrl, pxeConfig } = workerData as { nodeUrl: string; pxeConfig?: Record<string, unknown> };
13
+
14
+ const node = createAztecNodeClient(nodeUrl);
15
+ const wallet = await TestWallet.create(node, pxeConfig);
16
+
17
+ /** Handlers for methods that need custom implementation (not direct wallet passthrough). */
18
+ const handlers: Record<string, (...args: any[]) => Promise<any>> = {
19
+ proveTx: async (exec, opts) => {
20
+ const provenTx = await wallet.proveTx(exec, opts);
21
+ // ProvenTx has non-serializable fields (node proxy, etc.) — extract only Tx-compatible fields
22
+ const { data, chonkProof, contractClassLogFields, publicFunctionCalldata } = provenTx;
23
+ return { data, chonkProof, contractClassLogFields, publicFunctionCalldata };
24
+ },
25
+ registerAccount: async (secret, salt) => {
26
+ const manager = await wallet.createSchnorrAccount(secret, salt);
27
+ return manager.address;
28
+ },
29
+ };
30
+
31
+ const schema = WorkerWalletSchema as ApiSchema;
32
+ const listener = new NodeListener();
33
+ const server = new TransportServer<{ fn: string; args: string }>(listener, async msg => {
34
+ if (!schemaHasMethod(schema, msg.fn)) {
35
+ throw new Error(`Unknown method: ${msg.fn}`);
36
+ }
37
+ const jsonParams = JSON.parse(msg.args) as unknown[];
38
+ const args = await parseWithOptionals(jsonParams, schema[msg.fn].parameters());
39
+ const handler = handlers[msg.fn];
40
+ const result = handler ? await handler(...args) : await (wallet as any)[msg.fn](...args);
41
+ return jsonStringify(result);
42
+ });
43
+ server.start();