Skip to content

Commit

Permalink
fix: do not set time to stable mesh any big value by default
Browse files Browse the repository at this point in the history
  • Loading branch information
twoeths committed Aug 22, 2023
1 parent a3e6a45 commit 061740e
Showing 1 changed file with 5 additions and 17 deletions.
22 changes: 5 additions & 17 deletions packages/beacon-node/src/network/subnets/dllAttnetsService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@ type Subnet = number;
// map of subnet to time to form stable mesh as seconds, null if not yet formed
type AggregatorDutyInfo = Map<Subnet, number | null>;

/**
* This value means node is not able to form stable mesh.
*/
const MAX_TIME_TO_STABLE_MESH_SEC = 120;

/**
* Manage deleterministic long lived (DLL) subnets and short lived subnets.
* - PeerManager uses attnetsService to know which peers are required for duties and long lived subscriptions
Expand Down Expand Up @@ -196,6 +191,10 @@ export class DLLAttnetsService implements IAttnetsService {
}
};

/**
* We subsribe to aggregator duties 2 slots in advance, track time to stable mesh
* every half slot.
*/
private onHalfSlot = (clockSlot: Slot): void => {
for (const [dutiedSlot, dutiedInfo] of this.aggregatorSlotSubnet.entries()) {
this.trackTimeToStableMesh(clockSlot, dutiedSlot, dutiedInfo);
Expand All @@ -206,18 +205,7 @@ export class DLLAttnetsService implements IAttnetsService {
* Track time to form stable mesh if not yet formed
*/
private trackTimeToStableMesh(clockSlot: Slot, dutiedSlot: Slot, dutiedInfo: AggregatorDutyInfo): void {
if (dutiedSlot < clockSlot) {
// aggregator duty is expired, set timeToStableMesh to some big value so we know this value is not good
for (const [subnet, timeToFormMesh] of dutiedInfo.entries()) {
if (timeToFormMesh === null) {
dutiedInfo.set(subnet, MAX_TIME_TO_STABLE_MESH_SEC);
this.metrics?.attnetsService.subscriptionsCommitteeTimeToStableMesh.observe(
{subnet},
MAX_TIME_TO_STABLE_MESH_SEC
);
}
}
} else if (dutiedSlot <= clockSlot + this.opts.slotsToSubscribeBeforeAggregatorDuty) {
if (dutiedSlot <= clockSlot + this.opts.slotsToSubscribeBeforeAggregatorDuty) {
// aggregator duty is not expired, track time to stable mesh if this is the 1st time we see mesh peers>=Dlo (6)
for (const [subnet, timeToFormMesh] of dutiedInfo.entries()) {
if (timeToFormMesh === null) {
Expand Down

0 comments on commit 061740e

Please sign in to comment.