@aztec/validator-client 0.0.1-commit.03f7ef2 → 0.0.1-commit.08c5969dc

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.
Files changed (69) hide show
  1. package/README.md +285 -0
  2. package/dest/block_proposal_handler.d.ts +20 -10
  3. package/dest/block_proposal_handler.d.ts.map +1 -1
  4. package/dest/block_proposal_handler.js +337 -81
  5. package/dest/checkpoint_builder.d.ts +66 -0
  6. package/dest/checkpoint_builder.d.ts.map +1 -0
  7. package/dest/checkpoint_builder.js +173 -0
  8. package/dest/config.d.ts +1 -1
  9. package/dest/config.d.ts.map +1 -1
  10. package/dest/config.js +16 -8
  11. package/dest/duties/validation_service.d.ts +41 -12
  12. package/dest/duties/validation_service.d.ts.map +1 -1
  13. package/dest/duties/validation_service.js +109 -26
  14. package/dest/factory.d.ts +13 -10
  15. package/dest/factory.d.ts.map +1 -1
  16. package/dest/factory.js +2 -2
  17. package/dest/index.d.ts +3 -1
  18. package/dest/index.d.ts.map +1 -1
  19. package/dest/index.js +2 -0
  20. package/dest/key_store/ha_key_store.d.ts +99 -0
  21. package/dest/key_store/ha_key_store.d.ts.map +1 -0
  22. package/dest/key_store/ha_key_store.js +208 -0
  23. package/dest/key_store/index.d.ts +2 -1
  24. package/dest/key_store/index.d.ts.map +1 -1
  25. package/dest/key_store/index.js +1 -0
  26. package/dest/key_store/interface.d.ts +36 -6
  27. package/dest/key_store/interface.d.ts.map +1 -1
  28. package/dest/key_store/local_key_store.d.ts +10 -5
  29. package/dest/key_store/local_key_store.d.ts.map +1 -1
  30. package/dest/key_store/local_key_store.js +8 -4
  31. package/dest/key_store/node_keystore_adapter.d.ts +18 -5
  32. package/dest/key_store/node_keystore_adapter.d.ts.map +1 -1
  33. package/dest/key_store/node_keystore_adapter.js +18 -4
  34. package/dest/key_store/web3signer_key_store.d.ts +10 -5
  35. package/dest/key_store/web3signer_key_store.d.ts.map +1 -1
  36. package/dest/key_store/web3signer_key_store.js +8 -4
  37. package/dest/metrics.d.ts +4 -3
  38. package/dest/metrics.d.ts.map +1 -1
  39. package/dest/metrics.js +34 -30
  40. package/dest/tx_validator/index.d.ts +3 -0
  41. package/dest/tx_validator/index.d.ts.map +1 -0
  42. package/dest/tx_validator/index.js +2 -0
  43. package/dest/tx_validator/nullifier_cache.d.ts +14 -0
  44. package/dest/tx_validator/nullifier_cache.d.ts.map +1 -0
  45. package/dest/tx_validator/nullifier_cache.js +24 -0
  46. package/dest/tx_validator/tx_validator_factory.d.ts +19 -0
  47. package/dest/tx_validator/tx_validator_factory.d.ts.map +1 -0
  48. package/dest/tx_validator/tx_validator_factory.js +54 -0
  49. package/dest/validator.d.ts +66 -23
  50. package/dest/validator.d.ts.map +1 -1
  51. package/dest/validator.js +415 -78
  52. package/package.json +21 -13
  53. package/src/block_proposal_handler.ts +258 -49
  54. package/src/checkpoint_builder.ts +314 -0
  55. package/src/config.ts +15 -7
  56. package/src/duties/validation_service.ts +153 -31
  57. package/src/factory.ts +17 -11
  58. package/src/index.ts +2 -0
  59. package/src/key_store/ha_key_store.ts +269 -0
  60. package/src/key_store/index.ts +1 -0
  61. package/src/key_store/interface.ts +44 -5
  62. package/src/key_store/local_key_store.ts +13 -4
  63. package/src/key_store/node_keystore_adapter.ts +27 -4
  64. package/src/key_store/web3signer_key_store.ts +17 -4
  65. package/src/metrics.ts +45 -33
  66. package/src/tx_validator/index.ts +2 -0
  67. package/src/tx_validator/nullifier_cache.ts +30 -0
  68. package/src/tx_validator/tx_validator_factory.ts +154 -0
  69. package/src/validator.ts +566 -114
package/src/validator.ts CHANGED
@@ -1,33 +1,60 @@
1
- import type { FileStoreBlobClient } from '@aztec/blob-client/filestore';
2
- import { getBlobsPerL1Block } from '@aztec/blob-lib';
1
+ import type { BlobClientInterface } from '@aztec/blob-client/client';
2
+ import { type Blob, getBlobsPerL1Block } from '@aztec/blob-lib';
3
3
  import type { EpochCache } from '@aztec/epoch-cache';
4
- import { BlockNumber, EpochNumber } from '@aztec/foundation/branded-types';
4
+ import {
5
+ BlockNumber,
6
+ CheckpointNumber,
7
+ EpochNumber,
8
+ IndexWithinCheckpoint,
9
+ SlotNumber,
10
+ } from '@aztec/foundation/branded-types';
5
11
  import { Fr } from '@aztec/foundation/curves/bn254';
12
+ import { TimeoutError } from '@aztec/foundation/error';
6
13
  import type { EthAddress } from '@aztec/foundation/eth-address';
7
14
  import type { Signature } from '@aztec/foundation/eth-signature';
8
- import { type Logger, createLogger } from '@aztec/foundation/log';
15
+ import { type LogData, type Logger, createLogger } from '@aztec/foundation/log';
16
+ import { retryUntil } from '@aztec/foundation/retry';
9
17
  import { RunningPromise } from '@aztec/foundation/running-promise';
10
18
  import { sleep } from '@aztec/foundation/sleep';
11
19
  import { DateProvider } from '@aztec/foundation/timer';
12
20
  import type { KeystoreManager } from '@aztec/node-keystore';
13
- import type { P2P, PeerId, TxProvider } from '@aztec/p2p';
21
+ import type { DuplicateAttestationInfo, DuplicateProposalInfo, P2P, PeerId } from '@aztec/p2p';
14
22
  import { AuthRequest, AuthResponse, BlockProposalValidator, ReqRespSubProtocol } from '@aztec/p2p';
