@aztec/aztec-node 0.0.1-commit.c80b6263 → 0.0.1-commit.cb6bed7c2

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.
@@ -1,20 +1,15 @@
1
1
  import { Archiver, createArchiver } from '@aztec/archiver';
2
2
  import { BBCircuitVerifier, QueuedIVCVerifier, TestCircuitVerifier } from '@aztec/bb-prover';
3
3
  import { type BlobClientInterface, createBlobClientWithFileStores } from '@aztec/blob-client/client';
4
- import {
5
- ARCHIVE_HEIGHT,
6
- type L1_TO_L2_MSG_TREE_HEIGHT,
7
- type NOTE_HASH_TREE_HEIGHT,
8
- type NULLIFIER_TREE_HEIGHT,
9
- type PUBLIC_DATA_TREE_HEIGHT,
10
- } from '@aztec/constants';
4
+ import { Blob } from '@aztec/blob-lib';
5
+ import { ARCHIVE_HEIGHT, type L1_TO_L2_MSG_TREE_HEIGHT, type NOTE_HASH_TREE_HEIGHT } from '@aztec/constants';
11
6
  import { EpochCache, type EpochCacheInterface } from '@aztec/epoch-cache';
12
7
  import { createEthereumChain } from '@aztec/ethereum/chain';
13
8
  import { getPublicClient } from '@aztec/ethereum/client';
14
9
  import { RegistryContract, RollupContract } from '@aztec/ethereum/contracts';
