@aztec/end-to-end 0.82.3-nightly.20250330 → 0.82.3-nightly.20250403

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 (38) hide show
  1. package/dest/bench/client_flows/client_flows_benchmark.d.ts +15 -1
  2. package/dest/bench/client_flows/client_flows_benchmark.d.ts.map +1 -1
  3. package/dest/bench/client_flows/client_flows_benchmark.js +51 -6
  4. package/dest/bench/client_flows/config.d.ts +14 -0
  5. package/dest/bench/client_flows/config.d.ts.map +1 -0
  6. package/dest/bench/client_flows/config.js +85 -0
  7. package/dest/bench/client_flows/data_extractor.js +1 -2
  8. package/dest/bench/utils.js +2 -2
  9. package/dest/e2e_fees/fees_test.d.ts.map +1 -1
  10. package/dest/e2e_fees/fees_test.js +2 -4
  11. package/dest/e2e_p2p/p2p_network.js +1 -1
  12. package/dest/fixtures/l1_to_l2_messaging.d.ts +2 -2
  13. package/dest/fixtures/l1_to_l2_messaging.d.ts.map +1 -1
  14. package/dest/fixtures/l1_to_l2_messaging.js +2 -1
  15. package/dest/fixtures/setup_l1_contracts.d.ts.map +1 -1
  16. package/dest/fixtures/setup_l1_contracts.js +1 -2
  17. package/dest/fixtures/snapshot_manager.d.ts.map +1 -1
  18. package/dest/fixtures/snapshot_manager.js +4 -1
  19. package/dest/fixtures/utils.d.ts +0 -4
  20. package/dest/fixtures/utils.d.ts.map +1 -1
  21. package/dest/fixtures/utils.js +216 -238
  22. package/dest/shared/cross_chain_test_harness.d.ts +1 -1
  23. package/dest/shared/cross_chain_test_harness.d.ts.map +1 -1
  24. package/dest/shared/cross_chain_test_harness.js +2 -2
  25. package/dest/shared/uniswap_l1_l2.js +8 -6
  26. package/package.json +32 -32
  27. package/src/bench/client_flows/client_flows_benchmark.ts +69 -5
  28. package/src/bench/client_flows/config.ts +53 -0
  29. package/src/bench/client_flows/data_extractor.ts +2 -2
  30. package/src/bench/utils.ts +2 -2
  31. package/src/e2e_fees/fees_test.ts +1 -4
  32. package/src/e2e_p2p/p2p_network.ts +1 -1
  33. package/src/fixtures/l1_to_l2_messaging.ts +12 -3
  34. package/src/fixtures/setup_l1_contracts.ts +1 -2
  35. package/src/fixtures/snapshot_manager.ts +4 -1
  36. package/src/fixtures/utils.ts +235 -261
  37. package/src/shared/cross_chain_test_harness.ts +2 -2
  38. package/src/shared/uniswap_l1_l2.ts +8 -8