15
23
  import { OffenseType, WANT_TO_SLASH_EVENT, type Watcher, type WatcherEmitter } from '@aztec/slasher';
16
24
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
17
- import type { CommitteeAttestationsAndSigners, L2BlockSource } from '@aztec/stdlib/block';
18
- import type { IFullNodeBlockBuilder, Validator, ValidatorClientFullConfig } from '@aztec/stdlib/interfaces/server';
19
- import type { L1ToL2MessageSource } from '@aztec/stdlib/messaging';
20
- import type { BlockAttestation, BlockProposal, BlockProposalOptions } from '@aztec/stdlib/p2p';
25
+ import type { CommitteeAttestationsAndSigners, L2Block, L2BlockSink, L2BlockSource } from '@aztec/stdlib/block';
26
+ import { getEpochAtSlot } from '@aztec/stdlib/epoch-helpers';
27
+ import type {
28
+ CreateCheckpointProposalLastBlockData,
29
+ ITxProvider,
30
+ Validator,
31
+ ValidatorClientFullConfig,
32
+ WorldStateSynchronizer,
33
+ } from '@aztec/stdlib/interfaces/server';
34
+ import { type L1ToL2MessageSource, accumulateCheckpointOutHashes } from '@aztec/stdlib/messaging';
35
+ import {
36
+ type BlockProposal,
37
+ type BlockProposalOptions,
38
+ type CheckpointAttestation,
39
+ CheckpointProposal,
40
+ type CheckpointProposalCore,
41
+ type CheckpointProposalOptions,
42
+ } from '@aztec/stdlib/p2p';
21
43
  import type { CheckpointHeader } from '@aztec/stdlib/rollup';
22
- import type { Tx } from '@aztec/stdlib/tx';
44
+ import type { BlockHeader, CheckpointGlobalVariables, Tx } from '@aztec/stdlib/tx';
23
45
  import { AttestationTimeoutError } from '@aztec/stdlib/validators';
24
46
  import { type TelemetryClient, type Tracer, getTelemetryClient } from '@aztec/telemetry-client';
47
+ import { createHASigner } from '@aztec/validator-ha-signer/factory';
48
+ import { DutyType, type SigningContext } from '@aztec/validator-ha-signer/types';
25
49
 
26
50
  import { EventEmitter } from 'events';
27
51
  import type { TypedDataDefinition } from 'viem';
28
52
 
29
53
  import { BlockProposalHandler, type BlockProposalValidationFailureReason } from './block_proposal_handler.js';
54
+ import type { FullNodeCheckpointsBuilder } from './checkpoint_builder.js';
30
55
  import { ValidationService } from './duties/validation_service.js';
56
+ import { HAKeyStore } from './key_store/ha_key_store.js';
57
+ import type { ExtendedValidatorKeyStore } from './key_store/interface.js';
31
58
  import { NodeKeystoreAdapter } from './key_store/node_keystore_adapter.js';
32
59
  import { ValidatorMetrics } from './metrics.js';
33
60
 
@@ -53,21 +80,31 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
53
80
  // Whether it has already registered handlers on the p2p client
54
81
  private hasRegisteredHandlers = false;
55
82
 
56
- // Used to check if we are sending the same proposal twice
57
- private previousProposal?: BlockProposal;
83
+ /** Tracks the last block proposal we created, to detect duplicate proposal attempts. */
84
+ private lastProposedBlock?: BlockProposal;
85
+
86
+ /** Tracks the last checkpoint proposal we created. */
87
+ private lastProposedCheckpoint?: CheckpointProposal;
58
88
 
59
89
  private lastEpochForCommitteeUpdateLoop: EpochNumber | undefined;
60
90
  private epochCacheUpdateLoop: RunningPromise;
61
91
 
62
92
  private proposersOfInvalidBlocks: Set<string> = new Set();
63
93
 
94
+ /** Tracks the last checkpoint proposal we attested to, to prevent equivocation. */
95
+ private lastAttestedProposal?: CheckpointProposalCore;
96
+
64
97
  protected constructor(
65
- private keyStore: NodeKeystoreAdapter,
98
+ private keyStore: ExtendedValidatorKeyStore,
66
99
  private epochCache: EpochCache,
67
100
  private p2pClient: P2P,
68
101
  private blockProposalHandler: BlockProposalHandler,
102
+ private blockSource: L2BlockSource,
103
+ private checkpointsBuilder: FullNodeCheckpointsBuilder,
104
+ private worldState: WorldStateSynchronizer,
105
+ private l1ToL2MessageSource: L1ToL2MessageSource,
69
106
  private config: ValidatorClientFullConfig,
70
- private fileStoreBlobUploadClient: FileStoreBlobClient | undefined,
107
+ private blobClient: BlobClientInterface,
71
108
  private dateProvider: DateProvider = new DateProvider(),
72
109
  telemetry: TelemetryClient = getTelemetryClient(),
73
110
  log = createLogger('validator'),
@@ -141,16 +178,17 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
141
178
  }
142
179
  }
143
180
 
144
- static new(
181
+ static async new(
145
182
  config: ValidatorClientFullConfig,
146
- blockBuilder: IFullNodeBlockBuilder,
183
+ checkpointsBuilder: FullNodeCheckpointsBuilder,
184
+ worldState: WorldStateSynchronizer,
147
185
  epochCache: EpochCache,
148
186
  p2pClient: P2P,
149
- blockSource: L2BlockSource,
187
+ blockSource: L2BlockSource & L2BlockSink,
150
188
  l1ToL2MessageSource: L1ToL2MessageSource,
151
- txProvider: TxProvider,
189
+ txProvider: ITxProvider,
152
190
  keyStoreManager: KeystoreManager,
153
- fileStoreBlobUploadClient?: FileStoreBlobClient,
191
+ blobClient: BlobClientInterface,
154
192
  dateProvider: DateProvider = new DateProvider(),
155
193
  telemetry: TelemetryClient = getTelemetryClient(),
156
194
  ) {
@@ -159,24 +197,41 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
159
197
  txsPermitted: !config.disableTransactions,
160
198
  });
161
199
  const blockProposalHandler = new BlockProposalHandler(
162
- blockBuilder,
200
+ checkpointsBuilder,
201
+ worldState,
163
202
  blockSource,
164
203
  l1ToL2MessageSource,
165
204
  txProvider,
166
205
  blockProposalValidator,
206
+ epochCache,
167
207
  config,
168
208
  metrics,
169
209
  dateProvider,
170
210
  telemetry,
171
211
  );
172
212
 
