@lodestar/beacon-node 1.50.0-dev.cddd01a6c6 → 1.50.0-dev.ce0e732118
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/lib/api/impl/beacon/index.d.ts.map +1 -1
- package/lib/api/impl/beacon/index.js +13 -0
- package/lib/api/impl/beacon/index.js.map +1 -1
- package/lib/api/impl/validator/index.d.ts +1 -0
- package/lib/api/impl/validator/index.d.ts.map +1 -1
- package/lib/api/impl/validator/index.js +17 -1
- package/lib/api/impl/validator/index.js.map +1 -1
- package/lib/chain/archiveStore/archiveStore.js +1 -1
- package/lib/chain/archiveStore/archiveStore.js.map +1 -1
- package/lib/chain/archiveStore/historicalState/getHistoricalState.d.ts +2 -2
- package/lib/chain/archiveStore/historicalState/getHistoricalState.d.ts.map +1 -1
- package/lib/chain/archiveStore/historicalState/getHistoricalState.js +5 -7
- package/lib/chain/archiveStore/historicalState/getHistoricalState.js.map +1 -1
- package/lib/chain/archiveStore/historicalState/historicalStateRegen.js +1 -1
- package/lib/chain/archiveStore/historicalState/historicalStateRegen.js.map +1 -1
- package/lib/chain/archiveStore/historicalState/types.d.ts +2 -2
- package/lib/chain/archiveStore/historicalState/types.d.ts.map +1 -1
- package/lib/chain/archiveStore/historicalState/worker.js +1 -1
- package/lib/chain/archiveStore/historicalState/worker.js.map +1 -1
- package/lib/chain/archiveStore/interface.d.ts +1 -1
- package/lib/chain/archiveStore/interface.d.ts.map +1 -1
- package/lib/chain/blocks/verifyBlock.d.ts.map +1 -1
- package/lib/chain/blocks/verifyBlock.js +1 -1
- package/lib/chain/blocks/verifyBlock.js.map +1 -1
- package/lib/chain/blocks/verifyBlocksStateTransitionOnly.d.ts +2 -1
- package/lib/chain/blocks/verifyBlocksStateTransitionOnly.d.ts.map +1 -1
- package/lib/chain/blocks/verifyBlocksStateTransitionOnly.js +5 -4
- package/lib/chain/blocks/verifyBlocksStateTransitionOnly.js.map +1 -1
- package/lib/chain/chain.d.ts +1 -0
- package/lib/chain/chain.d.ts.map +1 -1
- package/lib/chain/chain.js +29 -0
- package/lib/chain/chain.js.map +1 -1
- package/lib/chain/emitter.d.ts +7 -1
- package/lib/chain/emitter.d.ts.map +1 -1
- package/lib/chain/emitter.js +5 -0
- package/lib/chain/emitter.js.map +1 -1
- package/lib/chain/forkChoice/index.d.ts.map +1 -1
- package/lib/chain/forkChoice/index.js +2 -0
- package/lib/chain/forkChoice/index.js.map +1 -1
- package/lib/chain/opPools/proposerPreferencesPool.d.ts +4 -4
- package/lib/chain/opPools/proposerPreferencesPool.d.ts.map +1 -1
- package/lib/chain/opPools/proposerPreferencesPool.js +14 -11
- package/lib/chain/opPools/proposerPreferencesPool.js.map +1 -1
- package/lib/chain/options.d.ts +1 -1
- package/lib/chain/options.d.ts.map +1 -1
- package/lib/chain/options.js +1 -1
- package/lib/chain/options.js.map +1 -1
- package/lib/chain/produceBlock/computeNewStateRoot.js +1 -1
- package/lib/chain/produceBlock/computeNewStateRoot.js.map +1 -1
- package/lib/chain/regen/regen.d.ts +2 -0
- package/lib/chain/regen/regen.d.ts.map +1 -1
- package/lib/chain/regen/regen.js +10 -4
- package/lib/chain/regen/regen.js.map +1 -1
- package/lib/chain/validatorMonitor.d.ts +5 -1
- package/lib/chain/validatorMonitor.d.ts.map +1 -1
- package/lib/chain/validatorMonitor.js +64 -54
- package/lib/chain/validatorMonitor.js.map +1 -1
- package/lib/metrics/metrics.d.ts +7 -3
- package/lib/metrics/metrics.d.ts.map +1 -1
- package/lib/metrics/metrics.js +4 -4
- package/lib/metrics/metrics.js.map +1 -1
- package/lib/node/nodejs.d.ts.map +1 -1
- package/lib/node/nodejs.js +25 -3
- package/lib/node/nodejs.js.map +1 -1
- package/lib/sync/range/chain.d.ts.map +1 -1
- package/lib/sync/range/chain.js +5 -1
- package/lib/sync/range/chain.js.map +1 -1
- package/package.json +16 -16
- package/src/api/impl/beacon/index.ts +15 -0
- package/src/api/impl/validator/index.ts +16 -2
- package/src/chain/archiveStore/archiveStore.ts +1 -1
- package/src/chain/archiveStore/historicalState/getHistoricalState.ts +5 -7
- package/src/chain/archiveStore/historicalState/historicalStateRegen.ts +1 -1
- package/src/chain/archiveStore/historicalState/types.ts +2 -2
- package/src/chain/archiveStore/historicalState/worker.ts +1 -2
- package/src/chain/archiveStore/interface.ts +1 -1
- package/src/chain/blocks/verifyBlock.ts +1 -0
- package/src/chain/blocks/verifyBlocksStateTransitionOnly.ts +6 -3
- package/src/chain/chain.ts +33 -0
- package/src/chain/emitter.ts +7 -1
- package/src/chain/forkChoice/index.ts +2 -0
- package/src/chain/opPools/proposerPreferencesPool.ts +14 -10
- package/src/chain/options.ts +2 -2
- package/src/chain/produceBlock/computeNewStateRoot.ts +1 -1
- package/src/chain/regen/regen.ts +12 -4
- package/src/chain/validatorMonitor.ts +75 -57
- package/src/metrics/metrics.ts +21 -6
- package/src/node/nodejs.ts +31 -3
- package/src/sync/range/chain.ts +6 -1
|
@@ -123,6 +123,11 @@ export type ValidatorMonitorOpts = {
|
|
|
123
123
|
validatorMonitorLogs?: boolean;
|
|
124
124
|
};
|
|
125
125
|
|
|
126
|
+
export type NativeValidatorMonitor = {
|
|
127
|
+
registerLocalValidator(index: ValidatorIndex): void;
|
|
128
|
+
unregisterLocalValidator(index: ValidatorIndex): void;
|
|
129
|
+
};
|
|
130
|
+
|
|
126
131
|
export const defaultValidatorMonitorOpts: ValidatorMonitorOpts = {
|
|
127
132
|
validatorMonitorLogs: false,
|
|
128
133
|
};
|
|
@@ -296,7 +301,8 @@ export function createValidatorMonitor(
|
|
|
296
301
|
config: ChainForkConfig,
|
|
297
302
|
genesisTime: number,
|
|
298
303
|
logger: Logger,
|
|
299
|
-
opts: ValidatorMonitorOpts
|
|
304
|
+
opts: ValidatorMonitorOpts,
|
|
305
|
+
nativeValidatorMonitor: NativeValidatorMonitor | null = null
|
|
300
306
|
): ValidatorMonitor {
|
|
301
307
|
const logLevel = opts.validatorMonitorLogs ? LogLevel.info : LogLevel.debug;
|
|
302
308
|
const log: LogHandler = (message: string, context?: LogData) => {
|
|
@@ -327,18 +333,23 @@ export function createValidatorMonitor(
|
|
|
327
333
|
}));
|
|
328
334
|
|
|
329
335
|
let lastRegisteredStatusEpoch = -1;
|
|
336
|
+
let lastAttestationSummaryEpoch = -1;
|
|
330
337
|
|
|
331
338
|
// Track validator additions/removals per epoch for logging
|
|
332
339
|
const addedValidatorsInEpoch: Set<ValidatorIndex> = new Set();
|
|
333
340
|
const removedValidatorsInEpoch: Set<ValidatorIndex> = new Set();
|
|
334
341
|
|
|
335
|
-
const
|
|
342
|
+
const shouldRegisterStateDerivedMetrics = nativeValidatorMonitor === null;
|
|
343
|
+
const validatorMonitorMetrics = metricsRegister
|
|
344
|
+
? createValidatorMonitorMetrics(metricsRegister, shouldRegisterStateDerivedMetrics)
|
|
345
|
+
: null;
|
|
336
346
|
|
|
337
347
|
const validatorMonitor: ValidatorMonitor = {
|
|
338
348
|
registerLocalValidator(index) {
|
|
339
349
|
const isNewValidator = !validators.has(index);
|
|
340
350
|
validators.getOrDefault(index).lastRegisteredTimeMs = Date.now();
|
|
341
351
|
if (isNewValidator) {
|
|
352
|
+
nativeValidatorMonitor?.registerLocalValidator(index);
|
|
342
353
|
addedValidatorsInEpoch.add(index);
|
|
343
354
|
}
|
|
344
355
|
},
|
|
@@ -366,7 +377,7 @@ export function createValidatorMonitor(
|
|
|
366
377
|
// Track total balance instead of per-validator balance to reduce metric cardinality
|
|
367
378
|
let totalBalance = 0;
|
|
368
379
|
|
|
369
|
-
for (const
|
|
380
|
+
for (const index of validators.keys()) {
|
|
370
381
|
// We subtract two from the state of the epoch that generated these summaries.
|
|
371
382
|
//
|
|
372
383
|
// - One to account for it being the previous epoch.
|
|
@@ -380,68 +391,29 @@ export function createValidatorMonitor(
|
|
|
380
391
|
);
|
|
381
392
|
|
|
382
393
|
if (summary.isPrevSourceAttester) {
|
|
383
|
-
validatorMonitorMetrics?.prevEpochOnChainSourceAttesterHit
|
|
394
|
+
validatorMonitorMetrics?.prevEpochOnChainSourceAttesterHit?.inc();
|
|
384
395
|
} else {
|
|
385
|
-
validatorMonitorMetrics?.prevEpochOnChainSourceAttesterMiss
|
|
396
|
+
validatorMonitorMetrics?.prevEpochOnChainSourceAttesterMiss?.inc();
|
|
386
397
|
}
|
|
387
398
|
if (summary.isPrevHeadAttester) {
|
|
388
|
-
validatorMonitorMetrics?.prevEpochOnChainHeadAttesterHit
|
|
399
|
+
validatorMonitorMetrics?.prevEpochOnChainHeadAttesterHit?.inc();
|
|
389
400
|
} else {
|
|
390
|
-
validatorMonitorMetrics?.prevEpochOnChainHeadAttesterMiss
|
|
401
|
+
validatorMonitorMetrics?.prevEpochOnChainHeadAttesterMiss?.inc();
|
|
391
402
|
}
|
|
392
403
|
if (summary.isPrevTargetAttester) {
|
|
393
|
-
validatorMonitorMetrics?.prevEpochOnChainTargetAttesterHit
|
|
404
|
+
validatorMonitorMetrics?.prevEpochOnChainTargetAttesterHit?.inc();
|
|
394
405
|
} else {
|
|
395
|
-
validatorMonitorMetrics?.prevEpochOnChainTargetAttesterMiss
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
const prevEpochSummary = monitoredValidator.summaries.get(previousEpoch);
|
|
399
|
-
const attestationCorrectHead = prevEpochSummary?.attestationCorrectHead;
|
|
400
|
-
if (attestationCorrectHead !== null && attestationCorrectHead !== undefined) {
|
|
401
|
-
if (attestationCorrectHead) {
|
|
402
|
-
validatorMonitorMetrics?.prevOnChainAttesterCorrectHead.inc();
|
|
403
|
-
} else {
|
|
404
|
-
validatorMonitorMetrics?.prevOnChainAttesterIncorrectHead.inc();
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
const attestationMinBlockInclusionDistance = prevEpochSummary?.attestationMinBlockInclusionDistance;
|
|
409
|
-
const inclusionDistance =
|
|
410
|
-
attestationMinBlockInclusionDistance != null && attestationMinBlockInclusionDistance > 0
|
|
411
|
-
? // altair, attestation is not missed
|
|
412
|
-
attestationMinBlockInclusionDistance
|
|
413
|
-
: summary.inclusionDistance
|
|
414
|
-
? // phase0, this is from the state transition
|
|
415
|
-
summary.inclusionDistance
|
|
416
|
-
: null;
|
|
417
|
-
|
|
418
|
-
if (inclusionDistance !== null) {
|
|
419
|
-
validatorMonitorMetrics?.prevEpochOnChainInclusionDistance.observe(inclusionDistance);
|
|
420
|
-
validatorMonitorMetrics?.prevEpochOnChainAttesterHit.inc();
|
|
421
|
-
} else {
|
|
422
|
-
validatorMonitorMetrics?.prevEpochOnChainAttesterMiss.inc();
|
|
406
|
+
validatorMonitorMetrics?.prevEpochOnChainTargetAttesterMiss?.inc();
|
|
423
407
|
}
|
|
424
408
|
|
|
425
409
|
const balance = balances?.[index];
|
|
426
410
|
if (balance !== undefined) {
|
|
427
411
|
totalBalance += balance;
|
|
428
412
|
}
|
|
429
|
-
|
|
430
|
-
if (!summary.isPrevSourceAttester || !summary.isPrevTargetAttester || !summary.isPrevHeadAttester) {
|
|
431
|
-
log("Failed attestation in previous epoch", {
|
|
432
|
-
validator: index,
|
|
433
|
-
prevEpoch: currentEpoch - 1,
|
|
434
|
-
isPrevSourceAttester: summary.isPrevSourceAttester,
|
|
435
|
-
isPrevHeadAttester: summary.isPrevHeadAttester,
|
|
436
|
-
isPrevTargetAttester: summary.isPrevTargetAttester,
|
|
437
|
-
// inclusionDistance is not available in summary since altair
|
|
438
|
-
inclusionDistance,
|
|
439
|
-
});
|
|
440
|
-
}
|
|
441
413
|
}
|
|
442
414
|
|
|
443
415
|
if (balances !== undefined) {
|
|
444
|
-
validatorMonitorMetrics?.prevEpochOnChainBalance
|
|
416
|
+
validatorMonitorMetrics?.prevEpochOnChainBalance?.set(totalBalance);
|
|
445
417
|
}
|
|
446
418
|
},
|
|
447
419
|
|
|
@@ -732,6 +704,7 @@ export function createValidatorMonitor(
|
|
|
732
704
|
// Prune validators not seen in a while
|
|
733
705
|
for (const [index, validator] of validators.entries()) {
|
|
734
706
|
if (Date.now() - validator.lastRegisteredTimeMs > retainRegisteredValidatorsMs) {
|
|
707
|
+
nativeValidatorMonitor?.unregisterLocalValidator(index);
|
|
735
708
|
validators.delete(index);
|
|
736
709
|
removedValidatorsInEpoch.add(index);
|
|
737
710
|
}
|
|
@@ -767,6 +740,38 @@ export function createValidatorMonitor(
|
|
|
767
740
|
return;
|
|
768
741
|
}
|
|
769
742
|
|
|
743
|
+
// On-chain attestation summary of prevEpoch. Reads only the epoch summaries filled by
|
|
744
|
+
// registerAttestationInBlock(), so it works with both TS and native state transition.
|
|
745
|
+
if (prevEpoch > lastAttestationSummaryEpoch) {
|
|
746
|
+
lastAttestationSummaryEpoch = prevEpoch;
|
|
747
|
+
|
|
748
|
+
for (const monitoredValidator of validators.values()) {
|
|
749
|
+
const prevEpochSummary = monitoredValidator.summaries.get(prevEpoch);
|
|
750
|
+
const attestationCorrectHead = prevEpochSummary?.attestationCorrectHead;
|
|
751
|
+
if (attestationCorrectHead !== null && attestationCorrectHead !== undefined) {
|
|
752
|
+
if (attestationCorrectHead) {
|
|
753
|
+
validatorMonitorMetrics?.prevOnChainAttesterCorrectHead.inc();
|
|
754
|
+
} else {
|
|
755
|
+
validatorMonitorMetrics?.prevOnChainAttesterIncorrectHead.inc();
|
|
756
|
+
}
|
|
757
|
+
}
|
|
758
|
+
|
|
759
|
+
const attestationMinBlockInclusionDistance = prevEpochSummary?.attestationMinBlockInclusionDistance;
|
|
760
|
+
const inclusionDistance =
|
|
761
|
+
attestationMinBlockInclusionDistance != null && attestationMinBlockInclusionDistance > 0
|
|
762
|
+
? // altair, attestation is not missed
|
|
763
|
+
attestationMinBlockInclusionDistance
|
|
764
|
+
: null;
|
|
765
|
+
|
|
766
|
+
if (inclusionDistance !== null) {
|
|
767
|
+
validatorMonitorMetrics?.prevEpochOnChainInclusionDistance.observe(inclusionDistance);
|
|
768
|
+
validatorMonitorMetrics?.prevEpochOnChainAttesterHit.inc();
|
|
769
|
+
} else {
|
|
770
|
+
validatorMonitorMetrics?.prevEpochOnChainAttesterMiss.inc();
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
|
|
770
775
|
const rootCache = new RootHexCache(headState);
|
|
771
776
|
|
|
772
777
|
if (isStatePostAltair(headState)) {
|
|
@@ -784,6 +789,17 @@ export function createValidatorMonitor(
|
|
|
784
789
|
epoch: prevEpoch,
|
|
785
790
|
summary,
|
|
786
791
|
});
|
|
792
|
+
|
|
793
|
+
if (!flags.timelySource || !flags.timelyTarget || !flags.timelyHead) {
|
|
794
|
+
log("Failed attestation in previous epoch", {
|
|
795
|
+
validator: index,
|
|
796
|
+
prevEpoch,
|
|
797
|
+
isPrevSourceAttester: flags.timelySource,
|
|
798
|
+
isPrevHeadAttester: flags.timelyHead,
|
|
799
|
+
isPrevTargetAttester: flags.timelyTarget,
|
|
800
|
+
inclusionDistance: validator.summaries.get(prevEpoch)?.attestationMinBlockInclusionDistance ?? null,
|
|
801
|
+
});
|
|
802
|
+
}
|
|
787
803
|
}
|
|
788
804
|
}
|
|
789
805
|
|
|
@@ -1198,7 +1214,9 @@ export class RootHexCache {
|
|
|
1198
1214
|
}
|
|
1199
1215
|
}
|
|
1200
1216
|
|
|
1201
|
-
function createValidatorMonitorMetrics(register: RegistryMetricCreator) {
|
|
1217
|
+
function createValidatorMonitorMetrics(register: RegistryMetricCreator, registerStateDerivedMetrics = true) {
|
|
1218
|
+
const stateDerivedRegister = registerStateDerivedMetrics ? register : null;
|
|
1219
|
+
|
|
1202
1220
|
return {
|
|
1203
1221
|
validatorsConnected: register.gauge({
|
|
1204
1222
|
name: "validator_monitor_validators",
|
|
@@ -1217,7 +1235,7 @@ function createValidatorMonitorMetrics(register: RegistryMetricCreator) {
|
|
|
1217
1235
|
}),
|
|
1218
1236
|
|
|
1219
1237
|
// Validator Monitor Metrics (per-epoch summaries)
|
|
1220
|
-
prevEpochOnChainBalance:
|
|
1238
|
+
prevEpochOnChainBalance: stateDerivedRegister?.gauge({
|
|
1221
1239
|
name: "validator_monitor_prev_epoch_on_chain_balance",
|
|
1222
1240
|
help: "Total balance of all monitored validators after an epoch",
|
|
1223
1241
|
}),
|
|
@@ -1229,19 +1247,19 @@ function createValidatorMonitorMetrics(register: RegistryMetricCreator) {
|
|
|
1229
1247
|
name: "validator_monitor_prev_epoch_on_chain_attester_miss_total",
|
|
1230
1248
|
help: "Incremented if validator's submitted attestation is not included in any blocks",
|
|
1231
1249
|
}),
|
|
1232
|
-
prevEpochOnChainSourceAttesterHit:
|
|
1250
|
+
prevEpochOnChainSourceAttesterHit: stateDerivedRegister?.gauge({
|
|
1233
1251
|
name: "validator_monitor_prev_epoch_on_chain_source_attester_hit_total",
|
|
1234
1252
|
help: "Incremented if the validator is flagged as a previous epoch source attester during per epoch processing",
|
|
1235
1253
|
}),
|
|
1236
|
-
prevEpochOnChainSourceAttesterMiss:
|
|
1254
|
+
prevEpochOnChainSourceAttesterMiss: stateDerivedRegister?.gauge({
|
|
1237
1255
|
name: "validator_monitor_prev_epoch_on_chain_source_attester_miss_total",
|
|
1238
1256
|
help: "Incremented if the validator is not flagged as a previous epoch source attester during per epoch processing",
|
|
1239
1257
|
}),
|
|
1240
|
-
prevEpochOnChainHeadAttesterHit:
|
|
1258
|
+
prevEpochOnChainHeadAttesterHit: stateDerivedRegister?.gauge({
|
|
1241
1259
|
name: "validator_monitor_prev_epoch_on_chain_head_attester_hit_total",
|
|
1242
1260
|
help: "Incremented if the validator is flagged as a previous epoch head attester during per epoch processing",
|
|
1243
1261
|
}),
|
|
1244
|
-
prevEpochOnChainHeadAttesterMiss:
|
|
1262
|
+
prevEpochOnChainHeadAttesterMiss: stateDerivedRegister?.gauge({
|
|
1245
1263
|
name: "validator_monitor_prev_epoch_on_chain_head_attester_miss_total",
|
|
1246
1264
|
help: "Incremented if the validator is not flagged as a previous epoch head attester during per epoch processing",
|
|
1247
1265
|
}),
|
|
@@ -1253,11 +1271,11 @@ function createValidatorMonitorMetrics(register: RegistryMetricCreator) {
|
|
|
1253
1271
|
name: "validator_monitor_prev_epoch_on_chain_attester_incorrect_head_total",
|
|
1254
1272
|
help: "Total count of times a validator votes incorrect head",
|
|
1255
1273
|
}),
|
|
1256
|
-
prevEpochOnChainTargetAttesterHit:
|
|
1274
|
+
prevEpochOnChainTargetAttesterHit: stateDerivedRegister?.gauge({
|
|
1257
1275
|
name: "validator_monitor_prev_epoch_on_chain_target_attester_hit_total",
|
|
1258
1276
|
help: "Incremented if the validator is flagged as a previous epoch target attester during per epoch processing",
|
|
1259
1277
|
}),
|
|
1260
|
-
prevEpochOnChainTargetAttesterMiss:
|
|
1278
|
+
prevEpochOnChainTargetAttesterMiss: stateDerivedRegister?.gauge({
|
|
1261
1279
|
name: "validator_monitor_prev_epoch_on_chain_target_attester_miss_total",
|
|
1262
1280
|
help: "Incremented if the validator is not flagged as a previous epoch target attester during per epoch processing",
|
|
1263
1281
|
}),
|
package/src/metrics/metrics.ts
CHANGED
|
@@ -9,27 +9,42 @@ import {RegistryMetricCreator} from "./utils/registryMetricCreator.js";
|
|
|
9
9
|
|
|
10
10
|
export type Metrics = BeaconMetrics &
|
|
11
11
|
ForkChoiceMetrics &
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
LodestarMetrics & {
|
|
13
|
+
/** Null when we use native state transition metrics instead */
|
|
14
|
+
stateTransition: BeaconStateTransitionMetrics | null;
|
|
15
|
+
register: RegistryMetricCreator;
|
|
16
|
+
close: () => void;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export type CreateMetricsOptions = {
|
|
20
|
+
/*
|
|
21
|
+
* Toggle inclusion of state transition metrics.
|
|
22
|
+
*
|
|
23
|
+
* False when native state transition is used, so we
|
|
24
|
+
* can grab metrics from the native implementation instead.
|
|
25
|
+
* */
|
|
26
|
+
includeStateTransitionMetrics?: boolean;
|
|
27
|
+
collectNodeMetrics?: boolean;
|
|
28
|
+
};
|
|
14
29
|
|
|
15
30
|
export function createMetrics(
|
|
16
31
|
opts: MetricsOptions,
|
|
17
32
|
genesisTime: number,
|
|
18
33
|
externalRegistries: Registry[] = [],
|
|
19
|
-
|
|
34
|
+
createOpts: CreateMetricsOptions = {}
|
|
20
35
|
): Metrics {
|
|
21
36
|
const register = new RegistryMetricCreator();
|
|
22
37
|
const beacon = createBeaconMetrics(register);
|
|
23
38
|
const forkChoice = getForkChoiceMetrics(register);
|
|
24
39
|
const lodestar = createLodestarMetrics(register, opts.metadata, genesisTime);
|
|
25
|
-
const stateTransition = getMetrics(register);
|
|
40
|
+
const stateTransition = createOpts.includeStateTransitionMetrics === false ? null : getMetrics(register);
|
|
26
41
|
|
|
27
42
|
const onUnhandledRejection = (_error: unknown): void => {
|
|
28
43
|
lodestar.unhandledPromiseRejections.inc();
|
|
29
44
|
};
|
|
30
45
|
process.on("unhandledRejection", onUnhandledRejection);
|
|
31
46
|
|
|
32
|
-
const nodeJsMetricsClose = collectNodeMetrics
|
|
47
|
+
const nodeJsMetricsClose = createOpts.collectNodeMetrics === false ? (): void => {} : collectNodeJSMetrics(register);
|
|
33
48
|
const close = (): void => {
|
|
34
49
|
process.removeListener("unhandledRejection", onUnhandledRejection);
|
|
35
50
|
nodeJsMetricsClose();
|
|
@@ -46,7 +61,7 @@ export function createMetrics(
|
|
|
46
61
|
...beacon,
|
|
47
62
|
...forkChoice,
|
|
48
63
|
...lodestar,
|
|
49
|
-
|
|
64
|
+
stateTransition,
|
|
50
65
|
register,
|
|
51
66
|
close,
|
|
52
67
|
};
|
package/src/node/nodejs.ts
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import {setMaxListeners} from "node:events";
|
|
2
2
|
import {PrivateKey} from "@libp2p/interface";
|
|
3
3
|
import {Registry} from "prom-client";
|
|
4
|
+
import {
|
|
5
|
+
init as initNativeMetrics,
|
|
6
|
+
registerLocalValidator as registerNativeLocalValidator,
|
|
7
|
+
scrapeMetrics as scrapeNativeMetrics,
|
|
8
|
+
unregisterLocalValidator as unregisterNativeLocalValidator,
|
|
9
|
+
} from "@chainsafe/lodestar-z/metrics";
|
|
4
10
|
import {type PubkeyCache} from "@chainsafe/lodestar-z/pubkeys";
|
|
5
11
|
import {hasher} from "@chainsafe/persistent-merkle-tree";
|
|
6
12
|
import {BeaconApiMethods} from "@lodestar/api/beacon/server";
|
|
@@ -171,7 +177,13 @@ export class BeaconNode {
|
|
|
171
177
|
// monitoring relies on metrics data
|
|
172
178
|
opts.monitoring.endpoint
|
|
173
179
|
) {
|
|
174
|
-
|
|
180
|
+
if (opts.chain.nativeStateTransition) {
|
|
181
|
+
initNativeMetrics();
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
metrics = createMetrics(opts.metrics, anchorState.genesisTime, metricsRegistries, {
|
|
185
|
+
includeStateTransitionMetrics: !opts.chain.nativeStateTransition,
|
|
186
|
+
});
|
|
175
187
|
initBeaconMetrics(metrics, anchorState);
|
|
176
188
|
// Since the db is instantiated before this, metrics must be injected manually afterwards
|
|
177
189
|
db.setMetrics(metrics.db, metrics.flatFileStore);
|
|
@@ -185,7 +197,13 @@ export class BeaconNode {
|
|
|
185
197
|
config,
|
|
186
198
|
anchorState.genesisTime,
|
|
187
199
|
logger.child({module: LoggerModule.vmon}),
|
|
188
|
-
opts.validatorMonitor
|
|
200
|
+
opts.validatorMonitor,
|
|
201
|
+
opts.chain.nativeStateTransition
|
|
202
|
+
? {
|
|
203
|
+
registerLocalValidator: registerNativeLocalValidator,
|
|
204
|
+
unregisterLocalValidator: unregisterNativeLocalValidator,
|
|
205
|
+
}
|
|
206
|
+
: null
|
|
189
207
|
)
|
|
190
208
|
: null;
|
|
191
209
|
|
|
@@ -303,7 +321,17 @@ export class BeaconNode {
|
|
|
303
321
|
const metricsServer = opts.metrics.enabled
|
|
304
322
|
? await getHttpMetricsServer(opts.metrics, {
|
|
305
323
|
register: (metrics as Metrics).register,
|
|
306
|
-
getOtherMetrics: async () =>
|
|
324
|
+
getOtherMetrics: async () => {
|
|
325
|
+
const otherMetrics = await Promise.all([network.scrapeMetrics(), chain.archiveStore.scrapeMetrics()]);
|
|
326
|
+
if (opts.chain.nativeStateTransition) {
|
|
327
|
+
try {
|
|
328
|
+
otherMetrics.push(scrapeNativeMetrics());
|
|
329
|
+
} catch (e) {
|
|
330
|
+
logger.warn("Failed to scrape native state-transition metrics", {}, e as Error);
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
return otherMetrics;
|
|
334
|
+
},
|
|
307
335
|
logger: logger.child({module: LoggerModule.metrics}),
|
|
308
336
|
})
|
|
309
337
|
: null;
|
package/src/sync/range/chain.ts
CHANGED
|
@@ -225,6 +225,9 @@ export class SyncChain {
|
|
|
225
225
|
Math.floor((localFinalizedEpoch - this.lastEpochWithProcessBlocks) / EPOCHS_PER_BATCH) * EPOCHS_PER_BATCH;
|
|
226
226
|
this.advanceChain(lastEpochWithProcessBlocksAligned);
|
|
227
227
|
|
|
228
|
+
// stopSyncing() cleared the retry timer, but peers can still be in rate limit backoff
|
|
229
|
+
this.scheduleRateLimitBackoffRetry();
|
|
230
|
+
|
|
228
231
|
// Potentially download new batches and process pending
|
|
229
232
|
this.triggerBatchDownloader();
|
|
230
233
|
this.triggerBatchProcessor();
|
|
@@ -417,8 +420,10 @@ export class SyncChain {
|
|
|
417
420
|
this.rateLimitBackoffTimeout = setTimeout(
|
|
418
421
|
() => {
|
|
419
422
|
this.rateLimitBackoffTimeout = undefined;
|
|
420
|
-
|
|
423
|
+
// Must run before the downloader, it drops expired peers without triggering a download. If it ran
|
|
424
|
+
// after, a backoff expiring in between would leave the peer idle with no retry scheduled.
|
|
421
425
|
this.scheduleRateLimitBackoffRetry();
|
|
426
|
+
this.triggerBatchDownloader();
|
|
422
427
|
},
|
|
423
428
|
Math.max(0, retryAt - now)
|
|
424
429
|
);
|