@lodestar/beacon-node 1.18.0-dev.e10a54d8d5 → 1.18.0-dev.ea7c6c6bb6

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 (37) hide show
  1. package/lib/api/impl/beacon/state/utils.js +6 -4
  2. package/lib/api/impl/beacon/state/utils.js.map +1 -1
  3. package/lib/chain/chain.d.ts +1 -5
  4. package/lib/chain/chain.js +1 -10
  5. package/lib/chain/chain.js.map +1 -1
  6. package/lib/chain/interface.d.ts +1 -6
  7. package/lib/chain/stateCache/index.d.ts +1 -1
  8. package/lib/chain/stateCache/index.js +1 -1
  9. package/lib/chain/stateCache/index.js.map +1 -1
  10. package/lib/chain/stateCache/persistentCheckpointsCache.js +2 -2
  11. package/lib/chain/stateCache/persistentCheckpointsCache.js.map +1 -1
  12. package/lib/chain/stateCache/{inMemoryCheckpointsCache.d.ts → stateContextCheckpointsCache.d.ts} +1 -7
  13. package/lib/chain/stateCache/{inMemoryCheckpointsCache.js → stateContextCheckpointsCache.js} +4 -5
  14. package/lib/chain/stateCache/stateContextCheckpointsCache.js.map +1 -0
  15. package/lib/metrics/metrics/lodestar.d.ts +2 -2
  16. package/lib/metrics/metrics/lodestar.js +4 -4
  17. package/lib/metrics/metrics/lodestar.js.map +1 -1
  18. package/lib/network/core/metrics.d.ts +3 -2
  19. package/lib/network/core/metrics.js.map +1 -1
  20. package/lib/network/core/networkCore.js +6 -3
  21. package/lib/network/core/networkCore.js.map +1 -1
  22. package/lib/network/options.js +2 -0
  23. package/lib/network/options.js.map +1 -1
  24. package/lib/network/subnets/attnetsService.d.ts +44 -38
  25. package/lib/network/subnets/attnetsService.js +149 -160
  26. package/lib/network/subnets/attnetsService.js.map +1 -1
  27. package/lib/network/subnets/dllAttnetsService.d.ts +112 -0
  28. package/lib/network/subnets/dllAttnetsService.js +336 -0
  29. package/lib/network/subnets/dllAttnetsService.js.map +1 -0
  30. package/lib/network/subnets/index.d.ts +1 -0
  31. package/lib/network/subnets/index.js +1 -0
  32. package/lib/network/subnets/index.js.map +1 -1
  33. package/lib/network/subnets/interface.d.ts +1 -0
  34. package/lib/util/profile.js +1 -4
  35. package/lib/util/profile.js.map +1 -1
  36. package/package.json +14 -14
  37. package/lib/chain/stateCache/inMemoryCheckpointsCache.js.map +0 -1
@@ -1,38 +1,37 @@
1
- import { ATTESTATION_SUBNET_COUNT, EPOCHS_PER_RANDOM_SUBNET_SUBSCRIPTION, SLOTS_PER_EPOCH, } from "@lodestar/params";
1
+ import { computeStartSlotAtEpoch } from "@lodestar/state-transition";
2
+ import { ATTESTATION_SUBNET_COUNT, EPOCHS_PER_RANDOM_SUBNET_SUBSCRIPTION, RANDOM_SUBNETS_PER_VALIDATOR, SLOTS_PER_EPOCH, } from "@lodestar/params";
2
3
  import { ssz } from "@lodestar/types";
3
- import { MapDef } from "@lodestar/utils";
4
+ import { MapDef, randBetween } from "@lodestar/utils";
5
+ import { shuffle } from "../../util/shuffle.js";
4
6
  import { ClockEvent } from "../../util/clock.js";
5
7
  import { GossipType } from "../gossip/index.js";
6
8
  import { SubnetMap } from "../peers/utils/index.js";
7
9
  import { getActiveForks } from "../forks.js";
8
- import { stringifyGossipTopic } from "../gossip/topic.js";
9
- import { GOSSIP_D_LOW } from "../gossip/scoringParameters.js";
10
- import { computeSubscribedSubnet } from "./util.js";
10
+ /**
11
+ * The time (in slots) before a last seen validator is considered absent and we unsubscribe from the random
12
+ * gossip topics that we subscribed to due to the validator connection.
13
+ */
14
+ const LAST_SEEN_VALIDATOR_TIMEOUT = 150;
11
15
  const gossipType = GossipType.beacon_attestation;
12
16
  export var SubnetSource;
13
17
  (function (SubnetSource) {
14
18
  SubnetSource["committee"] = "committee";
15
- SubnetSource["longLived"] = "long_lived";
19
+ SubnetSource["random"] = "random";
16
20
  })(SubnetSource || (SubnetSource = {}));