213
+ let validatorKeyStore: ExtendedValidatorKeyStore = NodeKeystoreAdapter.fromKeyStoreManager(keyStoreManager);
214
+ if (config.haSigningEnabled) {
215
+ // If maxStuckDutiesAgeMs is not explicitly set, compute it from Aztec slot duration
216
+ const haConfig = {
217
+ ...config,
218
+ maxStuckDutiesAgeMs: config.maxStuckDutiesAgeMs ?? epochCache.getL1Constants().slotDuration * 2 * 1000,
219
+ };
220
+ const { signer } = await createHASigner(haConfig);
221
+ validatorKeyStore = new HAKeyStore(validatorKeyStore, signer);
222
+ }
223
+
173
224
  const validator = new ValidatorClient(
174
- NodeKeystoreAdapter.fromKeyStoreManager(keyStoreManager),
225
+ validatorKeyStore,
175
226
  epochCache,
176
227
  p2pClient,
177
228
  blockProposalHandler,
229
+ blockSource,
230
+ checkpointsBuilder,
231
+ worldState,
232
+ l1ToL2MessageSource,
178
233
  config,
179
- fileStoreBlobUploadClient,
234
+ blobClient,
180
235
  dateProvider,
181
236
  telemetry,
182
237
  );
@@ -194,18 +249,8 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
194
249
  return this.blockProposalHandler;
195
250
  }
196
251
 
197
- // Proxy method for backwards compatibility with tests
198
- public reExecuteTransactions(
199
- proposal: BlockProposal,
200
- blockNumber: BlockNumber,
201
- txs: any[],
202
- l1ToL2Messages: Fr[],
203
- ): Promise<any> {
204
- return this.blockProposalHandler.reexecuteTransactions(proposal, blockNumber, txs, l1ToL2Messages);
205
- }
206
-
207
- public signWithAddress(addr: EthAddress, msg: TypedDataDefinition) {
208
- return this.keyStore.signTypedDataWithAddress(addr, msg);
252
+ public signWithAddress(addr: EthAddress, msg: TypedDataDefinition, context: SigningContext) {
253
+ return this.keyStore.signTypedDataWithAddress(addr, msg, context);
209
254
  }
210
255
 
211
256
  public getCoinbaseForAttestor(attestor: EthAddress): EthAddress {
@@ -230,6 +275,8 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
230
275
  return;
231
276
  }
232
277
 
278
+ await this.keyStore.start();
279
+
233
280
  await this.registerHandlers();
234
281
 
235
282
  const myAddresses = this.getValidatorAddresses();
@@ -245,6 +292,7 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
245
292
 
246
293
  public async stop() {
247
294
  await this.epochCacheUpdateLoop.stop();
295
+ await this.keyStore.stop();
248
296
  }
249
297
 
250
298
  /** Register handlers on the p2p client */
@@ -253,9 +301,29 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
253
301
  this.hasRegisteredHandlers = true;
254
302
  this.log.debug(`Registering validator handlers for p2p client`);
255
303
 
256
- const handler = (block: BlockProposal, proposalSender: PeerId): Promise<BlockAttestation[] | undefined> =>
257
- this.attestToProposal(block, proposalSender);
258
- this.p2pClient.registerBlockProposalHandler(handler);
304
+ // Block proposal handler - validates but does NOT attest (validators only attest to checkpoints)
305
+ const blockHandler = (block: BlockProposal, proposalSender: PeerId): Promise<boolean> =>
306
+ this.validateBlockProposal(block, proposalSender);
307
+ this.p2pClient.registerBlockProposalHandler(blockHandler);
308
+
309
+ // Checkpoint proposal handler - validates and creates attestations
310
+ // The checkpoint is received as CheckpointProposalCore since the lastBlock is extracted
311
+ // and processed separately via the block handler above.
312
+ const checkpointHandler = (
313
+ checkpoint: CheckpointProposalCore,
314
+ proposalSender: PeerId,
315
+ ): Promise<CheckpointAttestation[] | undefined> => this.attestToCheckpointProposal(checkpoint, proposalSender);
316
+ this.p2pClient.registerCheckpointProposalHandler(checkpointHandler);
317
+
318
+ // Duplicate proposal handler - triggers slashing for equivocation
319
+ this.p2pClient.registerDuplicateProposalCallback((info: DuplicateProposalInfo) => {
320
+ this.handleDuplicateProposal(info);
321
+ });
322
+
323
+ // Duplicate attestation handler - triggers slashing for attestation equivocation
324
+ this.p2pClient.registerDuplicateAttestationCallback((info: DuplicateAttestationInfo) => {
325
+ this.handleDuplicateAttestation(info);
326
+ });
259
327
 
260
328
  const myAddresses = this.getValidatorAddresses();
261
329
  this.p2pClient.registerThisValidatorAddresses(myAddresses);
@@ -264,29 +332,47 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
264
332
  }
265
333
  }
266
334
 
