@aztec/validator-client 0.0.1-commit.5476d83 → 0.0.1-commit.5914bae
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 +326 -0
- package/dest/checkpoint_builder.d.ts +79 -0
- package/dest/checkpoint_builder.d.ts.map +1 -0
- package/dest/checkpoint_builder.js +251 -0
- package/dest/config.d.ts +1 -1
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +36 -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 +105 -28
- package/dest/factory.d.ts +19 -11
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +6 -5
- package/dest/index.d.ts +3 -2
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +2 -1
- 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 +12 -3
- package/dest/metrics.d.ts.map +1 -1
- package/dest/metrics.js +46 -30
- package/dest/proposal_handler.d.ts +94 -0
- package/dest/proposal_handler.d.ts.map +1 -0
- package/dest/proposal_handler.js +852 -0
- package/dest/validator.d.ts +64 -22
- package/dest/validator.d.ts.map +1 -1
- package/dest/validator.js +278 -61
- package/package.json +23 -13
- package/src/checkpoint_builder.ts +417 -0
- package/src/config.ts +35 -7
- package/src/duties/validation_service.ts +156 -33
- package/src/factory.ts +26 -11
- package/src/index.ts +2 -1
- 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 +63 -33
- package/src/proposal_handler.ts +903 -0
- package/src/validator.ts +433 -91
- package/dest/block_proposal_handler.d.ts +0 -52
- package/dest/block_proposal_handler.d.ts.map +0 -1
- package/dest/block_proposal_handler.js +0 -290
- package/src/block_proposal_handler.ts +0 -341
package/src/validator.ts
CHANGED
|
@@ -1,33 +1,60 @@
|
|
|
1
|
+
import type { BlobClientInterface } from '@aztec/blob-client/client';
|
|
1
2
|
import type { EpochCache } from '@aztec/epoch-cache';
|
|
2
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
BlockNumber,
|
|
5
|
+
CheckpointNumber,
|
|
6
|
+
EpochNumber,
|
|
7
|
+
IndexWithinCheckpoint,
|
|
8
|
+
SlotNumber,
|
|
9
|
+
} from '@aztec/foundation/branded-types';
|
|
10
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
11
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
12
|
import type { Signature } from '@aztec/foundation/eth-signature';
|
|
5
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
6
13
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
7
14
|
import { RunningPromise } from '@aztec/foundation/running-promise';
|
|
8
15
|
import { sleep } from '@aztec/foundation/sleep';
|
|
9
16
|
import { DateProvider } from '@aztec/foundation/timer';
|
|
10
17
|
import type { KeystoreManager } from '@aztec/node-keystore';
|
|
11
|
-
import type { P2P, PeerId
|
|
18
|
+
import type { DuplicateAttestationInfo, DuplicateProposalInfo, P2P, PeerId } from '@aztec/p2p';
|
|
12
19
|
import { AuthRequest, AuthResponse, BlockProposalValidator, ReqRespSubProtocol } from '@aztec/p2p';
|
|
13
20
|
import { OffenseType, WANT_TO_SLASH_EVENT, type Watcher, type WatcherEmitter } from '@aztec/slasher';
|
|
14
21
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
15
|
-
import type { CommitteeAttestationsAndSigners, L2BlockSource } from '@aztec/stdlib/block';
|
|
16
|
-
import
|
|
22
|
+
import type { CommitteeAttestationsAndSigners, L2BlockSink, L2BlockSource } from '@aztec/stdlib/block';
|
|
23
|
+
import { getEpochAtSlot } from '@aztec/stdlib/epoch-helpers';
|
|
24
|
+
import type {
|
|
25
|
+
CreateCheckpointProposalLastBlockData,
|
|
26
|
+
ITxProvider,
|
|
27
|
+
Validator,
|
|
28
|
+
ValidatorClientFullConfig,
|
|
29
|
+
WorldStateSynchronizer,
|
|
30
|
+
} from '@aztec/stdlib/interfaces/server';
|
|
17
31
|
import type { L1ToL2MessageSource } from '@aztec/stdlib/messaging';
|
|
18
|
-
import
|
|
32
|
+
import {
|
|
33
|
+
type BlockProposal,
|
|
34
|
+
type BlockProposalOptions,
|
|
35
|
+
type CheckpointAttestation,
|
|
36
|
+
CheckpointProposal,
|
|
37
|
+
type CheckpointProposalCore,
|
|
38
|
+
type CheckpointProposalOptions,
|
|
39
|
+
} from '@aztec/stdlib/p2p';
|
|
19
40
|
import type { CheckpointHeader } from '@aztec/stdlib/rollup';
|
|
20
|
-
import type { Tx } from '@aztec/stdlib/tx';
|
|
41
|
+
import type { BlockHeader, Tx } from '@aztec/stdlib/tx';
|
|
21
42
|
import { AttestationTimeoutError } from '@aztec/stdlib/validators';
|
|
22
43
|
import { type TelemetryClient, type Tracer, getTelemetryClient } from '@aztec/telemetry-client';
|
|
44
|
+
import { createHASigner, createSignerFromSharedDb } from '@aztec/validator-ha-signer/factory';
|
|
45
|
+
import { DutyType, type SigningContext, type SlashingProtectionDatabase } from '@aztec/validator-ha-signer/types';
|
|
46
|
+
import type { ValidatorHASigner } from '@aztec/validator-ha-signer/validator-ha-signer';
|
|
23
47
|
|
|
24
48
|
import { EventEmitter } from 'events';
|
|
25
49
|
import type { TypedDataDefinition } from 'viem';
|
|
26
50
|
|
|
27
|
-
import {
|
|
51
|
+
import type { FullNodeCheckpointsBuilder } from './checkpoint_builder.js';
|
|
28
52
|
import { ValidationService } from './duties/validation_service.js';
|
|
53
|
+
import { HAKeyStore } from './key_store/ha_key_store.js';
|
|
54
|
+
import type { ExtendedValidatorKeyStore } from './key_store/interface.js';
|
|
29
55
|
import { NodeKeystoreAdapter } from './key_store/node_keystore_adapter.js';
|
|
30
56
|
import { ValidatorMetrics } from './metrics.js';
|
|
57
|
+
import { type BlockProposalValidationFailureReason, ProposalHandler } from './proposal_handler.js';
|
|
31
58
|
|
|
32
59
|
// We maintain a set of proposers who have proposed invalid blocks.
|
|
33
60
|
// Just cap the set to avoid unbounded growth.
|
|
@@ -47,24 +74,33 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
47
74
|
private validationService: ValidationService;
|
|
48
75
|
private metrics: ValidatorMetrics;
|
|
49
76
|
private log: Logger;
|
|
50
|
-
|
|
51
77
|
// Whether it has already registered handlers on the p2p client
|
|
52
78
|
private hasRegisteredHandlers = false;
|
|
53
79
|
|
|
54
|
-
|
|
55
|
-
private
|
|
80
|
+
/** Tracks the last block proposal we created, to detect duplicate proposal attempts. */
|
|
81
|
+
private lastProposedBlock?: BlockProposal;
|
|
82
|
+
|
|
83
|
+
/** Tracks the last checkpoint proposal we created. */
|
|
84
|
+
private lastProposedCheckpoint?: CheckpointProposal;
|
|
56
85
|
|
|
57
86
|
private lastEpochForCommitteeUpdateLoop: EpochNumber | undefined;
|
|
58
87
|
private epochCacheUpdateLoop: RunningPromise;
|
|
88
|
+
/** Tracks the last epoch in which each attester successfully submitted at least one attestation. */
|
|
89
|
+
private lastAttestedEpochByAttester: Map<string, EpochNumber> = new Map();
|
|
59
90
|
|
|
60
91
|
private proposersOfInvalidBlocks: Set<string> = new Set();
|
|
61
92
|
|
|
93
|
+
/** Tracks the last checkpoint proposal we attested to, to prevent equivocation. */
|
|
94
|
+
private lastAttestedProposal?: CheckpointProposalCore;
|
|
95
|
+
|
|
62
96
|
protected constructor(
|
|
63
|
-
private keyStore:
|
|
97
|
+
private keyStore: ExtendedValidatorKeyStore,
|
|
64
98
|
private epochCache: EpochCache,
|
|
65
99
|
private p2pClient: P2P,
|
|
66
|
-
private
|
|
100
|
+
private proposalHandler: ProposalHandler,
|
|
67
101
|
private config: ValidatorClientFullConfig,
|
|
102
|
+
private blobClient: BlobClientInterface,
|
|
103
|
+
private haSigner: ValidatorHASigner | undefined,
|
|
68
104
|
private dateProvider: DateProvider = new DateProvider(),
|
|
69
105
|
telemetry: TelemetryClient = getTelemetryClient(),
|
|
70
106
|
log = createLogger('validator'),
|
|
@@ -118,6 +154,7 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
118
154
|
this.log.trace(`No committee found for slot`);
|
|
119
155
|
return;
|
|
120
156
|
}
|
|
157
|
+
this.metrics.setCurrentEpoch(epoch);
|
|
121
158
|
if (epoch !== this.lastEpochForCommitteeUpdateLoop) {
|
|
122
159
|
const me = this.getValidatorAddresses();
|
|
123
160
|
const committeeSet = new Set(committee.map(v => v.toString()));
|
|
@@ -138,40 +175,68 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
138
175
|
}
|
|
139
176
|
}
|
|
140
177
|
|
|
141
|
-
static new(
|
|
178
|
+
static async new(
|
|
142
179
|
config: ValidatorClientFullConfig,
|
|
143
|
-
|
|
180
|
+
checkpointsBuilder: FullNodeCheckpointsBuilder,
|
|
181
|
+
worldState: WorldStateSynchronizer,
|
|
144
182
|
epochCache: EpochCache,
|
|
145
183
|
p2pClient: P2P,
|
|
146
|
-
blockSource: L2BlockSource,
|
|
184
|
+
blockSource: L2BlockSource & L2BlockSink,
|
|
147
185
|
l1ToL2MessageSource: L1ToL2MessageSource,
|
|
148
|
-
txProvider:
|
|
186
|
+
txProvider: ITxProvider,
|
|
149
187
|
keyStoreManager: KeystoreManager,
|
|
188
|
+
blobClient: BlobClientInterface,
|
|
150
189
|
dateProvider: DateProvider = new DateProvider(),
|
|
151
190
|
telemetry: TelemetryClient = getTelemetryClient(),
|
|
191
|
+
slashingProtectionDb?: SlashingProtectionDatabase,
|
|
152
192
|
) {
|
|
153
193
|
const metrics = new ValidatorMetrics(telemetry);
|
|
154
194
|
const blockProposalValidator = new BlockProposalValidator(epochCache, {
|
|
155
195
|
txsPermitted: !config.disableTransactions,
|
|
196
|
+
maxTxsPerBlock: config.validateMaxTxsPerBlock,
|
|
156
197
|
});
|
|
157
|
-
const
|
|
158
|
-
|
|
198
|
+
const proposalHandler = new ProposalHandler(
|
|
199
|
+
checkpointsBuilder,
|
|
200
|
+
worldState,
|
|
159
201
|
blockSource,
|
|
160
202
|
l1ToL2MessageSource,
|
|
161
203
|
txProvider,
|
|
162
204
|
blockProposalValidator,
|
|
205
|
+
epochCache,
|
|
163
206
|
config,
|
|
207
|
+
blobClient,
|
|
164
208
|
metrics,
|
|
165
209
|
dateProvider,
|
|
166
210
|
telemetry,
|
|
167
211
|
);
|
|
168
212
|
|
|
213
|
+
const nodeKeystoreAdapter = NodeKeystoreAdapter.fromKeyStoreManager(keyStoreManager);
|
|
214
|
+
let validatorKeyStore: ExtendedValidatorKeyStore = nodeKeystoreAdapter;
|
|
215
|
+
let haSigner: ValidatorHASigner | undefined;
|
|
216
|
+
if (slashingProtectionDb) {
|
|
217
|
+
// Shared database mode: use a pre-existing database (e.g. for testing HA setups).
|
|
218
|
+
const { signer } = createSignerFromSharedDb(slashingProtectionDb, config);
|
|
219
|
+
haSigner = signer;
|
|
220
|
+
validatorKeyStore = new HAKeyStore(nodeKeystoreAdapter, signer);
|
|
221
|
+
} else if (config.haSigningEnabled) {
|
|
222
|
+
// If maxStuckDutiesAgeMs is not explicitly set, compute it from Aztec slot duration
|
|
223
|
+
const haConfig = {
|
|
224
|
+
...config,
|
|
225
|
+
maxStuckDutiesAgeMs: config.maxStuckDutiesAgeMs ?? epochCache.getL1Constants().slotDuration * 2 * 1000,
|
|
226
|
+
};
|
|
227
|
+
const { signer } = await createHASigner(haConfig);
|
|
228
|
+
haSigner = signer;
|
|
229
|
+
validatorKeyStore = new HAKeyStore(nodeKeystoreAdapter, signer);
|
|
230
|
+
}
|
|
231
|
+
|
|
169
232
|
const validator = new ValidatorClient(
|
|
170
|
-
|
|
233
|
+
validatorKeyStore,
|
|
171
234
|
epochCache,
|
|
172
235
|
p2pClient,
|
|
173
|
-
|
|
236
|
+
proposalHandler,
|
|
174
237
|
config,
|
|
238
|
+
blobClient,
|
|
239
|
+
haSigner,
|
|
175
240
|
dateProvider,
|
|
176
241
|
telemetry,
|
|
177
242
|
);
|
|
@@ -185,22 +250,12 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
185
250
|
.filter(addr => !this.config.disabledValidators.some(disabled => disabled.equals(addr)));
|
|
186
251
|
}
|
|
187
252
|
|
|
188
|
-
public
|
|
189
|
-
return this.
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
// Proxy method for backwards compatibility with tests
|
|
193
|
-
public reExecuteTransactions(
|
|
194
|
-
proposal: BlockProposal,
|
|
195
|
-
blockNumber: number,
|
|
196
|
-
txs: any[],
|
|
197
|
-
l1ToL2Messages: Fr[],
|
|
198
|
-
): Promise<any> {
|
|
199
|
-
return this.blockProposalHandler.reexecuteTransactions(proposal, blockNumber, txs, l1ToL2Messages);
|
|
253
|
+
public getProposalHandler() {
|
|
254
|
+
return this.proposalHandler;
|
|
200
255
|
}
|
|
201
256
|
|
|
202
|
-
public signWithAddress(addr: EthAddress, msg: TypedDataDefinition) {
|
|
203
|
-
return this.keyStore.signTypedDataWithAddress(addr, msg);
|
|
257
|
+
public signWithAddress(addr: EthAddress, msg: TypedDataDefinition, context: SigningContext) {
|
|
258
|
+
return this.keyStore.signTypedDataWithAddress(addr, msg, context);
|
|
204
259
|
}
|
|
205
260
|
|
|
206
261
|
public getCoinbaseForAttestor(attestor: EthAddress): EthAddress {
|
|
@@ -219,12 +274,36 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
219
274
|
this.config = { ...this.config, ...config };
|
|
220
275
|
}
|
|
221
276
|
|
|
277
|
+
public reloadKeystore(newManager: KeystoreManager): void {
|
|
278
|
+
if (this.config.haSigningEnabled && !this.haSigner) {
|
|
279
|
+
this.log.warn(
|
|
280
|
+
'HA signing is enabled in config but was not initialized at startup. ' +
|
|
281
|
+
'Restart the node to enable HA signing.',
|
|
282
|
+
);
|
|
283
|
+
} else if (!this.config.haSigningEnabled && this.haSigner) {
|
|
284
|
+
this.log.warn(
|
|
285
|
+
'HA signing was disabled via config update but the HA signer is still active. ' +
|
|
286
|
+
'Restart the node to fully disable HA signing.',
|
|
287
|
+
);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
const newAdapter = NodeKeystoreAdapter.fromKeyStoreManager(newManager);
|
|
291
|
+
if (this.haSigner) {
|
|
292
|
+
this.keyStore = new HAKeyStore(newAdapter, this.haSigner);
|
|
293
|
+
} else {
|
|
294
|
+
this.keyStore = newAdapter;
|
|
295
|
+
}
|
|
296
|
+
this.validationService = new ValidationService(this.keyStore, this.log.createChild('validation-service'));
|
|
297
|
+
}
|
|
298
|
+
|
|
222
299
|
public async start() {
|
|
223
300
|
if (this.epochCacheUpdateLoop.isRunning()) {
|
|
224
301
|
this.log.warn(`Validator client already started`);
|
|
225
302
|
return;
|
|
226
303
|
}
|
|
227
304
|
|
|
305
|
+
await this.keyStore.start();
|
|
306
|
+
|
|
228
307
|
await this.registerHandlers();
|
|
229
308
|
|
|
230
309
|
const myAddresses = this.getValidatorAddresses();
|
|
@@ -240,6 +319,7 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
240
319
|
|
|
241
320
|
public async stop() {
|
|
242
321
|
await this.epochCacheUpdateLoop.stop();
|
|
322
|
+
await this.keyStore.stop();
|
|
243
323
|
}
|
|
244
324
|
|
|
245
325
|
/** Register handlers on the p2p client */
|
|
@@ -248,9 +328,29 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
248
328
|
this.hasRegisteredHandlers = true;
|
|
249
329
|
this.log.debug(`Registering validator handlers for p2p client`);
|
|
250
330
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
331
|
+
// Block proposal handler - validates but does NOT attest (validators only attest to checkpoints)
|
|
332
|
+
const blockHandler = (block: BlockProposal, proposalSender: PeerId): Promise<boolean> =>
|
|
333
|
+
this.validateBlockProposal(block, proposalSender);
|
|
334
|
+
this.p2pClient.registerBlockProposalHandler(blockHandler);
|
|
335
|
+
|
|
336
|
+
// Checkpoint proposal handler - validates and creates attestations
|
|
337
|
+
// The checkpoint is received as CheckpointProposalCore since the lastBlock is extracted
|
|
338
|
+
// and processed separately via the block handler above.
|
|
339
|
+
const checkpointHandler = (
|
|
340
|
+
checkpoint: CheckpointProposalCore,
|
|
341
|
+
proposalSender: PeerId,
|
|
342
|
+
): Promise<CheckpointAttestation[] | undefined> => this.attestToCheckpointProposal(checkpoint, proposalSender);
|
|
343
|
+
this.p2pClient.registerCheckpointProposalHandler(checkpointHandler);
|
|
344
|
+
|
|
345
|
+
// Duplicate proposal handler - triggers slashing for equivocation
|
|
346
|
+
this.p2pClient.registerDuplicateProposalCallback((info: DuplicateProposalInfo) => {
|
|
347
|
+
this.handleDuplicateProposal(info);
|
|
348
|
+
});
|
|
349
|
+
|
|
350
|
+
// Duplicate attestation handler - triggers slashing for attestation equivocation
|
|
351
|
+
this.p2pClient.registerDuplicateAttestationCallback((info: DuplicateAttestationInfo) => {
|
|
352
|
+
this.handleDuplicateAttestation(info);
|
|
353
|
+
});
|
|
254
354
|
|
|
255
355
|
const myAddresses = this.getValidatorAddresses();
|
|
256
356
|
this.p2pClient.registerThisValidatorAddresses(myAddresses);
|
|
@@ -259,29 +359,46 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
259
359
|
}
|
|
260
360
|
}
|
|
261
361
|
|
|
262
|
-
|
|
362
|
+
/**
|
|
363
|
+
* Validate a block proposal from a peer.
|
|
364
|
+
* Note: Validators do NOT attest to individual blocks - attestations are only for checkpoint proposals.
|
|
365
|
+
* @returns true if the proposal is valid, false otherwise
|
|
366
|
+
*/
|
|
367
|
+
async validateBlockProposal(proposal: BlockProposal, proposalSender: PeerId): Promise<boolean> {
|
|
263
368
|
const slotNumber = proposal.slotNumber;
|
|
369
|
+
|
|
370
|
+
// Note: During escape hatch, we still want to "validate" proposals for observability,
|
|
371
|
+
// but we intentionally reject them and disable slashing invalid block and attestation flow.
|
|
372
|
+
const escapeHatchOpen = await this.epochCache.isEscapeHatchOpenAtSlot(slotNumber);
|
|
373
|
+
|
|
264
374
|
const proposer = proposal.getSender();
|
|
265
375
|
|
|
266
376
|
// Reject proposals with invalid signatures
|
|
267
377
|
if (!proposer) {
|
|
268
|
-
this.log.warn(`Received proposal with invalid signature for slot ${slotNumber}`);
|
|
269
|
-
return
|
|
378
|
+
this.log.warn(`Received block proposal with invalid signature for slot ${slotNumber}`);
|
|
379
|
+
return false;
|
|
270
380
|
}
|
|
271
381
|
|
|
272
|
-
//
|
|
382
|
+
// Log self-proposals from HA peers (same validator key on different nodes)
|
|
383
|
+
if (this.getValidatorAddresses().some(addr => addr.equals(proposer))) {
|
|
384
|
+
this.log.verbose(`Processing block proposal from HA peer for slot ${slotNumber}`, {
|
|
385
|
+
proposer: proposer.toString(),
|
|
386
|
+
slotNumber,
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
// Check if we're in the committee (for metrics purposes)
|
|
273
391
|
const inCommittee = await this.epochCache.filterInCommittee(slotNumber, this.getValidatorAddresses());
|
|
274
392
|
const partOfCommittee = inCommittee.length > 0;
|
|
275
393
|
|
|
276
394
|
const proposalInfo = { ...proposal.toBlockInfo(), proposer: proposer.toString() };
|
|
277
|
-
this.log.info(`Received proposal for slot ${slotNumber}`, {
|
|
395
|
+
this.log.info(`Received block proposal for slot ${slotNumber}`, {
|
|
278
396
|
...proposalInfo,
|
|
279
397
|
txHashes: proposal.txHashes.map(t => t.toString()),
|
|
280
398
|
fishermanMode: this.config.fishermanMode || false,
|
|
281
399
|
});
|
|
282
400
|
|
|
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.
|
|
401
|
+
// Reexecute txs if we are part of the committee, or if slashing is enabled, or if we are configured to always reexecute.
|
|
285
402
|
// In fisherman mode, we always reexecute to validate proposals.
|
|
286
403
|
const { validatorReexecute, slashBroadcastedInvalidBlockPenalty, alwaysReexecuteBlockProposals, fishermanMode } =
|
|
287
404
|
this.config;
|
|
@@ -289,18 +406,20 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
289
406
|
fishermanMode ||
|
|
290
407
|
(slashBroadcastedInvalidBlockPenalty > 0n && validatorReexecute) ||
|
|
291
408
|
(partOfCommittee && validatorReexecute) ||
|
|
292
|
-
alwaysReexecuteBlockProposals
|
|
409
|
+
alwaysReexecuteBlockProposals ||
|
|
410
|
+
this.blobClient.canUpload();
|
|
293
411
|
|
|
294
|
-
const validationResult = await this.
|
|
412
|
+
const validationResult = await this.proposalHandler.handleBlockProposal(
|
|
295
413
|
proposal,
|
|
296
414
|
proposalSender,
|
|
297
|
-
!!shouldReexecute,
|
|
415
|
+
!!shouldReexecute && !escapeHatchOpen,
|
|
298
416
|
);
|
|
299
417
|
|
|
300
418
|
if (!validationResult.isValid) {
|
|
301
|
-
this.log.warn(`Proposal validation failed: ${validationResult.reason}`, proposalInfo);
|
|
302
|
-
|
|
303
419
|
const reason = validationResult.reason || 'unknown';
|
|
420
|
+
|
|
421
|
+
this.log.warn(`Block proposal validation failed: ${reason}`, proposalInfo);
|
|
422
|
+
|
|
304
423
|
// Classify failure reason: bad proposal vs node issue
|
|
305
424
|
const badProposalReasons: BlockProposalValidationFailureReason[] = [
|
|
306
425
|
'invalid_proposal',
|
|
@@ -313,12 +432,13 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
313
432
|
if (badProposalReasons.includes(reason as BlockProposalValidationFailureReason)) {
|
|
314
433
|
this.metrics.incFailedAttestationsBadProposal(1, reason, partOfCommittee);
|
|
315
434
|
} else {
|
|
316
|
-
// Node issues so we can't
|
|
435
|
+
// Node issues so we can't validate
|
|
317
436
|
this.metrics.incFailedAttestationsNodeIssue(1, reason, partOfCommittee);
|
|
318
437
|
}
|
|
319
438
|
|
|
320
439
|
// Slash invalid block proposals (can happen even when not in committee)
|
|
321
440
|
if (
|
|
441
|
+
!escapeHatchOpen &&
|
|
322
442
|
validationResult.reason &&
|
|
323
443
|
SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT.includes(validationResult.reason) &&
|
|
324
444
|
slashBroadcastedInvalidBlockPenalty > 0n
|
|
@@ -326,9 +446,77 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
326
446
|
this.log.warn(`Slashing proposer for invalid block proposal`, proposalInfo);
|
|
327
447
|
this.slashInvalidBlock(proposal);
|
|
328
448
|
}
|
|
449
|
+
return false;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
this.log.info(`Validated block proposal for slot ${slotNumber}`, {
|
|
453
|
+
...proposalInfo,
|
|
454
|
+
inCommittee: partOfCommittee,
|
|
455
|
+
fishermanMode: this.config.fishermanMode || false,
|
|
456
|
+
escapeHatchOpen,
|
|
457
|
+
});
|
|
458
|
+
|
|
459
|
+
if (escapeHatchOpen) {
|
|
460
|
+
this.log.warn(`Escape hatch open for slot ${slotNumber}, rejecting block proposal`, proposalInfo);
|
|
461
|
+
return false;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
return true;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
/**
|
|
468
|
+
* Validate and attest to a checkpoint proposal from a peer.
|
|
469
|
+
* The proposal is received as CheckpointProposalCore (without lastBlock) since
|
|
470
|
+
* the lastBlock is extracted and processed separately via the block handler.
|
|
471
|
+
* @returns Checkpoint attestations if valid, undefined otherwise
|
|
472
|
+
*/
|
|
473
|
+
async attestToCheckpointProposal(
|
|
474
|
+
proposal: CheckpointProposalCore,
|
|
475
|
+
_proposalSender: PeerId,
|
|
476
|
+
): Promise<CheckpointAttestation[] | undefined> {
|
|
477
|
+
const slotNumber = proposal.slotNumber;
|
|
478
|
+
const proposer = proposal.getSender();
|
|
479
|
+
|
|
480
|
+
// If escape hatch is open for this slot's epoch, do not attest.
|
|
481
|
+
if (await this.epochCache.isEscapeHatchOpenAtSlot(slotNumber)) {
|
|
482
|
+
this.log.warn(`Escape hatch open for slot ${slotNumber}, skipping checkpoint attestation handling`);
|
|
329
483
|
return undefined;
|
|
330
484
|
}
|
|
331
485
|
|
|
486
|
+
// Ignore proposals from ourselves (may happen in HA setups)
|
|
487
|
+
if (proposer && this.getValidatorAddresses().some(addr => addr.equals(proposer))) {
|
|
488
|
+
this.log.debug(`Ignoring block proposal from self for slot ${slotNumber}`, {
|
|
489
|
+
proposer: proposer.toString(),
|
|
490
|
+
slotNumber,
|
|
491
|
+
});
|
|
492
|
+
return undefined;
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
// Check that I have any address in the committee where this checkpoint will land before attesting
|
|
496
|
+
const inCommittee = await this.epochCache.filterInCommittee(slotNumber, this.getValidatorAddresses());
|
|
497
|
+
const partOfCommittee = inCommittee.length > 0;
|
|
498
|
+
|
|
499
|
+
const proposalInfo = {
|
|
500
|
+
slotNumber,
|
|
501
|
+
archive: proposal.archive.toString(),
|
|
502
|
+
proposer: proposer?.toString(),
|
|
503
|
+
};
|
|
504
|
+
this.log.info(`Received checkpoint proposal for slot ${slotNumber}`, {
|
|
505
|
+
...proposalInfo,
|
|
506
|
+
fishermanMode: this.config.fishermanMode || false,
|
|
507
|
+
});
|
|
508
|
+
|
|
509
|
+
// Validate the checkpoint proposal and upload blobs (unless skipCheckpointProposalValidation is set)
|
|
510
|
+
if (this.config.skipCheckpointProposalValidation) {
|
|
511
|
+
this.log.warn(`Skipping checkpoint proposal validation for slot ${slotNumber}`, proposalInfo);
|
|
512
|
+
} else {
|
|
513
|
+
const validationResult = await this.proposalHandler.handleCheckpointProposal(proposal, proposalInfo);
|
|
514
|
+
if (!validationResult.isValid) {
|
|
515
|
+
this.log.warn(`Checkpoint proposal validation failed: ${validationResult.reason}`, proposalInfo);
|
|
516
|
+
return undefined;
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
|
|
332
520
|
// Check that I have any address in current committee before attesting
|
|
333
521
|
// In fisherman mode, we still create attestations for validation even if not in committee
|
|
334
522
|
if (!partOfCommittee && !this.config.fishermanMode) {
|
|
@@ -337,7 +525,7 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
337
525
|
}
|
|
338
526
|
|
|
339
527
|
// 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}`, {
|
|
528
|
+
this.log.info(`${partOfCommittee ? 'Attesting to' : 'Validated'} checkpoint proposal for slot ${slotNumber}`, {
|
|
341
529
|
...proposalInfo,
|
|
342
530
|
inCommittee: partOfCommittee,
|
|
343
531
|
fishermanMode: this.config.fishermanMode || false,
|
|
@@ -345,7 +533,17 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
345
533
|
|
|
346
534
|
this.metrics.incSuccessfulAttestations(inCommittee.length);
|
|
347
535
|
|
|
348
|
-
//
|
|
536
|
+
// Track epoch participation per attester: count each (attester, epoch) pair at most once
|
|
537
|
+
const proposalEpoch = getEpochAtSlot(slotNumber, this.epochCache.getL1Constants());
|
|
538
|
+
for (const attester of inCommittee) {
|
|
539
|
+
const key = attester.toString();
|
|
540
|
+
const lastEpoch = this.lastAttestedEpochByAttester.get(key);
|
|
541
|
+
if (lastEpoch === undefined || proposalEpoch > lastEpoch) {
|
|
542
|
+
this.lastAttestedEpochByAttester.set(key, proposalEpoch);
|
|
543
|
+
this.metrics.incAttestedEpochCount(attester);
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
|
|
349
547
|
// Determine which validators should attest
|
|
350
548
|
let attestors: EthAddress[];
|
|
351
549
|
if (partOfCommittee) {
|
|
@@ -364,13 +562,53 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
364
562
|
|
|
365
563
|
if (this.config.fishermanMode) {
|
|
366
564
|
// bail out early and don't save attestations to the pool in fisherman mode
|
|
367
|
-
this.log.info(`Creating attestations for
|
|
565
|
+
this.log.info(`Creating checkpoint attestations for slot ${slotNumber}`, {
|
|
368
566
|
...proposalInfo,
|
|
369
567
|
attestors: attestors.map(a => a.toString()),
|
|
370
568
|
});
|
|
371
569
|
return undefined;
|
|
372
570
|
}
|
|
373
|
-
|
|
571
|
+
|
|
572
|
+
return await this.createCheckpointAttestationsFromProposal(proposal, attestors);
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
/**
|
|
576
|
+
* Checks if we should attest to a slot based on equivocation prevention rules.
|
|
577
|
+
* @returns true if we should attest, false if we should skip
|
|
578
|
+
*/
|
|
579
|
+
private shouldAttestToSlot(slotNumber: SlotNumber): boolean {
|
|
580
|
+
// If attestToEquivocatedProposals is true, always allow
|
|
581
|
+
if (this.config.attestToEquivocatedProposals) {
|
|
582
|
+
return true;
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
// Check if incoming slot is strictly greater than last attested
|
|
586
|
+
if (this.lastAttestedProposal && slotNumber <= this.lastAttestedProposal.slotNumber) {
|
|
587
|
+
this.log.warn(
|
|
588
|
+
`Refusing to process a proposal for slot ${slotNumber} given we already attested to a proposal for slot ${this.lastAttestedProposal.slotNumber}`,
|
|
589
|
+
);
|
|
590
|
+
return false;
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
return true;
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
private async createCheckpointAttestationsFromProposal(
|
|
597
|
+
proposal: CheckpointProposalCore,
|
|
598
|
+
attestors: EthAddress[] = [],
|
|
599
|
+
): Promise<CheckpointAttestation[] | undefined> {
|
|
600
|
+
// Equivocation check: must happen right before signing to minimize the race window
|
|
601
|
+
if (!this.shouldAttestToSlot(proposal.slotNumber)) {
|
|
602
|
+
return undefined;
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
const attestations = await this.validationService.attestToCheckpointProposal(proposal, attestors);
|
|
606
|
+
|
|
607
|
+
// Track the proposal we attested to (to prevent equivocation)
|
|
608
|
+
this.lastAttestedProposal = proposal;
|
|
609
|
+
|
|
610
|
+
await this.p2pClient.addOwnCheckpointAttestations(attestations);
|
|
611
|
+
return attestations;
|
|
374
612
|
}
|
|
375
613
|
|
|
376
614
|
private slashInvalidBlock(proposal: BlockProposal) {
|
|
@@ -400,24 +638,125 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
400
638
|
]);
|
|
401
639
|
}
|
|
402
640
|
|
|
641
|
+
/**
|
|
642
|
+
* Handle detection of a duplicate proposal (equivocation).
|
|
643
|
+
* Emits a slash event when a proposer sends multiple proposals for the same position.
|
|
644
|
+
*/
|
|
645
|
+
private handleDuplicateProposal(info: DuplicateProposalInfo): void {
|
|
646
|
+
const { slot, proposer, type } = info;
|
|
647
|
+
|
|
648
|
+
this.log.warn(`Triggering slash event for duplicate ${type} proposal from ${proposer.toString()} at slot ${slot}`, {
|
|
649
|
+
proposer: proposer.toString(),
|
|
650
|
+
slot,
|
|
651
|
+
type,
|
|
652
|
+
});
|
|
653
|
+
|
|
654
|
+
// Emit slash event
|
|
655
|
+
this.emit(WANT_TO_SLASH_EVENT, [
|
|
656
|
+
{
|
|
657
|
+
validator: proposer,
|
|
658
|
+
amount: this.config.slashDuplicateProposalPenalty,
|
|
659
|
+
offenseType: OffenseType.DUPLICATE_PROPOSAL,
|
|
660
|
+
epochOrSlot: BigInt(slot),
|
|
661
|
+
},
|
|
662
|
+
]);
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
/**
|
|
666
|
+
* Handle detection of a duplicate attestation (equivocation).
|
|
667
|
+
* Emits a slash event when an attester signs attestations for different proposals at the same slot.
|
|
668
|
+
*/
|
|
669
|
+
private handleDuplicateAttestation(info: DuplicateAttestationInfo): void {
|
|
670
|
+
const { slot, attester } = info;
|
|
671
|
+
|
|
672
|
+
this.log.warn(`Triggering slash event for duplicate attestation from ${attester.toString()} at slot ${slot}`, {
|
|
673
|
+
attester: attester.toString(),
|
|
674
|
+
slot,
|
|
675
|
+
});
|
|
676
|
+
|
|
677
|
+
this.emit(WANT_TO_SLASH_EVENT, [
|
|
678
|
+
{
|
|
679
|
+
validator: attester,
|
|
680
|
+
amount: this.config.slashDuplicateAttestationPenalty,
|
|
681
|
+
offenseType: OffenseType.DUPLICATE_ATTESTATION,
|
|
682
|
+
epochOrSlot: BigInt(slot),
|
|
683
|
+
},
|
|
684
|
+
]);
|
|
685
|
+
}
|
|
686
|
+
|
|
403
687
|
async createBlockProposal(
|
|
404
|
-
|
|
405
|
-
|
|
688
|
+
blockHeader: BlockHeader,
|
|
689
|
+
indexWithinCheckpoint: IndexWithinCheckpoint,
|
|
690
|
+
inHash: Fr,
|
|
406
691
|
archive: Fr,
|
|
407
692
|
txs: Tx[],
|
|
408
693
|
proposerAddress: EthAddress | undefined,
|
|
409
|
-
options: BlockProposalOptions,
|
|
410
|
-
): Promise<BlockProposal
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
694
|
+
options: BlockProposalOptions = {},
|
|
695
|
+
): Promise<BlockProposal> {
|
|
696
|
+
// Validate that we're not creating a proposal for an older or equal position
|
|
697
|
+
if (this.lastProposedBlock) {
|
|
698
|
+
const lastSlot = this.lastProposedBlock.slotNumber;
|
|
699
|
+
const lastIndex = this.lastProposedBlock.indexWithinCheckpoint;
|
|
700
|
+
const newSlot = blockHeader.globalVariables.slotNumber;
|
|
701
|
+
|
|
702
|
+
if (newSlot < lastSlot || (newSlot === lastSlot && indexWithinCheckpoint <= lastIndex)) {
|
|
703
|
+
throw new Error(
|
|
704
|
+
`Cannot create block proposal for slot ${newSlot} index ${indexWithinCheckpoint}: ` +
|
|
705
|
+
`already proposed block for slot ${lastSlot} index ${lastIndex}`,
|
|
706
|
+
);
|
|
707
|
+
}
|
|
414
708
|
}
|
|
415
709
|
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
710
|
+
this.log.info(
|
|
711
|
+
`Assembling block proposal for block ${blockHeader.globalVariables.blockNumber} slot ${blockHeader.globalVariables.slotNumber}`,
|
|
712
|
+
);
|
|
713
|
+
const newProposal = await this.validationService.createBlockProposal(
|
|
714
|
+
blockHeader,
|
|
715
|
+
indexWithinCheckpoint,
|
|
716
|
+
inHash,
|
|
717
|
+
archive,
|
|
718
|
+
txs,
|
|
719
|
+
proposerAddress,
|
|
720
|
+
{
|
|
721
|
+
...options,
|
|
722
|
+
broadcastInvalidBlockProposal: this.config.broadcastInvalidBlockProposal,
|
|
723
|
+
},
|
|
724
|
+
);
|
|
725
|
+
this.lastProposedBlock = newProposal;
|
|
726
|
+
return newProposal;
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
async createCheckpointProposal(
|
|
730
|
+
checkpointHeader: CheckpointHeader,
|
|
731
|
+
archive: Fr,
|
|
732
|
+
feeAssetPriceModifier: bigint,
|
|
733
|
+
lastBlockInfo: CreateCheckpointProposalLastBlockData | undefined,
|
|
734
|
+
proposerAddress: EthAddress | undefined,
|
|
735
|
+
options: CheckpointProposalOptions = {},
|
|
736
|
+
): Promise<CheckpointProposal> {
|
|
737
|
+
// Validate that we're not creating a proposal for an older or equal slot
|
|
738
|
+
if (this.lastProposedCheckpoint) {
|
|
739
|
+
const lastSlot = this.lastProposedCheckpoint.slotNumber;
|
|
740
|
+
const newSlot = checkpointHeader.slotNumber;
|
|
741
|
+
|
|
742
|
+
if (newSlot <= lastSlot) {
|
|
743
|
+
throw new Error(
|
|
744
|
+
`Cannot create checkpoint proposal for slot ${newSlot}: ` +
|
|
745
|
+
`already proposed checkpoint for slot ${lastSlot}`,
|
|
746
|
+
);
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
this.log.info(`Assembling checkpoint proposal for slot ${checkpointHeader.slotNumber}`);
|
|
751
|
+
const newProposal = await this.validationService.createCheckpointProposal(
|
|
752
|
+
checkpointHeader,
|
|
753
|
+
archive,
|
|
754
|
+
feeAssetPriceModifier,
|
|
755
|
+
lastBlockInfo,
|
|
756
|
+
proposerAddress,
|
|
757
|
+
options,
|
|
758
|
+
);
|
|
759
|
+
this.lastProposedCheckpoint = newProposal;
|
|
421
760
|
return newProposal;
|
|
422
761
|
}
|
|
423
762
|
|
|
@@ -428,28 +767,38 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
428
767
|
async signAttestationsAndSigners(
|
|
429
768
|
attestationsAndSigners: CommitteeAttestationsAndSigners,
|
|
430
769
|
proposer: EthAddress,
|
|
770
|
+
slot: SlotNumber,
|
|
771
|
+
blockNumber: BlockNumber | CheckpointNumber,
|
|
431
772
|
): Promise<Signature> {
|
|
432
|
-
return await this.validationService.signAttestationsAndSigners(attestationsAndSigners, proposer);
|
|
773
|
+
return await this.validationService.signAttestationsAndSigners(attestationsAndSigners, proposer, slot, blockNumber);
|
|
433
774
|
}
|
|
434
775
|
|
|
435
|
-
async collectOwnAttestations(proposal:
|
|
436
|
-
const slot = proposal.
|
|
776
|
+
async collectOwnAttestations(proposal: CheckpointProposal): Promise<CheckpointAttestation[]> {
|
|
777
|
+
const slot = proposal.slotNumber;
|
|
437
778
|
const inCommittee = await this.epochCache.filterInCommittee(slot, this.getValidatorAddresses());
|
|
438
779
|
this.log.debug(`Collecting ${inCommittee.length} self-attestations for slot ${slot}`, { inCommittee });
|
|
439
|
-
const attestations = await this.
|
|
780
|
+
const attestations = await this.createCheckpointAttestationsFromProposal(proposal, inCommittee);
|
|
781
|
+
|
|
782
|
+
if (!attestations) {
|
|
783
|
+
return [];
|
|
784
|
+
}
|
|
440
785
|
|
|
441
786
|
// We broadcast our own attestations to our peers so, in case our block does not get mined on L1,
|
|
442
787
|
// other nodes can see that our validators did attest to this block proposal, and do not slash us
|
|
443
788
|
// due to inactivity for missed attestations.
|
|
444
|
-
void this.p2pClient.
|
|
789
|
+
void this.p2pClient.broadcastCheckpointAttestations(attestations).catch(err => {
|
|
445
790
|
this.log.error(`Failed to broadcast self-attestations for slot ${slot}`, err);
|
|
446
791
|
});
|
|
447
792
|
return attestations;
|
|
448
793
|
}
|
|
449
794
|
|
|
450
|
-
async collectAttestations(
|
|
451
|
-
|
|
452
|
-
|
|
795
|
+
async collectAttestations(
|
|
796
|
+
proposal: CheckpointProposal,
|
|
797
|
+
required: number,
|
|
798
|
+
deadline: Date,
|
|
799
|
+
): Promise<CheckpointAttestation[]> {
|
|
800
|
+
// Wait and poll the p2pClient's attestation pool for this checkpoint until we have enough attestations
|
|
801
|
+
const slot = proposal.slotNumber;
|
|
453
802
|
this.log.debug(`Collecting ${required} attestations for slot ${slot} with deadline ${deadline.toISOString()}`);
|
|
454
803
|
|
|
455
804
|
if (+deadline < this.dateProvider.now()) {
|
|
@@ -464,16 +813,16 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
464
813
|
const proposalId = proposal.archive.toString();
|
|
465
814
|
const myAddresses = this.getValidatorAddresses();
|
|
466
815
|
|
|
467
|
-
let attestations:
|
|
816
|
+
let attestations: CheckpointAttestation[] = [];
|
|
468
817
|
while (true) {
|
|
469
|
-
// Filter out attestations with a mismatching
|
|
818
|
+
// Filter out attestations with a mismatching archive. This should NOT happen since we have verified
|
|
470
819
|
// the proposer signature (ie our own) before accepting the attestation into the pool via the p2p client.
|
|
471
|
-
const collectedAttestations = (await this.p2pClient.
|
|
820
|
+
const collectedAttestations = (await this.p2pClient.getCheckpointAttestationsForSlot(slot, proposalId)).filter(
|
|
472
821
|
attestation => {
|
|
473
|
-
if (!attestation.
|
|
822
|
+
if (!attestation.archive.equals(proposal.archive)) {
|
|
474
823
|
this.log.warn(
|
|
475
|
-
`Received attestation for slot ${slot} with mismatched
|
|
476
|
-
{
|
|
824
|
+
`Received attestation for slot ${slot} with mismatched archive from ${attestation.getSender()?.toString()}`,
|
|
825
|
+
{ attestationArchive: attestation.archive.toString(), proposalArchive: proposal.archive.toString() },
|
|
477
826
|
);
|
|
478
827
|
return false;
|
|
479
828
|
}
|
|
@@ -514,15 +863,6 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
514
863
|
}
|
|
515
864
|
}
|
|
516
865
|
|
|
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
866
|
private async handleAuthRequest(peer: PeerId, msg: Buffer): Promise<Buffer> {
|
|
527
867
|
const authRequest = AuthRequest.fromBuffer(msg);
|
|
528
868
|
const statusMessage = await this.p2pClient.handleAuthRequestFromPeer(authRequest, peer).catch(_ => undefined);
|
|
@@ -541,7 +881,9 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
541
881
|
}
|
|
542
882
|
|
|
543
883
|
const payloadToSign = authRequest.getPayloadToSign();
|
|
544
|
-
|
|
884
|
+
// AUTH_REQUEST doesn't require HA protection - multiple signatures are safe
|
|
885
|
+
const context: SigningContext = { dutyType: DutyType.AUTH_REQUEST };
|
|
886
|
+
const signature = await this.keyStore.signMessageWithAddress(addressToUse, payloadToSign, context);
|
|
545
887
|
const authResponse = new AuthResponse(statusMessage, signature);
|
|
546
888
|
return authResponse.toBuffer();
|
|
547
889
|
}
|