@lodestar/beacon-node 1.36.0-dev.793f92c091 → 1.36.0-dev.801b1f4f52

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 (294) 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/blobSidecarError.d.ts +5 -0
  34. package/lib/chain/errors/blobSidecarError.d.ts.map +1 -1
  35. package/lib/chain/errors/blobSidecarError.js.map +1 -1
  36. package/lib/chain/errors/blockError.d.ts +1 -0
  37. package/lib/chain/errors/blockError.d.ts.map +1 -1
  38. package/lib/chain/errors/dataColumnSidecarError.d.ts +27 -13
  39. package/lib/chain/errors/dataColumnSidecarError.d.ts.map +1 -1
  40. package/lib/chain/errors/dataColumnSidecarError.js +5 -0
  41. package/lib/chain/errors/dataColumnSidecarError.js.map +1 -1
  42. package/lib/chain/errors/voluntaryExitError.d.ts +16 -2
  43. package/lib/chain/errors/voluntaryExitError.d.ts.map +1 -1
  44. package/lib/chain/errors/voluntaryExitError.js +22 -1
  45. package/lib/chain/errors/voluntaryExitError.js.map +1 -1
  46. package/lib/chain/forkChoice/index.d.ts +9 -1
  47. package/lib/chain/forkChoice/index.d.ts.map +1 -1
  48. package/lib/chain/forkChoice/index.js +109 -4
  49. package/lib/chain/forkChoice/index.js.map +1 -1
  50. package/lib/chain/interface.d.ts +2 -0
  51. package/lib/chain/interface.d.ts.map +1 -1
  52. package/lib/chain/lightClient/index.d.ts +3 -0
  53. package/lib/chain/lightClient/index.d.ts.map +1 -1
  54. package/lib/chain/lightClient/index.js +24 -13
  55. package/lib/chain/lightClient/index.js.map +1 -1
  56. package/lib/chain/opPools/syncContributionAndProofPool.d.ts +3 -1
  57. package/lib/chain/opPools/syncContributionAndProofPool.d.ts.map +1 -1
  58. package/lib/chain/opPools/syncContributionAndProofPool.js +4 -3
  59. package/lib/chain/opPools/syncContributionAndProofPool.js.map +1 -1
  60. package/lib/chain/options.d.ts +0 -2
  61. package/lib/chain/options.d.ts.map +1 -1
  62. package/lib/chain/options.js +2 -2
  63. package/lib/chain/options.js.map +1 -1
  64. package/lib/chain/stateCache/datastore/db.d.ts +12 -0
  65. package/lib/chain/stateCache/datastore/db.d.ts.map +1 -1
  66. package/lib/chain/stateCache/datastore/db.js +70 -0
  67. package/lib/chain/stateCache/datastore/db.js.map +1 -1
  68. package/lib/chain/stateCache/datastore/file.d.ts +1 -0
  69. package/lib/chain/stateCache/datastore/file.d.ts.map +1 -1
  70. package/lib/chain/stateCache/datastore/file.js +7 -0
  71. package/lib/chain/stateCache/datastore/file.js.map +1 -1
  72. package/lib/chain/stateCache/datastore/types.d.ts +1 -0
  73. package/lib/chain/stateCache/datastore/types.d.ts.map +1 -1
  74. package/lib/chain/stateCache/persistentCheckpointsCache.d.ts +16 -1
  75. package/lib/chain/stateCache/persistentCheckpointsCache.d.ts.map +1 -1
  76. package/lib/chain/stateCache/persistentCheckpointsCache.js +31 -1
  77. package/lib/chain/stateCache/persistentCheckpointsCache.js.map +1 -1
  78. package/lib/chain/validation/attestation.d.ts.map +1 -1
  79. package/lib/chain/validation/attestation.js +6 -7
  80. package/lib/chain/validation/attestation.js.map +1 -1
  81. package/lib/chain/validation/blobSidecar.d.ts +4 -1
  82. package/lib/chain/validation/blobSidecar.d.ts.map +1 -1
  83. package/lib/chain/validation/blobSidecar.js +46 -11
  84. package/lib/chain/validation/blobSidecar.js.map +1 -1
  85. package/lib/chain/validation/block.d.ts.map +1 -1
  86. package/lib/chain/validation/block.js +2 -2
  87. package/lib/chain/validation/block.js.map +1 -1
  88. package/lib/chain/validation/dataColumnSidecar.d.ts +4 -1
  89. package/lib/chain/validation/dataColumnSidecar.d.ts.map +1 -1
  90. package/lib/chain/validation/dataColumnSidecar.js +76 -20
  91. package/lib/chain/validation/dataColumnSidecar.js.map +1 -1
  92. package/lib/chain/validation/lightClientOptimisticUpdate.d.ts.map +1 -1
  93. package/lib/chain/validation/lightClientOptimisticUpdate.js +1 -2
  94. package/lib/chain/validation/lightClientOptimisticUpdate.js.map +1 -1
  95. package/lib/chain/validation/voluntaryExit.d.ts.map +1 -1
  96. package/lib/chain/validation/voluntaryExit.js +5 -4
  97. package/lib/chain/validation/voluntaryExit.js.map +1 -1
  98. package/lib/constants/constants.d.ts +0 -5
  99. package/lib/constants/constants.d.ts.map +1 -1
  100. package/lib/constants/constants.js +0 -5
  101. package/lib/constants/constants.js.map +1 -1
  102. package/lib/constants/network.d.ts +0 -14
  103. package/lib/constants/network.d.ts.map +1 -1
  104. package/lib/constants/network.js +0 -15
  105. package/lib/constants/network.js.map +1 -1
  106. package/lib/index.d.ts +2 -0
  107. package/lib/index.d.ts.map +1 -1
  108. package/lib/index.js +2 -0
  109. package/lib/index.js.map +1 -1
  110. package/lib/metrics/metrics/lodestar.d.ts +11 -0
  111. package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
  112. package/lib/metrics/metrics/lodestar.js +19 -1
  113. package/lib/metrics/metrics/lodestar.js.map +1 -1
  114. package/lib/network/core/networkCore.d.ts.map +1 -1
  115. package/lib/network/core/networkCore.js +5 -1
  116. package/lib/network/core/networkCore.js.map +1 -1
  117. package/lib/network/core/networkCoreWorker.js +8 -8
  118. package/lib/network/core/networkCoreWorker.js.map +1 -1
  119. package/lib/network/core/networkCoreWorkerHandler.js +1 -1
  120. package/lib/network/core/networkCoreWorkerHandler.js.map +1 -1
  121. package/lib/network/discv5/utils.d.ts.map +1 -1
  122. package/lib/network/discv5/utils.js +1 -2
  123. package/lib/network/discv5/utils.js.map +1 -1
  124. package/lib/network/discv5/worker.js +2 -7
  125. package/lib/network/discv5/worker.js.map +1 -1
  126. package/lib/network/events.d.ts +1 -0
  127. package/lib/network/events.d.ts.map +1 -1
  128. package/lib/network/gossip/encoding.js +1 -1
  129. package/lib/network/gossip/encoding.js.map +1 -1
  130. package/lib/network/gossip/gossipsub.d.ts.map +1 -1
  131. package/lib/network/gossip/gossipsub.js +7 -8
  132. package/lib/network/gossip/gossipsub.js.map +1 -1
  133. package/lib/network/gossip/interface.d.ts +2 -0
  134. package/lib/network/gossip/interface.d.ts.map +1 -1
  135. package/lib/network/gossip/snappy_bun.d.ts +3 -0
  136. package/lib/network/gossip/snappy_bun.d.ts.map +1 -0
  137. package/lib/network/gossip/snappy_bun.js +3 -0
  138. package/lib/network/gossip/snappy_bun.js.map +1 -0
  139. package/lib/network/metadata.d.ts +1 -1
  140. package/lib/network/metadata.d.ts.map +1 -1
  141. package/lib/network/metadata.js +1 -0
  142. package/lib/network/metadata.js.map +1 -1
  143. package/lib/network/network.d.ts.map +1 -1
  144. package/lib/network/network.js +1 -0
  145. package/lib/network/network.js.map +1 -1
  146. package/lib/network/options.d.ts +0 -1
  147. package/lib/network/options.d.ts.map +1 -1
  148. package/lib/network/options.js.map +1 -1
  149. package/lib/network/peers/discover.js +2 -2
  150. package/lib/network/peers/discover.js.map +1 -1
  151. package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
  152. package/lib/network/processor/gossipHandlers.js +28 -8
  153. package/lib/network/processor/gossipHandlers.js.map +1 -1
  154. package/lib/network/processor/gossipValidatorFn.d.ts.map +1 -1
  155. package/lib/network/processor/gossipValidatorFn.js +8 -6
  156. package/lib/network/processor/gossipValidatorFn.js.map +1 -1
  157. package/lib/network/processor/types.d.ts +2 -0
  158. package/lib/network/processor/types.d.ts.map +1 -1
  159. package/lib/network/reqresp/ReqRespBeaconNode.d.ts.map +1 -1
  160. package/lib/network/reqresp/ReqRespBeaconNode.js +3 -1
  161. package/lib/network/reqresp/ReqRespBeaconNode.js.map +1 -1
  162. package/lib/network/reqresp/handlers/beaconBlocksByRange.d.ts +2 -1
  163. package/lib/network/reqresp/handlers/beaconBlocksByRange.d.ts.map +1 -1
  164. package/lib/network/reqresp/handlers/beaconBlocksByRange.js +14 -3
  165. package/lib/network/reqresp/handlers/beaconBlocksByRange.js.map +1 -1
  166. package/lib/network/reqresp/handlers/blobSidecarsByRange.js +5 -5
  167. package/lib/network/reqresp/handlers/blobSidecarsByRange.js.map +1 -1
  168. package/lib/network/reqresp/handlers/blobSidecarsByRoot.js +4 -4
  169. package/lib/network/reqresp/handlers/blobSidecarsByRoot.js.map +1 -1
  170. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.d.ts +2 -1
  171. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.d.ts.map +1 -1
  172. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js +9 -1
  173. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js.map +1 -1
  174. package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.d.ts +2 -1
  175. package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.d.ts.map +1 -1
  176. package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.js +9 -1
  177. package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.js.map +1 -1
  178. package/lib/network/reqresp/handlers/index.js +6 -6
  179. package/lib/network/reqresp/handlers/index.js.map +1 -1
  180. package/lib/network/reqresp/types.d.ts +1 -0
  181. package/lib/network/reqresp/types.d.ts.map +1 -1
  182. package/lib/network/subnets/attnetsService.d.ts +1 -1
  183. package/lib/network/subnets/attnetsService.js +6 -6
  184. package/lib/network/subnets/attnetsService.js.map +1 -1
  185. package/lib/network/subnets/util.d.ts +3 -2
  186. package/lib/network/subnets/util.d.ts.map +1 -1
  187. package/lib/network/subnets/util.js +6 -6
  188. package/lib/network/subnets/util.js.map +1 -1
  189. package/lib/node/nodejs.d.ts +2 -1
  190. package/lib/node/nodejs.d.ts.map +1 -1
  191. package/lib/node/nodejs.js +2 -1
  192. package/lib/node/nodejs.js.map +1 -1
  193. package/lib/sync/range/range.d.ts.map +1 -1
  194. package/lib/sync/range/range.js +2 -1
  195. package/lib/sync/range/range.js.map +1 -1
  196. package/lib/sync/unknownBlock.js +1 -1
  197. package/lib/sync/unknownBlock.js.map +1 -1
  198. package/lib/sync/utils/downloadByRange.d.ts +59 -15
  199. package/lib/sync/utils/downloadByRange.d.ts.map +1 -1
  200. package/lib/sync/utils/downloadByRange.js +204 -83
  201. package/lib/sync/utils/downloadByRange.js.map +1 -1
  202. package/lib/sync/utils/downloadByRoot.d.ts +8 -14
  203. package/lib/sync/utils/downloadByRoot.d.ts.map +1 -1
  204. package/lib/sync/utils/downloadByRoot.js +18 -33
  205. package/lib/sync/utils/downloadByRoot.js.map +1 -1
  206. package/lib/sync/utils/remoteSyncType.d.ts +2 -1
  207. package/lib/sync/utils/remoteSyncType.d.ts.map +1 -1
  208. package/lib/sync/utils/remoteSyncType.js +19 -4
  209. package/lib/sync/utils/remoteSyncType.js.map +1 -1
  210. package/lib/util/blobs.d.ts +1 -1
  211. package/lib/util/blobs.d.ts.map +1 -1
  212. package/lib/util/blobs.js +53 -20
  213. package/lib/util/blobs.js.map +1 -1
  214. package/lib/util/clock.d.ts.map +1 -1
  215. package/lib/util/clock.js +3 -4
  216. package/lib/util/clock.js.map +1 -1
  217. package/lib/util/profile.d.ts +6 -4
  218. package/lib/util/profile.d.ts.map +1 -1
  219. package/lib/util/profile.js +40 -3
  220. package/lib/util/profile.js.map +1 -1
  221. package/lib/util/sszBytes.d.ts +2 -0
  222. package/lib/util/sszBytes.d.ts.map +1 -1
  223. package/lib/util/sszBytes.js +25 -0
  224. package/lib/util/sszBytes.js.map +1 -1
  225. package/package.json +32 -25
  226. package/src/api/impl/beacon/blocks/index.ts +47 -25
  227. package/src/api/impl/config/constants.ts +10 -4
  228. package/src/api/impl/lodestar/index.ts +42 -10
  229. package/src/api/impl/node/utils.ts +1 -1
  230. package/src/api/impl/validator/index.ts +5 -2
  231. package/src/chain/archiveStore/archiveStore.ts +27 -0
  232. package/src/chain/archiveStore/strategies/frequencyStateArchiveStrategy.ts +32 -5
  233. package/src/chain/beaconProposerCache.ts +4 -8
  234. package/src/chain/chain.ts +50 -25
  235. package/src/chain/errors/blobSidecarError.ts +12 -2
  236. package/src/chain/errors/blockError.ts +1 -1
  237. package/src/chain/errors/dataColumnSidecarError.ts +38 -15
  238. package/src/chain/errors/voluntaryExitError.ts +30 -2
  239. package/src/chain/forkChoice/index.ts +178 -2
  240. package/src/chain/interface.ts +2 -0
  241. package/src/chain/lightClient/index.ts +26 -12
  242. package/src/chain/opPools/syncContributionAndProofPool.ts +3 -2
  243. package/src/chain/options.ts +2 -3
  244. package/src/chain/stateCache/datastore/db.ts +89 -1
  245. package/src/chain/stateCache/datastore/file.ts +8 -0
  246. package/src/chain/stateCache/datastore/types.ts +1 -0
  247. package/src/chain/stateCache/persistentCheckpointsCache.ts +45 -2
  248. package/src/chain/validation/attestation.ts +6 -7
  249. package/src/chain/validation/blobSidecar.ts +54 -10
  250. package/src/chain/validation/block.ts +2 -2
  251. package/src/chain/validation/dataColumnSidecar.ts +95 -21
  252. package/src/chain/validation/lightClientOptimisticUpdate.ts +3 -2
  253. package/src/chain/validation/voluntaryExit.ts +14 -4
  254. package/src/constants/constants.ts +0 -6
  255. package/src/constants/network.ts +0 -19
  256. package/src/index.ts +2 -0
  257. package/src/metrics/metrics/lodestar.ts +22 -1
  258. package/src/network/core/networkCore.ts +5 -1
  259. package/src/network/core/networkCoreWorker.ts +9 -9
  260. package/src/network/core/networkCoreWorkerHandler.ts +1 -1
  261. package/src/network/discv5/utils.ts +1 -2
  262. package/src/network/discv5/worker.ts +2 -7
  263. package/src/network/events.ts +1 -1
  264. package/src/network/gossip/encoding.ts +1 -1
  265. package/src/network/gossip/gossipsub.ts +8 -11
  266. package/src/network/gossip/interface.ts +2 -0
  267. package/src/network/gossip/snappy_bun.ts +2 -0
  268. package/src/network/metadata.ts +3 -1
  269. package/src/network/network.ts +1 -0
  270. package/src/network/options.ts +0 -1
  271. package/src/network/peers/discover.ts +2 -2
  272. package/src/network/processor/gossipHandlers.ts +31 -7
  273. package/src/network/processor/gossipValidatorFn.ts +33 -6
  274. package/src/network/processor/types.ts +2 -0
  275. package/src/network/reqresp/ReqRespBeaconNode.ts +3 -1
  276. package/src/network/reqresp/handlers/beaconBlocksByRange.ts +18 -3
  277. package/src/network/reqresp/handlers/blobSidecarsByRange.ts +6 -6
  278. package/src/network/reqresp/handlers/blobSidecarsByRoot.ts +5 -5
  279. package/src/network/reqresp/handlers/dataColumnSidecarsByRange.ts +13 -1
  280. package/src/network/reqresp/handlers/dataColumnSidecarsByRoot.ts +13 -1
  281. package/src/network/reqresp/handlers/index.ts +6 -6
  282. package/src/network/reqresp/types.ts +1 -0
  283. package/src/network/subnets/attnetsService.ts +6 -6
  284. package/src/network/subnets/util.ts +12 -12
  285. package/src/node/nodejs.ts +3 -0
  286. package/src/sync/range/range.ts +2 -1
  287. package/src/sync/unknownBlock.ts +1 -1
  288. package/src/sync/utils/downloadByRange.ts +273 -108
  289. package/src/sync/utils/downloadByRoot.ts +22 -56
  290. package/src/sync/utils/remoteSyncType.ts +23 -4
  291. package/src/util/blobs.ts +64 -20
  292. package/src/util/clock.ts +3 -4
  293. package/src/util/profile.ts +45 -3
  294. package/src/util/sszBytes.ts +30 -0
