@lodestar/beacon-node 1.36.0-dev.598c1ec54e → 1.36.0-dev.6604fa5719
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/config/constants.d.ts +2 -4
- package/lib/api/impl/config/constants.d.ts.map +1 -1
- package/lib/api/impl/config/constants.js +3 -6
- package/lib/api/impl/config/constants.js.map +1 -1
- package/lib/api/impl/validator/index.d.ts.map +1 -1
- package/lib/api/impl/validator/index.js +2 -2
- package/lib/api/impl/validator/index.js.map +1 -1
- package/lib/chain/chain.js +1 -1
- package/lib/chain/chain.js.map +1 -1
- package/lib/chain/opPools/syncContributionAndProofPool.d.ts +1 -3
- package/lib/chain/opPools/syncContributionAndProofPool.d.ts.map +1 -1
- package/lib/chain/opPools/syncContributionAndProofPool.js +3 -4
- package/lib/chain/opPools/syncContributionAndProofPool.js.map +1 -1
- package/lib/chain/validation/attestation.d.ts.map +1 -1
- package/lib/chain/validation/attestation.js +7 -6
- package/lib/chain/validation/attestation.js.map +1 -1
- package/lib/chain/validation/block.d.ts.map +1 -1
- package/lib/chain/validation/block.js +2 -1
- package/lib/chain/validation/block.js.map +1 -1
- package/lib/chain/validation/lightClientOptimisticUpdate.d.ts.map +1 -1
- package/lib/chain/validation/lightClientOptimisticUpdate.js +2 -1
- package/lib/chain/validation/lightClientOptimisticUpdate.js.map +1 -1
- package/lib/constants/constants.d.ts +5 -0
- package/lib/constants/constants.d.ts.map +1 -1
- package/lib/constants/constants.js +5 -0
- package/lib/constants/constants.js.map +1 -1
- package/lib/constants/network.d.ts +14 -0
- package/lib/constants/network.d.ts.map +1 -1
- package/lib/constants/network.js +15 -0
- package/lib/constants/network.js.map +1 -1
- package/lib/network/discv5/utils.d.ts.map +1 -1
- package/lib/network/discv5/utils.js +2 -1
- package/lib/network/discv5/utils.js.map +1 -1
- package/lib/network/gossip/gossipsub.d.ts.map +1 -1
- package/lib/network/gossip/gossipsub.js +7 -1
- package/lib/network/gossip/gossipsub.js.map +1 -1
- package/lib/network/reqresp/handlers/blobSidecarsByRange.js +5 -5
- package/lib/network/reqresp/handlers/blobSidecarsByRange.js.map +1 -1
- package/lib/network/reqresp/handlers/blobSidecarsByRoot.js +4 -4
- package/lib/network/reqresp/handlers/blobSidecarsByRoot.js.map +1 -1
- package/lib/network/subnets/attnetsService.d.ts +1 -1
- package/lib/network/subnets/attnetsService.js +6 -6
- package/lib/network/subnets/attnetsService.js.map +1 -1
- package/lib/network/subnets/util.d.ts +2 -3
- package/lib/network/subnets/util.d.ts.map +1 -1
- package/lib/network/subnets/util.js +6 -6
- package/lib/network/subnets/util.js.map +1 -1
- package/lib/util/clock.d.ts.map +1 -1
- package/lib/util/clock.js +4 -3
- package/lib/util/clock.js.map +1 -1
- package/package.json +14 -14
- package/src/api/impl/config/constants.ts +4 -10
- package/src/api/impl/validator/index.ts +2 -5
- package/src/chain/chain.ts +1 -1
- package/src/chain/opPools/syncContributionAndProofPool.ts +2 -3
- package/src/chain/validation/attestation.ts +7 -6
- package/src/chain/validation/block.ts +2 -1
- package/src/chain/validation/lightClientOptimisticUpdate.ts +2 -3
- package/src/constants/constants.ts +6 -0
- package/src/constants/network.ts +19 -0
- package/src/network/discv5/utils.ts +2 -1
- package/src/network/gossip/gossipsub.ts +10 -1
- package/src/network/reqresp/handlers/blobSidecarsByRange.ts +6 -6
- package/src/network/reqresp/handlers/blobSidecarsByRoot.ts +5 -5
- package/src/network/subnets/attnetsService.ts +6 -6
- package/src/network/subnets/util.ts +12 -12
- package/src/util/clock.ts +4 -3
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import {digest} from "@chainsafe/as-sha256";
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import {
|
|
3
|
+
ATTESTATION_SUBNET_COUNT,
|
|
4
|
+
ATTESTATION_SUBNET_PREFIX_BITS,
|
|
5
|
+
EPOCHS_PER_SUBNET_SUBSCRIPTION,
|
|
6
|
+
NODE_ID_BITS,
|
|
7
|
+
SUBNETS_PER_NODE,
|
|
8
|
+
} from "@lodestar/params";
|
|
4
9
|
import {computeShuffledIndex} from "@lodestar/state-transition";
|
|
5
10
|
import {Epoch, ssz} from "@lodestar/types";
|
|
6
11
|
import {NodeId} from "./interface.js";
|
|
@@ -8,10 +13,10 @@ import {NodeId} from "./interface.js";
|
|
|
8
13
|
/**
|
|
9
14
|
* Spec https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.3/specs/phase0/p2p-interface.md
|
|
10
15
|
*/
|
|
11
|
-
export function computeSubscribedSubnet(
|
|
16
|
+
export function computeSubscribedSubnet(nodeId: NodeId, epoch: Epoch): number[] {
|
|
12
17
|
const subnets: number[] = [];
|
|
13
|
-
for (let index = 0; index <
|
|
14
|
-
subnets.push(computeSubscribedSubnetByIndex(
|
|
18
|
+
for (let index = 0; index < SUBNETS_PER_NODE; index++) {
|
|
19
|
+
subnets.push(computeSubscribedSubnetByIndex(nodeId, epoch, index));
|
|
15
20
|
}
|
|
16
21
|
return subnets;
|
|
17
22
|
}
|
|
@@ -19,16 +24,11 @@ export function computeSubscribedSubnet(config: ChainConfig, nodeId: NodeId, epo
|
|
|
19
24
|
/**
|
|
20
25
|
* Spec https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.3/specs/phase0/p2p-interface.md
|
|
21
26
|
*/
|
|
22
|
-
export function computeSubscribedSubnetByIndex(
|
|
23
|
-
config: ChainConfig,
|
|
24
|
-
nodeId: NodeId,
|
|
25
|
-
epoch: Epoch,
|
|
26
|
-
index: number
|
|
27
|
-
): number {
|
|
27
|
+
export function computeSubscribedSubnetByIndex(nodeId: NodeId, epoch: Epoch, index: number): number {
|
|
28
28
|
const nodeIdPrefix = getNodeIdPrefix(nodeId);
|
|
29
29
|
const nodeOffset = getNodeOffset(nodeId);
|
|
30
30
|
const permutationSeed = digest(
|
|
31
|
-
ssz.UintNum64.serialize(Math.floor((epoch + nodeOffset) /
|
|
31
|
+
ssz.UintNum64.serialize(Math.floor((epoch + nodeOffset) / EPOCHS_PER_SUBNET_SUBSCRIPTION))
|
|
32
32
|
);
|
|
33
33
|
const permutatedPrefix = computeShuffledIndex(nodeIdPrefix, 1 << ATTESTATION_SUBNET_PREFIX_BITS, permutationSeed);
|
|
34
34
|
return (permutatedPrefix + index) % ATTESTATION_SUBNET_COUNT;
|
package/src/util/clock.ts
CHANGED
|
@@ -4,6 +4,7 @@ import {ChainForkConfig} from "@lodestar/config";
|
|
|
4
4
|
import {computeEpochAtSlot, computeTimeAtSlot, getCurrentSlot} from "@lodestar/state-transition";
|
|
5
5
|
import type {Epoch, Slot} from "@lodestar/types";
|
|
6
6
|
import {ErrorAborted} from "@lodestar/utils";
|
|
7
|
+
import {MAXIMUM_GOSSIP_CLOCK_DISPARITY} from "../constants/constants.js";
|
|
7
8
|
|
|
8
9
|
export enum ClockEvent {
|
|
9
10
|
/**
|
|
@@ -100,7 +101,7 @@ export class Clock extends EventEmitter implements IClock {
|
|
|
100
101
|
get currentSlotWithGossipDisparity(): Slot {
|
|
101
102
|
const currentSlot = this.currentSlot;
|
|
102
103
|
const nextSlotTime = computeTimeAtSlot(this.config, currentSlot + 1, this.genesisTime) * 1000;
|
|
103
|
-
return nextSlotTime - Date.now() <
|
|
104
|
+
return nextSlotTime - Date.now() < MAXIMUM_GOSSIP_CLOCK_DISPARITY ? currentSlot + 1 : currentSlot;
|
|
104
105
|
}
|
|
105
106
|
|
|
106
107
|
get currentEpoch(): Epoch {
|
|
@@ -129,12 +130,12 @@ export class Clock extends EventEmitter implements IClock {
|
|
|
129
130
|
}
|
|
130
131
|
const nextSlotTime = computeTimeAtSlot(this.config, currentSlot + 1, this.genesisTime) * 1000;
|
|
131
132
|
// we're too close to next slot, accept next slot
|
|
132
|
-
if (nextSlotTime - Date.now() <
|
|
133
|
+
if (nextSlotTime - Date.now() < MAXIMUM_GOSSIP_CLOCK_DISPARITY) {
|
|
133
134
|
return slot === currentSlot + 1;
|
|
134
135
|
}
|
|
135
136
|
const currentSlotTime = computeTimeAtSlot(this.config, currentSlot, this.genesisTime) * 1000;
|
|
136
137
|
// we've just passed the current slot, accept previous slot
|
|
137
|
-
if (Date.now() - currentSlotTime <
|
|
138
|
+
if (Date.now() - currentSlotTime < MAXIMUM_GOSSIP_CLOCK_DISPARITY) {
|
|
138
139
|
return slot === currentSlot - 1;
|
|
139
140
|
}
|
|
140
141
|
return false;
|