@aztec/validator-client 0.0.1-commit.2ed92850 → 0.0.1-commit.3100065
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 +63 -18
- package/dest/checkpoint_builder.d.ts +26 -14
- package/dest/checkpoint_builder.d.ts.map +1 -1
- package/dest/checkpoint_builder.js +138 -45
- package/dest/config.d.ts +9 -3
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +47 -10
- package/dest/duties/validation_service.d.ts +12 -13
- package/dest/duties/validation_service.d.ts.map +1 -1
- package/dest/duties/validation_service.js +33 -45
- package/dest/factory.d.ts +10 -4
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +19 -6
- package/dest/index.d.ts +2 -3
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -2
- package/dest/key_store/ha_key_store.d.ts +1 -1
- package/dest/key_store/ha_key_store.d.ts.map +1 -1
- package/dest/key_store/ha_key_store.js +3 -3
- package/dest/key_store/web3signer_key_store.d.ts +10 -2
- package/dest/key_store/web3signer_key_store.d.ts.map +1 -1
- package/dest/key_store/web3signer_key_store.js +32 -41
- package/dest/metrics.d.ts +16 -3
- package/dest/metrics.d.ts.map +1 -1
- package/dest/metrics.js +58 -5
- package/dest/proposal_handler.d.ts +165 -0
- package/dest/proposal_handler.d.ts.map +1 -0
- package/dest/proposal_handler.js +1207 -0
- package/dest/validator.d.ts +65 -25
- package/dest/validator.d.ts.map +1 -1
- package/dest/validator.js +377 -240
- package/package.json +19 -17
- package/src/checkpoint_builder.ts +185 -50
- package/src/config.ts +55 -12
- package/src/duties/validation_service.ts +59 -54
- package/src/factory.ts +29 -4
- package/src/index.ts +1 -2
- package/src/key_store/ha_key_store.ts +3 -3
- package/src/key_store/web3signer_key_store.ts +43 -59
- package/src/metrics.ts +81 -6
- package/src/proposal_handler.ts +1314 -0
- package/src/validator.ts +512 -291
- package/dest/block_proposal_handler.d.ts +0 -64
- package/dest/block_proposal_handler.d.ts.map +0 -1
- package/dest/block_proposal_handler.js +0 -545
- package/dest/tx_validator/index.d.ts +0 -3
- package/dest/tx_validator/index.d.ts.map +0 -1
- package/dest/tx_validator/index.js +0 -2
- package/dest/tx_validator/nullifier_cache.d.ts +0 -14
- package/dest/tx_validator/nullifier_cache.d.ts.map +0 -1
- package/dest/tx_validator/nullifier_cache.js +0 -24
- package/dest/tx_validator/tx_validator_factory.d.ts +0 -18
- package/dest/tx_validator/tx_validator_factory.d.ts.map +0 -1
- package/dest/tx_validator/tx_validator_factory.js +0 -54
- package/src/block_proposal_handler.ts +0 -554
- package/src/tx_validator/index.ts +0 -2
- package/src/tx_validator/nullifier_cache.ts +0 -30
- package/src/tx_validator/tx_validator_factory.ts +0 -135
package/src/validator.ts
CHANGED
|
@@ -1,71 +1,82 @@
|
|
|
1
1
|
import type { BlobClientInterface } from '@aztec/blob-client/client';
|
|
2
2
|
import { type Blob, getBlobsPerL1Block } from '@aztec/blob-lib';
|
|
3
3
|
import type { EpochCache } from '@aztec/epoch-cache';
|
|
4
|
-
import {
|
|
5
|
-
BlockNumber,
|
|
6
|
-
CheckpointNumber,
|
|
7
|
-
EpochNumber,
|
|
8
|
-
IndexWithinCheckpoint,
|
|
9
|
-
SlotNumber,
|
|
10
|
-
} from '@aztec/foundation/branded-types';
|
|
4
|
+
import { CheckpointNumber, EpochNumber, IndexWithinCheckpoint, SlotNumber } from '@aztec/foundation/branded-types';
|
|
11
5
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
12
|
-
import { TimeoutError } from '@aztec/foundation/error';
|
|
13
6
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
14
|
-
import
|
|
7
|
+
import { Signature } from '@aztec/foundation/eth-signature';
|
|
8
|
+
import { FifoSet } from '@aztec/foundation/fifo-set';
|
|
15
9
|
import { type LogData, type Logger, createLogger } from '@aztec/foundation/log';
|
|
16
|
-
import { retryUntil } from '@aztec/foundation/retry';
|
|
17
10
|
import { RunningPromise } from '@aztec/foundation/running-promise';
|
|
18
11
|
import { sleep } from '@aztec/foundation/sleep';
|
|
19
12
|
import { DateProvider } from '@aztec/foundation/timer';
|
|
20
13
|
import type { KeystoreManager } from '@aztec/node-keystore';
|
|
21
|
-
import type { P2P, PeerId
|
|
14
|
+
import type { DuplicateAttestationInfo, DuplicateProposalInfo, OversizedProposalInfo, P2P, PeerId } from '@aztec/p2p';
|
|
22
15
|
import { AuthRequest, AuthResponse, BlockProposalValidator, ReqRespSubProtocol } from '@aztec/p2p';
|
|
23
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
OffenseType,
|
|
18
|
+
WANT_TO_CLEAR_SLASH_EVENT,
|
|
19
|
+
WANT_TO_SLASH_EVENT,
|
|
20
|
+
type Watcher,
|
|
21
|
+
type WatcherEmitter,
|
|
22
|
+
getOffenseTypeName,
|
|
23
|
+
} from '@aztec/slasher';
|
|
24
24
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
25
|
-
import type { CommitteeAttestationsAndSigners,
|
|
25
|
+
import type { CommitteeAttestationsAndSigners, L2BlockSink, L2BlockSource } from '@aztec/stdlib/block';
|
|
26
|
+
import type { CheckpointReexecutionTracker } from '@aztec/stdlib/checkpoint';
|
|
26
27
|
import { getEpochAtSlot } from '@aztec/stdlib/epoch-helpers';
|
|
27
28
|
import type {
|
|
28
|
-
|
|
29
|
+
ITxProvider,
|
|
29
30
|
Validator,
|
|
30
31
|
ValidatorClientFullConfig,
|
|
31
32
|
WorldStateSynchronizer,
|
|
32
33
|
} from '@aztec/stdlib/interfaces/server';
|
|
33
34
|
import type { L1ToL2MessageSource } from '@aztec/stdlib/messaging';
|
|
34
|
-
import
|
|
35
|
-
BlockProposal,
|
|
36
|
-
BlockProposalOptions,
|
|
35
|
+
import {
|
|
36
|
+
type BlockProposal,
|
|
37
|
+
type BlockProposalOptions,
|
|
37
38
|
CheckpointAttestation,
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
CheckpointProposal,
|
|
40
|
+
type CheckpointProposalCore,
|
|
41
|
+
type CheckpointProposalOptions,
|
|
42
|
+
type CoordinationSignatureContext,
|
|
40
43
|
} from '@aztec/stdlib/p2p';
|
|
41
|
-
import { CheckpointProposal } from '@aztec/stdlib/p2p';
|
|
42
44
|
import type { CheckpointHeader } from '@aztec/stdlib/rollup';
|
|
43
|
-
import
|
|
45
|
+
import { ConsensusTimetable } from '@aztec/stdlib/timetable';
|
|
46
|
+
import type { BlockHeader, Tx } from '@aztec/stdlib/tx';
|
|
44
47
|
import { AttestationTimeoutError } from '@aztec/stdlib/validators';
|
|
45
48
|
import { type TelemetryClient, type Tracer, getTelemetryClient } from '@aztec/telemetry-client';
|
|
46
|
-
import {
|
|
47
|
-
|
|
49
|
+
import {
|
|
50
|
+
createHASigner,
|
|
51
|
+
createLocalSignerWithProtection,
|
|
52
|
+
createSignerFromSharedDb,
|
|
53
|
+
} from '@aztec/validator-ha-signer/factory';
|
|
54
|
+
import { DutyType, type SigningContext, type SlashingProtectionDatabase } from '@aztec/validator-ha-signer/types';
|
|
55
|
+
import type { ValidatorHASigner } from '@aztec/validator-ha-signer/validator-ha-signer';
|
|
48
56
|
|
|
49
57
|
import { EventEmitter } from 'events';
|
|
50
58
|
import type { TypedDataDefinition } from 'viem';
|
|
51
59
|
|
|
52
|
-
import { BlockProposalHandler, type BlockProposalValidationFailureReason } from './block_proposal_handler.js';
|
|
53
60
|
import type { FullNodeCheckpointsBuilder } from './checkpoint_builder.js';
|
|
61
|
+
import { DEFAULT_MAX_GOSSIP_CLOCK_DISPARITY_MS } from './config.js';
|
|
54
62
|
import { ValidationService } from './duties/validation_service.js';
|
|
55
63
|
import { HAKeyStore } from './key_store/ha_key_store.js';
|
|
56
64
|
import type { ExtendedValidatorKeyStore } from './key_store/interface.js';
|
|
57
65
|
import { NodeKeystoreAdapter } from './key_store/node_keystore_adapter.js';
|
|
58
66
|
import { ValidatorMetrics } from './metrics.js';
|
|
67
|
+
import {
|
|
68
|
+
type BlockProposalValidationFailureReason,
|
|
69
|
+
type CheckpointProposalValidationFailureResult,
|
|
70
|
+
ProposalHandler,
|
|
71
|
+
SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT,
|
|
72
|
+
SLASHABLE_CHECKPOINT_PROPOSAL_VALIDATION_RESULT,
|
|
73
|
+
} from './proposal_handler.js';
|
|
59
74
|
|
|
60
75
|
// We maintain a set of proposers who have proposed invalid blocks.
|
|
61
76
|
// Just cap the set to avoid unbounded growth.
|
|
62
77
|
const MAX_PROPOSERS_OF_INVALID_BLOCKS = 1000;
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
const SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT: BlockProposalValidationFailureReason[] = [
|
|
66
|
-
'state_mismatch',
|
|
67
|
-
'failed_txs',
|
|
68
|
-
];
|
|
78
|
+
const MAX_TRACKED_INVALID_CHECKPOINT_PROPOSALS = 1000;
|
|
79
|
+
const MAX_TRACKED_BAD_ATTESTATIONS = 10_000;
|
|
69
80
|
|
|
70
81
|
/**
|
|
71
82
|
* Validator Client
|
|
@@ -75,34 +86,40 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
75
86
|
private validationService: ValidationService;
|
|
76
87
|
private metrics: ValidatorMetrics;
|
|
77
88
|
private log: Logger;
|
|
78
|
-
|
|
79
89
|
// Whether it has already registered handlers on the p2p client
|
|
80
90
|
private hasRegisteredHandlers = false;
|
|
81
91
|
|
|
82
|
-
|
|
83
|
-
private
|
|
92
|
+
/** Tracks the last block proposal we created, to detect duplicate proposal attempts. */
|
|
93
|
+
private lastProposedBlock?: BlockProposal;
|
|
94
|
+
|
|
95
|
+
/** Tracks the last checkpoint proposal we created. */
|
|
96
|
+
private lastProposedCheckpoint?: CheckpointProposal;
|
|
84
97
|
|
|
85
98
|
private lastEpochForCommitteeUpdateLoop: EpochNumber | undefined;
|
|
86
99
|
private epochCacheUpdateLoop: RunningPromise;
|
|
100
|
+
/** Tracks the last epoch in which each attester successfully submitted at least one attestation. */
|
|
101
|
+
private lastAttestedEpochByAttester: Map<string, EpochNumber> = new Map();
|
|
87
102
|
|
|
88
|
-
private proposersOfInvalidBlocks
|
|
103
|
+
private proposersOfInvalidBlocks = FifoSet.withLimit<string>(MAX_PROPOSERS_OF_INVALID_BLOCKS);
|
|
104
|
+
private invalidCheckpointProposalOffenseKeys = FifoSet.withLimit<string>(MAX_TRACKED_INVALID_CHECKPOINT_PROPOSALS);
|
|
105
|
+
private oversizedProposalOffenseKeys = FifoSet.withLimit<string>(MAX_TRACKED_INVALID_CHECKPOINT_PROPOSALS);
|
|
106
|
+
private badAttestationOffenseKeys = FifoSet.withLimit<string>(MAX_TRACKED_BAD_ATTESTATIONS);
|
|
89
107
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
// eslint-disable-next-line aztec-custom/no-non-primitive-in-collections
|
|
93
|
-
private validatedBlockSlots: Set<SlotNumber> = new Set();
|
|
108
|
+
/** Tracks the last checkpoint proposal we attested to, to prevent equivocation. */
|
|
109
|
+
private lastAttestedProposal?: CheckpointProposalCore;
|
|
94
110
|
|
|
95
111
|
protected constructor(
|
|
96
112
|
private keyStore: ExtendedValidatorKeyStore,
|
|
97
113
|
private epochCache: EpochCache,
|
|
98
114
|
private p2pClient: P2P,
|
|
99
|
-
private
|
|
115
|
+
private proposalHandler: ProposalHandler,
|
|
100
116
|
private blockSource: L2BlockSource,
|
|
101
117
|
private checkpointsBuilder: FullNodeCheckpointsBuilder,
|
|
102
118
|
private worldState: WorldStateSynchronizer,
|
|
103
119
|
private l1ToL2MessageSource: L1ToL2MessageSource,
|
|
104
120
|
private config: ValidatorClientFullConfig,
|
|
105
121
|
private blobClient: BlobClientInterface,
|
|
122
|
+
private slashingProtectionSigner: ValidatorHASigner,
|
|
106
123
|
private dateProvider: DateProvider = new DateProvider(),
|
|
107
124
|
telemetry: TelemetryClient = getTelemetryClient(),
|
|
108
125
|
log = createLogger('validator'),
|
|
@@ -115,11 +132,17 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
115
132
|
this.tracer = telemetry.getTracer('Validator');
|
|
116
133
|
this.metrics = new ValidatorMetrics(telemetry);
|
|
117
134
|
|
|
118
|
-
this.validationService = new ValidationService(
|
|
135
|
+
this.validationService = new ValidationService(
|
|
136
|
+
keyStore,
|
|
137
|
+
this.getSignatureContext(),
|
|
138
|
+
this.log.createChild('validation-service'),
|
|
139
|
+
);
|
|
140
|
+
this.proposalHandler.setCheckpointProposalValidationFailureCallback((proposal, result, proposalInfo) =>
|
|
141
|
+
this.handleInvalidCheckpointProposal(proposal, result, proposalInfo),
|
|
142
|
+
);
|
|
119
143
|
|
|
120
144
|
// Refresh epoch cache every second to trigger alert if participation in committee changes
|
|
121
145
|
this.epochCacheUpdateLoop = new RunningPromise(this.handleEpochCommitteeUpdate.bind(this), this.log, 1000);
|
|
122
|
-
|
|
123
146
|
const myAddresses = this.getValidatorAddresses();
|
|
124
147
|
this.log.verbose(`Initialized validator with addresses: ${myAddresses.map(a => a.toString()).join(', ')}`);
|
|
125
148
|
}
|
|
@@ -156,6 +179,7 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
156
179
|
this.log.trace(`No committee found for slot`);
|
|
157
180
|
return;
|
|
158
181
|
}
|
|
182
|
+
this.metrics.setCurrentEpoch(epoch);
|
|
159
183
|
if (epoch !== this.lastEpochForCommitteeUpdateLoop) {
|
|
160
184
|
const me = this.getValidatorAddresses();
|
|
161
185
|
const committeeSet = new Set(committee.map(v => v.toString()));
|
|
@@ -184,17 +208,31 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
184
208
|
p2pClient: P2P,
|
|
185
209
|
blockSource: L2BlockSource & L2BlockSink,
|
|
186
210
|
l1ToL2MessageSource: L1ToL2MessageSource,
|
|
187
|
-
txProvider:
|
|
211
|
+
txProvider: ITxProvider,
|
|
188
212
|
keyStoreManager: KeystoreManager,
|
|
189
213
|
blobClient: BlobClientInterface,
|
|
214
|
+
reexecutionTracker: CheckpointReexecutionTracker,
|
|
190
215
|
dateProvider: DateProvider = new DateProvider(),
|
|
191
216
|
telemetry: TelemetryClient = getTelemetryClient(),
|
|
217
|
+
slashingProtectionDb?: SlashingProtectionDatabase,
|
|
192
218
|
) {
|
|
193
219
|
const metrics = new ValidatorMetrics(telemetry);
|
|
194
|
-
const
|
|
220
|
+
const consensusTimetable = new ConsensusTimetable({
|
|
221
|
+
l1Constants: epochCache.getL1Constants(),
|
|
222
|
+
blockDuration: config.blockDurationMs / 1000,
|
|
223
|
+
});
|
|
224
|
+
const blockProposalValidator = new BlockProposalValidator(epochCache, consensusTimetable, {
|
|
195
225
|
txsPermitted: !config.disableTransactions,
|
|
226
|
+
maxTxsPerBlock: config.validateMaxTxsPerBlock,
|
|
227
|
+
maxBlocksPerCheckpoint: config.maxBlocksPerCheckpoint,
|
|
228
|
+
skipSlotValidation: config.skipProposalSlotValidation,
|
|
229
|
+
signatureContext: {
|
|
230
|
+
chainId: config.l1ChainId,
|
|
231
|
+
rollupAddress: config.rollupAddress,
|
|
232
|
+
},
|
|
233
|
+
clockDisparityMs: config.maxGossipClockDisparityMs ?? DEFAULT_MAX_GOSSIP_CLOCK_DISPARITY_MS,
|
|
196
234
|
});
|
|
197
|
-
const
|
|
235
|
+
const proposalHandler = new ProposalHandler(
|
|
198
236
|
checkpointsBuilder,
|
|
199
237
|
worldState,
|
|
200
238
|
blockSource,
|
|
@@ -202,34 +240,57 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
202
240
|
txProvider,
|
|
203
241
|
blockProposalValidator,
|
|
204
242
|
epochCache,
|
|
243
|
+
consensusTimetable,
|
|
205
244
|
config,
|
|
245
|
+
blobClient,
|
|
246
|
+
reexecutionTracker,
|
|
206
247
|
metrics,
|
|
207
248
|
dateProvider,
|
|
208
249
|
telemetry,
|
|
250
|
+
undefined,
|
|
209
251
|
);
|
|
210
252
|
|
|
211
|
-
|
|
212
|
-
|
|
253
|
+
const nodeKeystoreAdapter = NodeKeystoreAdapter.fromKeyStoreManager(keyStoreManager);
|
|
254
|
+
let slashingProtectionSigner: ValidatorHASigner;
|
|
255
|
+
if (slashingProtectionDb) {
|
|
256
|
+
// Shared database mode: use a pre-existing database (e.g. for testing HA setups).
|
|
257
|
+
({ signer: slashingProtectionSigner } = createSignerFromSharedDb(slashingProtectionDb, config, {
|
|
258
|
+
telemetryClient: telemetry,
|
|
259
|
+
dateProvider,
|
|
260
|
+
}));
|
|
261
|
+
} else if (config.haSigningEnabled) {
|
|
262
|
+
// Multi-node HA mode: use PostgreSQL-backed distributed locking.
|
|
213
263
|
// If maxStuckDutiesAgeMs is not explicitly set, compute it from Aztec slot duration
|
|
214
264
|
const haConfig = {
|
|
215
265
|
...config,
|
|
216
266
|
maxStuckDutiesAgeMs: config.maxStuckDutiesAgeMs ?? epochCache.getL1Constants().slotDuration * 2 * 1000,
|
|
217
267
|
};
|
|
218
|
-
|
|
219
|
-
|
|
268
|
+
({ signer: slashingProtectionSigner } = await createHASigner(haConfig, {
|
|
269
|
+
telemetryClient: telemetry,
|
|
270
|
+
dateProvider,
|
|
271
|
+
}));
|
|
272
|
+
} else {
|
|
273
|
+
// Single-node mode: use LMDB-backed local signing protection.
|
|
274
|
+
// This prevents double-signing if the node crashes and restarts mid-proposal.
|
|
275
|
+
({ signer: slashingProtectionSigner } = await createLocalSignerWithProtection(config, {
|
|
276
|
+
telemetryClient: telemetry,
|
|
277
|
+
dateProvider,
|
|
278
|
+
}));
|
|
220
279
|
}
|
|
280
|
+
const validatorKeyStore: ExtendedValidatorKeyStore = new HAKeyStore(nodeKeystoreAdapter, slashingProtectionSigner);
|
|
221
281
|
|
|
222
282
|
const validator = new ValidatorClient(
|
|
223
283
|
validatorKeyStore,
|
|
224
284
|
epochCache,
|
|
225
285
|
p2pClient,
|
|
226
|
-
|
|
286
|
+
proposalHandler,
|
|
227
287
|
blockSource,
|
|
228
288
|
checkpointsBuilder,
|
|
229
289
|
worldState,
|
|
230
290
|
l1ToL2MessageSource,
|
|
231
291
|
config,
|
|
232
292
|
blobClient,
|
|
293
|
+
slashingProtectionSigner,
|
|
233
294
|
dateProvider,
|
|
234
295
|
telemetry,
|
|
235
296
|
);
|
|
@@ -243,14 +304,21 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
243
304
|
.filter(addr => !this.config.disabledValidators.some(disabled => disabled.equals(addr)));
|
|
244
305
|
}
|
|
245
306
|
|
|
246
|
-
public
|
|
247
|
-
return this.
|
|
307
|
+
public getProposalHandler() {
|
|
308
|
+
return this.proposalHandler;
|
|
248
309
|
}
|
|
249
310
|
|
|
250
311
|
public signWithAddress(addr: EthAddress, msg: TypedDataDefinition, context: SigningContext) {
|
|
251
312
|
return this.keyStore.signTypedDataWithAddress(addr, msg, context);
|
|
252
313
|
}
|
|
253
314
|
|
|
315
|
+
private getSignatureContext(): CoordinationSignatureContext {
|
|
316
|
+
return {
|
|
317
|
+
chainId: this.config.l1ChainId,
|
|
318
|
+
rollupAddress: this.config.rollupAddress,
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
|
|
254
322
|
public getCoinbaseForAttestor(attestor: EthAddress): EthAddress {
|
|
255
323
|
return this.keyStore.getCoinbaseAddress(attestor);
|
|
256
324
|
}
|
|
@@ -263,8 +331,27 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
263
331
|
return this.config;
|
|
264
332
|
}
|
|
265
333
|
|
|
334
|
+
public hasProposalEquivocation(slotNumber: SlotNumber): boolean {
|
|
335
|
+
return this.proposalHandler.hasProposalEquivocation(slotNumber);
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
public hasInvalidProposals(slotNumber: SlotNumber): boolean {
|
|
339
|
+
return this.proposalHandler.hasInvalidProposals(slotNumber);
|
|
340
|
+
}
|
|
341
|
+
|
|
266
342
|
public updateConfig(config: Partial<ValidatorClientFullConfig>) {
|
|
267
343
|
this.config = { ...this.config, ...config };
|
|
344
|
+
this.proposalHandler.updateConfig(config);
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
public reloadKeystore(newManager: KeystoreManager): void {
|
|
348
|
+
const newAdapter = NodeKeystoreAdapter.fromKeyStoreManager(newManager);
|
|
349
|
+
this.keyStore = new HAKeyStore(newAdapter, this.slashingProtectionSigner);
|
|
350
|
+
this.validationService = new ValidationService(
|
|
351
|
+
this.keyStore,
|
|
352
|
+
this.getSignatureContext(),
|
|
353
|
+
this.log.createChild('validation-service'),
|
|
354
|
+
);
|
|
268
355
|
}
|
|
269
356
|
|
|
270
357
|
public async start() {
|
|
@@ -311,7 +398,26 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
311
398
|
checkpoint: CheckpointProposalCore,
|
|
312
399
|
proposalSender: PeerId,
|
|
313
400
|
): Promise<CheckpointAttestation[] | undefined> => this.attestToCheckpointProposal(checkpoint, proposalSender);
|
|
314
|
-
this.p2pClient.
|
|
401
|
+
this.p2pClient.registerValidatorCheckpointProposalHandler(checkpointHandler);
|
|
402
|
+
|
|
403
|
+
// Duplicate proposal handler - triggers slashing for equivocation
|
|
404
|
+
this.p2pClient.registerDuplicateProposalCallback((info: DuplicateProposalInfo) => {
|
|
405
|
+
this.handleDuplicateProposal(info);
|
|
406
|
+
});
|
|
407
|
+
|
|
408
|
+
// Oversized proposal handler - triggers slashing for proposals beyond the per-checkpoint block limit
|
|
409
|
+
this.p2pClient.registerOversizedProposalCallback((info: OversizedProposalInfo) => {
|
|
410
|
+
this.handleOversizedProposal(info);
|
|
411
|
+
});
|
|
412
|
+
|
|
413
|
+
// Duplicate attestation handler - triggers slashing for attestation equivocation
|
|
414
|
+
this.p2pClient.registerDuplicateAttestationCallback((info: DuplicateAttestationInfo) => {
|
|
415
|
+
this.handleDuplicateAttestation(info);
|
|
416
|
+
});
|
|
417
|
+
|
|
418
|
+
this.p2pClient.registerCheckpointAttestationCallback((attestation: CheckpointAttestation) => {
|
|
419
|
+
this.handleCheckpointAttestation(attestation);
|
|
420
|
+
});
|
|
315
421
|
|
|
316
422
|
const myAddresses = this.getValidatorAddresses();
|
|
317
423
|
this.p2pClient.registerThisValidatorAddresses(myAddresses);
|
|
@@ -340,6 +446,14 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
340
446
|
return false;
|
|
341
447
|
}
|
|
342
448
|
|
|
449
|
+
// Log self-proposals from HA peers (same validator key on different nodes)
|
|
450
|
+
if (this.getValidatorAddresses().some(addr => addr.equals(proposer))) {
|
|
451
|
+
this.log.verbose(`Processing block proposal from HA peer for slot ${slotNumber}`, {
|
|
452
|
+
proposer: proposer.toString(),
|
|
453
|
+
slotNumber,
|
|
454
|
+
});
|
|
455
|
+
}
|
|
456
|
+
|
|
343
457
|
// Check if we're in the committee (for metrics purposes)
|
|
344
458
|
const inCommittee = await this.epochCache.filterInCommittee(slotNumber, this.getValidatorAddresses());
|
|
345
459
|
const partOfCommittee = inCommittee.length > 0;
|
|
@@ -351,27 +465,14 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
351
465
|
fishermanMode: this.config.fishermanMode || false,
|
|
352
466
|
});
|
|
353
467
|
|
|
354
|
-
// Reexecute
|
|
355
|
-
|
|
356
|
-
const { validatorReexecute, slashBroadcastedInvalidBlockPenalty, alwaysReexecuteBlockProposals, fishermanMode } =
|
|
357
|
-
this.config;
|
|
358
|
-
const shouldReexecute =
|
|
359
|
-
fishermanMode ||
|
|
360
|
-
(slashBroadcastedInvalidBlockPenalty > 0n && validatorReexecute) ||
|
|
361
|
-
(partOfCommittee && validatorReexecute) ||
|
|
362
|
-
alwaysReexecuteBlockProposals ||
|
|
363
|
-
this.blobClient.canUpload();
|
|
364
|
-
|
|
365
|
-
const validationResult = await this.blockProposalHandler.handleBlockProposal(
|
|
366
|
-
proposal,
|
|
367
|
-
proposalSender,
|
|
368
|
-
!!shouldReexecute && !escapeHatchOpen,
|
|
369
|
-
);
|
|
468
|
+
// Reexecute outside the escape hatch so slashing observers can detect invalid proposals even when penalties are 0.
|
|
469
|
+
const validationResult = await this.proposalHandler.handleBlockProposal(proposal, proposalSender, !escapeHatchOpen);
|
|
370
470
|
|
|
371
471
|
if (!validationResult.isValid) {
|
|
372
|
-
this.log.warn(`Block proposal validation failed: ${validationResult.reason}`, proposalInfo);
|
|
373
|
-
|
|
374
472
|
const reason = validationResult.reason || 'unknown';
|
|
473
|
+
|
|
474
|
+
this.log.warn(`Block proposal validation failed: ${reason}`, proposalInfo);
|
|
475
|
+
|
|
375
476
|
// Classify failure reason: bad proposal vs node issue
|
|
376
477
|
const badProposalReasons: BlockProposalValidationFailureReason[] = [
|
|
377
478
|
'invalid_proposal',
|
|
@@ -388,15 +489,18 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
388
489
|
this.metrics.incFailedAttestationsNodeIssue(1, reason, partOfCommittee);
|
|
389
490
|
}
|
|
390
491
|
|
|
391
|
-
// Slash invalid block proposals (can happen even when not in committee)
|
|
392
492
|
if (
|
|
393
493
|
!escapeHatchOpen &&
|
|
394
494
|
validationResult.reason &&
|
|
395
|
-
SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT.includes(validationResult.reason)
|
|
396
|
-
slashBroadcastedInvalidBlockPenalty > 0n
|
|
495
|
+
SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT.includes(validationResult.reason)
|
|
397
496
|
) {
|
|
398
|
-
this.log.
|
|
497
|
+
this.log.info(`Detected invalid block proposal offense`, {
|
|
498
|
+
...proposalInfo,
|
|
499
|
+
amount: this.config.slashBroadcastedInvalidBlockPenalty,
|
|
500
|
+
offenseType: getOffenseTypeName(OffenseType.BROADCASTED_INVALID_BLOCK_PROPOSAL),
|
|
501
|
+
});
|
|
399
502
|
this.slashInvalidBlock(proposal);
|
|
503
|
+
this.markInvalidProposalSlot(proposal.slotNumber);
|
|
400
504
|
}
|
|
401
505
|
return false;
|
|
402
506
|
}
|
|
@@ -413,10 +517,6 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
413
517
|
return false;
|
|
414
518
|
}
|
|
415
519
|
|
|
416
|
-
// TODO(palla/mbps): Remove this once checkpoint validation is stable.
|
|
417
|
-
// Track that we successfully validated a block for this slot, so we can attest to checkpoint proposals for it.
|
|
418
|
-
this.validatedBlockSlots.add(slotNumber);
|
|
419
|
-
|
|
420
520
|
return true;
|
|
421
521
|
}
|
|
422
522
|
|
|
@@ -430,59 +530,56 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
430
530
|
proposal: CheckpointProposalCore,
|
|
431
531
|
_proposalSender: PeerId,
|
|
432
532
|
): Promise<CheckpointAttestation[] | undefined> {
|
|
433
|
-
const
|
|
533
|
+
const proposalSlotNumber = proposal.slotNumber;
|
|
434
534
|
const proposer = proposal.getSender();
|
|
435
535
|
|
|
436
536
|
// If escape hatch is open for this slot's epoch, do not attest.
|
|
437
|
-
if (await this.epochCache.isEscapeHatchOpenAtSlot(
|
|
438
|
-
this.log.warn(`Escape hatch open for slot ${
|
|
537
|
+
if (await this.epochCache.isEscapeHatchOpenAtSlot(proposalSlotNumber)) {
|
|
538
|
+
this.log.warn(`Escape hatch open for slot ${proposalSlotNumber}, skipping checkpoint attestation handling`);
|
|
439
539
|
return undefined;
|
|
440
540
|
}
|
|
441
541
|
|
|
442
|
-
//
|
|
443
|
-
if (!
|
|
444
|
-
this.log.warn(`Received checkpoint proposal with invalid signature for slot ${slotNumber}`);
|
|
542
|
+
// Early-out for equivocation: refuses if we've already attested to a higher slot.
|
|
543
|
+
if (!this.shouldAttestToSlot(proposalSlotNumber)) {
|
|
445
544
|
return undefined;
|
|
446
545
|
}
|
|
447
546
|
|
|
448
|
-
//
|
|
449
|
-
|
|
547
|
+
// Ignore proposals from ourselves (may happen in HA setups)
|
|
548
|
+
if (proposer && this.getValidatorAddresses().some(addr => addr.equals(proposer))) {
|
|
549
|
+
this.log.debug(`Not attesting to block proposal from self for slot ${proposalSlotNumber}`, {
|
|
550
|
+
proposer: proposer.toString(),
|
|
551
|
+
proposalSlotNumber,
|
|
552
|
+
});
|
|
553
|
+
return undefined;
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
// Check that I have any address in the committee where this checkpoint will land before attesting
|
|
557
|
+
const inCommittee = await this.epochCache.filterInCommittee(proposalSlotNumber, this.getValidatorAddresses());
|
|
450
558
|
const partOfCommittee = inCommittee.length > 0;
|
|
451
559
|
|
|
452
560
|
const proposalInfo = {
|
|
453
|
-
|
|
561
|
+
proposalSlotNumber,
|
|
454
562
|
archive: proposal.archive.toString(),
|
|
455
|
-
proposer: proposer
|
|
456
|
-
txCount: proposal.txHashes.length,
|
|
563
|
+
proposer: proposer?.toString(),
|
|
457
564
|
};
|
|
458
|
-
this.log.info(`Received checkpoint proposal for slot ${
|
|
565
|
+
this.log.info(`Received checkpoint proposal for slot ${proposalSlotNumber}`, {
|
|
459
566
|
...proposalInfo,
|
|
460
|
-
txHashes: proposal.txHashes.map(t => t.toString()),
|
|
461
567
|
fishermanMode: this.config.fishermanMode || false,
|
|
462
568
|
});
|
|
463
569
|
|
|
464
|
-
//
|
|
465
|
-
//
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
// Validate the checkpoint proposal before attesting (unless skipCheckpointProposalValidation is set)
|
|
472
|
-
// TODO(palla/mbps): Change default to false once checkpoint validation is stable.
|
|
473
|
-
if (this.config.skipCheckpointProposalValidation !== false) {
|
|
474
|
-
this.log.verbose(`Skipping checkpoint proposal validation for slot ${slotNumber}`, proposalInfo);
|
|
570
|
+
// Validate the checkpoint proposal before attesting (unless skipCheckpointProposalValidation is set).
|
|
571
|
+
// Uses the cached result from the all-nodes callback if available (avoids double validation).
|
|
572
|
+
let checkpointNumber: CheckpointNumber;
|
|
573
|
+
if (this.config.skipCheckpointProposalValidation) {
|
|
574
|
+
this.log.warn(`Skipping checkpoint proposal validation for slot ${proposalSlotNumber}`, proposalInfo);
|
|
575
|
+
checkpointNumber = CheckpointNumber(0);
|
|
475
576
|
} else {
|
|
476
|
-
const validationResult = await this.
|
|
577
|
+
const validationResult = await this.proposalHandler.handleCheckpointProposal(proposal, proposalInfo);
|
|
477
578
|
if (!validationResult.isValid) {
|
|
478
579
|
this.log.warn(`Checkpoint proposal validation failed: ${validationResult.reason}`, proposalInfo);
|
|
479
580
|
return undefined;
|
|
480
581
|
}
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
// Upload blobs to filestore if we can (fire and forget)
|
|
484
|
-
if (this.blobClient.canUpload()) {
|
|
485
|
-
void this.uploadBlobsForCheckpoint(proposal, proposalInfo);
|
|
582
|
+
checkpointNumber = validationResult.checkpointNumber;
|
|
486
583
|
}
|
|
487
584
|
|
|
488
585
|
// Check that I have any address in current committee before attesting
|
|
@@ -493,14 +590,28 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
493
590
|
}
|
|
494
591
|
|
|
495
592
|
// Provided all of the above checks pass, we can attest to the proposal
|
|
496
|
-
this.log.info(
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
593
|
+
this.log.info(
|
|
594
|
+
`${partOfCommittee ? 'Attesting to' : 'Validated'} checkpoint proposal for slot ${proposalSlotNumber}`,
|
|
595
|
+
{
|
|
596
|
+
...proposalInfo,
|
|
597
|
+
inCommittee: partOfCommittee,
|
|
598
|
+
fishermanMode: this.config.fishermanMode || false,
|
|
599
|
+
},
|
|
600
|
+
);
|
|
501
601
|
|
|
502
602
|
this.metrics.incSuccessfulAttestations(inCommittee.length);
|
|
503
603
|
|
|
604
|
+
// Track epoch participation per attester: count each (attester, epoch) pair at most once
|
|
605
|
+
const proposalEpoch = getEpochAtSlot(proposalSlotNumber, this.epochCache.getL1Constants());
|
|
606
|
+
for (const attester of inCommittee) {
|
|
607
|
+
const key = attester.toString();
|
|
608
|
+
const lastEpoch = this.lastAttestedEpochByAttester.get(key);
|
|
609
|
+
if (lastEpoch === undefined || proposalEpoch > lastEpoch) {
|
|
610
|
+
this.lastAttestedEpochByAttester.set(key, proposalEpoch);
|
|
611
|
+
this.metrics.incAttestedEpochCount(attester);
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
|
|
504
615
|
// Determine which validators should attest
|
|
505
616
|
let attestors: EthAddress[];
|
|
506
617
|
if (partOfCommittee) {
|
|
@@ -519,169 +630,62 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
519
630
|
|
|
520
631
|
if (this.config.fishermanMode) {
|
|
521
632
|
// bail out early and don't save attestations to the pool in fisherman mode
|
|
522
|
-
this.log.info(`Creating checkpoint attestations for slot ${
|
|
633
|
+
this.log.info(`Creating checkpoint attestations for slot ${proposalSlotNumber}`, {
|
|
523
634
|
...proposalInfo,
|
|
524
635
|
attestors: attestors.map(a => a.toString()),
|
|
525
636
|
});
|
|
526
637
|
return undefined;
|
|
527
638
|
}
|
|
528
639
|
|
|
529
|
-
return this.createCheckpointAttestationsFromProposal(proposal, attestors);
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
private async createCheckpointAttestationsFromProposal(
|
|
533
|
-
proposal: CheckpointProposalCore,
|
|
534
|
-
attestors: EthAddress[] = [],
|
|
535
|
-
): Promise<CheckpointAttestation[]> {
|
|
536
|
-
const attestations = await this.validationService.attestToCheckpointProposal(proposal, attestors);
|
|
537
|
-
await this.p2pClient.addCheckpointAttestations(attestations);
|
|
538
|
-
return attestations;
|
|
640
|
+
return await this.createCheckpointAttestationsFromProposal(proposal, attestors, checkpointNumber);
|
|
539
641
|
}
|
|
540
642
|
|
|
541
643
|
/**
|
|
542
|
-
*
|
|
543
|
-
* @returns
|
|
644
|
+
* Checks if we should attest to a slot based on equivocation prevention rules.
|
|
645
|
+
* @returns true if we should attest, false if we should skip
|
|
544
646
|
*/
|
|
545
|
-
private
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
const timeoutSeconds = 10;
|
|
647
|
+
private shouldAttestToSlot(slotNumber: SlotNumber): boolean {
|
|
648
|
+
// If attestToEquivocatedProposals is true, always allow
|
|
649
|
+
if (this.config.attestToEquivocatedProposals) {
|
|
650
|
+
return true;
|
|
651
|
+
}
|
|
551
652
|
|
|
552
|
-
//
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
async () => {
|
|
557
|
-
await this.blockSource.syncImmediate();
|
|
558
|
-
return this.blockSource.getBlockHeaderByArchive(proposal.archive);
|
|
559
|
-
},
|
|
560
|
-
`waiting for block with archive ${proposal.archive.toString()} for slot ${slot}`,
|
|
561
|
-
timeoutSeconds,
|
|
562
|
-
0.5,
|
|
653
|
+
// Check if incoming slot is strictly greater than last attested
|
|
654
|
+
if (this.lastAttestedProposal && slotNumber <= this.lastAttestedProposal.slotNumber) {
|
|
655
|
+
this.log.warn(
|
|
656
|
+
`Refusing to process a proposal for slot ${slotNumber} given we already attested to a proposal for slot ${this.lastAttestedProposal.slotNumber}`,
|
|
563
657
|
);
|
|
564
|
-
|
|
565
|
-
if (err instanceof TimeoutError) {
|
|
566
|
-
this.log.warn(`Timed out waiting for block with archive matching checkpoint proposal`, proposalInfo);
|
|
567
|
-
return { isValid: false, reason: 'last_block_not_found' };
|
|
568
|
-
}
|
|
569
|
-
this.log.error(`Error fetching last block for checkpoint proposal`, err, proposalInfo);
|
|
570
|
-
return { isValid: false, reason: 'block_fetch_error' };
|
|
658
|
+
return false;
|
|
571
659
|
}
|
|
572
660
|
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
return { isValid: false, reason: 'last_block_not_found' };
|
|
576
|
-
}
|
|
661
|
+
return true;
|
|
662
|
+
}
|
|
577
663
|
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
664
|
+
private async createCheckpointAttestationsFromProposal(
|
|
665
|
+
proposal: CheckpointProposalCore,
|
|
666
|
+
attestors: EthAddress[] = [],
|
|
667
|
+
checkpointNumber: CheckpointNumber,
|
|
668
|
+
): Promise<CheckpointAttestation[] | undefined> {
|
|
669
|
+
// Equivocation check: must happen right before signing to minimize the race window
|
|
670
|
+
if (!this.shouldAttestToSlot(proposal.slotNumber)) {
|
|
671
|
+
return undefined;
|
|
583
672
|
}
|
|
584
673
|
|
|
585
|
-
this.
|
|
586
|
-
...proposalInfo,
|
|
587
|
-
blockNumbers: blocks.map(b => b.number),
|
|
588
|
-
});
|
|
589
|
-
|
|
590
|
-
// Get checkpoint constants from first block
|
|
591
|
-
const firstBlock = blocks[0];
|
|
592
|
-
const constants = this.extractCheckpointConstants(firstBlock);
|
|
593
|
-
const checkpointNumber = firstBlock.checkpointNumber;
|
|
594
|
-
|
|
595
|
-
// Get L1-to-L2 messages for this checkpoint
|
|
596
|
-
const l1ToL2Messages = await this.l1ToL2MessageSource.getL1ToL2Messages(checkpointNumber);
|
|
597
|
-
|
|
598
|
-
// Compute the previous checkpoint out hashes for the epoch.
|
|
599
|
-
// TODO: There can be a more efficient way to get the previous checkpoint out hashes without having to fetch the
|
|
600
|
-
// actual checkpoints and the blocks/txs in them.
|
|
601
|
-
const epoch = getEpochAtSlot(slot, this.epochCache.getL1Constants());
|
|
602
|
-
const previousCheckpoints = (await this.blockSource.getCheckpointsForEpoch(epoch))
|
|
603
|
-
.filter(b => b.number < checkpointNumber)
|
|
604
|
-
.sort((a, b) => a.number - b.number);
|
|
605
|
-
const previousCheckpointOutHashes = previousCheckpoints.map(c => c.getCheckpointOutHash());
|
|
606
|
-
|
|
607
|
-
// Fork world state at the block before the first block
|
|
608
|
-
const parentBlockNumber = BlockNumber(firstBlock.number - 1);
|
|
609
|
-
const fork = await this.worldState.fork(parentBlockNumber);
|
|
610
|
-
|
|
611
|
-
try {
|
|
612
|
-
// Create checkpoint builder with all existing blocks
|
|
613
|
-
const checkpointBuilder = await this.checkpointsBuilder.openCheckpoint(
|
|
614
|
-
checkpointNumber,
|
|
615
|
-
constants,
|
|
616
|
-
l1ToL2Messages,
|
|
617
|
-
previousCheckpointOutHashes,
|
|
618
|
-
fork,
|
|
619
|
-
blocks,
|
|
620
|
-
);
|
|
621
|
-
|
|
622
|
-
// Complete the checkpoint to get computed values
|
|
623
|
-
const computedCheckpoint = await checkpointBuilder.completeCheckpoint();
|
|
624
|
-
|
|
625
|
-
// Compare checkpoint header with proposal
|
|
626
|
-
if (!computedCheckpoint.header.equals(proposal.checkpointHeader)) {
|
|
627
|
-
this.log.warn(`Checkpoint header mismatch`, {
|
|
628
|
-
...proposalInfo,
|
|
629
|
-
computed: computedCheckpoint.header.toInspect(),
|
|
630
|
-
proposal: proposal.checkpointHeader.toInspect(),
|
|
631
|
-
});
|
|
632
|
-
return { isValid: false, reason: 'checkpoint_header_mismatch' };
|
|
633
|
-
}
|
|
634
|
-
|
|
635
|
-
// Compare archive root with proposal
|
|
636
|
-
if (!computedCheckpoint.archive.root.equals(proposal.archive)) {
|
|
637
|
-
this.log.warn(`Archive root mismatch`, {
|
|
638
|
-
...proposalInfo,
|
|
639
|
-
computed: computedCheckpoint.archive.root.toString(),
|
|
640
|
-
proposal: proposal.archive.toString(),
|
|
641
|
-
});
|
|
642
|
-
return { isValid: false, reason: 'archive_mismatch' };
|
|
643
|
-
}
|
|
644
|
-
|
|
645
|
-
// Check that the accumulated out hash matches the value in the proposal.
|
|
646
|
-
const computedOutHash = computedCheckpoint.getCheckpointOutHash();
|
|
647
|
-
const proposalOutHash = proposal.checkpointHeader.epochOutHash;
|
|
648
|
-
if (!computedOutHash.equals(proposalOutHash)) {
|
|
649
|
-
this.log.warn(`Epoch out hash mismatch`, {
|
|
650
|
-
proposalOutHash: proposalOutHash.toString(),
|
|
651
|
-
computedOutHash: computedOutHash.toString(),
|
|
652
|
-
...proposalInfo,
|
|
653
|
-
});
|
|
654
|
-
return { isValid: false, reason: 'out_hash_mismatch' };
|
|
655
|
-
}
|
|
674
|
+
const attestations = await this.validationService.attestToCheckpointProposal(proposal, attestors, checkpointNumber);
|
|
656
675
|
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
} finally {
|
|
660
|
-
await fork.close();
|
|
661
|
-
}
|
|
662
|
-
}
|
|
676
|
+
// Track the proposal we attested to (to prevent equivocation)
|
|
677
|
+
this.lastAttestedProposal = proposal;
|
|
663
678
|
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
*/
|
|
667
|
-
private extractCheckpointConstants(block: L2Block): CheckpointGlobalVariables {
|
|
668
|
-
const gv = block.header.globalVariables;
|
|
669
|
-
return {
|
|
670
|
-
chainId: gv.chainId,
|
|
671
|
-
version: gv.version,
|
|
672
|
-
slotNumber: gv.slotNumber,
|
|
673
|
-
coinbase: gv.coinbase,
|
|
674
|
-
feeRecipient: gv.feeRecipient,
|
|
675
|
-
gasFees: gv.gasFees,
|
|
676
|
-
};
|
|
679
|
+
await this.p2pClient.addOwnCheckpointAttestations(attestations);
|
|
680
|
+
return attestations;
|
|
677
681
|
}
|
|
678
682
|
|
|
679
683
|
/**
|
|
680
684
|
* Uploads blobs for a checkpoint to the filestore (fire and forget).
|
|
681
685
|
*/
|
|
682
|
-
|
|
686
|
+
protected async uploadBlobsForCheckpoint(proposal: CheckpointProposalCore, proposalInfo: LogData): Promise<void> {
|
|
683
687
|
try {
|
|
684
|
-
const lastBlockHeader = await this.blockSource.
|
|
688
|
+
const lastBlockHeader = (await this.blockSource.getBlockData({ archive: proposal.archive }))?.header;
|
|
685
689
|
if (!lastBlockHeader) {
|
|
686
690
|
this.log.warn(`Failed to get last block header for blob upload`, proposalInfo);
|
|
687
691
|
return;
|
|
@@ -694,7 +698,7 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
694
698
|
}
|
|
695
699
|
|
|
696
700
|
const blobFields = blocks.flatMap(b => b.toBlobFields());
|
|
697
|
-
const blobs: Blob[] = getBlobsPerL1Block(blobFields);
|
|
701
|
+
const blobs: Blob[] = await getBlobsPerL1Block(blobFields);
|
|
698
702
|
await this.blobClient.sendBlobsToFilestore(blobs);
|
|
699
703
|
this.log.debug(`Uploaded ${blobs.length} blobs to filestore for checkpoint at slot ${proposal.slotNumber}`, {
|
|
700
704
|
...proposalInfo,
|
|
@@ -714,12 +718,6 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
714
718
|
return;
|
|
715
719
|
}
|
|
716
720
|
|
|
717
|
-
// Trim the set if it's too big.
|
|
718
|
-
if (this.proposersOfInvalidBlocks.size > MAX_PROPOSERS_OF_INVALID_BLOCKS) {
|
|
719
|
-
// remove oldest proposer. `values` is guaranteed to be in insertion order.
|
|
720
|
-
this.proposersOfInvalidBlocks.delete(this.proposersOfInvalidBlocks.values().next().value!);
|
|
721
|
-
}
|
|
722
|
-
|
|
723
721
|
this.proposersOfInvalidBlocks.add(proposer.toString());
|
|
724
722
|
|
|
725
723
|
this.emit(WANT_TO_SLASH_EVENT, [
|
|
@@ -732,26 +730,219 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
732
730
|
]);
|
|
733
731
|
}
|
|
734
732
|
|
|
733
|
+
private handleInvalidCheckpointProposal(
|
|
734
|
+
proposal: CheckpointProposalCore,
|
|
735
|
+
result: CheckpointProposalValidationFailureResult,
|
|
736
|
+
proposalInfo: LogData,
|
|
737
|
+
): void {
|
|
738
|
+
if (!SLASHABLE_CHECKPOINT_PROPOSAL_VALIDATION_RESULT[result.reason]) {
|
|
739
|
+
return;
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
// The slot is already marked invalid by the all-nodes checkpoint handler that invokes this callback,
|
|
743
|
+
// so we only emit the proposer slash event here.
|
|
744
|
+
if (this.slashInvalidCheckpointProposal(proposal)) {
|
|
745
|
+
this.log.info(`Detected invalid checkpoint proposal offense`, {
|
|
746
|
+
...proposalInfo,
|
|
747
|
+
reason: result.reason,
|
|
748
|
+
amount: this.config.slashBroadcastedInvalidCheckpointProposalPenalty,
|
|
749
|
+
offenseType: getOffenseTypeName(OffenseType.BROADCASTED_INVALID_CHECKPOINT_PROPOSAL),
|
|
750
|
+
});
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
private slashInvalidCheckpointProposal(proposal: CheckpointProposalCore): boolean {
|
|
755
|
+
const proposer = proposal.getSender();
|
|
756
|
+
if (!proposer) {
|
|
757
|
+
this.log.warn(`Cannot slash checkpoint proposal with invalid signature`, {
|
|
758
|
+
slotNumber: proposal.slotNumber,
|
|
759
|
+
archive: proposal.archive.toString(),
|
|
760
|
+
});
|
|
761
|
+
return false;
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
const offenseType = OffenseType.BROADCASTED_INVALID_CHECKPOINT_PROPOSAL;
|
|
765
|
+
const offenseKey = `${proposer.toString()}:${offenseType}:${proposal.slotNumber}`;
|
|
766
|
+
if (!this.invalidCheckpointProposalOffenseKeys.addIfAbsent(offenseKey)) {
|
|
767
|
+
return false;
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
this.emit(WANT_TO_SLASH_EVENT, [
|
|
771
|
+
{
|
|
772
|
+
validator: proposer,
|
|
773
|
+
amount: this.config.slashBroadcastedInvalidCheckpointProposalPenalty,
|
|
774
|
+
offenseType,
|
|
775
|
+
epochOrSlot: BigInt(proposal.slotNumber),
|
|
776
|
+
},
|
|
777
|
+
]);
|
|
778
|
+
return true;
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
private markInvalidProposalSlot(slotNumber: SlotNumber): void {
|
|
782
|
+
this.proposalHandler.markInvalidProposalSlot(slotNumber);
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
private handleCheckpointAttestation(attestation: CheckpointAttestation): void {
|
|
786
|
+
const slotNumber = attestation.slotNumber;
|
|
787
|
+
if (
|
|
788
|
+
!this.proposalHandler.hasInvalidProposals(slotNumber) ||
|
|
789
|
+
this.proposalHandler.hasProposalEquivocation(slotNumber)
|
|
790
|
+
) {
|
|
791
|
+
return;
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
const attester = attestation.getSender();
|
|
795
|
+
if (!attester) {
|
|
796
|
+
this.log.warn(`Cannot slash checkpoint attestation with invalid signature`, {
|
|
797
|
+
slotNumber,
|
|
798
|
+
archive: attestation.archive.toString(),
|
|
799
|
+
});
|
|
800
|
+
return;
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
this.slashAttestedToInvalidCheckpointProposal(slotNumber, attester);
|
|
804
|
+
}
|
|
805
|
+
|
|
806
|
+
private slashAttestedToInvalidCheckpointProposal(slotNumber: SlotNumber, attester: EthAddress): void {
|
|
807
|
+
const offenseKey = `${attester.toString()}:${OffenseType.ATTESTED_TO_INVALID_CHECKPOINT_PROPOSAL}:${slotNumber}`;
|
|
808
|
+
if (!this.badAttestationOffenseKeys.addIfAbsent(offenseKey)) {
|
|
809
|
+
return;
|
|
810
|
+
}
|
|
811
|
+
|
|
812
|
+
this.log.info(`Detected attestation to invalid checkpoint proposal offense`, {
|
|
813
|
+
attester: attester.toString(),
|
|
814
|
+
slotNumber,
|
|
815
|
+
amount: this.config.slashAttestInvalidCheckpointProposalPenalty,
|
|
816
|
+
offenseType: getOffenseTypeName(OffenseType.ATTESTED_TO_INVALID_CHECKPOINT_PROPOSAL),
|
|
817
|
+
});
|
|
818
|
+
|
|
819
|
+
this.emit(WANT_TO_SLASH_EVENT, [
|
|
820
|
+
{
|
|
821
|
+
validator: attester,
|
|
822
|
+
amount: this.config.slashAttestInvalidCheckpointProposalPenalty,
|
|
823
|
+
offenseType: OffenseType.ATTESTED_TO_INVALID_CHECKPOINT_PROPOSAL,
|
|
824
|
+
epochOrSlot: BigInt(slotNumber),
|
|
825
|
+
},
|
|
826
|
+
]);
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
/**
|
|
830
|
+
* Handle detection of an oversized block proposal: one whose index within its checkpoint lands at or
|
|
831
|
+
* beyond the consensus per-checkpoint block limit. A single signed proposal at an illegal index is
|
|
832
|
+
* self-contained evidence, so emit an invalid-block-proposal slash event for the proposer, deduped per
|
|
833
|
+
* (proposer, slot) since the p2p layer reports every oversized proposal it stores.
|
|
834
|
+
*/
|
|
835
|
+
private handleOversizedProposal(info: OversizedProposalInfo): void {
|
|
836
|
+
const { slot, proposer } = info;
|
|
837
|
+
const offenseType = OffenseType.BROADCASTED_INVALID_BLOCK_PROPOSAL;
|
|
838
|
+
if (!this.oversizedProposalOffenseKeys.addIfAbsent(`${proposer.toString()}:${offenseType}:${slot}`)) {
|
|
839
|
+
return;
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
this.log.info(`Detected oversized block proposal offense from ${proposer.toString()} at slot ${slot}`, {
|
|
843
|
+
proposer: proposer.toString(),
|
|
844
|
+
slot,
|
|
845
|
+
amount: this.config.slashBroadcastedInvalidBlockPenalty,
|
|
846
|
+
offenseType: getOffenseTypeName(offenseType),
|
|
847
|
+
});
|
|
848
|
+
|
|
849
|
+
this.emit(WANT_TO_SLASH_EVENT, [
|
|
850
|
+
{
|
|
851
|
+
validator: proposer,
|
|
852
|
+
amount: this.config.slashBroadcastedInvalidBlockPenalty,
|
|
853
|
+
offenseType,
|
|
854
|
+
epochOrSlot: BigInt(slot),
|
|
855
|
+
},
|
|
856
|
+
]);
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
/**
|
|
860
|
+
* Handle detection of a duplicate proposal (equivocation).
|
|
861
|
+
* Emits a slash event when a proposer sends multiple proposals for the same position.
|
|
862
|
+
*/
|
|
863
|
+
private handleDuplicateProposal(info: DuplicateProposalInfo): void {
|
|
864
|
+
const { slot, proposer, type } = info;
|
|
865
|
+
this.proposalHandler.markProposalEquivocation(slot);
|
|
866
|
+
|
|
867
|
+
this.log.info(`Detected duplicate ${type} proposal offense from ${proposer.toString()} at slot ${slot}`, {
|
|
868
|
+
proposer: proposer.toString(),
|
|
869
|
+
slot,
|
|
870
|
+
type,
|
|
871
|
+
amount: this.config.slashDuplicateProposalPenalty,
|
|
872
|
+
offenseType: getOffenseTypeName(OffenseType.DUPLICATE_PROPOSAL),
|
|
873
|
+
});
|
|
874
|
+
|
|
875
|
+
this.emit(WANT_TO_SLASH_EVENT, [
|
|
876
|
+
{
|
|
877
|
+
validator: proposer,
|
|
878
|
+
amount: this.config.slashDuplicateProposalPenalty,
|
|
879
|
+
offenseType: OffenseType.DUPLICATE_PROPOSAL,
|
|
880
|
+
epochOrSlot: BigInt(slot),
|
|
881
|
+
},
|
|
882
|
+
]);
|
|
883
|
+
|
|
884
|
+
this.emit(WANT_TO_CLEAR_SLASH_EVENT, [
|
|
885
|
+
{
|
|
886
|
+
offenseType: OffenseType.ATTESTED_TO_INVALID_CHECKPOINT_PROPOSAL,
|
|
887
|
+
epochOrSlot: BigInt(slot),
|
|
888
|
+
},
|
|
889
|
+
]);
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
/**
|
|
893
|
+
* Handle detection of a duplicate attestation (equivocation).
|
|
894
|
+
* Emits a slash event when an attester signs attestations for different proposals at the same slot.
|
|
895
|
+
*/
|
|
896
|
+
private handleDuplicateAttestation(info: DuplicateAttestationInfo): void {
|
|
897
|
+
const { slot, attester } = info;
|
|
898
|
+
|
|
899
|
+
this.log.info(`Detected duplicate attestation offense from ${attester.toString()} at slot ${slot}`, {
|
|
900
|
+
attester: attester.toString(),
|
|
901
|
+
slot,
|
|
902
|
+
amount: this.config.slashDuplicateAttestationPenalty,
|
|
903
|
+
offenseType: getOffenseTypeName(OffenseType.DUPLICATE_ATTESTATION),
|
|
904
|
+
});
|
|
905
|
+
|
|
906
|
+
this.emit(WANT_TO_SLASH_EVENT, [
|
|
907
|
+
{
|
|
908
|
+
validator: attester,
|
|
909
|
+
amount: this.config.slashDuplicateAttestationPenalty,
|
|
910
|
+
offenseType: OffenseType.DUPLICATE_ATTESTATION,
|
|
911
|
+
epochOrSlot: BigInt(slot),
|
|
912
|
+
},
|
|
913
|
+
]);
|
|
914
|
+
}
|
|
915
|
+
|
|
735
916
|
async createBlockProposal(
|
|
736
917
|
blockHeader: BlockHeader,
|
|
918
|
+
checkpointNumber: CheckpointNumber,
|
|
737
919
|
indexWithinCheckpoint: IndexWithinCheckpoint,
|
|
738
920
|
inHash: Fr,
|
|
739
921
|
archive: Fr,
|
|
740
922
|
txs: Tx[],
|
|
741
923
|
proposerAddress: EthAddress | undefined,
|
|
742
|
-
options: BlockProposalOptions,
|
|
924
|
+
options: BlockProposalOptions = {},
|
|
743
925
|
): Promise<BlockProposal> {
|
|
744
|
-
//
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
926
|
+
// Validate that we're not creating a proposal for an older or equal position
|
|
927
|
+
if (this.lastProposedBlock) {
|
|
928
|
+
const lastSlot = this.lastProposedBlock.slotNumber;
|
|
929
|
+
const lastIndex = this.lastProposedBlock.indexWithinCheckpoint;
|
|
930
|
+
const newSlot = blockHeader.globalVariables.slotNumber;
|
|
931
|
+
|
|
932
|
+
if (newSlot < lastSlot || (newSlot === lastSlot && indexWithinCheckpoint <= lastIndex)) {
|
|
933
|
+
throw new Error(
|
|
934
|
+
`Cannot create block proposal for slot ${newSlot} index ${indexWithinCheckpoint}: ` +
|
|
935
|
+
`already proposed block for slot ${lastSlot} index ${lastIndex}`,
|
|
936
|
+
);
|
|
937
|
+
}
|
|
938
|
+
}
|
|
749
939
|
|
|
750
940
|
this.log.info(
|
|
751
941
|
`Assembling block proposal for block ${blockHeader.globalVariables.blockNumber} slot ${blockHeader.globalVariables.slotNumber}`,
|
|
752
942
|
);
|
|
753
943
|
const newProposal = await this.validationService.createBlockProposal(
|
|
754
944
|
blockHeader,
|
|
945
|
+
checkpointNumber,
|
|
755
946
|
indexWithinCheckpoint,
|
|
756
947
|
inHash,
|
|
757
948
|
archive,
|
|
@@ -759,28 +950,55 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
759
950
|
proposerAddress,
|
|
760
951
|
{
|
|
761
952
|
...options,
|
|
762
|
-
broadcastInvalidBlockProposal:
|
|
953
|
+
broadcastInvalidBlockProposal:
|
|
954
|
+
options.broadcastInvalidBlockProposal || this.config.broadcastInvalidBlockProposal,
|
|
763
955
|
},
|
|
764
956
|
);
|
|
765
|
-
this.
|
|
957
|
+
this.lastProposedBlock = newProposal;
|
|
766
958
|
return newProposal;
|
|
767
959
|
}
|
|
768
960
|
|
|
769
961
|
async createCheckpointProposal(
|
|
770
962
|
checkpointHeader: CheckpointHeader,
|
|
771
963
|
archive: Fr,
|
|
772
|
-
|
|
964
|
+
checkpointNumber: CheckpointNumber,
|
|
965
|
+
feeAssetPriceModifier: bigint,
|
|
966
|
+
lastBlockProposal: BlockProposal | undefined,
|
|
773
967
|
proposerAddress: EthAddress | undefined,
|
|
774
|
-
options: CheckpointProposalOptions,
|
|
968
|
+
options: CheckpointProposalOptions = {},
|
|
775
969
|
): Promise<CheckpointProposal> {
|
|
970
|
+
// Validate that we're not creating a proposal for an older or equal slot
|
|
971
|
+
if (this.lastProposedCheckpoint) {
|
|
972
|
+
const lastSlot = this.lastProposedCheckpoint.slotNumber;
|
|
973
|
+
const newSlot = checkpointHeader.slotNumber;
|
|
974
|
+
|
|
975
|
+
if (newSlot <= lastSlot) {
|
|
976
|
+
throw new Error(
|
|
977
|
+
`Cannot create checkpoint proposal for slot ${newSlot}: ` +
|
|
978
|
+
`already proposed checkpoint for slot ${lastSlot}`,
|
|
979
|
+
);
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
|
|
776
983
|
this.log.info(`Assembling checkpoint proposal for slot ${checkpointHeader.slotNumber}`);
|
|
777
|
-
|
|
984
|
+
const newProposal = await this.validationService.createCheckpointProposal(
|
|
778
985
|
checkpointHeader,
|
|
779
986
|
archive,
|
|
780
|
-
|
|
987
|
+
checkpointNumber,
|
|
988
|
+
feeAssetPriceModifier,
|
|
989
|
+
lastBlockProposal,
|
|
781
990
|
proposerAddress,
|
|
782
991
|
options,
|
|
783
992
|
);
|
|
993
|
+
this.lastProposedCheckpoint = newProposal;
|
|
994
|
+
// Self-record this slot's outcome on the re-execution tracker. Proposers don't run their
|
|
995
|
+
// own proposals through `handleCheckpointProposal`, so without this call the proposer's
|
|
996
|
+
// sentinel would see no outcome for slots it proposed and would mis-attribute itself as
|
|
997
|
+
// inactive. We pass the locally-computed `archive` (not `newProposal.archive`, which may
|
|
998
|
+
// be intentionally corrupted under test-only flags); from the proposer's local-view
|
|
999
|
+
// perspective the work it just completed is valid by definition.
|
|
1000
|
+
this.proposalHandler.recordOwnCheckpointProposalAsValid(checkpointHeader.slotNumber, archive, checkpointNumber);
|
|
1001
|
+
return newProposal;
|
|
784
1002
|
}
|
|
785
1003
|
|
|
786
1004
|
async broadcastBlockProposal(proposal: BlockProposal): Promise<void> {
|
|
@@ -791,16 +1009,28 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
791
1009
|
attestationsAndSigners: CommitteeAttestationsAndSigners,
|
|
792
1010
|
proposer: EthAddress,
|
|
793
1011
|
slot: SlotNumber,
|
|
794
|
-
|
|
1012
|
+
checkpointNumber: CheckpointNumber,
|
|
795
1013
|
): Promise<Signature> {
|
|
796
|
-
return await this.validationService.signAttestationsAndSigners(
|
|
1014
|
+
return await this.validationService.signAttestationsAndSigners(
|
|
1015
|
+
attestationsAndSigners,
|
|
1016
|
+
proposer,
|
|
1017
|
+
slot,
|
|
1018
|
+
checkpointNumber,
|
|
1019
|
+
);
|
|
797
1020
|
}
|
|
798
1021
|
|
|
799
|
-
async collectOwnAttestations(
|
|
1022
|
+
async collectOwnAttestations(
|
|
1023
|
+
proposal: CheckpointProposal,
|
|
1024
|
+
checkpointNumber: CheckpointNumber,
|
|
1025
|
+
): Promise<CheckpointAttestation[]> {
|
|
800
1026
|
const slot = proposal.slotNumber;
|
|
801
1027
|
const inCommittee = await this.epochCache.filterInCommittee(slot, this.getValidatorAddresses());
|
|
802
1028
|
this.log.debug(`Collecting ${inCommittee.length} self-attestations for slot ${slot}`, { inCommittee });
|
|
803
|
-
const attestations = await this.createCheckpointAttestationsFromProposal(proposal, inCommittee);
|
|
1029
|
+
const attestations = await this.createCheckpointAttestationsFromProposal(proposal, inCommittee, checkpointNumber);
|
|
1030
|
+
|
|
1031
|
+
if (!attestations) {
|
|
1032
|
+
return [];
|
|
1033
|
+
}
|
|
804
1034
|
|
|
805
1035
|
// We broadcast our own attestations to our peers so, in case our block does not get mined on L1,
|
|
806
1036
|
// other nodes can see that our validators did attest to this block proposal, and do not slash us
|
|
@@ -815,6 +1045,7 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
815
1045
|
proposal: CheckpointProposal,
|
|
816
1046
|
required: number,
|
|
817
1047
|
deadline: Date,
|
|
1048
|
+
checkpointNumber: CheckpointNumber,
|
|
818
1049
|
): Promise<CheckpointAttestation[]> {
|
|
819
1050
|
// Wait and poll the p2pClient's attestation pool for this checkpoint until we have enough attestations
|
|
820
1051
|
const slot = proposal.slotNumber;
|
|
@@ -827,33 +1058,23 @@ export class ValidatorClient extends (EventEmitter as new () => WatcherEmitter)
|
|
|
827
1058
|
throw new AttestationTimeoutError(0, required, slot);
|
|
828
1059
|
}
|
|
829
1060
|
|
|
830
|
-
await this.collectOwnAttestations(proposal);
|
|
1061
|
+
await this.collectOwnAttestations(proposal, checkpointNumber);
|
|
831
1062
|
|
|
832
|
-
const
|
|
1063
|
+
const proposalPayloadHash = proposal.getPayloadHash();
|
|
833
1064
|
const myAddresses = this.getValidatorAddresses();
|
|
834
1065
|
|
|
835
1066
|
let attestations: CheckpointAttestation[] = [];
|
|
836
1067
|
while (true) {
|
|
837
|
-
//
|
|
838
|
-
//
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
if (!attestation.archive.equals(proposal.archive)) {
|
|
842
|
-
this.log.warn(
|
|
843
|
-
`Received attestation for slot ${slot} with mismatched archive from ${attestation.getSender()?.toString()}`,
|
|
844
|
-
{ attestationArchive: attestation.archive.toString(), proposalArchive: proposal.archive.toString() },
|
|
845
|
-
);
|
|
846
|
-
return false;
|
|
847
|
-
}
|
|
848
|
-
return true;
|
|
849
|
-
},
|
|
850
|
-
);
|
|
1068
|
+
// The pool already filters by proposal payload hash; if any attestation slips through with a
|
|
1069
|
+
// mismatched payload hash, drop it defensively. Equivocations are emitted as separate slash
|
|
1070
|
+
// events from libp2p_service.
|
|
1071
|
+
const collectedAttestations = await this.p2pClient.getCheckpointAttestationsForSlot(slot, proposalPayloadHash);
|
|
851
1072
|
|
|
852
1073
|
// Log new attestations we collected
|
|
853
1074
|
const oldSenders = attestations.map(attestation => attestation.getSender());
|
|
854
1075
|
for (const collected of collectedAttestations) {
|
|
855
1076
|
const collectedSender = collected.getSender();
|
|
856
|
-
// Skip attestations with invalid signatures
|
|
1077
|
+
// Skip attestations with invalid signatures. Should not happen as we don't add invalid attestations to our pool.
|
|
857
1078
|
if (!collectedSender) {
|
|
858
1079
|
this.log.warn(`Skipping attestation with invalid signature for slot ${slot}`);
|
|
859
1080
|
continue;
|