@aztec/validator-client 0.0.1-commit.b655e406 → 0.0.1-commit.b6e433891

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 (57) hide show
  1. package/README.md +326 -0
  2. package/dest/block_proposal_handler.d.ts +27 -15
  3. package/dest/block_proposal_handler.d.ts.map +1 -1
  4. package/dest/block_proposal_handler.js +441 -113
  5. package/dest/checkpoint_builder.d.ts +79 -0
  6. package/dest/checkpoint_builder.d.ts.map +1 -0
  7. package/dest/checkpoint_builder.js +251 -0
  8. package/dest/config.d.ts +1 -1
  9. package/dest/config.d.ts.map +1 -1
  10. package/dest/config.js +41 -7
  11. package/dest/duties/validation_service.d.ts +42 -13
  12. package/dest/duties/validation_service.d.ts.map +1 -1
  13. package/dest/duties/validation_service.js +107 -31
  14. package/dest/factory.d.ts +15 -8
  15. package/dest/factory.d.ts.map +1 -1
  16. package/dest/factory.js +4 -3
  17. package/dest/index.d.ts +2 -1
  18. package/dest/index.d.ts.map +1 -1
  19. package/dest/index.js +1 -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 +9 -5
  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 -11
  35. package/dest/key_store/web3signer_key_store.d.ts.map +1 -1
  36. package/dest/key_store/web3signer_key_store.js +9 -5
  37. package/dest/metrics.d.ts +12 -3
  38. package/dest/metrics.d.ts.map +1 -1
  39. package/dest/metrics.js +46 -30
  40. package/dest/validator.d.ts +77 -22
  41. package/dest/validator.d.ts.map +1 -1
  42. package/dest/validator.js +529 -66
  43. package/package.json +24 -14
  44. package/src/block_proposal_handler.ts +380 -91
  45. package/src/checkpoint_builder.ts +417 -0
  46. package/src/config.ts +41 -6
  47. package/src/duties/validation_service.ts +158 -38
  48. package/src/factory.ts +21 -8
  49. package/src/index.ts +1 -0
  50. package/src/key_store/ha_key_store.ts +269 -0
  51. package/src/key_store/index.ts +1 -0
  52. package/src/key_store/interface.ts +44 -5
  53. package/src/key_store/local_key_store.ts +14 -5
  54. package/src/key_store/node_keystore_adapter.ts +28 -5
  55. package/src/key_store/web3signer_key_store.ts +18 -5
  56. package/src/metrics.ts +63 -33
  57. package/src/validator.ts +705 -98
package/dest/validator.js CHANGED
@@ -1,14 +1,25 @@
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';
1
5
  import { createLogger } from '@aztec/foundation/log';
6
+ import { retryUntil } from '@aztec/foundation/retry';
2
7
  import { RunningPromise } from '@aztec/foundation/running-promise';
3
8
  import { sleep } from '@aztec/foundation/sleep';
4
9
  import { DateProvider } from '@aztec/foundation/timer';
5
10
  import { AuthRequest, AuthResponse, BlockProposalValidator, ReqRespSubProtocol } from '@aztec/p2p';
6
11
  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';
7
15
  import { AttestationTimeoutError } from '@aztec/stdlib/validators';
8
16
  import { getTelemetryClient } from '@aztec/telemetry-client';
17
+ import { createHASigner, createLocalSignerWithProtection, createSignerFromSharedDb } from '@aztec/validator-ha-signer/factory';
18
+ import { DutyType } from '@aztec/validator-ha-signer/types';
9
19
  import { EventEmitter } from 'events';
10
20
  import { BlockProposalHandler } from './block_proposal_handler.js';
11
21
  import { ValidationService } from './duties/validation_service.js';
22
+ import { HAKeyStore } from './key_store/ha_key_store.js';
12
23
  import { NodeKeystoreAdapter } from './key_store/node_keystore_adapter.js';
13
24
  import { ValidatorMetrics } from './metrics.js';
14
25
  // We maintain a set of proposers who have proposed invalid blocks.
