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

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 (251) hide show
  1. package/lib/api/impl/beacon/blocks/index.d.ts.map +1 -1
  2. package/lib/api/impl/beacon/blocks/index.js +41 -22
  3. package/lib/api/impl/beacon/blocks/index.js.map +1 -1
  4. package/lib/api/impl/config/constants.d.ts +4 -2
  5. package/lib/api/impl/config/constants.d.ts.map +1 -1
  6. package/lib/api/impl/config/constants.js +6 -3
  7. package/lib/api/impl/config/constants.js.map +1 -1
  8. package/lib/api/impl/lodestar/index.d.ts +5 -0
  9. package/lib/api/impl/lodestar/index.d.ts.map +1 -1
  10. package/lib/api/impl/lodestar/index.js +35 -10
  11. package/lib/api/impl/lodestar/index.js.map +1 -1
  12. package/lib/api/impl/node/utils.js +1 -1
  13. package/lib/api/impl/node/utils.js.map +1 -1
  14. package/lib/api/impl/validator/index.d.ts.map +1 -1
  15. package/lib/api/impl/validator/index.js +2 -2
  16. package/lib/api/impl/validator/index.js.map +1 -1
  17. package/lib/chain/archiveStore/archiveStore.d.ts +9 -0
  18. package/lib/chain/archiveStore/archiveStore.d.ts.map +1 -1
  19. package/lib/chain/archiveStore/archiveStore.js +24 -0
  20. package/lib/chain/archiveStore/archiveStore.js.map +1 -1
  21. package/lib/chain/archiveStore/strategies/frequencyStateArchiveStrategy.d.ts +7 -0
  22. package/lib/chain/archiveStore/strategies/frequencyStateArchiveStrategy.d.ts.map +1 -1
  23. package/lib/chain/archiveStore/strategies/frequencyStateArchiveStrategy.js +31 -5
  24. package/lib/chain/archiveStore/strategies/frequencyStateArchiveStrategy.js.map +1 -1
  25. package/lib/chain/beaconProposerCache.d.ts +3 -0
  26. package/lib/chain/beaconProposerCache.d.ts.map +1 -1
  27. package/lib/chain/beaconProposerCache.js +4 -6
  28. package/lib/chain/beaconProposerCache.js.map +1 -1
  29. package/lib/chain/chain.d.ts +5 -2
  30. package/lib/chain/chain.d.ts.map +1 -1
  31. package/lib/chain/chain.js +34 -18
  32. package/lib/chain/chain.js.map +1 -1
  33. package/lib/chain/errors/dataColumnSidecarError.d.ts +23 -13
  34. package/lib/chain/errors/dataColumnSidecarError.d.ts.map +1 -1
  35. package/lib/chain/errors/dataColumnSidecarError.js +5 -0
  36. package/lib/chain/errors/dataColumnSidecarError.js.map +1 -1
  37. package/lib/chain/errors/voluntaryExitError.d.ts +16 -2
  38. package/lib/chain/errors/voluntaryExitError.d.ts.map +1 -1
  39. package/lib/chain/errors/voluntaryExitError.js +22 -1
  40. package/lib/chain/errors/voluntaryExitError.js.map +1 -1
  41. package/lib/chain/forkChoice/index.d.ts +9 -1
  42. package/lib/chain/forkChoice/index.d.ts.map +1 -1
  43. package/lib/chain/forkChoice/index.js +109 -4
  44. package/lib/chain/forkChoice/index.js.map +1 -1
  45. package/lib/chain/interface.d.ts +2 -0
  46. package/lib/chain/interface.d.ts.map +1 -1
  47. package/lib/chain/lightClient/index.d.ts +3 -0
  48. package/lib/chain/lightClient/index.d.ts.map +1 -1
  49. package/lib/chain/lightClient/index.js +24 -13
  50. package/lib/chain/lightClient/index.js.map +1 -1
  51. package/lib/chain/opPools/syncContributionAndProofPool.d.ts +3 -1
  52. package/lib/chain/opPools/syncContributionAndProofPool.d.ts.map +1 -1
  53. package/lib/chain/opPools/syncContributionAndProofPool.js +4 -3
  54. package/lib/chain/opPools/syncContributionAndProofPool.js.map +1 -1
  55. package/lib/chain/options.d.ts +0 -2
  56. package/lib/chain/options.d.ts.map +1 -1
  57. package/lib/chain/options.js +0 -1
  58. package/lib/chain/options.js.map +1 -1
  59. package/lib/chain/stateCache/datastore/db.d.ts +12 -0
  60. package/lib/chain/stateCache/datastore/db.d.ts.map +1 -1
  61. package/lib/chain/stateCache/datastore/db.js +70 -0
  62. package/lib/chain/stateCache/datastore/db.js.map +1 -1
  63. package/lib/chain/stateCache/datastore/file.d.ts +1 -0
  64. package/lib/chain/stateCache/datastore/file.d.ts.map +1 -1
  65. package/lib/chain/stateCache/datastore/file.js +7 -0
  66. package/lib/chain/stateCache/datastore/file.js.map +1 -1
  67. package/lib/chain/stateCache/datastore/types.d.ts +1 -0
  68. package/lib/chain/stateCache/datastore/types.d.ts.map +1 -1
  69. package/lib/chain/validation/attestation.d.ts.map +1 -1
  70. package/lib/chain/validation/attestation.js +6 -7
  71. package/lib/chain/validation/attestation.js.map +1 -1
  72. package/lib/chain/validation/block.d.ts.map +1 -1
  73. package/lib/chain/validation/block.js +1 -2
  74. package/lib/chain/validation/block.js.map +1 -1
  75. package/lib/chain/validation/dataColumnSidecar.d.ts.map +1 -1
  76. package/lib/chain/validation/dataColumnSidecar.js +45 -17
  77. package/lib/chain/validation/dataColumnSidecar.js.map +1 -1
  78. package/lib/chain/validation/lightClientOptimisticUpdate.d.ts.map +1 -1
  79. package/lib/chain/validation/lightClientOptimisticUpdate.js +1 -2
  80. package/lib/chain/validation/lightClientOptimisticUpdate.js.map +1 -1
  81. package/lib/chain/validation/voluntaryExit.d.ts.map +1 -1
  82. package/lib/chain/validation/voluntaryExit.js +5 -4
  83. package/lib/chain/validation/voluntaryExit.js.map +1 -1
  84. package/lib/constants/constants.d.ts +0 -5
  85. package/lib/constants/constants.d.ts.map +1 -1
  86. package/lib/constants/constants.js +0 -5
  87. package/lib/constants/constants.js.map +1 -1
  88. package/lib/constants/network.d.ts +0 -14
  89. package/lib/constants/network.d.ts.map +1 -1
  90. package/lib/constants/network.js +0 -15
  91. package/lib/constants/network.js.map +1 -1
  92. package/lib/index.d.ts +2 -0
  93. package/lib/index.d.ts.map +1 -1
  94. package/lib/index.js +2 -0
  95. package/lib/index.js.map +1 -1
  96. package/lib/metrics/metrics/lodestar.d.ts +11 -0
  97. package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
  98. package/lib/metrics/metrics/lodestar.js +19 -1
  99. package/lib/metrics/metrics/lodestar.js.map +1 -1
  100. package/lib/network/core/networkCore.d.ts.map +1 -1
  101. package/lib/network/core/networkCore.js +5 -1
  102. package/lib/network/core/networkCore.js.map +1 -1
  103. package/lib/network/core/networkCoreWorker.js +8 -8
  104. package/lib/network/core/networkCoreWorker.js.map +1 -1
  105. package/lib/network/core/networkCoreWorkerHandler.js +1 -1
  106. package/lib/network/core/networkCoreWorkerHandler.js.map +1 -1
  107. package/lib/network/discv5/utils.d.ts.map +1 -1
  108. package/lib/network/discv5/utils.js +1 -2
  109. package/lib/network/discv5/utils.js.map +1 -1
  110. package/lib/network/discv5/worker.js +2 -7
  111. package/lib/network/discv5/worker.js.map +1 -1
  112. package/lib/network/events.d.ts +1 -0
  113. package/lib/network/events.d.ts.map +1 -1
  114. package/lib/network/gossip/encoding.js +1 -1
  115. package/lib/network/gossip/encoding.js.map +1 -1
  116. package/lib/network/gossip/gossipsub.d.ts.map +1 -1
  117. package/lib/network/gossip/gossipsub.js +1 -7
  118. package/lib/network/gossip/gossipsub.js.map +1 -1
  119. package/lib/network/gossip/snappy_bun.d.ts +3 -0
  120. package/lib/network/gossip/snappy_bun.d.ts.map +1 -0
  121. package/lib/network/gossip/snappy_bun.js +3 -0
  122. package/lib/network/gossip/snappy_bun.js.map +1 -0
  123. package/lib/network/metadata.d.ts +1 -1
  124. package/lib/network/metadata.d.ts.map +1 -1
  125. package/lib/network/metadata.js +1 -0
  126. package/lib/network/metadata.js.map +1 -1
  127. package/lib/network/options.d.ts +0 -1
  128. package/lib/network/options.d.ts.map +1 -1
  129. package/lib/network/options.js.map +1 -1
  130. package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
  131. package/lib/network/processor/gossipHandlers.js +14 -8
  132. package/lib/network/processor/gossipHandlers.js.map +1 -1
  133. package/lib/network/reqresp/ReqRespBeaconNode.d.ts.map +1 -1
  134. package/lib/network/reqresp/ReqRespBeaconNode.js +3 -1
  135. package/lib/network/reqresp/ReqRespBeaconNode.js.map +1 -1
  136. package/lib/network/reqresp/handlers/beaconBlocksByRange.d.ts +2 -1
  137. package/lib/network/reqresp/handlers/beaconBlocksByRange.d.ts.map +1 -1
  138. package/lib/network/reqresp/handlers/beaconBlocksByRange.js +14 -3
  139. package/lib/network/reqresp/handlers/beaconBlocksByRange.js.map +1 -1
  140. package/lib/network/reqresp/handlers/blobSidecarsByRange.js +5 -5
  141. package/lib/network/reqresp/handlers/blobSidecarsByRange.js.map +1 -1
  142. package/lib/network/reqresp/handlers/blobSidecarsByRoot.js +4 -4
  143. package/lib/network/reqresp/handlers/blobSidecarsByRoot.js.map +1 -1
  144. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.d.ts +2 -1
  145. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.d.ts.map +1 -1
  146. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js +9 -1
  147. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js.map +1 -1
  148. package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.d.ts +2 -1
  149. package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.d.ts.map +1 -1
  150. package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.js +9 -1
  151. package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.js.map +1 -1
  152. package/lib/network/reqresp/handlers/index.js +6 -6
  153. package/lib/network/reqresp/handlers/index.js.map +1 -1
  154. package/lib/network/reqresp/types.d.ts +1 -0
  155. package/lib/network/reqresp/types.d.ts.map +1 -1
  156. package/lib/network/subnets/attnetsService.d.ts +1 -1
  157. package/lib/network/subnets/attnetsService.js +6 -6
  158. package/lib/network/subnets/attnetsService.js.map +1 -1
  159. package/lib/network/subnets/util.d.ts +3 -2
  160. package/lib/network/subnets/util.d.ts.map +1 -1
  161. package/lib/network/subnets/util.js +6 -6
  162. package/lib/network/subnets/util.js.map +1 -1
  163. package/lib/node/nodejs.d.ts +2 -1
  164. package/lib/node/nodejs.d.ts.map +1 -1
  165. package/lib/node/nodejs.js +2 -1
  166. package/lib/node/nodejs.js.map +1 -1
  167. package/lib/sync/range/range.d.ts.map +1 -1
  168. package/lib/sync/range/range.js +2 -1
  169. package/lib/sync/range/range.js.map +1 -1
  170. package/lib/sync/utils/downloadByRange.d.ts +58 -13
  171. package/lib/sync/utils/downloadByRange.d.ts.map +1 -1
  172. package/lib/sync/utils/downloadByRange.js +201 -82
  173. package/lib/sync/utils/downloadByRange.js.map +1 -1
  174. package/lib/sync/utils/remoteSyncType.d.ts +2 -1
  175. package/lib/sync/utils/remoteSyncType.d.ts.map +1 -1
  176. package/lib/sync/utils/remoteSyncType.js +19 -4
  177. package/lib/sync/utils/remoteSyncType.js.map +1 -1
  178. package/lib/util/blobs.d.ts +1 -1
  179. package/lib/util/blobs.d.ts.map +1 -1
  180. package/lib/util/blobs.js +53 -20
  181. package/lib/util/blobs.js.map +1 -1
  182. package/lib/util/clock.d.ts.map +1 -1
  183. package/lib/util/clock.js +3 -4
  184. package/lib/util/clock.js.map +1 -1
  185. package/lib/util/profile.d.ts +6 -4
  186. package/lib/util/profile.d.ts.map +1 -1
  187. package/lib/util/profile.js +40 -3
  188. package/lib/util/profile.js.map +1 -1
  189. package/lib/util/sszBytes.d.ts +2 -0
  190. package/lib/util/sszBytes.d.ts.map +1 -1
  191. package/lib/util/sszBytes.js +25 -0
  192. package/lib/util/sszBytes.js.map +1 -1
  193. package/package.json +31 -24
  194. package/src/api/impl/beacon/blocks/index.ts +47 -25
  195. package/src/api/impl/config/constants.ts +10 -4
  196. package/src/api/impl/lodestar/index.ts +42 -10
  197. package/src/api/impl/node/utils.ts +1 -1
  198. package/src/api/impl/validator/index.ts +5 -2
  199. package/src/chain/archiveStore/archiveStore.ts +27 -0
  200. package/src/chain/archiveStore/strategies/frequencyStateArchiveStrategy.ts +32 -5
  201. package/src/chain/beaconProposerCache.ts +4 -8
  202. package/src/chain/chain.ts +50 -25
  203. package/src/chain/errors/dataColumnSidecarError.ts +27 -13
  204. package/src/chain/errors/voluntaryExitError.ts +30 -2
  205. package/src/chain/forkChoice/index.ts +178 -2
  206. package/src/chain/interface.ts +2 -0
  207. package/src/chain/lightClient/index.ts +26 -12
  208. package/src/chain/opPools/syncContributionAndProofPool.ts +3 -2
  209. package/src/chain/options.ts +0 -3
  210. package/src/chain/stateCache/datastore/db.ts +89 -1
  211. package/src/chain/stateCache/datastore/file.ts +8 -0
  212. package/src/chain/stateCache/datastore/types.ts +1 -0
  213. package/src/chain/validation/attestation.ts +6 -7
  214. package/src/chain/validation/block.ts +1 -2
  215. package/src/chain/validation/dataColumnSidecar.ts +54 -19
  216. package/src/chain/validation/lightClientOptimisticUpdate.ts +3 -2
  217. package/src/chain/validation/voluntaryExit.ts +14 -4
  218. package/src/constants/constants.ts +0 -6
  219. package/src/constants/network.ts +0 -19
  220. package/src/index.ts +2 -0
  221. package/src/metrics/metrics/lodestar.ts +22 -1
  222. package/src/network/core/networkCore.ts +5 -1
  223. package/src/network/core/networkCoreWorker.ts +9 -9
  224. package/src/network/core/networkCoreWorkerHandler.ts +1 -1
  225. package/src/network/discv5/utils.ts +1 -2
  226. package/src/network/discv5/worker.ts +2 -7
  227. package/src/network/events.ts +1 -1
  228. package/src/network/gossip/encoding.ts +1 -1
  229. package/src/network/gossip/gossipsub.ts +1 -10
  230. package/src/network/gossip/snappy_bun.ts +2 -0
  231. package/src/network/metadata.ts +3 -1
  232. package/src/network/options.ts +0 -1
  233. package/src/network/processor/gossipHandlers.ts +16 -7
  234. package/src/network/reqresp/ReqRespBeaconNode.ts +3 -1
  235. package/src/network/reqresp/handlers/beaconBlocksByRange.ts +18 -3
  236. package/src/network/reqresp/handlers/blobSidecarsByRange.ts +6 -6
  237. package/src/network/reqresp/handlers/blobSidecarsByRoot.ts +5 -5
  238. package/src/network/reqresp/handlers/dataColumnSidecarsByRange.ts +13 -1
  239. package/src/network/reqresp/handlers/dataColumnSidecarsByRoot.ts +13 -1
  240. package/src/network/reqresp/handlers/index.ts +6 -6
  241. package/src/network/reqresp/types.ts +1 -0
  242. package/src/network/subnets/attnetsService.ts +6 -6
  243. package/src/network/subnets/util.ts +12 -12
  244. package/src/node/nodejs.ts +3 -0
  245. package/src/sync/range/range.ts +2 -1
  246. package/src/sync/utils/downloadByRange.ts +259 -103
  247. package/src/sync/utils/remoteSyncType.ts +23 -4
  248. package/src/util/blobs.ts +64 -20
  249. package/src/util/clock.ts +3 -4
  250. package/src/util/profile.ts +45 -3
  251. package/src/util/sszBytes.ts +30 -0
