@aztec/validator-client 0.0.1-fake-ceab37513c → 0.0.6-commit.a2d1860fe9

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 +25 -14
  3. package/dest/block_proposal_handler.d.ts.map +1 -1
  4. package/dest/block_proposal_handler.js +339 -93
  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 +175 -0
  8. package/dest/config.d.ts +1 -1
  9. package/dest/config.d.ts.map +1 -1
  10. package/dest/config.js +20 -7
  11. package/dest/duties/validation_service.d.ts +47 -15
  12. package/dest/duties/validation_service.d.ts.map +1 -1
  13. package/dest/duties/validation_service.js +119 -30
  14. package/dest/factory.d.ts +13 -8
  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 +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 +13 -10
  37. package/dest/metrics.d.ts +8 -5
  38. package/dest/metrics.d.ts.map +1 -1
  39. package/dest/metrics.js +48 -33
  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 +77 -22
  50. package/dest/validator.d.ts.map +1 -1
  51. package/dest/validator.js +521 -72
  52. package/package.json +24 -14
  53. package/src/block_proposal_handler.ts +265 -73
  54. package/src/checkpoint_builder.ts +321 -0
  55. package/src/config.ts +20 -6
  56. package/src/duties/validation_service.ts +173 -37
  57. package/src/factory.ts +17 -8
  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 +14 -5
  63. package/src/key_store/node_keystore_adapter.ts +28 -5
  64. package/src/key_store/web3signer_key_store.ts +22 -12
  65. package/src/metrics.ts +67 -36
  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 +697 -104
package/dest/validator.js CHANGED
@@ -1,14 +1,24 @@
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 { getEpochAtSlot, getTimestampForSlot } from '@aztec/stdlib/epoch-helpers';
13
+ import { accumulateCheckpointOutHashes } from '@aztec/stdlib/messaging';
7
14
  import { AttestationTimeoutError } from '@aztec/stdlib/validators';
8
15
  import { getTelemetryClient } from '@aztec/telemetry-client';
16
+ import { createHASigner } from '@aztec/validator-ha-signer/factory';
17
+ import { DutyType } from '@aztec/validator-ha-signer/types';
9
18
  import { EventEmitter } from 'events';
10
19
  import { BlockProposalHandler } from './block_proposal_handler.js';
11
20
  import { ValidationService } from './duties/validation_service.js';
21
+ import { HAKeyStore } from './key_store/ha_key_store.js';
12
22
  import { NodeKeystoreAdapter } from './key_store/node_keystore_adapter.js';
13
23
  import { ValidatorMetrics } from './metrics.js';
14
24
  // We maintain a set of proposers who have proposed invalid blocks.