@@ -14,7 +14,6 @@ import {
14
14
  type AztecNode,
15
15
  BatchCall,
16
16
  type ContractMethod,
17
- FeeJuicePaymentMethod,
18
17
  type Logger,
19
18
  type PXE,
20
19
  SignerlessWallet,
@@ -30,7 +29,7 @@ import { SponsoredFeePaymentMethod } from '@aztec/aztec.js/fee/testing';
30
29
  import { AnvilTestWatcher, CheatCodes } from '@aztec/aztec.js/testing';
31
30
  import { createBlobSinkClient } from '@aztec/blob-sink/client';
32
31
  import { type BlobSinkServer, createBlobSinkServer } from '@aztec/blob-sink/server';
33
- import { FEE_JUICE_INITIAL_MINT, GENESIS_ARCHIVE_ROOT, GENESIS_BLOCK_HASH, SPONSORED_FPC_SALT } from '@aztec/constants';
32
+ import { GENESIS_ARCHIVE_ROOT, GENESIS_BLOCK_HASH, SPONSORED_FPC_SALT } from '@aztec/constants';
34
33
  import { DefaultMultiCallEntrypoint } from '@aztec/entrypoints/multicall';
35
34
  import {
36
35
  type DeployL1ContractsArgs,
@@ -49,10 +48,9 @@ import { EthAddress } from '@aztec/foundation/eth-address';
49
48
  import { Fr } from '@aztec/foundation/fields';
50
49
  import { retryUntil } from '@aztec/foundation/retry';
51
50
  import { TestDateProvider } from '@aztec/foundation/timer';
52
- import { FeeJuiceContract } from '@aztec/noir-contracts.js/FeeJuice';
53
51
  import { SponsoredFPCContract } from '@aztec/noir-contracts.js/SponsoredFPC';
54
52
  import { getVKTreeRoot } from '@aztec/noir-protocol-circuits-types/vk-tree';
55
- import { ProtocolContractAddress, protocolContractTreeRoot } from '@aztec/protocol-contracts';
53
+ import { protocolContractTreeRoot } from '@aztec/protocol-contracts';
56
54
  import { type ProverNode, type ProverNodeConfig, createProverNode } from '@aztec/prover-node';
57
55
  import {
58
56
  type PXEService,
@@ -65,7 +63,6 @@ import type { TestSequencerClient } from '@aztec/sequencer-client/test';
65
63
  import { WASMSimulator } from '@aztec/simulator/client';
66
64
  import { SimulationProviderRecorderWrapper } from '@aztec/simulator/testing';
67
65
  import { getContractClassFromArtifact, getContractInstanceFromDeployParams } from '@aztec/stdlib/contract';
68
- import { Gas } from '@aztec/stdlib/gas';
69
66
  import type { AztecNodeAdmin } from '@aztec/stdlib/interfaces/client';
70
67
  import type { PublicDataTreeLeaf } from '@aztec/stdlib/trees';
71
68
  import {
@@ -82,7 +79,6 @@ import fs from 'fs/promises';
82
79
  import getPort from 'get-port';
83
80
  import { tmpdir } from 'os';
84
81
  import * as path from 'path';
85
- import { inspect } from 'util';
86
82
  import { type Chain, type HDAccount, type Hex, type PrivateKeyAccount, getContract } from 'viem';
87
83
  import { mnemonicToAccount, privateKeyToAccount } from 'viem/accounts';
88
84
  import { foundry } from 'viem/chains';
@@ -126,7 +122,6 @@ export const setupL1Contracts = async (
126
122
  chain: Chain = foundry,
127
123
  ) => {
128
124
  const l1Data = await deployL1Contracts(l1RpcUrls, account, chain, logger, {
129
- l2FeeJuiceAddress: ProtocolContractAddress.FeeJuice.toField(),
130
125
  vkTreeRoot: getVKTreeRoot(),
131
126
  protocolContractTreeRoot,
132
127
  genesisArchiveRoot: args.genesisArchiveRoot ?? new Fr(GENESIS_ARCHIVE_ROOT),
@@ -239,8 +234,6 @@ async function setupWithRemoteEnvironment(
239
234
  const cheatCodes = await CheatCodes.create(config.l1RpcUrls, pxeClient!);
240
235
  const teardown = () => Promise.resolve();
241
236
 
242
- await setupCanonicalFeeJuice(pxeClient);
243
-
244
237
  logger.verbose('Constructing available wallets from already registered accounts...');
245
238
  const initialFundedAccounts = await getDeployedTestAccounts(pxeClient);
246
239
  const wallets = await getDeployedTestAccountsWallets(pxeClient);
@@ -357,271 +350,273 @@ export async function setup(
357
350
  pxeOpts: Partial<PXEServiceConfig> = {},
358
351
  chain: Chain = foundry,
359
352
  ): Promise<EndToEndContext> {
360
- const config = { ...getConfigEnvVars(), ...opts };
361
- config.peerCheckIntervalMS = TEST_PEER_CHECK_INTERVAL_MS;
362
- // For tests we only want proving enabled if specifically requested
363
- config.realProofs = !!opts.realProofs;
364
-
365
- const logger = getLogger();
366
-
367
- // Create a temp directory for any services that need it and cleanup later
368
- const directoryToCleanup = path.join(tmpdir(), randomBytes(8).toString('hex'));
369
- await fs.mkdir(directoryToCleanup, { recursive: true });
370
- if (!config.dataDirectory) {
371
- config.dataDirectory = directoryToCleanup;
372
- }
373
-
374
353
  let anvil: Anvil | undefined;
375
-
376
- if (!config.l1RpcUrls?.length) {
377
- if (!isAnvilTestChain(chain.id)) {
378
- throw new Error(`No ETHEREUM_HOSTS set but non anvil chain requested`);
379
- }
380
- if (PXE_URL) {
381
- throw new Error(
382
- `PXE_URL provided but no ETHEREUM_HOSTS set. Refusing to run, please set both variables so tests can deploy L1 contracts to the same Anvil instance`,
383
- );
354
+ try {
355
+ const config = { ...getConfigEnvVars(), ...opts };
356
+ config.peerCheckIntervalMS = TEST_PEER_CHECK_INTERVAL_MS;
357
+ // For tests we only want proving enabled if specifically requested
358
+ config.realProofs = !!opts.realProofs;
359
+ // Only enforce the time table if requested
360
+ config.enforceTimeTable = !!opts.enforceTimeTable;
361
+
362
+ const logger = getLogger();
363
+
364
+ // Create a temp directory for any services that need it and cleanup later
365
+ const directoryToCleanup = path.join(tmpdir(), randomBytes(8).toString('hex'));
366
+ await fs.mkdir(directoryToCleanup, { recursive: true });
367
+ if (!config.dataDirectory) {
368
+ config.dataDirectory = directoryToCleanup;
384
369
  }
385
370
 
386
- const res = await startAnvil({ l1BlockTime: opts.ethereumSlotDuration });
387
- anvil = res.anvil;
388
- config.l1RpcUrls = [res.rpcUrl];
389
- }
390
-
391
- // Enable logging metrics to a local file named after the test suite
392
- if (isMetricsLoggingRequested()) {
393
- const filename = path.join('log', getJobName() + '.jsonl');
394
- logger.info(`Logging metrics to ${filename}`);
395
- setupMetricsLogger(filename);
396
- }
397
-
398
- const ethCheatCodes = new EthCheatCodesWithState(config.l1RpcUrls);
399
-
400
- if (opts.stateLoad) {
401
- await ethCheatCodes.loadChainState(opts.stateLoad);
402
- }
403
-
404
- if (opts.l1StartTime) {
405
- await ethCheatCodes.warp(opts.l1StartTime);
406
- }
407
-
408
- let publisherPrivKey = undefined;
409
- let publisherHdAccount = undefined;
410
-
411
- if (config.publisherPrivateKey && config.publisherPrivateKey != NULL_KEY) {
412
- publisherHdAccount = privateKeyToAccount(config.publisherPrivateKey);
413
- } else if (!MNEMONIC) {
414
- throw new Error(`Mnemonic not provided and no publisher private key`);
415
- } else {
416
- publisherHdAccount = mnemonicToAccount(MNEMONIC, { addressIndex: 0 });
417
- const publisherPrivKeyRaw = publisherHdAccount.getHdKey().privateKey;
418
- publisherPrivKey = publisherPrivKeyRaw === null ? null : Buffer.from(publisherPrivKeyRaw);
419
- config.publisherPrivateKey = `0x${publisherPrivKey!.toString('hex')}`;
420
- }
421
-
422
- // Made as separate values such that keys can change, but for test they will be the same.
423
- config.validatorPrivateKey = config.publisherPrivateKey;
424
-
425
- if (PXE_URL) {
426
- // we are setting up against a remote environment, l1 contracts are assumed to already be deployed
427
- return await setupWithRemoteEnvironment(publisherHdAccount!, config, logger, numberOfAccounts);
428
- }
429
-
430
- const initialFundedAccounts =
431
- opts.initialFundedAccounts ??
432
- (await generateSchnorrAccounts(opts.numberOfInitialFundedAccounts ?? numberOfAccounts));
433
- const { genesisBlockHash, genesisArchiveRoot, prefilledPublicData } = await getGenesisValues(
434
- initialFundedAccounts.map(a => a.address),
435
- opts.initialAccountFeeJuice,
436
- opts.genesisPublicData,
437
- );
438
-
439
- const deployL1ContractsValues =
440
- opts.deployL1ContractsValues ??
441
- (await setupL1Contracts(
442
- config.l1RpcUrls,
443
- publisherHdAccount!,
444
- logger,
445
- { ...opts, genesisArchiveRoot, genesisBlockHash },
446
- chain,
447
- ));
371
+ if (!config.l1RpcUrls?.length) {
372
+ if (!isAnvilTestChain(chain.id)) {
373
+ throw new Error(`No ETHEREUM_HOSTS set but non anvil chain requested`);
374
+ }
375
+ if (PXE_URL) {
376
+ throw new Error(
377
+ `PXE_URL provided but no ETHEREUM_HOSTS set. Refusing to run, please set both variables so tests can deploy L1 contracts to the same Anvil instance`,
378
+ );
379
+ }
448
380
 
449
- config.l1Contracts = deployL1ContractsValues.l1ContractAddresses;
381
+ const res = await startAnvil({ l1BlockTime: opts.ethereumSlotDuration });
382
+ anvil = res.anvil;
383
+ config.l1RpcUrls = [res.rpcUrl];
384
+ }
450
385
 
451
- if (opts.fundRewardDistributor) {
452
- // Mints block rewards for 10000 blocks to the rewardDistributor contract
386
+ // Enable logging metrics to a local file named after the test suite
387
+ if (isMetricsLoggingRequested()) {
388
+ const filename = path.join('log', getJobName() + '.jsonl');
389
+ logger.info(`Logging metrics to ${filename}`);
390
+ setupMetricsLogger(filename);
391
+ }
453
392
 
454
- const rewardDistributor = getContract({
455
- address: deployL1ContractsValues.l1ContractAddresses.rewardDistributorAddress.toString(),
456
- abi: l1Artifacts.rewardDistributor.contractAbi,
457
- client: deployL1ContractsValues.publicClient,
458
- });
393
+ const ethCheatCodes = new EthCheatCodesWithState(config.l1RpcUrls);
459
394
 
460
- const blockReward = await rewardDistributor.read.BLOCK_REWARD();
461
- const mintAmount = 10_000n * (blockReward as bigint);
395
+ if (opts.stateLoad) {
396
+ await ethCheatCodes.loadChainState(opts.stateLoad);
397
+ }
462
398
 
463
- const feeJuice = getContract({
464
- address: deployL1ContractsValues.l1ContractAddresses.feeJuiceAddress.toString(),
465
- abi: l1Artifacts.feeAsset.contractAbi,
466
- client: deployL1ContractsValues.walletClient,
467
- });
399
+ if (opts.l1StartTime) {
400
+ await ethCheatCodes.warp(opts.l1StartTime);
401
+ }
468
402
 
469
- const rewardDistributorMintTxHash = await feeJuice.write.mint([rewardDistributor.address, mintAmount], {} as any);
470
- await deployL1ContractsValues.publicClient.waitForTransactionReceipt({ hash: rewardDistributorMintTxHash });
471
- logger.info(`Funding rewardDistributor in ${rewardDistributorMintTxHash}`);
472
- }
403
+ let publisherPrivKey = undefined;
404
+ let publisherHdAccount = undefined;
405
+
406
+ if (config.publisherPrivateKey && config.publisherPrivateKey != NULL_KEY) {
407
+ publisherHdAccount = privateKeyToAccount(config.publisherPrivateKey);
408
+ } else if (!MNEMONIC) {
409
+ throw new Error(`Mnemonic not provided and no publisher private key`);
410
+ } else {
411
+ publisherHdAccount = mnemonicToAccount(MNEMONIC, { addressIndex: 0 });
412
+ const publisherPrivKeyRaw = publisherHdAccount.getHdKey().privateKey;
413
+ publisherPrivKey = publisherPrivKeyRaw === null ? null : Buffer.from(publisherPrivKeyRaw);
414
+ config.publisherPrivateKey = `0x${publisherPrivKey!.toString('hex')}`;
415
+ }
473
416
 
474
- if (opts.l2StartTime) {
475
- // This should only be used in synching test or when you need to have a stable
476
- // timestamp for the first l2 block.
477
- await ethCheatCodes.warp(opts.l2StartTime);
478
- }
417
+ // Made as separate values such that keys can change, but for test they will be the same.
418
+ config.validatorPrivateKey = config.publisherPrivateKey;
479
419
 
480
- const dateProvider = new TestDateProvider();
420
+ if (PXE_URL) {
421
+ // we are setting up against a remote environment, l1 contracts are assumed to already be deployed
422
+ return await setupWithRemoteEnvironment(publisherHdAccount!, config, logger, numberOfAccounts);
423
+ }
481
424
 
482
- const watcher = new AnvilTestWatcher(
483
- new EthCheatCodesWithState(config.l1RpcUrls),
484
- deployL1ContractsValues.l1ContractAddresses.rollupAddress,
485
- deployL1ContractsValues.publicClient,
486
- dateProvider,
487
- );
425
+ const initialFundedAccounts =
426
+ opts.initialFundedAccounts ??
427
+ (await generateSchnorrAccounts(opts.numberOfInitialFundedAccounts ?? numberOfAccounts));
428
+ const { genesisBlockHash, genesisArchiveRoot, prefilledPublicData, fundingNeeded } = await getGenesisValues(
429
+ initialFundedAccounts.map(a => a.address),
430
+ opts.initialAccountFeeJuice,
431
+ opts.genesisPublicData,
432
+ );
488
433
 
489
- await watcher.start();
434
+ const deployL1ContractsValues =
435
+ opts.deployL1ContractsValues ??
436
+ (await setupL1Contracts(
437
+ config.l1RpcUrls,
438
+ publisherHdAccount!,
439
+ logger,
440
+ { ...opts, genesisArchiveRoot, genesisBlockHash, feeJuicePortalInitialBalance: fundingNeeded },
441
+ chain,
442
+ ));
443
+
444
+ config.l1Contracts = deployL1ContractsValues.l1ContractAddresses;
445
+
446
+ if (opts.fundRewardDistributor) {
447
+ // Mints block rewards for 10000 blocks to the rewardDistributor contract
448
+
449
+ const rewardDistributor = getContract({
450
+ address: deployL1ContractsValues.l1ContractAddresses.rewardDistributorAddress.toString(),
451
+ abi: l1Artifacts.rewardDistributor.contractAbi,
452
+ client: deployL1ContractsValues.publicClient,
453
+ });
454
+
455
+ const blockReward = await rewardDistributor.read.BLOCK_REWARD();
456
+ const mintAmount = 10_000n * (blockReward as bigint);
457
+
458
+ const feeJuice = getContract({
459
+ address: deployL1ContractsValues.l1ContractAddresses.feeJuiceAddress.toString(),
460
+ abi: l1Artifacts.feeAsset.contractAbi,
461
+ client: deployL1ContractsValues.walletClient,
462
+ });
463
+
464
+ const rewardDistributorMintTxHash = await feeJuice.write.mint([rewardDistributor.address, mintAmount], {} as any);
465
+ await deployL1ContractsValues.publicClient.waitForTransactionReceipt({ hash: rewardDistributorMintTxHash });
466
+ logger.info(`Funding rewardDistributor in ${rewardDistributorMintTxHash}`);
467
+ }
490
468
 
491
- const telemetry = getTelemetryClient(opts.telemetryConfig);
469
+ if (opts.l2StartTime) {
470
+ // This should only be used in synching test or when you need to have a stable
471
+ // timestamp for the first l2 block.
472
+ await ethCheatCodes.warp(opts.l2StartTime);
473
+ }
492
474
 
493
- // Blob sink service - blobs get posted here and served from here
494
- const blobSinkPort = await getPort();
495
- const blobSink = await createBlobSinkServer(
496
- {
497
- l1ChainId: config.l1ChainId,
498
- l1RpcUrls: config.l1RpcUrls,
499
- rollupAddress: config.l1Contracts.rollupAddress,
500
- port: blobSinkPort,
501
- dataDirectory: config.dataDirectory,
502
- dataStoreMapSizeKB: config.dataStoreMapSizeKB,
503
- },
504
- telemetry,
505
- );
506
- await blobSink.start();
507
- config.blobSinkUrl = `http://localhost:${blobSinkPort}`;
475
+ const dateProvider = new TestDateProvider();
508
476
 
509
- logger.verbose('Creating and synching an aztec node...');
477
+ const watcher = new AnvilTestWatcher(
478
+ new EthCheatCodesWithState(config.l1RpcUrls),
479
+ deployL1ContractsValues.l1ContractAddresses.rollupAddress,
480
+ deployL1ContractsValues.publicClient,
481
+ dateProvider,
482
+ );
510
483
 
511
- const acvmConfig = await getACVMConfig(logger);
512
- if (acvmConfig) {
513
- config.acvmWorkingDirectory = acvmConfig.acvmWorkingDirectory;
514
- config.acvmBinaryPath = acvmConfig.acvmBinaryPath;
515
- }
484
+ await watcher.start();
485
+
486
+ const telemetry = getTelemetryClient(opts.telemetryConfig);
487
+
488
+ // Blob sink service - blobs get posted here and served from here
489
+ const blobSinkPort = await getPort();
490
+ const blobSink = await createBlobSinkServer(
491
+ {
492
+ l1ChainId: config.l1ChainId,
493
+ l1RpcUrls: config.l1RpcUrls,
494
+ rollupAddress: config.l1Contracts.rollupAddress,
495
+ port: blobSinkPort,
496
+ dataDirectory: config.dataDirectory,
497
+ dataStoreMapSizeKB: config.dataStoreMapSizeKB,
498
+ },
499
+ telemetry,
500
+ );
501
+ await blobSink.start();
502
+ config.blobSinkUrl = `http://localhost:${blobSinkPort}`;
516
503
 
517
- const bbConfig = await getBBConfig(logger);
518
- if (bbConfig) {
519
- config.bbBinaryPath = bbConfig.bbBinaryPath;
520
- config.bbWorkingDirectory = bbConfig.bbWorkingDirectory;
521
- }
522
- config.l1PublishRetryIntervalMS = 100;
504
+ logger.verbose('Creating and synching an aztec node...');
523
505
 
524
- const blobSinkClient = createBlobSinkClient(config);
525
- const aztecNode = await AztecNodeService.createAndSync(
526
- config,
527
- { dateProvider, blobSinkClient, telemetry },
528
- { prefilledPublicData },
529
- );
530
- const sequencer = aztecNode.getSequencer();
506
+ const acvmConfig = await getACVMConfig(logger);
507
+ if (acvmConfig) {
508
+ config.acvmWorkingDirectory = acvmConfig.acvmWorkingDirectory;
509
+ config.acvmBinaryPath = acvmConfig.acvmBinaryPath;
510
+ }
531
511
 
532
- if (sequencer) {
533
- const publisher = (sequencer as TestSequencerClient).sequencer.publisher;
534
- publisher.l1TxUtils = DelayedTxUtils.fromL1TxUtils(publisher.l1TxUtils, config.ethereumSlotDuration);
535
- }
512
+ const bbConfig = await getBBConfig(logger);
513
+ if (bbConfig) {
514
+ config.bbBinaryPath = bbConfig.bbBinaryPath;
515
+ config.bbWorkingDirectory = bbConfig.bbWorkingDirectory;
516
+ }
517
+ config.l1PublishRetryIntervalMS = 100;
536
518
 
537
- let proverNode: ProverNode | undefined = undefined;
538
- if (opts.startProverNode) {
539
- logger.verbose('Creating and syncing a simulated prover node...');
540
- const proverNodePrivateKey = getPrivateKeyFromIndex(2);
541
- const proverNodePrivateKeyHex: Hex = `0x${proverNodePrivateKey!.toString('hex')}`;
542
- proverNode = await createAndSyncProverNode(
543
- proverNodePrivateKeyHex,
519
+ const blobSinkClient = createBlobSinkClient(config);
520
+ const aztecNode = await AztecNodeService.createAndSync(
544
521
  config,
545
- aztecNode,
546
- path.join(directoryToCleanup, randomBytes(8).toString('hex')),
522
+ { dateProvider, blobSinkClient, telemetry },
523
+ { prefilledPublicData },
547
524
  );
548
- }
525
+ const sequencer = aztecNode.getSequencer();
549
526
 
550
- logger.verbose('Creating a pxe...');
551
- const { pxe, teardown: pxeTeardown } = await setupPXEService(aztecNode!, pxeOpts, logger);
527
+ if (sequencer) {
528
+ const publisher = (sequencer as TestSequencerClient).sequencer.publisher;
529
+ publisher.l1TxUtils = DelayedTxUtils.fromL1TxUtils(publisher.l1TxUtils, config.ethereumSlotDuration);
530
+ }
552
531
 
553
- if (!config.skipProtocolContracts) {
554
- logger.verbose('Setting up Fee Juice...');
555
- await setupCanonicalFeeJuice(pxe);
556
- }
532
+ let proverNode: ProverNode | undefined = undefined;
533
+ if (opts.startProverNode) {
534
+ logger.verbose('Creating and syncing a simulated prover node...');
535
+ const proverNodePrivateKey = getPrivateKeyFromIndex(2);
536
+ const proverNodePrivateKeyHex: Hex = `0x${proverNodePrivateKey!.toString('hex')}`;
537
+ proverNode = await createAndSyncProverNode(
538
+ proverNodePrivateKeyHex,
539
+ config,
540
+ aztecNode,
541
+ path.join(directoryToCleanup, randomBytes(8).toString('hex')),
542
+ );
543
+ }
557
544
 
558
- const accountManagers = await deployFundedSchnorrAccounts(pxe, initialFundedAccounts.slice(0, numberOfAccounts));
559
- const wallets = await Promise.all(accountManagers.map(account => account.getWallet()));
560
- if (initialFundedAccounts.length < numberOfAccounts) {
561
- // TODO: Create (numberOfAccounts - initialFundedAccounts.length) wallets without funds.
562
- throw new Error(
563
- `Unable to deploy ${numberOfAccounts} accounts. Only ${initialFundedAccounts.length} accounts were funded.`,
564
- );
565
- }
545
+ logger.verbose('Creating a pxe...');
546
+ const { pxe, teardown: pxeTeardown } = await setupPXEService(aztecNode!, pxeOpts, logger);
566
547
 
567
- const cheatCodes = await CheatCodes.create(config.l1RpcUrls, pxe!);
548
+ const accountManagers = await deployFundedSchnorrAccounts(pxe, initialFundedAccounts.slice(0, numberOfAccounts));
549
+ const wallets = await Promise.all(accountManagers.map(account => account.getWallet()));
550
+ if (initialFundedAccounts.length < numberOfAccounts) {
551
+ // TODO: Create (numberOfAccounts - initialFundedAccounts.length) wallets without funds.
552
+ throw new Error(
553
+ `Unable to deploy ${numberOfAccounts} accounts. Only ${initialFundedAccounts.length} accounts were funded.`,
554
+ );
555
+ }
568
556
 
569
- const teardown = async () => {
570
- await pxeTeardown();
557
+ const cheatCodes = await CheatCodes.create(config.l1RpcUrls, pxe!);
571
558
 
572
- if (aztecNode instanceof AztecNodeService) {
573
- await aztecNode?.stop();
574
- }
559
+ const teardown = async () => {
560
+ await pxeTeardown();
575
561
 
576
- if (proverNode) {
577
- await proverNode.stop();
578
- }
562
+ if (aztecNode instanceof AztecNodeService) {
563
+ await aztecNode?.stop();
564
+ }
579
565
 
580
- if (acvmConfig?.cleanup) {
581
- // remove the temp directory created for the acvm
582
- logger.verbose(`Cleaning up ACVM state`);
583
- await acvmConfig.cleanup();
584
- }
566
+ if (proverNode) {
567
+ await proverNode.stop();
568
+ }
585
569
 
586
- if (bbConfig?.cleanup) {
587
- // remove the temp directory created for the acvm
588
- logger.verbose(`Cleaning up BB state`);
589
- await bbConfig.cleanup();
590
- }
570
+ if (acvmConfig?.cleanup) {
571
+ // remove the temp directory created for the acvm
572
+ logger.verbose(`Cleaning up ACVM state`);
573
+ await acvmConfig.cleanup();
574
+ }
591
575
 
592
- await anvil?.stop().catch(err => getLogger().error(err));
593
- await watcher.stop();
594
- await blobSink?.stop();
576
+ if (bbConfig?.cleanup) {
577
+ // remove the temp directory created for the acvm
578
+ logger.verbose(`Cleaning up BB state`);
579
+ await bbConfig.cleanup();
580
+ }
595
581
 
596
- if (directoryToCleanup) {
597
- try {
598
- logger.verbose(`Cleaning up data directory at ${directoryToCleanup}`);
599
- await fs.rm(directoryToCleanup, { recursive: true, force: true, maxRetries: 3 });
600
- } catch (err) {
601
- logger.warn(`Failed to delete data directory at ${directoryToCleanup}: ${err}`);
582
+ await anvil?.stop().catch(err => getLogger().error(err));
583
+ await watcher.stop();
584
+ await blobSink?.stop();
585
+
586
+ if (directoryToCleanup) {
587
+ try {
588
+ logger.verbose(`Cleaning up data directory at ${directoryToCleanup}`);
589
+ await fs.rm(directoryToCleanup, { recursive: true, force: true, maxRetries: 3 });
590
+ } catch (err) {
591
+ logger.warn(`Failed to delete data directory at ${directoryToCleanup}: ${err}`);
592
+ }
602
593
  }
603
- }
604
- };
594
+ };
605
595
 
606
- return {
607
- aztecNode,
608
- aztecNodeAdmin: aztecNode,
609
- blobSink,
610
- cheatCodes,
611
- config,
612
- dateProvider,
613
- deployL1ContractsValues,
614
- initialFundedAccounts,
615
- logger,
616
- proverNode,
617
- pxe,
618
- sequencer,
619
- teardown,
620
- telemetryClient: telemetry,
621
- wallet: wallets[0],
622
- wallets,
623
- watcher,
624
- };
596
+ return {
597
+ aztecNode,
598
+ aztecNodeAdmin: aztecNode,
599
+ blobSink,
600
+ cheatCodes,
601
+ config,
602
+ dateProvider,
603
+ deployL1ContractsValues,
604
+ initialFundedAccounts,
605
+ logger,
606
+ proverNode,
607
+ pxe,
608
+ sequencer,
609
+ teardown,
610
+ telemetryClient: telemetry,
611
+ wallet: wallets[0],
612
+ wallets,
613
+ watcher,
614
+ };
615
+ } catch (err) {
616
+ // TODO: Just hoisted anvil for now to ensure cleanup. Prob need to hoist the rest.
617
+ await anvil?.stop();
618
+ throw err;
619
+ }
625
620
  }
626
621
 
627
622
  /**
@@ -736,27 +731,6 @@ export async function expectMappingDelta<K, V extends number | bigint>(
736
731
  expect(diffs).toEqual(expectedDiffs);
737
732
  }
738
733
 
739
- /**
740
- * Deploy the canonical Fee Juice contract to a running instance.
741
- */
742
- export async function setupCanonicalFeeJuice(pxe: PXE) {
743
- // "deploy" the Fee Juice as it contains public functions
744
- const feeJuicePortalAddress = (await pxe.getNodeInfo()).l1ContractAddresses.feeJuicePortalAddress;
745
- const wallet = new SignerlessWallet(pxe);
746
- const feeJuice = await FeeJuiceContract.at(ProtocolContractAddress.FeeJuice, wallet);
747
-
748
- try {
749
- const paymentMethod = new FeeJuicePaymentMethod(ProtocolContractAddress.FeeJuice);
750
- await feeJuice.methods
751
- .initialize(feeJuicePortalAddress, FEE_JUICE_INITIAL_MINT)
752
- .send({ fee: { paymentMethod, gasSettings: { teardownGasLimits: Gas.empty() } } })
753
- .wait();
754
- getLogger().info(`Fee Juice successfully setup. Portal address: ${feeJuicePortalAddress}`);
755
- } catch (error) {
756
- getLogger().warn(`Fee Juice might have already been setup. Got error: ${inspect(error)}.`);
757
- }
758
- }
759
-
760
734
  /**
761
735
  * Computes the address of the "canonical" SponosoredFPCContract. This is not a protocol contract
762
736
  * but by conventions its address is computed with a salt of 0.
@@ -773,8 +747,8 @@ export async function getSponsoredFPCAddress() {
773
747
  * Deploy a sponsored FPC contract to a running instance.
774
748
  */
775
749
  export async function setupSponsoredFPC(pxe: PXE) {
776
- const { l1ChainId: chainId, protocolVersion } = await pxe.getNodeInfo();
777
- const deployer = new SignerlessWallet(pxe, new DefaultMultiCallEntrypoint(chainId, protocolVersion));
750
+ const { l1ChainId: chainId, rollupVersion } = await pxe.getNodeInfo();
751
+ const deployer = new SignerlessWallet(pxe, new DefaultMultiCallEntrypoint(chainId, rollupVersion));
778
752
 
779
753
  // Make the contract pay for the deployment fee itself
780
754
  const paymentMethod = new SponsoredFeePaymentMethod(await getSponsoredFPCAddress());
@@ -325,8 +325,8 @@ export class CrossChainTestHarness {
325
325
  expect(balance).toBe(expectedBalance);
326
326
  }
327
327
 
328
- getL2ToL1MessageLeaf(withdrawAmount: bigint, callerOnL1: EthAddress = EthAddress.ZERO): Fr {
329
- return this.l1TokenPortalManager.getL2ToL1MessageLeaf(
328
+ async getL2ToL1MessageLeaf(withdrawAmount: bigint, callerOnL1: EthAddress = EthAddress.ZERO): Promise<Fr> {
329
+ return await this.l1TokenPortalManager.getL2ToL1MessageLeaf(
330
330
  withdrawAmount,
331
331
  this.ethAccount,
332
332
  this.l2Bridge.address,