@aztec/aztec-node 0.0.1-commit.7cf39cb55 → 0.0.1-commit.808bf7f90

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.
@@ -13,9 +13,14 @@ import {
13
13
  import { type SharedNodeConfig, sharedNodeConfigMappings } from '@aztec/node-lib/config';
14
14
  import { type P2PConfig, p2pConfigMappings } from '@aztec/p2p/config';
15
15
  import { type ProverClientUserConfig, proverClientConfigMappings } from '@aztec/prover-client/config';
16
+ import {
17
+ type ProverNodeConfig,
18
+ proverNodeConfigMappings,
19
+ specificProverNodeConfigMappings,
20
+ } from '@aztec/prover-node/config';
16
21
  import {
17
22
  type SequencerClientConfig,
18
- type TxSenderConfig,
23
+ type SequencerTxSenderConfig,
19
24
  sequencerClientConfigMappings,
20
25
  } from '@aztec/sequencer-client/config';
21
26
  import { slasherConfigMappings } from '@aztec/slasher';
@@ -46,16 +51,18 @@ export type AztecNodeConfig = ArchiverConfig &
46
51
  SharedNodeConfig &
47
52
  GenesisStateConfig &
48
53
  NodeRPCConfig &
49
- SlasherConfig & {
54
+ SlasherConfig &
55
+ ProverNodeConfig & {
50
56
  /** L1 contracts addresses */
51
57
  l1Contracts: L1ContractAddresses;
52
58
  /** Whether the validator is disabled for this node */
53
59
  disableValidator: boolean;
54
60
  /** Whether to skip waiting for the archiver to be fully synced before starting other services */
55
61
  skipArchiverInitialSync: boolean;
56
-
57
62
  /** A flag to force verification of tx Chonk proofs. Only used for testnet */
58
63
  debugForceTxProofVerification: boolean;
64
+ /** Whether to enable the prover node as a subsystem. */
65
+ enableProverNode: boolean;
59
66
  };
60
67
 
61
68
  export const aztecNodeConfigMappings: ConfigMappingsType<AztecNodeConfig> = {
@@ -63,6 +70,7 @@ export const aztecNodeConfigMappings: ConfigMappingsType<AztecNodeConfig> = {
63
70
  ...keyStoreConfigMappings,
64
71
  ...archiverConfigMappings,
65
72
  ...sequencerClientConfigMappings,
73
+ ...proverNodeConfigMappings,
66
74
  ...validatorClientConfigMappings,
67
75
  ...proverClientConfigMappings,
68
76
  ...worldStateConfigMappings,
@@ -72,6 +80,7 @@ export const aztecNodeConfigMappings: ConfigMappingsType<AztecNodeConfig> = {
72
80
  ...genesisStateConfigMappings,
73
81
  ...nodeRpcConfigMappings,
74
82
  ...slasherConfigMappings,
83
+ ...specificProverNodeConfigMappings,
75
84
  l1Contracts: {
76
85
  description: 'The deployed L1 contract addresses',
77
86
  nested: l1ContractAddressesMapping,
@@ -91,6 +100,11 @@ export const aztecNodeConfigMappings: ConfigMappingsType<AztecNodeConfig> = {
91
100
  description: 'Whether to skip waiting for the archiver to be fully synced before starting other services.',
92
101
  ...booleanConfigHelper(false),
93
102
  },
103
+ enableProverNode: {
104
+ env: 'ENABLE_PROVER_NODE',
105
+ description: 'Whether to enable the prover node as a subsystem.',
106
+ ...booleanConfigHelper(false),
107
+ },
94
108
  };
95
109
 
96
110
  /**
@@ -101,7 +115,7 @@ export function getConfigEnvVars(): AztecNodeConfig {
101
115
  return getConfigFromMappings<AztecNodeConfig>(aztecNodeConfigMappings);
102
116
  }
103
117
 
104
- type ConfigRequiredToBuildKeyStore = TxSenderConfig & SequencerClientConfig & SharedNodeConfig & ValidatorClientConfig;
118
+ type ConfigRequiredToBuildKeyStore = SequencerClientConfig & SharedNodeConfig & ValidatorClientConfig;
105
119
 
106
120
  function createKeyStoreFromWeb3Signer(config: ConfigRequiredToBuildKeyStore): KeyStore | undefined {
107
121
  const validatorKeyStores: ValidatorKeyStore[] = [];
@@ -120,7 +134,7 @@ function createKeyStoreFromWeb3Signer(config: ConfigRequiredToBuildKeyStore): Ke
120
134
  feeRecipient: config.feeRecipient ?? AztecAddress.ZERO,
121
135
  coinbase: config.coinbase ?? config.validatorAddresses[0],
122
136
  remoteSigner: config.web3SignerUrl,
123
- publisher: config.publisherAddresses ?? [],
137
+ publisher: config.sequencerPublisherAddresses ?? [],
124
138
  });
125
139
 
126
140
  const keyStore: KeyStore = {
@@ -145,8 +159,10 @@ function createKeyStoreFromPrivateKeys(config: ConfigRequiredToBuildKeyStore): K
145
159
  const coinbase = config.coinbase ?? EthAddress.fromString(privateKeyToAddress(ethPrivateKeys[0]));
146
160
  const feeRecipient = config.feeRecipient ?? AztecAddress.ZERO;
147
161
 
148
- const publisherKeys = config.publisherPrivateKeys
149
- ? config.publisherPrivateKeys.map((k: { getValue: () => string }) => ethPrivateKeySchema.parse(k.getValue()))
162
+ const publisherKeys = config.sequencerPublisherPrivateKeys
163
+ ? config.sequencerPublisherPrivateKeys.map((k: { getValue: () => string }) =>
164
+ ethPrivateKeySchema.parse(k.getValue()),
165
+ )
150
166
  : [];
151
167
 
152
168
  validatorKeyStores.push({
@@ -168,7 +184,7 @@ function createKeyStoreFromPrivateKeys(config: ConfigRequiredToBuildKeyStore): K
168
184
  }
169
185
 
170
186
  export function createKeyStoreForValidator(
171
- config: TxSenderConfig & SequencerClientConfig & SharedNodeConfig,
187
+ config: SequencerTxSenderConfig & SequencerClientConfig & SharedNodeConfig,
172
188
  ): KeyStore | undefined {
173
189
  if (config.web3SignerUrl !== undefined && config.web3SignerUrl.length > 0) {
174
190
  return createKeyStoreFromWeb3Signer(config);
@@ -1,6 +1,7 @@
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 { Blob } from '@aztec/blob-lib';
4
5
  import { ARCHIVE_HEIGHT, type L1_TO_L2_MSG_TREE_HEIGHT, type NOTE_HASH_TREE_HEIGHT } from '@aztec/constants';
5
6
  import { EpochCache, type EpochCacheInterface } from '@aztec/epoch-cache';
6
7
  import { createEthereumChain } from '@aztec/ethereum/chain';
@@ -8,7 +9,7 @@ import { getPublicClient } from '@aztec/ethereum/client';
8
9
  import { RegistryContract, RollupContract } from '@aztec/ethereum/contracts';
9
10
  import type { L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
10
11
  import { BlockNumber, CheckpointNumber, EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
11
- import { compactArray, pick } from '@aztec/foundation/collection';
12
+ import { compactArray, pick, unique } from '@aztec/foundation/collection';
12
13
  import { Fr } from '@aztec/foundation/curves/bn254';
13
14
  import { EthAddress } from '@aztec/foundation/eth-address';
14
15
  import { BadRequestError } from '@aztec/foundation/json-rpc';
@@ -16,14 +17,13 @@ import { type Logger, createLogger } from '@aztec/foundation/log';
16
17
  import { count } from '@aztec/foundation/string';
17
18
  import { DateProvider, Timer } from '@aztec/foundation/timer';
18
19
  import { MembershipWitness, SiblingPath } from '@aztec/foundation/trees';
19
- import { KeystoreManager, loadKeystores, mergeKeystores } from '@aztec/node-keystore';
20
+ import { type KeyStore, KeystoreManager, loadKeystores, mergeKeystores } from '@aztec/node-keystore';
20
21
  import { trySnapshotSync, uploadSnapshot } from '@aztec/node-lib/actions';
21
- import {
22
- createForwarderL1TxUtilsFromEthSigner,
23
- createL1TxUtilsWithBlobsFromEthSigner,
24
- } from '@aztec/node-lib/factories';
22
+ import { createForwarderL1TxUtilsFromSigners, createL1TxUtilsFromSigners } from '@aztec/node-lib/factories';
25
23
  import { type P2P, type P2PClientDeps, createP2PClient, getDefaultAllowedSetupFunctions } from '@aztec/p2p';
26
24
  import { ProtocolContractAddress } from '@aztec/protocol-contracts';
25
+ import { type ProverNode, type ProverNodeDeps, createProverNode } from '@aztec/prover-node';
26
+ import { createKeyStoreForProver } from '@aztec/prover-node/config';
27
27
  import { GlobalVariableBuilder, SequencerClient, type SequencerPublisher } from '@aztec/sequencer-client';
28
28
  import { PublicProcessorFactory } from '@aztec/simulator/server';
29
29
  import {
@@ -35,7 +35,14 @@ import {
35
35
  } from '@aztec/slasher';
36
36
  import { CollectionLimitsConfig, PublicSimulatorConfig } from '@aztec/stdlib/avm';
37
37
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
38
- import { BlockHash, type BlockParameter, type DataInBlock, L2Block, type L2BlockSource } from '@aztec/stdlib/block';
38
+ import {
39
+ type BlockData,
40
+ BlockHash,
41
+ type BlockParameter,
42
+ type DataInBlock,
43
+ L2Block,
44
+ type L2BlockSource,
45
+ } from '@aztec/stdlib/block';
39
46
  import type { PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
40
47
  import type {
41
48
  ContractClassPublic,
@@ -63,7 +70,8 @@ import {
63
70
  type WorldStateSynchronizer,
64
71
  tryStop,
65
72
  } from '@aztec/stdlib/interfaces/server';
66
- import type { LogFilter, SiloedTag, Tag, TxScopedL2Log } from '@aztec/stdlib/logs';
73
+ import type { DebugLogStore, LogFilter, SiloedTag, Tag, TxScopedL2Log } from '@aztec/stdlib/logs';
74
+ import { InMemoryDebugLogStore, NullDebugLogStore } from '@aztec/stdlib/logs';
67
75
  import { InboxLeaf, type L1ToL2MessageSource } from '@aztec/stdlib/messaging';
68
76
  import { P2PClientType } from '@aztec/stdlib/p2p';
69
77
  import type { Offense, SlashPayloadRound } from '@aztec/stdlib/slashing';
@@ -129,6 +137,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
129
137
  protected readonly l1ToL2MessageSource: L1ToL2MessageSource,
130
138
  protected readonly worldStateSynchronizer: WorldStateSynchronizer,
131
139
  protected readonly sequencer: SequencerClient | undefined,
140
+ protected readonly proverNode: ProverNode | undefined,
132
141
  protected readonly slasherClient: SlasherClientInterface | undefined,
133
142
  protected readonly validatorsSentinel: Sentinel | undefined,
134
143
  protected readonly epochPruneWatcher: EpochPruneWatcher | undefined,
@@ -141,12 +150,22 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
141
150
  private telemetry: TelemetryClient = getTelemetryClient(),
142
151
  private log = createLogger('node'),
143
152
  private blobClient?: BlobClientInterface,
153
+ private validatorClient?: ValidatorClient,
154
+ private keyStoreManager?: KeystoreManager,
155
+ private debugLogStore: DebugLogStore = new NullDebugLogStore(),
144
156
  ) {
145
157
  this.metrics = new NodeMetrics(telemetry, 'AztecNodeService');
146
158
  this.tracer = telemetry.getTracer('AztecNodeService');
147
159
 
148
160
  this.log.info(`Aztec Node version: ${this.packageVersion}`);
149
161
  this.log.info(`Aztec Node started on chain 0x${l1ChainId.toString(16)}`, config.l1Contracts);
162
+
163
+ // A defensive check that protects us against introducing a bug in the complex `createAndSync` function. We must
164
+ // never have debugLogStore enabled when not in test mode because then we would be accumulating debug logs in
165
+ // memory which could be a DoS vector on the sequencer (since no fees are paid for debug logs).
166
+ if (debugLogStore.isEnabled && config.realProofs) {
167
+ throw new Error('debugLogStore should never be enabled when realProofs are set');
168
+ }
150
169
  }
151
170
 
152
171
  public async getWorldStateSyncStatus(): Promise<WorldStateSyncStatus> {
@@ -171,10 +190,12 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
171
190
  publisher?: SequencerPublisher;
172
191
  dateProvider?: DateProvider;
173
192
  p2pClientDeps?: P2PClientDeps<P2PClientType.Full>;
193
+ proverNodeDeps?: Partial<ProverNodeDeps>;
174
194
  } = {},
175
195
  options: {
176
196
  prefilledPublicData?: PublicDataTreeLeaf[];
177
197
  dontStartSequencer?: boolean;
198
+ dontStartProverNode?: boolean;
178
199
  } = {},
179
200
  ): Promise<AztecNodeService> {
180
201
  const config = { ...inputConfig }; // Copy the config so we dont mutate the input object
@@ -184,16 +205,29 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
184
205
  const dateProvider = deps.dateProvider ?? new DateProvider();
185
206
  const ethereumChain = createEthereumChain(config.l1RpcUrls, config.l1ChainId);
186
207
 
187
- // Build a key store from file if given or from environment otherwise
208
+ // Build a key store from file if given or from environment otherwise.
209
+ // We keep the raw KeyStore available so we can merge with prover keys if enableProverNode is set.
188
210
  let keyStoreManager: KeystoreManager | undefined;
189
211
  const keyStoreProvided = config.keyStoreDirectory !== undefined && config.keyStoreDirectory.length > 0;
190
212
  if (keyStoreProvided) {
191
213
  const keyStores = loadKeystores(config.keyStoreDirectory!);
192
214
  keyStoreManager = new KeystoreManager(mergeKeystores(keyStores));
193
215
  } else {
194
- const keyStore = createKeyStoreForValidator(config);
195
- if (keyStore) {
196
- keyStoreManager = new KeystoreManager(keyStore);
216
+ const rawKeyStores: KeyStore[] = [];
217
+ const validatorKeyStore = createKeyStoreForValidator(config);
218
+ if (validatorKeyStore) {
219
+ rawKeyStores.push(validatorKeyStore);
220
+ }
221
+ if (config.enableProverNode) {
222
+ const proverKeyStore = createKeyStoreForProver(config);
223
+ if (proverKeyStore) {
224
+ rawKeyStores.push(proverKeyStore);
225
+ }
226
+ }
227
+ if (rawKeyStores.length > 0) {
228
+ keyStoreManager = new KeystoreManager(
229
+ rawKeyStores.length === 1 ? rawKeyStores[0] : mergeKeystores(rawKeyStores),
230
+ );
197
231
  }
198
232
  }
199
233
 
@@ -204,10 +238,8 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
204
238
  if (keyStoreManager === undefined) {
205
239
  throw new Error('Failed to create key store, a requirement for running a validator');
206
240
  }
207
- if (!keyStoreProvided) {
208
- log.warn(
209
- 'KEY STORE CREATED FROM ENVIRONMENT, IT IS RECOMMENDED TO USE A FILE-BASED KEY STORE IN PRODUCTION ENVIRONMENTS',
210
- );
241
+ if (!keyStoreProvided && process.env.NODE_ENV !== 'test') {
242
+ log.warn("Keystore created from env: it's recommended to use a file-based key store for production");
211
243
  }
212
244
  ValidatorClient.validateKeyStoreConfiguration(keyStoreManager, log);
213
245
  }
@@ -249,7 +281,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
249
281
  );
250
282
  }
251
283
 
252
- const blobClient = await createBlobClientWithFileStores(config, createLogger('node:blob-client:client'));
284
+ const blobClient = await createBlobClientWithFileStores(config, log.createChild('blob-client'));
253
285
 
254
286
  // attempt snapshot sync if possible
255
287
  await trySnapshotSync(config, log);
@@ -273,9 +305,19 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
273
305
  config.realProofs || config.debugForceTxProofVerification
274
306
  ? await BBCircuitVerifier.new(config)
275
307
  : new TestCircuitVerifier(config.proverTestVerificationDelayMs);
308
+
309
+ let debugLogStore: DebugLogStore;
276
310
  if (!config.realProofs) {
277
311
  log.warn(`Aztec node is accepting fake proofs`);
312
+
313
+ debugLogStore = new InMemoryDebugLogStore();
314
+ log.info(
315
+ 'Aztec node started in test mode (realProofs set to false) hence debug logs from public functions will be collected and served',
316
+ );
317
+ } else {
318
+ debugLogStore = new NullDebugLogStore();
278
319
  }
320
+
279
321
  const proofVerifier = new QueuedIVCVerifier(config, circuitVerifier);
280
322
 
281
323
  // create the tx pool and the p2p client, which will need the l2 block source
@@ -412,19 +454,19 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
412
454
  );
413
455
  await slasherClient.start();
414
456
 
415
- const l1TxUtils = config.publisherForwarderAddress
416
- ? await createForwarderL1TxUtilsFromEthSigner(
457
+ const l1TxUtils = config.sequencerPublisherForwarderAddress
458
+ ? await createForwarderL1TxUtilsFromSigners(
417
459
  publicClient,
418
460
  keyStoreManager!.createAllValidatorPublisherSigners(),
419
- config.publisherForwarderAddress,
461
+ config.sequencerPublisherForwarderAddress,
420
462
  { ...config, scope: 'sequencer' },
421
- { telemetry, logger: log.createChild('l1-tx-utils'), dateProvider },
463
+ { telemetry, logger: log.createChild('l1-tx-utils'), dateProvider, kzg: Blob.getViemKzgInstance() },
422
464
  )
423
- : await createL1TxUtilsWithBlobsFromEthSigner(
465
+ : await createL1TxUtilsFromSigners(
424
466
  publicClient,
425
467
  keyStoreManager!.createAllValidatorPublisherSigners(),
426
468
  { ...config, scope: 'sequencer' },
427
- { telemetry, logger: log.createChild('l1-tx-utils'), dateProvider },
469
+ { telemetry, logger: log.createChild('l1-tx-utils'), dateProvider, kzg: Blob.getViemKzgInstance() },
428
470
  );
429
471
 
430
472
  // Create and start the sequencer client
@@ -434,6 +476,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
434
476
  archiver,
435
477
  dateProvider,
436
478
  telemetry,
479
+ debugLogStore,
437
480
  );
438
481
 
439
482
  sequencer = await SequencerClient.new(config, {
@@ -461,6 +504,29 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
461
504
  log.warn(`Sequencer created but not started`);
462
505
  }
463
506
 
507
+ // Create prover node subsystem if enabled
508
+ let proverNode: ProverNode | undefined;
509
+ if (config.enableProverNode) {
510
+ proverNode = await createProverNode(config, {
511
+ ...deps.proverNodeDeps,
512
+ telemetry,
513
+ dateProvider,
514
+ archiver,
515
+ worldStateSynchronizer,
516
+ p2pClient,
517
+ epochCache,
518
+ blobClient,
519
+ keyStoreManager,
520
+ });
521
+
522
+ if (!options.dontStartProverNode) {
523
+ await proverNode.start();
524
+ log.info(`Prover node subsystem started`);
525
+ } else {
526
+ log.info(`Prover node subsystem created but not started`);
527
+ }
528
+ }
529
+
464
530
  const globalVariableBuilder = new GlobalVariableBuilder({
465
531
  ...config,
466
532
  rollupVersion: BigInt(config.rollupVersion),
@@ -468,7 +534,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
468
534
  slotDuration: Number(slotDuration),
469
535
  });
470
536
 
471
- return new AztecNodeService(
537
+ const node = new AztecNodeService(
472
538
  config,
473
539
  p2pClient,
474
540
  archiver,
@@ -477,6 +543,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
477
543
  archiver,
478
544
  worldStateSynchronizer,
479
545
  sequencer,
546
+ proverNode,
480
547
  slasherClient,
481
548
  validatorsSentinel,
482
549
  epochPruneWatcher,
@@ -489,7 +556,12 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
489
556
  telemetry,
490
557
  log,
491
558
  blobClient,
559
+ validatorClient,
560
+ keyStoreManager,
561
+ debugLogStore,
492
562
  );
563
+
564
+ return node;
493
565
  }
494
566
 
495
567
  /**
@@ -500,6 +572,11 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
500
572
  return this.sequencer;
501
573
  }
502
574
 
575
+ /** Returns the prover node subsystem, if enabled. */
576
+ public getProverNode(): ProverNode | undefined {
577
+ return this.proverNode;
578
+ }
579
+
503
580
  public getBlockSource(): L2BlockSource {
504
581
  return this.blockSource;
505
582
  }
@@ -775,18 +852,22 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
775
852
  // Then get the actual tx from the archiver, which tracks every tx in a mined block.
776
853
  const settledTxReceipt = await this.blockSource.getSettledTxReceipt(txHash);
777
854
 
855
+ let receipt: TxReceipt;
778
856
  if (settledTxReceipt) {
779
- // If the archiver has the receipt then return it.
780
- return settledTxReceipt;
857
+ receipt = settledTxReceipt;
781
858
  } else if (isKnownToPool) {
782
859
  // If the tx is in the pool but not in the archiver, it's pending.
783
860
  // This handles race conditions between archiver and p2p, where the archiver
784
861
  // has pruned the block in which a tx was mined, but p2p has not caught up yet.
785
- return new TxReceipt(txHash, TxStatus.PENDING, undefined, undefined);
862
+ receipt = new TxReceipt(txHash, TxStatus.PENDING, undefined, undefined);
786
863
  } else {
787
864
  // Otherwise, if we don't know the tx, we consider it dropped.
788
- return new TxReceipt(txHash, TxStatus.DROPPED, undefined, 'Tx dropped by P2P node');
865
+ receipt = new TxReceipt(txHash, TxStatus.DROPPED, undefined, 'Tx dropped by P2P node');
789
866
  }
867
+
868
+ this.debugLogStore.decorateReceiptWithLogs(txHash.toString(), receipt);
869
+
870
+ return receipt;
790
871
  }
791
872
 
792
873
  public getTxEffect(txHash: TxHash): Promise<IndexedTxEffect | undefined> {
@@ -803,6 +884,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
803
884
  await tryStop(this.slasherClient);
804
885
  await tryStop(this.proofVerifier);
805
886
  await tryStop(this.sequencer);
887
+ await tryStop(this.proverNode);
806
888
  await tryStop(this.p2pClient);
807
889
  await tryStop(this.worldStateSynchronizer);
808
890
  await tryStop(this.blockSource);
@@ -1106,6 +1188,14 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
1106
1188
  return await this.blockSource.getBlockHeaderByArchive(archive);
1107
1189
  }
1108
1190
 
1191
+ public getBlockData(number: BlockNumber): Promise<BlockData | undefined> {
1192
+ return this.blockSource.getBlockData(number);
1193
+ }
1194
+
1195
+ public getBlockDataByArchive(archive: Fr): Promise<BlockData | undefined> {
1196
+ return this.blockSource.getBlockDataByArchive(archive);
1197
+ }
1198
+
1109
1199
  /**
1110
1200
  * Simulates the public part of a transaction with the current state.
1111
1201
  * @param tx - The transaction to simulate.
@@ -1129,7 +1219,8 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
1129
1219
  }
1130
1220
 
1131
1221
  const txHash = tx.getTxHash();
1132
- const blockNumber = BlockNumber((await this.blockSource.getBlockNumber()) + 1);
1222
+ const latestBlockNumber = await this.blockSource.getBlockNumber();
1223
+ const blockNumber = BlockNumber.add(latestBlockNumber, 1);
1133
1224
 
1134
1225
  // If sequencer is not initialized, we just set these values to zero for simulation.
1135
1226
  const coinbase = EthAddress.ZERO;
@@ -1153,6 +1244,8 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
1153
1244
  blockNumber,
1154
1245
  });
1155
1246
 
1247
+ // Ensure world-state has caught up with the latest block we loaded from the archiver
1248
+ await this.worldStateSynchronizer.syncImmediate(latestBlockNumber);
1156
1249
  const merkleTreeFork = await this.worldStateSynchronizer.fork();
1157
1250
  try {
1158
1251
  const config = PublicSimulatorConfig.from({
@@ -1168,7 +1261,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
1168
1261
  const processor = publicProcessorFactory.create(merkleTreeFork, newGlobalVariables, config);
1169
1262
 
1170
1263
  // REFACTOR: Consider merging ProcessReturnValues into ProcessedTx
1171
- const [processedTxs, failedTxs, _usedTxs, returns] = await processor.process([tx]);
1264
+ const [processedTxs, failedTxs, _usedTxs, returns, _blobFields, debugLogs] = await processor.process([tx]);
1172
1265
  // REFACTOR: Consider returning the error rather than throwing
1173
1266
  if (failedTxs.length) {
1174
1267
  this.log.warn(`Simulated tx ${txHash} fails: ${failedTxs[0].error}`, { txHash });
@@ -1182,6 +1275,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
1182
1275
  processedTx.txEffect,
1183
1276
  returns,
1184
1277
  processedTx.gasUsed,
1278
+ debugLogs,
1185
1279
  );
1186
1280
  } finally {
1187
1281
  await merkleTreeFork.close();
@@ -1195,7 +1289,7 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
1195
1289
  const db = this.worldStateSynchronizer.getCommitted();
1196
1290
  const verifier = isSimulation ? undefined : this.proofVerifier;
1197
1291
 
1198
- // We accept transactions if they are not expired by the next slot (checked based on the IncludeByTimestamp field)
1292
+ // We accept transactions if they are not expired by the next slot (checked based on the ExpirationTimestamp field)
1199
1293
  const { ts: nextSlotTimestamp } = this.epochCache.getEpochAndSlotInNextL1Slot();
1200
1294
  const blockNumber = BlockNumber((await this.blockSource.getBlockNumber()) + 1);
1201
1295
  const validator = createValidatorForAcceptingTxs(
@@ -1377,6 +1471,94 @@ export class AztecNodeService implements AztecNode, AztecNodeAdmin, Traceable {
1377
1471
  }
1378
1472
  }
1379
1473
 
1474
+ public async reloadKeystore(): Promise<void> {
1475
+ if (!this.config.keyStoreDirectory?.length) {
1476
+ throw new BadRequestError(
1477
+ 'Cannot reload keystore: node is not using a file-based keystore. ' +
1478
+ 'Set KEY_STORE_DIRECTORY to use file-based keystores.',
1479
+ );
1480
+ }
1481
+ if (!this.validatorClient) {
1482
+ throw new BadRequestError('Cannot reload keystore: validator is not enabled.');
1483
+ }
1484
+
1485
+ this.log.info('Reloading keystore from disk');
1486
+
1487
+ // Re-read and validate keystore files
1488
+ const keyStores = loadKeystores(this.config.keyStoreDirectory);
1489
+ const newManager = new KeystoreManager(mergeKeystores(keyStores));
1490
+ await newManager.validateSigners();
1491
+ ValidatorClient.validateKeyStoreConfiguration(newManager, this.log);
1492
+
1493
+ // Validate that every validator's publisher keys overlap with the L1 signers
1494
+ // that were initialized at startup. Publishers cannot be hot-reloaded, so a
1495
+ // validator with a publisher key that doesn't match any existing L1 signer
1496
+ // would silently fail on every proposer slot.
1497
+ if (this.keyStoreManager && this.sequencer) {
1498
+ const oldAdapter = NodeKeystoreAdapter.fromKeyStoreManager(this.keyStoreManager);
1499
+ const availablePublishers = new Set(
1500
+ oldAdapter
1501
+ .getAttesterAddresses()
1502
+ .flatMap(a => oldAdapter.getPublisherAddresses(a).map(p => p.toString().toLowerCase())),
1503
+ );
1504
+
1505
+ const newAdapter = NodeKeystoreAdapter.fromKeyStoreManager(newManager);
1506
+ for (const attester of newAdapter.getAttesterAddresses()) {
1507
+ const pubs = newAdapter.getPublisherAddresses(attester);
1508
+ if (pubs.length > 0 && !pubs.some(p => availablePublishers.has(p.toString().toLowerCase()))) {
1509
+ throw new BadRequestError(
1510
+ `Cannot reload keystore: validator ${attester} has publisher keys ` +
1511
+ `[${pubs.map(p => p.toString()).join(', ')}] but none match the L1 signers initialized at startup ` +
1512
+ `[${[...availablePublishers].join(', ')}]. Publishers cannot be hot-reloaded — ` +
1513
+ `use an existing publisher key or restart the node.`,
1514
+ );
1515
+ }
1516
+ }
1517
+ }
1518
+
1519
+ // Build adapters for old and new keystores to compute diff
1520
+ const newAdapter = NodeKeystoreAdapter.fromKeyStoreManager(newManager);
1521
+ const newAddresses = newAdapter.getAttesterAddresses();
1522
+ const oldAddresses = this.keyStoreManager
1523
+ ? NodeKeystoreAdapter.fromKeyStoreManager(this.keyStoreManager).getAttesterAddresses()
1524
+ : [];
1525
+
1526
+ const oldSet = new Set(oldAddresses.map(a => a.toString()));
1527
+ const newSet = new Set(newAddresses.map(a => a.toString()));
1528
+ const added = newAddresses.filter(a => !oldSet.has(a.toString()));
1529
+ const removed = oldAddresses.filter(a => !newSet.has(a.toString()));
1530
+
1531
+ if (added.length > 0) {
1532
+ this.log.info(`Keystore reload: adding attester keys: ${added.map(a => a.toString()).join(', ')}`);
1533
+ }
1534
+ if (removed.length > 0) {
1535
+ this.log.info(`Keystore reload: removing attester keys: ${removed.map(a => a.toString()).join(', ')}`);
1536
+ }
1537
+ if (added.length === 0 && removed.length === 0) {
1538
+ this.log.info('Keystore reload: attester keys unchanged');
1539
+ }
1540
+
1541
+ // Update the validator client (coinbase, feeRecipient, attester keys)
1542
+ this.validatorClient.reloadKeystore(newManager);
1543
+
1544
+ // Update the publisher factory's keystore so newly-added validators
1545
+ // can be matched to existing publisher keys when proposing blocks.
1546
+ if (this.sequencer) {
1547
+ this.sequencer.updatePublisherNodeKeyStore(newAdapter);
1548
+ }
1549
+
1550
+ // Update slasher's "don't-slash-self" list with new validator addresses
1551
+ if (this.slasherClient && !this.config.slashSelfAllowed) {
1552
+ const slashValidatorsNever = unique(
1553
+ [...(this.config.slashValidatorsNever ?? []), ...newAddresses].map(a => a.toString()),
1554
+ ).map(EthAddress.fromString);
1555
+ this.slasherClient.updateConfig({ slashValidatorsNever });
1556
+ }
1557
+
1558
+ this.keyStoreManager = newManager;
1559
+ this.log.info('Keystore reloaded: coinbase, feeRecipient, and attester keys updated');
1560
+ }
1561
+
1380
1562
  #getInitialHeaderHash(): Promise<BlockHash> {
1381
1563
  if (!this.initialHeaderHashPromise) {
1382
1564
  this.initialHeaderHashPromise = this.worldStateSynchronizer.getCommitted().getInitialHeader().hash();
@@ -139,15 +139,15 @@ export class Sentinel extends (EventEmitter as new () => WatcherEmitter) impleme
139
139
  return;
140
140
  }
141
141
  const blockNumber = event.block.number;
142
- const block = await this.archiver.getL2Block(blockNumber);
143
- if (!block) {
144
- this.logger.error(`Failed to get block ${blockNumber}`, { block });
142
+ const header = await this.archiver.getBlockHeader(blockNumber);
143
+ if (!header) {
144
+ this.logger.error(`Failed to get block header ${blockNumber}`);
145
145
  return;
146
146
  }
147
147
 
148
148
  // TODO(palla/slash): We should only be computing proven performance if this is
149
149
  // a full proof epoch and not a partial one, otherwise we'll end up with skewed stats.
150
- const epoch = getEpochAtSlot(block.header.getSlot(), this.epochCache.getL1Constants());
150
+ const epoch = getEpochAtSlot(header.getSlot(), this.epochCache.getL1Constants());
151
151
  this.logger.debug(`Computing proven performance for epoch ${epoch}`);
152
152
  const performance = await this.computeProvenPerformance(epoch);
153
153
  this.logger.info(`Computed proven performance for epoch ${epoch}`, performance);
@@ -158,7 +158,11 @@ export class Sentinel extends (EventEmitter as new () => WatcherEmitter) impleme
158
158
 
159
159
  protected async computeProvenPerformance(epoch: EpochNumber): Promise<ValidatorsEpochPerformance> {
160
160
  const [fromSlot, toSlot] = getSlotRangeForEpoch(epoch, this.epochCache.getL1Constants());
161
- const { committee } = await this.epochCache.getCommittee(fromSlot);
161
+ const { committee, isEscapeHatchOpen } = await this.epochCache.getCommittee(fromSlot);
162
+ if (isEscapeHatchOpen) {
163
+ this.logger.info(`Skipping proven performance for epoch ${epoch} - escape hatch is open`);
164
+ return {};
165
+ }
162
166
  if (!committee) {
163
167
  this.logger.trace(`No committee found for slot ${fromSlot}`);
164
168
  return {};
@@ -327,7 +331,12 @@ export class Sentinel extends (EventEmitter as new () => WatcherEmitter) impleme
327
331
  * and updates overall stats.
328
332
  */
329
333
  protected async processSlot(slot: SlotNumber) {
330
- const { epoch, seed, committee } = await this.epochCache.getCommittee(slot);
334
+ const { epoch, seed, committee, isEscapeHatchOpen } = await this.epochCache.getCommittee(slot);
335
+ if (isEscapeHatchOpen) {
336
+ this.logger.info(`Skipping slot ${slot} at epoch ${epoch} - escape hatch is open`);
337
+ this.lastProcessedSlot = slot;
338
+ return;
339
+ }
331
340
  if (!committee || committee.length === 0) {
332
341
  this.logger.trace(`No committee found for slot ${slot} at epoch ${epoch}`);
333
342
  this.lastProcessedSlot = slot;