@lodestar/beacon-node 2.1.0-dev.48a9458cd6 → 2.1.0-dev.4b0199a2eb

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 (371) hide show
  1. package/lib/api/impl/beacon/blocks/index.d.ts.map +1 -1
  2. package/lib/api/impl/beacon/blocks/index.js +1 -3
  3. package/lib/api/impl/beacon/blocks/index.js.map +1 -1
  4. package/lib/api/impl/beacon/pool/index.d.ts.map +1 -1
  5. package/lib/api/impl/beacon/pool/index.js +8 -0
  6. package/lib/api/impl/beacon/pool/index.js.map +1 -1
  7. package/lib/api/impl/beacon/state/index.d.ts.map +1 -1
  8. package/lib/api/impl/beacon/state/index.js +3 -2
  9. package/lib/api/impl/beacon/state/index.js.map +1 -1
  10. package/lib/api/impl/beacon/state/utils.js +1 -1
  11. package/lib/api/impl/beacon/state/utils.js.map +1 -1
  12. package/lib/api/impl/config/constants.d.ts +0 -1
  13. package/lib/api/impl/config/constants.d.ts.map +1 -1
  14. package/lib/api/impl/config/constants.js +1 -3
  15. package/lib/api/impl/config/constants.js.map +1 -1
  16. package/lib/api/impl/debug/index.d.ts.map +1 -1
  17. package/lib/api/impl/debug/index.js +0 -3
  18. package/lib/api/impl/debug/index.js.map +1 -1
  19. package/lib/api/impl/errors.d.ts +7 -0
  20. package/lib/api/impl/errors.d.ts.map +1 -1
  21. package/lib/api/impl/errors.js +9 -0
  22. package/lib/api/impl/errors.js.map +1 -1
  23. package/lib/api/impl/validator/index.d.ts.map +1 -1
  24. package/lib/api/impl/validator/index.js +4 -94
  25. package/lib/api/impl/validator/index.js.map +1 -1
  26. package/lib/api/rest/base.d.ts.map +1 -1
  27. package/lib/api/rest/base.js +5 -2
  28. package/lib/api/rest/base.js.map +1 -1
  29. package/lib/chain/ColumnReconstructionTracker.d.ts +3 -0
  30. package/lib/chain/ColumnReconstructionTracker.d.ts.map +1 -1
  31. package/lib/chain/ColumnReconstructionTracker.js +3 -1
  32. package/lib/chain/ColumnReconstructionTracker.js.map +1 -1
  33. package/lib/chain/GetBlobsTracker.d.ts +3 -0
  34. package/lib/chain/GetBlobsTracker.d.ts.map +1 -1
  35. package/lib/chain/GetBlobsTracker.js +3 -1
  36. package/lib/chain/GetBlobsTracker.js.map +1 -1
  37. package/lib/chain/blocks/importBlock.d.ts.map +1 -1
  38. package/lib/chain/blocks/importBlock.js +14 -5
  39. package/lib/chain/blocks/importBlock.js.map +1 -1
  40. package/lib/chain/blocks/importExecutionPayload.d.ts.map +1 -1
  41. package/lib/chain/blocks/importExecutionPayload.js +7 -56
  42. package/lib/chain/blocks/importExecutionPayload.js.map +1 -1
  43. package/lib/chain/blocks/payloadEnvelopeInput/types.d.ts +2 -1
  44. package/lib/chain/blocks/payloadEnvelopeInput/types.d.ts.map +1 -1
  45. package/lib/chain/blocks/types.d.ts +0 -4
  46. package/lib/chain/blocks/types.d.ts.map +1 -1
  47. package/lib/chain/blocks/types.js +0 -5
  48. package/lib/chain/blocks/types.js.map +1 -1
  49. package/lib/chain/chain.d.ts +3 -3
  50. package/lib/chain/chain.d.ts.map +1 -1
  51. package/lib/chain/chain.js +30 -10
  52. package/lib/chain/chain.js.map +1 -1
  53. package/lib/chain/errors/dataColumnSidecarError.d.ts +7 -0
  54. package/lib/chain/errors/dataColumnSidecarError.d.ts.map +1 -1
  55. package/lib/chain/errors/dataColumnSidecarError.js +1 -0
  56. package/lib/chain/errors/dataColumnSidecarError.js.map +1 -1
  57. package/lib/chain/errors/executionPayloadBid.d.ts +0 -15
  58. package/lib/chain/errors/executionPayloadBid.d.ts.map +1 -1
  59. package/lib/chain/errors/executionPayloadBid.js +0 -3
  60. package/lib/chain/errors/executionPayloadBid.js.map +1 -1
  61. package/lib/chain/errors/index.d.ts +0 -1
  62. package/lib/chain/errors/index.d.ts.map +1 -1
  63. package/lib/chain/errors/index.js +0 -1
  64. package/lib/chain/errors/index.js.map +1 -1
  65. package/lib/chain/forkChoice/index.d.ts +11 -2
  66. package/lib/chain/forkChoice/index.d.ts.map +1 -1
  67. package/lib/chain/forkChoice/index.js +180 -13
  68. package/lib/chain/forkChoice/index.js.map +1 -1
  69. package/lib/chain/forkChoiceExecutionEngine.d.ts +1 -2
  70. package/lib/chain/forkChoiceExecutionEngine.d.ts.map +1 -1
  71. package/lib/chain/forkChoiceExecutionEngine.js +0 -3
  72. package/lib/chain/forkChoiceExecutionEngine.js.map +1 -1
  73. package/lib/chain/interface.d.ts +3 -3
  74. package/lib/chain/interface.d.ts.map +1 -1
  75. package/lib/chain/interface.js.map +1 -1
  76. package/lib/chain/opPools/index.d.ts +0 -1
  77. package/lib/chain/opPools/index.d.ts.map +1 -1
  78. package/lib/chain/opPools/index.js +0 -1
  79. package/lib/chain/opPools/index.js.map +1 -1
  80. package/lib/chain/opPools/opPool.d.ts +9 -3
  81. package/lib/chain/opPools/opPool.d.ts.map +1 -1
  82. package/lib/chain/opPools/opPool.js +22 -16
  83. package/lib/chain/opPools/opPool.js.map +1 -1
  84. package/lib/chain/options.d.ts.map +1 -1
  85. package/lib/chain/options.js +1 -2
  86. package/lib/chain/options.js.map +1 -1
  87. package/lib/chain/produceBlock/produceBlockBody.d.ts +1 -3
  88. package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
  89. package/lib/chain/produceBlock/produceBlockBody.js +3 -33
  90. package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
  91. package/lib/chain/regen/interface.d.ts +0 -1
  92. package/lib/chain/regen/interface.d.ts.map +1 -1
  93. package/lib/chain/regen/interface.js +0 -1
  94. package/lib/chain/regen/interface.js.map +1 -1
  95. package/lib/chain/seenCache/index.d.ts +1 -0
  96. package/lib/chain/seenCache/index.d.ts.map +1 -1
  97. package/lib/chain/seenCache/index.js +1 -0
  98. package/lib/chain/seenCache/index.js.map +1 -1
  99. package/lib/chain/seenCache/seenBlockProposers.d.ts +3 -0
  100. package/lib/chain/seenCache/seenBlockProposers.d.ts.map +1 -1
  101. package/lib/chain/seenCache/seenBlockProposers.js +6 -2
  102. package/lib/chain/seenCache/seenBlockProposers.js.map +1 -1
  103. package/lib/chain/seenCache/seenDataColumnSidecars.d.ts +17 -0
  104. package/lib/chain/seenCache/seenDataColumnSidecars.d.ts.map +1 -0
  105. package/lib/chain/seenCache/seenDataColumnSidecars.js +61 -0
  106. package/lib/chain/seenCache/seenDataColumnSidecars.js.map +1 -0
  107. package/lib/chain/seenCache/seenPayloadEnvelopeInput.d.ts +11 -2
  108. package/lib/chain/seenCache/seenPayloadEnvelopeInput.d.ts.map +1 -1
  109. package/lib/chain/seenCache/seenPayloadEnvelopeInput.js +28 -2
  110. package/lib/chain/seenCache/seenPayloadEnvelopeInput.js.map +1 -1
  111. package/lib/chain/validation/attestation.d.ts.map +1 -1
  112. package/lib/chain/validation/attestation.js +4 -2
  113. package/lib/chain/validation/attestation.js.map +1 -1
  114. package/lib/chain/validation/block.d.ts.map +1 -1
  115. package/lib/chain/validation/block.js +20 -7
  116. package/lib/chain/validation/block.js.map +1 -1
  117. package/lib/chain/validation/dataColumnSidecar.js +1 -1
  118. package/lib/chain/validation/dataColumnSidecar.js.map +1 -1
  119. package/lib/chain/validation/executionPayloadBid.d.ts.map +1 -1
  120. package/lib/chain/validation/executionPayloadBid.js +1 -34
  121. package/lib/chain/validation/executionPayloadBid.js.map +1 -1
  122. package/lib/chain/validation/index.d.ts +0 -1
  123. package/lib/chain/validation/index.d.ts.map +1 -1
  124. package/lib/chain/validation/index.js +0 -1
  125. package/lib/chain/validation/index.js.map +1 -1
  126. package/lib/chain/validation/proposerSlashing.js +5 -1
  127. package/lib/chain/validation/proposerSlashing.js.map +1 -1
  128. package/lib/chain/validation/voluntaryExit.js +2 -2
  129. package/lib/chain/validation/voluntaryExit.js.map +1 -1
  130. package/lib/execution/builder/validateBid.d.ts.map +1 -1
  131. package/lib/execution/builder/validateBid.js +1 -14
  132. package/lib/execution/builder/validateBid.js.map +1 -1
  133. package/lib/execution/engine/disabled.d.ts +0 -1
  134. package/lib/execution/engine/disabled.d.ts.map +1 -1
  135. package/lib/execution/engine/disabled.js +0 -3
  136. package/lib/execution/engine/disabled.js.map +1 -1
  137. package/lib/execution/engine/http.d.ts +2 -8
  138. package/lib/execution/engine/http.d.ts.map +1 -1
  139. package/lib/execution/engine/http.js +4 -27
  140. package/lib/execution/engine/http.js.map +1 -1
  141. package/lib/execution/engine/interface.d.ts +2 -13
  142. package/lib/execution/engine/interface.d.ts.map +1 -1
  143. package/lib/execution/engine/interface.js.map +1 -1
  144. package/lib/execution/engine/jsonRpcTransport.d.ts +2 -3
  145. package/lib/execution/engine/jsonRpcTransport.d.ts.map +1 -1
  146. package/lib/execution/engine/jsonRpcTransport.js +9 -33
  147. package/lib/execution/engine/jsonRpcTransport.js.map +1 -1
  148. package/lib/execution/engine/mock.d.ts +0 -1
  149. package/lib/execution/engine/mock.d.ts.map +1 -1
  150. package/lib/execution/engine/mock.js +3 -25
  151. package/lib/execution/engine/mock.js.map +1 -1
  152. package/lib/execution/engine/payloadIdCache.d.ts +1 -4
  153. package/lib/execution/engine/payloadIdCache.d.ts.map +1 -1
  154. package/lib/execution/engine/payloadIdCache.js +2 -16
  155. package/lib/execution/engine/payloadIdCache.js.map +1 -1
  156. package/lib/execution/engine/restTransport.d.ts +1 -2
  157. package/lib/execution/engine/restTransport.d.ts.map +1 -1
  158. package/lib/execution/engine/restTransport.js +0 -3
  159. package/lib/execution/engine/restTransport.js.map +1 -1
  160. package/lib/execution/engine/transport.d.ts +2 -3
  161. package/lib/execution/engine/transport.d.ts.map +1 -1
  162. package/lib/execution/engine/types.d.ts +0 -24
  163. package/lib/execution/engine/types.d.ts.map +1 -1
  164. package/lib/execution/engine/types.js +0 -12
  165. package/lib/execution/engine/types.js.map +1 -1
  166. package/lib/index.d.ts +1 -0
  167. package/lib/index.d.ts.map +1 -1
  168. package/lib/index.js +1 -0
  169. package/lib/index.js.map +1 -1
  170. package/lib/metrics/metrics/beacon.d.ts +0 -16
  171. package/lib/metrics/metrics/beacon.d.ts.map +1 -1
  172. package/lib/metrics/metrics/beacon.js +0 -35
  173. package/lib/metrics/metrics/beacon.js.map +1 -1
  174. package/lib/metrics/metrics/lodestar.d.ts +0 -9
  175. package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
  176. package/lib/metrics/metrics/lodestar.js +0 -20
  177. package/lib/metrics/metrics/lodestar.js.map +1 -1
  178. package/lib/network/core/networkCore.d.ts +1 -3
  179. package/lib/network/core/networkCore.d.ts.map +1 -1
  180. package/lib/network/core/networkCore.js +1 -3
  181. package/lib/network/core/networkCore.js.map +1 -1
  182. package/lib/network/forks.d.ts +2 -2
  183. package/lib/network/forks.d.ts.map +1 -1
  184. package/lib/network/forks.js +3 -3
  185. package/lib/network/forks.js.map +1 -1
  186. package/lib/network/gossip/interface.d.ts +2 -8
  187. package/lib/network/gossip/interface.d.ts.map +1 -1
  188. package/lib/network/gossip/interface.js +0 -1
  189. package/lib/network/gossip/interface.js.map +1 -1
  190. package/lib/network/gossip/scoringParameters.js +19 -14
  191. package/lib/network/gossip/scoringParameters.js.map +1 -1
  192. package/lib/network/gossip/topic.d.ts +17 -29
  193. package/lib/network/gossip/topic.d.ts.map +1 -1
  194. package/lib/network/gossip/topic.js +1 -13
  195. package/lib/network/gossip/topic.js.map +1 -1
  196. package/lib/network/interface.d.ts +1 -2
  197. package/lib/network/interface.d.ts.map +1 -1
  198. package/lib/network/network.d.ts +2 -8
  199. package/lib/network/network.d.ts.map +1 -1
  200. package/lib/network/network.js +16 -45
  201. package/lib/network/network.js.map +1 -1
  202. package/lib/network/options.d.ts +0 -1
  203. package/lib/network/options.d.ts.map +1 -1
  204. package/lib/network/options.js +0 -1
  205. package/lib/network/options.js.map +1 -1
  206. package/lib/network/peers/discover.d.ts +1 -0
  207. package/lib/network/peers/discover.d.ts.map +1 -1
  208. package/lib/network/peers/discover.js +44 -48
  209. package/lib/network/peers/discover.js.map +1 -1
  210. package/lib/network/peers/score/store.d.ts.map +1 -1
  211. package/lib/network/peers/score/store.js +1 -2
  212. package/lib/network/peers/score/store.js.map +1 -1
  213. package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
  214. package/lib/network/processor/gossipHandlers.js +76 -50
  215. package/lib/network/processor/gossipHandlers.js.map +1 -1
  216. package/lib/network/processor/gossipQueues/index.d.ts.map +1 -1
  217. package/lib/network/processor/gossipQueues/index.js +0 -6
  218. package/lib/network/processor/gossipQueues/index.js.map +1 -1
  219. package/lib/network/processor/gossipValidatorFn.d.ts.map +1 -1
  220. package/lib/network/processor/gossipValidatorFn.js +1 -5
  221. package/lib/network/processor/gossipValidatorFn.js.map +1 -1
  222. package/lib/network/processor/index.d.ts.map +1 -1
  223. package/lib/network/processor/index.js +0 -1
  224. package/lib/network/processor/index.js.map +1 -1
  225. package/lib/network/reqresp/ReqRespBeaconNode.d.ts.map +1 -1
  226. package/lib/network/reqresp/ReqRespBeaconNode.js +0 -6
  227. package/lib/network/reqresp/ReqRespBeaconNode.js.map +1 -1
  228. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.d.ts.map +1 -1
  229. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js +3 -1
  230. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js.map +1 -1
  231. package/lib/network/reqresp/handlers/index.d.ts.map +1 -1
  232. package/lib/network/reqresp/handlers/index.js +0 -5
  233. package/lib/network/reqresp/handlers/index.js.map +1 -1
  234. package/lib/network/reqresp/protocols.d.ts +0 -1
  235. package/lib/network/reqresp/protocols.d.ts.map +1 -1
  236. package/lib/network/reqresp/protocols.js +0 -5
  237. package/lib/network/reqresp/protocols.js.map +1 -1
  238. package/lib/network/reqresp/rateLimit.d.ts.map +1 -1
  239. package/lib/network/reqresp/rateLimit.js +0 -4
  240. package/lib/network/reqresp/rateLimit.js.map +1 -1
  241. package/lib/network/reqresp/types.d.ts +2 -5
  242. package/lib/network/reqresp/types.d.ts.map +1 -1
  243. package/lib/network/reqresp/types.js +0 -3
  244. package/lib/network/reqresp/types.js.map +1 -1
  245. package/lib/sync/range/chain.d.ts.map +1 -1
  246. package/lib/sync/range/chain.js +1 -0
  247. package/lib/sync/range/chain.js.map +1 -1
  248. package/lib/sync/range/range.d.ts.map +1 -1
  249. package/lib/sync/range/range.js +5 -1
  250. package/lib/sync/range/range.js.map +1 -1
  251. package/lib/sync/unknownBlock.d.ts.map +1 -1
  252. package/lib/sync/unknownBlock.js +14 -1
  253. package/lib/sync/unknownBlock.js.map +1 -1
  254. package/lib/sync/utils/downloadByRange.d.ts +6 -0
  255. package/lib/sync/utils/downloadByRange.d.ts.map +1 -1
  256. package/lib/sync/utils/downloadByRange.js +17 -8
  257. package/lib/sync/utils/downloadByRange.js.map +1 -1
  258. package/lib/sync/utils/downloadByRoot.d.ts.map +1 -1
  259. package/lib/sync/utils/downloadByRoot.js +1 -1
  260. package/lib/sync/utils/downloadByRoot.js.map +1 -1
  261. package/lib/sync/utils/pendingBlocksTree.d.ts.map +1 -1
  262. package/lib/sync/utils/pendingBlocksTree.js +6 -1
  263. package/lib/sync/utils/pendingBlocksTree.js.map +1 -1
  264. package/lib/util/dataColumns.d.ts +2 -1
  265. package/lib/util/dataColumns.d.ts.map +1 -1
  266. package/lib/util/dataColumns.js +7 -2
  267. package/lib/util/dataColumns.js.map +1 -1
  268. package/lib/util/execution.d.ts +2 -1
  269. package/lib/util/execution.d.ts.map +1 -1
  270. package/lib/util/execution.js +7 -2
  271. package/lib/util/execution.js.map +1 -1
  272. package/package.json +18 -21
  273. package/src/api/impl/beacon/blocks/index.ts +1 -5
  274. package/src/api/impl/beacon/pool/index.ts +11 -0
  275. package/src/api/impl/beacon/state/index.ts +3 -7
  276. package/src/api/impl/beacon/state/utils.ts +1 -1
  277. package/src/api/impl/config/constants.ts +0 -4
  278. package/src/api/impl/debug/index.ts +0 -4
  279. package/src/api/impl/errors.ts +10 -0
  280. package/src/api/impl/validator/index.ts +2 -123
  281. package/src/api/rest/base.ts +4 -2
  282. package/src/chain/ColumnReconstructionTracker.ts +5 -1
  283. package/src/chain/GetBlobsTracker.ts +5 -0
  284. package/src/chain/blocks/importBlock.ts +14 -7
  285. package/src/chain/blocks/importExecutionPayload.ts +7 -74
  286. package/src/chain/blocks/payloadEnvelopeInput/types.ts +8 -1
  287. package/src/chain/blocks/types.ts +0 -5
  288. package/src/chain/chain.ts +34 -9
  289. package/src/chain/errors/dataColumnSidecarError.ts +8 -0
  290. package/src/chain/errors/executionPayloadBid.ts +0 -18
  291. package/src/chain/errors/index.ts +0 -1
  292. package/src/chain/forkChoice/index.ts +233 -13
  293. package/src/chain/forkChoiceExecutionEngine.ts +1 -5
  294. package/src/chain/interface.ts +2 -2
  295. package/src/chain/opPools/index.ts +0 -1
  296. package/src/chain/opPools/opPool.ts +27 -16
  297. package/src/chain/options.ts +1 -2
  298. package/src/chain/produceBlock/produceBlockBody.ts +12 -66
  299. package/src/chain/regen/interface.ts +0 -1
  300. package/src/chain/seenCache/index.ts +1 -0
  301. package/src/chain/seenCache/seenBlockProposers.ts +12 -2
  302. package/src/chain/seenCache/seenDataColumnSidecars.ts +69 -0
  303. package/src/chain/seenCache/seenPayloadEnvelopeInput.ts +28 -2
  304. package/src/chain/validation/attestation.ts +4 -2
  305. package/src/chain/validation/block.ts +19 -7
  306. package/src/chain/validation/dataColumnSidecar.ts +1 -1
  307. package/src/chain/validation/executionPayloadBid.ts +2 -49
  308. package/src/chain/validation/index.ts +0 -1
  309. package/src/chain/validation/proposerSlashing.ts +5 -1
  310. package/src/chain/validation/voluntaryExit.ts +2 -2
  311. package/src/execution/builder/validateBid.ts +2 -23
  312. package/src/execution/engine/disabled.ts +0 -4
  313. package/src/execution/engine/http.ts +5 -40
  314. package/src/execution/engine/interface.ts +2 -24
  315. package/src/execution/engine/jsonRpcTransport.ts +9 -46
  316. package/src/execution/engine/mock.ts +3 -26
  317. package/src/execution/engine/payloadIdCache.ts +4 -25
  318. package/src/execution/engine/restTransport.ts +1 -15
  319. package/src/execution/engine/transport.ts +2 -5
  320. package/src/execution/engine/types.ts +0 -35
  321. package/src/index.ts +1 -0
  322. package/src/metrics/metrics/beacon.ts +0 -37
  323. package/src/metrics/metrics/lodestar.ts +0 -21
  324. package/src/network/core/networkCore.ts +1 -3
  325. package/src/network/forks.ts +7 -3
  326. package/src/network/gossip/interface.ts +0 -5
  327. package/src/network/gossip/scoringParameters.ts +23 -14
  328. package/src/network/gossip/topic.ts +0 -14
  329. package/src/network/interface.ts +0 -2
  330. package/src/network/network.ts +20 -55
  331. package/src/network/options.ts +0 -2
  332. package/src/network/peers/discover.ts +42 -52
  333. package/src/network/peers/score/store.ts +1 -2
  334. package/src/network/processor/gossipHandlers.ts +135 -69
  335. package/src/network/processor/gossipQueues/index.ts +0 -6
  336. package/src/network/processor/gossipValidatorFn.ts +0 -5
  337. package/src/network/processor/index.ts +0 -1
  338. package/src/network/reqresp/ReqRespBeaconNode.ts +0 -7
  339. package/src/network/reqresp/handlers/dataColumnSidecarsByRange.ts +4 -1
  340. package/src/network/reqresp/handlers/index.ts +0 -5
  341. package/src/network/reqresp/protocols.ts +0 -6
  342. package/src/network/reqresp/rateLimit.ts +0 -4
  343. package/src/network/reqresp/types.ts +0 -6
  344. package/src/sync/range/chain.ts +1 -0
  345. package/src/sync/range/range.ts +7 -1
  346. package/src/sync/unknownBlock.ts +20 -1
  347. package/src/sync/utils/downloadByRange.ts +30 -7
  348. package/src/sync/utils/downloadByRoot.ts +12 -9
  349. package/src/sync/utils/pendingBlocksTree.ts +6 -1
  350. package/src/util/dataColumns.ts +13 -1
  351. package/src/util/execution.ts +16 -1
  352. package/lib/chain/errors/inclusionList.d.ts +0 -60
  353. package/lib/chain/errors/inclusionList.d.ts.map +0 -1
  354. package/lib/chain/errors/inclusionList.js +0 -19
  355. package/lib/chain/errors/inclusionList.js.map +0 -1
  356. package/lib/chain/opPools/inclusionListStore.d.ts +0 -66
  357. package/lib/chain/opPools/inclusionListStore.d.ts.map +0 -1
  358. package/lib/chain/opPools/inclusionListStore.js +0 -174
  359. package/lib/chain/opPools/inclusionListStore.js.map +0 -1
  360. package/lib/chain/validation/inclusionList.d.ts +0 -14
  361. package/lib/chain/validation/inclusionList.d.ts.map +0 -1
  362. package/lib/chain/validation/inclusionList.js +0 -150
  363. package/lib/chain/validation/inclusionList.js.map +0 -1
  364. package/lib/network/reqresp/handlers/inclusionListsByIndices.d.ts +0 -10
  365. package/lib/network/reqresp/handlers/inclusionListsByIndices.d.ts.map +0 -1
  366. package/lib/network/reqresp/handlers/inclusionListsByIndices.js +0 -30
  367. package/lib/network/reqresp/handlers/inclusionListsByIndices.js.map +0 -1
  368. package/src/chain/errors/inclusionList.ts +0 -38
  369. package/src/chain/opPools/inclusionListStore.ts +0 -211
  370. package/src/chain/validation/inclusionList.ts +0 -192
  371. package/src/network/reqresp/handlers/inclusionListsByIndices.ts +0 -44