267
- async attestToProposal(proposal: BlockProposal, proposalSender: PeerId): Promise<BlockAttestation[] | undefined> {
335
+ /**
336
+ * Validate a block proposal from a peer.
337
+ * Note: Validators do NOT attest to individual blocks - attestations are only for checkpoint proposals.
338
+ * @returns true if the proposal is valid, false otherwise
339
+ */
340
+ async validateBlockProposal(proposal: BlockProposal, proposalSender: PeerId): Promise<boolean> {
268
341
  const slotNumber = proposal.slotNumber;
342
+
343
+ // Note: During escape hatch, we still want to "validate" proposals for observability,
344
+ // but we intentionally reject them and disable slashing invalid block and attestation flow.
345
+ const escapeHatchOpen = await this.epochCache.isEscapeHatchOpenAtSlot(slotNumber);
346
+
269
347
  const proposer = proposal.getSender();
270
348
 
271
349
  // Reject proposals with invalid signatures
272
350
  if (!proposer) {
273
- this.log.warn(`Received proposal with invalid signature for slot ${slotNumber}`);
274
- return undefined;
351
+ this.log.warn(`Received block proposal with invalid signature for slot ${slotNumber}`);
352
+ return false;
275
353
  }
276
354
 
277
- // Check that I have any address in current committee before attesting
355
+ // Ignore proposals from ourselves (may happen in HA setups)
356
+ if (this.getValidatorAddresses().some(addr => addr.equals(proposer))) {
357
+ this.log.warn(`Ignoring block proposal from self for slot ${slotNumber}`, {
358
+ proposer: proposer.toString(),
359
+ slotNumber,
360
+ });
361
+ return false;
362
+ }
363
+
364
+ // Check if we're in the committee (for metrics purposes)
278
365
  const inCommittee = await this.epochCache.filterInCommittee(slotNumber, this.getValidatorAddresses());
279
366
  const partOfCommittee = inCommittee.length > 0;
280
367
 
281
368
  const proposalInfo = { ...proposal.toBlockInfo(), proposer: proposer.toString() };
282
- this.log.info(`Received proposal for slot ${slotNumber}`, {
369
+ this.log.info(`Received block proposal for slot ${slotNumber}`, {
283
370
  ...proposalInfo,
284
371
  txHashes: proposal.txHashes.map(t => t.toString()),
285
372
  fishermanMode: this.config.fishermanMode || false,
286
373
  });
287
374
 
288
- // Reexecute txs if we are part of the committee so we can attest, or if slashing is enabled so we can slash
289
- // invalid proposals even when not in the committee, or if we are configured to always reexecute for monitoring purposes.
375
+ // Reexecute txs if we are part of the committee, or if slashing is enabled, or if we are configured to always reexecute.
290
376
  // In fisherman mode, we always reexecute to validate proposals.
291
377
  const { validatorReexecute, slashBroadcastedInvalidBlockPenalty, alwaysReexecuteBlockProposals, fishermanMode } =
292
378
  this.config;
@@ -295,16 +381,16 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
295
381
  (slashBroadcastedInvalidBlockPenalty > 0n && validatorReexecute) ||
296
382
  (partOfCommittee && validatorReexecute) ||
297
383
  alwaysReexecuteBlockProposals ||
298
- this.fileStoreBlobUploadClient;
384
+ this.blobClient.canUpload();
299
385
 
300
386
  const validationResult = await this.blockProposalHandler.handleBlockProposal(
301
387
  proposal,
302
388
  proposalSender,
303
- !!shouldReexecute,
389
+ !!shouldReexecute && !escapeHatchOpen,
304
390
  );
305
391
 
306
392
  if (!validationResult.isValid) {
307
- this.log.warn(`Proposal validation failed: ${validationResult.reason}`, proposalInfo);
393
+ this.log.warn(`Block proposal validation failed: ${validationResult.reason}`, proposalInfo);
308
394
 
309
395
  const reason = validationResult.reason || 'unknown';
310
396
  // Classify failure reason: bad proposal vs node issue
@@ -319,12 +405,13 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
319
405
  if (badProposalReasons.includes(reason as BlockProposalValidationFailureReason)) {
320
406
  this.metrics.incFailedAttestationsBadProposal(1, reason, partOfCommittee);
321
407
  } else {
322
- // Node issues so we can't attest
408
+ // Node issues so we can't validate
323
409
  this.metrics.incFailedAttestationsNodeIssue(1, reason, partOfCommittee);
324
410
  }
325
411
 
326
412
  // Slash invalid block proposals (can happen even when not in committee)
327
413
  if (
414
+ !escapeHatchOpen &&
328
415
  validationResult.reason &&
329
416
  SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT.includes(validationResult.reason) &&
330
417
  slashBroadcastedInvalidBlockPenalty > 0n
@@ -332,9 +419,90 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
332
419
  this.log.warn(`Slashing proposer for invalid block proposal`, proposalInfo);
333
420
  this.slashInvalidBlock(proposal);
334
421
  }
422
+ return false;
423
+ }
424
+
425
+ this.log.info(`Validated block proposal for slot ${slotNumber}`, {
426
+ ...proposalInfo,
427
+ inCommittee: partOfCommittee,
428
+ fishermanMode: this.config.fishermanMode || false,
429
+ escapeHatchOpen,
430
+ });
431
+
432
+ if (escapeHatchOpen) {
433
+ this.log.warn(`Escape hatch open for slot ${slotNumber}, rejecting block proposal`, proposalInfo);
434
+ return false;
435
+ }
436
+
437
+ return true;
438
+ }
439
+
440
+ /**
441
+ * Validate and attest to a checkpoint proposal from a peer.
442
+ * The proposal is received as CheckpointProposalCore (without lastBlock) since
443
+ * the lastBlock is extracted and processed separately via the block handler.
444
+ * @returns Checkpoint attestations if valid, undefined otherwise
445
+ */
446
+ async attestToCheckpointProposal(
447
+ proposal: CheckpointProposalCore,
448
+ _proposalSender: PeerId,
449
+ ): Promise<CheckpointAttestation[] | undefined> {
450
+ const slotNumber = proposal.slotNumber;
451
+ const proposer = proposal.getSender();
452
+
453
+ // If escape hatch is open for this slot's epoch, do not attest.
454
+ if (await this.epochCache.isEscapeHatchOpenAtSlot(slotNumber)) {
455
+ this.log.warn(`Escape hatch open for slot ${slotNumber}, skipping checkpoint attestation handling`);
456
+ return undefined;
457
+ }
458
+
459
+ // Reject proposals with invalid signatures
460
+ if (!proposer) {
461
+ this.log.warn(`Received checkpoint proposal with invalid signature for slot ${slotNumber}`);
462
+ return undefined;
463
+ }
464
+
465
+ // Ignore proposals from ourselves (may happen in HA setups)
466
+ if (this.getValidatorAddresses().some(addr => addr.equals(proposer))) {
467
+ this.log.warn(`Ignoring block proposal from self for slot ${slotNumber}`, {
468
+ proposer: proposer.toString(),
469
+ slotNumber,
470
+ });
335
471
  return undefined;
336
472
  }
337
473
 
474
+ // Check that I have any address in current committee before attesting
475
+ const inCommittee = await this.epochCache.filterInCommittee(slotNumber, this.getValidatorAddresses());
476
+ const partOfCommittee = inCommittee.length > 0;
477
+
478
+ const proposalInfo = {
479
+ slotNumber,
480
+ archive: proposal.archive.toString(),
481
+ proposer: proposer.toString(),
482
+ txCount: proposal.txHashes.length,
483
+ };
484
+ this.log.info(`Received checkpoint proposal for slot ${slotNumber}`, {
485
+ ...proposalInfo,
486
+ txHashes: proposal.txHashes.map(t => t.toString()),
487
+ fishermanMode: this.config.fishermanMode || false,
488
+ });
489
+
490
+ // Validate the checkpoint proposal before attesting (unless skipCheckpointProposalValidation is set)
491
+ if (this.config.skipCheckpointProposalValidation) {
492
+ this.log.warn(`Skipping checkpoint proposal validation for slot ${slotNumber}`, proposalInfo);
493
+ } else {
494
+ const validationResult = await this.validateCheckpointProposal(proposal, proposalInfo);
495
+ if (!validationResult.isValid) {
496
+ this.log.warn(`Checkpoint proposal validation failed: ${validationResult.reason}`, proposalInfo);
497
+ return undefined;
498
+ }
499
+ }
500
+
501
+ // Upload blobs to filestore if we can (fire and forget)
502
+ if (this.blobClient.canUpload()) {
503
+ void this.uploadBlobsForCheckpoint(proposal, proposalInfo);
504
+ }
505
+
338
506
  // Check that I have any address in current committee before attesting
339
507
  // In fisherman mode, we still create attestations for validation even if not in committee
340
508
  if (!partOfCommittee && !this.config.fishermanMode) {
@@ -343,7 +511,7 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
343
511
  }
344
512
 
345
513
  // Provided all of the above checks pass, we can attest to the proposal
346
- this.log.info(`${partOfCommittee ? 'Attesting to' : 'Validated'} proposal for slot ${slotNumber}`, {
514
+ this.log.info(`${partOfCommittee ? 'Attesting to' : 'Validated'} checkpoint proposal for slot ${slotNumber}`, {
347
515
  ...proposalInfo,
348
516
  inCommittee: partOfCommittee,
349
517
  fishermanMode: this.config.fishermanMode || false,
@@ -351,21 +519,6 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
351
519
 
352
520
  this.metrics.incSuccessfulAttestations(inCommittee.length);
353
521
 
354
- // Upload blobs to filestore after successful re-execution (fire-and-forget)
355
- if (validationResult.reexecutionResult?.block && this.fileStoreBlobUploadClient) {
356
- void Promise.resolve().then(async () => {
357
- try {
358
- const blobFields = validationResult.reexecutionResult!.block.getCheckpointBlobFields();
359
- const blobs = getBlobsPerL1Block(blobFields);
360
- await this.fileStoreBlobUploadClient!.saveBlobs(blobs, true);
361
- this.log.debug(`Uploaded ${blobs.length} blobs to filestore from re-execution`, proposalInfo);
362
- } catch (err) {
363
- this.log.warn(`Failed to upload blobs from re-execution`, err);
364
- }
365
- });
366
- }
367
-
368
- // If the above function does not throw an error, then we can attest to the proposal
369
522
  // Determine which validators should attest
370
523
  let attestors: EthAddress[];
371
524
  if (partOfCommittee) {
@@ -384,13 +537,225 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
384
537
 
385
538
  if (this.config.fishermanMode) {
386
539
  // bail out early and don't save attestations to the pool in fisherman mode
387
- this.log.info(`Creating attestations for proposal for slot ${slotNumber}`, {
540
+ this.log.info(`Creating checkpoint attestations for slot ${slotNumber}`, {
388
541
  ...proposalInfo,
389
542
  attestors: attestors.map(a => a.toString()),
390
543
  });
391
544
  return undefined;
392
545
  }
393
- return this.createBlockAttestationsFromProposal(proposal, attestors);
546
+
547
+ return await this.createCheckpointAttestationsFromProposal(proposal, attestors);
548
+ }
549
+
550
+ /**
551
+ * Checks if we should attest to a slot based on equivocation prevention rules.
552
+ * @returns true if we should attest, false if we should skip
553
+ */
554
+ private shouldAttestToSlot(slotNumber: SlotNumber): boolean {
555
+ // If attestToEquivocatedProposals is true, always allow
556
+ if (this.config.attestToEquivocatedProposals) {
557
+ return true;
558
+ }
559
+
560
+ // Check if incoming slot is strictly greater than last attested
561
+ if (this.lastAttestedProposal && slotNumber <= this.lastAttestedProposal.slotNumber) {
562
+ this.log.warn(
563
+ `Refusing to process a proposal for slot ${slotNumber} given we already attested to a proposal for slot ${this.lastAttestedProposal.slotNumber}`,
564
+ );
565
+ return false;
566
+ }
567
+
568
+ return true;
569
+ }
570
+
571
+ private async createCheckpointAttestationsFromProposal(
572
+ proposal: CheckpointProposalCore,
573
+ attestors: EthAddress[] = [],
574
+ ): Promise<CheckpointAttestation[] | undefined> {
575
+ // Equivocation check: must happen right before signing to minimize the race window
576
+ if (!this.shouldAttestToSlot(proposal.slotNumber)) {
577
+ return undefined;
578
+ }
579
+
580
+ const attestations = await this.validationService.attestToCheckpointProposal(proposal, attestors);
581
+
582
+ // Track the proposal we attested to (to prevent equivocation)
583
+ this.lastAttestedProposal = proposal;
584
+
585
+ await this.p2pClient.addOwnCheckpointAttestations(attestations);
586
+ return attestations;
587
+ }
588
+
589
+ /**
590
+ * Validates a checkpoint proposal by building the full checkpoint and comparing it with the proposal.
591
+ * @returns Validation result with isValid flag and reason if invalid.
592
+ */
593
+ private async validateCheckpointProposal(
594
+ proposal: CheckpointProposalCore,
595
+ proposalInfo: LogData,
596
+ ): Promise<{ isValid: true } | { isValid: false; reason: string }> {
597
+ const slot = proposal.slotNumber;
598
+ const timeoutSeconds = 10; // TODO(palla/mbps): This should map to the timetable settings
599
+
600
+ // Wait for last block to sync by archive
601
+ let lastBlockHeader: BlockHeader | undefined;
602
+ try {
603
+ lastBlockHeader = await retryUntil(
604
+ async () => {
605
+ await this.blockSource.syncImmediate();
606
+ return this.blockSource.getBlockHeaderByArchive(proposal.archive);
607
+ },
608
+ `waiting for block with archive ${proposal.archive.toString()} for slot ${slot}`,
609
+ timeoutSeconds,
610
+ 0.5,
611
+ );
612
+ } catch (err) {
613
+ if (err instanceof TimeoutError) {
614
+ this.log.warn(`Timed out waiting for block with archive matching checkpoint proposal`, proposalInfo);
615
+ return { isValid: false, reason: 'last_block_not_found' };
616
+ }
617
+ this.log.error(`Error fetching last block for checkpoint proposal`, err, proposalInfo);
618
+ return { isValid: false, reason: 'block_fetch_error' };
619
+ }
620
+
621
+ if (!lastBlockHeader) {
622
+ this.log.warn(`Last block not found for checkpoint proposal`, proposalInfo);
623
+ return { isValid: false, reason: 'last_block_not_found' };
624
+ }
625
+
626
+ // Get all full blocks for the slot and checkpoint
627
+ const blocks = await this.blockSource.getBlocksForSlot(slot);
628
+ if (blocks.length === 0) {
629
+ this.log.warn(`No blocks found for slot ${slot}`, proposalInfo);
630
+ return { isValid: false, reason: 'no_blocks_for_slot' };
631
+ }
632
+
633
+ this.log.debug(`Found ${blocks.length} blocks for slot ${slot}`, {
634
+ ...proposalInfo,
635
+ blockNumbers: blocks.map(b => b.number),
636
+ });
637
+
638
+ // Get checkpoint constants from first block
639
+ const firstBlock = blocks[0];
640
+ const constants = this.extractCheckpointConstants(firstBlock);
641
+ const checkpointNumber = firstBlock.checkpointNumber;
642
+
643
+ // Get L1-to-L2 messages for this checkpoint
644
+ const l1ToL2Messages = await this.l1ToL2MessageSource.getL1ToL2Messages(checkpointNumber);
645
+
646
+ // Compute the previous checkpoint out hashes for the epoch.
647
+ // TODO: There can be a more efficient way to get the previous checkpoint out hashes without having to fetch the
648
+ // actual checkpoints and the blocks/txs in them.
649
+ const epoch = getEpochAtSlot(slot, this.epochCache.getL1Constants());
650
+ const previousCheckpoints = (await this.blockSource.getCheckpointsForEpoch(epoch))
651
+ .filter(b => b.number < checkpointNumber)
652
+ .sort((a, b) => a.number - b.number);
653
+ const previousCheckpointOutHashes = previousCheckpoints.map(c => c.getCheckpointOutHash());
654
+
655
+ // Fork world state at the block before the first block
656
+ const parentBlockNumber = BlockNumber(firstBlock.number - 1);
657
+ const fork = await this.worldState.fork(parentBlockNumber);
658
+
659
+ try {
660
+ // Create checkpoint builder with all existing blocks
661
+ const checkpointBuilder = await this.checkpointsBuilder.openCheckpoint(
662
+ checkpointNumber,
663
+ constants,
664
+ l1ToL2Messages,
665
+ previousCheckpointOutHashes,
666
+ fork,
667
+ blocks,
668
+ this.log.getBindings(),
669
+ );
670
+
671
+ // Complete the checkpoint to get computed values
672
+ const computedCheckpoint = await checkpointBuilder.completeCheckpoint();
673
+
674
+ // Compare checkpoint header with proposal
675
+ if (!computedCheckpoint.header.equals(proposal.checkpointHeader)) {
676
+ this.log.warn(`Checkpoint header mismatch`, {
677
+ ...proposalInfo,
678
+ computed: computedCheckpoint.header.toInspect(),
679
+ proposal: proposal.checkpointHeader.toInspect(),
680
+ });
681
+ return { isValid: false, reason: 'checkpoint_header_mismatch' };
682
+ }
683
+
684
+ // Compare archive root with proposal
685
+ if (!computedCheckpoint.archive.root.equals(proposal.archive)) {
686
+ this.log.warn(`Archive root mismatch`, {
687
+ ...proposalInfo,
688
+ computed: computedCheckpoint.archive.root.toString(),
689
+ proposal: proposal.archive.toString(),
690
+ });
691
+ return { isValid: false, reason: 'archive_mismatch' };
692
+ }
693
+
694
+ // Check that the accumulated epoch out hash matches the value in the proposal.
695
+ // The epoch out hash is the accumulated hash of all checkpoint out hashes in the epoch.
696
+ const checkpointOutHash = computedCheckpoint.getCheckpointOutHash();
697
+ const computedEpochOutHash = accumulateCheckpointOutHashes([...previousCheckpointOutHashes, checkpointOutHash]);
698
+ const proposalEpochOutHash = proposal.checkpointHeader.epochOutHash;
699
+ if (!computedEpochOutHash.equals(proposalEpochOutHash)) {
700
+ this.log.warn(`Epoch out hash mismatch`, {
701
+ proposalEpochOutHash: proposalEpochOutHash.toString(),
702
+ computedEpochOutHash: computedEpochOutHash.toString(),
703
+ checkpointOutHash: checkpointOutHash.toString(),
704
+ previousCheckpointOutHashes: previousCheckpointOutHashes.map(h => h.toString()),
705
+ ...proposalInfo,
706
+ });
707
+ return { isValid: false, reason: 'out_hash_mismatch' };
708
+ }
709
+
710
+ this.log.verbose(`Checkpoint proposal validation successful for slot ${slot}`, proposalInfo);
711
+ return { isValid: true };
712
+ } finally {
713
+ await fork.close();
714
+ }
715
+ }
716
+
717
+ /**
718
+ * Extract checkpoint global variables from a block.
719
+ */
720
+ private extractCheckpointConstants(block: L2Block): CheckpointGlobalVariables {
721
+ const gv = block.header.globalVariables;
722
+ return {
723
+ chainId: gv.chainId,
724
+ version: gv.version,
725
+ slotNumber: gv.slotNumber,
726
+ coinbase: gv.coinbase,
727
+ feeRecipient: gv.feeRecipient,
728
+ gasFees: gv.gasFees,
729
+ };
730
+ }
731
+
732
+ /**
733
+ * Uploads blobs for a checkpoint to the filestore (fire and forget).
734
+ */
735
+ private async uploadBlobsForCheckpoint(proposal: CheckpointProposalCore, proposalInfo: LogData): Promise<void> {
736
+ try {
737
+ const lastBlockHeader = await this.blockSource.getBlockHeaderByArchive(proposal.archive);
738
+ if (!lastBlockHeader) {
739
+ this.log.warn(`Failed to get last block header for blob upload`, proposalInfo);
740
+ return;
741
+ }
742
+
743
+ const blocks = await this.blockSource.getBlocksForSlot(proposal.slotNumber);
744
+ if (blocks.length === 0) {
745
+ this.log.warn(`No blocks found for blob upload`, proposalInfo);
746
+ return;
747
+ }
748
+
749
+ const blobFields = blocks.flatMap(b => b.toBlobFields());
750
+ const blobs: Blob[] = getBlobsPerL1Block(blobFields);
751
+ await this.blobClient.sendBlobsToFilestore(blobs);
752
+ this.log.debug(`Uploaded ${blobs.length} blobs to filestore for checkpoint at slot ${proposal.slotNumber}`, {
753
+ ...proposalInfo,
754
+ numBlobs: blobs.length,
755
+ });
756
+ } catch (err) {
757
+ this.log.warn(`Failed to upload blobs for checkpoint: ${err}`, proposalInfo);
758
+ }
394
759
  }
395
760
 
396
761
  private slashInvalidBlock(proposal: BlockProposal) {
@@ -420,40 +785,124 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
420
785
  ]);
421
786
  }
422
787
 
423
- // TODO(palla/mbps): Block proposal should not require a checkpoint proposal
788
+ /**
789
+ * Handle detection of a duplicate proposal (equivocation).
790
+ * Emits a slash event when a proposer sends multiple proposals for the same position.
791
+ */
792
+ private handleDuplicateProposal(info: DuplicateProposalInfo): void {
793
+ const { slot, proposer, type } = info;
794
+
795
+ this.log.warn(`Triggering slash event for duplicate ${type} proposal from ${proposer.toString()} at slot ${slot}`, {
796
+ proposer: proposer.toString(),
797
+ slot,
798
+ type,
799
+ });
800
+
801
+ // Emit slash event
802
+ this.emit(WANT_TO_SLASH_EVENT, [
803
+ {
804
+ validator: proposer,
805
+ amount: this.config.slashDuplicateProposalPenalty,
806
+ offenseType: OffenseType.DUPLICATE_PROPOSAL,
807
+ epochOrSlot: BigInt(slot),
808
+ },
809
+ ]);
810
+ }
811
+
812
+ /**
813
+ * Handle detection of a duplicate attestation (equivocation).
814
+ * Emits a slash event when an attester signs attestations for different proposals at the same slot.
815
+ */
816
+ private handleDuplicateAttestation(info: DuplicateAttestationInfo): void {
817
+ const { slot, attester } = info;
818
+
819
+ this.log.warn(`Triggering slash event for duplicate attestation from ${attester.toString()} at slot ${slot}`, {
820
+ attester: attester.toString(),
821
+ slot,
822
+ });
823
+
824
+ this.emit(WANT_TO_SLASH_EVENT, [
825
+ {
826
+ validator: attester,
827
+ amount: this.config.slashDuplicateAttestationPenalty,
828
+ offenseType: OffenseType.DUPLICATE_ATTESTATION,
829
+ epochOrSlot: BigInt(slot),
830
+ },
831
+ ]);
832
+ }
833
+
424
834
  async createBlockProposal(
425
- blockNumber: BlockNumber,
426
- header: CheckpointHeader,
835
+ blockHeader: BlockHeader,
836
+ indexWithinCheckpoint: IndexWithinCheckpoint,
837
+ inHash: Fr,
427
838
  archive: Fr,
428
839
  txs: Tx[],
429
840
  proposerAddress: EthAddress | undefined,
430
- options: BlockProposalOptions,
841
+ options: BlockProposalOptions = {},
431
842
  ): Promise<BlockProposal> {
432
- // TODO(palla/mbps): Prevent double proposals properly
433
- // if (this.previousProposal?.slotNumber === header.slotNumber) {
434
- // this.log.verbose(`Already made a proposal for the same slot, skipping proposal`);
435
- // return Promise.resolve(undefined);
436
- // }
437
-
438
- this.log.info(`Assembling block proposal for block ${blockNumber} slot ${header.slotNumber}`);
439
- const newProposal = await this.validationService.createBlockProposal(header, archive, txs, proposerAddress, {
440
- ...options,
441
- broadcastInvalidBlockProposal: this.config.broadcastInvalidBlockProposal,
442
- });
443
- this.previousProposal = newProposal;
843
+ // Validate that we're not creating a proposal for an older or equal position
844
+ if (this.lastProposedBlock) {
845
+ const lastSlot = this.lastProposedBlock.slotNumber;
846
+ const lastIndex = this.lastProposedBlock.indexWithinCheckpoint;
847
+ const newSlot = blockHeader.globalVariables.slotNumber;
848
+
849
+ if (newSlot < lastSlot || (newSlot === lastSlot && indexWithinCheckpoint <= lastIndex)) {
850
+ throw new Error(
851
+ `Cannot create block proposal for slot ${newSlot} index ${indexWithinCheckpoint}: ` +
852
+ `already proposed block for slot ${lastSlot} index ${lastIndex}`,
853
+ );
854
+ }
855
+ }
856
+
857
+ this.log.info(
858
+ `Assembling block proposal for block ${blockHeader.globalVariables.blockNumber} slot ${blockHeader.globalVariables.slotNumber}`,
859
+ );
860
+ const newProposal = await this.validationService.createBlockProposal(
861
+ blockHeader,
862
+ indexWithinCheckpoint,
863
+ inHash,
864
+ archive,
865
+ txs,
866
+ proposerAddress,
867
+ {
868
+ ...options,
869
+ broadcastInvalidBlockProposal: this.config.broadcastInvalidBlockProposal,
870
+ },
871
+ );
872
+ this.lastProposedBlock = newProposal;
444
873
  return newProposal;
445
874
  }
446
875
 
447
- // TODO(palla/mbps): Effectively create a checkpoint proposal different from a block proposal
448
- createCheckpointProposal(
449
- header: CheckpointHeader,
876
+ async createCheckpointProposal(
877
+ checkpointHeader: CheckpointHeader,
450
878
  archive: Fr,
451
- txs: Tx[],
879
+ lastBlockInfo: CreateCheckpointProposalLastBlockData | undefined,
452
880
  proposerAddress: EthAddress | undefined,
453
- options: BlockProposalOptions,
454
- ): Promise<BlockProposal> {
455
- this.log.info(`Assembling checkpoint proposal for slot ${header.slotNumber}`);
456
- return this.createBlockProposal(0 as BlockNumber, header, archive, txs, proposerAddress, options);
881
+ options: CheckpointProposalOptions = {},
882
+ ): Promise<CheckpointProposal> {
883
+ // Validate that we're not creating a proposal for an older or equal slot
884
+ if (this.lastProposedCheckpoint) {
885
+ const lastSlot = this.lastProposedCheckpoint.slotNumber;
886
+ const newSlot = checkpointHeader.slotNumber;
887
+
888
+ if (newSlot <= lastSlot) {
889
+ throw new Error(
890
+ `Cannot create checkpoint proposal for slot ${newSlot}: ` +
891
+ `already proposed checkpoint for slot ${lastSlot}`,
892
+ );
893
+ }
894
+ }
895
+
896
+ this.log.info(`Assembling checkpoint proposal for slot ${checkpointHeader.slotNumber}`);
897
+ const newProposal = await this.validationService.createCheckpointProposal(
898
+ checkpointHeader,
899
+ archive,
900
+ lastBlockInfo,
901
+ proposerAddress,
902
+ options,
903
+ );
904
+ this.lastProposedCheckpoint = newProposal;
905
+ return newProposal;
457
906
  }
458
907
 
459
908
  async broadcastBlockProposal(proposal: BlockProposal): Promise<void> {
@@ -463,28 +912,38 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
463
912
  async signAttestationsAndSigners(
464
913
  attestationsAndSigners: CommitteeAttestationsAndSigners,
465
914
  proposer: EthAddress,
915
+ slot: SlotNumber,
916
+ blockNumber: BlockNumber | CheckpointNumber,
466
917
  ): Promise<Signature> {
467
- return await this.validationService.signAttestationsAndSigners(attestationsAndSigners, proposer);
918
+ return await this.validationService.signAttestationsAndSigners(attestationsAndSigners, proposer, slot, blockNumber);
468
919
  }
469
920
 
470
- async collectOwnAttestations(proposal: BlockProposal): Promise<BlockAttestation[]> {
471
- const slot = proposal.payload.header.slotNumber;
921
+ async collectOwnAttestations(proposal: CheckpointProposal): Promise<CheckpointAttestation[]> {
922
+ const slot = proposal.slotNumber;
472
923
  const inCommittee = await this.epochCache.filterInCommittee(slot, this.getValidatorAddresses());
473
924
  this.log.debug(`Collecting ${inCommittee.length} self-attestations for slot ${slot}`, { inCommittee });
474
- const attestations = await this.createBlockAttestationsFromProposal(proposal, inCommittee);
925
+ const attestations = await this.createCheckpointAttestationsFromProposal(proposal, inCommittee);
926
+
927
+ if (!attestations) {
928
+ return [];
929
+ }
475
930
 
476
931
  // We broadcast our own attestations to our peers so, in case our block does not get mined on L1,
477
932
  // other nodes can see that our validators did attest to this block proposal, and do not slash us
478
933
  // due to inactivity for missed attestations.
479
- void this.p2pClient.broadcastAttestations(attestations).catch(err => {
934
+ void this.p2pClient.broadcastCheckpointAttestations(attestations).catch(err => {
480
935
  this.log.error(`Failed to broadcast self-attestations for slot ${slot}`, err);
481
936
  });
482
937
  return attestations;
483
938
  }
484
939
 
485
- async collectAttestations(proposal: BlockProposal, required: number, deadline: Date): Promise<BlockAttestation[]> {
486
- // Wait and poll the p2pClient's attestation pool for this block until we have enough attestations
487
- const slot = proposal.payload.header.slotNumber;
940
+ async collectAttestations(
941
+ proposal: CheckpointProposal,
942
+ required: number,
943
+ deadline: Date,
944
+ ): Promise<CheckpointAttestation[]> {
945
+ // Wait and poll the p2pClient's attestation pool for this checkpoint until we have enough attestations
946
+ const slot = proposal.slotNumber;
488
947
  this.log.debug(`Collecting ${required} attestations for slot ${slot} with deadline ${deadline.toISOString()}`);
489
948
 
490
949
  if (+deadline < this.dateProvider.now()) {
@@ -499,16 +958,16 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
499
958
  const proposalId = proposal.archive.toString();
500
959
  const myAddresses = this.getValidatorAddresses();
501
960
 
502
- let attestations: BlockAttestation[] = [];
961
+ let attestations: CheckpointAttestation[] = [];
503
962
  while (true) {
504
- // Filter out attestations with a mismatching payload. This should NOT happen since we have verified
963
+ // Filter out attestations with a mismatching archive. This should NOT happen since we have verified
505
964
  // the proposer signature (ie our own) before accepting the attestation into the pool via the p2p client.
506
- const collectedAttestations = (await this.p2pClient.getAttestationsForSlot(slot, proposalId)).filter(
965
+ const collectedAttestations = (await this.p2pClient.getCheckpointAttestationsForSlot(slot, proposalId)).filter(
507
966
  attestation => {
508
- if (!attestation.payload.equals(proposal.payload)) {
967
+ if (!attestation.archive.equals(proposal.archive)) {
509
968
  this.log.warn(
510
- `Received attestation for slot ${slot} with mismatched payload from ${attestation.getSender()?.toString()}`,
511
- { attestationPayload: attestation.payload, proposalPayload: proposal.payload },
969
+ `Received attestation for slot ${slot} with mismatched archive from ${attestation.getSender()?.toString()}`,
970
+ { attestationArchive: attestation.archive.toString(), proposalArchive: proposal.archive.toString() },
512
971
  );
513
972
  return false;
514
973
  }
@@ -549,15 +1008,6 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
549
1008
  }
550
1009
  }
551
1010
 
552
- private async createBlockAttestationsFromProposal(
553
- proposal: BlockProposal,
554
- attestors: EthAddress[] = [],
555
- ): Promise<BlockAttestation[]> {
556
- const attestations = await this.validationService.attestToProposal(proposal, attestors);
557
- await this.p2pClient.addAttestations(attestations);
558
- return attestations;
559
- }
560
-
561
1011
  private async handleAuthRequest(peer: PeerId, msg: Buffer): Promise<Buffer> {
562
1012
  const authRequest = AuthRequest.fromBuffer(msg);
563
1013
  const statusMessage = await this.p2pClient.handleAuthRequestFromPeer(authRequest, peer).catch(_ => undefined);
@@ -576,7 +1026,9 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
576
1026
  }
577
1027
 
578
1028
  const payloadToSign = authRequest.getPayloadToSign();
579
- const signature = await this.keyStore.signMessageWithAddress(addressToUse, payloadToSign);
1029
+ // AUTH_REQUEST doesn't require HA protection - multiple signatures are safe
1030
+ const context: SigningContext = { dutyType: DutyType.AUTH_REQUEST };
1031
+ const signature = await this.keyStore.signMessageWithAddress(addressToUse, payloadToSign, context);
580
1032
  const authResponse = new AuthResponse(statusMessage, signature);
581
1033
  return authResponse.toBuffer();
582
1034
  }