@@ -29,7 +29,7 @@ export type NetworkEventData = {
29
29
  clientAgent: string;
30
30
  };
31
31
  [NetworkEvent.peerDisconnected]: {peer: PeerIdStr};
32
- [NetworkEvent.reqRespRequest]: {request: RequestTypedContainer; peer: PeerId};
32
+ [NetworkEvent.reqRespRequest]: {request: RequestTypedContainer; peer: PeerId; peerClient: string};
33
33
  [NetworkEvent.pendingGossipsubMessage]: PendingGossipsubMessage;
34
34
  [NetworkEvent.gossipMessageValidationResult]: {
35
35
  msgId: string;
@@ -1,6 +1,6 @@
1
1
  import {Message} from "@libp2p/interface";
2
- import {compress, uncompress} from "snappyjs";
3
2
  import xxhashFactory from "xxhash-wasm";
3
+ import {compress, uncompress} from "#snappy";
4
4
  import {digest} from "@chainsafe/as-sha256";
5
5
  import {RPC} from "@chainsafe/libp2p-gossipsub/message";
6
6
  import {DataTransform} from "@chainsafe/libp2p-gossipsub/types";
@@ -6,7 +6,6 @@ import {BeaconConfig, ForkBoundary} from "@lodestar/config";
6
6
  import {ATTESTATION_SUBNET_COUNT, SLOTS_PER_EPOCH, SYNC_COMMITTEE_SUBNET_COUNT} from "@lodestar/params";
7
7
  import {SubnetID} from "@lodestar/types";
8
8
  import {Logger, Map2d, Map2dArr} from "@lodestar/utils";
9
- import {GOSSIP_MAX_SIZE, GOSSIP_MAX_SIZE_BELLATRIX} from "../../constants/network.js";
10
9
  import {RegistryMetricCreator} from "../../metrics/index.js";
11
10
  import {callInNextEventLoop} from "../../util/eventLoop.js";
12
11
  import {NetworkEvent, NetworkEventBus, NetworkEventData} from "../events.js";
@@ -117,15 +116,7 @@ export class Eth2Gossipsub extends GossipSub {
117
116
  fastMsgIdFn: fastMsgIdFn,
118
117
  msgIdFn: msgIdFn.bind(msgIdFn, gossipTopicCache),
119
118
  msgIdToStrFn: msgIdToStrFn,
120
- // Use the bellatrix max size if the merge is configured. pre-merge using this size
121
- // could only be an issue on outgoing payloads, its highly unlikely we will send out
122
- // a chunk bigger than GOSSIP_MAX_SIZE pre merge even on mainnet network.
123
- //
124
- // TODO: figure out a way to dynamically transition to the size
125
- dataTransform: new DataTransformSnappy(
126
- gossipTopicCache,
127
- Number.isFinite(config.BELLATRIX_FORK_EPOCH) ? GOSSIP_MAX_SIZE_BELLATRIX : GOSSIP_MAX_SIZE
128
- ),
119
+ dataTransform: new DataTransformSnappy(gossipTopicCache, config.MAX_PAYLOAD_SIZE),
129
120
  metricsRegister: metricsRegister as MetricsRegister | null,
130
121
  metricsTopicStrToLabel: metricsRegister
131
122
  ? getMetricsTopicStrToLabel(networkConfig, {disableLightClientServer: opts.disableLightClientServer ?? false})
@@ -305,6 +296,10 @@ export class Eth2Gossipsub extends GossipSub {
305
296
  // Get seenTimestamp before adding the message to the queue or add async delays
306
297
  const seenTimestampSec = Date.now() / 1000;
307
298
 
299
+ const peerIdStr = propagationSource.toString();
300
+ const clientAgent = this.peersData.getPeerKind(peerIdStr) ?? "Unknown";
301
+ const clientVersion = this.peersData.getAgentVersion(peerIdStr);
302
+
308
303
  // Use setTimeout to yield to the macro queue
309
304
  // Without this we'll have huge event loop lag
310
305
  // See https://github.com/ChainSafe/lodestar/issues/5604
@@ -314,7 +309,9 @@ export class Eth2Gossipsub extends GossipSub {
314
309
  msg,
315
310
  msgId,
316
311
  // Hot path, use cached .toString() version
317
- propagationSource: propagationSource.toString(),
312
+ propagationSource: peerIdStr,
313
+ clientVersion,
314
+ clientAgent,
318
315
  seenTimestampSec,
319
316
  startProcessUnixSec: null,
320
317
  });
@@ -150,6 +150,8 @@ export type GossipMessageInfo = {
150
150
  topic: GossipTopic;
151
151
  msg: Message;
152
152
  propagationSource: PeerIdStr;
153
+ clientAgent: string;
154
+ clientVersion: string;
153
155
  seenTimestampSec: number;
154
156
  msgSlot: Slot | null;
155
157
  indexed?: string;
@@ -0,0 +1,2 @@
1
+ import {snappy} from "@lodestar/bun";
2
+ export const {compress, uncompress} = snappy;
@@ -126,7 +126,7 @@ export class MetadataController {
126
126
  * 2. Network MUST call this method on fork transition.
127
127
  * Current Clock implementation ensures no race conditions, epoch is correct if re-fetched
128
128
  */
129
- updateEth2Field(epoch: Epoch): void {
129
+ updateEth2Field(epoch: Epoch): phase0.ENRForkID {
130
130
  const config = this.networkConfig.config;
131
131
  const enrForkId = getENRForkID(config, epoch);
132
132
  const {forkDigest, nextForkVersion, nextForkEpoch} = enrForkId;
@@ -143,6 +143,8 @@ export class MetadataController {
143
143
  : ssz.ForkDigest.defaultValue();
144
144
  this.onSetValue(ENRKey.nfd, nextForkDigest);
145
145
  this.logger.debug("Updated nfd field in ENR", {nextForkDigest: toHex(nextForkDigest)});
146
+
147
+ return enrForkId;
146
148
  }
147
149
  }
148
150
 
@@ -236,6 +236,7 @@ export class Network implements INetwork {
236
236
  this.chain.emitter.off(routes.events.EventType.lightClientOptimisticUpdate, this.onLightClientOptimisticUpdate);
237
237
  this.chain.emitter.off(ChainEvent.updateTargetCustodyGroupCount, this.onTargetGroupCountUpdated);
238
238
  this.chain.emitter.off(ChainEvent.publishDataColumns, this.onPublishDataColumns);
239
+ this.chain.emitter.off(ChainEvent.publishBlobSidecars, this.onPublishBlobSidecars);
239
240
  this.chain.emitter.off(ChainEvent.updateStatus, this.onUpdateStatus);
240
241
  await this.core.close();
241
242
 
@@ -23,7 +23,6 @@ export interface NetworkOptions
23
23
  useWorker?: boolean;
24
24
  maxYoungGenerationSizeMb?: number;
25
25
  disableLightClientServer?: boolean;
26
- supernode?: boolean;
27
26
 
28
27
  /**
29
28
  * During E2E tests observe a lot of following `missing stream`:
@@ -391,8 +391,8 @@ export class PeerDiscovery {
391
391
  // tcp multiaddr is known to be be present, checked inside the worker
392
392
  const multiaddrTCP = enr.getLocationMultiaddr(ENRKey.tcp);
393
393
  if (!multiaddrTCP) {
394
- this.logger.error("Discv5 worker sent enr without tcp multiaddr", {enr: enr.encodeTxt()});
395
- this.metrics?.discovery.discoveredStatus.inc({status: DiscoveredPeerStatus.error});
394
+ this.logger.warn("Discv5 worker sent enr without tcp multiaddr", {enr: enr.encodeTxt()});
395
+ this.metrics?.discovery.discoveredStatus.inc({status: DiscoveredPeerStatus.no_multiaddrs});
396
396
  return;
397
397
  }
398
398
  // Are this fields mandatory?
@@ -39,6 +39,7 @@ import {
39
39
  BlockError,
40
40
  BlockErrorCode,
41
41
  BlockGossipError,
42
+ DataColumnSidecarErrorCode,
42
43
  DataColumnSidecarGossipError,
43
44
  GossipAction,
44
45
  GossipActionError,
@@ -295,6 +296,21 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
295
296
  const slot = dataColumnBlockHeader.slot;
296
297
  const blockRootHex = toRootHex(ssz.phase0.BeaconBlockHeader.hashTreeRoot(dataColumnBlockHeader));
297
298
 
299
+ // check to see if block has already been processed and BlockInput has been deleted (column received via reqresp or other means)
300
+ if (chain.forkChoice.hasBlockHex(blockRootHex)) {
301
+ metrics?.peerDas.dataColumnSidecarProcessingSkip.inc();
302
+ logger.debug("Already processed block for column sidecar, skipping processing", {
303
+ slot,
304
+ blockRoot: blockRootHex,
305
+ index: dataColumnSidecar.index,
306
+ });
307
+ throw new DataColumnSidecarGossipError(GossipAction.IGNORE, {
308
+ code: DataColumnSidecarErrorCode.ALREADY_KNOWN,
309
+ columnIndex: dataColumnSidecar.index,
310
+ slot,
311
+ });
312
+ }
313
+
298
314
  // first check if we should even process this column (we may have already processed it via getBlobsV2)
299
315
  {
300
316
  const blockInput = chain.seenBlockInputCache.get(blockRootHex);
@@ -304,7 +320,11 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
304
320
  ...blockInput.getLogMeta(),
305
321
  index: dataColumnSidecar.index,
306
322
  });
307
- return blockInput;
323
+ throw new DataColumnSidecarGossipError(GossipAction.IGNORE, {
324
+ code: DataColumnSidecarErrorCode.ALREADY_KNOWN,
325
+ columnIndex: dataColumnSidecar.index,
326
+ slot,
327
+ });
308
328
  }
309
329
  }
310
330
 
@@ -556,6 +576,16 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
556
576
  metrics?.dataColumns.elapsedTimeTillReceived.observe({receivedOrder: receivedColumns}, delaySec);
557
577
  break;
558
578
  }
579
+
580
+ if (!blockInput.hasAllData()) {
581
+ // immediately attempt fetch of data columns from execution engine
582
+ chain.getBlobsTracker.triggerGetBlobs(blockInput);
583
+ // if we've received at least half of the columns, trigger reconstruction of the rest
584
+ if (blockInput.columnCount >= NUMBER_OF_COLUMNS / 2) {
585
+ chain.columnReconstructionTracker.triggerColumnReconstruction(blockInput);
586
+ }
587
+ }
588
+
559
589
  if (!blockInput.hasBlockAndAllData()) {
560
590
  const cutoffTimeMs = getCutoffTimeMs(chain, dataColumnSlot, BLOCK_AVAILABILITY_CUTOFF_MS);
561
591
  chain.logger.debug("Received gossip data column, waiting for full data availability", {
@@ -578,12 +608,6 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
578
608
  source: BlockInputSource.gossip,
579
609
  });
580
610
  });
581
- // immediately attempt fetch of data columns from execution engine
582
- chain.getBlobsTracker.triggerGetBlobs(blockInput);
583
- // if we've received at least half of the columns, trigger reconstruction of the rest
584
- if (blockInput.columnCount >= NUMBER_OF_COLUMNS / 2) {
585
- chain.columnReconstructionTracker.triggerColumnReconstruction(blockInput);
586
- }
587
611
  }
588
612
  },
589
613
 
@@ -11,6 +11,7 @@ import {
11
11
  GossipValidatorBatchFn,
12
12
  GossipValidatorFn,
13
13
  } from "../gossip/interface.js";
14
+ import {prettyPrintPeerIdStr} from "../util.ts";
14
15
 
15
16
  export type ValidatorFnModules = {
16
17
  config: ChainForkConfig;
@@ -45,13 +46,19 @@ export function getGossipValidatorBatchFn(
45
46
  }))
46
47
  );
47
48
 
48
- return results.map((e) => {
49
+ return results.map((e, i) => {
49
50
  if (e == null) {
50
51
  return TopicValidatorResult.Accept;
51
52
  }
52
53
 
54
+ const {clientAgent, clientVersion, propagationSource} = messageInfos[i];
55
+
53
56
  if (!(e instanceof AttestationError)) {
54
- logger.debug(`Gossip batch validation ${type} threw a non-AttestationError`, {}, e as Error);
57
+ logger.debug(
58
+ `Gossip batch validation ${type} threw a non-AttestationError`,
59
+ {peerId: prettyPrintPeerIdStr(propagationSource), clientAgent, clientVersion},
60
+ e as Error
61
+ );
55
62
  metrics?.networkProcessor.gossipValidationIgnore.inc({topic: type});
56
63
  return TopicValidatorResult.Ignore;
57
64
  }
@@ -66,7 +73,11 @@ export function getGossipValidatorBatchFn(
66
73
  metrics?.networkProcessor.gossipValidationReject.inc({topic: type});
67
74
  // only beacon_attestation topic is validated in batch
68
75
  metrics?.networkProcessor.gossipAttestationRejectByReason.inc({reason: e.type.code});
69
- logger.debug(`Gossip validation ${type} rejected`, {}, e);
76
+ logger.debug(
77
+ `Gossip validation ${type} rejected`,
78
+ {peerId: prettyPrintPeerIdStr(propagationSource), clientAgent, clientVersion},
79
+ e
80
+ );
70
81
  return TopicValidatorResult.Reject;
71
82
  }
72
83
  });
@@ -99,7 +110,15 @@ export function getGossipValidatorBatchFn(
99
110
  export function getGossipValidatorFn(gossipHandlers: GossipHandlers, modules: ValidatorFnModules): GossipValidatorFn {
100
111
  const {logger, metrics} = modules;
101
112
 
102
- return async function gossipValidatorFn({topic, msg, propagationSource, seenTimestampSec, msgSlot}) {
113
+ return async function gossipValidatorFn({
114
+ topic,
115
+ msg,
116
+ propagationSource,
117
+ clientAgent,
118
+ clientVersion,
119
+ seenTimestampSec,
120
+ msgSlot,
121
+ }) {
103
122
  const type = topic.type;
104
123
 
105
124
  try {
@@ -116,7 +135,11 @@ export function getGossipValidatorFn(gossipHandlers: GossipHandlers, modules: Va
116
135
  } catch (e) {
117
136
  if (!(e instanceof GossipActionError)) {
118
137
  // not deserve to log error here, it looks too dangerous to users
119
- logger.debug(`Gossip validation ${type} threw a non-GossipActionError`, {}, e as Error);
138
+ logger.debug(
139
+ `Gossip validation ${type} threw a non-GossipActionError`,
140
+ {peerId: prettyPrintPeerIdStr(propagationSource), clientAgent, clientVersion},
141
+ e as Error
142
+ );
120
143
  return TopicValidatorResult.Ignore;
121
144
  }
122
145
 
@@ -134,7 +157,11 @@ export function getGossipValidatorFn(gossipHandlers: GossipHandlers, modules: Va
134
157
 
135
158
  case GossipAction.REJECT:
136
159
  metrics?.networkProcessor.gossipValidationReject.inc({topic: type});
137
- logger.debug(`Gossip validation ${type} rejected`, {}, e);
160
+ logger.debug(
161
+ `Gossip validation ${type} rejected`,
162
+ {peerId: prettyPrintPeerIdStr(propagationSource), clientAgent, clientVersion},
163
+ e
164
+ );
138
165
  return TopicValidatorResult.Reject;
139
166
  }
140
167
  }
@@ -15,6 +15,8 @@ export type PendingGossipsubMessage = {
15
15
  msgSlot?: Slot;
16
16
  msgId: string;
17
17
  propagationSource: PeerIdStr;
18
+ clientAgent: string;
19
+ clientVersion: string;
18
20
  seenTimestampSec: number;
19
21
  startProcessUnixSec: number | null;
20
22
  // specific properties for IndexedGossipQueueMinSize, for beacon_attestation topic only
@@ -19,6 +19,7 @@ import {callInNextEventLoop} from "../../util/eventLoop.js";
19
19
  import {NetworkCoreMetrics} from "../core/metrics.js";
20
20
  import {INetworkEventBus, NetworkEvent} from "../events.js";
21
21
  import {MetadataController} from "../metadata.js";
22
+ import {ClientKind} from "../peers/client.ts";
22
23
  import {PeersData} from "../peers/peersData.js";
23
24
  import {IPeerRpcScoreStore, PeerAction} from "../peers/score/index.js";
24
25
  import {StatusCache} from "../statusCache.js";
@@ -300,10 +301,11 @@ export class ReqRespBeaconNode extends ReqResp {
300
301
  }
301
302
 
302
303
  protected onIncomingRequestBody(request: RequestTypedContainer, peer: PeerId): void {
304
+ const peerClient = this.peersData.getPeerKind(peer.toString()) ?? ClientKind.Unknown;
303
305
  // Allow onRequest to return and close the stream
304
306
  // For Goodbye there may be a race condition where the listener of `receivedGoodbye`
305
307
  // disconnects in the same synchronous call, preventing the stream from ending cleanly
306
- callInNextEventLoop(() => this.networkEventBus.emit(NetworkEvent.reqRespRequest, {request, peer}));
308
+ callInNextEventLoop(() => this.networkEventBus.emit(NetworkEvent.reqRespRequest, {request, peer, peerClient}));
307
309
  }
308
310
 
309
311
  protected onIncomingRequest(peerId: PeerId, protocol: ProtocolDescriptor): void {
@@ -1,25 +1,40 @@
1
+ import {PeerId} from "@libp2p/interface";
1
2
  import {BeaconConfig} from "@lodestar/config";
2
- import {GENESIS_SLOT, isForkPostDeneb} from "@lodestar/params";
3
+ import {GENESIS_SLOT, isForkPostDeneb, isForkPostFulu} from "@lodestar/params";
3
4
  import {RespStatus, ResponseError, ResponseOutgoing} from "@lodestar/reqresp";
4
5
  import {computeEpochAtSlot} from "@lodestar/state-transition";
5
6
  import {deneb, phase0} 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
 
10
12
  // TODO: Unit test
11
13
 
12
14
  export async function* onBeaconBlocksByRange(
13
15
  request: phase0.BeaconBlocksByRangeRequest,
14
16
  chain: IBeaconChain,
15
- db: IBeaconDb
17
+ db: IBeaconDb,
18
+ peerId: PeerId,
19
+ peerClient: string
16
20
  ): AsyncIterable<ResponseOutgoing> {
17
21
  const {startSlot, count} = validateBeaconBlocksByRangeRequest(chain.config, request);
18
22
  const endSlot = startSlot + count;
19
23
 
20
24
  const finalized = db.blockArchive;
21
25
  const unfinalized = db.block;
22
- const finalizedSlot = chain.forkChoice.getFinalizedBlock().slot;
26
+ // in the case of initializing from a non-finalized state, we don't have the finalized block so this api does not work
27
+ // chain.forkChoice.getFinalizeBlock().slot
28
+ const finalizedSlot = chain.forkChoice.getFinalizedCheckpointSlot();
29
+
30
+ const forkName = chain.config.getForkName(startSlot);
31
+ if (isForkPostFulu(forkName) && startSlot < chain.earliestAvailableSlot) {
32
+ chain.logger.verbose("Peer did not respect earliestAvailableSlot for BeaconBlocksByRange", {
33
+ peer: prettyPrintPeerId(peerId),
34
+ client: peerClient,
35
+ });
36
+ return;
37
+ }
23
38
 
24
39
  // Finalized range of blocks
25
40
  if (startSlot <= finalizedSlot) {
@@ -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,