@aztec/validator-client 0.0.1-commit.2ed92850 → 0.0.1-commit.2f68f620
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 +61 -18
- package/dest/checkpoint_builder.d.ts +26 -14
- package/dest/checkpoint_builder.d.ts.map +1 -1
- package/dest/checkpoint_builder.js +136 -45
- package/dest/config.d.ts +1 -1
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +39 -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 +11 -5
- 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/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 +134 -0
- package/dest/proposal_handler.d.ts.map +1 -0
- package/dest/proposal_handler.js +1072 -0
- package/dest/validator.d.ts +58 -24
- package/dest/validator.d.ts.map +1 -1
- package/dest/validator.js +363 -235
- package/package.json +19 -17
- package/src/checkpoint_builder.ts +183 -50
- package/src/config.ts +39 -9
- package/src/duties/validation_service.ts +59 -54
- package/src/factory.ts +20 -3
- package/src/index.ts +1 -2
- package/src/key_store/ha_key_store.ts +3 -3
- package/src/metrics.ts +81 -6
- package/src/proposal_handler.ts +1161 -0
- package/src/validator.ts +490 -284
- 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
|
@@ -1,17 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
BlockNumber,
|
|
3
|
-
type CheckpointNumber,
|
|
4
|
-
IndexWithinCheckpoint,
|
|
5
|
-
type SlotNumber,
|
|
6
|
-
} from '@aztec/foundation/branded-types';
|
|
7
|
-
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
8
|
-
import { keccak256 } from '@aztec/foundation/crypto/keccak';
|
|
1
|
+
import { type CheckpointNumber, IndexWithinCheckpoint, type SlotNumber } from '@aztec/foundation/branded-types';
|
|
9
2
|
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
10
3
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
11
4
|
import type { Signature } from '@aztec/foundation/eth-signature';
|
|
12
5
|
import { createLogger } from '@aztec/foundation/log';
|
|
13
|
-
import
|
|
14
|
-
import type { CreateCheckpointProposalLastBlockData } from '@aztec/stdlib/interfaces/server';
|
|
6
|
+
import { CommitteeAttestationsAndSigners } from '@aztec/stdlib/block';
|
|
15
7
|
import {
|
|
16
8
|
BlockProposal,
|
|
17
9
|
type BlockProposalOptions,
|
|
@@ -20,9 +12,10 @@ import {
|
|
|
20
12
|
type CheckpointProposalCore,
|
|
21
13
|
type CheckpointProposalOptions,
|
|
22
14
|
ConsensusPayload,
|
|
23
|
-
|
|
15
|
+
type CoordinationSignatureContext,
|
|
16
|
+
getCoordinationSignatureTypedData,
|
|
24
17
|
} from '@aztec/stdlib/p2p';
|
|
25
|
-
import
|
|
18
|
+
import { CheckpointHeader } from '@aztec/stdlib/rollup';
|
|
26
19
|
import type { BlockHeader, Tx } from '@aztec/stdlib/tx';
|
|
27
20
|
import { DutyAlreadySignedError, SlashingProtectionError } from '@aztec/validator-ha-signer/errors';
|
|
28
21
|
import { DutyType, type SigningContext } from '@aztec/validator-ha-signer/types';
|
|
@@ -32,6 +25,7 @@ import type { ValidatorKeyStore } from '../key_store/interface.js';
|
|
|
32
25
|
export class ValidationService {
|
|
33
26
|
constructor(
|
|
34
27
|
private keyStore: ValidatorKeyStore,
|
|
28
|
+
private signatureContext: CoordinationSignatureContext,
|
|
35
29
|
private log = createLogger('validator:validation-service'),
|
|
36
30
|
) {}
|
|
37
31
|
|
|
@@ -52,6 +46,7 @@ export class ValidationService {
|
|
|
52
46
|
*/
|
|
53
47
|
public createBlockProposal(
|
|
54
48
|
blockHeader: BlockHeader,
|
|
49
|
+
checkpointNumber: CheckpointNumber,
|
|
55
50
|
blockIndexWithinCheckpoint: IndexWithinCheckpoint,
|
|
56
51
|
inHash: Fr,
|
|
57
52
|
archive: Fr,
|
|
@@ -67,17 +62,26 @@ export class ValidationService {
|
|
|
67
62
|
|
|
68
63
|
// Create a signer that uses the appropriate address
|
|
69
64
|
const address = proposerAttesterAddress ?? this.keyStore.getAddress(0);
|
|
70
|
-
const payloadSigner = (
|
|
71
|
-
|
|
65
|
+
const payloadSigner = (
|
|
66
|
+
typedData: Parameters<ValidatorKeyStore['signTypedDataWithAddress']>[1],
|
|
67
|
+
context: SigningContext,
|
|
68
|
+
) => this.keyStore.signTypedDataWithAddress(address, typedData, context);
|
|
69
|
+
const txsSigner = (
|
|
70
|
+
typedData: Parameters<ValidatorKeyStore['signTypedDataWithAddress']>[1],
|
|
71
|
+
context: SigningContext,
|
|
72
|
+
) => this.keyStore.signTypedDataWithAddress(address, typedData, context);
|
|
72
73
|
|
|
73
74
|
return BlockProposal.createProposalFromSigner(
|
|
74
75
|
blockHeader,
|
|
76
|
+
checkpointNumber,
|
|
75
77
|
blockIndexWithinCheckpoint,
|
|
76
78
|
inHash,
|
|
77
79
|
archive,
|
|
78
80
|
txs.map(tx => tx.getTxHash()),
|
|
79
81
|
options.publishFullTxs ? txs : undefined,
|
|
82
|
+
this.signatureContext,
|
|
80
83
|
payloadSigner,
|
|
84
|
+
txsSigner,
|
|
81
85
|
);
|
|
82
86
|
}
|
|
83
87
|
|
|
@@ -86,7 +90,7 @@ export class ValidationService {
|
|
|
86
90
|
*
|
|
87
91
|
* @param checkpointHeader - The checkpoint header containing aggregated data
|
|
88
92
|
* @param archive - The archive of the checkpoint
|
|
89
|
-
* @param
|
|
93
|
+
* @param lastBlockProposal - Signed block proposal for the last block in the checkpoint, or undefined
|
|
90
94
|
* @param proposerAttesterAddress - The address of the proposer
|
|
91
95
|
* @param options - Checkpoint proposal options
|
|
92
96
|
*
|
|
@@ -95,31 +99,43 @@ export class ValidationService {
|
|
|
95
99
|
public createCheckpointProposal(
|
|
96
100
|
checkpointHeader: CheckpointHeader,
|
|
97
101
|
archive: Fr,
|
|
98
|
-
|
|
102
|
+
checkpointNumber: CheckpointNumber,
|
|
103
|
+
feeAssetPriceModifier: bigint,
|
|
104
|
+
lastBlockProposal: BlockProposal | undefined,
|
|
99
105
|
proposerAttesterAddress: EthAddress | undefined,
|
|
100
106
|
options: CheckpointProposalOptions,
|
|
101
107
|
): Promise<CheckpointProposal> {
|
|
102
|
-
// For testing:
|
|
108
|
+
// For testing: corrupt the checkpoint so observers' checkpoint validation fails.
|
|
109
|
+
//
|
|
110
|
+
// Keep `archive` aligned with `lastBlockProposal.archiveRoot` so the archive-based lookup
|
|
111
|
+
// in `validateCheckpointProposal` (`getBlockData({ archive })`) still succeeds
|
|
103
112
|
if (options.broadcastInvalidCheckpointProposal) {
|
|
104
|
-
archive = Fr.random();
|
|
113
|
+
archive = lastBlockProposal?.archiveRoot ?? Fr.random();
|
|
114
|
+
checkpointHeader = CheckpointHeader.from({
|
|
115
|
+
...checkpointHeader,
|
|
116
|
+
epochOutHash: Fr.random(),
|
|
117
|
+
});
|
|
105
118
|
this.log.warn(`Creating INVALID checkpoint proposal for slot ${checkpointHeader.slotNumber}`);
|
|
106
119
|
}
|
|
107
120
|
|
|
108
121
|
// Create a signer that takes payload and context, and uses the appropriate address
|
|
109
|
-
const payloadSigner = (
|
|
122
|
+
const payloadSigner = (
|
|
123
|
+
typedData: Parameters<ValidatorKeyStore['signTypedDataWithAddress']>[1],
|
|
124
|
+
context: SigningContext,
|
|
125
|
+
) => {
|
|
110
126
|
const address = proposerAttesterAddress ?? this.keyStore.getAddress(0);
|
|
111
|
-
return this.keyStore.
|
|
127
|
+
return this.keyStore.signTypedDataWithAddress(address, typedData, context);
|
|
112
128
|
};
|
|
113
129
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
130
|
+
return CheckpointProposal.createProposalFromSigner(
|
|
131
|
+
checkpointHeader,
|
|
132
|
+
archive,
|
|
133
|
+
checkpointNumber,
|
|
134
|
+
feeAssetPriceModifier,
|
|
135
|
+
lastBlockProposal,
|
|
136
|
+
this.signatureContext,
|
|
137
|
+
payloadSigner,
|
|
138
|
+
);
|
|
123
139
|
}
|
|
124
140
|
|
|
125
141
|
/**
|
|
@@ -135,35 +151,27 @@ export class ValidationService {
|
|
|
135
151
|
async attestToCheckpointProposal(
|
|
136
152
|
proposal: CheckpointProposalCore,
|
|
137
153
|
attestors: EthAddress[],
|
|
154
|
+
checkpointNumber: CheckpointNumber,
|
|
138
155
|
): Promise<CheckpointAttestation[]> {
|
|
139
156
|
// Create the attestation payload from the checkpoint proposal
|
|
140
|
-
const payload = new ConsensusPayload(
|
|
141
|
-
|
|
142
|
-
|
|
157
|
+
const payload = new ConsensusPayload(
|
|
158
|
+
proposal.checkpointHeader,
|
|
159
|
+
proposal.archive,
|
|
160
|
+
proposal.feeAssetPriceModifier,
|
|
161
|
+
this.signatureContext,
|
|
143
162
|
);
|
|
163
|
+
const typedData = getCoordinationSignatureTypedData(payload);
|
|
144
164
|
|
|
145
|
-
// TODO(spy/ha): Use checkpointNumber instead of blockNumber once CheckpointHeader includes it.
|
|
146
|
-
// Currently using lastBlock.blockNumber as a proxy for checkpoint identification in HA signing.
|
|
147
|
-
// blockNumber is NOT used for the primary key so it's safe to use here.
|
|
148
|
-
// See CheckpointHeader TODO and SigningContext types documentation.
|
|
149
|
-
let blockNumber: BlockNumber;
|
|
150
|
-
try {
|
|
151
|
-
blockNumber = proposal.blockNumber;
|
|
152
|
-
} catch {
|
|
153
|
-
// Checkpoint proposal may not have lastBlock, use 0 as fallback
|
|
154
|
-
blockNumber = BlockNumber(0);
|
|
155
|
-
}
|
|
156
165
|
const context: SigningContext = {
|
|
157
166
|
slot: proposal.slotNumber,
|
|
158
|
-
|
|
167
|
+
checkpointNumber,
|
|
159
168
|
dutyType: DutyType.ATTESTATION,
|
|
160
169
|
};
|
|
161
170
|
|
|
162
171
|
// Sign each attestor in parallel, catching HA errors per-attestor
|
|
163
172
|
const results = await Promise.allSettled(
|
|
164
173
|
attestors.map(async attestor => {
|
|
165
|
-
const sig = await this.keyStore.
|
|
166
|
-
// return new BlockAttestation(proposal.payload, sig, proposal.signature);
|
|
174
|
+
const sig = await this.keyStore.signTypedDataWithAddress(attestor, typedData, context);
|
|
167
175
|
return new CheckpointAttestation(payload, sig, proposal.signature);
|
|
168
176
|
}),
|
|
169
177
|
);
|
|
@@ -176,7 +184,7 @@ export class ValidationService {
|
|
|
176
184
|
} else {
|
|
177
185
|
const error = result.reason;
|
|
178
186
|
if (error instanceof DutyAlreadySignedError || error instanceof SlashingProtectionError) {
|
|
179
|
-
this.log.
|
|
187
|
+
this.log.verbose(
|
|
180
188
|
`Attestation for slot ${proposal.slotNumber} by ${attestors[i]} already signed by another High-Availability node`,
|
|
181
189
|
);
|
|
182
190
|
// Continue with remaining attestors
|
|
@@ -194,7 +202,6 @@ export class ValidationService {
|
|
|
194
202
|
* @param attestationsAndSigners - The attestations and signers to sign
|
|
195
203
|
* @param proposer - The proposer address to sign with
|
|
196
204
|
* @param slot - The slot number for HA signing context
|
|
197
|
-
* @param blockNumber - The block or checkpoint number for HA signing context
|
|
198
205
|
* @returns signature
|
|
199
206
|
* @throws DutyAlreadySignedError if already signed by another HA node
|
|
200
207
|
* @throws SlashingProtectionError if attempting to sign different data for same slot
|
|
@@ -203,17 +210,15 @@ export class ValidationService {
|
|
|
203
210
|
attestationsAndSigners: CommitteeAttestationsAndSigners,
|
|
204
211
|
proposer: EthAddress,
|
|
205
212
|
slot: SlotNumber,
|
|
206
|
-
|
|
213
|
+
checkpointNumber: CheckpointNumber,
|
|
207
214
|
): Promise<Signature> {
|
|
208
215
|
const context: SigningContext = {
|
|
209
216
|
slot,
|
|
210
|
-
|
|
217
|
+
checkpointNumber,
|
|
211
218
|
dutyType: DutyType.ATTESTATIONS_AND_SIGNERS,
|
|
212
219
|
};
|
|
213
220
|
|
|
214
|
-
const
|
|
215
|
-
|
|
216
|
-
);
|
|
217
|
-
return this.keyStore.signMessageWithAddress(proposer, buf, context);
|
|
221
|
+
const typedData = getCoordinationSignatureTypedData(attestationsAndSigners);
|
|
222
|
+
return this.keyStore.signTypedDataWithAddress(proposer, typedData, context);
|
|
218
223
|
}
|
|
219
224
|
}
|
package/src/factory.ts
CHANGED
|
@@ -4,16 +4,18 @@ import type { DateProvider } from '@aztec/foundation/timer';
|
|
|
4
4
|
import type { KeystoreManager } from '@aztec/node-keystore';
|
|
5
5
|
import { BlockProposalValidator, type P2PClient } from '@aztec/p2p';
|
|
6
6
|
import type { L2BlockSink, L2BlockSource } from '@aztec/stdlib/block';
|
|
7
|
+
import type { CheckpointReexecutionTracker } from '@aztec/stdlib/checkpoint';
|
|
7
8
|
import type { ValidatorClientFullConfig, WorldStateSynchronizer } from '@aztec/stdlib/interfaces/server';
|
|
8
9
|
import type { L1ToL2MessageSource } from '@aztec/stdlib/messaging';
|
|
9
10
|
import type { TelemetryClient } from '@aztec/telemetry-client';
|
|
11
|
+
import type { SlashingProtectionDatabase } from '@aztec/validator-ha-signer/types';
|
|
10
12
|
|
|
11
|
-
import { BlockProposalHandler } from './block_proposal_handler.js';
|
|
12
13
|
import type { FullNodeCheckpointsBuilder } from './checkpoint_builder.js';
|
|
13
14
|
import { ValidatorMetrics } from './metrics.js';
|
|
15
|
+
import { ProposalHandler } from './proposal_handler.js';
|
|
14
16
|
import { ValidatorClient } from './validator.js';
|
|
15
17
|
|
|
16
|
-
export function
|
|
18
|
+
export function createProposalHandler(
|
|
17
19
|
config: ValidatorClientFullConfig,
|
|
18
20
|
deps: {
|
|
19
21
|
checkpointsBuilder: FullNodeCheckpointsBuilder;
|
|
@@ -22,15 +24,23 @@ export function createBlockProposalHandler(
|
|
|
22
24
|
l1ToL2MessageSource: L1ToL2MessageSource;
|
|
23
25
|
p2pClient: P2PClient;
|
|
24
26
|
epochCache: EpochCache;
|
|
27
|
+
blobClient: BlobClientInterface;
|
|
25
28
|
dateProvider: DateProvider;
|
|
26
29
|
telemetry: TelemetryClient;
|
|
30
|
+
reexecutionTracker: CheckpointReexecutionTracker;
|
|
27
31
|
},
|
|
28
32
|
) {
|
|
29
33
|
const metrics = new ValidatorMetrics(deps.telemetry);
|
|
30
34
|
const blockProposalValidator = new BlockProposalValidator(deps.epochCache, {
|
|
31
35
|
txsPermitted: !config.disableTransactions,
|
|
36
|
+
maxTxsPerBlock: config.validateMaxTxsPerBlock ?? config.validateMaxTxsPerCheckpoint,
|
|
37
|
+
maxBlocksPerCheckpoint: config.maxBlocksPerCheckpoint,
|
|
38
|
+
signatureContext: {
|
|
39
|
+
chainId: config.l1ChainId,
|
|
40
|
+
rollupAddress: config.rollupAddress,
|
|
41
|
+
},
|
|
32
42
|
});
|
|
33
|
-
return new
|
|
43
|
+
return new ProposalHandler(
|
|
34
44
|
deps.checkpointsBuilder,
|
|
35
45
|
deps.worldState,
|
|
36
46
|
deps.blockSource,
|
|
@@ -39,9 +49,12 @@ export function createBlockProposalHandler(
|
|
|
39
49
|
blockProposalValidator,
|
|
40
50
|
deps.epochCache,
|
|
41
51
|
config,
|
|
52
|
+
deps.blobClient,
|
|
53
|
+
deps.reexecutionTracker,
|
|
42
54
|
metrics,
|
|
43
55
|
deps.dateProvider,
|
|
44
56
|
deps.telemetry,
|
|
57
|
+
undefined,
|
|
45
58
|
);
|
|
46
59
|
}
|
|
47
60
|
|
|
@@ -58,6 +71,8 @@ export function createValidatorClient(
|
|
|
58
71
|
epochCache: EpochCache;
|
|
59
72
|
keyStoreManager: KeystoreManager | undefined;
|
|
60
73
|
blobClient: BlobClientInterface;
|
|
74
|
+
reexecutionTracker: CheckpointReexecutionTracker;
|
|
75
|
+
slashingProtectionDb?: SlashingProtectionDatabase;
|
|
61
76
|
},
|
|
62
77
|
) {
|
|
63
78
|
if (config.disableValidator || !deps.keyStoreManager) {
|
|
@@ -76,7 +91,9 @@ export function createValidatorClient(
|
|
|
76
91
|
txProvider,
|
|
77
92
|
deps.keyStoreManager,
|
|
78
93
|
deps.blobClient,
|
|
94
|
+
deps.reexecutionTracker,
|
|
79
95
|
deps.dateProvider,
|
|
80
96
|
deps.telemetry,
|
|
97
|
+
deps.slashingProtectionDb,
|
|
81
98
|
);
|
|
82
99
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './proposal_handler.js';
|
|
2
2
|
export * from './checkpoint_builder.js';
|
|
3
3
|
export * from './config.js';
|
|
4
4
|
export * from './factory.js';
|
|
5
5
|
export * from './validator.js';
|
|
6
6
|
export * from './key_store/index.js';
|
|
7
|
-
export * from './tx_validator/index.js';
|
|
@@ -240,7 +240,7 @@ export class HAKeyStore implements ExtendedValidatorKeyStore {
|
|
|
240
240
|
}
|
|
241
241
|
|
|
242
242
|
if (error instanceof SlashingProtectionError) {
|
|
243
|
-
this.log.
|
|
243
|
+
this.log.info(`Duty already signed by another node with different payload`, {
|
|
244
244
|
dutyType: context.dutyType,
|
|
245
245
|
slot: context.slot,
|
|
246
246
|
existingMessageHash: error.existingMessageHash,
|
|
@@ -256,8 +256,8 @@ export class HAKeyStore implements ExtendedValidatorKeyStore {
|
|
|
256
256
|
/**
|
|
257
257
|
* Start the high-availability key store
|
|
258
258
|
*/
|
|
259
|
-
public start()
|
|
260
|
-
|
|
259
|
+
public async start() {
|
|
260
|
+
await this.haSigner.start();
|
|
261
261
|
}
|
|
262
262
|
|
|
263
263
|
/**
|
package/src/metrics.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { EpochNumber } from '@aztec/foundation/branded-types';
|
|
2
|
+
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
1
3
|
import type { BlockProposal } from '@aztec/stdlib/p2p';
|
|
2
4
|
import {
|
|
3
5
|
Attributes,
|
|
@@ -6,38 +8,83 @@ import {
|
|
|
6
8
|
Metrics,
|
|
7
9
|
type TelemetryClient,
|
|
8
10
|
type UpDownCounter,
|
|
11
|
+
createUpDownCounterWithDefault,
|
|
9
12
|
} from '@aztec/telemetry-client';
|
|
10
13
|
|
|
14
|
+
import type { BlockProposalValidationFailureReason } from './proposal_handler.js';
|
|
15
|
+
|
|
11
16
|
export class ValidatorMetrics {
|
|
12
17
|
private failedReexecutionCounter: UpDownCounter;
|
|
13
18
|
private successfulAttestationsCount: UpDownCounter;
|
|
14
19
|
private failedAttestationsBadProposalCount: UpDownCounter;
|
|
15
20
|
private failedAttestationsNodeIssueCount: UpDownCounter;
|
|
21
|
+
private currentEpoch: Gauge;
|
|
22
|
+
private attestedEpochCount: UpDownCounter;
|
|
16
23
|
|
|
17
24
|
private reexMana: Histogram;
|
|
18
25
|
private reexTx: Histogram;
|
|
19
26
|
private reexDuration: Gauge;
|
|
27
|
+
private checkpointProposalToPipelinedStateDuration: Histogram;
|
|
28
|
+
private checkpointProposalReceiveOffsetFromNextSlotBoundary: Histogram;
|
|
20
29
|
|
|
21
30
|
constructor(telemetryClient: TelemetryClient) {
|
|
22
31
|
const meter = telemetryClient.getMeter('Validator');
|
|
23
32
|
|
|
24
|
-
this.failedReexecutionCounter = meter
|
|
33
|
+
this.failedReexecutionCounter = createUpDownCounterWithDefault(meter, Metrics.VALIDATOR_FAILED_REEXECUTION_COUNT, {
|
|
34
|
+
[Attributes.STATUS]: ['failed'],
|
|
35
|
+
});
|
|
25
36
|
|
|
26
|
-
this.successfulAttestationsCount =
|
|
37
|
+
this.successfulAttestationsCount = createUpDownCounterWithDefault(
|
|
38
|
+
meter,
|
|
39
|
+
Metrics.VALIDATOR_ATTESTATION_SUCCESS_COUNT,
|
|
40
|
+
);
|
|
27
41
|
|
|
28
|
-
this.failedAttestationsBadProposalCount =
|
|
42
|
+
this.failedAttestationsBadProposalCount = createUpDownCounterWithDefault(
|
|
43
|
+
meter,
|
|
29
44
|
Metrics.VALIDATOR_ATTESTATION_FAILED_BAD_PROPOSAL_COUNT,
|
|
45
|
+
{
|
|
46
|
+
[Attributes.ERROR_TYPE]: [
|
|
47
|
+
'invalid_proposal',
|
|
48
|
+
'state_mismatch',
|
|
49
|
+
'failed_txs',
|
|
50
|
+
'in_hash_mismatch',
|
|
51
|
+
'parent_block_wrong_slot',
|
|
52
|
+
],
|
|
53
|
+
[Attributes.IS_COMMITTEE_MEMBER]: [true, false],
|
|
54
|
+
},
|
|
30
55
|
);
|
|
31
56
|
|
|
32
|
-
this.failedAttestationsNodeIssueCount =
|
|
57
|
+
this.failedAttestationsNodeIssueCount = createUpDownCounterWithDefault(
|
|
58
|
+
meter,
|
|
33
59
|
Metrics.VALIDATOR_ATTESTATION_FAILED_NODE_ISSUE_COUNT,
|
|
60
|
+
{
|
|
61
|
+
[Attributes.ERROR_TYPE]: [
|
|
62
|
+
'parent_block_not_found',
|
|
63
|
+
'global_variables_mismatch',
|
|
64
|
+
'block_number_already_exists',
|
|
65
|
+
'txs_not_available',
|
|
66
|
+
'timeout',
|
|
67
|
+
'unknown_error',
|
|
68
|
+
],
|
|
69
|
+
[Attributes.IS_COMMITTEE_MEMBER]: [true, false],
|
|
70
|
+
},
|
|
34
71
|
);
|
|
35
72
|
|
|
73
|
+
this.currentEpoch = meter.createGauge(Metrics.VALIDATOR_CURRENT_EPOCH);
|
|
74
|
+
|
|
75
|
+
this.attestedEpochCount = createUpDownCounterWithDefault(meter, Metrics.VALIDATOR_ATTESTED_EPOCH_COUNT);
|
|
76
|
+
|
|
36
77
|
this.reexMana = meter.createHistogram(Metrics.VALIDATOR_RE_EXECUTION_MANA);
|
|
37
78
|
|
|
38
79
|
this.reexTx = meter.createHistogram(Metrics.VALIDATOR_RE_EXECUTION_TX_COUNT);
|
|
39
80
|
|
|
40
81
|
this.reexDuration = meter.createGauge(Metrics.VALIDATOR_RE_EXECUTION_TIME);
|
|
82
|
+
this.checkpointProposalToPipelinedStateDuration = meter.createHistogram(
|
|
83
|
+
Metrics.VALIDATOR_CHECKPOINT_PROPOSAL_TO_PIPELINED_STATE_DURATION,
|
|
84
|
+
);
|
|
85
|
+
this.checkpointProposalReceiveOffsetFromNextSlotBoundary = meter.createHistogram(
|
|
86
|
+
Metrics.VALIDATOR_CHECKPOINT_PROPOSAL_RECEIVE_OFFSET_FROM_NEXT_SLOT_BOUNDARY,
|
|
87
|
+
);
|
|
41
88
|
}
|
|
42
89
|
|
|
43
90
|
public recordReex(time: number, txs: number, mManaTotal: number) {
|
|
@@ -46,6 +93,16 @@ export class ValidatorMetrics {
|
|
|
46
93
|
this.reexMana.record(mManaTotal);
|
|
47
94
|
}
|
|
48
95
|
|
|
96
|
+
public recordCheckpointProposalToPipelinedStateDuration(durationMs: number) {
|
|
97
|
+
this.checkpointProposalToPipelinedStateDuration.record(Math.ceil(durationMs));
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
public recordCheckpointProposalReceiveOffsetFromNextSlotBoundary(offsetMs: number) {
|
|
101
|
+
this.checkpointProposalReceiveOffsetFromNextSlotBoundary.record(Math.ceil(Math.abs(offsetMs)), {
|
|
102
|
+
[Attributes.SLOT_BOUNDARY_SIDE]: offsetMs < 0 ? 'before' : 'after',
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
|
|
49
106
|
public recordFailedReexecution(proposal: BlockProposal) {
|
|
50
107
|
const proposer = proposal.getSender();
|
|
51
108
|
this.failedReexecutionCounter.add(1, {
|
|
@@ -58,17 +115,35 @@ export class ValidatorMetrics {
|
|
|
58
115
|
this.successfulAttestationsCount.add(num);
|
|
59
116
|
}
|
|
60
117
|
|
|
61
|
-
public incFailedAttestationsBadProposal(
|
|
118
|
+
public incFailedAttestationsBadProposal(
|
|
119
|
+
num: number,
|
|
120
|
+
reason: BlockProposalValidationFailureReason,
|
|
121
|
+
inCommittee: boolean,
|
|
122
|
+
) {
|
|
62
123
|
this.failedAttestationsBadProposalCount.add(num, {
|
|
63
124
|
[Attributes.ERROR_TYPE]: reason,
|
|
64
125
|
[Attributes.IS_COMMITTEE_MEMBER]: inCommittee,
|
|
65
126
|
});
|
|
66
127
|
}
|
|
67
128
|
|
|
68
|
-
public incFailedAttestationsNodeIssue(
|
|
129
|
+
public incFailedAttestationsNodeIssue(
|
|
130
|
+
num: number,
|
|
131
|
+
reason: BlockProposalValidationFailureReason,
|
|
132
|
+
inCommittee: boolean,
|
|
133
|
+
) {
|
|
69
134
|
this.failedAttestationsNodeIssueCount.add(num, {
|
|
70
135
|
[Attributes.ERROR_TYPE]: reason,
|
|
71
136
|
[Attributes.IS_COMMITTEE_MEMBER]: inCommittee,
|
|
72
137
|
});
|
|
73
138
|
}
|
|
139
|
+
|
|
140
|
+
/** Update the gauge tracking the current epoch number (proxy for total epochs elapsed). */
|
|
141
|
+
public setCurrentEpoch(epoch: EpochNumber) {
|
|
142
|
+
this.currentEpoch.record(Number(epoch));
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** Increment the count of epochs in which the given attester submitted at least one attestation. */
|
|
146
|
+
public incAttestedEpochCount(attester: EthAddress) {
|
|
147
|
+
this.attestedEpochCount.add(1, { [Attributes.ATTESTER_ADDRESS]: attester.toString() });
|
|
148
|
+
}
|
|
74
149
|
}
|