@aztec/validator-client 0.0.1-commit.9d2bcf6d → 0.0.1-commit.9ee6fcc6
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 +62 -18
- package/dest/block_proposal_handler.d.ts +5 -4
- package/dest/block_proposal_handler.d.ts.map +1 -1
- package/dest/block_proposal_handler.js +130 -62
- package/dest/checkpoint_builder.d.ts +21 -8
- package/dest/checkpoint_builder.d.ts.map +1 -1
- package/dest/checkpoint_builder.js +124 -46
- package/dest/config.d.ts +1 -1
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +26 -1
- package/dest/duties/validation_service.d.ts +2 -2
- package/dest/duties/validation_service.d.ts.map +1 -1
- package/dest/duties/validation_service.js +6 -12
- package/dest/factory.d.ts +3 -1
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +3 -2
- package/dest/index.d.ts +1 -2
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +0 -1
- package/dest/key_store/ha_key_store.js +1 -1
- package/dest/metrics.d.ts +9 -1
- package/dest/metrics.d.ts.map +1 -1
- package/dest/metrics.js +12 -0
- package/dest/validator.d.ts +37 -10
- package/dest/validator.d.ts.map +1 -1
- package/dest/validator.js +214 -47
- package/package.json +19 -19
- package/src/block_proposal_handler.ts +157 -80
- package/src/checkpoint_builder.ts +142 -39
- package/src/config.ts +26 -1
- package/src/duties/validation_service.ts +12 -11
- package/src/factory.ts +4 -0
- package/src/index.ts +0 -1
- package/src/key_store/ha_key_store.ts +1 -1
- package/src/metrics.ts +18 -0
- package/src/validator.ts +276 -57
- 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 -19
- package/dest/tx_validator/tx_validator_factory.d.ts.map +0 -1
- package/dest/tx_validator/tx_validator_factory.js +0 -54
- 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 -154
package/dest/validator.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { BlockNumber, CheckpointNumber, IndexWithinCheckpoint, SlotNumber } from
|
|
|
4
4
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
5
5
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
6
6
|
import type { Signature } from '@aztec/foundation/eth-signature';
|
|
7
|
-
import { type Logger } from '@aztec/foundation/log';
|
|
7
|
+
import { type LogData, type Logger } from '@aztec/foundation/log';
|
|
8
8
|
import { DateProvider } from '@aztec/foundation/timer';
|
|
9
9
|
import type { KeystoreManager } from '@aztec/node-keystore';
|
|
10
10
|
import type { P2P, PeerId } from '@aztec/p2p';
|
|
@@ -13,12 +13,12 @@ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
|
13
13
|
import type { CommitteeAttestationsAndSigners, L2BlockSink, L2BlockSource } from '@aztec/stdlib/block';
|
|
14
14
|
import type { CreateCheckpointProposalLastBlockData, ITxProvider, Validator, ValidatorClientFullConfig, WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
|
|
15
15
|
import { type L1ToL2MessageSource } from '@aztec/stdlib/messaging';
|
|
16
|
-
import type
|
|
17
|
-
import { CheckpointProposal } from '@aztec/stdlib/p2p';
|
|
16
|
+
import { type BlockProposal, type BlockProposalOptions, type CheckpointAttestation, CheckpointProposal, type CheckpointProposalCore, type CheckpointProposalOptions } from '@aztec/stdlib/p2p';
|
|
18
17
|
import type { CheckpointHeader } from '@aztec/stdlib/rollup';
|
|
19
18
|
import type { BlockHeader, Tx } from '@aztec/stdlib/tx';
|
|
20
19
|
import { type TelemetryClient, type Tracer } from '@aztec/telemetry-client';
|
|
21
|
-
import { type SigningContext } from '@aztec/validator-ha-signer/types';
|
|
20
|
+
import { type SigningContext, type SlashingProtectionDatabase } from '@aztec/validator-ha-signer/types';
|
|
21
|
+
import type { ValidatorHASigner } from '@aztec/validator-ha-signer/validator-ha-signer';
|
|
22
22
|
import type { TypedDataDefinition } from 'viem';
|
|
23
23
|
import { BlockProposalHandler } from './block_proposal_handler.js';
|
|
24
24
|
import type { FullNodeCheckpointsBuilder } from './checkpoint_builder.js';
|
|
@@ -38,20 +38,28 @@ export declare class ValidatorClient extends ValidatorClient_base implements Val
|
|
|
38
38
|
private l1ToL2MessageSource;
|
|
39
39
|
private config;
|
|
40
40
|
private blobClient;
|
|
41
|
+
private slashingProtectionSigner;
|
|
41
42
|
private dateProvider;
|
|
42
43
|
readonly tracer: Tracer;
|
|
43
44
|
private validationService;
|
|
44
45
|
private metrics;
|
|
45
46
|
private log;
|
|
46
47
|
private hasRegisteredHandlers;
|
|
47
|
-
|
|
48
|
+
/** Tracks the last block proposal we created, to detect duplicate proposal attempts. */
|
|
49
|
+
private lastProposedBlock?;
|
|
50
|
+
/** Tracks the last checkpoint proposal we created. */
|
|
51
|
+
private lastProposedCheckpoint?;
|
|
48
52
|
private lastEpochForCommitteeUpdateLoop;
|
|
49
53
|
private epochCacheUpdateLoop;
|
|
54
|
+
/** Tracks the last epoch in which each attester successfully submitted at least one attestation. */
|
|
55
|
+
private lastAttestedEpochByAttester;
|
|
50
56
|
private proposersOfInvalidBlocks;
|
|
51
|
-
|
|
57
|
+
/** Tracks the last checkpoint proposal we attested to, to prevent equivocation. */
|
|
58
|
+
private lastAttestedProposal?;
|
|
59
|
+
protected constructor(keyStore: ExtendedValidatorKeyStore, epochCache: EpochCache, p2pClient: P2P, blockProposalHandler: BlockProposalHandler, blockSource: L2BlockSource, checkpointsBuilder: FullNodeCheckpointsBuilder, worldState: WorldStateSynchronizer, l1ToL2MessageSource: L1ToL2MessageSource, config: ValidatorClientFullConfig, blobClient: BlobClientInterface, slashingProtectionSigner: ValidatorHASigner, dateProvider?: DateProvider, telemetry?: TelemetryClient, log?: Logger);
|
|
52
60
|
static validateKeyStoreConfiguration(keyStoreManager: KeystoreManager, logger?: Logger): void;
|
|
53
61
|
private handleEpochCommitteeUpdate;
|
|
54
|
-
static new(config: ValidatorClientFullConfig, checkpointsBuilder: FullNodeCheckpointsBuilder, worldState: WorldStateSynchronizer, epochCache: EpochCache, p2pClient: P2P, blockSource: L2BlockSource & L2BlockSink, l1ToL2MessageSource: L1ToL2MessageSource, txProvider: ITxProvider, keyStoreManager: KeystoreManager, blobClient: BlobClientInterface, dateProvider?: DateProvider, telemetry?: TelemetryClient): Promise<ValidatorClient>;
|
|
62
|
+
static new(config: ValidatorClientFullConfig, checkpointsBuilder: FullNodeCheckpointsBuilder, worldState: WorldStateSynchronizer, epochCache: EpochCache, p2pClient: P2P, blockSource: L2BlockSource & L2BlockSink, l1ToL2MessageSource: L1ToL2MessageSource, txProvider: ITxProvider, keyStoreManager: KeystoreManager, blobClient: BlobClientInterface, dateProvider?: DateProvider, telemetry?: TelemetryClient, slashingProtectionDb?: SlashingProtectionDatabase): Promise<ValidatorClient>;
|
|
55
63
|
getValidatorAddresses(): EthAddress[];
|
|
56
64
|
getBlockProposalHandler(): BlockProposalHandler;
|
|
57
65
|
signWithAddress(addr: EthAddress, msg: TypedDataDefinition, context: SigningContext): Promise<Signature>;
|
|
@@ -59,6 +67,7 @@ export declare class ValidatorClient extends ValidatorClient_base implements Val
|
|
|
59
67
|
getFeeRecipientForAttestor(attestor: EthAddress): AztecAddress;
|
|
60
68
|
getConfig(): ValidatorClientFullConfig;
|
|
61
69
|
updateConfig(config: Partial<ValidatorClientFullConfig>): void;
|
|
70
|
+
reloadKeystore(newManager: KeystoreManager): void;
|
|
62
71
|
start(): Promise<void>;
|
|
63
72
|
stop(): Promise<void>;
|
|
64
73
|
/** Register handlers on the p2p client */
|
|
@@ -76,16 +85,34 @@ export declare class ValidatorClient extends ValidatorClient_base implements Val
|
|
|
76
85
|
* @returns Checkpoint attestations if valid, undefined otherwise
|
|
77
86
|
*/
|
|
78
87
|
attestToCheckpointProposal(proposal: CheckpointProposalCore, _proposalSender: PeerId): Promise<CheckpointAttestation[] | undefined>;
|
|
88
|
+
/**
|
|
89
|
+
* Checks if we should attest to a slot based on equivocation prevention rules.
|
|
90
|
+
* @returns true if we should attest, false if we should skip
|
|
91
|
+
*/
|
|
92
|
+
private shouldAttestToSlot;
|
|
79
93
|
private createCheckpointAttestationsFromProposal;
|
|
80
94
|
private validateCheckpointProposal;
|
|
81
95
|
/**
|
|
82
96
|
* Extract checkpoint global variables from a block.
|
|
83
97
|
*/
|
|
84
98
|
private extractCheckpointConstants;
|
|
85
|
-
|
|
99
|
+
/**
|
|
100
|
+
* Uploads blobs for a checkpoint to the filestore (fire and forget).
|
|
101
|
+
*/
|
|
102
|
+
protected uploadBlobsForCheckpoint(proposal: CheckpointProposalCore, proposalInfo: LogData): Promise<void>;
|
|
86
103
|
private slashInvalidBlock;
|
|
104
|
+
/**
|
|
105
|
+
* Handle detection of a duplicate proposal (equivocation).
|
|
106
|
+
* Emits a slash event when a proposer sends multiple proposals for the same position.
|
|
107
|
+
*/
|
|
108
|
+
private handleDuplicateProposal;
|
|
109
|
+
/**
|
|
110
|
+
* Handle detection of a duplicate attestation (equivocation).
|
|
111
|
+
* Emits a slash event when an attester signs attestations for different proposals at the same slot.
|
|
112
|
+
*/
|
|
113
|
+
private handleDuplicateAttestation;
|
|
87
114
|
createBlockProposal(blockHeader: BlockHeader, indexWithinCheckpoint: IndexWithinCheckpoint, inHash: Fr, archive: Fr, txs: Tx[], proposerAddress: EthAddress | undefined, options?: BlockProposalOptions): Promise<BlockProposal>;
|
|
88
|
-
createCheckpointProposal(checkpointHeader: CheckpointHeader, archive: Fr, lastBlockInfo: CreateCheckpointProposalLastBlockData | undefined, proposerAddress: EthAddress | undefined, options?: CheckpointProposalOptions): Promise<CheckpointProposal>;
|
|
115
|
+
createCheckpointProposal(checkpointHeader: CheckpointHeader, archive: Fr, feeAssetPriceModifier: bigint, lastBlockInfo: CreateCheckpointProposalLastBlockData | undefined, proposerAddress: EthAddress | undefined, options?: CheckpointProposalOptions): Promise<CheckpointProposal>;
|
|
89
116
|
broadcastBlockProposal(proposal: BlockProposal): Promise<void>;
|
|
90
117
|
signAttestationsAndSigners(attestationsAndSigners: CommitteeAttestationsAndSigners, proposer: EthAddress, slot: SlotNumber, blockNumber: BlockNumber | CheckpointNumber): Promise<Signature>;
|
|
91
118
|
collectOwnAttestations(proposal: CheckpointProposal): Promise<CheckpointAttestation[]>;
|
|
@@ -93,4 +120,4 @@ export declare class ValidatorClient extends ValidatorClient_base implements Val
|
|
|
93
120
|
private handleAuthRequest;
|
|
94
121
|
}
|
|
95
122
|
export {};
|
|
96
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
123
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidmFsaWRhdG9yLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvdmFsaWRhdG9yLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sS0FBSyxFQUFFLG1CQUFtQixFQUFFLE1BQU0sMkJBQTJCLENBQUM7QUFFckUsT0FBTyxLQUFLLEVBQUUsVUFBVSxFQUFFLE1BQU0sb0JBQW9CLENBQUM7QUFFckQsT0FBTyxFQUNMLFdBQVcsRUFDWCxnQkFBZ0IsRUFFaEIscUJBQXFCLEVBQ3JCLFVBQVUsRUFDWCxNQUFNLGlDQUFpQyxDQUFDO0FBQ3pDLE9BQU8sRUFBRSxFQUFFLEVBQUUsTUFBTSxnQ0FBZ0MsQ0FBQztBQUVwRCxPQUFPLEtBQUssRUFBRSxVQUFVLEVBQUUsTUFBTSwrQkFBK0IsQ0FBQztBQUNoRSxPQUFPLEtBQUssRUFBRSxTQUFTLEVBQUUsTUFBTSxpQ0FBaUMsQ0FBQztBQUNqRSxPQUFPLEVBQUUsS0FBSyxPQUFPLEV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xFQUN2QyxPQUFPLEdBQUUseUJBQThCLEdBQ3RDLE9BQU8sQ0FBQyxrQkFBa0IsQ0FBQyxDQXlCN0I7SUFFSyxzQkFBc0IsQ0FBQyxRQUFRLEVBQUUsYUFBYSxHQUFHLE9BQU8sQ0FBQyxJQUFJLENBQUMsQ0FFbkU7SUFFSywwQkFBMEIsQ0FDOUIsc0JBQXNCLEVBQUUsK0JBQStCLEVBQ3ZELFFBQVEsRUFBRSxVQUFVLEVBQ3BCLElBQUksRUFBRSxVQUFVLEVBQ2hCLFdBQVcsRUFBRSxXQUFXLEdBQUcsZ0JBQWdCLEdBQzFDLE9BQU8sQ0FBQyxTQUFTLENBQUMsQ0FFcEI7SUFFSyxzQkFBc0IsQ0FBQyxRQUFRLEVBQUUsa0JBQWtCLEdBQUcsT0FBTyxDQUFDLHFCQUFxQixFQUFFLENBQUMsQ0FpQjNGO0lBRUssbUJBQW1CLENBQ3ZCLFFBQVEsRUFBRSxrQkFBa0IsRUFDNUIsUUFBUSxFQUFFLE1BQU0sRUFDaEIsUUFBUSxFQUFFLElBQUksR0FDYixPQUFPLENBQUMscUJBQXFCLEVBQUUsQ0FBQyxDQWlFbEM7WUFFYSxpQkFBaUI7Q0F3QmhDIn0=
|
package/dest/validator.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../src/validator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAErE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../src/validator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAErE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAErD,OAAO,EACL,WAAW,EACX,gBAAgB,E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QAAQ,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAEnE;IAEK,0BAA0B,CAC9B,sBAAsB,EAAE,+BAA+B,EACvD,QAAQ,EAAE,UAAU,EACpB,IAAI,EAAE,UAAU,EAChB,WAAW,EAAE,WAAW,GAAG,gBAAgB,GAC1C,OAAO,CAAC,SAAS,CAAC,CAEpB;IAEK,sBAAsB,CAAC,QAAQ,EAAE,kBAAkB,GAAG,OAAO,CAAC,qBAAqB,EAAE,CAAC,CAiB3F;IAEK,mBAAmB,CACvB,QAAQ,EAAE,kBAAkB,EAC5B,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,IAAI,GACb,OAAO,CAAC,qBAAqB,EAAE,CAAC,CAiElC;YAEa,iBAAiB;CAwBhC"}
|
package/dest/validator.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { getBlobsPerL1Block } from '@aztec/blob-lib';
|
|
2
|
-
import {
|
|
2
|
+
import { validateFeeAssetPriceModifier } from '@aztec/ethereum/contracts';
|
|
3
|
+
import { BlockNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
3
4
|
import { TimeoutError } from '@aztec/foundation/error';
|
|
4
5
|
import { createLogger } from '@aztec/foundation/log';
|
|
5
6
|
import { retryUntil } from '@aztec/foundation/retry';
|
|
@@ -8,11 +9,12 @@ import { sleep } from '@aztec/foundation/sleep';
|
|
|
8
9
|
import { DateProvider } from '@aztec/foundation/timer';
|
|
9
10
|
import { AuthRequest, AuthResponse, BlockProposalValidator, ReqRespSubProtocol } from '@aztec/p2p';
|
|
10
11
|
import { OffenseType, WANT_TO_SLASH_EVENT } from '@aztec/slasher';
|
|
11
|
-
import {
|
|
12
|
+
import { validateCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
13
|
+
import { getEpochAtSlot, getTimestampForSlot } from '@aztec/stdlib/epoch-helpers';
|
|
12
14
|
import { accumulateCheckpointOutHashes } from '@aztec/stdlib/messaging';
|
|
13
15
|
import { AttestationTimeoutError } from '@aztec/stdlib/validators';
|
|
14
16
|
import { getTelemetryClient } from '@aztec/telemetry-client';
|
|
15
|
-
import { createHASigner } from '@aztec/validator-ha-signer/factory';
|
|
17
|
+
import { createHASigner, createLocalSignerWithProtection, createSignerFromSharedDb } from '@aztec/validator-ha-signer/factory';
|
|
16
18
|
import { DutyType } from '@aztec/validator-ha-signer/types';
|
|
17
19
|
import { EventEmitter } from 'events';
|
|
18
20
|
import { BlockProposalHandler } from './block_proposal_handler.js';
|
|
@@ -41,6 +43,7 @@ const SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT = [
|
|
|
41
43
|
l1ToL2MessageSource;
|
|
42
44
|
config;
|
|
43
45
|
blobClient;
|
|
46
|
+
slashingProtectionSigner;
|
|
44
47
|
dateProvider;
|
|
45
48
|
tracer;
|
|
46
49
|
validationService;
|
|
@@ -48,13 +51,15 @@ const SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT = [
|
|
|
48
51
|
log;
|
|
49
52
|
// Whether it has already registered handlers on the p2p client
|
|
50
53
|
hasRegisteredHandlers;
|
|
51
|
-
|
|
52
|
-
|
|
54
|
+
/** Tracks the last block proposal we created, to detect duplicate proposal attempts. */ lastProposedBlock;
|
|
55
|
+
/** Tracks the last checkpoint proposal we created. */ lastProposedCheckpoint;
|
|
53
56
|
lastEpochForCommitteeUpdateLoop;
|
|
54
57
|
epochCacheUpdateLoop;
|
|
58
|
+
/** Tracks the last epoch in which each attester successfully submitted at least one attestation. */ lastAttestedEpochByAttester;
|
|
55
59
|
proposersOfInvalidBlocks;
|
|
56
|
-
|
|
57
|
-
|
|
60
|
+
/** Tracks the last checkpoint proposal we attested to, to prevent equivocation. */ lastAttestedProposal;
|
|
61
|
+
constructor(keyStore, epochCache, p2pClient, blockProposalHandler, blockSource, checkpointsBuilder, worldState, l1ToL2MessageSource, config, blobClient, slashingProtectionSigner, dateProvider = new DateProvider(), telemetry = getTelemetryClient(), log = createLogger('validator')){
|
|
62
|
+
super(), this.keyStore = keyStore, this.epochCache = epochCache, this.p2pClient = p2pClient, this.blockProposalHandler = blockProposalHandler, this.blockSource = blockSource, this.checkpointsBuilder = checkpointsBuilder, this.worldState = worldState, this.l1ToL2MessageSource = l1ToL2MessageSource, this.config = config, this.blobClient = blobClient, this.slashingProtectionSigner = slashingProtectionSigner, this.dateProvider = dateProvider, this.hasRegisteredHandlers = false, this.lastAttestedEpochByAttester = new Map(), this.proposersOfInvalidBlocks = new Set();
|
|
58
63
|
// Create child logger with fisherman prefix if in fisherman mode
|
|
59
64
|
this.log = config.fishermanMode ? log.createChild('[FISHERMAN]') : log;
|
|
60
65
|
this.tracer = telemetry.getTracer('Validator');
|
|
@@ -93,6 +98,7 @@ const SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT = [
|
|
|
93
98
|
this.log.trace(`No committee found for slot`);
|
|
94
99
|
return;
|
|
95
100
|
}
|
|
101
|
+
this.metrics.setCurrentEpoch(epoch);
|
|
96
102
|
if (epoch !== this.lastEpochForCommitteeUpdateLoop) {
|
|
97
103
|
const me = this.getValidatorAddresses();
|
|
98
104
|
const committeeSet = new Set(committee.map((v)=>v.toString()));
|
|
@@ -108,23 +114,42 @@ const SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT = [
|
|
|
108
114
|
this.log.error(`Error updating epoch committee`, err);
|
|
109
115
|
}
|
|
110
116
|
}
|
|
111
|
-
static async new(config, checkpointsBuilder, worldState, epochCache, p2pClient, blockSource, l1ToL2MessageSource, txProvider, keyStoreManager, blobClient, dateProvider = new DateProvider(), telemetry = getTelemetryClient()) {
|
|
117
|
+
static async new(config, checkpointsBuilder, worldState, epochCache, p2pClient, blockSource, l1ToL2MessageSource, txProvider, keyStoreManager, blobClient, dateProvider = new DateProvider(), telemetry = getTelemetryClient(), slashingProtectionDb) {
|
|
112
118
|
const metrics = new ValidatorMetrics(telemetry);
|
|
113
119
|
const blockProposalValidator = new BlockProposalValidator(epochCache, {
|
|
114
|
-
txsPermitted: !config.disableTransactions
|
|
120
|
+
txsPermitted: !config.disableTransactions,
|
|
121
|
+
maxTxsPerBlock: config.validateMaxTxsPerBlock
|
|
115
122
|
});
|
|
116
123
|
const blockProposalHandler = new BlockProposalHandler(checkpointsBuilder, worldState, blockSource, l1ToL2MessageSource, txProvider, blockProposalValidator, epochCache, config, metrics, dateProvider, telemetry);
|
|
117
|
-
|
|
118
|
-
|
|
124
|
+
const nodeKeystoreAdapter = NodeKeystoreAdapter.fromKeyStoreManager(keyStoreManager);
|
|
125
|
+
let slashingProtectionSigner;
|
|
126
|
+
if (slashingProtectionDb) {
|
|
127
|
+
// Shared database mode: use a pre-existing database (e.g. for testing HA setups).
|
|
128
|
+
({ signer: slashingProtectionSigner } = createSignerFromSharedDb(slashingProtectionDb, config, {
|
|
129
|
+
telemetryClient: telemetry,
|
|
130
|
+
dateProvider
|
|
131
|
+
}));
|
|
132
|
+
} else if (config.haSigningEnabled) {
|
|
133
|
+
// Multi-node HA mode: use PostgreSQL-backed distributed locking.
|
|
119
134
|
// If maxStuckDutiesAgeMs is not explicitly set, compute it from Aztec slot duration
|
|
120
135
|
const haConfig = {
|
|
121
136
|
...config,
|
|
122
137
|
maxStuckDutiesAgeMs: config.maxStuckDutiesAgeMs ?? epochCache.getL1Constants().slotDuration * 2 * 1000
|
|
123
138
|
};
|
|
124
|
-
|
|
125
|
-
|
|
139
|
+
({ signer: slashingProtectionSigner } = await createHASigner(haConfig, {
|
|
140
|
+
telemetryClient: telemetry,
|
|
141
|
+
dateProvider
|
|
142
|
+
}));
|
|
143
|
+
} else {
|
|
144
|
+
// Single-node mode: use LMDB-backed local signing protection.
|
|
145
|
+
// This prevents double-signing if the node crashes and restarts mid-proposal.
|
|
146
|
+
({ signer: slashingProtectionSigner } = await createLocalSignerWithProtection(config, {
|
|
147
|
+
telemetryClient: telemetry,
|
|
148
|
+
dateProvider
|
|
149
|
+
}));
|
|
126
150
|
}
|
|
127
|
-
const
|
|
151
|
+
const validatorKeyStore = new HAKeyStore(nodeKeystoreAdapter, slashingProtectionSigner);
|
|
152
|
+
const validator = new ValidatorClient(validatorKeyStore, epochCache, p2pClient, blockProposalHandler, blockSource, checkpointsBuilder, worldState, l1ToL2MessageSource, config, blobClient, slashingProtectionSigner, dateProvider, telemetry);
|
|
128
153
|
return validator;
|
|
129
154
|
}
|
|
130
155
|
getValidatorAddresses() {
|
|
@@ -151,6 +176,11 @@ const SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT = [
|
|
|
151
176
|
...config
|
|
152
177
|
};
|
|
153
178
|
}
|
|
179
|
+
reloadKeystore(newManager) {
|
|
180
|
+
const newAdapter = NodeKeystoreAdapter.fromKeyStoreManager(newManager);
|
|
181
|
+
this.keyStore = new HAKeyStore(newAdapter, this.slashingProtectionSigner);
|
|
182
|
+
this.validationService = new ValidationService(this.keyStore, this.log.createChild('validation-service'));
|
|
183
|
+
}
|
|
154
184
|
async start() {
|
|
155
185
|
if (this.epochCacheUpdateLoop.isRunning()) {
|
|
156
186
|
this.log.warn(`Validator client already started`);
|
|
@@ -183,6 +213,14 @@ const SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT = [
|
|
|
183
213
|
// and processed separately via the block handler above.
|
|
184
214
|
const checkpointHandler = (checkpoint, proposalSender)=>this.attestToCheckpointProposal(checkpoint, proposalSender);
|
|
185
215
|
this.p2pClient.registerCheckpointProposalHandler(checkpointHandler);
|
|
216
|
+
// Duplicate proposal handler - triggers slashing for equivocation
|
|
217
|
+
this.p2pClient.registerDuplicateProposalCallback((info)=>{
|
|
218
|
+
this.handleDuplicateProposal(info);
|
|
219
|
+
});
|
|
220
|
+
// Duplicate attestation handler - triggers slashing for attestation equivocation
|
|
221
|
+
this.p2pClient.registerDuplicateAttestationCallback((info)=>{
|
|
222
|
+
this.handleDuplicateAttestation(info);
|
|
223
|
+
});
|
|
186
224
|
const myAddresses = this.getValidatorAddresses();
|
|
187
225
|
this.p2pClient.registerThisValidatorAddresses(myAddresses);
|
|
188
226
|
await this.p2pClient.addReqRespSubProtocol(ReqRespSubProtocol.AUTH, this.handleAuthRequest.bind(this));
|
|
@@ -203,6 +241,13 @@ const SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT = [
|
|
|
203
241
|
this.log.warn(`Received block proposal with invalid signature for slot ${slotNumber}`);
|
|
204
242
|
return false;
|
|
205
243
|
}
|
|
244
|
+
// Log self-proposals from HA peers (same validator key on different nodes)
|
|
245
|
+
if (this.getValidatorAddresses().some((addr)=>addr.equals(proposer))) {
|
|
246
|
+
this.log.verbose(`Processing block proposal from HA peer for slot ${slotNumber}`, {
|
|
247
|
+
proposer: proposer.toString(),
|
|
248
|
+
slotNumber
|
|
249
|
+
});
|
|
250
|
+
}
|
|
206
251
|
// Check if we're in the committee (for metrics purposes)
|
|
207
252
|
const inCommittee = await this.epochCache.filterInCommittee(slotNumber, this.getValidatorAddresses());
|
|
208
253
|
const partOfCommittee = inCommittee.length > 0;
|
|
@@ -221,8 +266,8 @@ const SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT = [
|
|
|
221
266
|
const shouldReexecute = fishermanMode || slashBroadcastedInvalidBlockPenalty > 0n && validatorReexecute || partOfCommittee && validatorReexecute || alwaysReexecuteBlockProposals || this.blobClient.canUpload();
|
|
222
267
|
const validationResult = await this.blockProposalHandler.handleBlockProposal(proposal, proposalSender, !!shouldReexecute && !escapeHatchOpen);
|
|
223
268
|
if (!validationResult.isValid) {
|
|
224
|
-
this.log.warn(`Block proposal validation failed: ${validationResult.reason}`, proposalInfo);
|
|
225
269
|
const reason = validationResult.reason || 'unknown';
|
|
270
|
+
this.log.warn(`Block proposal validation failed: ${reason}`, proposalInfo);
|
|
226
271
|
// Classify failure reason: bad proposal vs node issue
|
|
227
272
|
const badProposalReasons = [
|
|
228
273
|
'invalid_proposal',
|
|
@@ -262,35 +307,46 @@ const SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT = [
|
|
|
262
307
|
* the lastBlock is extracted and processed separately via the block handler.
|
|
263
308
|
* @returns Checkpoint attestations if valid, undefined otherwise
|
|
264
309
|
*/ async attestToCheckpointProposal(proposal, _proposalSender) {
|
|
265
|
-
const
|
|
310
|
+
const proposalSlotNumber = proposal.slotNumber;
|
|
266
311
|
const proposer = proposal.getSender();
|
|
267
312
|
// If escape hatch is open for this slot's epoch, do not attest.
|
|
268
|
-
if (await this.epochCache.isEscapeHatchOpenAtSlot(
|
|
269
|
-
this.log.warn(`Escape hatch open for slot ${
|
|
313
|
+
if (await this.epochCache.isEscapeHatchOpenAtSlot(proposalSlotNumber)) {
|
|
314
|
+
this.log.warn(`Escape hatch open for slot ${proposalSlotNumber}, skipping checkpoint attestation handling`);
|
|
270
315
|
return undefined;
|
|
271
316
|
}
|
|
272
317
|
// Reject proposals with invalid signatures
|
|
273
318
|
if (!proposer) {
|
|
274
|
-
this.log.warn(`Received checkpoint proposal with invalid signature for slot ${
|
|
319
|
+
this.log.warn(`Received checkpoint proposal with invalid signature for proposal slot ${proposalSlotNumber}`);
|
|
275
320
|
return undefined;
|
|
276
321
|
}
|
|
277
|
-
//
|
|
278
|
-
|
|
322
|
+
// Ignore proposals from ourselves (may happen in HA setups)
|
|
323
|
+
if (this.getValidatorAddresses().some((addr)=>addr.equals(proposer))) {
|
|
324
|
+
this.log.debug(`Ignoring block proposal from self for slot ${proposalSlotNumber}`, {
|
|
325
|
+
proposer: proposer.toString(),
|
|
326
|
+
proposalSlotNumber
|
|
327
|
+
});
|
|
328
|
+
return undefined;
|
|
329
|
+
}
|
|
330
|
+
// Validate fee asset price modifier is within allowed range
|
|
331
|
+
if (!validateFeeAssetPriceModifier(proposal.feeAssetPriceModifier)) {
|
|
332
|
+
this.log.warn(`Received checkpoint proposal with invalid feeAssetPriceModifier ${proposal.feeAssetPriceModifier} for slot ${proposalSlotNumber}`);
|
|
333
|
+
return undefined;
|
|
334
|
+
}
|
|
335
|
+
// Check that I have any address in the committee where this checkpoint will land before attesting
|
|
336
|
+
const inCommittee = await this.epochCache.filterInCommittee(proposalSlotNumber, this.getValidatorAddresses());
|
|
279
337
|
const partOfCommittee = inCommittee.length > 0;
|
|
280
338
|
const proposalInfo = {
|
|
281
|
-
|
|
339
|
+
proposalSlotNumber,
|
|
282
340
|
archive: proposal.archive.toString(),
|
|
283
|
-
proposer: proposer.toString()
|
|
284
|
-
txCount: proposal.txHashes.length
|
|
341
|
+
proposer: proposer.toString()
|
|
285
342
|
};
|
|
286
|
-
this.log.info(`Received checkpoint proposal for slot ${
|
|
343
|
+
this.log.info(`Received checkpoint proposal for slot ${proposalSlotNumber}`, {
|
|
287
344
|
...proposalInfo,
|
|
288
|
-
txHashes: proposal.txHashes.map((t)=>t.toString()),
|
|
289
345
|
fishermanMode: this.config.fishermanMode || false
|
|
290
346
|
});
|
|
291
347
|
// Validate the checkpoint proposal before attesting (unless skipCheckpointProposalValidation is set)
|
|
292
348
|
if (this.config.skipCheckpointProposalValidation) {
|
|
293
|
-
this.log.warn(`Skipping checkpoint proposal validation for slot ${
|
|
349
|
+
this.log.warn(`Skipping checkpoint proposal validation for slot ${proposalSlotNumber}`, proposalInfo);
|
|
294
350
|
} else {
|
|
295
351
|
const validationResult = await this.validateCheckpointProposal(proposal, proposalInfo);
|
|
296
352
|
if (!validationResult.isValid) {
|
|
@@ -309,12 +365,22 @@ const SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT = [
|
|
|
309
365
|
return undefined;
|
|
310
366
|
}
|
|
311
367
|
// Provided all of the above checks pass, we can attest to the proposal
|
|
312
|
-
this.log.info(`${partOfCommittee ? 'Attesting to' : 'Validated'} checkpoint proposal for slot ${
|
|
368
|
+
this.log.info(`${partOfCommittee ? 'Attesting to' : 'Validated'} checkpoint proposal for slot ${proposalSlotNumber}`, {
|
|
313
369
|
...proposalInfo,
|
|
314
370
|
inCommittee: partOfCommittee,
|
|
315
371
|
fishermanMode: this.config.fishermanMode || false
|
|
316
372
|
});
|
|
317
373
|
this.metrics.incSuccessfulAttestations(inCommittee.length);
|
|
374
|
+
// Track epoch participation per attester: count each (attester, epoch) pair at most once
|
|
375
|
+
const proposalEpoch = getEpochAtSlot(proposalSlotNumber, this.epochCache.getL1Constants());
|
|
376
|
+
for (const attester of inCommittee){
|
|
377
|
+
const key = attester.toString();
|
|
378
|
+
const lastEpoch = this.lastAttestedEpochByAttester.get(key);
|
|
379
|
+
if (lastEpoch === undefined || proposalEpoch > lastEpoch) {
|
|
380
|
+
this.lastAttestedEpochByAttester.set(key, proposalEpoch);
|
|
381
|
+
this.metrics.incAttestedEpochCount(attester);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
318
384
|
// Determine which validators should attest
|
|
319
385
|
let attestors;
|
|
320
386
|
if (partOfCommittee) {
|
|
@@ -331,17 +397,38 @@ const SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT = [
|
|
|
331
397
|
}
|
|
332
398
|
if (this.config.fishermanMode) {
|
|
333
399
|
// bail out early and don't save attestations to the pool in fisherman mode
|
|
334
|
-
this.log.info(`Creating checkpoint attestations for slot ${
|
|
400
|
+
this.log.info(`Creating checkpoint attestations for slot ${proposalSlotNumber}`, {
|
|
335
401
|
...proposalInfo,
|
|
336
402
|
attestors: attestors.map((a)=>a.toString())
|
|
337
403
|
});
|
|
338
404
|
return undefined;
|
|
339
405
|
}
|
|
340
|
-
return this.createCheckpointAttestationsFromProposal(proposal, attestors);
|
|
406
|
+
return await this.createCheckpointAttestationsFromProposal(proposal, attestors);
|
|
407
|
+
}
|
|
408
|
+
/**
|
|
409
|
+
* Checks if we should attest to a slot based on equivocation prevention rules.
|
|
410
|
+
* @returns true if we should attest, false if we should skip
|
|
411
|
+
*/ shouldAttestToSlot(slotNumber) {
|
|
412
|
+
// If attestToEquivocatedProposals is true, always allow
|
|
413
|
+
if (this.config.attestToEquivocatedProposals) {
|
|
414
|
+
return true;
|
|
415
|
+
}
|
|
416
|
+
// Check if incoming slot is strictly greater than last attested
|
|
417
|
+
if (this.lastAttestedProposal && slotNumber <= this.lastAttestedProposal.slotNumber) {
|
|
418
|
+
this.log.warn(`Refusing to process a proposal for slot ${slotNumber} given we already attested to a proposal for slot ${this.lastAttestedProposal.slotNumber}`);
|
|
419
|
+
return false;
|
|
420
|
+
}
|
|
421
|
+
return true;
|
|
341
422
|
}
|
|
342
423
|
async createCheckpointAttestationsFromProposal(proposal, attestors = []) {
|
|
424
|
+
// Equivocation check: must happen right before signing to minimize the race window
|
|
425
|
+
if (!this.shouldAttestToSlot(proposal.slotNumber)) {
|
|
426
|
+
return undefined;
|
|
427
|
+
}
|
|
343
428
|
const attestations = await this.validationService.attestToCheckpointProposal(proposal, attestors);
|
|
344
|
-
|
|
429
|
+
// Track the proposal we attested to (to prevent equivocation)
|
|
430
|
+
this.lastAttestedProposal = proposal;
|
|
431
|
+
await this.p2pClient.addOwnCheckpointAttestations(attestations);
|
|
345
432
|
return attestations;
|
|
346
433
|
}
|
|
347
434
|
/**
|
|
@@ -349,7 +436,10 @@ const SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT = [
|
|
|
349
436
|
* @returns Validation result with isValid flag and reason if invalid.
|
|
350
437
|
*/ async validateCheckpointProposal(proposal, proposalInfo) {
|
|
351
438
|
const slot = proposal.slotNumber;
|
|
352
|
-
|
|
439
|
+
// Timeout block syncing at the start of the next slot
|
|
440
|
+
const config = this.checkpointsBuilder.getConfig();
|
|
441
|
+
const nextSlotTimestampSeconds = Number(getTimestampForSlot(SlotNumber(slot + 1), config));
|
|
442
|
+
const timeoutSeconds = Math.max(1, nextSlotTimestampSeconds - Math.floor(this.dateProvider.now() / 1000));
|
|
353
443
|
// Wait for last block to sync by archive
|
|
354
444
|
let lastBlockHeader;
|
|
355
445
|
try {
|
|
@@ -387,6 +477,14 @@ const SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT = [
|
|
|
387
477
|
reason: 'no_blocks_for_slot'
|
|
388
478
|
};
|
|
389
479
|
}
|
|
480
|
+
// Ensure the last block for this slot matches the archive in the checkpoint proposal
|
|
481
|
+
if (!blocks.at(-1)?.archive.root.equals(proposal.archive)) {
|
|
482
|
+
this.log.warn(`Last block archive mismatch for checkpoint proposal`, proposalInfo);
|
|
483
|
+
return {
|
|
484
|
+
isValid: false,
|
|
485
|
+
reason: 'last_block_archive_mismatch'
|
|
486
|
+
};
|
|
487
|
+
}
|
|
390
488
|
this.log.debug(`Found ${blocks.length} blocks for slot ${slot}`, {
|
|
391
489
|
...proposalInfo,
|
|
392
490
|
blockNumbers: blocks.map((b)=>b.number)
|
|
@@ -397,18 +495,15 @@ const SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT = [
|
|
|
397
495
|
const checkpointNumber = firstBlock.checkpointNumber;
|
|
398
496
|
// Get L1-to-L2 messages for this checkpoint
|
|
399
497
|
const l1ToL2Messages = await this.l1ToL2MessageSource.getL1ToL2Messages(checkpointNumber);
|
|
400
|
-
//
|
|
401
|
-
// TODO: There can be a more efficient way to get the previous checkpoint out hashes without having to fetch the
|
|
402
|
-
// actual checkpoints and the blocks/txs in them.
|
|
498
|
+
// Collect the out hashes of all the checkpoints before this one in the same epoch
|
|
403
499
|
const epoch = getEpochAtSlot(slot, this.epochCache.getL1Constants());
|
|
404
|
-
const
|
|
405
|
-
const previousCheckpointOutHashes = previousCheckpoints.map((c)=>c.getCheckpointOutHash());
|
|
500
|
+
const previousCheckpointOutHashes = (await this.blockSource.getCheckpointsDataForEpoch(epoch)).filter((c)=>c.checkpointNumber < checkpointNumber).map((c)=>c.checkpointOutHash);
|
|
406
501
|
// Fork world state at the block before the first block
|
|
407
502
|
const parentBlockNumber = BlockNumber(firstBlock.number - 1);
|
|
408
503
|
const fork = await this.worldState.fork(parentBlockNumber);
|
|
409
504
|
try {
|
|
410
505
|
// Create checkpoint builder with all existing blocks
|
|
411
|
-
const checkpointBuilder = await this.checkpointsBuilder.openCheckpoint(checkpointNumber, constants, l1ToL2Messages, previousCheckpointOutHashes, fork, blocks, this.log.getBindings());
|
|
506
|
+
const checkpointBuilder = await this.checkpointsBuilder.openCheckpoint(checkpointNumber, constants, proposal.feeAssetPriceModifier, l1ToL2Messages, previousCheckpointOutHashes, fork, blocks, this.log.getBindings());
|
|
412
507
|
// Complete the checkpoint to get computed values
|
|
413
508
|
const computedCheckpoint = await checkpointBuilder.completeCheckpoint();
|
|
414
509
|
// Compare checkpoint header with proposal
|
|
@@ -456,6 +551,22 @@ const SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT = [
|
|
|
456
551
|
reason: 'out_hash_mismatch'
|
|
457
552
|
};
|
|
458
553
|
}
|
|
554
|
+
// Final round of validations on the checkpoint, just in case.
|
|
555
|
+
try {
|
|
556
|
+
validateCheckpoint(computedCheckpoint, {
|
|
557
|
+
rollupManaLimit: this.checkpointsBuilder.getConfig().rollupManaLimit,
|
|
558
|
+
maxDABlockGas: this.config.validateMaxDABlockGas,
|
|
559
|
+
maxL2BlockGas: this.config.validateMaxL2BlockGas,
|
|
560
|
+
maxTxsPerBlock: this.config.validateMaxTxsPerBlock,
|
|
561
|
+
maxTxsPerCheckpoint: this.config.validateMaxTxsPerCheckpoint
|
|
562
|
+
});
|
|
563
|
+
} catch (err) {
|
|
564
|
+
this.log.warn(`Checkpoint validation failed: ${err}`, proposalInfo);
|
|
565
|
+
return {
|
|
566
|
+
isValid: false,
|
|
567
|
+
reason: 'checkpoint_validation_failed'
|
|
568
|
+
};
|
|
569
|
+
}
|
|
459
570
|
this.log.verbose(`Checkpoint proposal validation successful for slot ${slot}`, proposalInfo);
|
|
460
571
|
return {
|
|
461
572
|
isValid: true
|
|
@@ -472,6 +583,7 @@ const SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT = [
|
|
|
472
583
|
chainId: gv.chainId,
|
|
473
584
|
version: gv.version,
|
|
474
585
|
slotNumber: gv.slotNumber,
|
|
586
|
+
timestamp: gv.timestamp,
|
|
475
587
|
coinbase: gv.coinbase,
|
|
476
588
|
feeRecipient: gv.feeRecipient,
|
|
477
589
|
gasFees: gv.gasFees
|
|
@@ -492,7 +604,7 @@ const SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT = [
|
|
|
492
604
|
return;
|
|
493
605
|
}
|
|
494
606
|
const blobFields = blocks.flatMap((b)=>b.toBlobFields());
|
|
495
|
-
const blobs = getBlobsPerL1Block(blobFields);
|
|
607
|
+
const blobs = await getBlobsPerL1Block(blobFields);
|
|
496
608
|
await this.blobClient.sendBlobsToFilestore(blobs);
|
|
497
609
|
this.log.debug(`Uploaded ${blobs.length} blobs to filestore for checkpoint at slot ${proposal.slotNumber}`, {
|
|
498
610
|
...proposalInfo,
|
|
@@ -524,23 +636,75 @@ const SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT = [
|
|
|
524
636
|
}
|
|
525
637
|
]);
|
|
526
638
|
}
|
|
639
|
+
/**
|
|
640
|
+
* Handle detection of a duplicate proposal (equivocation).
|
|
641
|
+
* Emits a slash event when a proposer sends multiple proposals for the same position.
|
|
642
|
+
*/ handleDuplicateProposal(info) {
|
|
643
|
+
const { slot, proposer, type } = info;
|
|
644
|
+
this.log.warn(`Triggering slash event for duplicate ${type} proposal from ${proposer.toString()} at slot ${slot}`, {
|
|
645
|
+
proposer: proposer.toString(),
|
|
646
|
+
slot,
|
|
647
|
+
type
|
|
648
|
+
});
|
|
649
|
+
// Emit slash event
|
|
650
|
+
this.emit(WANT_TO_SLASH_EVENT, [
|
|
651
|
+
{
|
|
652
|
+
validator: proposer,
|
|
653
|
+
amount: this.config.slashDuplicateProposalPenalty,
|
|
654
|
+
offenseType: OffenseType.DUPLICATE_PROPOSAL,
|
|
655
|
+
epochOrSlot: BigInt(slot)
|
|
656
|
+
}
|
|
657
|
+
]);
|
|
658
|
+
}
|
|
659
|
+
/**
|
|
660
|
+
* Handle detection of a duplicate attestation (equivocation).
|
|
661
|
+
* Emits a slash event when an attester signs attestations for different proposals at the same slot.
|
|
662
|
+
*/ handleDuplicateAttestation(info) {
|
|
663
|
+
const { slot, attester } = info;
|
|
664
|
+
this.log.warn(`Triggering slash event for duplicate attestation from ${attester.toString()} at slot ${slot}`, {
|
|
665
|
+
attester: attester.toString(),
|
|
666
|
+
slot
|
|
667
|
+
});
|
|
668
|
+
this.emit(WANT_TO_SLASH_EVENT, [
|
|
669
|
+
{
|
|
670
|
+
validator: attester,
|
|
671
|
+
amount: this.config.slashDuplicateAttestationPenalty,
|
|
672
|
+
offenseType: OffenseType.DUPLICATE_ATTESTATION,
|
|
673
|
+
epochOrSlot: BigInt(slot)
|
|
674
|
+
}
|
|
675
|
+
]);
|
|
676
|
+
}
|
|
527
677
|
async createBlockProposal(blockHeader, indexWithinCheckpoint, inHash, archive, txs, proposerAddress, options = {}) {
|
|
528
|
-
//
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
678
|
+
// Validate that we're not creating a proposal for an older or equal position
|
|
679
|
+
if (this.lastProposedBlock) {
|
|
680
|
+
const lastSlot = this.lastProposedBlock.slotNumber;
|
|
681
|
+
const lastIndex = this.lastProposedBlock.indexWithinCheckpoint;
|
|
682
|
+
const newSlot = blockHeader.globalVariables.slotNumber;
|
|
683
|
+
if (newSlot < lastSlot || newSlot === lastSlot && indexWithinCheckpoint <= lastIndex) {
|
|
684
|
+
throw new Error(`Cannot create block proposal for slot ${newSlot} index ${indexWithinCheckpoint}: ` + `already proposed block for slot ${lastSlot} index ${lastIndex}`);
|
|
685
|
+
}
|
|
686
|
+
}
|
|
533
687
|
this.log.info(`Assembling block proposal for block ${blockHeader.globalVariables.blockNumber} slot ${blockHeader.globalVariables.slotNumber}`);
|
|
534
688
|
const newProposal = await this.validationService.createBlockProposal(blockHeader, indexWithinCheckpoint, inHash, archive, txs, proposerAddress, {
|
|
535
689
|
...options,
|
|
536
690
|
broadcastInvalidBlockProposal: this.config.broadcastInvalidBlockProposal
|
|
537
691
|
});
|
|
538
|
-
this.
|
|
692
|
+
this.lastProposedBlock = newProposal;
|
|
539
693
|
return newProposal;
|
|
540
694
|
}
|
|
541
|
-
async createCheckpointProposal(checkpointHeader, archive, lastBlockInfo, proposerAddress, options = {}) {
|
|
695
|
+
async createCheckpointProposal(checkpointHeader, archive, feeAssetPriceModifier, lastBlockInfo, proposerAddress, options = {}) {
|
|
696
|
+
// Validate that we're not creating a proposal for an older or equal slot
|
|
697
|
+
if (this.lastProposedCheckpoint) {
|
|
698
|
+
const lastSlot = this.lastProposedCheckpoint.slotNumber;
|
|
699
|
+
const newSlot = checkpointHeader.slotNumber;
|
|
700
|
+
if (newSlot <= lastSlot) {
|
|
701
|
+
throw new Error(`Cannot create checkpoint proposal for slot ${newSlot}: ` + `already proposed checkpoint for slot ${lastSlot}`);
|
|
702
|
+
}
|
|
703
|
+
}
|
|
542
704
|
this.log.info(`Assembling checkpoint proposal for slot ${checkpointHeader.slotNumber}`);
|
|
543
|
-
|
|
705
|
+
const newProposal = await this.validationService.createCheckpointProposal(checkpointHeader, archive, feeAssetPriceModifier, lastBlockInfo, proposerAddress, options);
|
|
706
|
+
this.lastProposedCheckpoint = newProposal;
|
|
707
|
+
return newProposal;
|
|
544
708
|
}
|
|
545
709
|
async broadcastBlockProposal(proposal) {
|
|
546
710
|
await this.p2pClient.broadcastProposal(proposal);
|
|
@@ -555,6 +719,9 @@ const SLASHABLE_BLOCK_PROPOSAL_VALIDATION_RESULT = [
|
|
|
555
719
|
inCommittee
|
|
556
720
|
});
|
|
557
721
|
const attestations = await this.createCheckpointAttestationsFromProposal(proposal, inCommittee);
|
|
722
|
+
if (!attestations) {
|
|
723
|
+
return [];
|
|
724
|
+
}
|
|
558
725
|
// We broadcast our own attestations to our peers so, in case our block does not get mined on L1,
|
|
559
726
|
// other nodes can see that our validators did attest to this block proposal, and do not slash us
|
|
560
727
|
// due to inactivity for missed attestations.
|