@lodestar/beacon-node 1.36.0-dev.a2a22d66ef → 1.36.0-dev.d9cc6b90f7

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 (86) hide show
  1. package/lib/api/impl/config/constants.d.ts +4 -2
  2. package/lib/api/impl/config/constants.d.ts.map +1 -1
  3. package/lib/api/impl/config/constants.js +6 -3
  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 +2 -2
  9. package/lib/chain/chain.js.map +1 -1
  10. package/lib/chain/errors/voluntaryExitError.d.ts +16 -2
  11. package/lib/chain/errors/voluntaryExitError.d.ts.map +1 -1
  12. package/lib/chain/errors/voluntaryExitError.js +22 -1
  13. package/lib/chain/errors/voluntaryExitError.js.map +1 -1
  14. package/lib/chain/lightClient/index.d.ts +3 -0
  15. package/lib/chain/lightClient/index.d.ts.map +1 -1
  16. package/lib/chain/lightClient/index.js +24 -13
  17. package/lib/chain/lightClient/index.js.map +1 -1
  18. package/lib/chain/opPools/syncContributionAndProofPool.d.ts +3 -1
  19. package/lib/chain/opPools/syncContributionAndProofPool.d.ts.map +1 -1
  20. package/lib/chain/opPools/syncContributionAndProofPool.js +4 -3
  21. package/lib/chain/opPools/syncContributionAndProofPool.js.map +1 -1
  22. package/lib/chain/validation/attestation.d.ts.map +1 -1
  23. package/lib/chain/validation/attestation.js +6 -7
  24. package/lib/chain/validation/attestation.js.map +1 -1
  25. package/lib/chain/validation/block.d.ts.map +1 -1
  26. package/lib/chain/validation/block.js +1 -2
  27. package/lib/chain/validation/block.js.map +1 -1
  28. package/lib/chain/validation/lightClientOptimisticUpdate.d.ts.map +1 -1
  29. package/lib/chain/validation/lightClientOptimisticUpdate.js +1 -2
  30. package/lib/chain/validation/lightClientOptimisticUpdate.js.map +1 -1
  31. package/lib/chain/validation/voluntaryExit.d.ts.map +1 -1
  32. package/lib/chain/validation/voluntaryExit.js +5 -4
  33. package/lib/chain/validation/voluntaryExit.js.map +1 -1
  34. package/lib/constants/constants.d.ts +0 -5
  35. package/lib/constants/constants.d.ts.map +1 -1
  36. package/lib/constants/constants.js +0 -5
  37. package/lib/constants/constants.js.map +1 -1
  38. package/lib/constants/network.d.ts +0 -14
  39. package/lib/constants/network.d.ts.map +1 -1
  40. package/lib/constants/network.js +0 -15
  41. package/lib/constants/network.js.map +1 -1
  42. package/lib/metrics/metrics/lodestar.d.ts +1 -0
  43. package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
  44. package/lib/metrics/metrics/lodestar.js +4 -0
  45. package/lib/metrics/metrics/lodestar.js.map +1 -1
  46. package/lib/network/discv5/utils.d.ts.map +1 -1
  47. package/lib/network/discv5/utils.js +1 -2
  48. package/lib/network/discv5/utils.js.map +1 -1
  49. package/lib/network/gossip/gossipsub.d.ts.map +1 -1
  50. package/lib/network/gossip/gossipsub.js +1 -7
  51. package/lib/network/gossip/gossipsub.js.map +1 -1
  52. package/lib/network/reqresp/handlers/blobSidecarsByRange.js +5 -5
  53. package/lib/network/reqresp/handlers/blobSidecarsByRange.js.map +1 -1
  54. package/lib/network/reqresp/handlers/blobSidecarsByRoot.js +4 -4
  55. package/lib/network/reqresp/handlers/blobSidecarsByRoot.js.map +1 -1
  56. package/lib/network/subnets/attnetsService.d.ts +1 -1
  57. package/lib/network/subnets/attnetsService.js +6 -6
  58. package/lib/network/subnets/attnetsService.js.map +1 -1
  59. package/lib/network/subnets/util.d.ts +3 -2
  60. package/lib/network/subnets/util.d.ts.map +1 -1
  61. package/lib/network/subnets/util.js +6 -6
  62. package/lib/network/subnets/util.js.map +1 -1
  63. package/lib/util/clock.d.ts.map +1 -1
  64. package/lib/util/clock.js +3 -4
  65. package/lib/util/clock.js.map +1 -1
  66. package/package.json +14 -14
  67. package/src/api/impl/config/constants.ts +10 -4
  68. package/src/api/impl/validator/index.ts +5 -2
  69. package/src/chain/chain.ts +2 -2
  70. package/src/chain/errors/voluntaryExitError.ts +30 -2
  71. package/src/chain/lightClient/index.ts +26 -12
  72. package/src/chain/opPools/syncContributionAndProofPool.ts +3 -2
  73. package/src/chain/validation/attestation.ts +6 -7
  74. package/src/chain/validation/block.ts +1 -2
  75. package/src/chain/validation/lightClientOptimisticUpdate.ts +3 -2
  76. package/src/chain/validation/voluntaryExit.ts +14 -4
  77. package/src/constants/constants.ts +0 -6
  78. package/src/constants/network.ts +0 -19
  79. package/src/metrics/metrics/lodestar.ts +4 -0
  80. package/src/network/discv5/utils.ts +1 -2
  81. package/src/network/gossip/gossipsub.ts +1 -10
  82. package/src/network/reqresp/handlers/blobSidecarsByRange.ts +6 -6
  83. package/src/network/reqresp/handlers/blobSidecarsByRoot.ts +5 -5
  84. package/src/network/subnets/attnetsService.ts +6 -6
  85. package/src/network/subnets/util.ts +12 -12
  86. package/src/util/clock.ts +3 -4
