@aztec/validator-client 0.0.1-commit.5de5ca79e → 0.0.1-commit.6201a7b05

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/dest/validator.js CHANGED
@@ -1,27 +1,22 @@
1
1
  import { getBlobsPerL1Block } from '@aztec/blob-lib';
2
- import { validateFeeAssetPriceModifier } from '@aztec/ethereum/contracts';
3
- import { BlockNumber, SlotNumber } from '@aztec/foundation/branded-types';
4
- import { TimeoutError } from '@aztec/foundation/error';
2
+ import { CheckpointNumber } from '@aztec/foundation/branded-types';
5
3
  import { createLogger } from '@aztec/foundation/log';
6
- import { retryUntil } from '@aztec/foundation/retry';
7
4
  import { RunningPromise } from '@aztec/foundation/running-promise';
8
5
  import { sleep } from '@aztec/foundation/sleep';
9
6
  import { DateProvider } from '@aztec/foundation/timer';
10
7
  import { AuthRequest, AuthResponse, BlockProposalValidator, ReqRespSubProtocol } from '@aztec/p2p';
11
8
  import { OffenseType, WANT_TO_SLASH_EVENT } from '@aztec/slasher';
12
- import { validateCheckpoint } from '@aztec/stdlib/checkpoint';
13
- import { getEpochAtSlot, getTimestampForSlot } from '@aztec/stdlib/epoch-helpers';
14
- import { accumulateCheckpointOutHashes } from '@aztec/stdlib/messaging';
9
+ import { getEpochAtSlot } from '@aztec/stdlib/epoch-helpers';
15
10
  import { AttestationTimeoutError } from '@aztec/stdlib/validators';
16
11
  import { getTelemetryClient } from '@aztec/telemetry-client';
17
12
  import { createHASigner, createLocalSignerWithProtection, createSignerFromSharedDb } from '@aztec/validator-ha-signer/factory';
18
13
  import { DutyType } from '@aztec/validator-ha-signer/types';
19
14
  import { EventEmitter } from 'events';
20
- import { BlockProposalHandler } from './block_proposal_handler.js';
21
15
  import { ValidationService } from './duties/validation_service.js';
22
16
  import { HAKeyStore } from './key_store/ha_key_store.js';
23
17
  import { NodeKeystoreAdapter } from './key_store/node_keystore_adapter.js';
24
18
  import { ValidatorMetrics } from './metrics.js';
19
+ import { ProposalHandler } from './proposal_handler.js';
25
20
  // We maintain a set of proposers who have proposed invalid blocks.
26
21
  // Just cap the set to avoid unbounded growth.
27
22
  const MAX_PROPOSERS_OF_INVALID_BLOCKS = 1000;
