@aztec-labs/validator-client 6.0.0 → 6.1.0-nightly.20261024

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.
@@ -26,6 +26,7 @@ import { retryUntil } from '@aztec-labs/foundation/retry';
26
26
  import { DateProvider, Timer, execWithSignal } from '@aztec-labs/foundation/timer';
27
27
  import { isErrorClass } from '@aztec-labs/foundation/types';
28
28
  import type { P2P, PeerId } from '@aztec-labs/p2p';
29
+ import { AvmProcessDiedError } from '@aztec-labs/simulator/server';
29
30
  import type { BlockData, BlockHash, L2Block, L2BlockSink, L2BlockSource } from '@aztec-labs/stdlib/block';
30
31
  import type { Checkpoint, CheckpointReexecutionTracker, ReexecutionOutcome } from '@aztec-labs/stdlib/checkpoint';
31
32
  import {
@@ -69,6 +70,7 @@ import {
69
70
  checkInboxEndpoint,
70
71
  } from './checkpoint_endpoint_check.js';
71
72
  import { warnCommitteeNotStable } from './committee_not_stable.js';
73
+ import { type InvalidBlockVerdict, checkpointCommitsToRejectedBlock } from './invalid_checkpoint_evidence.js';
72
74
  import type { ValidatorMetrics } from './metrics.js';
73
75
  import {
74
76
  type StreamingBlockCheckReason,
@@ -98,6 +100,8 @@ export type BlockProposalValidationFailureReason =
98
100
  | 'failed_txs'
99
101
  | 'initial_state_mismatch'
100
102
  | 'timeout'
103
+ // This node's AVM simulator process died while re-executing, so re-execution reached no verdict on the block.
104
+ | 'simulator_failure'
101
105
  | 'block_proposal_beyond_checkpoint'
102
106
  | 'checkpoint_proposal_equivocation'
103
107
  | 'unknown_error';
@@ -120,6 +124,11 @@ export type BlockProposalValidationFailureResult = {
120
124
  reason: BlockProposalValidationFailureReason;
121
125
  blockNumber?: BlockNumber;
122
126
  reexecutionResult?: ReexecuteTransactionsResult;
127
+ // Set only for an archive-only state_mismatch (the re-executed header matched, the claimed archive did not), which
128
+ // binds only when the block is the committed sequence's last and its wrong archive is the signed one. Every other
129
+ // header-committing reason is bound by HEADER_BOUND_BLOCK_REASONS without a per-result flag. See recordVerdictIfBound
130
+ // and checkpointCommitsToRejectedBlock.
131
+ headerBoundVerdict?: { headerMismatch: boolean; archiveMismatch: boolean };
123
132
  };
124
133
 
125
134
  export type BlockProposalValidationResult = BlockProposalValidationSuccessResult | BlockProposalValidationFailureResult;
@@ -269,6 +278,8 @@ type LocatedCheckpointBlocks = {
269
278
  firstBlock: L2Block;
270
279
  /** The first block's checkpoint number, which every failure after the blocks are located reports. */
271
280
  checkpointNumber: CheckpointNumber;
281
+ /** Blocks of the same slot this node already stored after the one carrying the signed archive. */
282
+ laterBlockNumbers: BlockNumber[];
272
283
  };
273
284
 
274
285
  /** Everything the checkpoint rebuild consumes besides the fork: the arguments `openCheckpoint` takes. */
@@ -418,12 +429,36 @@ export const SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT: Record<BlockProposalVal
418
429
  ['txs_not_available']: false,
419
430
  ['initial_state_mismatch']: false,
420
431
  ['timeout']: false,
432
+ ['simulator_failure']: false,
421
433
  ['block_proposal_beyond_checkpoint']: false,
422
434
  // Equivocation has its own offense path (markProposalEquivocation), so it is not a slashable invalid-block reason.
423
435
  ['checkpoint_proposal_equivocation']: false,
424
436
  ['unknown_error']: false,
425
437
  };
426
438
 
439
+ /**
440
+ * Slashable block-proposal rejections that always invalidate the block the signed header commits to, so a checkpoint
441
+ * whose committed sequence contains that header is bound to it by header membership. Only rejections that follow from
442
+ * the signed header and its parent are listed: the embedded-tx-body reasons (invalid_embedded_txs, failed_txs,
443
+ * duplicate_txs) are excluded because those tx bodies sit outside both the header and the checkpoint's signed payload,
444
+ * so a node that rejects for one of them cannot prove the checkpoint invalid to its honest signers.
445
+ *
446
+ * Rejections that depend on the proposal's indexWithinCheckpoint are excluded too: the index is signed in the block
447
+ * proposal but not committed to by the checkpoint, so a proposer can re-sign a valid header under a wrong index, get it
448
+ * rejected, and then commit the same header at its true index in a valid checkpoint. That covers the invalid_proposal
449
+ * slot checks (which check applies is chosen by the index) and checkpoint_over_msg_cap (the index picks the
450
+ * checkpoint's starting message count). global_variables_mismatch stays: it needs the header's slot to equal its
451
+ * parent's, which no index makes valid. state_mismatch is not listed: a re-executed header mismatch depends on the
452
+ * proposal's tx list, which the checkpoint does not sign; only its archive-only form binds, through a per-result
453
+ * headerBoundVerdict. See recordVerdictIfBound.
454
+ */
455
+ const HEADER_BOUND_BLOCK_REASONS: ReadonlySet<BlockProposalValidationFailureReason> = new Set([
456
+ 'parent_block_wrong_slot',
457
+ 'global_variables_mismatch',
458
+ 'consumption_moves_backwards',
459
+ 'bundle_over_block_cap',
460
+ ]);
461
+
427
462
  /** Checkpoint-proposal validation failures that constitute a slashable invalid-checkpoint offense. */
428
463
  export const SLASHABLE_CHECKPOINT_PROPOSAL_VALIDATION_RESULT: Record<
429
464
  CheckpointProposalValidationFailureReason,
@@ -479,6 +514,17 @@ function isSlashableCheckpointProposalResult(
479
514
  return !result.isValid && SLASHABLE_CHECKPOINT_PROPOSAL_VALIDATION_RESULT[result.reason];
480
515
  }
481
516
 
517
+ /**
518
+ * Whether a checkpoint-proposal rejection is evidence against the attesters of its payload, not only its proposer.
519
+ * last_block_archive_mismatch is not: this node already holds later blocks of the slot, and an attester that had not
520
+ * received them yet would rightly find the same payload valid.
521
+ */
522
+ function accusesCheckpointAttesters(
523
+ result: CheckpointProposalValidationResult,
524
+ ): result is CheckpointProposalValidationFailureResult {
525
+ return isSlashableCheckpointProposalResult(result) && result.reason !== 'last_block_archive_mismatch';
526
+ }
527
+
482
528
  /**
483
529
  * Handles block and checkpoint proposals for both validator and non-validator nodes. Also tracks which slots
484
530
  * had a slashable invalid proposal or a proposal equivocation, exposing them via the
@@ -532,6 +578,13 @@ export class ProposalHandler {
532
578
  */
533
579
  private readonly invalidCheckpointProposalHashesBySlot = new Map<SlotNumber, Set<CheckpointProposalHash>>();
534
580
 
581
+ /**
582
+ * Per-proposal verdicts for block proposals this node rejected for a payload-committing reason, per slot. Read when
583
+ * a checkpoint bails at last_block_not_found, to decide whether it commits to one of those rejected blocks (see
584
+ * checkpointCommitsToRejectedBlock). Bounded like invalidCheckpointProposalHashesBySlot (oldest slot evicted).
585
+ */
586
+ private readonly invalidBlockVerdictsBySlot = new Map<SlotNumber, InvalidBlockVerdict[]>();
587
+
535
588
  constructor(
536
589
  private checkpointsBuilder: FullNodeCheckpointsBuilder,
537
590
  private worldState: WorldStateSynchronizer,
@@ -578,9 +631,18 @@ export class ProposalHandler {
578
631
  * This is the one path that records a `valid` outcome without running the live Inbox endpoint gate: the
579
632
  * checkpoint ends at the bucket end its own sequencer resolved against the Inbox when it built the last block,
580
633
  * so the evidence exists — it was gathered while building rather than while validating.
634
+ *
635
+ * `lastArchiveRoot` is the archive root of the parent checkpoint the proposal builds on, and `payloadHash` the hash
636
+ * of the signed payload as broadcast, which is what attestors sign.
581
637
  */
582
- public recordOwnCheckpointProposalAsValid(slot: SlotNumber, archive: Fr, checkpointNumber: CheckpointNumber): void {
583
- this.reexecutionTracker.recordOutcome(slot, archive, 'valid', checkpointNumber);
638
+ public recordOwnCheckpointProposalAsValid(
639
+ slot: SlotNumber,
640
+ archive: Fr,
641
+ checkpointNumber: CheckpointNumber,
642
+ lastArchiveRoot: Fr,
643
+ payloadHash: CheckpointProposalHash,
644
+ ): void {
645
+ this.reexecutionTracker.recordOutcome(slot, archive, 'valid', checkpointNumber, { lastArchiveRoot, payloadHash });
584
646
  }
585
647
 
586
648
  /**
@@ -665,6 +727,84 @@ export class ProposalHandler {
665
727
  return [...(this.invalidCheckpointProposalHashesBySlot.get(slotNumber) ?? [])];
666
728
  }
667
729
 
730
+ /**
731
+ * Records a per-block verdict for a block proposal this node rejected for a reason that invalidates the block's
732
+ * signed header on its own (a header mismatch), or whose re-executed header matched but whose claimed resulting
733
+ * archive did not (an archive-only mismatch), so a checkpoint that commits to the block can later be bound to it.
734
+ * Bounded like the other per-slot stores (oldest slot evicted).
735
+ */
736
+ private recordInvalidBlockVerdict(slotNumber: SlotNumber, verdict: InvalidBlockVerdict): void {
737
+ let verdicts = this.invalidBlockVerdictsBySlot.get(slotNumber);
738
+ if (!verdicts) {
739
+ verdicts = [];
740
+ this.invalidBlockVerdictsBySlot.set(slotNumber, verdicts);
741
+ while (this.invalidBlockVerdictsBySlot.size > MAX_TRACKED_INVALID_PROPOSAL_SLOTS) {
742
+ const oldest = this.invalidBlockVerdictsBySlot.keys().next().value;
743
+ if (oldest === undefined) {
744
+ break;
745
+ }
746
+ this.invalidBlockVerdictsBySlot.delete(oldest);
747
+ }
748
+ }
749
+ verdicts.push(verdict);
750
+ }
751
+
752
+ /**
753
+ * Records a per-block verdict for a rejection that invalidates the block's signed header, so a checkpoint whose
754
+ * committed sequence contains that header can later be bound to it. Called once per proposal on the final result -
755
+ * after the parent-pruned demotion, which turns the reason non-slashable, so a demoted rejection records nothing.
756
+ * The shape comes from the result's own headerBoundVerdict (an archive-only state_mismatch) or, for the other
757
+ * header-committing reasons, from HEADER_BOUND_BLOCK_REASONS. A slashable reason that is neither (invalid_proposal,
758
+ * checkpoint_over_msg_cap, a state_mismatch whose re-executed header differs, or an embedded-tx-body reason) records
759
+ * nothing.
760
+ */
761
+ private recordVerdictIfBound(proposal: BlockProposal, result: BlockProposalValidationResult): void {
762
+ if (result.isValid || !SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT[result.reason]) {
763
+ return;
764
+ }
765
+ const shape =
766
+ result.headerBoundVerdict ??
767
+ (HEADER_BOUND_BLOCK_REASONS.has(result.reason) ? { headerMismatch: true, archiveMismatch: false } : undefined);
768
+ if (!shape) {
769
+ return;
770
+ }
771
+ this.recordInvalidBlockVerdict(proposal.slotNumber, {
772
+ blockHeader: proposal.blockHeader,
773
+ archiveRoot: proposal.archive,
774
+ ...shape,
775
+ });
776
+ }
777
+
778
+ /**
779
+ * When a checkpoint could not be validated because the block carrying its signed archive is not local
780
+ * (last_block_not_found), it may still commit to a block this node rejected. Records the invalid-checkpoint
781
+ * payload hash (so the watcher slashes its attesters) only when the rejection is provably bound to the signed
782
+ * payload; see checkpointCommitsToRejectedBlock. Missing evidence is never guilt, so an unbound or
783
+ * unreconstructable case records nothing.
784
+ */
785
+ private async recordInvalidCheckpointIfBoundToRejectedBlock(
786
+ proposal: CheckpointProposalCore,
787
+ proposalInfo: LogData,
788
+ ): Promise<void> {
789
+ const verdicts = this.invalidBlockVerdictsBySlot.get(proposal.slotNumber);
790
+ if (!verdicts || verdicts.length === 0 || !this.p2pClient) {
791
+ return;
792
+ }
793
+ const { blockProposals } = await this.p2pClient.getProposalsForSlot(proposal.slotNumber);
794
+ // A rejected block the checkpoint's signed payload names directly: its header is in the committed sequence, or
795
+ // its wrong archive is the signed archive. A rejection the payload does not commit to records nothing, so a few
796
+ // lazy attesters go unpunished for a corruption only a full rebuild could catch - and honest nodes cannot
797
+ // validate that checkpoint either, while the bad block's proposer is still slashed on the block path.
798
+ if (await checkpointCommitsToRejectedBlock(proposal, blockProposals, verdicts)) {
799
+ this.log.warn(`Checkpoint commits to a block this node rejected; recording invalid-checkpoint evidence`, {
800
+ ...proposalInfo,
801
+ slot: proposal.slotNumber,
802
+ });
803
+ this.markInvalidProposalSlot(proposal.slotNumber);
804
+ this.markInvalidCheckpointProposal(proposal.slotNumber, proposal.getPayloadHash());
805
+ }
806
+ }
807
+
668
808
  /**
669
809
  * Registers handlers for block and checkpoint proposals on the p2p client.
670
810
  * Records the p2p client so validation can inspect retained proposals.
@@ -801,7 +941,7 @@ export class ProposalHandler {
801
941
  // Track invalid checkpoint proposals so offense observers (the attested-invalid-proposal watcher)
802
942
  // work on non-validator nodes too. This handler runs for all nodes; validators also mark via the
803
943
  // failure callback below (idempotent).
804
- if (isSlashableCheckpointProposalResult(result)) {
944
+ if (accusesCheckpointAttesters(result)) {
805
945
  this.markInvalidProposalSlot(proposal.slotNumber);
806
946
  this.markInvalidCheckpointProposal(proposal.slotNumber, proposal.getPayloadHash());
807
947
  }
@@ -905,9 +1045,14 @@ export class ProposalHandler {
905
1045
  proposalInfo,
906
1046
  );
907
1047
  // A genesis parent cannot be pruned.
908
- return parentBlock !== 'genesis' && isSlashableBlockProposalResult(result)
909
- ? await this.checkParentStillLocal(proposal, result, proposalInfo)
910
- : result;
1048
+ const finalResult =
1049
+ parentBlock !== 'genesis' && isSlashableBlockProposalResult(result)
1050
+ ? await this.checkParentStillLocal(proposal, result, proposalInfo)
1051
+ : result;
1052
+ // Record the checkpoint-attester verdict only on the final classification: checkParentStillLocal may demote a
1053
+ // slashable rejection to the non-slashable parent_block_pruned_during_validation, which then records nothing.
1054
+ this.recordVerdictIfBound(proposal, finalResult);
1055
+ return finalResult;
911
1056
  }
912
1057
 
913
1058
  /**
@@ -1061,7 +1206,22 @@ export class ProposalHandler {
1061
1206
  } catch (error) {
1062
1207
  this.log.error(`Error reexecuting txs while processing block proposal`, error, proposalInfo);
1063
1208
  const reason = await this.classifyReexecutionFailure(error, proposal, streamingMetadata, proposalInfo);
1064
- return { isValid: false, blockNumber, reason, reexecutionResult };
1209
+ const failure: BlockProposalValidationFailureResult = { isValid: false, blockNumber, reason, reexecutionResult };
1210
+ // Only an archive-only mismatch is evidence against a committing checkpoint. Re-execution runs the proposal's own
1211
+ // tx list, which the checkpoint does not sign, so a header mismatch shows only that those txs do not produce the
1212
+ // header: the same header may be valid for the txs honest attesters received. With the header matching, the
1213
+ // resulting archive follows from the header and its parent alone, so a wrong one is wrong for every node. The
1214
+ // caller records on the final result, so a local-view demotion (inbox_prefix_*, not slashable) or a parent-pruned
1215
+ // demotion leaves no attester evidence.
1216
+ if (
1217
+ error instanceof ReExStateMismatchError &&
1218
+ SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT[reason] &&
1219
+ !error.headerMismatch &&
1220
+ error.archiveMismatch
1221
+ ) {
1222
+ failure.headerBoundVerdict = { headerMismatch: false, archiveMismatch: true };
1223
+ }
1224
+ return failure;
1065
1225
  }
1066
1226
 
1067
1227
  // If we succeeded, push this block into the archiver (unless disabled), carrying the proposal's signed Inbox
@@ -1421,6 +1581,8 @@ export class ProposalHandler {
1421
1581
  return 'failed_txs';
1422
1582
  } else if (err instanceof ReExTimeoutError) {
1423
1583
  return 'timeout';
1584
+ } else if (isErrorClass(err, AvmProcessDiedError)) {
1585
+ return 'simulator_failure';
1424
1586
  } else {
1425
1587
  return 'unknown_error';
1426
1588
  }
@@ -1911,7 +2073,7 @@ export class ProposalHandler {
1911
2073
  actualHeader: proposal.blockHeader.toInspect(),
1912
2074
  });
1913
2075
  this.metrics?.recordFailedReexecution(proposal);
1914
- throw new ReExStateMismatchError(proposal.archive, block.archive.root);
2076
+ throw new ReExStateMismatchError(proposal.archive, block.archive.root, !headerMatches, !archiveMatches);
1915
2077
  }
1916
2078
 
1917
2079
  const reexecutionTimeMs = timer.ms();
@@ -2019,7 +2181,10 @@ export class ProposalHandler {
2019
2181
  (result.checkpointNumber !== undefined &&
2020
2182
  this.reexecutionTracker.hasReexecuted(result.checkpointNumber, proposal.archive)));
2021
2183
  if (outcome !== undefined && !wouldForgetVerdict) {
2022
- this.reexecutionTracker.recordOutcome(slot, proposal.archive, outcome, result.checkpointNumber);
2184
+ this.reexecutionTracker.recordOutcome(slot, proposal.archive, outcome, result.checkpointNumber, {
2185
+ lastArchiveRoot: proposal.checkpointHeader.lastArchiveRoot,
2186
+ payloadHash,
2187
+ });
2023
2188
  }
2024
2189
 
2025
2190
  // Drop tracker entries for checkpoints that have reached L1 finality.
@@ -2193,20 +2358,63 @@ export class ProposalHandler {
2193
2358
  }
2194
2359
 
2195
2360
  /**
2196
- * Validates a checkpoint proposal's content by building the full checkpoint and comparing it with the proposal. The
2197
- * stages run in order, each on the previous one's output; the fork stays here so its disposal waits for the
2198
- * comparisons, and so the errors its narrow `try` turns into a verdict stay next to the ones that must escape.
2361
+ * Validates a checkpoint proposal's content against the blocks its signed archive covers. When this node already
2362
+ * stored later blocks of the same slot, the proposal leaves them out: a content failure of the covered blocks is
2363
+ * still reported as such, and anything else, a valid rebuild or a local inability to check included, is reported as
2364
+ * last_block_archive_mismatch.
2199
2365
  */
2200
2366
  private async validateCheckpointContent(
2201
2367
  proposal: CheckpointProposalCore,
2202
2368
  proposalInfo: LogData,
2203
2369
  ): Promise<CheckpointProposalValidationResult> {
2204
- const slot = proposal.slotNumber;
2205
-
2206
2370
  const located = await this.locateCheckpointBlocks(proposal, proposalInfo);
2207
2371
  if (isCheckpointValidationFailure(located)) {
2208
2372
  return located;
2209
2373
  }
2374
+ if (located.laterBlockNumbers.length === 0) {
2375
+ return await this.validateCoveredBlocks(proposal, located, proposalInfo);
2376
+ }
2377
+
2378
+ // A local failure to check the covered blocks, a thrown one included, must not erase the omission: the proposer
2379
+ // is still accountable for leaving out signed blocks, whatever this node could verify about the rest.
2380
+ let coveredBlocksResult: string;
2381
+ try {
2382
+ const result = await this.validateCoveredBlocks(proposal, located, proposalInfo);
2383
+ if (!result.isValid && SLASHABLE_CHECKPOINT_PROPOSAL_VALIDATION_RESULT[result.reason]) {
2384
+ return result;
2385
+ }
2386
+ coveredBlocksResult = result.isValid ? 'valid' : result.reason;
2387
+ } catch (err) {
2388
+ this.log.warn(`Failed to check the covered blocks of a checkpoint proposal that leaves blocks out`, {
2389
+ ...proposalInfo,
2390
+ err,
2391
+ });
2392
+ coveredBlocksResult = 'error';
2393
+ }
2394
+ this.log.warn(`Rejecting checkpoint proposal that leaves later blocks of its slot out`, {
2395
+ ...proposalInfo,
2396
+ coveredBlocksResult,
2397
+ laterBlockNumbers: located.laterBlockNumbers,
2398
+ });
2399
+ return { isValid: false, reason: 'last_block_archive_mismatch', checkpointNumber: located.checkpointNumber };
2400
+ }
2401
+
2402
+ /**
2403
+ * Validates the blocks a checkpoint proposal covers by building the full checkpoint and comparing it with the
2404
+ * proposal. The stages run in order, each on the previous one's output; the fork stays here so its disposal waits
2405
+ * for the comparisons, and so the errors its narrow `try` turns into a verdict stay next to the ones that must escape.
2406
+ */
2407
+ private async validateCoveredBlocks(
2408
+ proposal: CheckpointProposalCore,
2409
+ located: LocatedCheckpointBlocks,
2410
+ proposalInfo: LogData,
2411
+ ): Promise<CheckpointProposalValidationResult> {
2412
+ const slot = proposal.slotNumber;
2413
+
2414
+ const coveredBlocksFailure = this.checkCoveredBlocks(proposal, located, proposalInfo);
2415
+ if (coveredBlocksFailure) {
2416
+ return coveredBlocksFailure;
2417
+ }
2210
2418
  const inputs = await this.awaitCheckpointRebuildInputs(proposal, located, proposalInfo);
2211
2419
  if (isCheckpointValidationFailure(inputs)) {
2212
2420
  return inputs;
@@ -2276,7 +2484,8 @@ export class ProposalHandler {
2276
2484
 
2277
2485
  /**
2278
2486
  * Waits for the checkpoint's blocks to sync, forcing archiver syncs until the slot's attestation deadline, then
2279
- * rejects a checkpoint already on L1, one that leaves later blocks of its own slot out, and one over the block cap.
2487
+ * rejects a checkpoint already on L1. Returns the blocks the signed archive covers, and the later blocks of the same
2488
+ * slot this node already stored.
2280
2489
  */
2281
2490
  private async locateCheckpointBlocks(
2282
2491
  proposal: CheckpointProposalCore,
@@ -2312,6 +2521,7 @@ export class ProposalHandler {
2312
2521
  } catch (err) {
2313
2522
  if (err instanceof TimeoutError) {
2314
2523
  this.log.warn(`Timed out waiting for block with archive matching checkpoint proposal`, proposalInfo);
2524
+ await this.recordInvalidCheckpointIfBoundToRejectedBlock(proposal, proposalInfo);
2315
2525
  return { isValid: false, reason: 'last_block_not_found' };
2316
2526
  }
2317
2527
  this.log.error(`Error fetching last block for checkpoint proposal`, err, proposalInfo);
@@ -2336,20 +2546,35 @@ export class ProposalHandler {
2336
2546
  }
2337
2547
 
2338
2548
  // The signed archive names a block of the slot that is followed by more of the proposer's blocks for the same
2339
- // slot: the proposal leaves signed blocks of its own slot out, which no local race explains.
2340
- if (lastBlockIndex !== blocks.length - 1) {
2341
- this.log.warn(`Last block archive mismatch for checkpoint proposal`, {
2549
+ // slot: the proposal leaves signed blocks of its own slot out. Whether this node stored those blocks before the
2550
+ // proposal arrived is a matter of timing, so the covered blocks are still validated on their own.
2551
+ const coveredBlocks = blocks.slice(0, lastBlockIndex + 1);
2552
+ const laterBlockNumbers = blocks.slice(lastBlockIndex + 1).map(b => b.number);
2553
+ if (laterBlockNumbers.length > 0) {
2554
+ this.log.debug(`Checkpoint proposal leaves later blocks of its slot out`, {
2342
2555
  ...proposalInfo,
2343
2556
  lastBlockNumber: lastBlock.number,
2344
- laterBlockNumbers: blocks.slice(lastBlockIndex + 1).map(b => b.number),
2557
+ laterBlockNumbers,
2345
2558
  });
2346
- return {
2347
- isValid: false,
2348
- reason: 'last_block_archive_mismatch',
2349
- checkpointNumber: lastBlock.checkpointNumber,
2350
- };
2351
2559
  }
2352
2560
 
2561
+ this.log.debug(`Found ${coveredBlocks.length} blocks for slot ${slot}`, {
2562
+ ...proposalInfo,
2563
+ blockNumbers: coveredBlocks.map(b => b.number),
2564
+ });
2565
+
2566
+ const firstBlock = coveredBlocks[0];
2567
+ return { blocks: coveredBlocks, firstBlock, checkpointNumber: firstBlock.checkpointNumber, laterBlockNumbers };
2568
+ }
2569
+
2570
+ /** Rejects a checkpoint over the block cap, or whose header names another last archive than its first block. */
2571
+ private checkCoveredBlocks(
2572
+ proposal: CheckpointProposalCore,
2573
+ located: LocatedCheckpointBlocks,
2574
+ proposalInfo: LogData,
2575
+ ): CheckpointProposalValidationFailureResult | undefined {
2576
+ const { blocks, firstBlock, checkpointNumber } = located;
2577
+
2353
2578
  // The checkpoint root circuit caps how many blocks a checkpoint may contain, and L1 cannot check it when the
2354
2579
  // checkpoint is proposed (`ProposedHeader` carries no block count, only `blockHeadersHash`). An over-cap
2355
2580
  // checkpoint would therefore be accepted on L1 and then be unprovable, forcing an epoch reorg, so validators
@@ -2364,21 +2589,9 @@ export class ProposalHandler {
2364
2589
  blocksInProposal: blocks.length,
2365
2590
  maxBlocksPerCheckpoint,
2366
2591
  });
2367
- return {
2368
- isValid: false,
2369
- reason: 'too_many_blocks_in_checkpoint',
2370
- checkpointNumber: lastBlock.checkpointNumber,
2371
- };
2592
+ return { isValid: false, reason: 'too_many_blocks_in_checkpoint', checkpointNumber };
2372
2593
  }
2373
2594
 
2374
- this.log.debug(`Found ${blocks.length} blocks for slot ${slot}`, {
2375
- ...proposalInfo,
2376
- blockNumbers: blocks.map(b => b.number),
2377
- });
2378
-
2379
- const firstBlock = blocks[0];
2380
- const checkpointNumber = firstBlock.checkpointNumber;
2381
-
2382
2595
  // The rebuild derives the header's lastArchiveRoot from the first block's lastArchive (as does the checkpoint
2383
2596
  // circuit), so any other claimed value is an unprovable header; reject it before the Inbox waits and the rebuild.
2384
2597
  const expectedLastArchiveRoot = firstBlock.header.lastArchive.root;
@@ -2391,7 +2604,7 @@ export class ProposalHandler {
2391
2604
  return { isValid: false, reason: 'last_archive_root_mismatch', checkpointNumber };
2392
2605
  }
2393
2606
 
2394
- return { blocks, firstBlock, checkpointNumber };
2607
+ return undefined;
2395
2608
  }
2396
2609
 
2397
2610
  /**
@@ -2499,10 +2712,11 @@ export class ProposalHandler {
2499
2712
  return { isValid: false, reason: 'out_hash_mismatch', checkpointNumber };
2500
2713
  }
2501
2714
 
2502
- // Final round of validations on the checkpoint, just in case.
2715
+ // Final round of validations on the checkpoint, just in case. The mana limit is the tracker's live value, which can
2716
+ // trail a governance increase on L1 by a polling interval.
2503
2717
  try {
2504
2718
  validateCheckpoint(computedCheckpoint, {
2505
- rollupManaLimit: this.checkpointsBuilder.getConfig().rollupManaLimit,
2719
+ rollupManaLimit: Number(this.checkpointsBuilder.getFeeConfigProvider().getFeeConfig().manaLimit),
2506
2720
  maxDABlockGas: this.config.validateMaxDABlockGas,
2507
2721
  maxL2BlockGas: this.config.validateMaxL2BlockGas,
2508
2722
  maxTxsPerBlock: this.config.validateMaxTxsPerBlock,
package/src/validator.ts CHANGED
@@ -87,7 +87,6 @@ import {
87
87
  // Just cap the set to avoid unbounded growth.
88
88
  const MAX_PROPOSERS_OF_INVALID_BLOCKS = 1000;
89
89
  const MAX_TRACKED_INVALID_CHECKPOINT_PROPOSALS = 1000;
90
- const MAX_TRACKED_BAD_ATTESTATIONS = 10_000;
91
90
 
92
91
  /**
93
92
  * Validator Client
@@ -114,7 +113,6 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
114
113
  private proposersOfInvalidBlocks = FifoSet.withLimit<string>(MAX_PROPOSERS_OF_INVALID_BLOCKS);
115
114
  private invalidCheckpointProposalOffenseKeys = FifoSet.withLimit<string>(MAX_TRACKED_INVALID_CHECKPOINT_PROPOSALS);
116
115
  private oversizedProposalOffenseKeys = FifoSet.withLimit<string>(MAX_TRACKED_INVALID_CHECKPOINT_PROPOSALS);
117
- private badAttestationOffenseKeys = FifoSet.withLimit<string>(MAX_TRACKED_BAD_ATTESTATIONS);
118
116
 
119
117
  /** Tracks the last checkpoint proposal we attested to, to prevent equivocation. */
120
118
  private lastAttestedProposal?: CheckpointProposalCore;
@@ -438,10 +436,6 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
438
436
  this.handleDuplicateAttestation(info);
439
437
  });
440
438
 
441
- this.p2pClient.registerCheckpointAttestationCallback((attestation: CheckpointAttestation) => {
442
- this.handleCheckpointAttestation(attestation);
443
- });
444
-
445
439
  const myAddresses = this.getValidatorAddresses();
446
440
  this.p2pClient.registerThisValidatorAddresses(myAddresses);
447
441
 
@@ -800,8 +794,8 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
800
794
  return;
801
795
  }
802
796
 
803
- // The slot is already marked invalid by the all-nodes checkpoint handler that invokes this callback,
804
- // so we only emit the proposer slash event here.
797
+ // The all-nodes checkpoint handler that invokes this callback already marked the slot when the reason also
798
+ // accuses the attesters, so we only emit the proposer slash event here.
805
799
  if (this.slashInvalidCheckpointProposal(proposal)) {
806
800
  this.log.info(`Detected invalid checkpoint proposal offense`, {
807
801
  ...proposalInfo,
@@ -843,50 +837,6 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
843
837
  this.proposalHandler.markInvalidProposalSlot(slotNumber);
844
838
  }
845
839
 
846
- private handleCheckpointAttestation(attestation: CheckpointAttestation): void {
847
- const slotNumber = attestation.slotNumber;
848
- if (
849
- !this.proposalHandler.hasInvalidProposals(slotNumber) ||
850
- this.proposalHandler.hasProposalEquivocation(slotNumber)
851
- ) {
852
- return;
853
- }
854
-
855
- const attester = attestation.getSender();
856
- if (!attester) {
857
- this.log.warn(`Cannot slash checkpoint attestation with invalid signature`, {
858
- slotNumber,
859
- archive: attestation.archive.toString(),
860
- });
861
- return;
862
- }
863
-
864
- this.slashAttestedToInvalidCheckpointProposal(slotNumber, attester);
865
- }
866
-
867
- private slashAttestedToInvalidCheckpointProposal(slotNumber: SlotNumber, attester: EthAddress): void {
868
- const offenseKey = `${attester.toString()}:${OffenseType.ATTESTED_TO_INVALID_CHECKPOINT_PROPOSAL}:${slotNumber}`;
869
- if (!this.badAttestationOffenseKeys.addIfAbsent(offenseKey)) {
870
- return;
871
- }
872
-
873
- this.log.info(`Detected attestation to invalid checkpoint proposal offense`, {
874
- attester: attester.toString(),
875
- slotNumber,
876
- amount: this.config.slashAttestInvalidCheckpointProposalPenalty,
877
- offenseType: getOffenseTypeName(OffenseType.ATTESTED_TO_INVALID_CHECKPOINT_PROPOSAL),
878
- });
879
-
880
- this.emit(WANT_TO_SLASH_EVENT, [
881
- {
882
- validator: attester,
883
- amount: this.config.slashAttestInvalidCheckpointProposalPenalty,
884
- offenseType: OffenseType.ATTESTED_TO_INVALID_CHECKPOINT_PROPOSAL,
885
- epochOrSlot: BigInt(slotNumber),
886
- },
887
- ]);
888
- }
889
-
890
840
  /**
891
841
  * Handle detection of an oversized block proposal: one whose index within its checkpoint lands at or
892
842
  * beyond the consensus per-checkpoint block limit. A single signed proposal at an illegal index is
@@ -1048,7 +998,13 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
1048
998
  // inactive. We pass the locally-computed `archive` (not `newProposal.archive`, which may
1049
999
  // be intentionally corrupted under test-only flags); from the proposer's local-view
1050
1000
  // perspective the work it just completed is valid by definition.
1051
- this.proposalHandler.recordOwnCheckpointProposalAsValid(checkpointHeader.slotNumber, archive, checkpointNumber);
1001
+ this.proposalHandler.recordOwnCheckpointProposalAsValid(
1002
+ checkpointHeader.slotNumber,
1003
+ archive,
1004
+ checkpointNumber,
1005
+ checkpointHeader.lastArchiveRoot,
1006
+ newProposal.getPayloadHash(),
1007
+ );
1052
1008
  return newProposal;
1053
1009
  }
1054
1010