15
10
  import type { L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
16
11
  import { BlockNumber, CheckpointNumber, EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
17
- import { compactArray, pick } from '@aztec/foundation/collection';
12
+ import { compactArray, pick, unique } from '@aztec/foundation/collection';
18
13
  import { Fr } from '@aztec/foundation/curves/bn254';
19
14
  import { EthAddress } from '@aztec/foundation/eth-address';
20
15
  import { BadRequestError } from '@aztec/foundation/json-rpc';
@@ -22,14 +17,19 @@ import { type Logger, createLogger } from '@aztec/foundation/log';
22
17
  import { count } from '@aztec/foundation/string';
23
18
  import { DateProvider, Timer } from '@aztec/foundation/timer';
24
19
  import { MembershipWitness, SiblingPath } from '@aztec/foundation/trees';
25
- import { KeystoreManager, loadKeystores, mergeKeystores } from '@aztec/node-keystore';
20
+ import { type KeyStore, KeystoreManager, loadKeystores, mergeKeystores } from '@aztec/node-keystore';
26
21
  import { trySnapshotSync, uploadSnapshot } from '@aztec/node-lib/actions';
22
+ import { createForwarderL1TxUtilsFromSigners, createL1TxUtilsFromSigners } from '@aztec/node-lib/factories';
27
23
  import {
28
- createForwarderL1TxUtilsFromEthSigner,
29
- createL1TxUtilsWithBlobsFromEthSigner,
30
- } from '@aztec/node-lib/factories';
31
- import { type P2P, type P2PClientDeps, createP2PClient, getDefaultAllowedSetupFunctions } from '@aztec/p2p';
24
+ type P2P,
25
+ type P2PClientDeps,
26
+ createP2PClient,
27
+ createTxValidatorForAcceptingTxsOverRPC,
28
+ getDefaultAllowedSetupFunctions,
29
+ } from '@aztec/p2p';
32
30
  import { ProtocolContractAddress } from '@aztec/protocol-contracts';
31
+ import { type ProverNode, type ProverNodeDeps, createProverNode } from '@aztec/prover-node';
32
+ import { createKeyStoreForProver } from '@aztec/prover-node/config';
33
33
  import { GlobalVariableBuilder, SequencerClient, type SequencerPublisher } from '@aztec/sequencer-client';
34
34
  import { PublicProcessorFactory } from '@aztec/simulator/server';
35
35
  import {
@@ -41,7 +41,14 @@ import {
41
41
  } from '@aztec/slasher';
42
42
  import { CollectionLimitsConfig, PublicSimulatorConfig } from '@aztec/stdlib/avm';
43
43
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
44
- import { BlockHash, type BlockParameter, type DataInBlock, L2Block, type L2BlockSource } from '@aztec/stdlib/block';
44
+ import {
45
+ type BlockData,
46
+ BlockHash,
47
+ type BlockParameter,
48
+ type DataInBlock,
49
+ L2Block,
50
+ type L2BlockSource,
51
+ } from '@aztec/stdlib/block';
45
52
  import type { PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
46
53
  import type {
47
54
  ContractClassPublic,
@@ -69,9 +76,9 @@ import {
69
76
  type WorldStateSynchronizer,
70
77
  tryStop,
71
78
  } from '@aztec/stdlib/interfaces/server';
72
- import type { LogFilter, SiloedTag, Tag, TxScopedL2Log } from '@aztec/stdlib/logs';
79
+ import type { DebugLogStore, LogFilter, SiloedTag, Tag, TxScopedL2Log } from '@aztec/stdlib/logs';
80
+ import { InMemoryDebugLogStore, NullDebugLogStore } from '@aztec/stdlib/logs';
73
81
  import { InboxLeaf, type L1ToL2MessageSource } from '@aztec/stdlib/messaging';
74
- import { P2PClientType } from '@aztec/stdlib/p2p';
75
82
  import type { Offense, SlashPayloadRound } from '@aztec/stdlib/slashing';
76
83
  import type { NullifierLeafPreimage, PublicDataTreeLeaf, PublicDataTreeLeafPreimage } from '@aztec/stdlib/trees';
77
84
  import { MerkleTreeId, NullifierMembershipWitness, PublicDataWitness } from '@aztec/stdlib/trees';
@@ -103,7 +110,6 @@ import {
103
110
  ValidatorClient,
104
111
  createBlockProposalHandler,
105
112
  createValidatorClient,
106
- createValidatorForAcceptingTxs,
107
113
  } from '@aztec/validator-client';
108
114
  import { createWorldStateSynchronizer } from '@aztec/world-state';
109
115
 
@@ -135,6 +141,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
135
141
  protected readonly l1ToL2MessageSource: L1ToL2MessageSource,
136
142
  protected readonly worldStateSynchronizer: WorldStateSynchronizer,
137
143
  protected readonly sequencer: SequencerClient | undefined,
144
+ protected readonly proverNode: ProverNode | undefined,
138
145
  protected readonly slasherClient: SlasherClientInterface | undefined,
139
146
  protected readonly validatorsSentinel: Sentinel | undefined,
140
147
  protected readonly epochPruneWatcher: EpochPruneWatcher | undefined,
@@ -147,12 +154,22 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
147
154
  private telemetry: TelemetryClient = getTelemetryClient(),
148
155
  private log = createLogger('node'),
149
156
  private blobClient?: BlobClientInterface,
157
+ private validatorClient?: ValidatorClient,
158
+ private keyStoreManager?: KeystoreManager,
159
+ private debugLogStore: DebugLogStore = new NullDebugLogStore(),
150
160
  ) {
151
161
  this.metrics = new NodeMetrics(telemetry, 'AztecNodeService');
152
162
  this.tracer = telemetry.getTracer('AztecNodeService');
153
163
 
154
164
  this.log.info(`Aztec Node version: ${this.packageVersion}`);
155
165
  this.log.info(`Aztec Node started on chain 0x${l1ChainId.toString(16)}`, config.l1Contracts);
166
+
167
+ // A defensive check that protects us against introducing a bug in the complex `createAndSync` function. We must
168
+ // never have debugLogStore enabled when not in test mode because then we would be accumulating debug logs in
169
+ // memory which could be a DoS vector on the sequencer (since no fees are paid for debug logs).
170
+ if (debugLogStore.isEnabled && config.realProofs) {
171
+ throw new Error('debugLogStore should never be enabled when realProofs are set');
172
+ }
156
173
  }
157
174
 
158
175
  public async getWorldStateSyncStatus(): Promise<WorldStateSyncStatus> {
@@ -176,11 +193,13 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
176
193
  logger?: Logger;
177
194
  publisher?: SequencerPublisher;
178
195
  dateProvider?: DateProvider;
179
- p2pClientDeps?: P2PClientDeps<P2PClientType.Full>;
196
+ p2pClientDeps?: P2PClientDeps;
197
+ proverNodeDeps?: Partial<ProverNodeDeps>;
180
198
  } = {},
181
199
  options: {
182
200
  prefilledPublicData?: PublicDataTreeLeaf[];
183
201
  dontStartSequencer?: boolean;
202
+ dontStartProverNode?: boolean;
184
203
  } = {},
185
204
  ): Promise<AztecNodeService> {
186
205
  const config = { ...inputConfig }; // Copy the config so we dont mutate the input object
@@ -190,16 +209,29 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
190
209
  const dateProvider = deps.dateProvider ?? new DateProvider();
191
210
  const ethereumChain = createEthereumChain(config.l1RpcUrls, config.l1ChainId);
192
211
 
193
- // Build a key store from file if given or from environment otherwise
212
+ // Build a key store from file if given or from environment otherwise.
213
+ // We keep the raw KeyStore available so we can merge with prover keys if enableProverNode is set.
194
214
  let keyStoreManager: KeystoreManager | undefined;
195
215
  const keyStoreProvided = config.keyStoreDirectory !== undefined && config.keyStoreDirectory.length > 0;
196
216
  if (keyStoreProvided) {
197
217
  const keyStores = loadKeystores(config.keyStoreDirectory!);
198
218
  keyStoreManager = new KeystoreManager(mergeKeystores(keyStores));
199
219
  } else {
200
- const keyStore = createKeyStoreForValidator(config);
201
- if (keyStore) {
202
- keyStoreManager = new KeystoreManager(keyStore);
220
+ const rawKeyStores: KeyStore[] = [];
221
+ const validatorKeyStore = createKeyStoreForValidator(config);
222
+ if (validatorKeyStore) {
223
+ rawKeyStores.push(validatorKeyStore);
224
+ }
225
+ if (config.enableProverNode) {
226
+ const proverKeyStore = createKeyStoreForProver(config);
227
+ if (proverKeyStore) {
228
+ rawKeyStores.push(proverKeyStore);
229
+ }
230
+ }
231
+ if (rawKeyStores.length > 0) {
232
+ keyStoreManager = new KeystoreManager(
233
+ rawKeyStores.length === 1 ? rawKeyStores[0] : mergeKeystores(rawKeyStores),
234
+ );
203
235
  }
204
236
  }
205
237
 
@@ -210,10 +242,8 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
210
242
  if (keyStoreManager === undefined) {
211
243
  throw new Error('Failed to create key store, a requirement for running a validator');
212
244
  }
213
- if (!keyStoreProvided) {
214
- log.warn(
215
- 'KEY STORE CREATED FROM ENVIRONMENT, IT IS RECOMMENDED TO USE A FILE-BASED KEY STORE IN PRODUCTION ENVIRONMENTS',
216
- );
245
+ if (!keyStoreProvided && process.env.NODE_ENV !== 'test') {
246
+ log.warn("Keystore created from env: it's recommended to use a file-based key store for production");
217
247
  }
218
248
  ValidatorClient.validateKeyStoreConfiguration(keyStoreManager, log);
219
249
  }
@@ -241,10 +271,11 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
241
271
  config.l1Contracts = { ...config.l1Contracts, ...l1ContractsAddresses };
242
272
 
243
273
  const rollupContract = new RollupContract(publicClient, config.l1Contracts.rollupAddress.toString());
244
- const [l1GenesisTime, slotDuration, rollupVersionFromRollup] = await Promise.all([
274
+ const [l1GenesisTime, slotDuration, rollupVersionFromRollup, rollupManaLimit] = await Promise.all([
245
275
  rollupContract.getL1GenesisTime(),
246
276
  rollupContract.getSlotDuration(),
247
277
  rollupContract.getVersion(),
278
+ rollupContract.getManaLimit().then(Number),
248
279
  ] as const);
249
280
 
250
281
  config.rollupVersion ??= Number(rollupVersionFromRollup);
@@ -255,7 +286,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
255
286
  );
256
287
  }
257
288
 
258
- const blobClient = await createBlobClientWithFileStores(config, createLogger('node:blob-client:client'));
289
+ const blobClient = await createBlobClientWithFileStores(config, log.createChild('blob-client'));
259
290
 
260
291
  // attempt snapshot sync if possible
261
292
  await trySnapshotSync(config, log);
@@ -279,14 +310,28 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
279
310
  config.realProofs || config.debugForceTxProofVerification
280
311
  ? await BBCircuitVerifier.new(config)
281
312
  : new TestCircuitVerifier(config.proverTestVerificationDelayMs);
313
+
314
+ let debugLogStore: DebugLogStore;
282
315
  if (!config.realProofs) {
283
316
  log.warn(`Aztec node is accepting fake proofs`);
317
+
318
+ debugLogStore = new InMemoryDebugLogStore();
319
+ log.info(
320
+ 'Aztec node started in test mode (realProofs set to false) hence debug logs from public functions will be collected and served',
321
+ );
322
+ } else {
323
+ debugLogStore = new NullDebugLogStore();
284
324
  }
325
+
285
326
  const proofVerifier = new QueuedIVCVerifier(config, circuitVerifier);
286
327
 
328
+ const proverOnly = config.enableProverNode && config.disableValidator;
329
+ if (proverOnly) {
330
+ log.info('Starting in prover-only mode: skipping validator, sequencer, sentinel, and slasher subsystems');
331
+ }
332
+
287
333
  // create the tx pool and the p2p client, which will need the l2 block source
288
334
  const p2pClient = await createP2PClient(
289
- P2PClientType.Full,
290
335
  config,
291
336
  archiver,
292
337
  proofVerifier,
@@ -298,49 +343,59 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
298
343
  deps.p2pClientDeps,
299
344
  );
300
345
 
301
- // We should really not be modifying the config object
302
- config.txPublicSetupAllowList = config.txPublicSetupAllowList ?? (await getDefaultAllowedSetupFunctions());
346
+ // We'll accumulate sentinel watchers here
347
+ const watchers: Watcher[] = [];
303
348
 
304
- // Create FullNodeCheckpointsBuilder for validator and non-validator block proposal handling
349
+ // Create FullNodeCheckpointsBuilder for block proposal handling and tx validation.
350
+ // Override maxTxsPerCheckpoint with the validator-specific limit if set.
305
351
  const validatorCheckpointsBuilder = new FullNodeCheckpointsBuilder(
306
- { ...config, l1GenesisTime, slotDuration: Number(slotDuration) },
352
+ {
353
+ ...config,
354
+ l1GenesisTime,
355
+ slotDuration: Number(slotDuration),
356
+ rollupManaLimit,
357
+ maxTxsPerCheckpoint: config.validateMaxTxsPerCheckpoint,
358
+ },
307
359
  worldStateSynchronizer,
308
360
  archiver,
309
361
  dateProvider,
310
362
  telemetry,
311
363
  );
312
364
 
313
- // We'll accumulate sentinel watchers here
314
- const watchers: Watcher[] = [];
365
+ let validatorClient: ValidatorClient | undefined;
315
366
 
316
- // Create validator client if required
317
- const validatorClient = await createValidatorClient(config, {
318
- checkpointsBuilder: validatorCheckpointsBuilder,
319
- worldState: worldStateSynchronizer,
320
- p2pClient,
321
- telemetry,
322
- dateProvider,
323
- epochCache,
324
- blockSource: archiver,
325
- l1ToL2MessageSource: archiver,
326
- keyStoreManager,
327
- blobClient,
328
- });
367
+ if (!proverOnly) {
368
+ // Create validator client if required
369
+ validatorClient = await createValidatorClient(config, {
370
+ checkpointsBuilder: validatorCheckpointsBuilder,
371
+ worldState: worldStateSynchronizer,
372
+ p2pClient,
373
+ telemetry,
374
+ dateProvider,
375
+ epochCache,
376
+ blockSource: archiver,
377
+ l1ToL2MessageSource: archiver,
378
+ keyStoreManager,
379
+ blobClient,
380
+ });
329
381
 
330
- // If we have a validator client, register it as a source of offenses for the slasher,
331
- // and have it register callbacks on the p2p client *before* we start it, otherwise messages
332
- // like attestations or auths will fail.
333
- if (validatorClient) {
334
- watchers.push(validatorClient);
335
- if (!options.dontStartSequencer) {
336
- await validatorClient.registerHandlers();
382
+ // If we have a validator client, register it as a source of offenses for the slasher,
383
+ // and have it register callbacks on the p2p client *before* we start it, otherwise messages
384
+ // like attestations or auths will fail.
385
+ if (validatorClient) {
386
+ watchers.push(validatorClient);
387
+ if (!options.dontStartSequencer) {
388
+ await validatorClient.registerHandlers();
389
+ }
337
390
  }
338
391
  }
339
392
 
340
- // If there's no validator client but alwaysReexecuteBlockProposals is enabled,
341
- // create a BlockProposalHandler to reexecute block proposals for monitoring
342
- if (!validatorClient && config.alwaysReexecuteBlockProposals) {
343
- log.info('Setting up block proposal reexecution for monitoring');
393
+ // If there's no validator client, create a BlockProposalHandler to handle block proposals
394
+ // for monitoring or reexecution. Reexecution (default) allows us to follow the pending chain,
395
+ // while non-reexecution is used for validating the proposals and collecting their txs.
396
+ if (!validatorClient) {
397
+ const reexecute = !!config.alwaysReexecuteBlockProposals;
398
+ log.info(`Setting up block proposal handler` + (reexecute ? ' with reexecution of proposals' : ''));
344
399
  createBlockProposalHandler(config, {
345
400
  checkpointsBuilder: validatorCheckpointsBuilder,
346
401
  worldState: worldStateSynchronizer,
@@ -350,7 +405,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
350
405
  p2pClient,
351
406
  dateProvider,
352
407
  telemetry,
353
- }).registerForReexecution(p2pClient);
408
+ }).register(p2pClient, reexecute);
354
409
  }
355
410
 
356
411
  // Start world state and wait for it to sync to the archiver.
@@ -359,29 +414,33 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
359
414
  // Start p2p. Note that it depends on world state to be running.
360
415
  await p2pClient.start();
361
416
 
362
- const validatorsSentinel = await createSentinel(epochCache, archiver, p2pClient, config);
363
- if (validatorsSentinel && config.slashInactivityPenalty > 0n) {
364
- watchers.push(validatorsSentinel);
365
- }
366
-
417
+ let validatorsSentinel: Awaited<ReturnType<typeof createSentinel>> | undefined;
367
418
  let epochPruneWatcher: EpochPruneWatcher | undefined;
368
- if (config.slashPrunePenalty > 0n || config.slashDataWithholdingPenalty > 0n) {
369
- epochPruneWatcher = new EpochPruneWatcher(
370
- archiver,
371
- archiver,
372
- epochCache,
373
- p2pClient.getTxProvider(),
374
- validatorCheckpointsBuilder,
375
- config,
376
- );
377
- watchers.push(epochPruneWatcher);
378
- }
379
-
380
- // We assume we want to slash for invalid attestations unless all max penalties are set to 0
381
419
  let attestationsBlockWatcher: AttestationsBlockWatcher | undefined;
382
- if (config.slashProposeInvalidAttestationsPenalty > 0n || config.slashAttestDescendantOfInvalidPenalty > 0n) {
383
- attestationsBlockWatcher = new AttestationsBlockWatcher(archiver, epochCache, config);
384
- watchers.push(attestationsBlockWatcher);
420
+
421
+ if (!proverOnly) {
422
+ validatorsSentinel = await createSentinel(epochCache, archiver, p2pClient, config);
423
+ if (validatorsSentinel && config.slashInactivityPenalty > 0n) {
424
+ watchers.push(validatorsSentinel);
425
+ }
426
+
427
+ if (config.slashPrunePenalty > 0n || config.slashDataWithholdingPenalty > 0n) {
428
+ epochPruneWatcher = new EpochPruneWatcher(
429
+ archiver,
430
+ archiver,
431
+ epochCache,
432
+ p2pClient.getTxProvider(),
433
+ validatorCheckpointsBuilder,
434
+ config,
435
+ );
436
+ watchers.push(epochPruneWatcher);
437
+ }
438
+
439
+ // We assume we want to slash for invalid attestations unless all max penalties are set to 0
440
+ if (config.slashProposeInvalidAttestationsPenalty > 0n || config.slashAttestDescendantOfInvalidPenalty > 0n) {
441
+ attestationsBlockWatcher = new AttestationsBlockWatcher(archiver, epochCache, config);
442
+ watchers.push(attestationsBlockWatcher);
443
+ }
385
444
  }
386
445
 
387
446
  // Start p2p-related services once the archiver has completed sync
@@ -418,28 +477,29 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
418
477
  );
419
478
  await slasherClient.start();
420
479
 
421
- const l1TxUtils = config.publisherForwarderAddress
422
- ? await createForwarderL1TxUtilsFromEthSigner(
480
+ const l1TxUtils = config.sequencerPublisherForwarderAddress
481
+ ? await createForwarderL1TxUtilsFromSigners(
423
482
  publicClient,
424
483
  keyStoreManager!.createAllValidatorPublisherSigners(),
425
- config.publisherForwarderAddress,
484
+ config.sequencerPublisherForwarderAddress,
426
485
  { ...config, scope: 'sequencer' },
427
- { telemetry, logger: log.createChild('l1-tx-utils'), dateProvider },
486
+ { telemetry, logger: log.createChild('l1-tx-utils'), dateProvider, kzg: Blob.getViemKzgInstance() },
428
487
  )
429
- : await createL1TxUtilsWithBlobsFromEthSigner(
488
+ : await createL1TxUtilsFromSigners(
430
489
  publicClient,
431
490
  keyStoreManager!.createAllValidatorPublisherSigners(),
432
491
  { ...config, scope: 'sequencer' },
433
- { telemetry, logger: log.createChild('l1-tx-utils'), dateProvider },
492
+ { telemetry, logger: log.createChild('l1-tx-utils'), dateProvider, kzg: Blob.getViemKzgInstance() },
434
493
  );
435
494
 
436
495
  // Create and start the sequencer client
437
496
  const checkpointsBuilder = new CheckpointsBuilder(
438
- { ...config, l1GenesisTime, slotDuration: Number(slotDuration) },
497
+ { ...config, l1GenesisTime, slotDuration: Number(slotDuration), rollupManaLimit },
439
498
  worldStateSynchronizer,
440
499
  archiver,
441
500
  dateProvider,
442
501
  telemetry,
502
+ debugLogStore,
443
503
  );
444
504
 
445
505
  sequencer = await SequencerClient.new(config, {
@@ -467,6 +527,29 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
467
527
  log.warn(`Sequencer created but not started`);
468
528
  }
469
529
 
530
+ // Create prover node subsystem if enabled
531
+ let proverNode: ProverNode | undefined;
532
+ if (config.enableProverNode) {
533
+ proverNode = await createProverNode(config, {
534
+ ...deps.proverNodeDeps,
535
+ telemetry,
536
+ dateProvider,
537
+ archiver,
538
+ worldStateSynchronizer,
539
+ p2pClient,
540
+ epochCache,
541
+ blobClient,
542
+ keyStoreManager,
543
+ });
544
+
545
+ if (!options.dontStartProverNode) {
546
+ await proverNode.start();
547
+ log.info(`Prover node subsystem started`);
548
+ } else {
549
+ log.info(`Prover node subsystem created but not started`);
550
+ }
551
+ }
552
+
470
553
  const globalVariableBuilder = new GlobalVariableBuilder({
471
554
  ...config,
472
555
  rollupVersion: BigInt(config.rollupVersion),
@@ -474,7 +557,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
474
557
  slotDuration: Number(slotDuration),
475
558
  });
476
559
 
477
- return new AztecNodeService(
560
+ const node = new AztecNodeService(
478
561
  config,
479
562
  p2pClient,
480
563
  archiver,
@@ -483,6 +566,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
483
566
  archiver,
484
567
  worldStateSynchronizer,
485
568
  sequencer,
569
+ proverNode,
486
570
  slasherClient,
487
571
  validatorsSentinel,
488
572
  epochPruneWatcher,
@@ -495,7 +579,12 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
495
579
  telemetry,
496
580
  log,
497
581
  blobClient,
582
+ validatorClient,
583
+ keyStoreManager,
584
+ debugLogStore,
498
585
  );
586
+
587
+ return node;
499
588
  }
500
589
 
501
590
  /**
@@ -506,6 +595,11 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
506
595
  return this.sequencer;
507
596
  }
508
597
 
598
+ /** Returns the prover node subsystem, if enabled. */
599
+ public getProverNode(): ProverNode | undefined {
600
+ return this.proverNode;
601
+ }
602
+
509
603
  public getBlockSource(): L2BlockSource {
510
604
  return this.blockSource;
511
605
  }
@@ -531,7 +625,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
531
625
  }
532
626
 
533
627
  public async getAllowedPublicSetup(): Promise<AllowedElement[]> {
534
- return this.config.txPublicSetupAllowList ?? (await getDefaultAllowedSetupFunctions());
628
+ return [...(await getDefaultAllowedSetupFunctions()), ...(this.config.txPublicSetupAllowListExtend ?? [])];
535
629
  }
536
630
 
537
631
  /**
@@ -559,6 +653,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
559
653
  enr,
560
654
  l1ContractAddresses: contractAddresses,
561
655
  protocolContractAddresses: protocolContractAddresses,
656
+ realProofs: !!this.config.realProofs,
562
657
  };
563
658
 
564
659
  return nodeInfo;
@@ -570,8 +665,8 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
570
665
  * @returns The requested block.
571
666
  */
572
667
  public async getBlock(block: BlockParameter): Promise<L2Block | undefined> {
573
- if (BlockHash.isL2BlockHash(block)) {
574
- return this.getBlockByHash(Fr.fromBuffer(block.toBuffer()));
668
+ if (BlockHash.isBlockHash(block)) {
669
+ return this.getBlockByHash(block);
575
670
  }
576
671
  const blockNumber = block === 'latest' ? await this.getBlockNumber() : (block as BlockNumber);
577
672
  if (blockNumber === BlockNumber.ZERO) {
@@ -585,9 +680,9 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
585
680
  * @param blockHash - The block hash being requested.
586
681
  * @returns The requested block.
587
682
  */
588
- public async getBlockByHash(blockHash: Fr): Promise<L2Block | undefined> {
683
+ public async getBlockByHash(blockHash: BlockHash): Promise<L2Block | undefined> {
589
684
  const initialBlockHash = await this.#getInitialHeaderHash();
590
- if (blockHash.equals(Fr.fromBuffer(initialBlockHash.toBuffer()))) {
685
+ if (blockHash.equals(initialBlockHash)) {
591
686
  return this.buildInitialBlock();
592
687
  }
593
688
  return await this.blockSource.getL2BlockByHash(blockHash);
@@ -657,6 +752,10 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
657
752
  return await this.blockSource.getCheckpointedL2BlockNumber();
658
753
  }
659
754
 
755
+ public getCheckpointNumber(): Promise<CheckpointNumber> {
756
+ return this.blockSource.getCheckpointNumber();
757
+ }
758
+
660
759
  /**
661
760
  * Method to fetch the version of the package.
662
761
  * @returns The node package version
@@ -697,8 +796,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
697
796
  if (referenceBlock) {
698
797
  const initialBlockHash = await this.#getInitialHeaderHash();
699
798
  if (!referenceBlock.equals(initialBlockHash)) {
700
- const blockHashFr = Fr.fromBuffer(referenceBlock.toBuffer());
701
- const header = await this.blockSource.getBlockHeaderByHash(blockHashFr);
799
+ const header = await this.blockSource.getBlockHeaderByHash(referenceBlock);
702
800
  if (!header) {
703
801
  throw new Error(
704
802
  `Block ${referenceBlock.toString()} not found in the node. This might indicate a reorg has occurred.`,
@@ -718,8 +816,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
718
816
  if (referenceBlock) {
719
817
  const initialBlockHash = await this.#getInitialHeaderHash();
720
818
  if (!referenceBlock.equals(initialBlockHash)) {
721
- const blockHashFr = Fr.fromBuffer(referenceBlock.toBuffer());
722
- const header = await this.blockSource.getBlockHeaderByHash(blockHashFr);
819
+ const header = await this.blockSource.getBlockHeaderByHash(referenceBlock);
723
820
  if (!header) {
724
821
  throw new Error(
725
822
  `Block ${referenceBlock.toString()} not found in the node. This might indicate a reorg has occurred.`,
@@ -769,8 +866,9 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
769
866
  }
770
867
 
771
868
  await this.p2pClient!.sendTx(tx);
772
- this.metrics.receivedTx(timer.ms(), true);
773
- this.log.info(`Received tx ${txHash}`, { txHash });
869
+ const duration = timer.ms();
870
+ this.metrics.receivedTx(duration, true);
871
+ this.log.info(`Received tx ${txHash} in ${duration}ms`, { txHash });
774
872
  }
775
873
 
776
874
  public async getTxReceipt(txHash: TxHash): Promise<TxReceipt> {
@@ -782,18 +880,22 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
782
880
  // Then get the actual tx from the archiver, which tracks every tx in a mined block.
783
881
  const settledTxReceipt = await this.blockSource.getSettledTxReceipt(txHash);
784
882
 
883
+ let receipt: TxReceipt;
785
884
  if (settledTxReceipt) {
786
- // If the archiver has the receipt then return it.
787
- return settledTxReceipt;
885
+ receipt = settledTxReceipt;
788
886
  } else if (isKnownToPool) {
789
887
  // If the tx is in the pool but not in the archiver, it's pending.
790
888
  // This handles race conditions between archiver and p2p, where the archiver
791
889
  // has pruned the block in which a tx was mined, but p2p has not caught up yet.
792
- return new TxReceipt(txHash, TxStatus.PENDING, undefined, undefined);
890
+ receipt = new TxReceipt(txHash, TxStatus.PENDING, undefined, undefined);
793
891
  } else {
794
892
  // Otherwise, if we don't know the tx, we consider it dropped.
795
- return new TxReceipt(txHash, TxStatus.DROPPED, undefined, 'Tx dropped by P2P node');
893
+ receipt = new TxReceipt(txHash, TxStatus.DROPPED, undefined, 'Tx dropped by P2P node');
796
894
  }
895
+
896
+ this.debugLogStore.decorateReceiptWithLogs(txHash.toString(), receipt);
897
+
898
+ return receipt;
797
899
  }
798
900
 
799
901
  public getTxEffect(txHash: TxHash): Promise<IndexedTxEffect | undefined> {
@@ -810,6 +912,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
810
912
  await tryStop(this.slasherClient);
811
913
  await tryStop(this.proofVerifier);
812
914
  await tryStop(this.sequencer);
915
+ await tryStop(this.proverNode);
813
916
  await tryStop(this.p2pClient);
814
917
  await tryStop(this.worldStateSynchronizer);
815
918
  await tryStop(this.blockSource);
@@ -859,11 +962,11 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
859
962
  }
860
963
 
861
964
  public async findLeavesIndexes(
862
- block: BlockParameter,
965
+ referenceBlock: BlockParameter,
863
966
  treeId: MerkleTreeId,
864
967
  leafValues: Fr[],
865
968
  ): Promise<(DataInBlock<bigint> | undefined)[]> {
866
- const committedDb = await this.#getWorldState(block);
969
+ const committedDb = await this.#getWorldState(referenceBlock);
867
970
  const maybeIndices = await committedDb.findLeafIndices(
868
971
  treeId,
869
972
  leafValues.map(x => x.toBuffer()),
@@ -915,44 +1018,28 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
915
1018
  }
916
1019
  return {
917
1020
  l2BlockNumber: BlockNumber(Number(blockNumber)),
918
- l2BlockHash: BlockHash.fromField(blockHash),
1021
+ l2BlockHash: new BlockHash(blockHash),
919
1022
  data: index,
920
1023
  };
921
1024
  });
922
1025
  }
923
1026
 
924
- public async getNullifierSiblingPath(
925
- block: BlockParameter,
926
- leafIndex: bigint,
927
- ): Promise<SiblingPath<typeof NULLIFIER_TREE_HEIGHT>> {
928
- const committedDb = await this.#getWorldState(block);
929
- return committedDb.getSiblingPath(MerkleTreeId.NULLIFIER_TREE, leafIndex);
930
- }
931
-
932
- public async getNoteHashSiblingPath(
933
- block: BlockParameter,
934
- leafIndex: bigint,
935
- ): Promise<SiblingPath<typeof NOTE_HASH_TREE_HEIGHT>> {
936
- const committedDb = await this.#getWorldState(block);
937
- return committedDb.getSiblingPath(MerkleTreeId.NOTE_HASH_TREE, leafIndex);
938
- }
939
-
940
- public async getArchiveMembershipWitness(
941
- block: BlockParameter,
942
- archive: Fr,
1027
+ public async getBlockHashMembershipWitness(
1028
+ referenceBlock: BlockParameter,
1029
+ blockHash: BlockHash,
943
1030
  ): Promise<MembershipWitness<typeof ARCHIVE_HEIGHT> | undefined> {
944
- const committedDb = await this.#getWorldState(block);
945
- const [pathAndIndex] = await committedDb.findSiblingPaths<MerkleTreeId.ARCHIVE>(MerkleTreeId.ARCHIVE, [archive]);
1031
+ const committedDb = await this.#getWorldState(referenceBlock);
1032
+ const [pathAndIndex] = await committedDb.findSiblingPaths<MerkleTreeId.ARCHIVE>(MerkleTreeId.ARCHIVE, [blockHash]);
946
1033
  return pathAndIndex === undefined
947
1034
  ? undefined
948
1035
  : MembershipWitness.fromSiblingPath(pathAndIndex.index, pathAndIndex.path);
949
1036
  }
950
1037
 
951
1038
  public async getNoteHashMembershipWitness(
952
- block: BlockParameter,
1039
+ referenceBlock: BlockParameter,
953
1040
  noteHash: Fr,
954
1041
  ): Promise<MembershipWitness<typeof NOTE_HASH_TREE_HEIGHT> | undefined> {
955
- const committedDb = await this.#getWorldState(block);
1042
+ const committedDb = await this.#getWorldState(referenceBlock);
956
1043
  const [pathAndIndex] = await committedDb.findSiblingPaths<MerkleTreeId.NOTE_HASH_TREE>(
957
1044
  MerkleTreeId.NOTE_HASH_TREE,
958
1045
  [noteHash],
@@ -963,10 +1050,10 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
963
1050
  }
964
1051
 
965
1052
  public async getL1ToL2MessageMembershipWitness(
966
- block: BlockParameter,
1053
+ referenceBlock: BlockParameter,
967
1054
  l1ToL2Message: Fr,
968
1055
  ): Promise<[bigint, SiblingPath<typeof L1_TO_L2_MSG_TREE_HEIGHT>] | undefined> {
969
- const db = await this.#getWorldState(block);
1056
+ const db = await this.#getWorldState(referenceBlock);
970
1057
  const [witness] = await db.findSiblingPaths(MerkleTreeId.L1_TO_L2_MESSAGE_TREE, [l1ToL2Message]);
971
1058
  if (!witness) {
972
1059
  return undefined;
@@ -976,11 +1063,9 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
976
1063
  return [witness.index, witness.path];
977
1064
  }
978
1065
 
979
- public async getL1ToL2MessageBlock(l1ToL2Message: Fr): Promise<BlockNumber | undefined> {
1066
+ public async getL1ToL2MessageCheckpoint(l1ToL2Message: Fr): Promise<CheckpointNumber | undefined> {
980
1067
  const messageIndex = await this.l1ToL2MessageSource.getL1ToL2MessageIndex(l1ToL2Message);
981
- return messageIndex
982
- ? BlockNumber.fromCheckpointNumber(InboxLeaf.checkpointNumberFromIndex(messageIndex))
983
- : undefined;
1068
+ return messageIndex ? InboxLeaf.checkpointNumberFromIndex(messageIndex) : undefined;
984
1069
  }
985
1070
 
986
1071
  /**
@@ -1019,27 +1104,11 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
1019
1104
  );
1020
1105
  }
1021
1106
 
1022
- public async getArchiveSiblingPath(
1023
- block: BlockParameter,
1024
- leafIndex: bigint,
1025
- ): Promise<SiblingPath<typeof ARCHIVE_HEIGHT>> {
1026
- const committedDb = await this.#getWorldState(block);
1027
- return committedDb.getSiblingPath(MerkleTreeId.ARCHIVE, leafIndex);
1028
- }
1029
-
1030
- public async getPublicDataSiblingPath(
1031
- block: BlockParameter,
1032
- leafIndex: bigint,
1033
- ): Promise<SiblingPath<typeof PUBLIC_DATA_TREE_HEIGHT>> {
1034
- const committedDb = await this.#getWorldState(block);
1035
- return committedDb.getSiblingPath(MerkleTreeId.PUBLIC_DATA_TREE, leafIndex);
1036
- }
1037
-
1038
1107
  public async getNullifierMembershipWitness(
1039
- block: BlockParameter,
1108
+ referenceBlock: BlockParameter,
1040
1109
  nullifier: Fr,
1041
1110
  ): Promise<NullifierMembershipWitness | undefined> {
1042
- const db = await this.#getWorldState(block);
1111
+ const db = await this.#getWorldState(referenceBlock);
1043
1112
  const [witness] = await db.findSiblingPaths(MerkleTreeId.NULLIFIER_TREE, [nullifier.toBuffer()]);
1044
1113
  if (!witness) {
1045
1114
  return undefined;
@@ -1056,7 +1125,8 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
1056
1125
 
1057
1126
  /**
1058
1127
  * Returns a low nullifier membership witness for a given nullifier at a given block.
1059
- * @param block - The block parameter (block number, block hash, or 'latest') at which to get the data.
1128
+ * @param referenceBlock - The block parameter (block number, block hash, or 'latest') at which to get the data
1129
+ * (which contains the root of the nullifier tree in which we are searching for the nullifier).
1060
1130
  * @param nullifier - Nullifier we try to find the low nullifier witness for.
1061
1131
  * @returns The low nullifier membership witness (if found).
1062
1132
  * @remarks Low nullifier witness can be used to perform a nullifier non-inclusion proof by leveraging the "linked
@@ -1069,10 +1139,10 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
1069
1139
  * TODO: This is a confusing behavior and we should eventually address that.
1070
1140
  */
1071
1141
  public async getLowNullifierMembershipWitness(
1072
- block: BlockParameter,
1142
+ referenceBlock: BlockParameter,
1073
1143
  nullifier: Fr,
1074
1144
  ): Promise<NullifierMembershipWitness | undefined> {
1075
- const committedDb = await this.#getWorldState(block);
1145
+ const committedDb = await this.#getWorldState(referenceBlock);
1076
1146
  const findResult = await committedDb.getPreviousValueIndex(MerkleTreeId.NULLIFIER_TREE, nullifier.toBigInt());
1077
1147
  if (!findResult) {
1078
1148
  return undefined;
@@ -1087,8 +1157,8 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
1087
1157
  return new NullifierMembershipWitness(BigInt(index), preimageData as NullifierLeafPreimage, siblingPath);
1088
1158
  }
1089
1159
 
1090
- async getPublicDataWitness(block: BlockParameter, leafSlot: Fr): Promise<PublicDataWitness | undefined> {
1091
- const committedDb = await this.#getWorldState(block);
1160
+ async getPublicDataWitness(referenceBlock: BlockParameter, leafSlot: Fr): Promise<PublicDataWitness | undefined> {
1161
+ const committedDb = await this.#getWorldState(referenceBlock);
1092
1162
  const lowLeafResult = await committedDb.getPreviousValueIndex(MerkleTreeId.PUBLIC_DATA_TREE, leafSlot.toBigInt());
1093
1163
  if (!lowLeafResult) {
1094
1164
  return undefined;
@@ -1102,8 +1172,8 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
1102
1172
  }
1103
1173
  }
1104
1174
 
1105
- public async getPublicStorageAt(block: BlockParameter, contract: AztecAddress, slot: Fr): Promise<Fr> {
1106
- const committedDb = await this.#getWorldState(block);
1175
+ public async getPublicStorageAt(referenceBlock: BlockParameter, contract: AztecAddress, slot: Fr): Promise<Fr> {
1176
+ const committedDb = await this.#getWorldState(referenceBlock);
1107
1177
  const leafSlot = await computePublicDataTreeLeafSlot(contract, slot);
1108
1178
 
1109
1179
  const lowLeafResult = await committedDb.getPreviousValueIndex(MerkleTreeId.PUBLIC_DATA_TREE, leafSlot.toBigInt());
@@ -1118,14 +1188,13 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
1118
1188
  }
1119
1189
 
1120
1190
  public async getBlockHeader(block: BlockParameter = 'latest'): Promise<BlockHeader | undefined> {
1121
- if (BlockHash.isL2BlockHash(block)) {
1191
+ if (BlockHash.isBlockHash(block)) {
1122
1192
  const initialBlockHash = await this.#getInitialHeaderHash();
1123
1193
  if (block.equals(initialBlockHash)) {
1124
1194
  // Block source doesn't handle initial header so we need to handle the case separately.
1125
1195
  return this.worldStateSynchronizer.getCommitted().getInitialHeader();
1126
1196
  }
1127
- const blockHashFr = Fr.fromBuffer(block.toBuffer());
1128
- return this.blockSource.getBlockHeaderByHash(blockHashFr);
1197
+ return this.blockSource.getBlockHeaderByHash(block);
1129
1198
  } else {
1130
1199
  // Block source doesn't handle initial header so we need to handle the case separately.
1131
1200
  const blockNumber = block === 'latest' ? await this.getBlockNumber() : (block as BlockNumber);
@@ -1145,6 +1214,14 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
1145
1214
  return await this.blockSource.getBlockHeaderByArchive(archive);
1146
1215
  }
1147
1216
 
1217
+ public getBlockData(number: BlockNumber): Promise<BlockData | undefined> {
1218
+ return this.blockSource.getBlockData(number);
1219
+ }
1220
+
1221
+ public getBlockDataByArchive(archive: Fr): Promise<BlockData | undefined> {
1222
+ return this.blockSource.getBlockDataByArchive(archive);
1223
+ }
1224
+
1148
1225
  /**
1149
1226
  * Simulates the public part of a transaction with the current state.
1150
1227
  * @param tx - The transaction to simulate.
@@ -1168,7 +1245,8 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
1168
1245
  }
1169
1246
 
1170
1247
  const txHash = tx.getTxHash();
1171
- const blockNumber = BlockNumber((await this.blockSource.getBlockNumber()) + 1);
1248
+ const latestBlockNumber = await this.blockSource.getBlockNumber();
1249
+ const blockNumber = BlockNumber.add(latestBlockNumber, 1);
1172
1250
 
1173
1251
  // If sequencer is not initialized, we just set these values to zero for simulation.
1174
1252
  const coinbase = EthAddress.ZERO;
@@ -1192,6 +1270,8 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
1192
1270
  blockNumber,
1193
1271
  });
1194
1272
 
1273
+ // Ensure world-state has caught up with the latest block we loaded from the archiver
1274
+ await this.worldStateSynchronizer.syncImmediate(latestBlockNumber);
1195
1275
  const merkleTreeFork = await this.worldStateSynchronizer.fork();
1196
1276
  try {
1197
1277
  const config = PublicSimulatorConfig.from({
@@ -1207,7 +1287,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
1207
1287
  const processor = publicProcessorFactory.create(merkleTreeFork, newGlobalVariables, config);
1208
1288
 
1209
1289
  // REFACTOR: Consider merging ProcessReturnValues into ProcessedTx
1210
- const [processedTxs, failedTxs, _usedTxs, returns] = await processor.process([tx]);
1290
+ const [processedTxs, failedTxs, _usedTxs, returns, debugLogs] = await processor.process([tx]);
1211
1291
  // REFACTOR: Consider returning the error rather than throwing
1212
1292
  if (failedTxs.length) {
1213
1293
  this.log.warn(`Simulated tx ${txHash} fails: ${failedTxs[0].error}`, { txHash });
@@ -1221,6 +1301,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
1221
1301
  processedTx.txEffect,
1222
1302
  returns,
1223
1303
  processedTx.gasUsed,
1304
+ debugLogs,
1224
1305
  );
1225
1306
  } finally {
1226
1307
  await merkleTreeFork.close();
@@ -1234,10 +1315,10 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
1234
1315
  const db = this.worldStateSynchronizer.getCommitted();
1235
1316
  const verifier = isSimulation ? undefined : this.proofVerifier;
1236
1317
 
1237
- // We accept transactions if they are not expired by the next slot (checked based on the IncludeByTimestamp field)
1318
+ // We accept transactions if they are not expired by the next slot (checked based on the ExpirationTimestamp field)
1238
1319
  const { ts: nextSlotTimestamp } = this.epochCache.getEpochAndSlotInNextL1Slot();
1239
1320
  const blockNumber = BlockNumber((await this.blockSource.getBlockNumber()) + 1);
1240
- const validator = createValidatorForAcceptingTxs(
1321
+ const validator = createTxValidatorForAcceptingTxsOverRPC(
1241
1322
  db,
1242
1323
  this.contractDataSource,
1243
1324
  verifier,
@@ -1246,7 +1327,10 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
1246
1327
  blockNumber,
1247
1328
  l1ChainId: this.l1ChainId,
1248
1329
  rollupVersion: this.version,
1249
- setupAllowList: this.config.txPublicSetupAllowList ?? (await getDefaultAllowedSetupFunctions()),
1330
+ setupAllowList: [
1331
+ ...(await getDefaultAllowedSetupFunctions()),
1332
+ ...(this.config.txPublicSetupAllowListExtend ?? []),
1333
+ ],
1250
1334
  gasFees: await this.getCurrentMinFees(),
1251
1335
  skipFeeEnforcement,
1252
1336
  txsPermitted: !this.config.disableTransactions,
@@ -1416,6 +1500,94 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
1416
1500
  }
1417
1501
  }
1418
1502
 
1503
+ public async reloadKeystore(): Promise<void> {
1504
+ if (!this.config.keyStoreDirectory?.length) {
1505
+ throw new BadRequestError(
1506
+ 'Cannot reload keystore: node is not using a file-based keystore. ' +
1507
+ 'Set KEY_STORE_DIRECTORY to use file-based keystores.',
1508
+ );
1509
+ }
1510
+ if (!this.validatorClient) {
1511
+ throw new BadRequestError('Cannot reload keystore: validator is not enabled.');
1512
+ }
1513
+
1514
+ this.log.info('Reloading keystore from disk');
1515
+
1516
+ // Re-read and validate keystore files
1517
+ const keyStores = loadKeystores(this.config.keyStoreDirectory);
1518
+ const newManager = new KeystoreManager(mergeKeystores(keyStores));
1519
+ await newManager.validateSigners();
1520
+ ValidatorClient.validateKeyStoreConfiguration(newManager, this.log);
1521
+
1522
+ // Validate that every validator's publisher keys overlap with the L1 signers
1523
+ // that were initialized at startup. Publishers cannot be hot-reloaded, so a
1524
+ // validator with a publisher key that doesn't match any existing L1 signer
1525
+ // would silently fail on every proposer slot.
1526
+ if (this.keyStoreManager && this.sequencer) {
1527
+ const oldAdapter = NodeKeystoreAdapter.fromKeyStoreManager(this.keyStoreManager);
1528
+ const availablePublishers = new Set(
1529
+ oldAdapter
1530
+ .getAttesterAddresses()
1531
+ .flatMap(a => oldAdapter.getPublisherAddresses(a).map(p => p.toString().toLowerCase())),
1532
+ );
1533
+
1534
+ const newAdapter = NodeKeystoreAdapter.fromKeyStoreManager(newManager);
1535
+ for (const attester of newAdapter.getAttesterAddresses()) {
1536
+ const pubs = newAdapter.getPublisherAddresses(attester);
1537
+ if (pubs.length > 0 && !pubs.some(p => availablePublishers.has(p.toString().toLowerCase()))) {
1538
+ throw new BadRequestError(
1539
+ `Cannot reload keystore: validator ${attester} has publisher keys ` +
1540
+ `[${pubs.map(p => p.toString()).join(', ')}] but none match the L1 signers initialized at startup ` +
1541
+ `[${[...availablePublishers].join(', ')}]. Publishers cannot be hot-reloaded — ` +
1542
+ `use an existing publisher key or restart the node.`,
1543
+ );
1544
+ }
1545
+ }
1546
+ }
1547
+
1548
+ // Build adapters for old and new keystores to compute diff
1549
+ const newAdapter = NodeKeystoreAdapter.fromKeyStoreManager(newManager);
1550
+ const newAddresses = newAdapter.getAttesterAddresses();
1551
+ const oldAddresses = this.keyStoreManager
1552
+ ? NodeKeystoreAdapter.fromKeyStoreManager(this.keyStoreManager).getAttesterAddresses()
1553
+ : [];
1554
+
1555
+ const oldSet = new Set(oldAddresses.map(a => a.toString()));
1556
+ const newSet = new Set(newAddresses.map(a => a.toString()));
1557
+ const added = newAddresses.filter(a => !oldSet.has(a.toString()));
1558
+ const removed = oldAddresses.filter(a => !newSet.has(a.toString()));
1559
+
1560
+ if (added.length > 0) {
1561
+ this.log.info(`Keystore reload: adding attester keys: ${added.map(a => a.toString()).join(', ')}`);
1562
+ }
1563
+ if (removed.length > 0) {
1564
+ this.log.info(`Keystore reload: removing attester keys: ${removed.map(a => a.toString()).join(', ')}`);
1565
+ }
1566
+ if (added.length === 0 && removed.length === 0) {
1567
+ this.log.info('Keystore reload: attester keys unchanged');
1568
+ }
1569
+
1570
+ // Update the validator client (coinbase, feeRecipient, attester keys)
1571
+ this.validatorClient.reloadKeystore(newManager);
1572
+
1573
+ // Update the publisher factory's keystore so newly-added validators
1574
+ // can be matched to existing publisher keys when proposing blocks.
1575
+ if (this.sequencer) {
1576
+ this.sequencer.updatePublisherNodeKeyStore(newAdapter);
1577
+ }
1578
+
1579
+ // Update slasher's "don't-slash-self" list with new validator addresses
1580
+ if (this.slasherClient && !this.config.slashSelfAllowed) {
1581
+ const slashValidatorsNever = unique(
1582
+ [...(this.config.slashValidatorsNever ?? []), ...newAddresses].map(a => a.toString()),
1583
+ ).map(EthAddress.fromString);
1584
+ this.slasherClient.updateConfig({ slashValidatorsNever });
1585
+ }
1586
+
1587
+ this.keyStoreManager = newManager;
1588
+ this.log.info('Keystore reloaded: coinbase, feeRecipient, and attester keys updated');
1589
+ }
1590
+
1419
1591
  #getInitialHeaderHash(): Promise<BlockHash> {
1420
1592
  if (!this.initialHeaderHashPromise) {
1421
1593
  this.initialHeaderHashPromise = this.worldStateSynchronizer.getCommitted().getInitialHeader().hash();
@@ -1442,15 +1614,14 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
1442
1614
  return this.worldStateSynchronizer.getCommitted();
1443
1615
  }
1444
1616
 
1445
- if (BlockHash.isL2BlockHash(block)) {
1617
+ if (BlockHash.isBlockHash(block)) {
1446
1618
  const initialBlockHash = await this.#getInitialHeaderHash();
1447
1619
  if (block.equals(initialBlockHash)) {
1448
1620
  // Block source doesn't handle initial header so we need to handle the case separately.
1449
1621
  return this.worldStateSynchronizer.getSnapshot(BlockNumber.ZERO);
1450
1622
  }
1451
1623
 
1452
- const blockHashFr = Fr.fromBuffer(block.toBuffer());
1453
- const header = await this.blockSource.getBlockHeaderByHash(blockHashFr);
1624
+ const header = await this.blockSource.getBlockHeaderByHash(block);
1454
1625
  if (!header) {
1455
1626
  throw new Error(
1456
1627
  `Block hash ${block.toString()} not found when querying world state. If the node API has been queried with anchor block hash possibly a reorg has occurred.`,