@aztec/validator-client 0.0.1-commit.d3ec352c → 0.0.1-commit.e310a4c8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +282 -0
- package/dest/block_proposal_handler.d.ts +21 -11
- package/dest/block_proposal_handler.d.ts.map +1 -1
- package/dest/block_proposal_handler.js +339 -83
- package/dest/checkpoint_builder.d.ts +66 -0
- package/dest/checkpoint_builder.d.ts.map +1 -0
- package/dest/checkpoint_builder.js +173 -0
- package/dest/config.d.ts +1 -1
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +12 -8
- package/dest/duties/validation_service.d.ts +42 -13
- package/dest/duties/validation_service.d.ts.map +1 -1
- package/dest/duties/validation_service.js +111 -28
- package/dest/factory.d.ts +13 -8
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +2 -2
- package/dest/index.d.ts +3 -1
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +2 -0
- package/dest/key_store/ha_key_store.d.ts +99 -0
- package/dest/key_store/ha_key_store.d.ts.map +1 -0
- package/dest/key_store/ha_key_store.js +208 -0
- package/dest/key_store/index.d.ts +2 -1
- package/dest/key_store/index.d.ts.map +1 -1
- package/dest/key_store/index.js +1 -0
- package/dest/key_store/interface.d.ts +36 -6
- package/dest/key_store/interface.d.ts.map +1 -1
- package/dest/key_store/local_key_store.d.ts +10 -5
- package/dest/key_store/local_key_store.d.ts.map +1 -1
- package/dest/key_store/local_key_store.js +9 -5
- package/dest/key_store/node_keystore_adapter.d.ts +18 -5
- package/dest/key_store/node_keystore_adapter.d.ts.map +1 -1
- package/dest/key_store/node_keystore_adapter.js +18 -4
- package/dest/key_store/web3signer_key_store.d.ts +10 -5
- package/dest/key_store/web3signer_key_store.d.ts.map +1 -1
- package/dest/key_store/web3signer_key_store.js +9 -5
- package/dest/metrics.d.ts +4 -3
- package/dest/metrics.d.ts.map +1 -1
- package/dest/metrics.js +34 -30
- package/dest/tx_validator/index.d.ts +3 -0
- package/dest/tx_validator/index.d.ts.map +1 -0
- package/dest/tx_validator/index.js +2 -0
- package/dest/tx_validator/nullifier_cache.d.ts +14 -0
- package/dest/tx_validator/nullifier_cache.d.ts.map +1 -0
- package/dest/tx_validator/nullifier_cache.js +24 -0
- package/dest/tx_validator/tx_validator_factory.d.ts +19 -0
- package/dest/tx_validator/tx_validator_factory.d.ts.map +1 -0
- package/dest/tx_validator/tx_validator_factory.js +54 -0
- package/dest/validator.d.ts +47 -20
- package/dest/validator.d.ts.map +1 -1
- package/dest/validator.js +313 -54
- package/package.json +21 -11
- package/src/block_proposal_handler.ts +260 -49
- package/src/checkpoint_builder.ts +314 -0
- package/src/config.ts +11 -7
- package/src/duties/validation_service.ts +155 -33
- package/src/factory.ts +17 -8
- package/src/index.ts +2 -0
- package/src/key_store/ha_key_store.ts +269 -0
- package/src/key_store/index.ts +1 -0
- package/src/key_store/interface.ts +44 -5
- package/src/key_store/local_key_store.ts +14 -5
- package/src/key_store/node_keystore_adapter.ts +28 -5
- package/src/key_store/web3signer_key_store.ts +18 -5
- package/src/metrics.ts +45 -33
- package/src/tx_validator/index.ts +2 -0
- package/src/tx_validator/nullifier_cache.ts +30 -0
- package/src/tx_validator/tx_validator_factory.ts +154 -0
- package/src/validator.ts +433 -83
package/src/validator.ts
CHANGED
|
@@ -1,31 +1,60 @@
|
|
|
1
|
+
import type { BlobClientInterface } from '@aztec/blob-client/client';
|
|
2
|
+
import { type Blob, getBlobsPerL1Block } from '@aztec/blob-lib';
|
|
1
3
|
import type { EpochCache } from '@aztec/epoch-cache';
|
|
2
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
BlockNumber,
|
|
6
|
+
CheckpointNumber,
|
|
7
|
+
EpochNumber,
|
|
8
|
+
IndexWithinCheckpoint,
|
|
9
|
+
SlotNumber,
|
|
10
|
+
} from '@aztec/foundation/branded-types';
|
|
11
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
12
|
+
import { TimeoutError } from '@aztec/foundation/error';
|
|
3
13
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
14
|
import type { Signature } from '@aztec/foundation/eth-signature';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
15
|
+
import { type LogData, type Logger, createLogger } from '@aztec/foundation/log';
|
|
16
|
+
import { retryUntil } from '@aztec/foundation/retry';
|
|
7
17
|
import { RunningPromise } from '@aztec/foundation/running-promise';
|
|
8
18
|
import { sleep } from '@aztec/foundation/sleep';
|
|
9
19
|
import { DateProvider } from '@aztec/foundation/timer';
|
|
10
20
|
import type { KeystoreManager } from '@aztec/node-keystore';
|
|
11
|
-
import type { P2P, PeerId
|
|
21
|
+
import type { P2P, PeerId } from '@aztec/p2p';
|
|
12
22
|
import { AuthRequest, AuthResponse, BlockProposalValidator, ReqRespSubProtocol } from '@aztec/p2p';
|
|
13
23
|
import { OffenseType, WANT_TO_SLASH_EVENT, type Watcher, type WatcherEmitter } from '@aztec/slasher';
|
|
14
24
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
15
|
-
import type { CommitteeAttestationsAndSigners, L2BlockSource } from '@aztec/stdlib/block';
|
|
16
|
-
import
|
|
17
|
-
import type {
|
|
18
|
-
|
|
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 type {
|
|
36
|
+
BlockProposal,
|
|
37
|
+
BlockProposalOptions,
|
|
38
|
+
CheckpointAttestation,
|
|
39
|
+
CheckpointProposalCore,
|
|
40
|
+
CheckpointProposalOptions,
|
|
41
|
+
} from '@aztec/stdlib/p2p';
|
|
42
|
+
import { CheckpointProposal } from '@aztec/stdlib/p2p';
|
|
19
43
|
import type { CheckpointHeader } from '@aztec/stdlib/rollup';
|
|
20
|
-
import type { Tx } from '@aztec/stdlib/tx';
|
|
44
|
+
import type { BlockHeader, CheckpointGlobalVariables, Tx } from '@aztec/stdlib/tx';
|
|
21
45
|
import { AttestationTimeoutError } from '@aztec/stdlib/validators';
|
|
22
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';
|
|
23
49
|
|
|
24
50
|
import { EventEmitter } from 'events';
|
|
25
51
|
import type { TypedDataDefinition } from 'viem';
|
|
26
52
|
|
|
27
53
|
import { BlockProposalHandler, type BlockProposalValidationFailureReason } from './block_proposal_handler.js';
|
|
54
|
+
import type { FullNodeCheckpointsBuilder } from './checkpoint_builder.js';
|
|
28
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';
|
|
29
58
|
import { NodeKeystoreAdapter } from './key_store/node_keystore_adapter.js';
|
|
30
59
|
import { ValidatorMetrics } from './metrics.js';
|
|
31
60
|
|
|
@@ -60,11 +89,16 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
60
89
|
private proposersOfInvalidBlocks: Set<string> = new Set();
|
|
61
90
|
|
|
62
91
|
protected constructor(
|
|
63
|
-
private keyStore:
|
|
92
|
+
private keyStore: ExtendedValidatorKeyStore,
|
|
64
93
|
private epochCache: EpochCache,
|
|
65
94
|
private p2pClient: P2P,
|
|
66
95
|
private blockProposalHandler: BlockProposalHandler,
|
|
96
|
+
private blockSource: L2BlockSource,
|
|
97
|
+
private checkpointsBuilder: FullNodeCheckpointsBuilder,
|
|
98
|
+
private worldState: WorldStateSynchronizer,
|
|
99
|
+
private l1ToL2MessageSource: L1ToL2MessageSource,
|
|
67
100
|
private config: ValidatorClientFullConfig,
|
|
101
|
+
private blobClient: BlobClientInterface,
|
|
68
102
|
private dateProvider: DateProvider = new DateProvider(),
|
|
69
103
|
telemetry: TelemetryClient = getTelemetryClient(),
|
|
70
104
|
log = createLogger('validator'),
|
|
@@ -138,15 +172,17 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
138
172
|
}
|
|
139
173
|
}
|
|
140
174
|
|
|
141
|
-
static new(
|
|
175
|
+
static async new(
|
|
142
176
|
config: ValidatorClientFullConfig,
|
|
143
|
-
|
|
177
|
+
checkpointsBuilder: FullNodeCheckpointsBuilder,
|
|
178
|
+
worldState: WorldStateSynchronizer,
|
|
144
179
|
epochCache: EpochCache,
|
|
145
180
|
p2pClient: P2P,
|
|
146
|
-
blockSource: L2BlockSource,
|
|
181
|
+
blockSource: L2BlockSource & L2BlockSink,
|
|
147
182
|
l1ToL2MessageSource: L1ToL2MessageSource,
|
|
148
|
-
txProvider:
|
|
183
|
+
txProvider: ITxProvider,
|
|
149
184
|
keyStoreManager: KeystoreManager,
|
|
185
|
+
blobClient: BlobClientInterface,
|
|
150
186
|
dateProvider: DateProvider = new DateProvider(),
|
|
151
187
|
telemetry: TelemetryClient = getTelemetryClient(),
|
|
152
188
|
) {
|
|
@@ -155,23 +191,41 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
155
191
|
txsPermitted: !config.disableTransactions,
|
|
156
192
|
});
|
|
157
193
|
const blockProposalHandler = new BlockProposalHandler(
|
|
158
|
-
|
|
194
|
+
checkpointsBuilder,
|
|
195
|
+
worldState,
|
|
159
196
|
blockSource,
|
|
160
197
|
l1ToL2MessageSource,
|
|
161
198
|
txProvider,
|
|
162
199
|
blockProposalValidator,
|
|
200
|
+
epochCache,
|
|
163
201
|
config,
|
|
164
202
|
metrics,
|
|
165
203
|
dateProvider,
|
|
166
204
|
telemetry,
|
|
167
205
|
);
|
|
168
206
|
|
|
207
|
+
let validatorKeyStore: ExtendedValidatorKeyStore = NodeKeystoreAdapter.fromKeyStoreManager(keyStoreManager);
|
|
208
|
+
if (config.haSigningEnabled) {
|
|
209
|
+
// If maxStuckDutiesAgeMs is not explicitly set, compute it from Aztec slot duration
|
|
210
|
+
const haConfig = {
|
|
211
|
+
...config,
|
|
212
|
+
maxStuckDutiesAgeMs: config.maxStuckDutiesAgeMs ?? epochCache.getL1Constants().slotDuration * 2 * 1000,
|
|
213
|
+
};
|
|
214
|
+
const { signer } = await createHASigner(haConfig);
|
|
215
|
+
validatorKeyStore = new HAKeyStore(validatorKeyStore, signer);
|
|
216
|
+
}
|
|
217
|
+
|
|
169
218
|
const validator = new ValidatorClient(
|
|
170
|
-
|
|
219
|
+
validatorKeyStore,
|
|
171
220
|
epochCache,
|
|
172
221
|
p2pClient,
|
|
173
222
|
blockProposalHandler,
|
|
223
|
+
blockSource,
|
|
224
|
+
checkpointsBuilder,
|
|
225
|
+
worldState,
|
|
226
|
+
l1ToL2MessageSource,
|
|
174
227
|
config,
|
|
228
|
+
blobClient,
|
|
175
229
|
dateProvider,
|
|
176
230
|
telemetry,
|
|
177
231
|
);
|
|
@@ -189,18 +243,8 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
189
243
|
return this.blockProposalHandler;
|
|
190
244
|
}
|
|
191
245
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
proposal: BlockProposal,
|
|
195
|
-
blockNumber: BlockNumber,
|
|
196
|
-
txs: any[],
|
|
197
|
-
l1ToL2Messages: Fr[],
|
|
198
|
-
): Promise<any> {
|
|
199
|
-
return this.blockProposalHandler.reexecuteTransactions(proposal, blockNumber, txs, l1ToL2Messages);
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
public signWithAddress(addr: EthAddress, msg: TypedDataDefinition) {
|
|
203
|
-
return this.keyStore.signTypedDataWithAddress(addr, msg);
|
|
246
|
+
public signWithAddress(addr: EthAddress, msg: TypedDataDefinition, context: SigningContext) {
|
|
247
|
+
return this.keyStore.signTypedDataWithAddress(addr, msg, context);
|
|
204
248
|
}
|
|
205
249
|
|
|
206
250
|
public getCoinbaseForAttestor(attestor: EthAddress): EthAddress {
|
|
@@ -225,6 +269,8 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
225
269
|
return;
|
|
226
270
|
}
|
|
227
271
|
|
|
272
|
+
await this.keyStore.start();
|
|
273
|
+
|
|
228
274
|
await this.registerHandlers();
|
|
229
275
|
|
|
230
276
|
const myAddresses = this.getValidatorAddresses();
|
|
@@ -240,6 +286,7 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
240
286
|
|
|
241
287
|
public async stop() {
|
|
242
288
|
await this.epochCacheUpdateLoop.stop();
|
|
289
|
+
await this.keyStore.stop();
|
|
243
290
|
}
|
|
244
291
|
|
|
245
292
|
/** Register handlers on the p2p client */
|
|
@@ -248,9 +295,19 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
248
295
|
this.hasRegisteredHandlers = true;
|
|
249
296
|
this.log.debug(`Registering validator handlers for p2p client`);
|
|
250
297
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
298
|
+
// Block proposal handler - validates but does NOT attest (validators only attest to checkpoints)
|
|
299
|
+
const blockHandler = (block: BlockProposal, proposalSender: PeerId): Promise<boolean> =>
|
|
300
|
+
this.validateBlockProposal(block, proposalSender);
|
|
301
|
+
this.p2pClient.registerBlockProposalHandler(blockHandler);
|
|
302
|
+
|
|
303
|
+
// Checkpoint proposal handler - validates and creates attestations
|
|
304
|
+
// The checkpoint is received as CheckpointProposalCore since the lastBlock is extracted
|
|
305
|
+
// and processed separately via the block handler above.
|
|
306
|
+
const checkpointHandler = (
|
|
307
|
+
checkpoint: CheckpointProposalCore,
|
|
308
|
+
proposalSender: PeerId,
|
|
309
|
+
): Promise<CheckpointAttestation[] | undefined> => this.attestToCheckpointProposal(checkpoint, proposalSender);
|
|
310
|
+
this.p2pClient.registerCheckpointProposalHandler(checkpointHandler);
|
|
254
311
|
|
|
255
312
|
const myAddresses = this.getValidatorAddresses();
|
|
256
313
|
this.p2pClient.registerThisValidatorAddresses(myAddresses);
|
|
@@ -259,29 +316,38 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
259
316
|
}
|
|
260
317
|
}
|
|
261
318
|
|
|
262
|
-
|
|
319
|
+
/**
|
|
320
|
+
* Validate a block proposal from a peer.
|
|
321
|
+
* Note: Validators do NOT attest to individual blocks - attestations are only for checkpoint proposals.
|
|
322
|
+
* @returns true if the proposal is valid, false otherwise
|
|
323
|
+
*/
|
|
324
|
+
async validateBlockProposal(proposal: BlockProposal, proposalSender: PeerId): Promise<boolean> {
|
|
263
325
|
const slotNumber = proposal.slotNumber;
|
|
326
|
+
|
|
327
|
+
// Note: During escape hatch, we still want to "validate" proposals for observability,
|
|
328
|
+
// but we intentionally reject them and disable slashing invalid block and attestation flow.
|
|
329
|
+
const escapeHatchOpen = await this.epochCache.isEscapeHatchOpenAtSlot(slotNumber);
|
|
330
|
+
|
|
264
331
|
const proposer = proposal.getSender();
|
|
265
332
|
|
|
266
333
|
// Reject proposals with invalid signatures
|
|
267
334
|
if (!proposer) {
|
|
268
|
-
this.log.warn(`Received proposal with invalid signature for slot ${slotNumber}`);
|
|
269
|
-
return
|
|
335
|
+
this.log.warn(`Received block proposal with invalid signature for slot ${slotNumber}`);
|
|
336
|
+
return false;
|
|
270
337
|
}
|
|
271
338
|
|
|
272
|
-
// Check
|
|
339
|
+
// Check if we're in the committee (for metrics purposes)
|
|
273
340
|
const inCommittee = await this.epochCache.filterInCommittee(slotNumber, this.getValidatorAddresses());
|
|
274
341
|
const partOfCommittee = inCommittee.length > 0;
|
|
275
342
|
|
|
276
343
|
const proposalInfo = { ...proposal.toBlockInfo(), proposer: proposer.toString() };
|
|
277
|
-
this.log.info(`Received proposal for slot ${slotNumber}`, {
|
|
344
|
+
this.log.info(`Received block proposal for slot ${slotNumber}`, {
|
|
278
345
|
...proposalInfo,
|
|
279
346
|
txHashes: proposal.txHashes.map(t => t.toString()),
|
|
280
347
|
fishermanMode: this.config.fishermanMode || false,
|
|
281
348
|
});
|
|
282
349
|
|
|
283
|
-
// Reexecute txs if we are part of the committee
|
|
284
|
-
// invalid proposals even when not in the committee, or if we are configured to always reexecute for monitoring purposes.
|
|
350
|
+
// Reexecute txs if we are part of the committee, or if slashing is enabled, or if we are configured to always reexecute.
|
|
285
351
|
// In fisherman mode, we always reexecute to validate proposals.
|
|
286
352
|
const { validatorReexecute, slashBroadcastedInvalidBlockPenalty, alwaysReexecuteBlockProposals, fishermanMode } =
|
|
287
353
|
this.config;
|
|
@@ -289,16 +355,17 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
289
355
|
fishermanMode ||
|
|
290
356
|
(slashBroadcastedInvalidBlockPenalty > 0n && validatorReexecute) ||
|
|
291
357
|
(partOfCommittee && validatorReexecute) ||
|
|
292
|
-
alwaysReexecuteBlockProposals
|
|
358
|
+
alwaysReexecuteBlockProposals ||
|
|
359
|
+
this.blobClient.canUpload();
|
|
293
360
|
|
|
294
361
|
const validationResult = await this.blockProposalHandler.handleBlockProposal(
|
|
295
362
|
proposal,
|
|
296
363
|
proposalSender,
|
|
297
|
-
!!shouldReexecute,
|
|
364
|
+
!!shouldReexecute && !escapeHatchOpen,
|
|
298
365
|
);
|
|
299
366
|
|
|
300
367
|
if (!validationResult.isValid) {
|
|
301
|
-
this.log.warn(`
|
|
368
|
+
this.log.warn(`Block proposal validation failed: ${validationResult.reason}`, proposalInfo);
|
|
302
369
|
|
|
303
370
|
const reason = validationResult.reason || 'unknown';
|
|
304
371
|
// Classify failure reason: bad proposal vs node issue
|
|
@@ -313,12 +380,13 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
313
380
|
if (badProposalReasons.includes(reason as BlockProposalValidationFailureReason)) {
|
|
314
381
|
this.metrics.incFailedAttestationsBadProposal(1, reason, partOfCommittee);
|
|
315
382
|
} else {
|
|
316
|
-
// Node issues so we can't
|
|
383
|
+
// Node issues so we can't validate
|
|
317
384
|
this.metrics.incFailedAttestationsNodeIssue(1, reason, partOfCommittee);
|
|
318
385
|
}
|
|
319
386
|
|
|
320
387
|
// Slash invalid block proposals (can happen even when not in committee)
|
|
321
388
|
if (
|
|
389
|
+
!escapeHatchOpen &&
|
|
322
390
|
validationResult.reason &&
|
|
323
391
|
SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT.includes(validationResult.reason) &&
|
|
324
392
|
slashBroadcastedInvalidBlockPenalty > 0n
|
|
@@ -326,9 +394,81 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
326
394
|
this.log.warn(`Slashing proposer for invalid block proposal`, proposalInfo);
|
|
327
395
|
this.slashInvalidBlock(proposal);
|
|
328
396
|
}
|
|
397
|
+
return false;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
this.log.info(`Validated block proposal for slot ${slotNumber}`, {
|
|
401
|
+
...proposalInfo,
|
|
402
|
+
inCommittee: partOfCommittee,
|
|
403
|
+
fishermanMode: this.config.fishermanMode || false,
|
|
404
|
+
escapeHatchOpen,
|
|
405
|
+
});
|
|
406
|
+
|
|
407
|
+
if (escapeHatchOpen) {
|
|
408
|
+
this.log.warn(`Escape hatch open for slot ${slotNumber}, rejecting block proposal`, proposalInfo);
|
|
409
|
+
return false;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
return true;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
/**
|
|
416
|
+
* Validate and attest to a checkpoint proposal from a peer.
|
|
417
|
+
* The proposal is received as CheckpointProposalCore (without lastBlock) since
|
|
418
|
+
* the lastBlock is extracted and processed separately via the block handler.
|
|
419
|
+
* @returns Checkpoint attestations if valid, undefined otherwise
|
|
420
|
+
*/
|
|
421
|
+
async attestToCheckpointProposal(
|
|
422
|
+
proposal: CheckpointProposalCore,
|
|
423
|
+
_proposalSender: PeerId,
|
|
424
|
+
): Promise<CheckpointAttestation[] | undefined> {
|
|
425
|
+
const slotNumber = proposal.slotNumber;
|
|
426
|
+
const proposer = proposal.getSender();
|
|
427
|
+
|
|
428
|
+
// If escape hatch is open for this slot's epoch, do not attest.
|
|
429
|
+
if (await this.epochCache.isEscapeHatchOpenAtSlot(slotNumber)) {
|
|
430
|
+
this.log.warn(`Escape hatch open for slot ${slotNumber}, skipping checkpoint attestation handling`);
|
|
329
431
|
return undefined;
|
|
330
432
|
}
|
|
331
433
|
|
|
434
|
+
// Reject proposals with invalid signatures
|
|
435
|
+
if (!proposer) {
|
|
436
|
+
this.log.warn(`Received checkpoint proposal with invalid signature for slot ${slotNumber}`);
|
|
437
|
+
return undefined;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
// Check that I have any address in current committee before attesting
|
|
441
|
+
const inCommittee = await this.epochCache.filterInCommittee(slotNumber, this.getValidatorAddresses());
|
|
442
|
+
const partOfCommittee = inCommittee.length > 0;
|
|
443
|
+
|
|
444
|
+
const proposalInfo = {
|
|
445
|
+
slotNumber,
|
|
446
|
+
archive: proposal.archive.toString(),
|
|
447
|
+
proposer: proposer.toString(),
|
|
448
|
+
txCount: proposal.txHashes.length,
|
|
449
|
+
};
|
|
450
|
+
this.log.info(`Received checkpoint proposal for slot ${slotNumber}`, {
|
|
451
|
+
...proposalInfo,
|
|
452
|
+
txHashes: proposal.txHashes.map(t => t.toString()),
|
|
453
|
+
fishermanMode: this.config.fishermanMode || false,
|
|
454
|
+
});
|
|
455
|
+
|
|
456
|
+
// Validate the checkpoint proposal before attesting (unless skipCheckpointProposalValidation is set)
|
|
457
|
+
if (this.config.skipCheckpointProposalValidation) {
|
|
458
|
+
this.log.warn(`Skipping checkpoint proposal validation for slot ${slotNumber}`, proposalInfo);
|
|
459
|
+
} else {
|
|
460
|
+
const validationResult = await this.validateCheckpointProposal(proposal, proposalInfo);
|
|
461
|
+
if (!validationResult.isValid) {
|
|
462
|
+
this.log.warn(`Checkpoint proposal validation failed: ${validationResult.reason}`, proposalInfo);
|
|
463
|
+
return undefined;
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
// Upload blobs to filestore if we can (fire and forget)
|
|
468
|
+
if (this.blobClient.canUpload()) {
|
|
469
|
+
void this.uploadBlobsForCheckpoint(proposal, proposalInfo);
|
|
470
|
+
}
|
|
471
|
+
|
|
332
472
|
// Check that I have any address in current committee before attesting
|
|
333
473
|
// In fisherman mode, we still create attestations for validation even if not in committee
|
|
334
474
|
if (!partOfCommittee && !this.config.fishermanMode) {
|
|
@@ -337,7 +477,7 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
337
477
|
}
|
|
338
478
|
|
|
339
479
|
// Provided all of the above checks pass, we can attest to the proposal
|
|
340
|
-
this.log.info(`${partOfCommittee ? 'Attesting to' : 'Validated'} proposal for slot ${slotNumber}`, {
|
|
480
|
+
this.log.info(`${partOfCommittee ? 'Attesting to' : 'Validated'} checkpoint proposal for slot ${slotNumber}`, {
|
|
341
481
|
...proposalInfo,
|
|
342
482
|
inCommittee: partOfCommittee,
|
|
343
483
|
fishermanMode: this.config.fishermanMode || false,
|
|
@@ -345,7 +485,6 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
345
485
|
|
|
346
486
|
this.metrics.incSuccessfulAttestations(inCommittee.length);
|
|
347
487
|
|
|
348
|
-
// If the above function does not throw an error, then we can attest to the proposal
|
|
349
488
|
// Determine which validators should attest
|
|
350
489
|
let attestors: EthAddress[];
|
|
351
490
|
if (partOfCommittee) {
|
|
@@ -364,13 +503,195 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
364
503
|
|
|
365
504
|
if (this.config.fishermanMode) {
|
|
366
505
|
// bail out early and don't save attestations to the pool in fisherman mode
|
|
367
|
-
this.log.info(`Creating attestations for
|
|
506
|
+
this.log.info(`Creating checkpoint attestations for slot ${slotNumber}`, {
|
|
368
507
|
...proposalInfo,
|
|
369
508
|
attestors: attestors.map(a => a.toString()),
|
|
370
509
|
});
|
|
371
510
|
return undefined;
|
|
372
511
|
}
|
|
373
|
-
|
|
512
|
+
|
|
513
|
+
return this.createCheckpointAttestationsFromProposal(proposal, attestors);
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
private async createCheckpointAttestationsFromProposal(
|
|
517
|
+
proposal: CheckpointProposalCore,
|
|
518
|
+
attestors: EthAddress[] = [],
|
|
519
|
+
): Promise<CheckpointAttestation[]> {
|
|
520
|
+
const attestations = await this.validationService.attestToCheckpointProposal(proposal, attestors);
|
|
521
|
+
await this.p2pClient.addCheckpointAttestations(attestations);
|
|
522
|
+
return attestations;
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
/**
|
|
526
|
+
* Validates a checkpoint proposal by building the full checkpoint and comparing it with the proposal.
|
|
527
|
+
* @returns Validation result with isValid flag and reason if invalid.
|
|
528
|
+
*/
|
|
529
|
+
private async validateCheckpointProposal(
|
|
530
|
+
proposal: CheckpointProposalCore,
|
|
531
|
+
proposalInfo: LogData,
|
|
532
|
+
): Promise<{ isValid: true } | { isValid: false; reason: string }> {
|
|
533
|
+
const slot = proposal.slotNumber;
|
|
534
|
+
const timeoutSeconds = 10; // TODO(palla/mbps): This should map to the timetable settings
|
|
535
|
+
|
|
536
|
+
// Wait for last block to sync by archive
|
|
537
|
+
let lastBlockHeader: BlockHeader | undefined;
|
|
538
|
+
try {
|
|
539
|
+
lastBlockHeader = await retryUntil(
|
|
540
|
+
async () => {
|
|
541
|
+
await this.blockSource.syncImmediate();
|
|
542
|
+
return this.blockSource.getBlockHeaderByArchive(proposal.archive);
|
|
543
|
+
},
|
|
544
|
+
`waiting for block with archive ${proposal.archive.toString()} for slot ${slot}`,
|
|
545
|
+
timeoutSeconds,
|
|
546
|
+
0.5,
|
|
547
|
+
);
|
|
548
|
+
} catch (err) {
|
|
549
|
+
if (err instanceof TimeoutError) {
|
|
550
|
+
this.log.warn(`Timed out waiting for block with archive matching checkpoint proposal`, proposalInfo);
|
|
551
|
+
return { isValid: false, reason: 'last_block_not_found' };
|
|
552
|
+
}
|
|
553
|
+
this.log.error(`Error fetching last block for checkpoint proposal`, err, proposalInfo);
|
|
554
|
+
return { isValid: false, reason: 'block_fetch_error' };
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
if (!lastBlockHeader) {
|
|
558
|
+
this.log.warn(`Last block not found for checkpoint proposal`, proposalInfo);
|
|
559
|
+
return { isValid: false, reason: 'last_block_not_found' };
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
// Get all full blocks for the slot and checkpoint
|
|
563
|
+
const blocks = await this.blockSource.getBlocksForSlot(slot);
|
|
564
|
+
if (blocks.length === 0) {
|
|
565
|
+
this.log.warn(`No blocks found for slot ${slot}`, proposalInfo);
|
|
566
|
+
return { isValid: false, reason: 'no_blocks_for_slot' };
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
this.log.debug(`Found ${blocks.length} blocks for slot ${slot}`, {
|
|
570
|
+
...proposalInfo,
|
|
571
|
+
blockNumbers: blocks.map(b => b.number),
|
|
572
|
+
});
|
|
573
|
+
|
|
574
|
+
// Get checkpoint constants from first block
|
|
575
|
+
const firstBlock = blocks[0];
|
|
576
|
+
const constants = this.extractCheckpointConstants(firstBlock);
|
|
577
|
+
const checkpointNumber = firstBlock.checkpointNumber;
|
|
578
|
+
|
|
579
|
+
// Get L1-to-L2 messages for this checkpoint
|
|
580
|
+
const l1ToL2Messages = await this.l1ToL2MessageSource.getL1ToL2Messages(checkpointNumber);
|
|
581
|
+
|
|
582
|
+
// Compute the previous checkpoint out hashes for the epoch.
|
|
583
|
+
// TODO: There can be a more efficient way to get the previous checkpoint out hashes without having to fetch the
|
|
584
|
+
// actual checkpoints and the blocks/txs in them.
|
|
585
|
+
const epoch = getEpochAtSlot(slot, this.epochCache.getL1Constants());
|
|
586
|
+
const previousCheckpoints = (await this.blockSource.getCheckpointsForEpoch(epoch))
|
|
587
|
+
.filter(b => b.number < checkpointNumber)
|
|
588
|
+
.sort((a, b) => a.number - b.number);
|
|
589
|
+
const previousCheckpointOutHashes = previousCheckpoints.map(c => c.getCheckpointOutHash());
|
|
590
|
+
|
|
591
|
+
// Fork world state at the block before the first block
|
|
592
|
+
const parentBlockNumber = BlockNumber(firstBlock.number - 1);
|
|
593
|
+
const fork = await this.worldState.fork(parentBlockNumber);
|
|
594
|
+
|
|
595
|
+
try {
|
|
596
|
+
// Create checkpoint builder with all existing blocks
|
|
597
|
+
const checkpointBuilder = await this.checkpointsBuilder.openCheckpoint(
|
|
598
|
+
checkpointNumber,
|
|
599
|
+
constants,
|
|
600
|
+
l1ToL2Messages,
|
|
601
|
+
previousCheckpointOutHashes,
|
|
602
|
+
fork,
|
|
603
|
+
blocks,
|
|
604
|
+
this.log.getBindings(),
|
|
605
|
+
);
|
|
606
|
+
|
|
607
|
+
// Complete the checkpoint to get computed values
|
|
608
|
+
const computedCheckpoint = await checkpointBuilder.completeCheckpoint();
|
|
609
|
+
|
|
610
|
+
// Compare checkpoint header with proposal
|
|
611
|
+
if (!computedCheckpoint.header.equals(proposal.checkpointHeader)) {
|
|
612
|
+
this.log.warn(`Checkpoint header mismatch`, {
|
|
613
|
+
...proposalInfo,
|
|
614
|
+
computed: computedCheckpoint.header.toInspect(),
|
|
615
|
+
proposal: proposal.checkpointHeader.toInspect(),
|
|
616
|
+
});
|
|
617
|
+
return { isValid: false, reason: 'checkpoint_header_mismatch' };
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
// Compare archive root with proposal
|
|
621
|
+
if (!computedCheckpoint.archive.root.equals(proposal.archive)) {
|
|
622
|
+
this.log.warn(`Archive root mismatch`, {
|
|
623
|
+
...proposalInfo,
|
|
624
|
+
computed: computedCheckpoint.archive.root.toString(),
|
|
625
|
+
proposal: proposal.archive.toString(),
|
|
626
|
+
});
|
|
627
|
+
return { isValid: false, reason: 'archive_mismatch' };
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
// Check that the accumulated epoch out hash matches the value in the proposal.
|
|
631
|
+
// The epoch out hash is the accumulated hash of all checkpoint out hashes in the epoch.
|
|
632
|
+
const checkpointOutHash = computedCheckpoint.getCheckpointOutHash();
|
|
633
|
+
const computedEpochOutHash = accumulateCheckpointOutHashes([...previousCheckpointOutHashes, checkpointOutHash]);
|
|
634
|
+
const proposalEpochOutHash = proposal.checkpointHeader.epochOutHash;
|
|
635
|
+
if (!computedEpochOutHash.equals(proposalEpochOutHash)) {
|
|
636
|
+
this.log.warn(`Epoch out hash mismatch`, {
|
|
637
|
+
proposalEpochOutHash: proposalEpochOutHash.toString(),
|
|
638
|
+
computedEpochOutHash: computedEpochOutHash.toString(),
|
|
639
|
+
checkpointOutHash: checkpointOutHash.toString(),
|
|
640
|
+
previousCheckpointOutHashes: previousCheckpointOutHashes.map(h => h.toString()),
|
|
641
|
+
...proposalInfo,
|
|
642
|
+
});
|
|
643
|
+
return { isValid: false, reason: 'out_hash_mismatch' };
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
this.log.verbose(`Checkpoint proposal validation successful for slot ${slot}`, proposalInfo);
|
|
647
|
+
return { isValid: true };
|
|
648
|
+
} finally {
|
|
649
|
+
await fork.close();
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
/**
|
|
654
|
+
* Extract checkpoint global variables from a block.
|
|
655
|
+
*/
|
|
656
|
+
private extractCheckpointConstants(block: L2Block): CheckpointGlobalVariables {
|
|
657
|
+
const gv = block.header.globalVariables;
|
|
658
|
+
return {
|
|
659
|
+
chainId: gv.chainId,
|
|
660
|
+
version: gv.version,
|
|
661
|
+
slotNumber: gv.slotNumber,
|
|
662
|
+
coinbase: gv.coinbase,
|
|
663
|
+
feeRecipient: gv.feeRecipient,
|
|
664
|
+
gasFees: gv.gasFees,
|
|
665
|
+
};
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
/**
|
|
669
|
+
* Uploads blobs for a checkpoint to the filestore (fire and forget).
|
|
670
|
+
*/
|
|
671
|
+
private async uploadBlobsForCheckpoint(proposal: CheckpointProposalCore, proposalInfo: LogData): Promise<void> {
|
|
672
|
+
try {
|
|
673
|
+
const lastBlockHeader = await this.blockSource.getBlockHeaderByArchive(proposal.archive);
|
|
674
|
+
if (!lastBlockHeader) {
|
|
675
|
+
this.log.warn(`Failed to get last block header for blob upload`, proposalInfo);
|
|
676
|
+
return;
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
const blocks = await this.blockSource.getBlocksForSlot(proposal.slotNumber);
|
|
680
|
+
if (blocks.length === 0) {
|
|
681
|
+
this.log.warn(`No blocks found for blob upload`, proposalInfo);
|
|
682
|
+
return;
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
const blobFields = blocks.flatMap(b => b.toBlobFields());
|
|
686
|
+
const blobs: Blob[] = getBlobsPerL1Block(blobFields);
|
|
687
|
+
await this.blobClient.sendBlobsToFilestore(blobs);
|
|
688
|
+
this.log.debug(`Uploaded ${blobs.length} blobs to filestore for checkpoint at slot ${proposal.slotNumber}`, {
|
|
689
|
+
...proposalInfo,
|
|
690
|
+
numBlobs: blobs.length,
|
|
691
|
+
});
|
|
692
|
+
} catch (err) {
|
|
693
|
+
this.log.warn(`Failed to upload blobs for checkpoint: ${err}`, proposalInfo);
|
|
694
|
+
}
|
|
374
695
|
}
|
|
375
696
|
|
|
376
697
|
private slashInvalidBlock(proposal: BlockProposal) {
|
|
@@ -401,26 +722,56 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
401
722
|
}
|
|
402
723
|
|
|
403
724
|
async createBlockProposal(
|
|
404
|
-
|
|
405
|
-
|
|
725
|
+
blockHeader: BlockHeader,
|
|
726
|
+
indexWithinCheckpoint: IndexWithinCheckpoint,
|
|
727
|
+
inHash: Fr,
|
|
406
728
|
archive: Fr,
|
|
407
729
|
txs: Tx[],
|
|
408
730
|
proposerAddress: EthAddress | undefined,
|
|
409
|
-
options: BlockProposalOptions,
|
|
410
|
-
): Promise<BlockProposal
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
731
|
+
options: BlockProposalOptions = {},
|
|
732
|
+
): Promise<BlockProposal> {
|
|
733
|
+
// TODO(palla/mbps): Prevent double proposals properly
|
|
734
|
+
// if (this.previousProposal?.slotNumber === blockHeader.globalVariables.slotNumber) {
|
|
735
|
+
// this.log.verbose(`Already made a proposal for the same slot, skipping proposal`);
|
|
736
|
+
// return Promise.resolve(undefined);
|
|
737
|
+
// }
|
|
738
|
+
|
|
739
|
+
this.log.info(
|
|
740
|
+
`Assembling block proposal for block ${blockHeader.globalVariables.blockNumber} slot ${blockHeader.globalVariables.slotNumber}`,
|
|
741
|
+
);
|
|
742
|
+
const newProposal = await this.validationService.createBlockProposal(
|
|
743
|
+
blockHeader,
|
|
744
|
+
indexWithinCheckpoint,
|
|
745
|
+
inHash,
|
|
746
|
+
archive,
|
|
747
|
+
txs,
|
|
748
|
+
proposerAddress,
|
|
749
|
+
{
|
|
750
|
+
...options,
|
|
751
|
+
broadcastInvalidBlockProposal: this.config.broadcastInvalidBlockProposal,
|
|
752
|
+
},
|
|
753
|
+
);
|
|
420
754
|
this.previousProposal = newProposal;
|
|
421
755
|
return newProposal;
|
|
422
756
|
}
|
|
423
757
|
|
|
758
|
+
async createCheckpointProposal(
|
|
759
|
+
checkpointHeader: CheckpointHeader,
|
|
760
|
+
archive: Fr,
|
|
761
|
+
lastBlockInfo: CreateCheckpointProposalLastBlockData | undefined,
|
|
762
|
+
proposerAddress: EthAddress | undefined,
|
|
763
|
+
options: CheckpointProposalOptions = {},
|
|
764
|
+
): Promise<CheckpointProposal> {
|
|
765
|
+
this.log.info(`Assembling checkpoint proposal for slot ${checkpointHeader.slotNumber}`);
|
|
766
|
+
return await this.validationService.createCheckpointProposal(
|
|
767
|
+
checkpointHeader,
|
|
768
|
+
archive,
|
|
769
|
+
lastBlockInfo,
|
|
770
|
+
proposerAddress,
|
|
771
|
+
options,
|
|
772
|
+
);
|
|
773
|
+
}
|
|
774
|
+
|
|
424
775
|
async broadcastBlockProposal(proposal: BlockProposal): Promise<void> {
|
|
425
776
|
await this.p2pClient.broadcastProposal(proposal);
|
|
426
777
|
}
|
|
@@ -428,28 +779,34 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
428
779
|
async signAttestationsAndSigners(
|
|
429
780
|
attestationsAndSigners: CommitteeAttestationsAndSigners,
|
|
430
781
|
proposer: EthAddress,
|
|
782
|
+
slot: SlotNumber,
|
|
783
|
+
blockNumber: BlockNumber | CheckpointNumber,
|
|
431
784
|
): Promise<Signature> {
|
|
432
|
-
return await this.validationService.signAttestationsAndSigners(attestationsAndSigners, proposer);
|
|
785
|
+
return await this.validationService.signAttestationsAndSigners(attestationsAndSigners, proposer, slot, blockNumber);
|
|
433
786
|
}
|
|
434
787
|
|
|
435
|
-
async collectOwnAttestations(proposal:
|
|
436
|
-
const slot = proposal.
|
|
788
|
+
async collectOwnAttestations(proposal: CheckpointProposal): Promise<CheckpointAttestation[]> {
|
|
789
|
+
const slot = proposal.slotNumber;
|
|
437
790
|
const inCommittee = await this.epochCache.filterInCommittee(slot, this.getValidatorAddresses());
|
|
438
791
|
this.log.debug(`Collecting ${inCommittee.length} self-attestations for slot ${slot}`, { inCommittee });
|
|
439
|
-
const attestations = await this.
|
|
792
|
+
const attestations = await this.createCheckpointAttestationsFromProposal(proposal, inCommittee);
|
|
440
793
|
|
|
441
794
|
// We broadcast our own attestations to our peers so, in case our block does not get mined on L1,
|
|
442
795
|
// other nodes can see that our validators did attest to this block proposal, and do not slash us
|
|
443
796
|
// due to inactivity for missed attestations.
|
|
444
|
-
void this.p2pClient.
|
|
797
|
+
void this.p2pClient.broadcastCheckpointAttestations(attestations).catch(err => {
|
|
445
798
|
this.log.error(`Failed to broadcast self-attestations for slot ${slot}`, err);
|
|
446
799
|
});
|
|
447
800
|
return attestations;
|
|
448
801
|
}
|
|
449
802
|
|
|
450
|
-
async collectAttestations(
|
|
451
|
-
|
|
452
|
-
|
|
803
|
+
async collectAttestations(
|
|
804
|
+
proposal: CheckpointProposal,
|
|
805
|
+
required: number,
|
|
806
|
+
deadline: Date,
|
|
807
|
+
): Promise<CheckpointAttestation[]> {
|
|
808
|
+
// Wait and poll the p2pClient's attestation pool for this checkpoint until we have enough attestations
|
|
809
|
+
const slot = proposal.slotNumber;
|
|
453
810
|
this.log.debug(`Collecting ${required} attestations for slot ${slot} with deadline ${deadline.toISOString()}`);
|
|
454
811
|
|
|
455
812
|
if (+deadline < this.dateProvider.now()) {
|
|
@@ -464,16 +821,16 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
464
821
|
const proposalId = proposal.archive.toString();
|
|
465
822
|
const myAddresses = this.getValidatorAddresses();
|
|
466
823
|
|
|
467
|
-
let attestations:
|
|
824
|
+
let attestations: CheckpointAttestation[] = [];
|
|
468
825
|
while (true) {
|
|
469
|
-
// Filter out attestations with a mismatching
|
|
826
|
+
// Filter out attestations with a mismatching archive. This should NOT happen since we have verified
|
|
470
827
|
// the proposer signature (ie our own) before accepting the attestation into the pool via the p2p client.
|
|
471
|
-
const collectedAttestations = (await this.p2pClient.
|
|
828
|
+
const collectedAttestations = (await this.p2pClient.getCheckpointAttestationsForSlot(slot, proposalId)).filter(
|
|
472
829
|
attestation => {
|
|
473
|
-
if (!attestation.
|
|
830
|
+
if (!attestation.archive.equals(proposal.archive)) {
|
|
474
831
|
this.log.warn(
|
|
475
|
-
`Received attestation for slot ${slot} with mismatched
|
|
476
|
-
{
|
|
832
|
+
`Received attestation for slot ${slot} with mismatched archive from ${attestation.getSender()?.toString()}`,
|
|
833
|
+
{ attestationArchive: attestation.archive.toString(), proposalArchive: proposal.archive.toString() },
|
|
477
834
|
);
|
|
478
835
|
return false;
|
|
479
836
|
}
|
|
@@ -514,15 +871,6 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
514
871
|
}
|
|
515
872
|
}
|
|
516
873
|
|
|
517
|
-
private async createBlockAttestationsFromProposal(
|
|
518
|
-
proposal: BlockProposal,
|
|
519
|
-
attestors: EthAddress[] = [],
|
|
520
|
-
): Promise<BlockAttestation[]> {
|
|
521
|
-
const attestations = await this.validationService.attestToProposal(proposal, attestors);
|
|
522
|
-
await this.p2pClient.addAttestations(attestations);
|
|
523
|
-
return attestations;
|
|
524
|
-
}
|
|
525
|
-
|
|
526
874
|
private async handleAuthRequest(peer: PeerId, msg: Buffer): Promise<Buffer> {
|
|
527
875
|
const authRequest = AuthRequest.fromBuffer(msg);
|
|
528
876
|
const statusMessage = await this.p2pClient.handleAuthRequestFromPeer(authRequest, peer).catch(_ => undefined);
|
|
@@ -541,7 +889,9 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
541
889
|
}
|
|
542
890
|
|
|
543
891
|
const payloadToSign = authRequest.getPayloadToSign();
|
|
544
|
-
|
|
892
|
+
// AUTH_REQUEST doesn't require HA protection - multiple signatures are safe
|
|
893
|
+
const context: SigningContext = { dutyType: DutyType.AUTH_REQUEST };
|
|
894
|
+
const signature = await this.keyStore.signMessageWithAddress(addressToUse, payloadToSign, context);
|
|
545
895
|
const authResponse = new AuthResponse(statusMessage, signature);
|
|
546
896
|
return authResponse.toBuffer();
|
|
547
897
|
}
|