@aztec/end-to-end 2.0.0-nightly.20250826 → 2.0.0-nightly.20250827

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.
@@ -43,7 +43,13 @@ import {
43
43
  getL1ContractsConfigEnvVars,
44
44
  isAnvilTestChain,
45
45
  } from '@aztec/ethereum';
46
- import { DelayedTxUtils, EthCheatCodesWithState, startAnvil } from '@aztec/ethereum/test';
46
+ import {
47
+ DelayedTxUtils,
48
+ EthCheatCodes,
49
+ EthCheatCodesWithState,
50
+ createDelayedL1TxUtilsFromViemWallet,
51
+ startAnvil,
52
+ } from '@aztec/ethereum/test';
47
53
  import { SecretValue } from '@aztec/foundation/config';
48
54
  import { randomBytes } from '@aztec/foundation/crypto';
49
55
  import { EthAddress } from '@aztec/foundation/eth-address';
@@ -93,7 +99,7 @@ import getPort from 'get-port';
93
99
  import { tmpdir } from 'os';
94
100
  import * as path from 'path';
95
101
  import { type Chain, type HDAccount, type Hex, type PrivateKeyAccount, getContract } from 'viem';
96
- import { mnemonicToAccount, privateKeyToAccount } from 'viem/accounts';
102
+ import { generatePrivateKey, mnemonicToAccount, privateKeyToAccount } from 'viem/accounts';
97
103
  import { foundry } from 'viem/chains';
98
104
 
99
105
  import { MNEMONIC, TEST_PEER_CHECK_INTERVAL_MS } from './fixtures.js';
@@ -236,6 +242,7 @@ async function setupWithRemoteEnvironment(
236
242
  l1Client,
237
243
  rollupVersion,
238
244
  };
245
+ const ethCheatCodes = new EthCheatCodes(config.l1RpcUrls);
239
246
  const cheatCodes = await CheatCodes.create(config.l1RpcUrls, pxeClient!);
240
247
  const teardown = () => Promise.resolve();
241
248
 
