@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.
Files changed (67) hide show
  1. package/lib/api/impl/config/constants.d.ts +2 -4
  2. package/lib/api/impl/config/constants.d.ts.map +1 -1
  3. package/lib/api/impl/config/constants.js +3 -6
  4. package/lib/api/impl/config/constants.js.map +1 -1
  5. package/lib/api/impl/validator/index.d.ts.map +1 -1
  6. package/lib/api/impl/validator/index.js +2 -2
  7. package/lib/api/impl/validator/index.js.map +1 -1
  8. package/lib/chain/chain.js +1 -1
  9. package/lib/chain/chain.js.map +1 -1
  10. package/lib/chain/opPools/syncContributionAndProofPool.d.ts +1 -3
  11. package/lib/chain/opPools/syncContributionAndProofPool.d.ts.map +1 -1
  12. package/lib/chain/opPools/syncContributionAndProofPool.js +3 -4
  13. package/lib/chain/opPools/syncContributionAndProofPool.js.map +1 -1
  14. package/lib/chain/validation/attestation.d.ts.map +1 -1
  15. package/lib/chain/validation/attestation.js +7 -6
  16. package/lib/chain/validation/attestation.js.map +1 -1
  17. package/lib/chain/validation/block.d.ts.map +1 -1
  18. package/lib/chain/validation/block.js +2 -1
  19. package/lib/chain/validation/block.js.map +1 -1
  20. package/lib/chain/validation/lightClientOptimisticUpdate.d.ts.map +1 -1
  21. package/lib/chain/validation/lightClientOptimisticUpdate.js +2 -1
  22. package/lib/chain/validation/lightClientOptimisticUpdate.js.map +1 -1
  23. package/lib/constants/constants.d.ts +5 -0
  24. package/lib/constants/constants.d.ts.map +1 -1
  25. package/lib/constants/constants.js +5 -0
  26. package/lib/constants/constants.js.map +1 -1
  27. package/lib/constants/network.d.ts +14 -0
  28. package/lib/constants/network.d.ts.map +1 -1
  29. package/lib/constants/network.js +15 -0
  30. package/lib/constants/network.js.map +1 -1
  31. package/lib/network/discv5/utils.d.ts.map +1 -1
  32. package/lib/network/discv5/utils.js +2 -1
  33. package/lib/network/discv5/utils.js.map +1 -1
  34. package/lib/network/gossip/gossipsub.d.ts.map +1 -1
  35. package/lib/network/gossip/gossipsub.js +7 -1
  36. package/lib/network/gossip/gossipsub.js.map +1 -1
  37. package/lib/network/reqresp/handlers/blobSidecarsByRange.js +5 -5
  38. package/lib/network/reqresp/handlers/blobSidecarsByRange.js.map +1 -1
  39. package/lib/network/reqresp/handlers/blobSidecarsByRoot.js +4 -4
  40. package/lib/network/reqresp/handlers/blobSidecarsByRoot.js.map +1 -1
  41. package/lib/network/subnets/attnetsService.d.ts +1 -1
  42. package/lib/network/subnets/attnetsService.js +6 -6
  43. package/lib/network/subnets/attnetsService.js.map +1 -1
  44. package/lib/network/subnets/util.d.ts +2 -3
  45. package/lib/network/subnets/util.d.ts.map +1 -1
  46. package/lib/network/subnets/util.js +6 -6
  47. package/lib/network/subnets/util.js.map +1 -1
  48. package/lib/util/clock.d.ts.map +1 -1
  49. package/lib/util/clock.js +4 -3
  50. package/lib/util/clock.js.map +1 -1
  51. package/package.json +14 -14
  52. package/src/api/impl/config/constants.ts +4 -10
  53. package/src/api/impl/validator/index.ts +2 -5
  54. package/src/chain/chain.ts +1 -1
  55. package/src/chain/opPools/syncContributionAndProofPool.ts +2 -3
  56. package/src/chain/validation/attestation.ts +7 -6
  57. package/src/chain/validation/block.ts +2 -1
  58. package/src/chain/validation/lightClientOptimisticUpdate.ts +2 -3
  59. package/src/constants/constants.ts +6 -0
  60. package/src/constants/network.ts +19 -0
  61. package/src/network/discv5/utils.ts +2 -1
  62. package/src/network/gossip/gossipsub.ts +10 -1
  63. package/src/network/reqresp/handlers/blobSidecarsByRange.ts +6 -6
  64. package/src/network/reqresp/handlers/blobSidecarsByRoot.ts +5 -5
  65. package/src/network/subnets/attnetsService.ts +6 -6
  66. package/src/network/subnets/util.ts +12 -12
  67. package/src/util/clock.ts +4 -3
@@ -1,6 +1,11 @@
1
1
  import {digest} from "@chainsafe/as-sha256";
2
- import {ChainConfig} from "@lodestar/config";
3
- import {ATTESTATION_SUBNET_COUNT, ATTESTATION_SUBNET_PREFIX_BITS, NODE_ID_BITS} from "@lodestar/params";
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(config: ChainConfig, nodeId: NodeId, epoch: Epoch): number[] {
16
+ export function computeSubscribedSubnet(nodeId: NodeId, epoch: Epoch): number[] {
12
17
  const subnets: number[] = [];
13
- for (let index = 0; index < config.SUBNETS_PER_NODE; index++) {
14
- subnets.push(computeSubscribedSubnetByIndex(config, nodeId, epoch, index));
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) / config.EPOCHS_PER_SUBNET_SUBSCRIPTION))
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() < this.config.MAXIMUM_GOSSIP_CLOCK_DISPARITY ? currentSlot + 1 : currentSlot;
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() < this.config.MAXIMUM_GOSSIP_CLOCK_DISPARITY) {
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 < this.config.MAXIMUM_GOSSIP_CLOCK_DISPARITY) {
138
+ if (Date.now() - currentSlotTime < MAXIMUM_GOSSIP_CLOCK_DISPARITY) {
138
139
  return slot === currentSlot - 1;
139
140
  }
140
141
  return false;