@@ -36,7 +31,7 @@ const SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT = [
36
31
  keyStore;
37
32
  epochCache;
38
33
  p2pClient;
39
- blockProposalHandler;
34
+ proposalHandler;
40
35
  blockSource;
41
36
  checkpointsBuilder;
42
37
  worldState;
@@ -58,13 +53,13 @@ const SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT = [
58
53
  /** Tracks the last epoch in which each attester successfully submitted at least one attestation. */ lastAttestedEpochByAttester;
59
54
  proposersOfInvalidBlocks;
60
55
  /** Tracks the last checkpoint proposal we attested to, to prevent equivocation. */ lastAttestedProposal;
61
- constructor(keyStore, epochCache, p2pClient, blockProposalHandler, blockSource, checkpointsBuilder, worldState, l1ToL2MessageSource, config, blobClient, slashingProtectionSigner, dateProvider = new DateProvider(), telemetry = getTelemetryClient(), log = createLogger('validator')){
62
- super(), this.keyStore = keyStore, this.epochCache = epochCache, this.p2pClient = p2pClient, this.blockProposalHandler = blockProposalHandler, this.blockSource = blockSource, this.checkpointsBuilder = checkpointsBuilder, this.worldState = worldState, this.l1ToL2MessageSource = l1ToL2MessageSource, this.config = config, this.blobClient = blobClient, this.slashingProtectionSigner = slashingProtectionSigner, this.dateProvider = dateProvider, this.hasRegisteredHandlers = false, this.lastAttestedEpochByAttester = new Map(), this.proposersOfInvalidBlocks = new Set();
56
+ constructor(keyStore, epochCache, p2pClient, proposalHandler, blockSource, checkpointsBuilder, worldState, l1ToL2MessageSource, config, blobClient, slashingProtectionSigner, dateProvider = new DateProvider(), telemetry = getTelemetryClient(), log = createLogger('validator')){
57
+ super(), this.keyStore = keyStore, this.epochCache = epochCache, this.p2pClient = p2pClient, this.proposalHandler = proposalHandler, this.blockSource = blockSource, this.checkpointsBuilder = checkpointsBuilder, this.worldState = worldState, this.l1ToL2MessageSource = l1ToL2MessageSource, this.config = config, this.blobClient = blobClient, this.slashingProtectionSigner = slashingProtectionSigner, this.dateProvider = dateProvider, this.hasRegisteredHandlers = false, this.lastAttestedEpochByAttester = new Map(), this.proposersOfInvalidBlocks = new Set();
63
58
  // Create child logger with fisherman prefix if in fisherman mode
64
59
  this.log = config.fishermanMode ? log.createChild('[FISHERMAN]') : log;
65
60
  this.tracer = telemetry.getTracer('Validator');
66
61
  this.metrics = new ValidatorMetrics(telemetry);
67
- this.validationService = new ValidationService(keyStore, this.log.createChild('validation-service'));
62
+ this.validationService = new ValidationService(keyStore, this.getSignatureContext(), this.log.createChild('validation-service'));
68
63
  // Refresh epoch cache every second to trigger alert if participation in committee changes
69
64
  this.epochCacheUpdateLoop = new RunningPromise(this.handleEpochCommitteeUpdate.bind(this), this.log, 1000);
70
65
  const myAddresses = this.getValidatorAddresses();
@@ -118,9 +113,13 @@ const SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT = [
118
113
  const metrics = new ValidatorMetrics(telemetry);
119
114
  const blockProposalValidator = new BlockProposalValidator(epochCache, {
120
115
  txsPermitted: !config.disableTransactions,
121
- maxTxsPerBlock: config.validateMaxTxsPerBlock
116
+ maxTxsPerBlock: config.validateMaxTxsPerBlock,
117
+ signatureContext: {
118
+ chainId: config.l1ChainId,
119
+ rollupAddress: config.l1Contracts.rollupAddress
120
+ }
122
121
  });
123
- const blockProposalHandler = new BlockProposalHandler(checkpointsBuilder, worldState, blockSource, l1ToL2MessageSource, txProvider, blockProposalValidator, epochCache, config, metrics, dateProvider, telemetry);
122
+ const proposalHandler = new ProposalHandler(checkpointsBuilder, worldState, blockSource, l1ToL2MessageSource, txProvider, blockProposalValidator, epochCache, config, blobClient, metrics, dateProvider, telemetry, undefined);
124
123
  const nodeKeystoreAdapter = NodeKeystoreAdapter.fromKeyStoreManager(keyStoreManager);
125
124
  let slashingProtectionSigner;
126
125
  if (slashingProtectionDb) {
@@ -149,18 +148,24 @@ const SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT = [
149
148
  }));
150
149
  }
151
150
  const validatorKeyStore = new HAKeyStore(nodeKeystoreAdapter, slashingProtectionSigner);
152
- const validator = new ValidatorClient(validatorKeyStore, epochCache, p2pClient, blockProposalHandler, blockSource, checkpointsBuilder, worldState, l1ToL2MessageSource, config, blobClient, slashingProtectionSigner, dateProvider, telemetry);
151
+ const validator = new ValidatorClient(validatorKeyStore, epochCache, p2pClient, proposalHandler, blockSource, checkpointsBuilder, worldState, l1ToL2MessageSource, config, blobClient, slashingProtectionSigner, dateProvider, telemetry);
153
152
  return validator;
154
153
  }
155
154
  getValidatorAddresses() {
156
155
  return this.keyStore.getAddresses().filter((addr)=>!this.config.disabledValidators.some((disabled)=>disabled.equals(addr)));
157
156
  }
158
- getBlockProposalHandler() {
159
- return this.blockProposalHandler;
157
+ getProposalHandler() {
158
+ return this.proposalHandler;
160
159
  }
161
160
  signWithAddress(addr, msg, context) {
162
161
  return this.keyStore.signTypedDataWithAddress(addr, msg, context);
163
162
  }
163
+ getSignatureContext() {
164
+ return {
165
+ chainId: this.config.l1ChainId,
166
+ rollupAddress: this.config.l1Contracts.rollupAddress
167
+ };
168
+ }
164
169
  getCoinbaseForAttestor(attestor) {
165
170
  return this.keyStore.getCoinbaseAddress(attestor);
166
171
  }
@@ -179,7 +184,7 @@ const SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT = [
179
184
  reloadKeystore(newManager) {
180
185
  const newAdapter = NodeKeystoreAdapter.fromKeyStoreManager(newManager);
181
186
  this.keyStore = new HAKeyStore(newAdapter, this.slashingProtectionSigner);
182
- this.validationService = new ValidationService(this.keyStore, this.log.createChild('validation-service'));
187
+ this.validationService = new ValidationService(this.keyStore, this.getSignatureContext(), this.log.createChild('validation-service'));
183
188
  }
184
189
  async start() {
185
190
  if (this.epochCacheUpdateLoop.isRunning()) {
@@ -212,7 +217,7 @@ const SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT = [
212
217
  // The checkpoint is received as CheckpointProposalCore since the lastBlock is extracted
213
218
  // and processed separately via the block handler above.
214
219
  const checkpointHandler = (checkpoint, proposalSender)=>this.attestToCheckpointProposal(checkpoint, proposalSender);
215
- this.p2pClient.registerCheckpointProposalHandler(checkpointHandler);
220
+ this.p2pClient.registerValidatorCheckpointProposalHandler(checkpointHandler);
216
221
  // Duplicate proposal handler - triggers slashing for equivocation
217
222
  this.p2pClient.registerDuplicateProposalCallback((info)=>{
218
223
  this.handleDuplicateProposal(info);
@@ -262,9 +267,9 @@ const SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT = [
262
267
  });
263
268
  // Reexecute txs if we are part of the committee, or if slashing is enabled, or if we are configured to always reexecute.
264
269
  // In fisherman mode, we always reexecute to validate proposals.
265
- const { validatorReexecute, slashBroadcastedInvalidBlockPenalty, alwaysReexecuteBlockProposals, fishermanMode } = this.config;
266
- const shouldReexecute = fishermanMode || slashBroadcastedInvalidBlockPenalty > 0n && validatorReexecute || partOfCommittee && validatorReexecute || alwaysReexecuteBlockProposals || this.blobClient.canUpload();
267
- const validationResult = await this.blockProposalHandler.handleBlockProposal(proposal, proposalSender, !!shouldReexecute && !escapeHatchOpen);
270
+ const { slashBroadcastedInvalidBlockPenalty, alwaysReexecuteBlockProposals, fishermanMode } = this.config;
271
+ const shouldReexecute = fishermanMode || slashBroadcastedInvalidBlockPenalty > 0n || partOfCommittee || alwaysReexecuteBlockProposals || this.blobClient.canUpload();
272
+ const validationResult = await this.proposalHandler.handleBlockProposal(proposal, proposalSender, !!shouldReexecute && !escapeHatchOpen);
268
273
  if (!validationResult.isValid) {
269
274
  const reason = validationResult.reason || 'unknown';
270
275
  this.log.warn(`Block proposal validation failed: ${reason}`, proposalInfo);
@@ -314,49 +319,39 @@ const SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT = [
314
319
  this.log.warn(`Escape hatch open for slot ${proposalSlotNumber}, skipping checkpoint attestation handling`);
315
320
  return undefined;
316
321
  }
317
- // Reject proposals with invalid signatures
318
- if (!proposer) {
319
- this.log.warn(`Received checkpoint proposal with invalid signature for proposal slot ${proposalSlotNumber}`);
320
- return undefined;
321
- }
322
322
  // Ignore proposals from ourselves (may happen in HA setups)
323
- if (this.getValidatorAddresses().some((addr)=>addr.equals(proposer))) {
323
+ if (proposer && this.getValidatorAddresses().some((addr)=>addr.equals(proposer))) {
324
324
  this.log.debug(`Ignoring block proposal from self for slot ${proposalSlotNumber}`, {
325
325
  proposer: proposer.toString(),
326
326
  proposalSlotNumber
327
327
  });
328
328
  return undefined;
329
329
  }
330
- // Validate fee asset price modifier is within allowed range
331
- if (!validateFeeAssetPriceModifier(proposal.feeAssetPriceModifier)) {
332
- this.log.warn(`Received checkpoint proposal with invalid feeAssetPriceModifier ${proposal.feeAssetPriceModifier} for slot ${proposalSlotNumber}`);
333
- return undefined;
334
- }
335
330
  // Check that I have any address in the committee where this checkpoint will land before attesting
336
331
  const inCommittee = await this.epochCache.filterInCommittee(proposalSlotNumber, this.getValidatorAddresses());
337
332
  const partOfCommittee = inCommittee.length > 0;
338
333
  const proposalInfo = {
339
334
  proposalSlotNumber,
340
335
  archive: proposal.archive.toString(),
341
- proposer: proposer.toString()
336
+ proposer: proposer?.toString()
342
337
  };
343
338
  this.log.info(`Received checkpoint proposal for slot ${proposalSlotNumber}`, {
344
339
  ...proposalInfo,
345
340
  fishermanMode: this.config.fishermanMode || false
346
341
  });
347
- // Validate the checkpoint proposal before attesting (unless skipCheckpointProposalValidation is set)
342
+ // Validate the checkpoint proposal before attesting (unless skipCheckpointProposalValidation is set).
343
+ // Uses the cached result from the all-nodes callback if available (avoids double validation).
344
+ let checkpointNumber;
348
345
  if (this.config.skipCheckpointProposalValidation) {
349
346
  this.log.warn(`Skipping checkpoint proposal validation for slot ${proposalSlotNumber}`, proposalInfo);
347
+ checkpointNumber = CheckpointNumber(0);
350
348
  } else {
351
- const validationResult = await this.validateCheckpointProposal(proposal, proposalInfo);
349
+ const validationResult = await this.proposalHandler.handleCheckpointProposal(proposal, proposalInfo);
352
350
  if (!validationResult.isValid) {
353
351
  this.log.warn(`Checkpoint proposal validation failed: ${validationResult.reason}`, proposalInfo);
354
352
  return undefined;
355
353
  }
356
- }
357
- // Upload blobs to filestore if we can (fire and forget)
358
- if (this.blobClient.canUpload()) {
359
- void this.uploadBlobsForCheckpoint(proposal, proposalInfo);
354
+ checkpointNumber = validationResult.checkpointNumber;
360
355
  }
361
356
  // Check that I have any address in current committee before attesting
362
357
  // In fisherman mode, we still create attestations for validation even if not in committee
@@ -403,7 +398,7 @@ const SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT = [
403
398
  });
404
399
  return undefined;
405
400
  }
406
- return await this.createCheckpointAttestationsFromProposal(proposal, attestors);
401
+ return await this.createCheckpointAttestationsFromProposal(proposal, attestors, checkpointNumber);
407
402
  }
408
403
  /**
409
404
  * Checks if we should attest to a slot based on equivocation prevention rules.
@@ -420,176 +415,18 @@ const SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT = [
420
415
  }
421
416
  return true;
422
417
  }
423
- async createCheckpointAttestationsFromProposal(proposal, attestors = []) {
418
+ async createCheckpointAttestationsFromProposal(proposal, attestors = [], checkpointNumber) {
424
419
  // Equivocation check: must happen right before signing to minimize the race window
425
420
  if (!this.shouldAttestToSlot(proposal.slotNumber)) {
426
421
  return undefined;
427
422
  }
428
- const attestations = await this.validationService.attestToCheckpointProposal(proposal, attestors);
423
+ const attestations = await this.validationService.attestToCheckpointProposal(proposal, attestors, checkpointNumber);
429
424
  // Track the proposal we attested to (to prevent equivocation)
430
425
  this.lastAttestedProposal = proposal;
431
426
  await this.p2pClient.addOwnCheckpointAttestations(attestations);
432
427
  return attestations;
433
428
  }
434
429
  /**
435
- * Validates a checkpoint proposal by building the full checkpoint and comparing it with the proposal.
436
- * @returns Validation result with isValid flag and reason if invalid.
437
- */ async validateCheckpointProposal(proposal, proposalInfo) {
438
- const slot = proposal.slotNumber;
439
- // Timeout block syncing at the start of the next slot
440
- const config = this.checkpointsBuilder.getConfig();
441
- const nextSlotTimestampSeconds = Number(getTimestampForSlot(SlotNumber(slot + 1), config));
442
- const timeoutSeconds = Math.max(1, nextSlotTimestampSeconds - Math.floor(this.dateProvider.now() / 1000));
443
- // Wait for last block to sync by archive
444
- let lastBlockHeader;
445
- try {
446
- lastBlockHeader = await retryUntil(async ()=>{
447
- await this.blockSource.syncImmediate();
448
- return this.blockSource.getBlockHeaderByArchive(proposal.archive);
449
- }, `waiting for block with archive ${proposal.archive.toString()} for slot ${slot}`, timeoutSeconds, 0.5);
450
- } catch (err) {
451
- if (err instanceof TimeoutError) {
452
- this.log.warn(`Timed out waiting for block with archive matching checkpoint proposal`, proposalInfo);
453
- return {
454
- isValid: false,
455
- reason: 'last_block_not_found'
456
- };
457
- }
458
- this.log.error(`Error fetching last block for checkpoint proposal`, err, proposalInfo);
459
- return {
460
- isValid: false,
461
- reason: 'block_fetch_error'
462
- };
463
- }
464
- if (!lastBlockHeader) {
465
- this.log.warn(`Last block not found for checkpoint proposal`, proposalInfo);
466
- return {
467
- isValid: false,
468
- reason: 'last_block_not_found'
469
- };
470
- }
471
- // Get all full blocks for the slot and checkpoint
472
- const blocks = await this.blockSource.getBlocksForSlot(slot);
473
- if (blocks.length === 0) {
474
- this.log.warn(`No blocks found for slot ${slot}`, proposalInfo);
475
- return {
476
- isValid: false,
477
- reason: 'no_blocks_for_slot'
478
- };
479
- }
480
- // Ensure the last block for this slot matches the archive in the checkpoint proposal
481
- if (!blocks.at(-1)?.archive.root.equals(proposal.archive)) {
482
- this.log.warn(`Last block archive mismatch for checkpoint proposal`, proposalInfo);
483
- return {
484
- isValid: false,
485
- reason: 'last_block_archive_mismatch'
486
- };
487
- }
488
- this.log.debug(`Found ${blocks.length} blocks for slot ${slot}`, {
489
- ...proposalInfo,
490
- blockNumbers: blocks.map((b)=>b.number)
491
- });
492
- // Get checkpoint constants from first block
493
- const firstBlock = blocks[0];
494
- const constants = this.extractCheckpointConstants(firstBlock);
495
- const checkpointNumber = firstBlock.checkpointNumber;
496
- // Get L1-to-L2 messages for this checkpoint
497
- const l1ToL2Messages = await this.l1ToL2MessageSource.getL1ToL2Messages(checkpointNumber);
498
- // Collect the out hashes of all the checkpoints before this one in the same epoch
499
- const epoch = getEpochAtSlot(slot, this.epochCache.getL1Constants());
500
- const previousCheckpointOutHashes = (await this.blockSource.getCheckpointsDataForEpoch(epoch)).filter((c)=>c.checkpointNumber < checkpointNumber).map((c)=>c.checkpointOutHash);
501
- // Fork world state at the block before the first block
502
- const parentBlockNumber = BlockNumber(firstBlock.number - 1);
503
- const fork = await this.worldState.fork(parentBlockNumber);
504
- try {
505
- // Create checkpoint builder with all existing blocks
506
- const checkpointBuilder = await this.checkpointsBuilder.openCheckpoint(checkpointNumber, constants, proposal.feeAssetPriceModifier, l1ToL2Messages, previousCheckpointOutHashes, fork, blocks, this.log.getBindings());
507
- // Complete the checkpoint to get computed values
508
- const computedCheckpoint = await checkpointBuilder.completeCheckpoint();
509
- // Compare checkpoint header with proposal
510
- if (!computedCheckpoint.header.equals(proposal.checkpointHeader)) {
511
- this.log.warn(`Checkpoint header mismatch`, {
512
- ...proposalInfo,
513
- computed: computedCheckpoint.header.toInspect(),
514
- proposal: proposal.checkpointHeader.toInspect()
515
- });
516
- return {
517
- isValid: false,
518
- reason: 'checkpoint_header_mismatch'
519
- };
520
- }
521
- // Compare archive root with proposal
522
- if (!computedCheckpoint.archive.root.equals(proposal.archive)) {
523
- this.log.warn(`Archive root mismatch`, {
524
- ...proposalInfo,
525
- computed: computedCheckpoint.archive.root.toString(),
526
- proposal: proposal.archive.toString()
527
- });
528
- return {
529
- isValid: false,
530
- reason: 'archive_mismatch'
531
- };
532
- }
533
- // Check that the accumulated epoch out hash matches the value in the proposal.
534
- // The epoch out hash is the accumulated hash of all checkpoint out hashes in the epoch.
535
- const checkpointOutHash = computedCheckpoint.getCheckpointOutHash();
536
- const computedEpochOutHash = accumulateCheckpointOutHashes([
537
- ...previousCheckpointOutHashes,
538
- checkpointOutHash
539
- ]);
540
- const proposalEpochOutHash = proposal.checkpointHeader.epochOutHash;
541
- if (!computedEpochOutHash.equals(proposalEpochOutHash)) {
542
- this.log.warn(`Epoch out hash mismatch`, {
543
- proposalEpochOutHash: proposalEpochOutHash.toString(),
544
- computedEpochOutHash: computedEpochOutHash.toString(),
545
- checkpointOutHash: checkpointOutHash.toString(),
546
- previousCheckpointOutHashes: previousCheckpointOutHashes.map((h)=>h.toString()),
547
- ...proposalInfo
548
- });
549
- return {
550
- isValid: false,
551
- reason: 'out_hash_mismatch'
552
- };
553
- }
554
- // Final round of validations on the checkpoint, just in case.
555
- try {
556
- validateCheckpoint(computedCheckpoint, {
557
- rollupManaLimit: this.checkpointsBuilder.getConfig().rollupManaLimit,
558
- maxDABlockGas: this.config.validateMaxDABlockGas,
559
- maxL2BlockGas: this.config.validateMaxL2BlockGas,
560
- maxTxsPerBlock: this.config.validateMaxTxsPerBlock,
561
- maxTxsPerCheckpoint: this.config.validateMaxTxsPerCheckpoint
562
- });
563
- } catch (err) {
564
- this.log.warn(`Checkpoint validation failed: ${err}`, proposalInfo);
565
- return {
566
- isValid: false,
567
- reason: 'checkpoint_validation_failed'
568
- };
569
- }
570
- this.log.verbose(`Checkpoint proposal validation successful for slot ${slot}`, proposalInfo);
571
- return {
572
- isValid: true
573
- };
574
- } finally{
575
- await fork.close();
576
- }
577
- }
578
- /**
579
- * Extract checkpoint global variables from a block.
580
- */ extractCheckpointConstants(block) {
581
- const gv = block.header.globalVariables;
582
- return {
583
- chainId: gv.chainId,
584
- version: gv.version,
585
- slotNumber: gv.slotNumber,
586
- timestamp: gv.timestamp,
587
- coinbase: gv.coinbase,
588
- feeRecipient: gv.feeRecipient,
589
- gasFees: gv.gasFees
590
- };
591
- }
592
- /**
593
430
  * Uploads blobs for a checkpoint to the filestore (fire and forget).
594
431
  */ async uploadBlobsForCheckpoint(proposal, proposalInfo) {
595
432
  try {
@@ -674,7 +511,7 @@ const SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT = [
674
511
  }
675
512
  ]);
676
513
  }
677
- async createBlockProposal(blockHeader, indexWithinCheckpoint, inHash, archive, txs, proposerAddress, options = {}) {
514
+ async createBlockProposal(blockHeader, checkpointNumber, indexWithinCheckpoint, inHash, archive, txs, proposerAddress, options = {}) {
678
515
  // Validate that we're not creating a proposal for an older or equal position
679
516
  if (this.lastProposedBlock) {
680
517
  const lastSlot = this.lastProposedBlock.slotNumber;
@@ -685,14 +522,14 @@ const SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT = [
685
522
  }
686
523
  }
687
524
  this.log.info(`Assembling block proposal for block ${blockHeader.globalVariables.blockNumber} slot ${blockHeader.globalVariables.slotNumber}`);
688
- const newProposal = await this.validationService.createBlockProposal(blockHeader, indexWithinCheckpoint, inHash, archive, txs, proposerAddress, {
525
+ const newProposal = await this.validationService.createBlockProposal(blockHeader, checkpointNumber, indexWithinCheckpoint, inHash, archive, txs, proposerAddress, {
689
526
  ...options,
690
527
  broadcastInvalidBlockProposal: this.config.broadcastInvalidBlockProposal
691
528
  });
692
529
  this.lastProposedBlock = newProposal;
693
530
  return newProposal;
694
531
  }
695
- async createCheckpointProposal(checkpointHeader, archive, feeAssetPriceModifier, lastBlockInfo, proposerAddress, options = {}) {
532
+ async createCheckpointProposal(checkpointHeader, archive, checkpointNumber, feeAssetPriceModifier, lastBlockProposal, proposerAddress, options = {}) {
696
533
  // Validate that we're not creating a proposal for an older or equal slot
697
534
  if (this.lastProposedCheckpoint) {
698
535
  const lastSlot = this.lastProposedCheckpoint.slotNumber;
@@ -702,23 +539,23 @@ const SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT = [
702
539
  }
703
540
  }
704
541
  this.log.info(`Assembling checkpoint proposal for slot ${checkpointHeader.slotNumber}`);
705
- const newProposal = await this.validationService.createCheckpointProposal(checkpointHeader, archive, feeAssetPriceModifier, lastBlockInfo, proposerAddress, options);
542
+ const newProposal = await this.validationService.createCheckpointProposal(checkpointHeader, archive, checkpointNumber, feeAssetPriceModifier, lastBlockProposal, proposerAddress, options);
706
543
  this.lastProposedCheckpoint = newProposal;
707
544
  return newProposal;
708
545
  }
709
546
  async broadcastBlockProposal(proposal) {
710
547
  await this.p2pClient.broadcastProposal(proposal);
711
548
  }
712
- async signAttestationsAndSigners(attestationsAndSigners, proposer, slot, blockNumber) {
713
- return await this.validationService.signAttestationsAndSigners(attestationsAndSigners, proposer, slot, blockNumber);
549
+ async signAttestationsAndSigners(attestationsAndSigners, proposer, slot, checkpointNumber) {
550
+ return await this.validationService.signAttestationsAndSigners(attestationsAndSigners, proposer, slot, checkpointNumber);
714
551
  }
715
- async collectOwnAttestations(proposal) {
552
+ async collectOwnAttestations(proposal, checkpointNumber) {
716
553
  const slot = proposal.slotNumber;
717
554
  const inCommittee = await this.epochCache.filterInCommittee(slot, this.getValidatorAddresses());
718
555
  this.log.debug(`Collecting ${inCommittee.length} self-attestations for slot ${slot}`, {
719
556
  inCommittee
720
557
  });
721
- const attestations = await this.createCheckpointAttestationsFromProposal(proposal, inCommittee);
558
+ const attestations = await this.createCheckpointAttestationsFromProposal(proposal, inCommittee, checkpointNumber);
722
559
  if (!attestations) {
723
560
  return [];
724
561
  }
@@ -730,7 +567,7 @@ const SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT = [
730
567
  });
731
568
  return attestations;
732
569
  }
733
- async collectAttestations(proposal, required, deadline) {
570
+ async collectAttestations(proposal, required, deadline, checkpointNumber) {
734
571
  // Wait and poll the p2pClient's attestation pool for this checkpoint until we have enough attestations
735
572
  const slot = proposal.slotNumber;
736
573
  this.log.debug(`Collecting ${required} attestations for slot ${slot} with deadline ${deadline.toISOString()}`);
@@ -738,7 +575,7 @@ const SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT = [
738
575
  this.log.error(`Deadline ${deadline.toISOString()} for collecting ${required} attestations for slot ${slot} is in the past`);
739
576
  throw new AttestationTimeoutError(0, required, slot);
740
577
  }
741
- await this.collectOwnAttestations(proposal);
578
+ await this.collectOwnAttestations(proposal, checkpointNumber);
742
579
  const proposalId = proposal.archive.toString();
743
580
  const myAddresses = this.getValidatorAddresses();
744
581
  let attestations = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aztec/validator-client",
3
- "version": "0.0.1-commit.5de5ca79e",
3
+ "version": "0.0.1-commit.6201a7b05",
4
4
  "main": "dest/index.js",
5
5
  "type": "module",
6
6
  "exports": {
@@ -64,30 +64,30 @@
64
64
  ]
65
65
  },
66
66
  "dependencies": {
67
- "@aztec/blob-client": "0.0.1-commit.5de5ca79e",
68
- "@aztec/blob-lib": "0.0.1-commit.5de5ca79e",
69
- "@aztec/constants": "0.0.1-commit.5de5ca79e",
70
- "@aztec/epoch-cache": "0.0.1-commit.5de5ca79e",
71
- "@aztec/ethereum": "0.0.1-commit.5de5ca79e",
72
- "@aztec/foundation": "0.0.1-commit.5de5ca79e",
73
- "@aztec/node-keystore": "0.0.1-commit.5de5ca79e",
74
- "@aztec/noir-protocol-circuits-types": "0.0.1-commit.5de5ca79e",
75
- "@aztec/p2p": "0.0.1-commit.5de5ca79e",
76
- "@aztec/protocol-contracts": "0.0.1-commit.5de5ca79e",
77
- "@aztec/prover-client": "0.0.1-commit.5de5ca79e",
78
- "@aztec/simulator": "0.0.1-commit.5de5ca79e",
79
- "@aztec/slasher": "0.0.1-commit.5de5ca79e",
80
- "@aztec/stdlib": "0.0.1-commit.5de5ca79e",
81
- "@aztec/telemetry-client": "0.0.1-commit.5de5ca79e",
82
- "@aztec/validator-ha-signer": "0.0.1-commit.5de5ca79e",
67
+ "@aztec/blob-client": "0.0.1-commit.6201a7b05",
68
+ "@aztec/blob-lib": "0.0.1-commit.6201a7b05",
69
+ "@aztec/constants": "0.0.1-commit.6201a7b05",
70
+ "@aztec/epoch-cache": "0.0.1-commit.6201a7b05",
71
+ "@aztec/ethereum": "0.0.1-commit.6201a7b05",
72
+ "@aztec/foundation": "0.0.1-commit.6201a7b05",
73
+ "@aztec/node-keystore": "0.0.1-commit.6201a7b05",
74
+ "@aztec/noir-protocol-circuits-types": "0.0.1-commit.6201a7b05",
75
+ "@aztec/p2p": "0.0.1-commit.6201a7b05",
76
+ "@aztec/protocol-contracts": "0.0.1-commit.6201a7b05",
77
+ "@aztec/prover-client": "0.0.1-commit.6201a7b05",
78
+ "@aztec/simulator": "0.0.1-commit.6201a7b05",
79
+ "@aztec/slasher": "0.0.1-commit.6201a7b05",
80
+ "@aztec/stdlib": "0.0.1-commit.6201a7b05",
81
+ "@aztec/telemetry-client": "0.0.1-commit.6201a7b05",
82
+ "@aztec/validator-ha-signer": "0.0.1-commit.6201a7b05",
83
83
  "koa": "^2.16.1",
84
84
  "koa-router": "^13.1.1",
85
85
  "tslib": "^2.4.0",
86
86
  "viem": "npm:@aztec/viem@2.38.2"
87
87
  },
88
88
  "devDependencies": {
89
- "@aztec/archiver": "0.0.1-commit.5de5ca79e",
90
- "@aztec/world-state": "0.0.1-commit.5de5ca79e",
89
+ "@aztec/archiver": "0.0.1-commit.6201a7b05",
90
+ "@aztec/world-state": "0.0.1-commit.6201a7b05",
91
91
  "@electric-sql/pglite": "^0.3.14",
92
92
  "@jest/globals": "^30.0.0",
93
93
  "@types/jest": "^30.0.0",
package/src/config.ts CHANGED
@@ -3,6 +3,7 @@ import {
3
3
  booleanConfigHelper,
4
4
  getConfigFromMappings,
5
5
  numberConfigHelper,
6
+ optionalNumberConfigHelper,
6
7
  secretValueConfigHelper,
7
8
  } from '@aztec/foundation/config';
8
9
  import { EthAddress } from '@aztec/foundation/eth-address';
@@ -30,6 +31,12 @@ export const validatorClientConfigMappings: ConfigMappingsType<ValidatorClientCo
30
31
  .map(address => EthAddress.fromString(address.trim())),
31
32
  defaultValue: [],
32
33
  },
34
+ l1ChainId: {
35
+ env: 'L1_CHAIN_ID',
36
+ description: 'The chain ID of the ethereum host.',
37
+ parseEnv: (val: string) => +val,
38
+ defaultValue: 31337,
39
+ },
33
40
  disableValidator: {
34
41
  env: 'VALIDATOR_DISABLED',
35
42
  description: 'Do not run the validator',
@@ -49,11 +56,6 @@ export const validatorClientConfigMappings: ConfigMappingsType<ValidatorClientCo
49
56
  description: 'Interval between polling for new attestations',
50
57
  ...numberConfigHelper(200),
51
58
  },
52
- validatorReexecute: {
53
- env: 'VALIDATOR_REEXECUTE',
54
- description: 'Re-execute transactions before attesting',
55
- ...booleanConfigHelper(true),
56
- },
57
59
  alwaysReexecuteBlockProposals: {
58
60
  description:
59
61
  'Whether to always reexecute block proposals, even for non-validator nodes (useful for monitoring network status).',
@@ -80,22 +82,22 @@ export const validatorClientConfigMappings: ConfigMappingsType<ValidatorClientCo
80
82
  validateMaxL2BlockGas: {
81
83
  env: 'VALIDATOR_MAX_L2_BLOCK_GAS',
82
84
  description: 'Maximum L2 block gas for validation. Proposals exceeding this limit are rejected.',
83
- parseEnv: (val: string) => (val ? parseInt(val, 10) : undefined),
85
+ ...optionalNumberConfigHelper(),
84
86
  },
85
87
  validateMaxDABlockGas: {
86
88
  env: 'VALIDATOR_MAX_DA_BLOCK_GAS',
87
89
  description: 'Maximum DA block gas for validation. Proposals exceeding this limit are rejected.',
88
- parseEnv: (val: string) => (val ? parseInt(val, 10) : undefined),
90
+ ...optionalNumberConfigHelper(),
89
91
  },
90
92
  validateMaxTxsPerBlock: {
91
93
  env: 'VALIDATOR_MAX_TX_PER_BLOCK',
92
94
  description: 'Maximum transactions per block for validation. Proposals exceeding this limit are rejected.',
93
- parseEnv: (val: string) => (val ? parseInt(val, 10) : undefined),
95
+ ...optionalNumberConfigHelper(),
94
96
  },
95
97
  validateMaxTxsPerCheckpoint: {
96
98
  env: 'VALIDATOR_MAX_TX_PER_CHECKPOINT',
97
99
  description: 'Maximum transactions per checkpoint for validation. Proposals exceeding this limit are rejected.',
98
- parseEnv: (val: string) => (val ? parseInt(val, 10) : undefined),
100
+ ...optionalNumberConfigHelper(),
99
101
  },
100
102
  ...localSignerConfigMappings,
101
103
  ...validatorHASignerConfigMappings,