@@ -1,5 +1,5 @@
1
1
  import {ChainConfig} from "@lodestar/config";
2
- import {BLOBSIDECAR_FIXED_SIZE, GENESIS_SLOT} from "@lodestar/params";
2
+ import {BLOB_SIDECAR_FIXED_SIZE, GENESIS_SLOT} from "@lodestar/params";
3
3
  import {RespStatus, ResponseError, ResponseOutgoing} from "@lodestar/reqresp";
4
4
  import {computeEpochAtSlot} from "@lodestar/state-transition";
5
5
  import {Slot, deneb} from "@lodestar/types";
@@ -71,17 +71,17 @@ export function* iterateBlobBytesFromWrapper(
71
71
  blockSlot: Slot
72
72
  ): Iterable<ResponseOutgoing> {
73
73
  const allBlobSideCarsBytes = blobSideCarsBytesWrapped.slice(BLOB_SIDECARS_IN_WRAPPER_INDEX);
74
- const blobsLen = allBlobSideCarsBytes.length / BLOBSIDECAR_FIXED_SIZE;
74
+ const blobsLen = allBlobSideCarsBytes.length / BLOB_SIDECAR_FIXED_SIZE;
75
75
 
76
76
  for (let index = 0; index < blobsLen; index++) {
77
77
  const blobSideCarBytes = allBlobSideCarsBytes.slice(
78
- index * BLOBSIDECAR_FIXED_SIZE,
79
- (index + 1) * BLOBSIDECAR_FIXED_SIZE
78
+ index * BLOB_SIDECAR_FIXED_SIZE,
79
+ (index + 1) * BLOB_SIDECAR_FIXED_SIZE
80
80
  );
81
- if (blobSideCarBytes.length !== BLOBSIDECAR_FIXED_SIZE) {
81
+ if (blobSideCarBytes.length !== BLOB_SIDECAR_FIXED_SIZE) {
82
82
  throw new ResponseError(
83
83
  RespStatus.SERVER_ERROR,
84
- `Invalid blobSidecar index=${index} bytes length=${blobSideCarBytes.length} expected=${BLOBSIDECAR_FIXED_SIZE} for slot ${blockSlot} blobsLen=${blobsLen}`
84
+ `Invalid blobSidecar index=${index} bytes length=${blobSideCarBytes.length} expected=${BLOB_SIDECAR_FIXED_SIZE} for slot ${blockSlot} blobsLen=${blobsLen}`
85
85
  );
86
86
  }
87
87
  yield {
@@ -1,4 +1,4 @@
1
- import {BLOBSIDECAR_FIXED_SIZE} from "@lodestar/params";
1
+ import {BLOB_SIDECAR_FIXED_SIZE} from "@lodestar/params";
2
2
  import {RespStatus, ResponseError, ResponseOutgoing} from "@lodestar/reqresp";
3
3
  import {computeEpochAtSlot} from "@lodestar/state-transition";
4
4
  import {RootHex} from "@lodestar/types";
@@ -45,12 +45,12 @@ export async function* onBlobSidecarsByRoot(
45
45
  }
46
46
 
47
47
  const blobSidecarBytes = lastFetchedSideCars.bytes.slice(
48
- index * BLOBSIDECAR_FIXED_SIZE,
49
- (index + 1) * BLOBSIDECAR_FIXED_SIZE
48
+ index * BLOB_SIDECAR_FIXED_SIZE,
49
+ (index + 1) * BLOB_SIDECAR_FIXED_SIZE
50
50
  );
51
- if (blobSidecarBytes.length !== BLOBSIDECAR_FIXED_SIZE) {
51
+ if (blobSidecarBytes.length !== BLOB_SIDECAR_FIXED_SIZE) {
52
52
  throw Error(
53
- `Inconsistent state, blobSidecar blockRoot=${blockRootHex} index=${index} blobSidecarBytes=${blobSidecarBytes.length} expected=${BLOBSIDECAR_FIXED_SIZE}`
53
+ `Inconsistent state, blobSidecar blockRoot=${blockRootHex} index=${index} blobSidecarBytes=${blobSidecarBytes.length} expected=${BLOB_SIDECAR_FIXED_SIZE}`
54
54
  );
55
55
  }
56
56
 
@@ -1,5 +1,5 @@
1
1
  import {BeaconConfig, ForkBoundary} from "@lodestar/config";
2
- import {ATTESTATION_SUBNET_COUNT, EPOCHS_PER_RANDOM_SUBNET_SUBSCRIPTION, SLOTS_PER_EPOCH} from "@lodestar/params";
2
+ import {ATTESTATION_SUBNET_COUNT, SLOTS_PER_EPOCH} from "@lodestar/params";
3
3
  import {computeEpochAtSlot} from "@lodestar/state-transition";
4
4
  import {Epoch, Slot, SubnetID, ssz} from "@lodestar/types";
5
5
  import {Logger, MapDef} from "@lodestar/utils";
@@ -92,8 +92,8 @@ export class AttnetsService implements IAttnetsService {
92
92
  const shortLivedSubnets = this.committeeSubnets.getActiveTtl(this.clock.currentSlot);
93
93
 
94
94
  const longLivedSubscriptionsToSlot =
95
- (Math.floor(this.clock.currentEpoch / EPOCHS_PER_RANDOM_SUBNET_SUBSCRIPTION) + 1) *
96
- EPOCHS_PER_RANDOM_SUBNET_SUBSCRIPTION *
95
+ (Math.floor(this.clock.currentEpoch / this.config.EPOCHS_PER_SUBNET_SUBSCRIPTION) + 1) *
96
+ this.config.EPOCHS_PER_SUBNET_SUBSCRIPTION *
97
97
  SLOTS_PER_EPOCH;
98
98
  const longLivedSubnets = Array.from(this.longLivedSubscriptions).map((subnet) => ({
99
99
  subnet,
@@ -234,11 +234,11 @@ export class AttnetsService implements IAttnetsService {
234
234
 
235
235
  /**
236
236
  * Run per epoch, clean-up operations that are not urgent
237
- * Subscribe to new random subnets every EPOCHS_PER_RANDOM_SUBNET_SUBSCRIPTION epochs
237
+ * Subscribe to new random subnets every EPOCHS_PER_SUBNET_SUBSCRIPTION epochs
238
238
  */
239
239
  private onEpoch = (epoch: Epoch): void => {
240
240
  try {
241
- if (epoch % EPOCHS_PER_RANDOM_SUBNET_SUBSCRIPTION === 0) {
241
+ if (epoch % this.config.EPOCHS_PER_SUBNET_SUBSCRIPTION === 0) {
242
242
  this.recomputeLongLivedSubnets();
243
243
  }
244
244
  } catch (e) {
@@ -253,7 +253,7 @@ export class AttnetsService implements IAttnetsService {
253
253
  }
254
254
 
255
255
  const oldSubnets = this.longLivedSubscriptions;
256
- const newSubnets = computeSubscribedSubnet(this.nodeId, this.clock.currentEpoch);
256
+ const newSubnets = computeSubscribedSubnet(this.config, this.nodeId, this.clock.currentEpoch);
257
257
  this.logger.verbose("Recomputing long-lived subscriptions", {
258
258
  epoch: this.clock.currentEpoch,
259
259
  oldSubnets: Array.from(oldSubnets).join(","),
@@ -1,11 +1,6 @@
1
1
  import {digest} from "@chainsafe/as-sha256";
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";
2
+ import {ChainConfig} from "@lodestar/config";
3
+ import {ATTESTATION_SUBNET_COUNT, ATTESTATION_SUBNET_PREFIX_BITS, NODE_ID_BITS} from "@lodestar/params";
9
4
  import {computeShuffledIndex} from "@lodestar/state-transition";
10
5
  import {Epoch, ssz} from "@lodestar/types";
11
6
  import {NodeId} from "./interface.js";
@@ -13,10 +8,10 @@ import {NodeId} from "./interface.js";
13
8
  /**
14
9
  * Spec https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.3/specs/phase0/p2p-interface.md
15
10
  */
16
- export function computeSubscribedSubnet(nodeId: NodeId, epoch: Epoch): number[] {
11
+ export function computeSubscribedSubnet(config: ChainConfig, nodeId: NodeId, epoch: Epoch): number[] {
17
12
  const subnets: number[] = [];
18
- for (let index = 0; index < SUBNETS_PER_NODE; index++) {
19
- subnets.push(computeSubscribedSubnetByIndex(nodeId, epoch, index));
13
+ for (let index = 0; index < config.SUBNETS_PER_NODE; index++) {
14
+ subnets.push(computeSubscribedSubnetByIndex(config, nodeId, epoch, index));
20
15
  }
21
16
  return subnets;
22
17
  }
@@ -24,11 +19,16 @@ export function computeSubscribedSubnet(nodeId: NodeId, epoch: Epoch): number[]
24
19
  /**
25
20
  * Spec https://github.com/ethereum/consensus-specs/blob/v1.4.0-alpha.3/specs/phase0/p2p-interface.md
26
21
  */
27
- export function computeSubscribedSubnetByIndex(nodeId: NodeId, epoch: Epoch, index: number): number {
22
+ export function computeSubscribedSubnetByIndex(
23
+ config: ChainConfig,
24
+ nodeId: NodeId,
25
+ epoch: Epoch,
26
+ index: number
27
+ ): 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) / EPOCHS_PER_SUBNET_SUBSCRIPTION))
31
+ ssz.UintNum64.serialize(Math.floor((epoch + nodeOffset) / config.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,7 +4,6 @@ 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";
8
7
 
9
8
  export enum ClockEvent {
10
9
  /**
@@ -101,7 +100,7 @@ export class Clock extends EventEmitter implements IClock {
101
100
  get currentSlotWithGossipDisparity(): Slot {
102
101
  const currentSlot = this.currentSlot;
103
102
  const nextSlotTime = computeTimeAtSlot(this.config, currentSlot + 1, this.genesisTime) * 1000;
104
- return nextSlotTime - Date.now() < MAXIMUM_GOSSIP_CLOCK_DISPARITY ? currentSlot + 1 : currentSlot;
103
+ return nextSlotTime - Date.now() < this.config.MAXIMUM_GOSSIP_CLOCK_DISPARITY ? currentSlot + 1 : currentSlot;
105
104
  }
106
105
 
107
106
  get currentEpoch(): Epoch {
@@ -130,12 +129,12 @@ export class Clock extends EventEmitter implements IClock {
130
129
  }
131
130
  const nextSlotTime = computeTimeAtSlot(this.config, currentSlot + 1, this.genesisTime) * 1000;
132
131
  // we're too close to next slot, accept next slot
133
- if (nextSlotTime - Date.now() < MAXIMUM_GOSSIP_CLOCK_DISPARITY) {
132
+ if (nextSlotTime - Date.now() < this.config.MAXIMUM_GOSSIP_CLOCK_DISPARITY) {
134
133
  return slot === currentSlot + 1;
135
134
  }
136
135
  const currentSlotTime = computeTimeAtSlot(this.config, currentSlot, this.genesisTime) * 1000;
137
136
  // we've just passed the current slot, accept previous slot
138
- if (Date.now() - currentSlotTime < MAXIMUM_GOSSIP_CLOCK_DISPARITY) {
137
+ if (Date.now() - currentSlotTime < this.config.MAXIMUM_GOSSIP_CLOCK_DISPARITY) {
139
138
  return slot === currentSlot - 1;
140
139
  }
141
140
  return false;