17
21
  /**
18
- * This value means node is not able to form stable mesh.
19
- */
20
- const NOT_ABLE_TO_FORM_STABLE_MESH_SEC = -1;
21
- /**
22
- * Manage deleterministic long lived (DLL) subnets and short lived subnets.
23
- * - PeerManager uses attnetsService to know which peers are required for duties and long lived subscriptions
22
+ * Manage random (long lived) subnets and committee (short lived) subnets.
23
+ * - PeerManager uses attnetsService to know which peers are required for duties
24
24
  * - Network call addCommitteeSubscriptions() from API calls
25
25
  * - Gossip handler checks shouldProcess to know if validator is aggregator
26
26
  */
27
27
  export class AttnetsService {
28
- constructor(config, clock, gossip, metadata, logger, metrics, nodeId, opts) {
28
+ constructor(config, clock, gossip, metadata, logger, metrics, opts) {
29
29
  this.config = config;
30
30
  this.clock = clock;
31
31
  this.gossip = gossip;
32
32
  this.metadata = metadata;
33
33
  this.logger = logger;
34
34
  this.metrics = metrics;
35
- this.nodeId = nodeId;
36
35
  this.opts = opts;
37
36
  /** Committee subnets - PeerManager must find peers for those */
38
37
  this.committeeSubnets = new SubnetMap();
@@ -41,59 +40,55 @@ export class AttnetsService {
41
40
  * This class will tell gossip to subscribe and un-subscribe
42
41
  * If a value exists for `SubscriptionId` it means that gossip subscription is active in network.gossip
43
42
  */
44
- this.shortLivedSubscriptions = new SubnetMap();
45
- /** ${SUBNETS_PER_NODE} long lived subscriptions, may overlap with `shortLivedSubscriptions` */
46
- this.longLivedSubscriptions = new Set();
43
+ this.subscriptionsCommittee = new SubnetMap();
44
+ /** Same as `subscriptionsCommittee` but for long-lived subnets. May overlap with `subscriptionsCommittee` */
45
+ this.subscriptionsRandom = new SubnetMap();
47
46
  /**
48
- * Map of an aggregator at a slot and AggregatorDutyInfo
47
+ * Map of an aggregator at a slot and subnet
49
48
  * Used to determine if we should process an attestation.
50
49
  */
51
- this.aggregatorSlotSubnet = new MapDef(() => new Map());
50
+ this.aggregatorSlotSubnet = new MapDef(() => new Set());
51
+ /**
52
+ * A collection of seen validators. These dictate how many random subnets we should be
53
+ * subscribed to. As these time out, we unsubscribe from the required random subnets and update our ENR.
54
+ * This is a map of validator index and its last active slot.
55
+ */
56
+ this.knownValidators = new Map();
52
57
  /**
53
58
  * Run per slot.
54
59
  * - Subscribe to gossip subnets 2 slots in advance
55
60
  * - Unsubscribe from expired subnets
56
- * - Track time to stable mesh if not yet formed
57
61
  */
58
62
  this.onSlot = (clockSlot) => {
59
63
  try {
60
- setTimeout(() => {
61
- this.onHalfSlot(clockSlot);
62
- }, this.config.SECONDS_PER_SLOT * 0.5 * 1000);
63
- for (const [dutiedSlot, dutiedInfo] of this.aggregatorSlotSubnet.entries()) {
64
+ for (const [dutiedSlot, subnets] of this.aggregatorSlotSubnet.entries()) {
64
65
  if (dutiedSlot === clockSlot + this.opts.slotsToSubscribeBeforeAggregatorDuty) {
65
66
  // Trigger gossip subscription first, in batch
66
- if (dutiedInfo.size > 0) {
67
- this.subscribeToSubnets(Array.from(dutiedInfo.keys()), SubnetSource.committee);
67
+ if (subnets.size > 0) {
68
+ this.subscribeToSubnets(Array.from(subnets), SubnetSource.committee);
68
69
  }
69
70
  // Then, register the subscriptions
70
- for (const subnet of dutiedInfo.keys()) {
71
- this.shortLivedSubscriptions.request({ subnet, toSlot: dutiedSlot });
72
- }
71
+ Array.from(subnets).map((subnet) => this.subscriptionsCommittee.request({ subnet, toSlot: dutiedSlot }));
73
72
  }
74
- this.trackTimeToStableMesh(clockSlot, dutiedSlot, dutiedInfo);
75
73
  }
74
+ // For node >= 64 validators, we should consistently subscribe to all subnets
75
+ // it's important to check random subnets first
76
+ // See https://github.com/ChainSafe/lodestar/issues/4929
77
+ this.unsubscribeExpiredRandomSubnets(clockSlot);
76
78
  this.unsubscribeExpiredCommitteeSubnets(clockSlot);
77
- this.pruneExpiredAggregator(clockSlot);
78
79
  }
79
80
  catch (e) {
80
81
  this.logger.error("Error on AttnetsService.onSlot", { slot: clockSlot }, e);
81
82
  }
82
83
  };
83
- this.onHalfSlot = (clockSlot) => {
84
- for (const [dutiedSlot, dutiedInfo] of this.aggregatorSlotSubnet.entries()) {
85
- this.trackTimeToStableMesh(clockSlot, dutiedSlot, dutiedInfo);
86
- }
87
- };
88
84
  /**
89
85
  * Run per epoch, clean-up operations that are not urgent
90
- * Subscribe to new random subnets every EPOCHS_PER_RANDOM_SUBNET_SUBSCRIPTION epochs
91
86
  */
92
87
  this.onEpoch = (epoch) => {
93
88
  try {
94
- if (epoch % EPOCHS_PER_RANDOM_SUBNET_SUBSCRIPTION === 0) {
95
- this.recomputeLongLivedSubnets();
96
- }
89
+ const slot = computeStartSlotAtEpoch(epoch);
90
+ this.pruneExpiredKnownValidators(slot);
91
+ this.pruneExpiredAggregator(slot);
97
92
  }
98
93
  catch (e) {
99
94
  this.logger.error("Error on AttnetsService.onEpoch", { epoch }, e);
@@ -106,10 +101,11 @@ export class AttnetsService {
106
101
  this.committeeSubnets.request({ subnet, toSlot: Infinity });
107
102
  }
108
103
  }
104
+ this.randBetweenFn = this.opts.randBetweenFn ?? randBetween;
105
+ this.shuffleFn = this.opts.shuffleFn ?? shuffle;
109
106
  if (metrics) {
110
- metrics.attnetsService.longLivedSubscriptions.addCollect(() => this.onScrapeLodestarMetrics(metrics));
107
+ metrics.attnetsService.subscriptionsRandom.addCollect(() => this.onScrapeLodestarMetrics(metrics));
111
108
  }
112
- this.recomputeLongLivedSubnets();
113
109
  this.clock.on(ClockEvent.slot, this.onSlot);
114
110
  this.clock.on(ClockEvent.epoch, this.onEpoch);
115
111
  }
@@ -118,34 +114,32 @@ export class AttnetsService {
118
114
  this.clock.off(ClockEvent.epoch, this.onEpoch);
119
115
  }
120
116
  /**
121
- * Get all active subnets for the hearbeat:
122
- * - committeeSubnets so that submitted attestations can be spread to the network
123
- * - longLivedSubscriptions because other peers based on this node's ENR for their submitted attestations
117
+ * Get all active subnets for the hearbeat.
124
118
  */
125
119
  getActiveSubnets() {
126
- const shortLivedSubnets = this.committeeSubnets.getActiveTtl(this.clock.currentSlot);
127
- const longLivedSubscriptionsToSlot = (Math.floor(this.clock.currentEpoch / EPOCHS_PER_RANDOM_SUBNET_SUBSCRIPTION) + 1) *
128
- EPOCHS_PER_RANDOM_SUBNET_SUBSCRIPTION *
129
- SLOTS_PER_EPOCH;
130
- const longLivedSubnets = Array.from(this.longLivedSubscriptions).map((subnet) => ({
131
- subnet,
132
- toSlot: longLivedSubscriptionsToSlot,
133
- }));
134
- // could be overlap, PeerDiscovery will handle it
135
- return [...shortLivedSubnets, ...longLivedSubnets];
120
+ // Omit subscriptionsRandom, not necessary to force the network component to keep peers on that subnets
121
+ return this.committeeSubnets.getActiveTtl(this.clock.currentSlot);
136
122
  }
137
123
  /**
138
124
  * Called from the API when validator is a part of a committee.
139
125
  */
140
126
  addCommitteeSubscriptions(subscriptions) {
141
- for (const { subnet, slot, isAggregator } of subscriptions) {
127
+ const currentSlot = this.clock.currentSlot;
128
+ let addedknownValidators = false;
129
+ for (const { validatorIndex, subnet, slot, isAggregator } of subscriptions) {
130
+ // Add known validator
131
+ if (!this.knownValidators.has(validatorIndex))
132
+ addedknownValidators = true;
133
+ this.knownValidators.set(validatorIndex, currentSlot);
142
134
  // the peer-manager heartbeat will help find the subnet
143
135
  this.committeeSubnets.request({ subnet, toSlot: slot + 1 });
144
136
  if (isAggregator) {
145
137
  // need exact slot here
146
- this.aggregatorSlotSubnet.getOrDefault(slot).set(subnet, null);
138
+ this.aggregatorSlotSubnet.getOrDefault(slot).add(subnet);
147
139
  }
148
140
  }
141
+ if (addedknownValidators)
142
+ this.rebalanceRandomSubnets();
149
143
  }
150
144
  /**
151
145
  * Check if a subscription is still active before handling a gossip object
@@ -156,25 +150,16 @@ export class AttnetsService {
156
150
  }
157
151
  return this.aggregatorSlotSubnet.getOrDefault(slot).has(subnet);
158
152
  }
159
- /**
160
- * TODO-dll: clarify how many epochs before the fork we should subscribe to the new fork
161
- * Call ONLY ONCE: Two epoch before the fork, re-subscribe all existing random subscriptions to the new fork
162
- **/
153
+ /** Call ONLY ONCE: Two epoch before the fork, re-subscribe all existing random subscriptions to the new fork */
163
154
  subscribeSubnetsToNextFork(nextFork) {
164
- this.logger.info("Subscribing to long lived attnets to next fork", {
165
- nextFork,
166
- subnets: Array.from(this.longLivedSubscriptions).join(","),
167
- });
168
- for (const subnet of this.longLivedSubscriptions) {
155
+ this.logger.info("Subscribing to random attnets to next fork", { nextFork });
156
+ for (const subnet of this.subscriptionsRandom.getAll()) {
169
157
  this.gossip.subscribeTopic({ type: gossipType, fork: nextFork, subnet });
170
158
  }
171
159
  }
172
- /**
173
- * TODO-dll: clarify how many epochs after the fork we should unsubscribe to the new fork
174
- * Call ONLY ONCE: Two epochs after the fork, un-subscribe all subnets from the old fork
175
- **/
160
+ /** Call ONLY ONCE: Two epochs after the fork, un-subscribe all subnets from the old fork */
176
161
  unsubscribeSubnetsFromPrevFork(prevFork) {
177
- this.logger.info("Unsubscribing to long lived attnets from prev fork", { prevFork });
162
+ this.logger.info("Unsubscribing to random attnets from prev fork", { prevFork });
178
163
  for (let subnet = 0; subnet < ATTESTATION_SUBNET_COUNT; subnet++) {
179
164
  if (!this.opts.subscribeAllSubnets) {
180
165
  this.gossip.unsubscribeTopic({ type: gossipType, fork: prevFork, subnet });
@@ -182,95 +167,111 @@ export class AttnetsService {
182
167
  }
183
168
  }
184
169
  /**
185
- * Track time to form stable mesh if not yet formed
170
+ * Unsubscribe to a committee subnet from subscribedCommitteeSubnets.
171
+ * If a random subnet is present, we do not unsubscribe from it.
186
172
  */
187
- trackTimeToStableMesh(clockSlot, dutiedSlot, dutiedInfo) {
188
- if (dutiedSlot < clockSlot) {
189
- // aggregator duty is expired, set timeToStableMesh to some big value so we know this value is not good
190
- for (const [subnet, timeToFormMesh] of dutiedInfo.entries()) {
191
- if (timeToFormMesh === null) {
192
- dutiedInfo.set(subnet, NOT_ABLE_TO_FORM_STABLE_MESH_SEC);
193
- this.metrics?.attnetsService.subscriptionsCommitteeTimeToStableMesh.observe({ subnet }, NOT_ABLE_TO_FORM_STABLE_MESH_SEC);
194
- }
195
- }
196
- }
197
- else if (dutiedSlot <= clockSlot + this.opts.slotsToSubscribeBeforeAggregatorDuty) {
198
- // aggregator duty is not expired, track time to stable mesh if this is the 1st time we see mesh peers>=Dlo (6)
199
- for (const [subnet, timeToFormMesh] of dutiedInfo.entries()) {
200
- if (timeToFormMesh === null) {
201
- const topicStr = stringifyGossipTopic(this.config, {
202
- type: gossipType,
203
- fork: this.config.getForkName(dutiedSlot),
204
- subnet,
205
- });
206
- const numMeshPeers = this.gossip.mesh.get(topicStr)?.size ?? 0;
207
- if (numMeshPeers >= GOSSIP_D_LOW) {
208
- const timeToStableMeshSec = this.clock.secFromSlot(dutiedSlot - this.opts.slotsToSubscribeBeforeAggregatorDuty);
209
- // set to dutiedInfo so we'll not set to metrics again
210
- dutiedInfo.set(subnet, timeToStableMeshSec);
211
- this.metrics?.attnetsService.subscriptionsCommitteeTimeToStableMesh.observe({ subnet }, timeToStableMeshSec);
212
- }
213
- }
214
- }
173
+ unsubscribeExpiredCommitteeSubnets(slot) {
174
+ const expired = this.subscriptionsCommittee.getExpired(slot);
175
+ if (expired.length > 0) {
176
+ this.unsubscribeSubnets(expired, slot, SubnetSource.committee);
215
177
  }
216
178
  }
217
- recomputeLongLivedSubnets() {
218
- if (this.nodeId === null) {
219
- this.logger.verbose("Cannot recompute long-lived subscriptions, no nodeId");
179
+ /**
180
+ * A random subnet has expired.
181
+ * This function selects a new subnet to join, or extends the expiry if there are no more
182
+ * available subnets to choose from.
183
+ */
184
+ unsubscribeExpiredRandomSubnets(slot) {
185
+ const expired = this.subscriptionsRandom.getExpired(slot);
186
+ const currentSlot = this.clock.currentSlot;
187
+ if (expired.length === 0) {
220
188
  return;
221
189
  }
222
- const oldSubnets = this.longLivedSubscriptions;
223
- const newSubnets = computeSubscribedSubnet(this.nodeId, this.clock.currentEpoch);
224
- this.logger.verbose("Recomputing long-lived subscriptions", {
225
- epoch: this.clock.currentEpoch,
226
- oldSubnets: Array.from(oldSubnets).join(","),
227
- newSubnets: newSubnets.join(","),
228
- });
229
- const toRemoveSubnets = [];
230
- for (const subnet of oldSubnets) {
231
- if (!newSubnets.includes(subnet)) {
232
- toRemoveSubnets.push(subnet);
190
+ if (this.knownValidators.size * RANDOM_SUBNETS_PER_VALIDATOR >= ATTESTATION_SUBNET_COUNT) {
191
+ // Optimization: If we have to be subcribed to all subnets, no need to unsubscribe. Just extend the timeout
192
+ for (const subnet of expired) {
193
+ this.subscriptionsRandom.request({ subnet, toSlot: this.randomSubscriptionSlotLen() + currentSlot });
233
194
  }
195
+ return;
234
196
  }
235
- // First, tell gossip to subscribe to the subnets if not connected already
236
- this.subscribeToSubnets(newSubnets, SubnetSource.longLived);
237
- // then update longLivedSubscriptions
238
- for (const subnet of toRemoveSubnets) {
239
- this.longLivedSubscriptions.delete(subnet);
240
- }
241
- for (const subnet of newSubnets) {
242
- // this.longLivedSubscriptions is a set so it'll handle duplicates
243
- this.longLivedSubscriptions.add(subnet);
244
- }
245
- // Only tell gossip to unsubsribe last, longLivedSubscriptions has the latest state
246
- this.unsubscribeSubnets(toRemoveSubnets, this.clock.currentSlot, SubnetSource.longLived);
247
- this.updateMetadata();
197
+ // Prune subnets and re-subcribe to new ones
198
+ this.unsubscribeSubnets(expired, slot, SubnetSource.random);
199
+ this.rebalanceRandomSubnets();
248
200
  }
249
201
  /**
250
- * Unsubscribe to a committee subnet from subscribedCommitteeSubnets.
251
- * If a random subnet is present, we do not unsubscribe from it.
202
+ * A known validator has not sent a subscription in a while. They are considered offline and the
203
+ * beacon node no longer needs to be subscribed to the allocated random subnets.
204
+ *
205
+ * We don't keep track of a specific validator to random subnet, rather the ratio of active
206
+ * validators to random subnets. So when a validator goes offline, we can simply remove the
207
+ * allocated amount of random subnets.
252
208
  */
253
- unsubscribeExpiredCommitteeSubnets(slot) {
254
- const expired = this.shortLivedSubscriptions.getExpired(slot);
255
- if (expired.length > 0) {
256
- this.unsubscribeSubnets(expired, slot, SubnetSource.committee);
209
+ pruneExpiredKnownValidators(currentSlot) {
210
+ let deletedKnownValidators = false;
211
+ for (const [index, slot] of this.knownValidators.entries()) {
212
+ if (currentSlot > slot + LAST_SEEN_VALIDATOR_TIMEOUT) {
213
+ const deleted = this.knownValidators.delete(index);
214
+ if (deleted)
215
+ deletedKnownValidators = true;
216
+ }
257
217
  }
218
+ if (deletedKnownValidators)
219
+ this.rebalanceRandomSubnets();
258
220
  }
259
221
  /**
260
222
  * No need to track aggregator for past slots.
261
223
  * @param currentSlot
262
224
  */
263
225
  pruneExpiredAggregator(currentSlot) {
264
- for (const dutiedSlot of this.aggregatorSlotSubnet.keys()) {
265
- if (currentSlot > dutiedSlot) {
266
- this.aggregatorSlotSubnet.delete(dutiedSlot);
226
+ for (const slot of this.aggregatorSlotSubnet.keys()) {
227
+ if (currentSlot > slot) {
228
+ this.aggregatorSlotSubnet.delete(slot);
229
+ }
230
+ }
231
+ }
232
+ /**
233
+ * Called when we have new validators or expired validators.
234
+ * knownValidators should be updated before this function.
235
+ */
236
+ rebalanceRandomSubnets() {
237
+ const slot = this.clock.currentSlot;
238
+ // By limiting to ATTESTATION_SUBNET_COUNT, if target is still over subnetDiff equals 0
239
+ const targetRandomSubnetCount = Math.min(this.knownValidators.size * RANDOM_SUBNETS_PER_VALIDATOR, ATTESTATION_SUBNET_COUNT);
240
+ const subnetDiff = targetRandomSubnetCount - this.subscriptionsRandom.size;
241
+ // subscribe to more random subnets
242
+ if (subnetDiff > 0) {
243
+ const activeSubnets = new Set(this.subscriptionsRandom.getActive(slot));
244
+ const allSubnets = Array.from({ length: ATTESTATION_SUBNET_COUNT }, (_, i) => i);
245
+ const availableSubnets = allSubnets.filter((subnet) => !activeSubnets.has(subnet));
246
+ const subnetsToConnect = this.shuffleFn(availableSubnets).slice(0, subnetDiff);
247
+ // Tell gossip to connect to the subnets if not connected already
248
+ this.subscribeToSubnets(subnetsToConnect, SubnetSource.random);
249
+ // Register these new subnets until some future slot
250
+ for (const subnet of subnetsToConnect) {
251
+ // the heartbeat will help connect to respective peers
252
+ this.subscriptionsRandom.request({ subnet, toSlot: this.randomSubscriptionSlotLen() + slot });
253
+ }
254
+ }
255
+ // unsubscribe some random subnets
256
+ if (subnetDiff < 0) {
257
+ const activeRandomSubnets = this.subscriptionsRandom.getActive(slot);
258
+ // TODO: Do we want to remove the oldest subnets or the newest subnets?
259
+ // .slice(-2) will extract the last two items of the array
260
+ const toRemoveSubnets = activeRandomSubnets.slice(subnetDiff);
261
+ for (const subnet of toRemoveSubnets) {
262
+ this.subscriptionsRandom.delete(subnet);
267
263
  }
264
+ this.unsubscribeSubnets(toRemoveSubnets, slot, SubnetSource.random);
265
+ }
266
+ // If there has been a change update the local ENR bitfield
267
+ if (subnetDiff !== 0) {
268
+ this.updateMetadata();
268
269
  }
269
270
  }
270
271
  /** Update ENR */
271
272
  updateMetadata() {
272
273
  const subnets = ssz.phase0.AttestationSubnets.defaultValue();
273
- for (const subnet of this.longLivedSubscriptions) {
274
+ for (const subnet of this.subscriptionsRandom.getAll()) {
274
275
  subnets.set(subnet, true);
275
276
  }
276
277
  // Only update metadata if necessary, setting `metadata.[key]` triggers a write to disk
@@ -278,14 +279,11 @@ export class AttnetsService {
278
279
  this.metadata.attnets = subnets;
279
280
  }
280
281
  }
281
- /**
282
- * Trigger a gossip subcription only if not already subscribed
283
- * shortLivedSubscriptions or longLivedSubscriptions should be updated right AFTER this called
284
- **/
282
+ /** Tigger a gossip subcription only if not already subscribed */
285
283
  subscribeToSubnets(subnets, src) {
286
284
  const forks = getActiveForks(this.config, this.clock.currentEpoch);
287
285
  for (const subnet of subnets) {
288
- if (!this.shortLivedSubscriptions.has(subnet) && !this.longLivedSubscriptions.has(subnet)) {
286
+ if (!this.subscriptionsCommittee.has(subnet) && !this.subscriptionsRandom.has(subnet)) {
289
287
  for (const fork of forks) {
290
288
  this.gossip.subscribeTopic({ type: gossipType, fork, subnet });
291
289
  }
@@ -293,17 +291,15 @@ export class AttnetsService {
293
291
  }
294
292
  }
295
293
  }
296
- /**
297
- * Trigger a gossip un-subscription only if no-one is still subscribed
298
- * If unsubscribe long lived subnets, longLivedSubscriptions should be updated right BEFORE this called
299
- **/
294
+ /** Trigger a gossip un-subscrition only if no-one is still subscribed */
300
295
  unsubscribeSubnets(subnets, slot, src) {
301
296
  // No need to unsubscribeTopic(). Return early to prevent repetitive extra work
302
297
  if (this.opts.subscribeAllSubnets)
303
298
  return;
304
299
  const forks = getActiveForks(this.config, this.clock.currentEpoch);
305
300
  for (const subnet of subnets) {
306
- if (!this.shortLivedSubscriptions.isActiveAtSlot(subnet, slot) && !this.longLivedSubscriptions.has(subnet)) {
301
+ if (!this.subscriptionsCommittee.isActiveAtSlot(subnet, slot) &&
302
+ !this.subscriptionsRandom.isActiveAtSlot(subnet, slot)) {
307
303
  for (const fork of forks) {
308
304
  this.gossip.unsubscribeTopic({ type: gossipType, fork, subnet });
309
305
  }
@@ -311,21 +307,14 @@ export class AttnetsService {
311
307
  }
312
308
  }
313
309
  }
310
+ randomSubscriptionSlotLen() {
311
+ return (this.randBetweenFn(EPOCHS_PER_RANDOM_SUBNET_SUBSCRIPTION, 2 * EPOCHS_PER_RANDOM_SUBNET_SUBSCRIPTION) *
312
+ SLOTS_PER_EPOCH);
313
+ }
314
314
  onScrapeLodestarMetrics(metrics) {
315
315
  metrics.attnetsService.committeeSubnets.set(this.committeeSubnets.size);
316
- metrics.attnetsService.subscriptionsCommittee.set(this.shortLivedSubscriptions.size);
317
- // track short lived subnet status, >= 6 (Dlo) means healthy, otherwise unhealthy
318
- const currentSlot = this.clock.currentSlot;
319
- for (const { subnet } of this.shortLivedSubscriptions.getActiveTtl(currentSlot)) {
320
- const topicStr = stringifyGossipTopic(this.config, {
321
- type: gossipType,
322
- fork: this.config.getForkName(currentSlot),
323
- subnet,
324
- });
325
- const numMeshPeers = this.gossip.mesh.get(topicStr)?.size ?? 0;
326
- metrics.attnetsService.subscriptionsCommitteeMeshPeers.observe({ subnet }, numMeshPeers);
327
- }
328
- metrics.attnetsService.longLivedSubscriptions.set(this.longLivedSubscriptions.size);
316
+ metrics.attnetsService.subscriptionsCommittee.set(this.subscriptionsCommittee.size);
317
+ metrics.attnetsService.subscriptionsRandom.set(this.subscriptionsRandom.size);
329
318
  let aggregatorCount = 0;
330
319
  for (const subnets of this.aggregatorSlotSubnet.values()) {
331
320
  aggregatorCount += subnets.size;
@@ -1 +1 @@
1
- {"version":3,"file":"attnetsService.js","sourceRoot":"","sources":["../../../src/network/subnets/attnetsService.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,qCAAqC,EAErC,eAAe,GAChB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAc,GAAG,EAAC,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAS,MAAM,EAAC,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAC,UAAU,EAAS,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAC,UAAU,EAAC,MAAM,oBAAoB,CAAC;AAE9C,OAAO,EAAC,SAAS,EAAkB,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAC,cAAc,EAAC,MAAM,aAAa,CAAC;AAE3C,OAAO,EAAC,oBAAoB,EAAC,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAC,YAAY,EAAC,MAAM,gCAAgC,CAAC;AAE5D,OAAO,EAAC,uBAAuB,EAAC,MAAM,WAAW,CAAC;AAElD,MAAM,UAAU,GAAG,UAAU,CAAC,kBAAkB,CAAC;AAEjD,MAAM,CAAN,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,uCAAuB,CAAA;IACvB,wCAAwB,CAAA;AAC1B,CAAC,EAHW,YAAY,KAAZ,YAAY,QAGvB;AAMD;;GAEG;AACH,MAAM,gCAAgC,GAAG,CAAC,CAAC,CAAC;AAE5C;;;;;GAKG;AACH,MAAM,OAAO,cAAc;IAiBzB,YACmB,MAAoB,EACpB,KAAa,EACb,MAAwB,EACxB,QAA4B,EAC5B,MAAc,EACd,OAAkC,EAClC,MAAqB,EACrB,IAAwB;QAPxB,WAAM,GAAN,MAAM,CAAc;QACpB,UAAK,GAAL,KAAK,CAAQ;QACb,WAAM,GAAN,MAAM,CAAkB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,CAAC,gBAAgB,CAAC,GAAG,CAAC,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;QACxE,OAAO,CAAC,cAAc,CAAC,sBAAsB,CAAC,GAAG,CAAC,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,CAAC;QACpF,OAAO,CAAC,cAAc,CAAC,mBAAmB,CAAC,GAAG,CAAC,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;QAC9E,IAAI,eAAe,GAAG,CAAC,CAAC;QACxB,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,oBAAoB,CAAC,MAAM,EAAE,EAAE,CAAC;YACzD,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC;QAClC,CAAC;QACD,OAAO,CAAC,cAAc,CAAC,yBAAyB,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;IACxE,CAAC;CACF"}
@@ -0,0 +1,112 @@
1
+ import { ForkName } from "@lodestar/params";
2
+ import { Slot } from "@lodestar/types";
3
+ import { Logger } from "@lodestar/utils";
4
+ import { BeaconConfig } from "@lodestar/config";
5
+ import { IClock } from "../../util/clock.js";
6
+ import { MetadataController } from "../metadata.js";
7
+ import { RequestedSubnet } from "../peers/utils/index.js";
8
+ import { NetworkCoreMetrics } from "../core/metrics.js";
9
+ import { IAttnetsService, CommitteeSubscription, SubnetsServiceOpts, GossipSubscriber, NodeId } from "./interface.js";
10
+ export declare enum DLLSubnetSource {
11
+ committee = "committee",
12
+ longLived = "long_lived"
13
+ }
14
+ /**
15
+ * Manage deleterministic long lived (DLL) subnets and short lived subnets.
16
+ * - PeerManager uses attnetsService to know which peers are required for duties and long lived subscriptions
17
+ * - Network call addCommitteeSubscriptions() from API calls
18
+ * - Gossip handler checks shouldProcess to know if validator is aggregator
19
+ */
20
+ export declare class DLLAttnetsService implements IAttnetsService {
21
+ private readonly config;
22
+ private readonly clock;
23
+ private readonly gossip;
24
+ private readonly metadata;
25
+ private readonly logger;
26
+ private readonly metrics;
27
+ private readonly nodeId;
28
+ private readonly opts;
29
+ /** Committee subnets - PeerManager must find peers for those */
30
+ private committeeSubnets;
31
+ /**
32
+ * All currently subscribed short-lived subnets, for attestation aggregation
33
+ * This class will tell gossip to subscribe and un-subscribe
34
+ * If a value exists for `SubscriptionId` it means that gossip subscription is active in network.gossip
35
+ */
36
+ private shortLivedSubscriptions;
37
+ /** ${SUBNETS_PER_NODE} long lived subscriptions, may overlap with `shortLivedSubscriptions` */
38
+ private longLivedSubscriptions;
39
+ /**
40
+ * Map of an aggregator at a slot and AggregatorDutyInfo
41
+ * Used to determine if we should process an attestation.
42
+ */
43
+ private aggregatorSlotSubnet;
44
+ constructor(config: BeaconConfig, clock: IClock, gossip: GossipSubscriber, metadata: MetadataController, logger: Logger, metrics: NetworkCoreMetrics | null, nodeId: NodeId | null, opts: SubnetsServiceOpts);
45
+ close(): void;
46
+ /**
47
+ * Get all active subnets for the hearbeat:
48
+ * - committeeSubnets so that submitted attestations can be spread to the network
49
+ * - longLivedSubscriptions because other peers based on this node's ENR for their submitted attestations
50
+ */
51
+ getActiveSubnets(): RequestedSubnet[];
52
+ /**
53
+ * Called from the API when validator is a part of a committee.
54
+ */
55
+ addCommitteeSubscriptions(subscriptions: CommitteeSubscription[]): void;
56
+ /**
57
+ * Check if a subscription is still active before handling a gossip object
58
+ */
59
+ shouldProcess(subnet: number, slot: Slot): boolean;
60
+ /**
61
+ * TODO-dll: clarify how many epochs before the fork we should subscribe to the new fork
62
+ * Call ONLY ONCE: Two epoch before the fork, re-subscribe all existing random subscriptions to the new fork
63
+ **/
64
+ subscribeSubnetsToNextFork(nextFork: ForkName): void;
65
+ /**
66
+ * TODO-dll: clarify how many epochs after the fork we should unsubscribe to the new fork
67
+ * Call ONLY ONCE: Two epochs after the fork, un-subscribe all subnets from the old fork
68
+ **/
69
+ unsubscribeSubnetsFromPrevFork(prevFork: ForkName): void;
70
+ /**
71
+ * Run per slot.
72
+ * - Subscribe to gossip subnets 2 slots in advance
73
+ * - Unsubscribe from expired subnets
74
+ * - Track time to stable mesh if not yet formed
75
+ */
76
+ private onSlot;
77
+ private onHalfSlot;
78
+ /**
79
+ * Track time to form stable mesh if not yet formed
80
+ */
81
+ private trackTimeToStableMesh;
82
+ /**
83
+ * Run per epoch, clean-up operations that are not urgent
84
+ * Subscribe to new random subnets every EPOCHS_PER_RANDOM_SUBNET_SUBSCRIPTION epochs
85
+ */
86
+ private onEpoch;
87
+ private recomputeLongLivedSubnets;
88
+ /**
89
+ * Unsubscribe to a committee subnet from subscribedCommitteeSubnets.
90
+ * If a random subnet is present, we do not unsubscribe from it.
91
+ */
92
+ private unsubscribeExpiredCommitteeSubnets;
93
+ /**
94
+ * No need to track aggregator for past slots.
95
+ * @param currentSlot
96
+ */
97
+ private pruneExpiredAggregator;
98
+ /** Update ENR */
99
+ private updateMetadata;
100
+ /**
101
+ * Trigger a gossip subcription only if not already subscribed
102
+ * shortLivedSubscriptions or longLivedSubscriptions should be updated right AFTER this called
103
+ **/
104
+ private subscribeToSubnets;
105
+ /**
106
+ * Trigger a gossip un-subscription only if no-one is still subscribed
107
+ * If unsubscribe long lived subnets, longLivedSubscriptions should be updated right BEFORE this called
108
+ **/
109
+ private unsubscribeSubnets;
110
+ private onScrapeLodestarMetrics;
111
+ }
112
+ //# sourceMappingURL=dllAttnetsService.d.ts.map