@@ -26,38 +36,49 @@ const SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT = [
26
36
  epochCache;
27
37
  p2pClient;
28
38
  blockProposalHandler;
39
+ blockSource;
40
+ checkpointsBuilder;
41
+ worldState;
42
+ l1ToL2MessageSource;
29
43
  config;
44
+ blobClient;
45
+ haSigner;
30
46
  dateProvider;
31
- log;
32
47
  tracer;
33
48
  validationService;
34
49
  metrics;
50
+ log;
35
51
  // Whether it has already registered handlers on the p2p client
36
52
  hasRegisteredHandlers;
37
- // Used to check if we are sending the same proposal twice
38
- previousProposal;
53
+ /** Tracks the last block proposal we created, to detect duplicate proposal attempts. */ lastProposedBlock;
54
+ /** Tracks the last checkpoint proposal we created. */ lastProposedCheckpoint;
39
55
  lastEpochForCommitteeUpdateLoop;
40
56
  epochCacheUpdateLoop;
41
57
  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();
58
+ /** Tracks the last checkpoint proposal we attested to, to prevent equivocation. */ lastAttestedProposal;
59
+ constructor(keyStore, epochCache, p2pClient, blockProposalHandler, blockSource, checkpointsBuilder, worldState, l1ToL2MessageSource, config, blobClient, haSigner, dateProvider = new DateProvider(), telemetry = getTelemetryClient(), log = createLogger('validator')){
60
+ 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.haSigner = haSigner, this.dateProvider = dateProvider, this.hasRegisteredHandlers = false, this.proposersOfInvalidBlocks = new Set();
61
+ // Create child logger with fisherman prefix if in fisherman mode
62
+ this.log = config.fishermanMode ? log.createChild('[FISHERMAN]') : log;
44
63
  this.tracer = telemetry.getTracer('Validator');
45
64
  this.metrics = new ValidatorMetrics(telemetry);
46
- this.validationService = new ValidationService(keyStore);
65
+ this.validationService = new ValidationService(keyStore, this.log.createChild('validation-service'));
47
66
  // Refresh epoch cache every second to trigger alert if participation in committee changes
48
- this.epochCacheUpdateLoop = new RunningPromise(this.handleEpochCommitteeUpdate.bind(this), log, 1000);
67
+ this.epochCacheUpdateLoop = new RunningPromise(this.handleEpochCommitteeUpdate.bind(this), this.log, 1000);
49
68
  const myAddresses = this.getValidatorAddresses();
50
69
  this.log.verbose(`Initialized validator with addresses: ${myAddresses.map((a)=>a.toString()).join(', ')}`);
51
70
  }
52
- static validateKeyStoreConfiguration(keyStoreManager) {
71
+ static validateKeyStoreConfiguration(keyStoreManager, logger) {
53
72
  const validatorKeyStore = NodeKeystoreAdapter.fromKeyStoreManager(keyStoreManager);
54
73
  const validatorAddresses = validatorKeyStore.getAddresses();
55
74
  // Verify that we can retrieve all required data from the key store
56
75
  for (const address of validatorAddresses){
57
76
  // Functions throw if required data is not available
77
+ let coinbase;
78
+ let feeRecipient;
58
79
  try {
59
- validatorKeyStore.getCoinbaseAddress(address);
60
- validatorKeyStore.getFeeRecipient(address);
80
+ coinbase = validatorKeyStore.getCoinbaseAddress(address);
81
+ feeRecipient = validatorKeyStore.getFeeRecipient(address);
61
82
  } catch (error) {
62
83
  throw new Error(`Failed to retrieve required data for validator address ${address}, error: ${error}`);
63
84
  }
@@ -65,6 +86,7 @@ const SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT = [
65
86
  if (!publisherAddresses.length) {
66
87
  throw new Error(`No publisher addresses found for validator address ${address}`);
67
88
  }
89
+ logger?.debug(`Validator ${address.toString()} configured with coinbase ${coinbase.toString()}, feeRecipient ${feeRecipient.toString()} and publishers ${publisherAddresses.map((x)=>x.toString()).join()}`);
68
90
  }
69
91
  }
70
92
  async handleEpochCommitteeUpdate() {
@@ -89,13 +111,26 @@ const SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT = [
89
111
  this.log.error(`Error updating epoch committee`, err);
90
112
  }
91
113
  }
92
- static new(config, blockBuilder, epochCache, p2pClient, blockSource, l1ToL2MessageSource, txProvider, keyStoreManager, dateProvider = new DateProvider(), telemetry = getTelemetryClient()) {
114
+ static async new(config, checkpointsBuilder, worldState, epochCache, p2pClient, blockSource, l1ToL2MessageSource, txProvider, keyStoreManager, blobClient, dateProvider = new DateProvider(), telemetry = getTelemetryClient()) {
93
115
  const metrics = new ValidatorMetrics(telemetry);
94
116
  const blockProposalValidator = new BlockProposalValidator(epochCache, {
95
117
  txsPermitted: !config.disableTransactions
96
118
  });
97
- const blockProposalHandler = new BlockProposalHandler(blockBuilder, blockSource, l1ToL2MessageSource, txProvider, blockProposalValidator, config, metrics, dateProvider, telemetry);
98
- const validator = new ValidatorClient(NodeKeystoreAdapter.fromKeyStoreManager(keyStoreManager), epochCache, p2pClient, blockProposalHandler, config, dateProvider, telemetry);
119
+ const blockProposalHandler = new BlockProposalHandler(checkpointsBuilder, worldState, blockSource, l1ToL2MessageSource, txProvider, blockProposalValidator, epochCache, config, metrics, dateProvider, telemetry);
120
+ const nodeKeystoreAdapter = NodeKeystoreAdapter.fromKeyStoreManager(keyStoreManager);
121
+ let validatorKeyStore = nodeKeystoreAdapter;
122
+ let haSigner;
123
+ if (config.haSigningEnabled) {
124
+ // If maxStuckDutiesAgeMs is not explicitly set, compute it from Aztec slot duration
125
+ const haConfig = {
126
+ ...config,
127
+ maxStuckDutiesAgeMs: config.maxStuckDutiesAgeMs ?? epochCache.getL1Constants().slotDuration * 2 * 1000
128
+ };
129
+ const { signer } = await createHASigner(haConfig);
130
+ haSigner = signer;
131
+ validatorKeyStore = new HAKeyStore(nodeKeystoreAdapter, signer);
132
+ }
133
+ const validator = new ValidatorClient(validatorKeyStore, epochCache, p2pClient, blockProposalHandler, blockSource, checkpointsBuilder, worldState, l1ToL2MessageSource, config, blobClient, haSigner, dateProvider, telemetry);
99
134
  return validator;
100
135
  }
101
136
  getValidatorAddresses() {
@@ -104,12 +139,8 @@ const SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT = [
104
139
  getBlockProposalHandler() {
105
140
  return this.blockProposalHandler;
106
141
  }
107
- // Proxy method for backwards compatibility with tests
108
- reExecuteTransactions(proposal, blockNumber, txs, l1ToL2Messages) {
109
- return this.blockProposalHandler.reexecuteTransactions(proposal, blockNumber, txs, l1ToL2Messages);
110
- }
111
- signWithAddress(addr, msg) {
112
- return this.keyStore.signTypedDataWithAddress(addr, msg);
142
+ signWithAddress(addr, msg, context) {
143
+ return this.keyStore.signTypedDataWithAddress(addr, msg, context);
113
144
  }
114
145
  getCoinbaseForAttestor(attestor) {
115
146
  return this.keyStore.getCoinbaseAddress(attestor);
@@ -126,81 +157,429 @@ const SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT = [
126
157
  ...config
127
158
  };
128
159
  }
160
+ reloadKeystore(newManager) {
161
+ if (this.config.haSigningEnabled && !this.haSigner) {
162
+ this.log.warn('HA signing is enabled in config but was not initialized at startup. ' + 'Restart the node to enable HA signing.');
163
+ } else if (!this.config.haSigningEnabled && this.haSigner) {
164
+ this.log.warn('HA signing was disabled via config update but the HA signer is still active. ' + 'Restart the node to fully disable HA signing.');
165
+ }
166
+ const newAdapter = NodeKeystoreAdapter.fromKeyStoreManager(newManager);
167
+ if (this.haSigner) {
168
+ this.keyStore = new HAKeyStore(newAdapter, this.haSigner);
169
+ } else {
170
+ this.keyStore = newAdapter;
171
+ }
172
+ this.validationService = new ValidationService(this.keyStore, this.log.createChild('validation-service'));
173
+ }
129
174
  async start() {
130
175
  if (this.epochCacheUpdateLoop.isRunning()) {
131
176
  this.log.warn(`Validator client already started`);
132
177
  return;
133
178
  }
179
+ await this.keyStore.start();
134
180
  await this.registerHandlers();
135
181
  const myAddresses = this.getValidatorAddresses();
136
182
  const inCommittee = await this.epochCache.filterInCommittee('now', myAddresses);
183
+ this.log.info(`Started validator with addresses: ${myAddresses.map((a)=>a.toString()).join(', ')}`);
137
184
  if (inCommittee.length > 0) {
138
- this.log.info(`Started validator with addresses in current validator committee: ${inCommittee.map((a)=>a.toString()).join(', ')}`);
139
- } else {
140
- this.log.info(`Started validator with addresses: ${myAddresses.map((a)=>a.toString()).join(', ')}`);
185
+ this.log.info(`Addresses in current validator committee: ${inCommittee.map((a)=>a.toString()).join(', ')}`);
141
186
  }
142
187
  this.epochCacheUpdateLoop.start();
143
188
  return Promise.resolve();
144
189
  }
145
190
  async stop() {
146
191
  await this.epochCacheUpdateLoop.stop();
192
+ await this.keyStore.stop();
147
193
  }
148
194
  /** Register handlers on the p2p client */ async registerHandlers() {
149
195
  if (!this.hasRegisteredHandlers) {
150
196
  this.hasRegisteredHandlers = true;
151
197
  this.log.debug(`Registering validator handlers for p2p client`);
152
- const handler = (block, proposalSender)=>this.attestToProposal(block, proposalSender);
153
- this.p2pClient.registerBlockProposalHandler(handler);
198
+ // Block proposal handler - validates but does NOT attest (validators only attest to checkpoints)
199
+ const blockHandler = (block, proposalSender)=>this.validateBlockProposal(block, proposalSender);
200
+ this.p2pClient.registerBlockProposalHandler(blockHandler);
201
+ // Checkpoint proposal handler - validates and creates attestations
202
+ // The checkpoint is received as CheckpointProposalCore since the lastBlock is extracted
203
+ // and processed separately via the block handler above.
204
+ const checkpointHandler = (checkpoint, proposalSender)=>this.attestToCheckpointProposal(checkpoint, proposalSender);
205
+ this.p2pClient.registerCheckpointProposalHandler(checkpointHandler);
206
+ // Duplicate proposal handler - triggers slashing for equivocation
207
+ this.p2pClient.registerDuplicateProposalCallback((info)=>{
208
+ this.handleDuplicateProposal(info);
209
+ });
210
+ // Duplicate attestation handler - triggers slashing for attestation equivocation
211
+ this.p2pClient.registerDuplicateAttestationCallback((info)=>{
212
+ this.handleDuplicateAttestation(info);
213
+ });
154
214
  const myAddresses = this.getValidatorAddresses();
155
215
  this.p2pClient.registerThisValidatorAddresses(myAddresses);
156
216
  await this.p2pClient.addReqRespSubProtocol(ReqRespSubProtocol.AUTH, this.handleAuthRequest.bind(this));
157
217
  }
158
218
  }
159
- async attestToProposal(proposal, proposalSender) {
160
- const slotNumber = proposal.slotNumber.toBigInt();
219
+ /**
220
+ * Validate a block proposal from a peer.
221
+ * Note: Validators do NOT attest to individual blocks - attestations are only for checkpoint proposals.
222
+ * @returns true if the proposal is valid, false otherwise
223
+ */ async validateBlockProposal(proposal, proposalSender) {
224
+ const slotNumber = proposal.slotNumber;
225
+ // Note: During escape hatch, we still want to "validate" proposals for observability,
226
+ // but we intentionally reject them and disable slashing invalid block and attestation flow.
227
+ const escapeHatchOpen = await this.epochCache.isEscapeHatchOpenAtSlot(slotNumber);
161
228
  const proposer = proposal.getSender();
162
229
  // Reject proposals with invalid signatures
163
230
  if (!proposer) {
164
- this.log.warn(`Received proposal with invalid signature for slot ${slotNumber}`);
165
- return undefined;
231
+ this.log.warn(`Received block proposal with invalid signature for slot ${slotNumber}`);
232
+ return false;
166
233
  }
167
- // Check that I have any address in current committee before attesting
234
+ // Ignore proposals from ourselves (may happen in HA setups)
235
+ if (this.getValidatorAddresses().some((addr)=>addr.equals(proposer))) {
236
+ this.log.warn(`Ignoring block proposal from self for slot ${slotNumber}`, {
237
+ proposer: proposer.toString(),
238
+ slotNumber
239
+ });
240
+ return false;
241
+ }
242
+ // Check if we're in the committee (for metrics purposes)
168
243
  const inCommittee = await this.epochCache.filterInCommittee(slotNumber, this.getValidatorAddresses());
169
244
  const partOfCommittee = inCommittee.length > 0;
170
- const incFailedAttestation = (reason)=>this.metrics.incFailedAttestations(1, reason, partOfCommittee);
171
245
  const proposalInfo = {
172
246
  ...proposal.toBlockInfo(),
173
247
  proposer: proposer.toString()
174
248
  };
175
- this.log.info(`Received proposal for slot ${slotNumber}`, {
249
+ this.log.info(`Received block proposal for slot ${slotNumber}`, {
176
250
  ...proposalInfo,
177
- txHashes: proposal.txHashes.map((t)=>t.toString())
251
+ txHashes: proposal.txHashes.map((t)=>t.toString()),
252
+ fishermanMode: this.config.fishermanMode || false
178
253
  });
179
- // Reexecute txs if we are part of the committee so we can attest, or if slashing is enabled so we can slash
180
- // invalid proposals even when not in the committee, or if we are configured to always reexecute for monitoring purposes.
181
- const { validatorReexecute, slashBroadcastedInvalidBlockPenalty, alwaysReexecuteBlockProposals } = this.config;
182
- const shouldReexecute = slashBroadcastedInvalidBlockPenalty > 0n && validatorReexecute || partOfCommittee && validatorReexecute || alwaysReexecuteBlockProposals;
183
- const validationResult = await this.blockProposalHandler.handleBlockProposal(proposal, proposalSender, !!shouldReexecute);
254
+ // Reexecute txs if we are part of the committee, or if slashing is enabled, or if we are configured to always reexecute.
255
+ // In fisherman mode, we always reexecute to validate proposals.
256
+ const { validatorReexecute, slashBroadcastedInvalidBlockPenalty, alwaysReexecuteBlockProposals, fishermanMode } = this.config;
257
+ const shouldReexecute = fishermanMode || slashBroadcastedInvalidBlockPenalty > 0n && validatorReexecute || partOfCommittee && validatorReexecute || alwaysReexecuteBlockProposals || this.blobClient.canUpload();
258
+ const validationResult = await this.blockProposalHandler.handleBlockProposal(proposal, proposalSender, !!shouldReexecute && !escapeHatchOpen);
184
259
  if (!validationResult.isValid) {
185
- this.log.warn(`Proposal validation failed: ${validationResult.reason}`, proposalInfo);
186
- incFailedAttestation(validationResult.reason || 'unknown');
187
- // Slash invalid block proposals
188
- if (validationResult.reason && SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT.includes(validationResult.reason) && slashBroadcastedInvalidBlockPenalty > 0n) {
260
+ this.log.warn(`Block proposal validation failed: ${validationResult.reason}`, proposalInfo);
261
+ const reason = validationResult.reason || 'unknown';
262
+ // Classify failure reason: bad proposal vs node issue
263
+ const badProposalReasons = [
264
+ 'invalid_proposal',
265
+ 'state_mismatch',
266
+ 'failed_txs',
267
+ 'in_hash_mismatch',
268
+ 'parent_block_wrong_slot'
269
+ ];
270
+ if (badProposalReasons.includes(reason)) {
271
+ this.metrics.incFailedAttestationsBadProposal(1, reason, partOfCommittee);
272
+ } else {
273
+ // Node issues so we can't validate
274
+ this.metrics.incFailedAttestationsNodeIssue(1, reason, partOfCommittee);
275
+ }
276
+ // Slash invalid block proposals (can happen even when not in committee)
277
+ if (!escapeHatchOpen && validationResult.reason && SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT.includes(validationResult.reason) && slashBroadcastedInvalidBlockPenalty > 0n) {
189
278
  this.log.warn(`Slashing proposer for invalid block proposal`, proposalInfo);
190
279
  this.slashInvalidBlock(proposal);
191
280
  }
281
+ return false;
282
+ }
283
+ this.log.info(`Validated block proposal for slot ${slotNumber}`, {
284
+ ...proposalInfo,
285
+ inCommittee: partOfCommittee,
286
+ fishermanMode: this.config.fishermanMode || false,
287
+ escapeHatchOpen
288
+ });
289
+ if (escapeHatchOpen) {
290
+ this.log.warn(`Escape hatch open for slot ${slotNumber}, rejecting block proposal`, proposalInfo);
291
+ return false;
292
+ }
293
+ return true;
294
+ }
295
+ /**
296
+ * Validate and attest to a checkpoint proposal from a peer.
297
+ * The proposal is received as CheckpointProposalCore (without lastBlock) since
298
+ * the lastBlock is extracted and processed separately via the block handler.
299
+ * @returns Checkpoint attestations if valid, undefined otherwise
300
+ */ async attestToCheckpointProposal(proposal, _proposalSender) {
301
+ const slotNumber = proposal.slotNumber;
302
+ const proposer = proposal.getSender();
303
+ // If escape hatch is open for this slot's epoch, do not attest.
304
+ if (await this.epochCache.isEscapeHatchOpenAtSlot(slotNumber)) {
305
+ this.log.warn(`Escape hatch open for slot ${slotNumber}, skipping checkpoint attestation handling`);
192
306
  return undefined;
193
307
  }
308
+ // Reject proposals with invalid signatures
309
+ if (!proposer) {
310
+ this.log.warn(`Received checkpoint proposal with invalid signature for slot ${slotNumber}`);
311
+ return undefined;
312
+ }
313
+ // Ignore proposals from ourselves (may happen in HA setups)
314
+ if (this.getValidatorAddresses().some((addr)=>addr.equals(proposer))) {
315
+ this.log.warn(`Ignoring block proposal from self for slot ${slotNumber}`, {
316
+ proposer: proposer.toString(),
317
+ slotNumber
318
+ });
319
+ return undefined;
320
+ }
321
+ // Validate fee asset price modifier is within allowed range
322
+ if (!validateFeeAssetPriceModifier(proposal.feeAssetPriceModifier)) {
323
+ this.log.warn(`Received checkpoint proposal with invalid feeAssetPriceModifier ${proposal.feeAssetPriceModifier} for slot ${slotNumber}`);
324
+ return undefined;
325
+ }
326
+ // Check that I have any address in current committee before attesting
327
+ const inCommittee = await this.epochCache.filterInCommittee(slotNumber, this.getValidatorAddresses());
328
+ const partOfCommittee = inCommittee.length > 0;
329
+ const proposalInfo = {
330
+ slotNumber,
331
+ archive: proposal.archive.toString(),
332
+ proposer: proposer.toString(),
333
+ txCount: proposal.txHashes.length
334
+ };
335
+ this.log.info(`Received checkpoint proposal for slot ${slotNumber}`, {
336
+ ...proposalInfo,
337
+ txHashes: proposal.txHashes.map((t)=>t.toString()),
338
+ fishermanMode: this.config.fishermanMode || false
339
+ });
340
+ // Validate the checkpoint proposal before attesting (unless skipCheckpointProposalValidation is set)
341
+ if (this.config.skipCheckpointProposalValidation) {
342
+ this.log.warn(`Skipping checkpoint proposal validation for slot ${slotNumber}`, proposalInfo);
343
+ } else {
344
+ const validationResult = await this.validateCheckpointProposal(proposal, proposalInfo);
345
+ if (!validationResult.isValid) {
346
+ this.log.warn(`Checkpoint proposal validation failed: ${validationResult.reason}`, proposalInfo);
347
+ return undefined;
348
+ }
349
+ }
350
+ // Upload blobs to filestore if we can (fire and forget)
351
+ if (this.blobClient.canUpload()) {
352
+ void this.uploadBlobsForCheckpoint(proposal, proposalInfo);
353
+ }
194
354
  // Check that I have any address in current committee before attesting
195
- if (!partOfCommittee) {
355
+ // In fisherman mode, we still create attestations for validation even if not in committee
356
+ if (!partOfCommittee && !this.config.fishermanMode) {
196
357
  this.log.verbose(`No validator in the current committee, skipping attestation`, proposalInfo);
197
358
  return undefined;
198
359
  }
199
360
  // Provided all of the above checks pass, we can attest to the proposal
200
- this.log.info(`Attesting to proposal for block at slot ${slotNumber}`, proposalInfo);
201
- this.metrics.incAttestations(inCommittee.length);
202
- // If the above function does not throw an error, then we can attest to the proposal
203
- return this.createBlockAttestationsFromProposal(proposal, inCommittee);
361
+ this.log.info(`${partOfCommittee ? 'Attesting to' : 'Validated'} checkpoint proposal for slot ${slotNumber}`, {
362
+ ...proposalInfo,
363
+ inCommittee: partOfCommittee,
364
+ fishermanMode: this.config.fishermanMode || false
365
+ });
366
+ this.metrics.incSuccessfulAttestations(inCommittee.length);
367
+ // Determine which validators should attest
368
+ let attestors;
369
+ if (partOfCommittee) {
370
+ attestors = inCommittee;
371
+ } else if (this.config.fishermanMode) {
372
+ // In fisherman mode, create attestations for validation purposes even if not in committee. These won't be broadcast.
373
+ attestors = this.getValidatorAddresses();
374
+ } else {
375
+ attestors = [];
376
+ }
377
+ // Only create attestations if we have attestors
378
+ if (attestors.length === 0) {
379
+ return undefined;
380
+ }
381
+ if (this.config.fishermanMode) {
382
+ // bail out early and don't save attestations to the pool in fisherman mode
383
+ this.log.info(`Creating checkpoint attestations for slot ${slotNumber}`, {
384
+ ...proposalInfo,
385
+ attestors: attestors.map((a)=>a.toString())
386
+ });
387
+ return undefined;
388
+ }
389
+ return await this.createCheckpointAttestationsFromProposal(proposal, attestors);
390
+ }
391
+ /**
392
+ * Checks if we should attest to a slot based on equivocation prevention rules.
393
+ * @returns true if we should attest, false if we should skip
394
+ */ shouldAttestToSlot(slotNumber) {
395
+ // If attestToEquivocatedProposals is true, always allow
396
+ if (this.config.attestToEquivocatedProposals) {
397
+ return true;
398
+ }
399
+ // Check if incoming slot is strictly greater than last attested
400
+ if (this.lastAttestedProposal && slotNumber <= this.lastAttestedProposal.slotNumber) {
401
+ this.log.warn(`Refusing to process a proposal for slot ${slotNumber} given we already attested to a proposal for slot ${this.lastAttestedProposal.slotNumber}`);
402
+ return false;
403
+ }
404
+ return true;
405
+ }
406
+ async createCheckpointAttestationsFromProposal(proposal, attestors = []) {
407
+ // Equivocation check: must happen right before signing to minimize the race window
408
+ if (!this.shouldAttestToSlot(proposal.slotNumber)) {
409
+ return undefined;
410
+ }
411
+ const attestations = await this.validationService.attestToCheckpointProposal(proposal, attestors);
412
+ // Track the proposal we attested to (to prevent equivocation)
413
+ this.lastAttestedProposal = proposal;
414
+ await this.p2pClient.addOwnCheckpointAttestations(attestations);
415
+ return attestations;
416
+ }
417
+ /**
418
+ * Validates a checkpoint proposal by building the full checkpoint and comparing it with the proposal.
419
+ * @returns Validation result with isValid flag and reason if invalid.
420
+ */ async validateCheckpointProposal(proposal, proposalInfo) {
421
+ const slot = proposal.slotNumber;
422
+ // Timeout block syncing at the start of the next slot
423
+ const config = this.checkpointsBuilder.getConfig();
424
+ const nextSlotTimestampSeconds = Number(getTimestampForSlot(SlotNumber(slot + 1), config));
425
+ const timeoutSeconds = Math.max(1, nextSlotTimestampSeconds - Math.floor(this.dateProvider.now() / 1000));
426
+ // Wait for last block to sync by archive
427
+ let lastBlockHeader;
428
+ try {
429
+ lastBlockHeader = await retryUntil(async ()=>{
430
+ await this.blockSource.syncImmediate();
431
+ return this.blockSource.getBlockHeaderByArchive(proposal.archive);
432
+ }, `waiting for block with archive ${proposal.archive.toString()} for slot ${slot}`, timeoutSeconds, 0.5);
433
+ } catch (err) {
434
+ if (err instanceof TimeoutError) {
435
+ this.log.warn(`Timed out waiting for block with archive matching checkpoint proposal`, proposalInfo);
436
+ return {
437
+ isValid: false,
438
+ reason: 'last_block_not_found'
439
+ };
440
+ }
441
+ this.log.error(`Error fetching last block for checkpoint proposal`, err, proposalInfo);
442
+ return {
443
+ isValid: false,
444
+ reason: 'block_fetch_error'
445
+ };
446
+ }
447
+ if (!lastBlockHeader) {
448
+ this.log.warn(`Last block not found for checkpoint proposal`, proposalInfo);
449
+ return {
450
+ isValid: false,
451
+ reason: 'last_block_not_found'
452
+ };
453
+ }
454
+ // Get all full blocks for the slot and checkpoint
455
+ const blocks = await this.blockSource.getBlocksForSlot(slot);
456
+ if (blocks.length === 0) {
457
+ this.log.warn(`No blocks found for slot ${slot}`, proposalInfo);
458
+ return {
459
+ isValid: false,
460
+ reason: 'no_blocks_for_slot'
461
+ };
462
+ }
463
+ // Ensure the last block for this slot matches the archive in the checkpoint proposal
464
+ if (!blocks.at(-1)?.archive.root.equals(proposal.archive)) {
465
+ this.log.warn(`Last block archive mismatch for checkpoint proposal`, proposalInfo);
466
+ return {
467
+ isValid: false,
468
+ reason: 'last_block_archive_mismatch'
469
+ };
470
+ }
471
+ this.log.debug(`Found ${blocks.length} blocks for slot ${slot}`, {
472
+ ...proposalInfo,
473
+ blockNumbers: blocks.map((b)=>b.number)
474
+ });
475
+ // Get checkpoint constants from first block
476
+ const firstBlock = blocks[0];
477
+ const constants = this.extractCheckpointConstants(firstBlock);
478
+ const checkpointNumber = firstBlock.checkpointNumber;
479
+ // Get L1-to-L2 messages for this checkpoint
480
+ const l1ToL2Messages = await this.l1ToL2MessageSource.getL1ToL2Messages(checkpointNumber);
481
+ // Collect the out hashes of all the checkpoints before this one in the same epoch
482
+ const epoch = getEpochAtSlot(slot, this.epochCache.getL1Constants());
483
+ const previousCheckpointOutHashes = (await this.blockSource.getCheckpointsDataForEpoch(epoch)).filter((c)=>c.checkpointNumber < checkpointNumber).map((c)=>c.checkpointOutHash);
484
+ // Fork world state at the block before the first block
485
+ const parentBlockNumber = BlockNumber(firstBlock.number - 1);
486
+ const fork = await this.worldState.fork(parentBlockNumber);
487
+ try {
488
+ // Create checkpoint builder with all existing blocks
489
+ const checkpointBuilder = await this.checkpointsBuilder.openCheckpoint(checkpointNumber, constants, proposal.feeAssetPriceModifier, l1ToL2Messages, previousCheckpointOutHashes, fork, blocks, this.log.getBindings());
490
+ // Complete the checkpoint to get computed values
491
+ const computedCheckpoint = await checkpointBuilder.completeCheckpoint();
492
+ // Compare checkpoint header with proposal
493
+ if (!computedCheckpoint.header.equals(proposal.checkpointHeader)) {
494
+ this.log.warn(`Checkpoint header mismatch`, {
495
+ ...proposalInfo,
496
+ computed: computedCheckpoint.header.toInspect(),
497
+ proposal: proposal.checkpointHeader.toInspect()
498
+ });
499
+ return {
500
+ isValid: false,
501
+ reason: 'checkpoint_header_mismatch'
502
+ };
503
+ }
504
+ // Compare archive root with proposal
505
+ if (!computedCheckpoint.archive.root.equals(proposal.archive)) {
506
+ this.log.warn(`Archive root mismatch`, {
507
+ ...proposalInfo,
508
+ computed: computedCheckpoint.archive.root.toString(),
509
+ proposal: proposal.archive.toString()
510
+ });
511
+ return {
512
+ isValid: false,
513
+ reason: 'archive_mismatch'
514
+ };
515
+ }
516
+ // Check that the accumulated epoch out hash matches the value in the proposal.
517
+ // The epoch out hash is the accumulated hash of all checkpoint out hashes in the epoch.
518
+ const checkpointOutHash = computedCheckpoint.getCheckpointOutHash();
519
+ const computedEpochOutHash = accumulateCheckpointOutHashes([
520
+ ...previousCheckpointOutHashes,
521
+ checkpointOutHash
522
+ ]);
523
+ const proposalEpochOutHash = proposal.checkpointHeader.epochOutHash;
524
+ if (!computedEpochOutHash.equals(proposalEpochOutHash)) {
525
+ this.log.warn(`Epoch out hash mismatch`, {
526
+ proposalEpochOutHash: proposalEpochOutHash.toString(),
527
+ computedEpochOutHash: computedEpochOutHash.toString(),
528
+ checkpointOutHash: checkpointOutHash.toString(),
529
+ previousCheckpointOutHashes: previousCheckpointOutHashes.map((h)=>h.toString()),
530
+ ...proposalInfo
531
+ });
532
+ return {
533
+ isValid: false,
534
+ reason: 'out_hash_mismatch'
535
+ };
536
+ }
537
+ this.log.verbose(`Checkpoint proposal validation successful for slot ${slot}`, proposalInfo);
538
+ return {
539
+ isValid: true
540
+ };
541
+ } finally{
542
+ await fork.close();
543
+ }
544
+ }
545
+ /**
546
+ * Extract checkpoint global variables from a block.
547
+ */ extractCheckpointConstants(block) {
548
+ const gv = block.header.globalVariables;
549
+ return {
550
+ chainId: gv.chainId,
551
+ version: gv.version,
552
+ slotNumber: gv.slotNumber,
553
+ timestamp: gv.timestamp,
554
+ coinbase: gv.coinbase,
555
+ feeRecipient: gv.feeRecipient,
556
+ gasFees: gv.gasFees
557
+ };
558
+ }
559
+ /**
560
+ * Uploads blobs for a checkpoint to the filestore (fire and forget).
561
+ */ async uploadBlobsForCheckpoint(proposal, proposalInfo) {
562
+ try {
563
+ const lastBlockHeader = await this.blockSource.getBlockHeaderByArchive(proposal.archive);
564
+ if (!lastBlockHeader) {
565
+ this.log.warn(`Failed to get last block header for blob upload`, proposalInfo);
566
+ return;
567
+ }
568
+ const blocks = await this.blockSource.getBlocksForSlot(proposal.slotNumber);
569
+ if (blocks.length === 0) {
570
+ this.log.warn(`No blocks found for blob upload`, proposalInfo);
571
+ return;
572
+ }
573
+ const blobFields = blocks.flatMap((b)=>b.toBlobFields());
574
+ const blobs = await getBlobsPerL1Block(blobFields);
575
+ await this.blobClient.sendBlobsToFilestore(blobs);
576
+ this.log.debug(`Uploaded ${blobs.length} blobs to filestore for checkpoint at slot ${proposal.slotNumber}`, {
577
+ ...proposalInfo,
578
+ numBlobs: blobs.length
579
+ });
580
+ } catch (err) {
581
+ this.log.warn(`Failed to upload blobs for checkpoint: ${err}`, proposalInfo);
582
+ }
204
583
  }
205
584
  slashInvalidBlock(proposal) {
206
585
  const proposer = proposal.getSender();
@@ -220,36 +599,107 @@ const SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT = [
220
599
  validator: proposer,
221
600
  amount: this.config.slashBroadcastedInvalidBlockPenalty,
222
601
  offenseType: OffenseType.BROADCASTED_INVALID_BLOCK_PROPOSAL,
223
- epochOrSlot: proposal.slotNumber.toBigInt()
602
+ epochOrSlot: BigInt(proposal.slotNumber)
603
+ }
604
+ ]);
605
+ }
606
+ /**
607
+ * Handle detection of a duplicate proposal (equivocation).
608
+ * Emits a slash event when a proposer sends multiple proposals for the same position.
609
+ */ handleDuplicateProposal(info) {
610
+ const { slot, proposer, type } = info;
611
+ this.log.warn(`Triggering slash event for duplicate ${type} proposal from ${proposer.toString()} at slot ${slot}`, {
612
+ proposer: proposer.toString(),
613
+ slot,
614
+ type
615
+ });
616
+ // Emit slash event
617
+ this.emit(WANT_TO_SLASH_EVENT, [
618
+ {
619
+ validator: proposer,
620
+ amount: this.config.slashDuplicateProposalPenalty,
621
+ offenseType: OffenseType.DUPLICATE_PROPOSAL,
622
+ epochOrSlot: BigInt(slot)
224
623
  }
225
624
  ]);
226
625
  }
227
- async createBlockProposal(blockNumber, header, archive, stateReference, txs, proposerAddress, options) {
228
- if (this.previousProposal?.slotNumber.equals(header.slotNumber)) {
229
- this.log.verbose(`Already made a proposal for the same slot, skipping proposal`);
230
- return Promise.resolve(undefined);
626
+ /**
627
+ * Handle detection of a duplicate attestation (equivocation).
628
+ * Emits a slash event when an attester signs attestations for different proposals at the same slot.
629
+ */ handleDuplicateAttestation(info) {
630
+ const { slot, attester } = info;
631
+ this.log.warn(`Triggering slash event for duplicate attestation from ${attester.toString()} at slot ${slot}`, {
632
+ attester: attester.toString(),
633
+ slot
634
+ });
635
+ this.emit(WANT_TO_SLASH_EVENT, [
636
+ {
637
+ validator: attester,
638
+ amount: this.config.slashDuplicateAttestationPenalty,
639
+ offenseType: OffenseType.DUPLICATE_ATTESTATION,
640
+ epochOrSlot: BigInt(slot)
641
+ }
642
+ ]);
643
+ }
644
+ async createBlockProposal(blockHeader, indexWithinCheckpoint, inHash, archive, txs, proposerAddress, options = {}) {
645
+ // Validate that we're not creating a proposal for an older or equal position
646
+ if (this.lastProposedBlock) {
647
+ const lastSlot = this.lastProposedBlock.slotNumber;
648
+ const lastIndex = this.lastProposedBlock.indexWithinCheckpoint;
649
+ const newSlot = blockHeader.globalVariables.slotNumber;
650
+ if (newSlot < lastSlot || newSlot === lastSlot && indexWithinCheckpoint <= lastIndex) {
651
+ throw new Error(`Cannot create block proposal for slot ${newSlot} index ${indexWithinCheckpoint}: ` + `already proposed block for slot ${lastSlot} index ${lastIndex}`);
652
+ }
653
+ }
654
+ this.log.info(`Assembling block proposal for block ${blockHeader.globalVariables.blockNumber} slot ${blockHeader.globalVariables.slotNumber}`);
655
+ const newProposal = await this.validationService.createBlockProposal(blockHeader, indexWithinCheckpoint, inHash, archive, txs, proposerAddress, {
656
+ ...options,
657
+ broadcastInvalidBlockProposal: this.config.broadcastInvalidBlockProposal
658
+ });
659
+ this.lastProposedBlock = newProposal;
660
+ return newProposal;
661
+ }
662
+ async createCheckpointProposal(checkpointHeader, archive, feeAssetPriceModifier, lastBlockInfo, proposerAddress, options = {}) {
663
+ // Validate that we're not creating a proposal for an older or equal slot
664
+ if (this.lastProposedCheckpoint) {
665
+ const lastSlot = this.lastProposedCheckpoint.slotNumber;
666
+ const newSlot = checkpointHeader.slotNumber;
667
+ if (newSlot <= lastSlot) {
668
+ throw new Error(`Cannot create checkpoint proposal for slot ${newSlot}: ` + `already proposed checkpoint for slot ${lastSlot}`);
669
+ }
231
670
  }
232
- const newProposal = await this.validationService.createBlockProposal(header, archive, stateReference, txs, proposerAddress, options);
233
- this.previousProposal = newProposal;
671
+ this.log.info(`Assembling checkpoint proposal for slot ${checkpointHeader.slotNumber}`);
672
+ const newProposal = await this.validationService.createCheckpointProposal(checkpointHeader, archive, feeAssetPriceModifier, lastBlockInfo, proposerAddress, options);
673
+ this.lastProposedCheckpoint = newProposal;
234
674
  return newProposal;
235
675
  }
236
676
  async broadcastBlockProposal(proposal) {
237
677
  await this.p2pClient.broadcastProposal(proposal);
238
678
  }
239
- async signAttestationsAndSigners(attestationsAndSigners, proposer) {
240
- return await this.validationService.signAttestationsAndSigners(attestationsAndSigners, proposer);
679
+ async signAttestationsAndSigners(attestationsAndSigners, proposer, slot, blockNumber) {
680
+ return await this.validationService.signAttestationsAndSigners(attestationsAndSigners, proposer, slot, blockNumber);
241
681
  }
242
682
  async collectOwnAttestations(proposal) {
243
- const slot = proposal.payload.header.slotNumber.toBigInt();
683
+ const slot = proposal.slotNumber;
244
684
  const inCommittee = await this.epochCache.filterInCommittee(slot, this.getValidatorAddresses());
245
685
  this.log.debug(`Collecting ${inCommittee.length} self-attestations for slot ${slot}`, {
246
686
  inCommittee
247
687
  });
248
- return this.createBlockAttestationsFromProposal(proposal, inCommittee);
688
+ const attestations = await this.createCheckpointAttestationsFromProposal(proposal, inCommittee);
689
+ if (!attestations) {
690
+ return [];
691
+ }
692
+ // We broadcast our own attestations to our peers so, in case our block does not get mined on L1,
693
+ // other nodes can see that our validators did attest to this block proposal, and do not slash us
694
+ // due to inactivity for missed attestations.
695
+ void this.p2pClient.broadcastCheckpointAttestations(attestations).catch((err)=>{
696
+ this.log.error(`Failed to broadcast self-attestations for slot ${slot}`, err);
697
+ });
698
+ return attestations;
249
699
  }
250
700
  async collectAttestations(proposal, required, deadline) {
251
- // Wait and poll the p2pClient's attestation pool for this block until we have enough attestations
252
- const slot = proposal.payload.header.slotNumber.toBigInt();
701
+ // Wait and poll the p2pClient's attestation pool for this checkpoint until we have enough attestations
702
+ const slot = proposal.slotNumber;
253
703
  this.log.debug(`Collecting ${required} attestations for slot ${slot} with deadline ${deadline.toISOString()}`);
254
704
  if (+deadline < this.dateProvider.now()) {
255
705
  this.log.error(`Deadline ${deadline.toISOString()} for collecting ${required} attestations for slot ${slot} is in the past`);
@@ -260,13 +710,13 @@ const SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT = [
260
710
  const myAddresses = this.getValidatorAddresses();
261
711
  let attestations = [];
262
712
  while(true){
263
- // Filter out attestations with a mismatching payload. This should NOT happen since we have verified
713
+ // Filter out attestations with a mismatching archive. This should NOT happen since we have verified
264
714
  // the proposer signature (ie our own) before accepting the attestation into the pool via the p2p client.
265
- const collectedAttestations = (await this.p2pClient.getAttestationsForSlot(slot, proposalId)).filter((attestation)=>{
266
- if (!attestation.payload.equals(proposal.payload)) {
267
- this.log.warn(`Received attestation for slot ${slot} with mismatched payload from ${attestation.getSender()?.toString()}`, {
268
- attestationPayload: attestation.payload,
269
- proposalPayload: proposal.payload
715
+ const collectedAttestations = (await this.p2pClient.getCheckpointAttestationsForSlot(slot, proposalId)).filter((attestation)=>{
716
+ if (!attestation.archive.equals(proposal.archive)) {
717
+ this.log.warn(`Received attestation for slot ${slot} with mismatched archive from ${attestation.getSender()?.toString()}`, {
718
+ attestationArchive: attestation.archive.toString(),
719
+ proposalArchive: proposal.archive.toString()
270
720
  });
271
721
  return false;
272
722
  }
@@ -294,15 +744,10 @@ const SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT = [
294
744
  this.log.error(`Timeout ${deadline.toISOString()} waiting for ${required} attestations for slot ${slot}`);
295
745
  throw new AttestationTimeoutError(attestations.length, required, slot);
296
746
  }
297
- this.log.debug(`Collected ${attestations.length} attestations so far`);
747
+ this.log.debug(`Collected ${attestations.length} of ${required} attestations so far`);
298
748
  await sleep(this.config.attestationPollingIntervalMs);
299
749
  }
300
750
  }
301
- async createBlockAttestationsFromProposal(proposal, attestors = []) {
302
- const attestations = await this.validationService.attestToProposal(proposal, attestors);
303
- await this.p2pClient.addAttestations(attestations);
304
- return attestations;
305
- }
306
751
  async handleAuthRequest(peer, msg) {
307
752
  const authRequest = AuthRequest.fromBuffer(msg);
308
753
  const statusMessage = await this.p2pClient.handleAuthRequestFromPeer(authRequest, peer).catch((_)=>undefined);
@@ -317,7 +762,11 @@ const SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT = [
317
762
  return Buffer.alloc(0);
318
763
  }
319
764
  const payloadToSign = authRequest.getPayloadToSign();
320
- const signature = await this.keyStore.signMessageWithAddress(addressToUse, payloadToSign);
765
+ // AUTH_REQUEST doesn't require HA protection - multiple signatures are safe
766
+ const context = {
767
+ dutyType: DutyType.AUTH_REQUEST
768
+ };
769
+ const signature = await this.keyStore.signMessageWithAddress(addressToUse, payloadToSign, context);
321
770
  const authResponse = new AuthResponse(statusMessage, signature);
322
771
  return authResponse.toBuffer();
323
772
  }