@@ -29,10 +29,14 @@ import {Epoch} from "@lodestar/types";
29
29
  export const FORK_EPOCH_LOOKAHEAD = 2;
30
30
 
31
31
  /**
32
- * Return the list of `ForkBoundary`s meant to be active at `epoch`
32
+ * Return the fork boundaries active at any epoch in the inclusive range.
33
33
  * @see FORK_EPOCH_LOOKAHEAD for details on when fork boundaries are considered 'active'
34
34
  */
35
- export function getActiveForkBoundaries(config: ChainForkConfig, epoch: Epoch): ForkBoundary[] {
35
+ export function getActiveForkBoundaries(
36
+ config: ChainForkConfig,
37
+ fromEpoch: Epoch,
38
+ toEpoch = fromEpoch
39
+ ): ForkBoundary[] {
36
40
  const activeBoundaries: ForkBoundary[] = [];
37
41
  const {forkBoundariesAscendingEpochOrder} = config;
38
42
 
@@ -48,7 +52,7 @@ export function getActiveForkBoundaries(config: ChainForkConfig, epoch: Epoch):
48
52
  continue;
49
53
  }
50
54
 
51
- if (epoch >= currentEpoch - FORK_EPOCH_LOOKAHEAD && epoch <= nextEpoch + FORK_EPOCH_LOOKAHEAD) {
55
+ if (toEpoch >= currentEpoch - FORK_EPOCH_LOOKAHEAD && fromEpoch <= nextEpoch + FORK_EPOCH_LOOKAHEAD) {
52
56
  activeBoundaries.push(currentForkBoundary);
53
57
  }
54
58
  }
@@ -15,7 +15,6 @@ import {
15
15
  altair,
16
16
  capella,
17
17
  gloas,
18
- heze,
19
18
  phase0,
20
19
  } from "@lodestar/types";
21
20
  import {Logger} from "@lodestar/utils";
@@ -41,7 +40,6 @@ export enum GossipType {
41
40
  payload_attestation_message = "payload_attestation_message",
42
41
  execution_payload_bid = "execution_payload_bid",
43
42
  proposer_preferences = "proposer_preferences",
44
- inclusion_list = "inclusion_list",
45
43
  }
46
44
 
47
45
  export type SequentialGossipType = Exclude<GossipType, GossipType.beacon_attestation>;
@@ -79,7 +77,6 @@ export type GossipTopicTypeMap = {
79
77
  [GossipType.payload_attestation_message]: {type: GossipType.payload_attestation_message};
80
78
  [GossipType.execution_payload_bid]: {type: GossipType.execution_payload_bid};
81
79
  [GossipType.proposer_preferences]: {type: GossipType.proposer_preferences};
82
- [GossipType.inclusion_list]: {type: GossipType.inclusion_list};
83
80
  };
84
81
 
85
82
  export type GossipTopicMap = {
@@ -112,7 +109,6 @@ export type GossipTypeMap = {
112
109
  [GossipType.payload_attestation_message]: gloas.PayloadAttestationMessage;
113
110
  [GossipType.execution_payload_bid]: gloas.SignedExecutionPayloadBid;
114
111
  [GossipType.proposer_preferences]: gloas.SignedProposerPreferences;
115
- [GossipType.inclusion_list]: heze.SignedInclusionList;
116
112
  };
117
113
 
118
114
  export type GossipFnByType = {
@@ -146,7 +142,6 @@ export type GossipFnByType = {
146
142
  [GossipType.proposer_preferences]: (
147
143
  signedProposerPreferences: gloas.SignedProposerPreferences
148
144
  ) => Promise<void> | void;
149
- [GossipType.inclusion_list]: (signedInclusionList: heze.SignedInclusionList) => Promise<void> | void;
150
145
  };
151
146
 
152
147
  export type GossipFn = GossipFnByType[keyof GossipFnByType];
@@ -6,8 +6,8 @@ import {
6
6
  } from "@libp2p/gossipsub/score";
7
7
  import {BeaconConfig} from "@lodestar/config";
8
8
  import {ATTESTATION_SUBNET_COUNT, PTC_SIZE, SLOTS_PER_EPOCH, TARGET_AGGREGATORS_PER_COMMITTEE} from "@lodestar/params";
9
- import {computeCommitteeCount} from "@lodestar/state-transition";
10
- import {getActiveForkBoundaries} from "../forks.js";
9
+ import {computeCommitteeCount, computeStartSlotAtEpoch} from "@lodestar/state-transition";
10
+ import {FORK_EPOCH_LOOKAHEAD, getActiveForkBoundaries} from "../forks.js";
11
11
  import {Eth2Context} from "./gossipsub.js";
12
12
  import {GossipType} from "./interface.js";
13
13
  import {stringifyGossipTopic} from "./topic.js";
@@ -132,11 +132,20 @@ function getAllTopicsScoreParams(
132
132
  precomputedParams: PreComputedParams
133
133
  ): Record<string, TopicScoreParams> {
134
134
  const {epochDurationMs, slotDurationMs} = precomputedParams;
135
- const epoch = eth2Context.currentEpoch;
136
135
  const topicsParams: Record<string, TopicScoreParams> = {};
137
- const boundaries = getActiveForkBoundaries(config, epoch);
136
+ // Gossipsub copies the score parameters at construction, including those for future subscriptions.
137
+ const boundaries = getActiveForkBoundaries(config, eth2Context.currentEpoch, Infinity);
138
138
  const beaconAttestationSubnetWeight = 1 / ATTESTATION_SUBNET_COUNT;
139
139
  for (const boundary of boundaries) {
140
+ const currentSlot = Math.max(
141
+ eth2Context.currentSlot,
142
+ computeStartSlotAtEpoch(boundary.epoch - FORK_EPOCH_LOOKAHEAD)
143
+ );
144
+ // The node subscribes to a boundary's topics FORK_EPOCH_LOOKAHEAD epochs early, but peers only publish on
145
+ // them from the boundary epoch. Hold back the mesh delivery penalty until then, otherwise every mesh peer
146
+ // is penalized for an empty topic.
147
+ const subscribeEpoch = Math.max(eth2Context.currentEpoch, boundary.epoch - FORK_EPOCH_LOOKAHEAD);
148
+ const activationDelayMs = Math.max(0, boundary.epoch - subscribeEpoch) * epochDurationMs;
140
149
  //first all fixed topics
141
150
  topicsParams[
142
151
  stringifyGossipTopic(config, {
@@ -225,8 +234,8 @@ function getAllTopicsScoreParams(
225
234
  meshMessageInfo: {
226
235
  decaySlots: SLOTS_PER_EPOCH * 5,
227
236
  capFactor: 3,
228
- activationWindow: epochDurationMs,
229
- currentSlot: eth2Context.currentSlot,
237
+ activationWindow: activationDelayMs + epochDurationMs,
238
+ currentSlot,
230
239
  },
231
240
  });
232
241
  topicsParams[
@@ -241,8 +250,8 @@ function getAllTopicsScoreParams(
241
250
  meshMessageInfo: {
242
251
  decaySlots: SLOTS_PER_EPOCH * 5,
243
252
  capFactor: 3,
244
- activationWindow: epochDurationMs,
245
- currentSlot: eth2Context.currentSlot,
253
+ activationWindow: activationDelayMs + epochDurationMs,
254
+ currentSlot,
246
255
  },
247
256
  });
248
257
 
@@ -268,8 +277,8 @@ function getAllTopicsScoreParams(
268
277
  meshMessageInfo: {
269
278
  decaySlots: SLOTS_PER_EPOCH * 2,
270
279
  capFactor: 4,
271
- activationWindow: epochDurationMs,
272
- currentSlot: eth2Context.currentSlot,
280
+ activationWindow: activationDelayMs + epochDurationMs,
281
+ currentSlot,
273
282
  },
274
283
  });
275
284
 
@@ -280,10 +289,10 @@ function getAllTopicsScoreParams(
280
289
  meshMessageInfo: {
281
290
  decaySlots: multipleBurstsPerSubnetPerEpoch ? SLOTS_PER_EPOCH * 4 : SLOTS_PER_EPOCH * 16,
282
291
  capFactor: 16,
283
- activationWindow: multipleBurstsPerSubnetPerEpoch
284
- ? slotDurationMs * (SLOTS_PER_EPOCH / 2 + 1)
285
- : epochDurationMs,
286
- currentSlot: eth2Context.currentSlot,
292
+ activationWindow:
293
+ activationDelayMs +
294
+ (multipleBurstsPerSubnetPerEpoch ? slotDurationMs * (SLOTS_PER_EPOCH / 2 + 1) : epochDurationMs),
295
+ currentSlot,
287
296
  },
288
297
  });
289
298
  for (let subnet = 0; subnet < ATTESTATION_SUBNET_COUNT; subnet++) {
@@ -4,7 +4,6 @@ import {
4
4
  ATTESTATION_SUBNET_COUNT,
5
5
  ForkName,
6
6
  ForkSeq,
7
- MAX_SIGNED_INCLUSION_LIST_SIZE,
8
7
  SYNC_COMMITTEE_SUBNET_COUNT,
9
8
  isForkPostAltair,
10
9
  isForkPostElectra,
@@ -92,7 +91,6 @@ function stringifyGossipTopicType(topic: GossipTopic): string {
92
91
  case GossipType.payload_attestation_message:
93
92
  case GossipType.execution_payload_bid:
94
93
  case GossipType.proposer_preferences:
95
- case GossipType.inclusion_list:
96
94
  return topic.type;
97
95
  case GossipType.beacon_attestation:
98
96
  case GossipType.sync_committee:
@@ -142,8 +140,6 @@ export function getGossipSSZType(topic: GossipTopic) {
142
140
  return isForkPostGloas(fork) ? sszTypesFor(fork).SignedExecutionPayloadBid : ssz.gloas.SignedExecutionPayloadBid;
143
141
  case GossipType.proposer_preferences:
144
142
  return ssz.gloas.SignedProposerPreferences;
145
- case GossipType.inclusion_list:
146
- return ssz.heze.SignedInclusionList;
147
143
  }
148
144
  }
149
145
 
@@ -152,9 +148,6 @@ export function getGossipSSZType(topic: GossipTopic) {
152
148
  */
153
149
  export function getGossipSSZMaxSize(topic: GossipTopic, config: ChainForkConfig, sszType: CompositeTypeAny): number {
154
150
  const maxSize = Math.min(sszType.maxSize, config.MAX_PAYLOAD_SIZE);
155
- if (topic.type === GossipType.inclusion_list) {
156
- return Math.min(maxSize, MAX_SIGNED_INCLUSION_LIST_SIZE);
157
- }
158
151
  if (isForkPostGloas(topic.boundary.fork) && topic.type === GossipType.data_column_sidecar) {
159
152
  return Math.min(maxSize, computeMaxGloasDataColumnSidecarSize(config));
160
153
  }
@@ -225,7 +218,6 @@ export function parseGossipTopic(forkDigestContext: ForkDigestContext, topicStr:
225
218
  case GossipType.payload_attestation_message:
226
219
  case GossipType.execution_payload_bid:
227
220
  case GossipType.proposer_preferences:
228
- case GossipType.inclusion_list:
229
221
  return {type: gossipTypeStr, boundary, encoding};
230
222
  }
231
223
 
@@ -276,10 +268,6 @@ export function getCoreTopicsAtFork(
276
268
  topics.push({type: GossipType.proposer_preferences});
277
269
  }
278
270
 
279
- if (ForkSeq[fork] >= ForkSeq.heze) {
280
- topics.push({type: GossipType.inclusion_list});
281
- }
282
-
283
271
  // After fulu also track data_column_sidecar_{index}
284
272
  if (ForkSeq[fork] >= ForkSeq.fulu) {
285
273
  topics.push(...getDataColumnSidecarTopics(networkConfig, opts.subscribeAllColumnSubnets));
@@ -384,7 +372,6 @@ export const gossipTopicIgnoreDuplicatePublishError: Record<GossipType, boolean>
384
372
  [GossipType.payload_attestation_message]: true,
385
373
  [GossipType.execution_payload_bid]: true,
386
374
  [GossipType.proposer_preferences]: true,
387
- [GossipType.inclusion_list]: true,
388
375
  };
389
376
 
390
377
  /**
@@ -422,5 +409,4 @@ export const gossipTopicAllowPublishToZeroPeers: Record<GossipType, boolean> = {
422
409
  [GossipType.payload_attestation_message]: false,
423
410
  [GossipType.execution_payload_bid]: false,
424
411
  [GossipType.proposer_preferences]: false,
425
- [GossipType.inclusion_list]: false,
426
412
  };
@@ -32,7 +32,6 @@ import {
32
32
  capella,
33
33
  fulu,
34
34
  gloas,
35
- heze,
36
35
  phase0,
37
36
  } from "@lodestar/types";
38
37
  import {BlockInputSource} from "../chain/blocks/blockInput/types.js";
@@ -116,7 +115,6 @@ export interface INetwork extends INetworkCorePublic {
116
115
  publishSignedExecutionPayloadBid(signedBid: gloas.SignedExecutionPayloadBid): Promise<number>;
117
116
  publishPayloadAttestationMessage(payloadAttestationMessage: gloas.PayloadAttestationMessage): Promise<number>;
118
117
  publishProposerPreferences(signedProposerPreferences: gloas.SignedProposerPreferences): Promise<number>;
119
- publishInclusionList(signedInclusionList: heze.SignedInclusionList): Promise<number>;
120
118
 
121
119
  // Debug
122
120
  dumpGossipQueue(gossipType: GossipType): Promise<PendingGossipsubMessage[]>;
@@ -26,7 +26,6 @@ import {
26
26
  capella,
27
27
  fulu,
28
28
  gloas,
29
- heze,
30
29
  isGloasDataColumnSidecar,
31
30
  phase0,
32
31
  } from "@lodestar/types";
@@ -36,7 +35,7 @@ import {ChainEvent, IBeaconChain} from "../chain/index.js";
36
35
  import {computeSubnetForDataColumnSidecar} from "../chain/validation/dataColumnSidecar.js";
37
36
  import {GoodByeReasonCode} from "../constants/index.js";
38
37
  import {IBeaconDb} from "../db/interface.js";
39
- import {Metrics, RegistryMetricCreator} from "../metrics/index.js";
38
+ import {Metrics} from "../metrics/index.js";
40
39
  import {IClock} from "../util/clock.js";
41
40
  import {CustodyConfig} from "../util/dataColumns.js";
42
41
  import {PeerIdStr, peerIdToString} from "../util/peerId.js";
@@ -46,7 +45,7 @@ import {
46
45
  DataColumnSidecarsByRootRequest,
47
46
  ExecutionPayloadEnvelopesByRootRequest,
48
47
  } from "../util/types.js";
49
- import {INetworkCore, NetworkCore, WorkerNetworkCore} from "./core/index.js";
48
+ import {INetworkCore, WorkerNetworkCore} from "./core/index.js";
50
49
  import {INetworkEventBus, NetworkEvent, NetworkEventBus, NetworkEventData} from "./events.js";
51
50
  import {getActiveForkBoundaries} from "./forks.js";
52
51
  import {GossipHandlers, GossipTopicMap, GossipType, GossipTypeMap} from "./gossip/index.js";
@@ -100,12 +99,7 @@ export type NetworkInitModules = {
100
99
  };
101
100
 
102
101
  /**
103
- * Must support running both on worker and on main thread.
104
- *
105
- * Exists a front class that's what consumers interact with.
106
- * This class will multiplex between:
107
- * - libp2p in worker
108
- * - libp2p in main thread
102
+ * Front class that consumers interact with. libp2p runs in a worker thread.
109
103
  */
110
104
  export class Network implements INetwork {
111
105
  readonly peerId: PeerId;
@@ -173,42 +167,23 @@ export class Network implements INetwork {
173
167
  const initialStatus = chain.getStatus();
174
168
  const initialCustodyGroupCount = chain.custodyConfig.targetCustodyGroupCount;
175
169
 
176
- if (opts.useWorker) {
177
- logger.info("running libp2p instance in worker thread");
178
- }
179
-
180
- const core = opts.useWorker
181
- ? await WorkerNetworkCore.init({
182
- opts: {
183
- ...opts,
184
- peerStoreDir,
185
- metricsEnabled: Boolean(metrics),
186
- activeValidatorCount,
187
- genesisTime: chain.genesisTime,
188
- initialStatus,
189
- initialCustodyGroupCount,
190
- },
191
- config,
192
- privateKey,
193
- logger,
194
- events,
195
- metrics,
196
- getReqRespHandler,
197
- })
198
- : await NetworkCore.init({
199
- opts,
200
- config,
201
- privateKey,
202
- peerStoreDir,
203
- logger,
204
- clock: chain.clock,
205
- events,
206
- getReqRespHandler,
207
- metricsRegistry: metrics ? new RegistryMetricCreator() : null,
208
- initialStatus,
209
- initialCustodyGroupCount,
210
- activeValidatorCount,
211
- });
170
+ const core = await WorkerNetworkCore.init({
171
+ opts: {
172
+ ...opts,
173
+ peerStoreDir,
174
+ metricsEnabled: Boolean(metrics),
175
+ activeValidatorCount,
176
+ genesisTime: chain.genesisTime,
177
+ initialStatus,
178
+ initialCustodyGroupCount,
179
+ },
180
+ config,
181
+ privateKey,
182
+ logger,
183
+ events,
184
+ metrics,
185
+ getReqRespHandler,
186
+ });
212
187
 
213
188
  const networkProcessor = new NetworkProcessor(
214
189
  {chain, db, config, logger, metrics, events, gossipHandlers, core, aggregatorTracker},
@@ -545,16 +520,6 @@ export class Network implements INetwork {
545
520
  );
546
521
  }
547
522
 
548
- async publishInclusionList(signedInclusionList: heze.SignedInclusionList): Promise<number> {
549
- const epoch = computeEpochAtSlot(signedInclusionList.message.slot);
550
- const boundary = this.config.getForkBoundaryAtEpoch(epoch);
551
-
552
- return this.publishGossip<GossipType.inclusion_list>(
553
- {type: GossipType.inclusion_list, boundary},
554
- signedInclusionList
555
- );
556
- }
557
-
558
523
  async publishProposerPreferences(signedProposerPreferences: gloas.SignedProposerPreferences): Promise<number> {
559
524
  const epoch = computeEpochAtSlot(signedProposerPreferences.message.proposalSlot);
560
525
  const boundary = this.config.getForkBoundaryAtEpoch(epoch);
@@ -28,7 +28,6 @@ export interface NetworkOptions
28
28
  /** Include the version in libp2p Identify. Private mode takes precedence. */
29
29
  advertiseVersion?: boolean;
30
30
  private?: boolean;
31
- useWorker?: boolean;
32
31
  maxYoungGenerationSizeMb?: number;
33
32
  disableLightClientServer?: boolean;
34
33
  /**
@@ -67,7 +66,6 @@ export const defaultNetworkOptions: NetworkOptions = {
67
66
  /** disabled by default */
68
67
  discv5: null,
69
68
  rateLimitMultiplier: 1,
70
- useWorker: true,
71
69
  // set after testing before 1.19.0, see https://github.com/ChainSafe/lodestar/issues/6596
72
70
  disableFloodPublish: true,
73
71
  // default set via research in https://github.com/ChainSafe/lodestar/issues/2115
@@ -4,7 +4,7 @@ import {ENR} from "@chainsafe/enr";
4
4
  import {BeaconConfig} from "@lodestar/config";
5
5
  import {LoggerNode} from "@lodestar/logger/node";
6
6
  import {ATTESTATION_SUBNET_COUNT, ForkSeq, SYNC_COMMITTEE_SUBNET_COUNT} from "@lodestar/params";
7
- import {CustodyIndex, SubnetID} from "@lodestar/types";
7
+ import {SubnetID} from "@lodestar/types";
8
8
  import {bytesToInt, pruneSetToMax, sleep, toHex} from "@lodestar/utils";
9
9
  import {IClock} from "../../util/clock.js";
10
10
  import {getCustodyGroups} from "../../util/dataColumns.js";
@@ -252,32 +252,22 @@ export class PeerDiscovery {
252
252
  }
253
253
  cachedENRsReverse.reverse();
254
254
 
255
- this.peersToConnect += peersToConnect;
255
+ this.peersToConnect = peersToConnect;
256
256
 
257
257
  // starting from PeerDAS, we need to prioritize column subnet peers first in order to have stable subnet sampling
258
- const groupsToDiscover = new Set<CustodyIndex>();
259
- let groupPeersToDiscover = 0;
260
-
261
- const forkSeq = this.config.getForkSeq(this.clock.currentSlot);
262
- if (forkSeq >= ForkSeq.fulu) {
263
- group: for (const [group, maxPeersToConnect] of custodyGroupRequests) {
264
- let cachedENRsInGroup = 0;
265
- for (const cachedENR of cachedENRsReverse) {
266
- if (cachedENR.custodyGroups?.includes(group)) {
267
- cachedENRsToDial.set(cachedENR.peerId.toString(), cachedENR);
268
-
269
- if (++cachedENRsInGroup >= maxPeersToConnect) {
270
- continue group;
271
- }
272
- }
273
-
274
- const groupPeersToConnect = Math.max(maxPeersToConnect - cachedENRsInGroup, 0);
275
- this.custodyGroupQueries.set(group, groupPeersToConnect);
276
- groupsToDiscover.add(group);
277
- groupPeersToDiscover += groupPeersToConnect;
258
+ this.custodyGroupQueries.clear();
259
+ if (this.config.getForkSeq(this.clock.currentSlot) >= ForkSeq.fulu) {
260
+ for (const [group, count] of custodyGroupRequests) {
261
+ if (count > 0) this.custodyGroupQueries.set(group, count);
262
+ }
263
+ for (const cachedENR of cachedENRsReverse) {
264
+ if (this.custodyGroupQueries.size === 0) break;
265
+ if (this.consumeCustodyGroupRequests(cachedENR)) {
266
+ cachedENRsToDial.set(cachedENR.peerId.toString(), cachedENR);
278
267
  }
279
268
  }
280
269
  }
270
+ const groupPeersToDiscover = Array.from(this.custodyGroupQueries.values()).reduce((sum, count) => sum + count, 0);
281
271
 
282
272
  subnet: for (const subnetRequest of subnetRequests) {
283
273
  // Get cached ENRs from the discovery service that are in the requested `subnetId`, but not connected yet
@@ -312,7 +302,7 @@ export class PeerDiscovery {
312
302
  }
313
303
 
314
304
  // If subnetRequests won't connect enough peers for peersToConnect, add more
315
- if (cachedENRsToDial.size < peersToConnect) {
305
+ if (groupPeersToDiscover === 0 && cachedENRsToDial.size < peersToConnect) {
316
306
  for (const cachedENR of cachedENRsReverse) {
317
307
  cachedENRsToDial.set(cachedENR.peerId.toString(), cachedENR);
318
308
  if (cachedENRsToDial.size >= peersToConnect) {
@@ -330,7 +320,8 @@ export class PeerDiscovery {
330
320
  }
331
321
 
332
322
  // Run a discv5 subnet query to try to discover new peers
333
- const shouldRunFindRandomNodeQuery = subnetsToDiscoverPeers.length > 0 || cachedENRsToDial.size < peersToConnect;
323
+ const shouldRunFindRandomNodeQuery =
324
+ groupPeersToDiscover > 0 || subnetsToDiscoverPeers.length > 0 || cachedENRsToDial.size < peersToConnect;
334
325
  if (shouldRunFindRandomNodeQuery) {
335
326
  void this.runFindRandomNodeQuery();
336
327
  }
@@ -339,7 +330,7 @@ export class PeerDiscovery {
339
330
  peersToConnect,
340
331
  peersAvailableToDial: cachedENRsToDial.size,
341
332
  subnetsToDiscover: subnetsToDiscoverPeers.length,
342
- groupsToDiscover: Array.from(groupsToDiscover).join(","),
333
+ groupsToDiscover: Array.from(this.custodyGroupQueries.keys()).join(","),
343
334
  groupPeersToDiscover,
344
335
  shouldRunFindRandomNodeQuery,
345
336
  });
@@ -411,7 +402,14 @@ export class PeerDiscovery {
411
402
  if (this.randomNodeQuery.code === QueryStatusCode.Active) {
412
403
  this.randomNodeQuery.count++;
413
404
  }
414
- const peerId = enr.peerId;
405
+ let peerId: PeerId;
406
+ try {
407
+ peerId = enr.peerId;
408
+ } catch (e) {
409
+ this.logger.debug("Discovered ENR with invalid public key", {nodeId: enr.nodeId}, e as Error);
410
+ this.metrics?.discovery.discoveredStatus.inc({status: DiscoveredPeerStatus.error});
411
+ return;
412
+ }
415
413
  // At least one transport is known to be present, checked inside the worker
416
414
  const multiaddrTCP = enr.getLocationMultiaddr(ENRKey.tcp);
417
415
  const multiaddrQUIC = enr.getLocationMultiaddr(ENRKey.quic);
@@ -530,32 +528,24 @@ export class PeerDiscovery {
530
528
  }
531
529
  }
532
530
 
533
- private shouldDialPeer(peer: CachedENR): boolean {
534
- const forkSeq = this.config.getForkSeq(this.clock.currentSlot);
535
- if (forkSeq >= ForkSeq.fulu && peer.custodyGroups !== null) {
536
- // pre-fulu `this.custodyGroupQueries` is empty
537
- // starting from fulu, we need to make sure we have stable subnet sampling peers first
538
- // given SAMPLES_PER_SLOT = 8 and 100 peers, we have 800 custody columns from peers
539
- // with NUMBER_OF_CUSTODY_GROUPS = 128, we have 800 / 128 = 6.25 peers per column in average
540
- // it would not be hard to find TARGET_SUBNET_PEERS(6) peers per sampling columns columns and TARGET_GROUP_PEERS_PER_SUBNET(4) peers per non-sampling columns
541
- // after some first heartbeats, we should have no more column requested, then go with conditions of prior forks
542
- let hasMatchingGroup = false;
543
- let custodyGroupRequestCount = 0;
544
- for (const [group, peersToConnect] of this.custodyGroupQueries.entries()) {
545
- if (peersToConnect <= 0) {
546
- this.custodyGroupQueries.delete(group);
547
- } else if (peer.custodyGroups.includes(group)) {
548
- this.custodyGroupQueries.set(group, Math.max(0, peersToConnect - 1));
549
- hasMatchingGroup = true;
550
- custodyGroupRequestCount += peersToConnect;
551
- }
552
- }
531
+ private consumeCustodyGroupRequests(peer: CachedENR): boolean {
532
+ let matched = false;
533
+ for (const group of peer.custodyGroups ?? []) {
534
+ const remaining = this.custodyGroupQueries.get(group);
535
+ if (remaining === undefined) continue;
553
536
 
554
- // if subnet sampling peers are not stable and this peer is not in the requested columns, ignore it
555
- if (custodyGroupRequestCount > 0 && !hasMatchingGroup) {
556
- this.metrics?.discovery.notDialReason.inc({reason: NotDialReason.not_contain_requested_sampling_groups});
557
- return false;
558
- }
537
+ if (remaining === 1) this.custodyGroupQueries.delete(group);
538
+ else this.custodyGroupQueries.set(group, remaining - 1);
539
+ matched = true;
540
+ }
541
+ return matched;
542
+ }
543
+
544
+ private shouldDialPeer(peer: CachedENR): boolean {
545
+ const needsCustodyPeers = this.custodyGroupQueries.size > 0;
546
+ if (needsCustodyPeers && !this.consumeCustodyGroupRequests(peer)) {
547
+ this.metrics?.discovery.notDialReason.inc({reason: NotDialReason.not_contain_requested_sampling_groups});
548
+ return false;
559
549
  }
560
550
 
561
551
  // logics up to Deneb fork
@@ -580,7 +570,7 @@ export class PeerDiscovery {
580
570
  // ideally we may want to leave this cheap condition at the top of the function
581
571
  // however we want to also update peersToConnect in this.subnetRequests
582
572
  // the this.subnetRequests[type] gradually has 0 subnet so this function should be cheap enough
583
- if (this.peersToConnect > 0) {
573
+ if (needsCustodyPeers || this.peersToConnect > 0) {
584
574
  return true;
585
575
  }
586
576
 
@@ -85,8 +85,7 @@ export class PeerRpcScoreStore implements IPeerRpcScoreStore {
85
85
  for (const [peerIdStr, peerScore] of this.scores) {
86
86
  const newScore = peerScore.update();
87
87
 
88
- // Prune scores below threshold
89
- if (Math.abs(newScore) < SCORE_THRESHOLD) {
88
+ if (Math.abs(newScore) < SCORE_THRESHOLD && !peerScore.isCoolingDown()) {
90
89
  this.scores.delete(peerIdStr);
91
90
  }
92
91
  }