@@ -262,6 +269,7 @@ async function setupWithRemoteEnvironment(
262
269
  accounts: wallets.slice(0, numberOfAccounts).map(w => w.getAddress()),
263
270
  logger,
264
271
  cheatCodes,
272
+ ethCheatCodes,
265
273
  prefilledPublicData: undefined,
266
274
  mockGossipSubNetwork: undefined,
267
275
  watcher: undefined,
@@ -316,6 +324,8 @@ export type SetupOptions = {
316
324
  anvilAccounts?: number;
317
325
  /** Port to start anvil (defaults to 8545) */
318
326
  anvilPort?: number;
327
+ /** Key to use for publishing L1 contracts */
328
+ l1PublisherKey?: SecretValue<`0x${string}`>;
319
329
  } & Partial<AztecNodeConfig>;
320
330
 
321
331
  /** Context for an end-to-end test as returned by the `setup` function */
@@ -346,6 +356,8 @@ export type EndToEndContext = {
346
356
  logger: Logger;
347
357
  /** The cheat codes. */
348
358
  cheatCodes: CheatCodes;
359
+ /** The cheat codes for L1 */
360
+ ethCheatCodes: EthCheatCodes;
349
361
  /** The anvil test watcher (undefined if connected to remote environment) */
350
362
  watcher: AnvilTestWatcher | undefined;
351
363
  /** Allows tweaking current system time, used by the epoch cache only (undefined if connected to remote environment) */
@@ -438,17 +450,25 @@ export async function setup(
438
450
  let publisherPrivKey = undefined;
439
451
  let publisherHdAccount = undefined;
440
452
 
441
- if (config.publisherPrivateKey && config.publisherPrivateKey.getValue() != NULL_KEY) {
442
- publisherHdAccount = privateKeyToAccount(config.publisherPrivateKey.getValue());
453
+ if (opts.l1PublisherKey && opts.l1PublisherKey.getValue() && opts.l1PublisherKey.getValue() != NULL_KEY) {
454
+ publisherHdAccount = privateKeyToAccount(opts.l1PublisherKey.getValue());
455
+ } else if (
456
+ config.publisherPrivateKeys &&
457
+ config.publisherPrivateKeys.length > 0 &&
458
+ config.publisherPrivateKeys[0].getValue() != NULL_KEY
459
+ ) {
460
+ publisherHdAccount = privateKeyToAccount(config.publisherPrivateKeys[0].getValue());
443
461
  } else if (!MNEMONIC) {
444
462
  throw new Error(`Mnemonic not provided and no publisher private key`);
445
463
  } else {
446
464
  publisherHdAccount = mnemonicToAccount(MNEMONIC, { addressIndex: 0 });
447
465
  const publisherPrivKeyRaw = publisherHdAccount.getHdKey().privateKey;
448
466
  publisherPrivKey = publisherPrivKeyRaw === null ? null : Buffer.from(publisherPrivKeyRaw);
449
- config.publisherPrivateKey = new SecretValue(`0x${publisherPrivKey!.toString('hex')}` as const);
467
+ config.publisherPrivateKeys = [new SecretValue(`0x${publisherPrivKey!.toString('hex')}` as const)];
450
468
  }
451
469
 
470
+ config.coinbase = EthAddress.fromString(publisherHdAccount.address);
471
+
452
472
  if (PXE_URL) {
453
473
  // we are setting up against a remote environment, l1 contracts are assumed to already be deployed
454
474
  return await setupWithRemoteEnvironment(publisherHdAccount!, config, logger, numberOfAccounts);
@@ -603,6 +623,13 @@ export async function setup(
603
623
 
604
624
  config.p2pEnabled = opts.mockGossipSubNetwork || config.p2pEnabled;
605
625
  config.p2pIp = opts.p2pIp ?? config.p2pIp ?? '127.0.0.1';
626
+
627
+ if (!config.disableValidator) {
628
+ if ((config.validatorPrivateKeys?.getValue().length ?? 0) === 0) {
629
+ config.validatorPrivateKeys = new SecretValue([generatePrivateKey()]);
630
+ }
631
+ }
632
+
606
633
  const aztecNode = await AztecNodeService.createAndSync(
607
634
  config, // REFACTOR: createAndSync mutates this config
608
635
  { dateProvider, blobSinkClient, telemetry, p2pClientDeps, logger: createLogger('node:MAIN-aztec-node') },
@@ -612,7 +639,7 @@ export async function setup(
612
639
 
613
640
  if (sequencerClient) {
614
641
  const publisher = (sequencerClient as TestSequencerClient).sequencer.publisher;
615
- publisher.l1TxUtils = DelayedTxUtils.fromL1TxUtils(publisher.l1TxUtils, config.ethereumSlotDuration);
642
+ publisher.l1TxUtils = DelayedTxUtils.fromL1TxUtils(publisher.l1TxUtils, config.ethereumSlotDuration, l1Client);
616
643
  }
617
644
 
618
645
  let proverNode: ProverNode | undefined = undefined;
@@ -687,8 +714,9 @@ export async function setup(
687
714
  await bbConfig.cleanup();
688
715
  }
689
716
 
690
- await tryStop(anvil, logger);
691
717
  await tryStop(watcher, logger);
718
+ await tryStop(anvil, logger);
719
+
692
720
  await tryStop(blobSink, logger);
693
721
  await tryRmDir(directoryToCleanup, logger);
694
722
  } catch (err) {
@@ -701,6 +729,7 @@ export async function setup(
701
729
  aztecNodeAdmin: aztecNode,
702
730
  blobSink,
703
731
  cheatCodes,
732
+ ethCheatCodes,
704
733
  config,
705
734
  dateProvider,
706
735
  deployL1ContractsValues,
@@ -924,7 +953,7 @@ export function createAndSyncProverNode(
924
953
  txCollectionNodeRpcUrls: [],
925
954
  realProofs: false,
926
955
  proverAgentCount: 2,
927
- publisherPrivateKey: new SecretValue(proverNodePrivateKey),
956
+ publisherPrivateKeys: [new SecretValue(proverNodePrivateKey)],
928
957
  proverNodeMaxPendingJobs: 10,
929
958
  proverNodeMaxParallelBlocksPerEpoch: 32,
930
959
  proverNodePollingIntervalMs: 200,
@@ -933,6 +962,7 @@ export function createAndSyncProverNode(
933
962
  txGatheringMaxParallelRequestsPerNode: 10,
934
963
  txGatheringTimeoutMs: 24_000,
935
964
  proverNodeFailedEpochStore: undefined,
965
+ proverId: EthAddress.fromNumber(1),
936
966
  ...proverNodeConfig,
937
967
  };
938
968
 
@@ -963,7 +993,7 @@ function createDelayedL1TxUtils(
963
993
  const l1Client = createExtendedL1Client(aztecNodeConfig.l1RpcUrls, privateKey, foundry);
964
994
 
965
995
  const log = createLogger(logName);
966
- const l1TxUtils = new DelayedTxUtils(l1Client, log, dateProvider, aztecNodeConfig);
996
+ const l1TxUtils = createDelayedL1TxUtilsFromViemWallet(l1Client, log, dateProvider, aztecNodeConfig);
967
997
  l1TxUtils.enableDelayer(aztecNodeConfig.ethereumSlotDuration);
968
998
  return l1TxUtils;
969
999
  }