@@ -26,26 +37,36 @@ const SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT = [
26
37
  epochCache;
27
38
  p2pClient;
28
39
  blockProposalHandler;
40
+ blockSource;
41
+ checkpointsBuilder;
42
+ worldState;
43
+ l1ToL2MessageSource;
29
44
  config;
45
+ blobClient;
46
+ slashingProtectionSigner;
30
47
  dateProvider;
31
- log;
32
48
  tracer;
33
49
  validationService;
34
50
  metrics;
51
+ log;
35
52
  // Whether it has already registered handlers on the p2p client
36
53
  hasRegisteredHandlers;
37
- // Used to check if we are sending the same proposal twice
38
- previousProposal;
54
+ /** Tracks the last block proposal we created, to detect duplicate proposal attempts. */ lastProposedBlock;
55
+ /** Tracks the last checkpoint proposal we created. */ lastProposedCheckpoint;
39
56
  lastEpochForCommitteeUpdateLoop;
40
57
  epochCacheUpdateLoop;
58
+ /** Tracks the last epoch in which each attester successfully submitted at least one attestation. */ lastAttestedEpochByAttester;
41
59
  proposersOfInvalidBlocks;
42
- constructor(keyStore, epochCache, p2pClient, blockProposalHandler, config, dateProvider = new DateProvider(), telemetry = getTelemetryClient(), log = createLogger('validator')){
43
- super(), this.keyStore = keyStore, this.epochCache = epochCache, this.p2pClient = p2pClient, this.blockProposalHandler = blockProposalHandler, this.config = config, this.dateProvider = dateProvider, this.log = log, this.hasRegisteredHandlers = false, this.proposersOfInvalidBlocks = new Set();
60
+ /** 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();
63
+ // Create child logger with fisherman prefix if in fisherman mode
64
+ this.log = config.fishermanMode ? log.createChild('[FISHERMAN]') : log;
44
65
  this.tracer = telemetry.getTracer('Validator');
45
66
  this.metrics = new ValidatorMetrics(telemetry);
46
- this.validationService = new ValidationService(keyStore, log.createChild('validation-service'));
67
+ this.validationService = new ValidationService(keyStore, this.log.createChild('validation-service'));
47
68
  // Refresh epoch cache every second to trigger alert if participation in committee changes
48
- this.epochCacheUpdateLoop = new RunningPromise(this.handleEpochCommitteeUpdate.bind(this), log, 1000);
69
+ this.epochCacheUpdateLoop = new RunningPromise(this.handleEpochCommitteeUpdate.bind(this), this.log, 1000);
49
70
  const myAddresses = this.getValidatorAddresses();
50
71
  this.log.verbose(`Initialized validator with addresses: ${myAddresses.map((a)=>a.toString()).join(', ')}`);
51
72
  }
@@ -77,6 +98,7 @@ const SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT = [
77
98
  this.log.trace(`No committee found for slot`);
78
99
  return;
79
100
  }
101
+ this.metrics.setCurrentEpoch(epoch);
80
102
  if (epoch !== this.lastEpochForCommitteeUpdateLoop) {
81
103
  const me = this.getValidatorAddresses();
82
104
  const committeeSet = new Set(committee.map((v)=>v.toString()));
@@ -92,13 +114,42 @@ const SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT = [
92
114
  this.log.error(`Error updating epoch committee`, err);
93
115
  }
94
116
  }
95
- static new(config, blockBuilder, epochCache, p2pClient, blockSource, l1ToL2MessageSource, txProvider, keyStoreManager, dateProvider = new DateProvider(), telemetry = getTelemetryClient()) {
117
+ static async new(config, checkpointsBuilder, worldState, epochCache, p2pClient, blockSource, l1ToL2MessageSource, txProvider, keyStoreManager, blobClient, dateProvider = new DateProvider(), telemetry = getTelemetryClient(), slashingProtectionDb) {
96
118
  const metrics = new ValidatorMetrics(telemetry);
97
119
  const blockProposalValidator = new BlockProposalValidator(epochCache, {
98
- txsPermitted: !config.disableTransactions
120
+ txsPermitted: !config.disableTransactions,
121
+ maxTxsPerBlock: config.validateMaxTxsPerBlock
99
122
  });
100
- const blockProposalHandler = new BlockProposalHandler(blockBuilder, blockSource, l1ToL2MessageSource, txProvider, blockProposalValidator, config, metrics, dateProvider, telemetry);
101
- const validator = new ValidatorClient(NodeKeystoreAdapter.fromKeyStoreManager(keyStoreManager), epochCache, p2pClient, blockProposalHandler, config, dateProvider, telemetry);
123
+ const blockProposalHandler = new BlockProposalHandler(checkpointsBuilder, worldState, blockSource, l1ToL2MessageSource, txProvider, blockProposalValidator, epochCache, config, metrics, dateProvider, telemetry);
124
+ const nodeKeystoreAdapter = NodeKeystoreAdapter.fromKeyStoreManager(keyStoreManager);
125
+ let slashingProtectionSigner;
126
+ if (slashingProtectionDb) {
127
+ // Shared database mode: use a pre-existing database (e.g. for testing HA setups).
128
+ ({ signer: slashingProtectionSigner } = createSignerFromSharedDb(slashingProtectionDb, config, {
129
+ telemetryClient: telemetry,
130
+ dateProvider
131
+ }));
132
+ } else if (config.haSigningEnabled) {
133
+ // Multi-node HA mode: use PostgreSQL-backed distributed locking.
134
+ // If maxStuckDutiesAgeMs is not explicitly set, compute it from Aztec slot duration
135
+ const haConfig = {
136
+ ...config,
137
+ maxStuckDutiesAgeMs: config.maxStuckDutiesAgeMs ?? epochCache.getL1Constants().slotDuration * 2 * 1000
138
+ };
139
+ ({ signer: slashingProtectionSigner } = await createHASigner(haConfig, {
140
+ telemetryClient: telemetry,
141
+ dateProvider
142
+ }));
143
+ } else {
144
+ // Single-node mode: use LMDB-backed local signing protection.
145
+ // This prevents double-signing if the node crashes and restarts mid-proposal.
146
+ ({ signer: slashingProtectionSigner } = await createLocalSignerWithProtection(config, {
147
+ telemetryClient: telemetry,
148
+ dateProvider
149
+ }));
150
+ }
151
+ const validatorKeyStore = new HAKeyStore(nodeKeystoreAdapter, slashingProtectionSigner);
152
+ const validator = new ValidatorClient(validatorKeyStore, epochCache, p2pClient, blockProposalHandler, blockSource, checkpointsBuilder, worldState, l1ToL2MessageSource, config, blobClient, slashingProtectionSigner, dateProvider, telemetry);
102
153
  return validator;
103
154
  }
104
155
  getValidatorAddresses() {
@@ -107,12 +158,8 @@ const SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT = [
107
158
  getBlockProposalHandler() {
108
159
  return this.blockProposalHandler;
109
160
  }
110
- // Proxy method for backwards compatibility with tests
111
- reExecuteTransactions(proposal, blockNumber, txs, l1ToL2Messages) {
112
- return this.blockProposalHandler.reexecuteTransactions(proposal, blockNumber, txs, l1ToL2Messages);
113
- }
114
- signWithAddress(addr, msg) {
115
- return this.keyStore.signTypedDataWithAddress(addr, msg);
161
+ signWithAddress(addr, msg, context) {
162
+ return this.keyStore.signTypedDataWithAddress(addr, msg, context);
116
163
  }
117
164
  getCoinbaseForAttestor(attestor) {
118
165
  return this.keyStore.getCoinbaseAddress(attestor);
@@ -129,63 +176,98 @@ const SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT = [
129
176
  ...config
130
177
  };
131
178
  }
179
+ reloadKeystore(newManager) {
180
+ const newAdapter = NodeKeystoreAdapter.fromKeyStoreManager(newManager);
181
+ this.keyStore = new HAKeyStore(newAdapter, this.slashingProtectionSigner);
182
+ this.validationService = new ValidationService(this.keyStore, this.log.createChild('validation-service'));
183
+ }
132
184
  async start() {
133
185
  if (this.epochCacheUpdateLoop.isRunning()) {
134
186
  this.log.warn(`Validator client already started`);
135
187
  return;
136
188
  }
189
+ await this.keyStore.start();
137
190
  await this.registerHandlers();
138
191
  const myAddresses = this.getValidatorAddresses();
139
192
  const inCommittee = await this.epochCache.filterInCommittee('now', myAddresses);
193
+ this.log.info(`Started validator with addresses: ${myAddresses.map((a)=>a.toString()).join(', ')}`);
140
194
  if (inCommittee.length > 0) {
141
- this.log.info(`Started validator with addresses in current validator committee: ${inCommittee.map((a)=>a.toString()).join(', ')}`);
142
- } else {
143
- this.log.info(`Started validator with addresses: ${myAddresses.map((a)=>a.toString()).join(', ')}`);
195
+ this.log.info(`Addresses in current validator committee: ${inCommittee.map((a)=>a.toString()).join(', ')}`);
144
196
  }
145
197
  this.epochCacheUpdateLoop.start();
146
198
  return Promise.resolve();
147
199
  }
148
200
  async stop() {
149
201
  await this.epochCacheUpdateLoop.stop();
202
+ await this.keyStore.stop();
150
203
  }
151
204
  /** Register handlers on the p2p client */ async registerHandlers() {
152
205
  if (!this.hasRegisteredHandlers) {
153
206
  this.hasRegisteredHandlers = true;
154
207
  this.log.debug(`Registering validator handlers for p2p client`);
155
- const handler = (block, proposalSender)=>this.attestToProposal(block, proposalSender);
156
- this.p2pClient.registerBlockProposalHandler(handler);
208
+ // Block proposal handler - validates but does NOT attest (validators only attest to checkpoints)
209
+ const blockHandler = (block, proposalSender)=>this.validateBlockProposal(block, proposalSender);
210
+ this.p2pClient.registerBlockProposalHandler(blockHandler);
211
+ // Checkpoint proposal handler - validates and creates attestations
212
+ // The checkpoint is received as CheckpointProposalCore since the lastBlock is extracted
213
+ // and processed separately via the block handler above.
214
+ const checkpointHandler = (checkpoint, proposalSender)=>this.attestToCheckpointProposal(checkpoint, proposalSender);
215
+ this.p2pClient.registerCheckpointProposalHandler(checkpointHandler);
216
+ // Duplicate proposal handler - triggers slashing for equivocation
217
+ this.p2pClient.registerDuplicateProposalCallback((info)=>{
218
+ this.handleDuplicateProposal(info);
219
+ });
220
+ // Duplicate attestation handler - triggers slashing for attestation equivocation
221
+ this.p2pClient.registerDuplicateAttestationCallback((info)=>{
222
+ this.handleDuplicateAttestation(info);
223
+ });
157
224
  const myAddresses = this.getValidatorAddresses();
158
225
  this.p2pClient.registerThisValidatorAddresses(myAddresses);
159
226
  await this.p2pClient.addReqRespSubProtocol(ReqRespSubProtocol.AUTH, this.handleAuthRequest.bind(this));
160
227
  }
161
228
  }
162
- async attestToProposal(proposal, proposalSender) {
163
- const slotNumber = proposal.slotNumber.toBigInt();
229
+ /**
230
+ * Validate a block proposal from a peer.
231
+ * Note: Validators do NOT attest to individual blocks - attestations are only for checkpoint proposals.
232
+ * @returns true if the proposal is valid, false otherwise
233
+ */ async validateBlockProposal(proposal, proposalSender) {
234
+ const slotNumber = proposal.slotNumber;
235
+ // Note: During escape hatch, we still want to "validate" proposals for observability,
236
+ // but we intentionally reject them and disable slashing invalid block and attestation flow.
237
+ const escapeHatchOpen = await this.epochCache.isEscapeHatchOpenAtSlot(slotNumber);
164
238
  const proposer = proposal.getSender();
165
239
  // Reject proposals with invalid signatures
166
240
  if (!proposer) {
167
- this.log.warn(`Received proposal with invalid signature for slot ${slotNumber}`);
168
- return undefined;
241
+ this.log.warn(`Received block proposal with invalid signature for slot ${slotNumber}`);
242
+ return false;
169
243
  }
170
- // Check that I have any address in current committee before attesting
244
+ // Log self-proposals from HA peers (same validator key on different nodes)
245
+ if (this.getValidatorAddresses().some((addr)=>addr.equals(proposer))) {
246
+ this.log.verbose(`Processing block proposal from HA peer for slot ${slotNumber}`, {
247
+ proposer: proposer.toString(),
248
+ slotNumber
249
+ });
250
+ }
251
+ // Check if we're in the committee (for metrics purposes)
171
252
  const inCommittee = await this.epochCache.filterInCommittee(slotNumber, this.getValidatorAddresses());
172
253
  const partOfCommittee = inCommittee.length > 0;
173
254
  const proposalInfo = {
174
255
  ...proposal.toBlockInfo(),
175
256
  proposer: proposer.toString()
176
257
  };
177
- this.log.info(`Received proposal for slot ${slotNumber}`, {
258
+ this.log.info(`Received block proposal for slot ${slotNumber}`, {
178
259
  ...proposalInfo,
179
- txHashes: proposal.txHashes.map((t)=>t.toString())
260
+ txHashes: proposal.txHashes.map((t)=>t.toString()),
261
+ fishermanMode: this.config.fishermanMode || false
180
262
  });
181
- // Reexecute txs if we are part of the committee so we can attest, or if slashing is enabled so we can slash
182
- // invalid proposals even when not in the committee, or if we are configured to always reexecute for monitoring purposes.
183
- const { validatorReexecute, slashBroadcastedInvalidBlockPenalty, alwaysReexecuteBlockProposals } = this.config;
184
- const shouldReexecute = slashBroadcastedInvalidBlockPenalty > 0n && validatorReexecute || partOfCommittee && validatorReexecute || alwaysReexecuteBlockProposals;
185
- const validationResult = await this.blockProposalHandler.handleBlockProposal(proposal, proposalSender, !!shouldReexecute);
263
+ // Reexecute txs if we are part of the committee, or if slashing is enabled, or if we are configured to always reexecute.
264
+ // 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);
186
268
  if (!validationResult.isValid) {
187
- this.log.warn(`Proposal validation failed: ${validationResult.reason}`, proposalInfo);
188
269
  const reason = validationResult.reason || 'unknown';
270
+ this.log.warn(`Block proposal validation failed: ${reason}`, proposalInfo);
189
271
  // Classify failure reason: bad proposal vs node issue
190
272
  const badProposalReasons = [
191
273
  'invalid_proposal',
@@ -197,26 +279,340 @@ const SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT = [
197
279
  if (badProposalReasons.includes(reason)) {
198
280
  this.metrics.incFailedAttestationsBadProposal(1, reason, partOfCommittee);
199
281
  } else {
200
- // Node issues so we can't attest
282
+ // Node issues so we can't validate
201
283
  this.metrics.incFailedAttestationsNodeIssue(1, reason, partOfCommittee);
202
284
  }
203
285
  // Slash invalid block proposals (can happen even when not in committee)
204
- if (validationResult.reason && SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT.includes(validationResult.reason) && slashBroadcastedInvalidBlockPenalty > 0n) {
286
+ if (!escapeHatchOpen && validationResult.reason && SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT.includes(validationResult.reason) && slashBroadcastedInvalidBlockPenalty > 0n) {
205
287
  this.log.warn(`Slashing proposer for invalid block proposal`, proposalInfo);
206
288
  this.slashInvalidBlock(proposal);
207
289
  }
290
+ return false;
291
+ }
292
+ this.log.info(`Validated block proposal for slot ${slotNumber}`, {
293
+ ...proposalInfo,
294
+ inCommittee: partOfCommittee,
295
+ fishermanMode: this.config.fishermanMode || false,
296
+ escapeHatchOpen
297
+ });
298
+ if (escapeHatchOpen) {
299
+ this.log.warn(`Escape hatch open for slot ${slotNumber}, rejecting block proposal`, proposalInfo);
300
+ return false;
301
+ }
302
+ return true;
303
+ }
304
+ /**
305
+ * Validate and attest to a checkpoint proposal from a peer.
306
+ * The proposal is received as CheckpointProposalCore (without lastBlock) since
307
+ * the lastBlock is extracted and processed separately via the block handler.
308
+ * @returns Checkpoint attestations if valid, undefined otherwise
309
+ */ async attestToCheckpointProposal(proposal, _proposalSender) {
310
+ const proposalSlotNumber = proposal.slotNumber;
311
+ const proposer = proposal.getSender();
312
+ // If escape hatch is open for this slot's epoch, do not attest.
313
+ if (await this.epochCache.isEscapeHatchOpenAtSlot(proposalSlotNumber)) {
314
+ this.log.warn(`Escape hatch open for slot ${proposalSlotNumber}, skipping checkpoint attestation handling`);
315
+ return undefined;
316
+ }
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
+ // Ignore proposals from ourselves (may happen in HA setups)
323
+ if (this.getValidatorAddresses().some((addr)=>addr.equals(proposer))) {
324
+ this.log.debug(`Ignoring block proposal from self for slot ${proposalSlotNumber}`, {
325
+ proposer: proposer.toString(),
326
+ proposalSlotNumber
327
+ });
328
+ return undefined;
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}`);
208
333
  return undefined;
209
334
  }
335
+ // Check that I have any address in the committee where this checkpoint will land before attesting
336
+ const inCommittee = await this.epochCache.filterInCommittee(proposalSlotNumber, this.getValidatorAddresses());
337
+ const partOfCommittee = inCommittee.length > 0;
338
+ const proposalInfo = {
339
+ proposalSlotNumber,
340
+ archive: proposal.archive.toString(),
341
+ proposer: proposer.toString()
342
+ };
343
+ this.log.info(`Received checkpoint proposal for slot ${proposalSlotNumber}`, {
344
+ ...proposalInfo,
345
+ fishermanMode: this.config.fishermanMode || false
346
+ });
347
+ // Validate the checkpoint proposal before attesting (unless skipCheckpointProposalValidation is set)
348
+ if (this.config.skipCheckpointProposalValidation) {
349
+ this.log.warn(`Skipping checkpoint proposal validation for slot ${proposalSlotNumber}`, proposalInfo);
350
+ } else {
351
+ const validationResult = await this.validateCheckpointProposal(proposal, proposalInfo);
352
+ if (!validationResult.isValid) {
353
+ this.log.warn(`Checkpoint proposal validation failed: ${validationResult.reason}`, proposalInfo);
354
+ return undefined;
355
+ }
356
+ }
357
+ // Upload blobs to filestore if we can (fire and forget)
358
+ if (this.blobClient.canUpload()) {
359
+ void this.uploadBlobsForCheckpoint(proposal, proposalInfo);
360
+ }
210
361
  // Check that I have any address in current committee before attesting
211
- if (!partOfCommittee) {
362
+ // In fisherman mode, we still create attestations for validation even if not in committee
363
+ if (!partOfCommittee && !this.config.fishermanMode) {
212
364
  this.log.verbose(`No validator in the current committee, skipping attestation`, proposalInfo);
213
365
  return undefined;
214
366
  }
215
367
  // Provided all of the above checks pass, we can attest to the proposal
216
- this.log.info(`Attesting to proposal for slot ${slotNumber}`, proposalInfo);
368
+ this.log.info(`${partOfCommittee ? 'Attesting to' : 'Validated'} checkpoint proposal for slot ${proposalSlotNumber}`, {
369
+ ...proposalInfo,
370
+ inCommittee: partOfCommittee,
371
+ fishermanMode: this.config.fishermanMode || false
372
+ });
217
373
  this.metrics.incSuccessfulAttestations(inCommittee.length);
218
- // If the above function does not throw an error, then we can attest to the proposal
219
- return this.createBlockAttestationsFromProposal(proposal, inCommittee);
374
+ // Track epoch participation per attester: count each (attester, epoch) pair at most once
375
+ const proposalEpoch = getEpochAtSlot(proposalSlotNumber, this.epochCache.getL1Constants());
376
+ for (const attester of inCommittee){
377
+ const key = attester.toString();
378
+ const lastEpoch = this.lastAttestedEpochByAttester.get(key);
379
+ if (lastEpoch === undefined || proposalEpoch > lastEpoch) {
380
+ this.lastAttestedEpochByAttester.set(key, proposalEpoch);
381
+ this.metrics.incAttestedEpochCount(attester);
382
+ }
383
+ }
384
+ // Determine which validators should attest
385
+ let attestors;
386
+ if (partOfCommittee) {
387
+ attestors = inCommittee;
388
+ } else if (this.config.fishermanMode) {
389
+ // In fisherman mode, create attestations for validation purposes even if not in committee. These won't be broadcast.
390
+ attestors = this.getValidatorAddresses();
391
+ } else {
392
+ attestors = [];
393
+ }
394
+ // Only create attestations if we have attestors
395
+ if (attestors.length === 0) {
396
+ return undefined;
397
+ }
398
+ if (this.config.fishermanMode) {
399
+ // bail out early and don't save attestations to the pool in fisherman mode
400
+ this.log.info(`Creating checkpoint attestations for slot ${proposalSlotNumber}`, {
401
+ ...proposalInfo,
402
+ attestors: attestors.map((a)=>a.toString())
403
+ });
404
+ return undefined;
405
+ }
406
+ return await this.createCheckpointAttestationsFromProposal(proposal, attestors);
407
+ }
408
+ /**
409
+ * Checks if we should attest to a slot based on equivocation prevention rules.
410
+ * @returns true if we should attest, false if we should skip
411
+ */ shouldAttestToSlot(slotNumber) {
412
+ // If attestToEquivocatedProposals is true, always allow
413
+ if (this.config.attestToEquivocatedProposals) {
414
+ return true;
415
+ }
416
+ // Check if incoming slot is strictly greater than last attested
417
+ if (this.lastAttestedProposal && slotNumber <= this.lastAttestedProposal.slotNumber) {
418
+ this.log.warn(`Refusing to process a proposal for slot ${slotNumber} given we already attested to a proposal for slot ${this.lastAttestedProposal.slotNumber}`);
419
+ return false;
420
+ }
421
+ return true;
422
+ }
423
+ async createCheckpointAttestationsFromProposal(proposal, attestors = []) {
424
+ // Equivocation check: must happen right before signing to minimize the race window
425
+ if (!this.shouldAttestToSlot(proposal.slotNumber)) {
426
+ return undefined;
427
+ }
428
+ const attestations = await this.validationService.attestToCheckpointProposal(proposal, attestors);
429
+ // Track the proposal we attested to (to prevent equivocation)
430
+ this.lastAttestedProposal = proposal;
431
+ await this.p2pClient.addOwnCheckpointAttestations(attestations);
432
+ return attestations;
433
+ }
434
+ /**
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
+ * Uploads blobs for a checkpoint to the filestore (fire and forget).
594
+ */ async uploadBlobsForCheckpoint(proposal, proposalInfo) {
595
+ try {
596
+ const lastBlockHeader = await this.blockSource.getBlockHeaderByArchive(proposal.archive);
597
+ if (!lastBlockHeader) {
598
+ this.log.warn(`Failed to get last block header for blob upload`, proposalInfo);
599
+ return;
600
+ }
601
+ const blocks = await this.blockSource.getBlocksForSlot(proposal.slotNumber);
602
+ if (blocks.length === 0) {
603
+ this.log.warn(`No blocks found for blob upload`, proposalInfo);
604
+ return;
605
+ }
606
+ const blobFields = blocks.flatMap((b)=>b.toBlobFields());
607
+ const blobs = await getBlobsPerL1Block(blobFields);
608
+ await this.blobClient.sendBlobsToFilestore(blobs);
609
+ this.log.debug(`Uploaded ${blobs.length} blobs to filestore for checkpoint at slot ${proposal.slotNumber}`, {
610
+ ...proposalInfo,
611
+ numBlobs: blobs.length
612
+ });
613
+ } catch (err) {
614
+ this.log.warn(`Failed to upload blobs for checkpoint: ${err}`, proposalInfo);
615
+ }
220
616
  }
221
617
  slashInvalidBlock(proposal) {
222
618
  const proposer = proposal.getSender();
@@ -236,39 +632,107 @@ const SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT = [
236
632
  validator: proposer,
237
633
  amount: this.config.slashBroadcastedInvalidBlockPenalty,
238
634
  offenseType: OffenseType.BROADCASTED_INVALID_BLOCK_PROPOSAL,
239
- epochOrSlot: proposal.slotNumber.toBigInt()
635
+ epochOrSlot: BigInt(proposal.slotNumber)
636
+ }
637
+ ]);
638
+ }
639
+ /**
640
+ * Handle detection of a duplicate proposal (equivocation).
641
+ * Emits a slash event when a proposer sends multiple proposals for the same position.
642
+ */ handleDuplicateProposal(info) {
643
+ const { slot, proposer, type } = info;
644
+ this.log.warn(`Triggering slash event for duplicate ${type} proposal from ${proposer.toString()} at slot ${slot}`, {
645
+ proposer: proposer.toString(),
646
+ slot,
647
+ type
648
+ });
649
+ // Emit slash event
650
+ this.emit(WANT_TO_SLASH_EVENT, [
651
+ {
652
+ validator: proposer,
653
+ amount: this.config.slashDuplicateProposalPenalty,
654
+ offenseType: OffenseType.DUPLICATE_PROPOSAL,
655
+ epochOrSlot: BigInt(slot)
240
656
  }
241
657
  ]);
242
658
  }
243
- async createBlockProposal(blockNumber, header, archive, stateReference, txs, proposerAddress, options) {
244
- if (this.previousProposal?.slotNumber.equals(header.slotNumber)) {
245
- this.log.verbose(`Already made a proposal for the same slot, skipping proposal`);
246
- return Promise.resolve(undefined);
659
+ /**
660
+ * Handle detection of a duplicate attestation (equivocation).
661
+ * Emits a slash event when an attester signs attestations for different proposals at the same slot.
662
+ */ handleDuplicateAttestation(info) {
663
+ const { slot, attester } = info;
664
+ this.log.warn(`Triggering slash event for duplicate attestation from ${attester.toString()} at slot ${slot}`, {
665
+ attester: attester.toString(),
666
+ slot
667
+ });
668
+ this.emit(WANT_TO_SLASH_EVENT, [
669
+ {
670
+ validator: attester,
671
+ amount: this.config.slashDuplicateAttestationPenalty,
672
+ offenseType: OffenseType.DUPLICATE_ATTESTATION,
673
+ epochOrSlot: BigInt(slot)
674
+ }
675
+ ]);
676
+ }
677
+ async createBlockProposal(blockHeader, indexWithinCheckpoint, inHash, archive, txs, proposerAddress, options = {}) {
678
+ // Validate that we're not creating a proposal for an older or equal position
679
+ if (this.lastProposedBlock) {
680
+ const lastSlot = this.lastProposedBlock.slotNumber;
681
+ const lastIndex = this.lastProposedBlock.indexWithinCheckpoint;
682
+ const newSlot = blockHeader.globalVariables.slotNumber;
683
+ if (newSlot < lastSlot || newSlot === lastSlot && indexWithinCheckpoint <= lastIndex) {
684
+ throw new Error(`Cannot create block proposal for slot ${newSlot} index ${indexWithinCheckpoint}: ` + `already proposed block for slot ${lastSlot} index ${lastIndex}`);
685
+ }
247
686
  }
248
- const newProposal = await this.validationService.createBlockProposal(header, archive, stateReference, txs, proposerAddress, {
687
+ 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, {
249
689
  ...options,
250
690
  broadcastInvalidBlockProposal: this.config.broadcastInvalidBlockProposal
251
691
  });
252
- this.previousProposal = newProposal;
692
+ this.lastProposedBlock = newProposal;
693
+ return newProposal;
694
+ }
695
+ async createCheckpointProposal(checkpointHeader, archive, feeAssetPriceModifier, lastBlockInfo, proposerAddress, options = {}) {
696
+ // Validate that we're not creating a proposal for an older or equal slot
697
+ if (this.lastProposedCheckpoint) {
698
+ const lastSlot = this.lastProposedCheckpoint.slotNumber;
699
+ const newSlot = checkpointHeader.slotNumber;
700
+ if (newSlot <= lastSlot) {
701
+ throw new Error(`Cannot create checkpoint proposal for slot ${newSlot}: ` + `already proposed checkpoint for slot ${lastSlot}`);
702
+ }
703
+ }
704
+ this.log.info(`Assembling checkpoint proposal for slot ${checkpointHeader.slotNumber}`);
705
+ const newProposal = await this.validationService.createCheckpointProposal(checkpointHeader, archive, feeAssetPriceModifier, lastBlockInfo, proposerAddress, options);
706
+ this.lastProposedCheckpoint = newProposal;
253
707
  return newProposal;
254
708
  }
255
709
  async broadcastBlockProposal(proposal) {
256
710
  await this.p2pClient.broadcastProposal(proposal);
257
711
  }
258
- async signAttestationsAndSigners(attestationsAndSigners, proposer) {
259
- return await this.validationService.signAttestationsAndSigners(attestationsAndSigners, proposer);
712
+ async signAttestationsAndSigners(attestationsAndSigners, proposer, slot, blockNumber) {
713
+ return await this.validationService.signAttestationsAndSigners(attestationsAndSigners, proposer, slot, blockNumber);
260
714
  }
261
715
  async collectOwnAttestations(proposal) {
262
- const slot = proposal.payload.header.slotNumber.toBigInt();
716
+ const slot = proposal.slotNumber;
263
717
  const inCommittee = await this.epochCache.filterInCommittee(slot, this.getValidatorAddresses());
264
718
  this.log.debug(`Collecting ${inCommittee.length} self-attestations for slot ${slot}`, {
265
719
  inCommittee
266
720
  });
267
- return this.createBlockAttestationsFromProposal(proposal, inCommittee);
721
+ const attestations = await this.createCheckpointAttestationsFromProposal(proposal, inCommittee);
722
+ if (!attestations) {
723
+ return [];
724
+ }
725
+ // We broadcast our own attestations to our peers so, in case our block does not get mined on L1,
726
+ // other nodes can see that our validators did attest to this block proposal, and do not slash us
727
+ // due to inactivity for missed attestations.
728
+ void this.p2pClient.broadcastCheckpointAttestations(attestations).catch((err)=>{
729
+ this.log.error(`Failed to broadcast self-attestations for slot ${slot}`, err);
730
+ });
731
+ return attestations;
268
732
  }
269
733
  async collectAttestations(proposal, required, deadline) {
270
- // Wait and poll the p2pClient's attestation pool for this block until we have enough attestations
271
- const slot = proposal.payload.header.slotNumber.toBigInt();
734
+ // Wait and poll the p2pClient's attestation pool for this checkpoint until we have enough attestations
735
+ const slot = proposal.slotNumber;
272
736
  this.log.debug(`Collecting ${required} attestations for slot ${slot} with deadline ${deadline.toISOString()}`);
273
737
  if (+deadline < this.dateProvider.now()) {
274
738
  this.log.error(`Deadline ${deadline.toISOString()} for collecting ${required} attestations for slot ${slot} is in the past`);
@@ -279,13 +743,13 @@ const SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT = [
279
743
  const myAddresses = this.getValidatorAddresses();
280
744
  let attestations = [];
281
745
  while(true){
282
- // Filter out attestations with a mismatching payload. This should NOT happen since we have verified
746
+ // Filter out attestations with a mismatching archive. This should NOT happen since we have verified
283
747
  // the proposer signature (ie our own) before accepting the attestation into the pool via the p2p client.
284
- const collectedAttestations = (await this.p2pClient.getAttestationsForSlot(slot, proposalId)).filter((attestation)=>{
285
- if (!attestation.payload.equals(proposal.payload)) {
286
- this.log.warn(`Received attestation for slot ${slot} with mismatched payload from ${attestation.getSender()?.toString()}`, {
287
- attestationPayload: attestation.payload,
288
- proposalPayload: proposal.payload
748
+ const collectedAttestations = (await this.p2pClient.getCheckpointAttestationsForSlot(slot, proposalId)).filter((attestation)=>{
749
+ if (!attestation.archive.equals(proposal.archive)) {
750
+ this.log.warn(`Received attestation for slot ${slot} with mismatched archive from ${attestation.getSender()?.toString()}`, {
751
+ attestationArchive: attestation.archive.toString(),
752
+ proposalArchive: proposal.archive.toString()
289
753
  });
290
754
  return false;
291
755
  }
@@ -317,11 +781,6 @@ const SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT = [
317
781
  await sleep(this.config.attestationPollingIntervalMs);
318
782
  }
319
783
  }
320
- async createBlockAttestationsFromProposal(proposal, attestors = []) {
321
- const attestations = await this.validationService.attestToProposal(proposal, attestors);
322
- await this.p2pClient.addAttestations(attestations);
323
- return attestations;
324
- }
325
784
  async handleAuthRequest(peer, msg) {
326
785
  const authRequest = AuthRequest.fromBuffer(msg);
327
786
  const statusMessage = await this.p2pClient.handleAuthRequestFromPeer(authRequest, peer).catch((_)=>undefined);
@@ -336,7 +795,11 @@ const SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT = [
336
795
  return Buffer.alloc(0);
337
796
  }
338
797
  const payloadToSign = authRequest.getPayloadToSign();
339
- const signature = await this.keyStore.signMessageWithAddress(addressToUse, payloadToSign);
798
+ // AUTH_REQUEST doesn't require HA protection - multiple signatures are safe
799
+ const context = {
800
+ dutyType: DutyType.AUTH_REQUEST
801
+ };
802
+ const signature = await this.keyStore.signMessageWithAddress(addressToUse, payloadToSign, context);
340
803
  const authResponse = new AuthResponse(statusMessage, signature);
341
804
  return authResponse.toBuffer();
342
805
  }