@lodestar/validator 1.35.0-dev.549f58dd39 → 1.35.0-dev.56313c7299

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 (173) 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 +3 -4
  7. package/lib/repositories/metaDataRepository.js.map +1 -1
  8. package/lib/services/attestation.js +60 -77
  9. package/lib/services/attestation.js.map +1 -1
  10. package/lib/services/attestationDuties.js +98 -105
  11. package/lib/services/attestationDuties.js.map +1 -1
  12. package/lib/services/block.js +56 -64
  13. package/lib/services/block.js.map +1 -1
  14. package/lib/services/blockDuties.d.ts +2 -2
  15. package/lib/services/blockDuties.js +26 -35
  16. package/lib/services/blockDuties.js.map +1 -1
  17. package/lib/services/chainHeaderTracker.js +27 -30
  18. package/lib/services/chainHeaderTracker.js.map +1 -1
  19. package/lib/services/doppelgangerService.js +45 -52
  20. package/lib/services/doppelgangerService.js.map +1 -1
  21. package/lib/services/emitter.d.ts +1 -1
  22. package/lib/services/externalSignerSync.js.map +1 -1
  23. package/lib/services/indices.js +5 -8
  24. package/lib/services/indices.js.map +1 -1
  25. package/lib/services/prepareBeaconProposer.js.map +1 -1
  26. package/lib/services/syncCommittee.js +61 -80
  27. package/lib/services/syncCommittee.js.map +1 -1
  28. package/lib/services/syncCommitteeDuties.js +23 -28
  29. package/lib/services/syncCommitteeDuties.js.map +1 -1
  30. package/lib/services/syncingStatusTracker.js +27 -32
  31. package/lib/services/syncingStatusTracker.js.map +1 -1
  32. package/lib/services/validatorStore.js +3 -9
  33. package/lib/services/validatorStore.js.map +1 -1
  34. package/lib/slashingProtection/attestation/attestationByTargetRepository.js +3 -7
  35. package/lib/slashingProtection/attestation/attestationByTargetRepository.js.map +1 -1
  36. package/lib/slashingProtection/attestation/attestationLowerBoundRepository.js +3 -5
  37. package/lib/slashingProtection/attestation/attestationLowerBoundRepository.js.map +1 -1
  38. package/lib/slashingProtection/attestation/index.js +0 -3
  39. package/lib/slashingProtection/attestation/index.js.map +1 -1
  40. package/lib/slashingProtection/block/blockBySlotRepository.js +3 -7
  41. package/lib/slashingProtection/block/blockBySlotRepository.js.map +1 -1
  42. package/lib/slashingProtection/block/index.js +0 -1
  43. package/lib/slashingProtection/block/index.js.map +1 -1
  44. package/lib/slashingProtection/index.d.ts +1 -1
  45. package/lib/slashingProtection/index.js +0 -3
  46. package/lib/slashingProtection/index.js.map +1 -1
  47. package/lib/slashingProtection/minMaxSurround/distanceStoreRepository.js +0 -8
  48. package/lib/slashingProtection/minMaxSurround/distanceStoreRepository.js.map +1 -1
  49. package/lib/slashingProtection/minMaxSurround/minMaxSurround.js +0 -2
  50. package/lib/slashingProtection/minMaxSurround/minMaxSurround.js.map +1 -1
  51. package/lib/slashingProtection/utils.d.ts +1 -1
  52. package/lib/util/clock.d.ts +0 -3
  53. package/lib/util/clock.js +1 -9
  54. package/lib/util/clock.js.map +1 -1
  55. package/lib/util/params.js +1 -17
  56. package/lib/util/params.js.map +1 -1
  57. package/lib/validator.js +0 -15
  58. package/lib/validator.js.map +1 -1
  59. package/package.json +16 -19
  60. package/lib/buckets.d.ts.map +0 -1
  61. package/lib/defaults.d.ts.map +0 -1
  62. package/lib/genesis.d.ts.map +0 -1
  63. package/lib/index.d.ts.map +0 -1
  64. package/lib/metrics.d.ts.map +0 -1
  65. package/lib/repositories/index.d.ts.map +0 -1
  66. package/lib/repositories/metaDataRepository.d.ts.map +0 -1
  67. package/lib/services/attestation.d.ts.map +0 -1
  68. package/lib/services/attestationDuties.d.ts.map +0 -1
  69. package/lib/services/block.d.ts.map +0 -1
  70. package/lib/services/blockDuties.d.ts.map +0 -1
  71. package/lib/services/chainHeaderTracker.d.ts.map +0 -1
  72. package/lib/services/doppelgangerService.d.ts.map +0 -1
  73. package/lib/services/emitter.d.ts.map +0 -1
  74. package/lib/services/externalSignerSync.d.ts.map +0 -1
  75. package/lib/services/indices.d.ts.map +0 -1
  76. package/lib/services/prepareBeaconProposer.d.ts.map +0 -1
  77. package/lib/services/syncCommittee.d.ts.map +0 -1
  78. package/lib/services/syncCommitteeDuties.d.ts.map +0 -1
  79. package/lib/services/syncingStatusTracker.d.ts.map +0 -1
  80. package/lib/services/utils.d.ts.map +0 -1
  81. package/lib/services/validatorStore.d.ts.map +0 -1
  82. package/lib/slashingProtection/attestation/attestationByTargetRepository.d.ts.map +0 -1
  83. package/lib/slashingProtection/attestation/attestationLowerBoundRepository.d.ts.map +0 -1
  84. package/lib/slashingProtection/attestation/errors.d.ts.map +0 -1
  85. package/lib/slashingProtection/attestation/index.d.ts.map +0 -1
  86. package/lib/slashingProtection/block/blockBySlotRepository.d.ts.map +0 -1
  87. package/lib/slashingProtection/block/errors.d.ts.map +0 -1
  88. package/lib/slashingProtection/block/index.d.ts.map +0 -1
  89. package/lib/slashingProtection/index.d.ts.map +0 -1
  90. package/lib/slashingProtection/interchange/errors.d.ts.map +0 -1
  91. package/lib/slashingProtection/interchange/formats/completeV4.d.ts.map +0 -1
  92. package/lib/slashingProtection/interchange/formats/index.d.ts.map +0 -1
  93. package/lib/slashingProtection/interchange/formats/v5.d.ts.map +0 -1
  94. package/lib/slashingProtection/interchange/index.d.ts.map +0 -1
  95. package/lib/slashingProtection/interchange/parseInterchange.d.ts.map +0 -1
  96. package/lib/slashingProtection/interchange/serializeInterchange.d.ts.map +0 -1
  97. package/lib/slashingProtection/interchange/types.d.ts.map +0 -1
  98. package/lib/slashingProtection/interface.d.ts.map +0 -1
  99. package/lib/slashingProtection/minMaxSurround/distanceStoreRepository.d.ts.map +0 -1
  100. package/lib/slashingProtection/minMaxSurround/errors.d.ts.map +0 -1
  101. package/lib/slashingProtection/minMaxSurround/index.d.ts.map +0 -1
  102. package/lib/slashingProtection/minMaxSurround/interface.d.ts.map +0 -1
  103. package/lib/slashingProtection/minMaxSurround/minMaxSurround.d.ts.map +0 -1
  104. package/lib/slashingProtection/types.d.ts.map +0 -1
  105. package/lib/slashingProtection/utils.d.ts.map +0 -1
  106. package/lib/types.d.ts.map +0 -1
  107. package/lib/util/batch.d.ts.map +0 -1
  108. package/lib/util/clock.d.ts.map +0 -1
  109. package/lib/util/difference.d.ts.map +0 -1
  110. package/lib/util/externalSignerClient.d.ts.map +0 -1
  111. package/lib/util/format.d.ts.map +0 -1
  112. package/lib/util/index.d.ts.map +0 -1
  113. package/lib/util/logger.d.ts.map +0 -1
  114. package/lib/util/params.d.ts.map +0 -1
  115. package/lib/util/url.d.ts.map +0 -1
  116. package/lib/validator.d.ts.map +0 -1
  117. package/src/buckets.ts +0 -30
  118. package/src/defaults.ts +0 -8
  119. package/src/genesis.ts +0 -19
  120. package/src/index.ts +0 -22
  121. package/src/metrics.ts +0 -417
  122. package/src/repositories/index.ts +0 -1
  123. package/src/repositories/metaDataRepository.ts +0 -42
  124. package/src/services/attestation.ts +0 -362
  125. package/src/services/attestationDuties.ts +0 -406
  126. package/src/services/block.ts +0 -261
  127. package/src/services/blockDuties.ts +0 -217
  128. package/src/services/chainHeaderTracker.ts +0 -89
  129. package/src/services/doppelgangerService.ts +0 -286
  130. package/src/services/emitter.ts +0 -43
  131. package/src/services/externalSignerSync.ts +0 -81
  132. package/src/services/indices.ts +0 -165
  133. package/src/services/prepareBeaconProposer.ts +0 -119
  134. package/src/services/syncCommittee.ts +0 -338
  135. package/src/services/syncCommitteeDuties.ts +0 -337
  136. package/src/services/syncingStatusTracker.ts +0 -74
  137. package/src/services/utils.ts +0 -58
  138. package/src/services/validatorStore.ts +0 -830
  139. package/src/slashingProtection/attestation/attestationByTargetRepository.ts +0 -77
  140. package/src/slashingProtection/attestation/attestationLowerBoundRepository.ts +0 -44
  141. package/src/slashingProtection/attestation/errors.ts +0 -66
  142. package/src/slashingProtection/attestation/index.ts +0 -171
  143. package/src/slashingProtection/block/blockBySlotRepository.ts +0 -78
  144. package/src/slashingProtection/block/errors.ts +0 -28
  145. package/src/slashingProtection/block/index.ts +0 -94
  146. package/src/slashingProtection/index.ts +0 -95
  147. package/src/slashingProtection/interchange/errors.ts +0 -15
  148. package/src/slashingProtection/interchange/formats/completeV4.ts +0 -125
  149. package/src/slashingProtection/interchange/formats/index.ts +0 -7
  150. package/src/slashingProtection/interchange/formats/v5.ts +0 -120
  151. package/src/slashingProtection/interchange/index.ts +0 -5
  152. package/src/slashingProtection/interchange/parseInterchange.ts +0 -55
  153. package/src/slashingProtection/interchange/serializeInterchange.ts +0 -35
  154. package/src/slashingProtection/interchange/types.ts +0 -18
  155. package/src/slashingProtection/interface.ts +0 -28
  156. package/src/slashingProtection/minMaxSurround/distanceStoreRepository.ts +0 -57
  157. package/src/slashingProtection/minMaxSurround/errors.ts +0 -27
  158. package/src/slashingProtection/minMaxSurround/index.ts +0 -4
  159. package/src/slashingProtection/minMaxSurround/interface.ts +0 -23
  160. package/src/slashingProtection/minMaxSurround/minMaxSurround.ts +0 -104
  161. package/src/slashingProtection/types.ts +0 -12
  162. package/src/slashingProtection/utils.ts +0 -42
  163. package/src/types.ts +0 -31
  164. package/src/util/batch.ts +0 -15
  165. package/src/util/clock.ts +0 -170
  166. package/src/util/difference.ts +0 -10
  167. package/src/util/externalSignerClient.ts +0 -277
  168. package/src/util/format.ts +0 -3
  169. package/src/util/index.ts +0 -6
  170. package/src/util/logger.ts +0 -51
  171. package/src/util/params.ts +0 -320
  172. package/src/util/url.ts +0 -16
  173. 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
- }