@aztec/validator-client 4.1.2-rc.1 → 4.2.0-aztecnr-rc.2

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.
package/src/validator.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import type { BlobClientInterface } from '@aztec/blob-client/client';
2
+ import { type Blob, getBlobsPerL1Block } from '@aztec/blob-lib';
2
3
  import type { EpochCache } from '@aztec/epoch-cache';
4
+ import { validateFeeAssetPriceModifier } from '@aztec/ethereum/contracts';
3
5
  import {
4
6
  BlockNumber,
5
7
  CheckpointNumber,
@@ -8,9 +10,11 @@ import {
8
10
  SlotNumber,
9
11
  } from '@aztec/foundation/branded-types';
10
12
  import { Fr } from '@aztec/foundation/curves/bn254';
13
+ import { TimeoutError } from '@aztec/foundation/error';
11
14
  import type { EthAddress } from '@aztec/foundation/eth-address';
12
15
  import type { Signature } from '@aztec/foundation/eth-signature';
13
- import { type Logger, createLogger } from '@aztec/foundation/log';
16
+ import { type LogData, type Logger, createLogger } from '@aztec/foundation/log';
17
+ import { retryUntil } from '@aztec/foundation/retry';
14
18
  import { RunningPromise } from '@aztec/foundation/running-promise';
15
19
  import { sleep } from '@aztec/foundation/sleep';
16
20
  import { DateProvider } from '@aztec/foundation/timer';
@@ -19,8 +23,9 @@ import type { DuplicateAttestationInfo, DuplicateProposalInfo, P2P, PeerId } fro
19
23
  import { AuthRequest, AuthResponse, BlockProposalValidator, ReqRespSubProtocol } from '@aztec/p2p';
20
24
  import { OffenseType, WANT_TO_SLASH_EVENT, type Watcher, type WatcherEmitter } from '@aztec/slasher';
21
25
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
22
- import type { CommitteeAttestationsAndSigners, L2BlockSink, L2BlockSource } from '@aztec/stdlib/block';
23
- import { getEpochAtSlot } from '@aztec/stdlib/epoch-helpers';
26
+ import type { CommitteeAttestationsAndSigners, L2Block, L2BlockSink, L2BlockSource } from '@aztec/stdlib/block';
27
+ import { validateCheckpoint } from '@aztec/stdlib/checkpoint';
28
+ import { getEpochAtSlot, getTimestampForSlot } from '@aztec/stdlib/epoch-helpers';
24
29
  import type {
25
30
  CreateCheckpointProposalLastBlockData,
26
31
  ITxProvider,
@@ -28,7 +33,7 @@ import type {
28
33
  ValidatorClientFullConfig,
29
34
  WorldStateSynchronizer,
30
35
  } from '@aztec/stdlib/interfaces/server';
31
- import type { L1ToL2MessageSource } from '@aztec/stdlib/messaging';
36
+ import { type L1ToL2MessageSource, accumulateCheckpointOutHashes } from '@aztec/stdlib/messaging';
32
37
  import {
33
38
  type BlockProposal,
34
39
  type BlockProposalOptions,
@@ -38,23 +43,23 @@ import {
38
43
  type CheckpointProposalOptions,
39
44
  } from '@aztec/stdlib/p2p';
40
45
  import type { CheckpointHeader } from '@aztec/stdlib/rollup';
41
- import type { BlockHeader, Tx } from '@aztec/stdlib/tx';
46
+ import type { BlockHeader, CheckpointGlobalVariables, Tx } from '@aztec/stdlib/tx';
42
47
  import { AttestationTimeoutError } from '@aztec/stdlib/validators';
43
48
  import { type TelemetryClient, type Tracer, getTelemetryClient } from '@aztec/telemetry-client';
44
- import { createHASigner } from '@aztec/validator-ha-signer/factory';
45
- import { DutyType, type SigningContext } from '@aztec/validator-ha-signer/types';
49
+ import { createHASigner, createSignerFromSharedDb } from '@aztec/validator-ha-signer/factory';
50
+ import { DutyType, type SigningContext, type SlashingProtectionDatabase } from '@aztec/validator-ha-signer/types';
46
51
  import type { ValidatorHASigner } from '@aztec/validator-ha-signer/validator-ha-signer';
47
52
 
48
53
  import { EventEmitter } from 'events';
49
54
  import type { TypedDataDefinition } from 'viem';
50
55
 
56
+ import { BlockProposalHandler, type BlockProposalValidationFailureReason } from './block_proposal_handler.js';
51
57
  import type { FullNodeCheckpointsBuilder } from './checkpoint_builder.js';
52
58
  import { ValidationService } from './duties/validation_service.js';
53
59
  import { HAKeyStore } from './key_store/ha_key_store.js';
54
60
  import type { ExtendedValidatorKeyStore } from './key_store/interface.js';
55
61
  import { NodeKeystoreAdapter } from './key_store/node_keystore_adapter.js';
56
62
  import { ValidatorMetrics } from './metrics.js';
57
- import { type BlockProposalValidationFailureReason, ProposalHandler } from './proposal_handler.js';
58
63
 
59
64
  // We maintain a set of proposers who have proposed invalid blocks.
60
65
  // Just cap the set to avoid unbounded growth.
@@ -97,7 +102,11 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
97
102
  private keyStore: ExtendedValidatorKeyStore,
98
103
  private epochCache: EpochCache,
99
104
  private p2pClient: P2P,
100
- private proposalHandler: ProposalHandler,
105
+ private blockProposalHandler: BlockProposalHandler,
106
+ private blockSource: L2BlockSource,
107
+ private checkpointsBuilder: FullNodeCheckpointsBuilder,
108
+ private worldState: WorldStateSynchronizer,
109
+ private l1ToL2MessageSource: L1ToL2MessageSource,
101
110
  private config: ValidatorClientFullConfig,
102
111
  private blobClient: BlobClientInterface,
103
112
  private haSigner: ValidatorHASigner | undefined,
@@ -188,13 +197,14 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
188
197
  blobClient: BlobClientInterface,
189
198
  dateProvider: DateProvider = new DateProvider(),
190
199
  telemetry: TelemetryClient = getTelemetryClient(),
200
+ slashingProtectionDb?: SlashingProtectionDatabase,
191
201
  ) {
192
202
  const metrics = new ValidatorMetrics(telemetry);
193
203
  const blockProposalValidator = new BlockProposalValidator(epochCache, {
194
204
  txsPermitted: !config.disableTransactions,
195
205
  maxTxsPerBlock: config.validateMaxTxsPerBlock,
196
206
  });
197
- const proposalHandler = new ProposalHandler(
207
+ const blockProposalHandler = new BlockProposalHandler(
198
208
  checkpointsBuilder,
199
209
  worldState,
200
210
  blockSource,
@@ -203,7 +213,6 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
203
213
  blockProposalValidator,
204
214
  epochCache,
205
215
  config,
206
- blobClient,
207
216
  metrics,
208
217
  dateProvider,
209
218
  telemetry,
@@ -212,7 +221,12 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
212
221
  const nodeKeystoreAdapter = NodeKeystoreAdapter.fromKeyStoreManager(keyStoreManager);
213
222
  let validatorKeyStore: ExtendedValidatorKeyStore = nodeKeystoreAdapter;
214
223
  let haSigner: ValidatorHASigner | undefined;
215
- if (config.haSigningEnabled) {
224
+ if (slashingProtectionDb) {
225
+ // Shared database mode: use a pre-existing database (e.g. for testing HA setups).
226
+ const { signer } = createSignerFromSharedDb(slashingProtectionDb, config);
227
+ haSigner = signer;
228
+ validatorKeyStore = new HAKeyStore(nodeKeystoreAdapter, signer);
229
+ } else if (config.haSigningEnabled) {
216
230
  // If maxStuckDutiesAgeMs is not explicitly set, compute it from Aztec slot duration
217
231
  const haConfig = {
218
232
  ...config,
@@ -227,7 +241,11 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
227
241
  validatorKeyStore,
228
242
  epochCache,
229
243
  p2pClient,
230
- proposalHandler,
244
+ blockProposalHandler,
245
+ blockSource,
246
+ checkpointsBuilder,
247
+ worldState,
248
+ l1ToL2MessageSource,
231
249
  config,
232
250
  blobClient,
233
251
  haSigner,
@@ -244,8 +262,8 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
244
262
  .filter(addr => !this.config.disabledValidators.some(disabled => disabled.equals(addr)));
245
263
  }
246
264
 
247
- public getProposalHandler() {
248
- return this.proposalHandler;
265
+ public getBlockProposalHandler() {
266
+ return this.blockProposalHandler;
249
267
  }
250
268
 
251
269
  public signWithAddress(addr: EthAddress, msg: TypedDataDefinition, context: SigningContext) {
@@ -403,7 +421,7 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
403
421
  alwaysReexecuteBlockProposals ||
404
422
  this.blobClient.canUpload();
405
423
 
406
- const validationResult = await this.proposalHandler.handleBlockProposal(
424
+ const validationResult = await this.blockProposalHandler.handleBlockProposal(
407
425
  proposal,
408
426
  proposalSender,
409
427
  !!shouldReexecute && !escapeHatchOpen,
@@ -477,8 +495,14 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
477
495
  return undefined;
478
496
  }
479
497
 
498
+ // Reject proposals with invalid signatures
499
+ if (!proposer) {
500
+ this.log.warn(`Received checkpoint proposal with invalid signature for slot ${slotNumber}`);
501
+ return undefined;
502
+ }
503
+
480
504
  // Ignore proposals from ourselves (may happen in HA setups)
481
- if (proposer && this.getValidatorAddresses().some(addr => addr.equals(proposer))) {
505
+ if (this.getValidatorAddresses().some(addr => addr.equals(proposer))) {
482
506
  this.log.debug(`Ignoring block proposal from self for slot ${slotNumber}`, {
483
507
  proposer: proposer.toString(),
484
508
  slotNumber,
@@ -486,31 +510,44 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
486
510
  return undefined;
487
511
  }
488
512
 
489
- // Check that I have any address in the committee where this checkpoint will land before attesting
513
+ // Validate fee asset price modifier is within allowed range
514
+ if (!validateFeeAssetPriceModifier(proposal.feeAssetPriceModifier)) {
515
+ this.log.warn(
516
+ `Received checkpoint proposal with invalid feeAssetPriceModifier ${proposal.feeAssetPriceModifier} for slot ${slotNumber}`,
517
+ );
518
+ return undefined;
519
+ }
520
+
521
+ // Check that I have any address in current committee before attesting
490
522
  const inCommittee = await this.epochCache.filterInCommittee(slotNumber, this.getValidatorAddresses());
491
523
  const partOfCommittee = inCommittee.length > 0;
492
524
 
493
525
  const proposalInfo = {
494
526
  slotNumber,
495
527
  archive: proposal.archive.toString(),
496
- proposer: proposer?.toString(),
528
+ proposer: proposer.toString(),
497
529
  };
498
530
  this.log.info(`Received checkpoint proposal for slot ${slotNumber}`, {
499
531
  ...proposalInfo,
500
532
  fishermanMode: this.config.fishermanMode || false,
501
533
  });
502
534
 
503
- // Validate the checkpoint proposal and upload blobs (unless skipCheckpointProposalValidation is set)
535
+ // Validate the checkpoint proposal before attesting (unless skipCheckpointProposalValidation is set)
504
536
  if (this.config.skipCheckpointProposalValidation) {
505
537
  this.log.warn(`Skipping checkpoint proposal validation for slot ${slotNumber}`, proposalInfo);
506
538
  } else {
507
- const validationResult = await this.proposalHandler.handleCheckpointProposal(proposal, proposalInfo);
539
+ const validationResult = await this.validateCheckpointProposal(proposal, proposalInfo);
508
540
  if (!validationResult.isValid) {
509
541
  this.log.warn(`Checkpoint proposal validation failed: ${validationResult.reason}`, proposalInfo);
510
542
  return undefined;
511
543
  }
512
544
  }
513
545
 
546
+ // Upload blobs to filestore if we can (fire and forget)
547
+ if (this.blobClient.canUpload()) {
548
+ void this.uploadBlobsForCheckpoint(proposal, proposalInfo);
549
+ }
550
+
514
551
  // Check that I have any address in current committee before attesting
515
552
  // In fisherman mode, we still create attestations for validation even if not in committee
516
553
  if (!partOfCommittee && !this.config.fishermanMode) {
@@ -605,6 +642,201 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
605
642
  return attestations;
606
643
  }
607
644
 
645
+ /**
646
+ * Validates a checkpoint proposal by building the full checkpoint and comparing it with the proposal.
647
+ * @returns Validation result with isValid flag and reason if invalid.
648
+ */
649
+ private async validateCheckpointProposal(
650
+ proposal: CheckpointProposalCore,
651
+ proposalInfo: LogData,
652
+ ): Promise<{ isValid: true } | { isValid: false; reason: string }> {
653
+ const slot = proposal.slotNumber;
654
+
655
+ // Timeout block syncing at the start of the next slot
656
+ const config = this.checkpointsBuilder.getConfig();
657
+ const nextSlotTimestampSeconds = Number(getTimestampForSlot(SlotNumber(slot + 1), config));
658
+ const timeoutSeconds = Math.max(1, nextSlotTimestampSeconds - Math.floor(this.dateProvider.now() / 1000));
659
+
660
+ // Wait for last block to sync by archive
661
+ let lastBlockHeader: BlockHeader | undefined;
662
+ try {
663
+ lastBlockHeader = await retryUntil(
664
+ async () => {
665
+ await this.blockSource.syncImmediate();
666
+ return this.blockSource.getBlockHeaderByArchive(proposal.archive);
667
+ },
668
+ `waiting for block with archive ${proposal.archive.toString()} for slot ${slot}`,
669
+ timeoutSeconds,
670
+ 0.5,
671
+ );
672
+ } catch (err) {
673
+ if (err instanceof TimeoutError) {
674
+ this.log.warn(`Timed out waiting for block with archive matching checkpoint proposal`, proposalInfo);
675
+ return { isValid: false, reason: 'last_block_not_found' };
676
+ }
677
+ this.log.error(`Error fetching last block for checkpoint proposal`, err, proposalInfo);
678
+ return { isValid: false, reason: 'block_fetch_error' };
679
+ }
680
+
681
+ if (!lastBlockHeader) {
682
+ this.log.warn(`Last block not found for checkpoint proposal`, proposalInfo);
683
+ return { isValid: false, reason: 'last_block_not_found' };
684
+ }
685
+
686
+ // Get all full blocks for the slot and checkpoint
687
+ const blocks = await this.blockSource.getBlocksForSlot(slot);
688
+ if (blocks.length === 0) {
689
+ this.log.warn(`No blocks found for slot ${slot}`, proposalInfo);
690
+ return { isValid: false, reason: 'no_blocks_for_slot' };
691
+ }
692
+
693
+ // Ensure the last block for this slot matches the archive in the checkpoint proposal
694
+ if (!blocks.at(-1)?.archive.root.equals(proposal.archive)) {
695
+ this.log.warn(`Last block archive mismatch for checkpoint proposal`, proposalInfo);
696
+ return { isValid: false, reason: 'last_block_archive_mismatch' };
697
+ }
698
+
699
+ this.log.debug(`Found ${blocks.length} blocks for slot ${slot}`, {
700
+ ...proposalInfo,
701
+ blockNumbers: blocks.map(b => b.number),
702
+ });
703
+
704
+ // Get checkpoint constants from first block
705
+ const firstBlock = blocks[0];
706
+ const constants = this.extractCheckpointConstants(firstBlock);
707
+ const checkpointNumber = firstBlock.checkpointNumber;
708
+
709
+ // Get L1-to-L2 messages for this checkpoint
710
+ const l1ToL2Messages = await this.l1ToL2MessageSource.getL1ToL2Messages(checkpointNumber);
711
+
712
+ // Collect the out hashes of all the checkpoints before this one in the same epoch
713
+ const epoch = getEpochAtSlot(slot, this.epochCache.getL1Constants());
714
+ const previousCheckpointOutHashes = (await this.blockSource.getCheckpointsDataForEpoch(epoch))
715
+ .filter(c => c.checkpointNumber < checkpointNumber)
716
+ .map(c => c.checkpointOutHash);
717
+
718
+ // Fork world state at the block before the first block
719
+ const parentBlockNumber = BlockNumber(firstBlock.number - 1);
720
+ const fork = await this.worldState.fork(parentBlockNumber);
721
+
722
+ try {
723
+ // Create checkpoint builder with all existing blocks
724
+ const checkpointBuilder = await this.checkpointsBuilder.openCheckpoint(
725
+ checkpointNumber,
726
+ constants,
727
+ proposal.feeAssetPriceModifier,
728
+ l1ToL2Messages,
729
+ previousCheckpointOutHashes,
730
+ fork,
731
+ blocks,
732
+ this.log.getBindings(),
733
+ );
734
+
735
+ // Complete the checkpoint to get computed values
736
+ const computedCheckpoint = await checkpointBuilder.completeCheckpoint();
737
+
738
+ // Compare checkpoint header with proposal
739
+ if (!computedCheckpoint.header.equals(proposal.checkpointHeader)) {
740
+ this.log.warn(`Checkpoint header mismatch`, {
741
+ ...proposalInfo,
742
+ computed: computedCheckpoint.header.toInspect(),
743
+ proposal: proposal.checkpointHeader.toInspect(),
744
+ });
745
+ return { isValid: false, reason: 'checkpoint_header_mismatch' };
746
+ }
747
+
748
+ // Compare archive root with proposal
749
+ if (!computedCheckpoint.archive.root.equals(proposal.archive)) {
750
+ this.log.warn(`Archive root mismatch`, {
751
+ ...proposalInfo,
752
+ computed: computedCheckpoint.archive.root.toString(),
753
+ proposal: proposal.archive.toString(),
754
+ });
755
+ return { isValid: false, reason: 'archive_mismatch' };
756
+ }
757
+
758
+ // Check that the accumulated epoch out hash matches the value in the proposal.
759
+ // The epoch out hash is the accumulated hash of all checkpoint out hashes in the epoch.
760
+ const checkpointOutHash = computedCheckpoint.getCheckpointOutHash();
761
+ const computedEpochOutHash = accumulateCheckpointOutHashes([...previousCheckpointOutHashes, checkpointOutHash]);
762
+ const proposalEpochOutHash = proposal.checkpointHeader.epochOutHash;
763
+ if (!computedEpochOutHash.equals(proposalEpochOutHash)) {
764
+ this.log.warn(`Epoch out hash mismatch`, {
765
+ proposalEpochOutHash: proposalEpochOutHash.toString(),
766
+ computedEpochOutHash: computedEpochOutHash.toString(),
767
+ checkpointOutHash: checkpointOutHash.toString(),
768
+ previousCheckpointOutHashes: previousCheckpointOutHashes.map(h => h.toString()),
769
+ ...proposalInfo,
770
+ });
771
+ return { isValid: false, reason: 'out_hash_mismatch' };
772
+ }
773
+
774
+ // Final round of validations on the checkpoint, just in case.
775
+ try {
776
+ validateCheckpoint(computedCheckpoint, {
777
+ rollupManaLimit: this.checkpointsBuilder.getConfig().rollupManaLimit,
778
+ maxDABlockGas: this.config.validateMaxDABlockGas,
779
+ maxL2BlockGas: this.config.validateMaxL2BlockGas,
780
+ maxTxsPerBlock: this.config.validateMaxTxsPerBlock,
781
+ maxTxsPerCheckpoint: this.config.validateMaxTxsPerCheckpoint,
782
+ });
783
+ } catch (err) {
784
+ this.log.warn(`Checkpoint validation failed: ${err}`, proposalInfo);
785
+ return { isValid: false, reason: 'checkpoint_validation_failed' };
786
+ }
787
+
788
+ this.log.verbose(`Checkpoint proposal validation successful for slot ${slot}`, proposalInfo);
789
+ return { isValid: true };
790
+ } finally {
791
+ await fork.close();
792
+ }
793
+ }
794
+
795
+ /**
796
+ * Extract checkpoint global variables from a block.
797
+ */
798
+ private extractCheckpointConstants(block: L2Block): CheckpointGlobalVariables {
799
+ const gv = block.header.globalVariables;
800
+ return {
801
+ chainId: gv.chainId,
802
+ version: gv.version,
803
+ slotNumber: gv.slotNumber,
804
+ timestamp: gv.timestamp,
805
+ coinbase: gv.coinbase,
806
+ feeRecipient: gv.feeRecipient,
807
+ gasFees: gv.gasFees,
808
+ };
809
+ }
810
+
811
+ /**
812
+ * Uploads blobs for a checkpoint to the filestore (fire and forget).
813
+ */
814
+ protected async uploadBlobsForCheckpoint(proposal: CheckpointProposalCore, proposalInfo: LogData): Promise<void> {
815
+ try {
816
+ const lastBlockHeader = await this.blockSource.getBlockHeaderByArchive(proposal.archive);
817
+ if (!lastBlockHeader) {
818
+ this.log.warn(`Failed to get last block header for blob upload`, proposalInfo);
819
+ return;
820
+ }
821
+
822
+ const blocks = await this.blockSource.getBlocksForSlot(proposal.slotNumber);
823
+ if (blocks.length === 0) {
824
+ this.log.warn(`No blocks found for blob upload`, proposalInfo);
825
+ return;
826
+ }
827
+
828
+ const blobFields = blocks.flatMap(b => b.toBlobFields());
829
+ const blobs: Blob[] = await getBlobsPerL1Block(blobFields);
830
+ await this.blobClient.sendBlobsToFilestore(blobs);
831
+ this.log.debug(`Uploaded ${blobs.length} blobs to filestore for checkpoint at slot ${proposal.slotNumber}`, {
832
+ ...proposalInfo,
833
+ numBlobs: blobs.length,
834
+ });
835
+ } catch (err) {
836
+ this.log.warn(`Failed to upload blobs for checkpoint: ${err}`, proposalInfo);
837
+ }
838
+ }
839
+
608
840
  private slashInvalidBlock(proposal: BlockProposal) {
609
841
  const proposer = proposal.getSender();
610
842
 
@@ -1,94 +0,0 @@
1
- import type { BlobClientInterface } from '@aztec/blob-client/client';
2
- import type { EpochCache } from '@aztec/epoch-cache';
3
- import { BlockNumber, CheckpointNumber } from '@aztec/foundation/branded-types';
4
- import { Fr } from '@aztec/foundation/curves/bn254';
5
- import type { LogData } from '@aztec/foundation/log';
6
- import { DateProvider } from '@aztec/foundation/timer';
7
- import type { P2P, PeerId } from '@aztec/p2p';
8
- import { BlockProposalValidator } from '@aztec/p2p/msg_validators';
9
- import type { L2Block, L2BlockSink, L2BlockSource } from '@aztec/stdlib/block';
10
- import type { ITxProvider, ValidatorClientFullConfig, WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
11
- import { type L1ToL2MessageSource } from '@aztec/stdlib/messaging';
12
- import type { BlockProposal, CheckpointProposalCore } from '@aztec/stdlib/p2p';
13
- import type { FailedTx, Tx } from '@aztec/stdlib/tx';
14
- import { type TelemetryClient, type Tracer } from '@aztec/telemetry-client';
15
- import type { FullNodeCheckpointsBuilder } from './checkpoint_builder.js';
16
- import type { ValidatorMetrics } from './metrics.js';
17
- export type BlockProposalValidationFailureReason = 'invalid_proposal' | 'parent_block_not_found' | 'block_source_not_synced' | 'parent_block_wrong_slot' | 'in_hash_mismatch' | 'global_variables_mismatch' | 'block_number_already_exists' | 'txs_not_available' | 'state_mismatch' | 'failed_txs' | 'initial_state_mismatch' | 'timeout' | 'unknown_error';
18
- type ReexecuteTransactionsResult = {
19
- block: L2Block;
20
- failedTxs: FailedTx[];
21
- reexecutionTimeMs: number;
22
- totalManaUsed: number;
23
- };
24
- export type BlockProposalValidationSuccessResult = {
25
- isValid: true;
26
- blockNumber: BlockNumber;
27
- reexecutionResult?: ReexecuteTransactionsResult;
28
- };
29
- export type BlockProposalValidationFailureResult = {
30
- isValid: false;
31
- reason: BlockProposalValidationFailureReason;
32
- blockNumber?: BlockNumber;
33
- reexecutionResult?: ReexecuteTransactionsResult;
34
- };
35
- export type BlockProposalValidationResult = BlockProposalValidationSuccessResult | BlockProposalValidationFailureResult;
36
- export type CheckpointProposalValidationResult = {
37
- isValid: true;
38
- } | {
39
- isValid: false;
40
- reason: string;
41
- };
42
- /** Handles block and checkpoint proposals for both validator and non-validator nodes. */
43
- export declare class ProposalHandler {
44
- private checkpointsBuilder;
45
- private worldState;
46
- private blockSource;
47
- private l1ToL2MessageSource;
48
- private txProvider;
49
- private blockProposalValidator;
50
- private epochCache;
51
- private config;
52
- private blobClient;
53
- private metrics?;
54
- private dateProvider;
55
- private log;
56
- readonly tracer: Tracer;
57
- constructor(checkpointsBuilder: FullNodeCheckpointsBuilder, worldState: WorldStateSynchronizer, blockSource: L2BlockSource & L2BlockSink, l1ToL2MessageSource: L1ToL2MessageSource, txProvider: ITxProvider, blockProposalValidator: BlockProposalValidator, epochCache: EpochCache, config: ValidatorClientFullConfig, blobClient: BlobClientInterface, metrics?: ValidatorMetrics | undefined, dateProvider?: DateProvider, telemetry?: TelemetryClient, log?: import("@aztec/foundation/log").Logger);
58
- /**
59
- * Registers non-validator handlers for block and checkpoint proposals on the p2p client.
60
- * Block proposals are always registered. Checkpoint proposals are registered if the blob client can upload.
61
- */
62
- register(p2pClient: P2P, shouldReexecute: boolean): ProposalHandler;
63
- handleBlockProposal(proposal: BlockProposal, proposalSender: PeerId, shouldReexecute: boolean): Promise<BlockProposalValidationResult>;
64
- private getParentBlock;
65
- private computeCheckpointNumber;
66
- /**
67
- * Validates that a non-first block in a checkpoint has consistent global variables with its parent.
68
- * For blocks with indexWithinCheckpoint > 0, all global variables except blockNumber must match the parent.
69
- * @returns A failure result if validation fails, undefined if validation passes
70
- */
71
- private validateNonFirstBlockInCheckpoint;
72
- private getReexecutionDeadline;
73
- private waitForBlockSourceSync;
74
- private getReexecuteFailureReason;
75
- reexecuteTransactions(proposal: BlockProposal, blockNumber: BlockNumber, checkpointNumber: CheckpointNumber, txs: Tx[], l1ToL2Messages: Fr[], previousCheckpointOutHashes: Fr[]): Promise<ReexecuteTransactionsResult>;
76
- /**
77
- * Validates a checkpoint proposal and uploads blobs if configured.
78
- * Used by both non-validator nodes (via register) and the validator client (via delegation).
79
- */
80
- handleCheckpointProposal(proposal: CheckpointProposalCore, proposalInfo: LogData): Promise<CheckpointProposalValidationResult>;
81
- /**
82
- * Validates a checkpoint proposal by building the full checkpoint and comparing it with the proposal.
83
- * @returns Validation result with isValid flag and reason if invalid.
84
- */
85
- validateCheckpointProposal(proposal: CheckpointProposalCore, proposalInfo: LogData): Promise<CheckpointProposalValidationResult>;
86
- /** Extracts checkpoint global variables from a block. */
87
- private extractCheckpointConstants;
88
- /** Triggers blob upload for a checkpoint if the blob client can upload (fire and forget). */
89
- protected tryUploadBlobsForCheckpoint(proposal: CheckpointProposalCore, proposalInfo: LogData): void;
90
- /** Uploads blobs for a checkpoint to the filestore. */
91
- protected uploadBlobsForCheckpoint(proposal: CheckpointProposalCore, proposalInfo: LogData): Promise<void>;
92
- }
93
- export {};
94
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJvcG9zYWxfaGFuZGxlci5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL3Byb3Bvc2FsX2hhbmRsZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLEVBQUUsbUJBQW1CLEVBQUUsTUFBTSwyQkFBMkIsQ0FBQztBQUdyRSx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