@@ -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,3 +1,4 @@
1
+ import {PeerId} from "@libp2p/interface";
1
2
  import {ChainConfig} from "@lodestar/config";
2
3
  import {GENESIS_SLOT} from "@lodestar/params";
3
4
  import {RespStatus, ResponseError, ResponseOutgoing} from "@lodestar/reqresp";
@@ -6,6 +7,7 @@ import {ColumnIndex, fulu} from "@lodestar/types";
6
7
  import {fromHex} from "@lodestar/utils";
7
8
  import {IBeaconChain} from "../../../chain/index.js";
8
9
  import {IBeaconDb} from "../../../db/index.js";
10
+ import {prettyPrintPeerId} from "../../util.ts";
9
11
  import {
10
12
  handleColumnSidecarUnavailability,
11
13
  validateRequestedDataColumns,
@@ -14,7 +16,9 @@ import {
14
16
  export async function* onDataColumnSidecarsByRange(
15
17
  request: fulu.DataColumnSidecarsByRangeRequest,
16
18
  chain: IBeaconChain,
17
- db: IBeaconDb
19
+ db: IBeaconDb,
20
+ peerId: PeerId,
21
+ peerClient: string
18
22
  ): AsyncIterable<ResponseOutgoing> {
19
23
  // Non-finalized range of columns
20
24
  const {startSlot, count, columns: requestedColumns} = validateDataColumnSidecarsByRangeRequest(chain.config, request);
@@ -25,6 +29,14 @@ export async function* onDataColumnSidecarsByRange(
25
29
  return;
26
30
  }
27
31
 
32
+ if (startSlot < chain.earliestAvailableSlot) {
33
+ chain.logger.verbose("Peer did not respect earliestAvailableSlot for DataColumnSidecarsByRange", {
34
+ peer: prettyPrintPeerId(peerId),
35
+ client: peerClient,
36
+ });
37
+ return;
38
+ }
39
+
28
40
  const finalized = db.dataColumnSidecarArchive;
29
41
  const unfinalized = db.dataColumnSidecar;
30
42
  const finalizedSlot = chain.forkChoice.getFinalizedBlock().slot;
@@ -1,3 +1,4 @@
1
+ import {PeerId} from "@libp2p/interface";
1
2
  import {ResponseOutgoing} from "@lodestar/reqresp";
2
3
  import {computeEpochAtSlot} from "@lodestar/state-transition";
3
4
  import {ColumnIndex} from "@lodestar/types";
@@ -5,6 +6,7 @@ import {toRootHex} from "@lodestar/utils";
5
6
  import {IBeaconChain} from "../../../chain/index.js";
6
7
  import {IBeaconDb} from "../../../db/index.js";
7
8
  import {DataColumnSidecarsByRootRequest} from "../../../util/types.js";
9
+ import {prettyPrintPeerId} from "../../util.ts";
8
10
  import {
9
11
  handleColumnSidecarUnavailability,
10
12
  validateRequestedDataColumns,
@@ -13,7 +15,9 @@ import {
13
15
  export async function* onDataColumnSidecarsByRoot(
14
16
  requestBody: DataColumnSidecarsByRootRequest,
15
17
  chain: IBeaconChain,
16
- db: IBeaconDb
18
+ db: IBeaconDb,
19
+ peerId: PeerId,
20
+ peerClient: string
17
21
  ): AsyncIterable<ResponseOutgoing> {
18
22
  // SPEC: minimum_request_epoch = max(current_epoch - MIN_EPOCHS_FOR_DATA_COLUMN_SIDECARS_REQUESTS, FULU_FORK_EPOCH)
19
23
  const currentEpoch = chain.clock.currentEpoch;
@@ -39,6 +43,14 @@ export async function* onDataColumnSidecarsByRoot(
39
43
  continue;
40
44
  }
41
45
 
46
+ if (slot < chain.earliestAvailableSlot) {
47
+ chain.logger.verbose("Peer did not respect earliestAvailableSlot for DataColumnSidecarsByRoot", {
48
+ peer: prettyPrintPeerId(peerId),
49
+ client: peerClient,
50
+ });
51
+ continue;
52
+ }
53
+
42
54
  const requestedEpoch = computeEpochAtSlot(slot);
43
55
 
44
56
  // SPEC: Clients MUST support requesting sidecars since minimum_request_epoch.
@@ -35,9 +35,9 @@ export function getReqRespHandlers({db, chain}: {db: IBeaconDb; chain: IBeaconCh
35
35
  [ReqRespMethod.Goodbye]: notImplemented(ReqRespMethod.Goodbye),
36
36
  [ReqRespMethod.Ping]: notImplemented(ReqRespMethod.Ping),
37
37
  [ReqRespMethod.Metadata]: notImplemented(ReqRespMethod.Metadata),
38
- [ReqRespMethod.BeaconBlocksByRange]: (req) => {
38
+ [ReqRespMethod.BeaconBlocksByRange]: (req, peerId, peerClient) => {
39
39
  const body = ssz.phase0.BeaconBlocksByRangeRequest.deserialize(req.data);
40
- return onBeaconBlocksByRange(body, chain, db);
40
+ return onBeaconBlocksByRange(body, chain, db, peerId, peerClient);
41
41
  },
42
42
  [ReqRespMethod.BeaconBlocksByRoot]: (req) => {
43
43
  const fork = chain.config.getForkName(chain.clock.currentSlot);
@@ -53,13 +53,13 @@ export function getReqRespHandlers({db, chain}: {db: IBeaconDb; chain: IBeaconCh
53
53
  const body = ssz.deneb.BlobSidecarsByRangeRequest.deserialize(req.data);
54
54
  return onBlobSidecarsByRange(body, chain, db);
55
55
  },
56
- [ReqRespMethod.DataColumnSidecarsByRange]: (req) => {
56
+ [ReqRespMethod.DataColumnSidecarsByRange]: (req, peerId, peerClient) => {
57
57
  const body = ssz.fulu.DataColumnSidecarsByRangeRequest.deserialize(req.data);
58
- return onDataColumnSidecarsByRange(body, chain, db);
58
+ return onDataColumnSidecarsByRange(body, chain, db, peerId, peerClient);
59
59
  },
60
- [ReqRespMethod.DataColumnSidecarsByRoot]: (req) => {
60
+ [ReqRespMethod.DataColumnSidecarsByRoot]: (req, peerId, peerClient) => {
61
61
  const body = DataColumnSidecarsByRootRequestType(chain.config).deserialize(req.data);
62
- return onDataColumnSidecarsByRoot(body, chain, db);
62
+ return onDataColumnSidecarsByRoot(body, chain, db, peerId, peerClient);
63
63
  },
64
64
 
65
65
  [ReqRespMethod.LightClientBootstrap]: (req) => {
@@ -169,6 +169,7 @@ export type IncomingRequestArgs = {
169
169
  method: ReqRespMethod;
170
170
  req: ReqRespRequest;
171
171
  peerId: string;
172
+ peerClient: string;
172
173
  };
173
174
 
174
175
  export type GetReqRespHandlerFn = (method: ReqRespMethod) => ProtocolHandler;
@@ -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;
@@ -53,6 +53,7 @@ export type BeaconNodeInitModules = {
53
53
  dataDir: string;
54
54
  peerStoreDir?: string;
55
55
  anchorState: BeaconStateAllForks;
56
+ isAnchorStateFinalized: boolean;
56
57
  wsCheckpoint?: phase0.Checkpoint;
57
58
  metricsRegistries?: Registry[];
58
59
  };
@@ -154,6 +155,7 @@ export class BeaconNode {
154
155
  dataDir,
155
156
  peerStoreDir,
156
157
  anchorState,
158
+ isAnchorStateFinalized,
157
159
  wsCheckpoint,
158
160
  metricsRegistries = [],
159
161
  }: BeaconNodeInitModules): Promise<T> {
@@ -217,6 +219,7 @@ export class BeaconNode {
217
219
  metrics,
218
220
  validatorMonitor,
219
221
  anchorState,
222
+ isAnchorStateFinalized,
220
223
  eth1: initializeEth1ForBlockProduction(opts.eth1, {
221
224
  config,
222
225
  db,
@@ -114,13 +114,14 @@ export class RangeSync extends (EventEmitter as {new (): RangeSyncEmitter}) {
114
114
  */
115
115
  addPeer(peerId: PeerIdStr, localStatus: Status, peerStatus: Status): void {
116
116
  // Compute if we should do a Finalized or Head sync with this peer
117
- const {syncType, startEpoch, target} = getRangeSyncTarget(localStatus, peerStatus, this.chain.forkChoice);
117
+ const {syncType, startEpoch, target} = getRangeSyncTarget(localStatus, peerStatus, this.chain);
118
118
  this.logger.debug("Sync peer joined", {
119
119
  peer: peerId,
120
120
  syncType,
121
121
  startEpoch,
122
122
  targetSlot: target.slot,
123
123
  targetRoot: toRootHex(target.root),
124
+ localHeadSlot: localStatus.headSlot,
124
125
  earliestAvailableSlot: (peerStatus as fulu.Status).earliestAvailableSlot ?? Infinity,
125
126
  });
126
127