@lodestar/validator 1.35.0-dev.549f58dd39 → 1.35.0-dev.5c65fa3b36

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.
Files changed (140) hide show
  1. package/lib/index.d.ts +7 -7
  2. package/lib/index.js +5 -5
  3. package/lib/index.js.map +1 -1
  4. package/lib/metrics.js +14 -14
  5. package/lib/metrics.js.map +1 -1
  6. package/lib/repositories/metaDataRepository.js.map +1 -1
  7. package/lib/services/attestation.js +27 -35
  8. package/lib/services/attestation.js.map +1 -1
  9. package/lib/services/attestationDuties.js +0 -1
  10. package/lib/services/attestationDuties.js.map +1 -1
  11. package/lib/services/blockDuties.d.ts +2 -2
  12. package/lib/services/blockDuties.js +3 -4
  13. package/lib/services/blockDuties.js.map +1 -1
  14. package/lib/services/emitter.d.ts +1 -1
  15. package/lib/services/externalSignerSync.js.map +1 -1
  16. package/lib/services/prepareBeaconProposer.js.map +1 -1
  17. package/lib/services/syncCommittee.js +22 -30
  18. package/lib/services/syncCommittee.js.map +1 -1
  19. package/lib/slashingProtection/index.d.ts +1 -1
  20. package/lib/slashingProtection/index.js.map +1 -1
  21. package/lib/util/clock.d.ts +0 -3
  22. package/lib/util/clock.js +0 -4
  23. package/lib/util/clock.js.map +1 -1
  24. package/lib/util/params.js +1 -17
  25. package/lib/util/params.js.map +1 -1
  26. package/package.json +16 -19
  27. package/lib/buckets.d.ts.map +0 -1
  28. package/lib/defaults.d.ts.map +0 -1
  29. package/lib/genesis.d.ts.map +0 -1
  30. package/lib/index.d.ts.map +0 -1
  31. package/lib/metrics.d.ts.map +0 -1
  32. package/lib/repositories/index.d.ts.map +0 -1
  33. package/lib/repositories/metaDataRepository.d.ts.map +0 -1
  34. package/lib/services/attestation.d.ts.map +0 -1
  35. package/lib/services/attestationDuties.d.ts.map +0 -1
  36. package/lib/services/block.d.ts.map +0 -1
  37. package/lib/services/blockDuties.d.ts.map +0 -1
  38. package/lib/services/chainHeaderTracker.d.ts.map +0 -1
  39. package/lib/services/doppelgangerService.d.ts.map +0 -1
  40. package/lib/services/emitter.d.ts.map +0 -1
  41. package/lib/services/externalSignerSync.d.ts.map +0 -1
  42. package/lib/services/indices.d.ts.map +0 -1
  43. package/lib/services/prepareBeaconProposer.d.ts.map +0 -1
  44. package/lib/services/syncCommittee.d.ts.map +0 -1
  45. package/lib/services/syncCommitteeDuties.d.ts.map +0 -1
  46. package/lib/services/syncingStatusTracker.d.ts.map +0 -1
  47. package/lib/services/utils.d.ts.map +0 -1
  48. package/lib/services/validatorStore.d.ts.map +0 -1
  49. package/lib/slashingProtection/attestation/attestationByTargetRepository.d.ts.map +0 -1
  50. package/lib/slashingProtection/attestation/attestationLowerBoundRepository.d.ts.map +0 -1
  51. package/lib/slashingProtection/attestation/errors.d.ts.map +0 -1
  52. package/lib/slashingProtection/attestation/index.d.ts.map +0 -1
  53. package/lib/slashingProtection/block/blockBySlotRepository.d.ts.map +0 -1
  54. package/lib/slashingProtection/block/errors.d.ts.map +0 -1
  55. package/lib/slashingProtection/block/index.d.ts.map +0 -1
  56. package/lib/slashingProtection/index.d.ts.map +0 -1
  57. package/lib/slashingProtection/interchange/errors.d.ts.map +0 -1
  58. package/lib/slashingProtection/interchange/formats/completeV4.d.ts.map +0 -1
  59. package/lib/slashingProtection/interchange/formats/index.d.ts.map +0 -1
  60. package/lib/slashingProtection/interchange/formats/v5.d.ts.map +0 -1
  61. package/lib/slashingProtection/interchange/index.d.ts.map +0 -1
  62. package/lib/slashingProtection/interchange/parseInterchange.d.ts.map +0 -1
  63. package/lib/slashingProtection/interchange/serializeInterchange.d.ts.map +0 -1
  64. package/lib/slashingProtection/interchange/types.d.ts.map +0 -1
  65. package/lib/slashingProtection/interface.d.ts.map +0 -1
  66. package/lib/slashingProtection/minMaxSurround/distanceStoreRepository.d.ts.map +0 -1
  67. package/lib/slashingProtection/minMaxSurround/errors.d.ts.map +0 -1
  68. package/lib/slashingProtection/minMaxSurround/index.d.ts.map +0 -1
  69. package/lib/slashingProtection/minMaxSurround/interface.d.ts.map +0 -1
  70. package/lib/slashingProtection/minMaxSurround/minMaxSurround.d.ts.map +0 -1
  71. package/lib/slashingProtection/types.d.ts.map +0 -1
  72. package/lib/slashingProtection/utils.d.ts.map +0 -1
  73. package/lib/types.d.ts.map +0 -1
  74. package/lib/util/batch.d.ts.map +0 -1
  75. package/lib/util/clock.d.ts.map +0 -1
  76. package/lib/util/difference.d.ts.map +0 -1
  77. package/lib/util/externalSignerClient.d.ts.map +0 -1
  78. package/lib/util/format.d.ts.map +0 -1
  79. package/lib/util/index.d.ts.map +0 -1
  80. package/lib/util/logger.d.ts.map +0 -1
  81. package/lib/util/params.d.ts.map +0 -1
  82. package/lib/util/url.d.ts.map +0 -1
  83. package/lib/validator.d.ts.map +0 -1
  84. package/src/buckets.ts +0 -30
  85. package/src/defaults.ts +0 -8
  86. package/src/genesis.ts +0 -19
  87. package/src/index.ts +0 -22
  88. package/src/metrics.ts +0 -417
  89. package/src/repositories/index.ts +0 -1
  90. package/src/repositories/metaDataRepository.ts +0 -42
  91. package/src/services/attestation.ts +0 -362
  92. package/src/services/attestationDuties.ts +0 -406
  93. package/src/services/block.ts +0 -261
  94. package/src/services/blockDuties.ts +0 -217
  95. package/src/services/chainHeaderTracker.ts +0 -89
  96. package/src/services/doppelgangerService.ts +0 -286
  97. package/src/services/emitter.ts +0 -43
  98. package/src/services/externalSignerSync.ts +0 -81
  99. package/src/services/indices.ts +0 -165
  100. package/src/services/prepareBeaconProposer.ts +0 -119
  101. package/src/services/syncCommittee.ts +0 -338
  102. package/src/services/syncCommitteeDuties.ts +0 -337
  103. package/src/services/syncingStatusTracker.ts +0 -74
  104. package/src/services/utils.ts +0 -58
  105. package/src/services/validatorStore.ts +0 -830
  106. package/src/slashingProtection/attestation/attestationByTargetRepository.ts +0 -77
  107. package/src/slashingProtection/attestation/attestationLowerBoundRepository.ts +0 -44
  108. package/src/slashingProtection/attestation/errors.ts +0 -66
  109. package/src/slashingProtection/attestation/index.ts +0 -171
  110. package/src/slashingProtection/block/blockBySlotRepository.ts +0 -78
  111. package/src/slashingProtection/block/errors.ts +0 -28
  112. package/src/slashingProtection/block/index.ts +0 -94
  113. package/src/slashingProtection/index.ts +0 -95
  114. package/src/slashingProtection/interchange/errors.ts +0 -15
  115. package/src/slashingProtection/interchange/formats/completeV4.ts +0 -125
  116. package/src/slashingProtection/interchange/formats/index.ts +0 -7
  117. package/src/slashingProtection/interchange/formats/v5.ts +0 -120
  118. package/src/slashingProtection/interchange/index.ts +0 -5
  119. package/src/slashingProtection/interchange/parseInterchange.ts +0 -55
  120. package/src/slashingProtection/interchange/serializeInterchange.ts +0 -35
  121. package/src/slashingProtection/interchange/types.ts +0 -18
  122. package/src/slashingProtection/interface.ts +0 -28
  123. package/src/slashingProtection/minMaxSurround/distanceStoreRepository.ts +0 -57
  124. package/src/slashingProtection/minMaxSurround/errors.ts +0 -27
  125. package/src/slashingProtection/minMaxSurround/index.ts +0 -4
  126. package/src/slashingProtection/minMaxSurround/interface.ts +0 -23
  127. package/src/slashingProtection/minMaxSurround/minMaxSurround.ts +0 -104
  128. package/src/slashingProtection/types.ts +0 -12
  129. package/src/slashingProtection/utils.ts +0 -42
  130. package/src/types.ts +0 -31
  131. package/src/util/batch.ts +0 -15
  132. package/src/util/clock.ts +0 -170
  133. package/src/util/difference.ts +0 -10
  134. package/src/util/externalSignerClient.ts +0 -277
  135. package/src/util/format.ts +0 -3
  136. package/src/util/index.ts +0 -6
  137. package/src/util/logger.ts +0 -51
  138. package/src/util/params.ts +0 -320
  139. package/src/util/url.ts +0 -16
  140. package/src/validator.ts +0 -418
@@ -1,74 +0,0 @@
1
- import {ApiClient, routes} from "@lodestar/api";
2
- import {Slot} from "@lodestar/types";
3
- import {Logger} from "@lodestar/utils";
4
- import {BeaconHealth, Metrics} from "../metrics.js";
5
- import {IClock} from "../util/clock.js";
6
-
7
- export type SyncingStatus = routes.node.SyncingStatus;
8
-
9
- type RunOnResyncedFn = (slot: Slot, signal: AbortSignal) => Promise<void>;
10
-
11
- /**
12
- * Track the syncing status of connected beacon node(s)
13
- */
14
- export class SyncingStatusTracker {
15
- private prevSyncingStatus?: SyncingStatus | Error;
16
-
17
- private readonly fns: RunOnResyncedFn[] = [];
18
-
19
- constructor(
20
- private readonly logger: Logger,
21
- private readonly api: ApiClient,
22
- private readonly clock: IClock,
23
- private readonly metrics: Metrics | null
24
- ) {
25
- this.clock.runEverySlot(this.checkSyncingStatus);
26
- }
27
-
28
- /**
29
- * Run function when node status changes from syncing to synced
30
- *
31
- * Note: does not consider if execution client is offline or syncing and
32
- * hence it is not useful to schedule tasks that require a non-optimistic node.
33
- */
34
- runOnResynced(fn: RunOnResyncedFn): void {
35
- this.fns.push(fn);
36
- }
37
-
38
- private checkSyncingStatus = async (slot: Slot, signal: AbortSignal): Promise<void> => {
39
- try {
40
- const syncingStatus = (await this.api.node.getSyncingStatus()).value();
41
- const {isSyncing, headSlot, syncDistance, isOptimistic, elOffline} = syncingStatus;
42
- const prevErrorOrSyncing = this.prevSyncingStatus instanceof Error || this.prevSyncingStatus?.isSyncing === true;
43
-
44
- if (isSyncing === true) {
45
- this.logger.warn("Node is syncing", {slot, headSlot, syncDistance});
46
- } else if (this.prevSyncingStatus === undefined || prevErrorOrSyncing) {
47
- this.logger.info("Node is synced", {slot, headSlot, isOptimistic, elOffline});
48
- }
49
- this.logger.verbose("Node syncing status", {slot, ...syncingStatus});
50
-
51
- this.prevSyncingStatus = syncingStatus;
52
-
53
- this.metrics?.beaconHealth.set(
54
- !isSyncing && !isOptimistic && !elOffline ? BeaconHealth.READY : BeaconHealth.SYNCING
55
- );
56
-
57
- if (prevErrorOrSyncing && isSyncing === false) {
58
- await Promise.all(
59
- this.fns.map((fn) =>
60
- fn(slot, signal).catch((e) => this.logger.error("Error calling resynced event handler", e))
61
- )
62
- );
63
- }
64
- } catch (e) {
65
- // Error likely due to node being offline. In any case, handle failure to
66
- // check syncing status the same way as if node was previously syncing
67
- this.prevSyncingStatus = e as Error;
68
-
69
- this.metrics?.beaconHealth.set(BeaconHealth.ERROR);
70
-
71
- this.logger.error("Failed to check syncing status", {slot}, this.prevSyncingStatus);
72
- }
73
- };
74
- }
@@ -1,58 +0,0 @@
1
- import {SYNC_COMMITTEE_SUBNET_SIZE} from "@lodestar/params";
2
- import {CommitteeIndex, SubcommitteeIndex} from "@lodestar/types";
3
- import {AttDutyAndProof} from "./attestationDuties.js";
4
- import {SyncDutyAndProofs, SyncDutySubnet, SyncSelectionProof} from "./syncCommitteeDuties.js";
5
-
6
- /** Sync committee duty associated to a single sub committee subnet */
7
- export type SubcommitteeDuty = {
8
- duty: SyncDutySubnet;
9
- selectionProof: SyncSelectionProof["selectionProof"];
10
- };
11
-
12
- export function groupAttDutiesByCommitteeIndex(duties: AttDutyAndProof[]): Map<CommitteeIndex, AttDutyAndProof[]> {
13
- const dutiesByCommitteeIndex = new Map<CommitteeIndex, AttDutyAndProof[]>();
14
-
15
- for (const dutyAndProof of duties) {
16
- const {committeeIndex} = dutyAndProof.duty;
17
- let dutyAndProofArr = dutiesByCommitteeIndex.get(committeeIndex);
18
- if (!dutyAndProofArr) {
19
- dutyAndProofArr = [];
20
- dutiesByCommitteeIndex.set(committeeIndex, dutyAndProofArr);
21
- }
22
- dutyAndProofArr.push(dutyAndProof);
23
- }
24
-
25
- return dutiesByCommitteeIndex;
26
- }
27
-
28
- export function groupSyncDutiesBySubcommitteeIndex(
29
- duties: SyncDutyAndProofs[]
30
- ): Map<SubcommitteeIndex, SubcommitteeDuty[]> {
31
- const dutiesBySubcommitteeIndex = new Map<SubcommitteeIndex, SubcommitteeDuty[]>();
32
-
33
- for (const validatorDuty of duties) {
34
- for (const {selectionProof, subcommitteeIndex} of validatorDuty.selectionProofs) {
35
- let dutyAndProofArr = dutiesBySubcommitteeIndex.get(subcommitteeIndex);
36
- if (!dutyAndProofArr) {
37
- dutyAndProofArr = [];
38
- dutiesBySubcommitteeIndex.set(subcommitteeIndex, dutyAndProofArr);
39
- }
40
- dutyAndProofArr.push({duty: validatorDuty.duty, selectionProof: selectionProof});
41
- }
42
- }
43
-
44
- return dutiesBySubcommitteeIndex;
45
- }
46
-
47
- /**
48
- * Given a list of indexes of a sync committee returns the list of unique subnet numbers the indexes are part of
49
- */
50
- export function syncCommitteeIndicesToSubnets(indexesInCommittee: number[]): number[] {
51
- const subnets = new Set<number>();
52
-
53
- for (const indexInCommittee of indexesInCommittee) {
54
- subnets.add(Math.floor(indexInCommittee / SYNC_COMMITTEE_SUBNET_SIZE));
55
- }
56
-
57
- return Array.from(subnets);
58
- }