@lodestar/beacon-node 1.52.0-dev.269cf1aa5b → 1.52.0-dev.29dff83619

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 (353) hide show
  1. package/lib/api/impl/beacon/blocks/index.d.ts.map +1 -1
  2. package/lib/api/impl/beacon/blocks/index.js +47 -26
  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 +4 -2
  6. package/lib/api/impl/beacon/pool/index.js.map +1 -1
  7. package/lib/api/impl/beacon/state/utils.d.ts.map +1 -1
  8. package/lib/api/impl/beacon/state/utils.js +2 -1
  9. package/lib/api/impl/beacon/state/utils.js.map +1 -1
  10. package/lib/api/impl/debug/index.d.ts.map +1 -1
  11. package/lib/api/impl/debug/index.js +6 -2
  12. package/lib/api/impl/debug/index.js.map +1 -1
  13. package/lib/api/impl/validator/index.d.ts.map +1 -1
  14. package/lib/api/impl/validator/index.js +15 -8
  15. package/lib/api/impl/validator/index.js.map +1 -1
  16. package/lib/chain/ColumnReconstructionTracker.d.ts +4 -0
  17. package/lib/chain/ColumnReconstructionTracker.d.ts.map +1 -1
  18. package/lib/chain/ColumnReconstructionTracker.js +4 -0
  19. package/lib/chain/ColumnReconstructionTracker.js.map +1 -1
  20. package/lib/chain/archiveStore/historicalState/getHistoricalState.d.ts.map +1 -1
  21. package/lib/chain/archiveStore/historicalState/getHistoricalState.js +7 -0
  22. package/lib/chain/archiveStore/historicalState/getHistoricalState.js.map +1 -1
  23. package/lib/chain/archiveStore/utils/archiveBlocks.js +1 -1
  24. package/lib/chain/archiveStore/utils/archiveBlocks.js.map +1 -1
  25. package/lib/chain/archiveStore/utils/pruneHistory.d.ts.map +1 -1
  26. package/lib/chain/archiveStore/utils/pruneHistory.js +8 -4
  27. package/lib/chain/archiveStore/utils/pruneHistory.js.map +1 -1
  28. package/lib/chain/blocks/importExecutionPayload.d.ts +1 -1
  29. package/lib/chain/blocks/importExecutionPayload.d.ts.map +1 -1
  30. package/lib/chain/blocks/importExecutionPayload.js +9 -3
  31. package/lib/chain/blocks/importExecutionPayload.js.map +1 -1
  32. package/lib/chain/blocks/index.d.ts.map +1 -1
  33. package/lib/chain/blocks/index.js +3 -17
  34. package/lib/chain/blocks/index.js.map +1 -1
  35. package/lib/chain/chain.d.ts +6 -5
  36. package/lib/chain/chain.d.ts.map +1 -1
  37. package/lib/chain/chain.js +71 -25
  38. package/lib/chain/chain.js.map +1 -1
  39. package/lib/chain/errors/attestationError.d.ts +15 -1
  40. package/lib/chain/errors/attestationError.d.ts.map +1 -1
  41. package/lib/chain/errors/attestationError.js +8 -0
  42. package/lib/chain/errors/attestationError.js.map +1 -1
  43. package/lib/chain/errors/executionPayloadBid.d.ts +9 -3
  44. package/lib/chain/errors/executionPayloadBid.d.ts.map +1 -1
  45. package/lib/chain/errors/executionPayloadBid.js +2 -1
  46. package/lib/chain/errors/executionPayloadBid.js.map +1 -1
  47. package/lib/chain/errors/executionPayloadEnvelope.d.ts +55 -0
  48. package/lib/chain/errors/executionPayloadEnvelope.d.ts.map +1 -1
  49. package/lib/chain/errors/executionPayloadEnvelope.js +8 -0
  50. package/lib/chain/errors/executionPayloadEnvelope.js.map +1 -1
  51. package/lib/chain/interface.d.ts +1 -1
  52. package/lib/chain/interface.d.ts.map +1 -1
  53. package/lib/chain/lightClient/index.d.ts +13 -6
  54. package/lib/chain/lightClient/index.d.ts.map +1 -1
  55. package/lib/chain/lightClient/index.js +95 -115
  56. package/lib/chain/lightClient/index.js.map +1 -1
  57. package/lib/chain/opPools/opPool.js +6 -6
  58. package/lib/chain/opPools/opPool.js.map +1 -1
  59. package/lib/chain/prepareNextSlot.d.ts +45 -0
  60. package/lib/chain/prepareNextSlot.d.ts.map +1 -1
  61. package/lib/chain/prepareNextSlot.js +265 -69
  62. package/lib/chain/prepareNextSlot.js.map +1 -1
  63. package/lib/chain/produceBlock/produceBlockBody.d.ts +1 -0
  64. package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
  65. package/lib/chain/produceBlock/produceBlockBody.js +23 -15
  66. package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
  67. package/lib/chain/seenCache/seenAttesters.d.ts +1 -0
  68. package/lib/chain/seenCache/seenAttesters.d.ts.map +1 -1
  69. package/lib/chain/seenCache/seenAttesters.js +1 -1
  70. package/lib/chain/seenCache/seenAttesters.js.map +1 -1
  71. package/lib/chain/seenCache/seenBlockAttesters.d.ts +8 -2
  72. package/lib/chain/seenCache/seenBlockAttesters.d.ts.map +1 -1
  73. package/lib/chain/seenCache/seenBlockAttesters.js +43 -6
  74. package/lib/chain/seenCache/seenBlockAttesters.js.map +1 -1
  75. package/lib/chain/seenCache/seenExecutionPayloadBids.d.ts +13 -4
  76. package/lib/chain/seenCache/seenExecutionPayloadBids.d.ts.map +1 -1
  77. package/lib/chain/seenCache/seenExecutionPayloadBids.js +13 -12
  78. package/lib/chain/seenCache/seenExecutionPayloadBids.js.map +1 -1
  79. package/lib/chain/validation/aggregateAndProof.d.ts.map +1 -1
  80. package/lib/chain/validation/aggregateAndProof.js +24 -7
  81. package/lib/chain/validation/aggregateAndProof.js.map +1 -1
  82. package/lib/chain/validation/attestation.d.ts.map +1 -1
  83. package/lib/chain/validation/attestation.js +32 -16
  84. package/lib/chain/validation/attestation.js.map +1 -1
  85. package/lib/chain/validation/attesterSlashing.d.ts.map +1 -1
  86. package/lib/chain/validation/attesterSlashing.js +4 -2
  87. package/lib/chain/validation/attesterSlashing.js.map +1 -1
  88. package/lib/chain/validation/block.d.ts.map +1 -1
  89. package/lib/chain/validation/block.js +9 -1
  90. package/lib/chain/validation/block.js.map +1 -1
  91. package/lib/chain/validation/executionPayloadBid.d.ts.map +1 -1
  92. package/lib/chain/validation/executionPayloadBid.js +47 -42
  93. package/lib/chain/validation/executionPayloadBid.js.map +1 -1
  94. package/lib/chain/validation/executionPayloadEnvelope.d.ts.map +1 -1
  95. package/lib/chain/validation/executionPayloadEnvelope.js +100 -9
  96. package/lib/chain/validation/executionPayloadEnvelope.js.map +1 -1
  97. package/lib/chain/validation/payloadAttestationMessage.js +9 -0
  98. package/lib/chain/validation/payloadAttestationMessage.js.map +1 -1
  99. package/lib/chain/validation/proposerSlashing.js +4 -2
  100. package/lib/chain/validation/proposerSlashing.js.map +1 -1
  101. package/lib/chain/validation/signatureSets/contributionAndProof.d.ts +2 -2
  102. package/lib/chain/validation/signatureSets/contributionAndProof.d.ts.map +1 -1
  103. package/lib/chain/validation/signatureSets/contributionAndProof.js +2 -2
  104. package/lib/chain/validation/signatureSets/contributionAndProof.js.map +1 -1
  105. package/lib/chain/validation/signatureSets/syncCommittee.d.ts +2 -2
  106. package/lib/chain/validation/signatureSets/syncCommittee.d.ts.map +1 -1
  107. package/lib/chain/validation/signatureSets/syncCommittee.js +2 -2
  108. package/lib/chain/validation/signatureSets/syncCommittee.js.map +1 -1
  109. package/lib/chain/validation/signatureSets/syncCommitteeContribution.d.ts +2 -2
  110. package/lib/chain/validation/signatureSets/syncCommitteeContribution.d.ts.map +1 -1
  111. package/lib/chain/validation/signatureSets/syncCommitteeContribution.js +2 -2
  112. package/lib/chain/validation/signatureSets/syncCommitteeContribution.js.map +1 -1
  113. package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.d.ts +2 -2
  114. package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.d.ts.map +1 -1
  115. package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.js +2 -2
  116. package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.js.map +1 -1
  117. package/lib/chain/validation/syncCommittee.d.ts +1 -1
  118. package/lib/chain/validation/syncCommittee.d.ts.map +1 -1
  119. package/lib/chain/validation/syncCommittee.js +5 -5
  120. package/lib/chain/validation/syncCommittee.js.map +1 -1
  121. package/lib/chain/validation/syncCommitteeContributionAndProof.js +3 -3
  122. package/lib/chain/validation/syncCommitteeContributionAndProof.js.map +1 -1
  123. package/lib/chain/validation/voluntaryExit.d.ts.map +1 -1
  124. package/lib/chain/validation/voluntaryExit.js +39 -6
  125. package/lib/chain/validation/voluntaryExit.js.map +1 -1
  126. package/lib/chain/validatorMonitor.js +43 -43
  127. package/lib/chain/validatorMonitor.js.map +1 -1
  128. package/lib/execution/engine/blockHash.d.ts +12 -0
  129. package/lib/execution/engine/blockHash.d.ts.map +1 -0
  130. package/lib/execution/engine/blockHash.js +17 -0
  131. package/lib/execution/engine/blockHash.js.map +1 -0
  132. package/lib/execution/engine/http.d.ts +2 -2
  133. package/lib/execution/engine/http.d.ts.map +1 -1
  134. package/lib/execution/engine/http.js +13 -7
  135. package/lib/execution/engine/http.js.map +1 -1
  136. package/lib/execution/engine/interface.d.ts +16 -3
  137. package/lib/execution/engine/interface.d.ts.map +1 -1
  138. package/lib/execution/engine/interface.js +11 -0
  139. package/lib/execution/engine/interface.js.map +1 -1
  140. package/lib/execution/engine/jsonRpcHttpClient.d.ts +2 -0
  141. package/lib/execution/engine/jsonRpcHttpClient.d.ts.map +1 -1
  142. package/lib/execution/engine/jsonRpcHttpClient.js +14 -6
  143. package/lib/execution/engine/jsonRpcHttpClient.js.map +1 -1
  144. package/lib/execution/engine/jsonRpcTransport.d.ts +2 -2
  145. package/lib/execution/engine/jsonRpcTransport.d.ts.map +1 -1
  146. package/lib/execution/engine/jsonRpcTransport.js +4 -4
  147. package/lib/execution/engine/jsonRpcTransport.js.map +1 -1
  148. package/lib/execution/engine/mock.d.ts.map +1 -1
  149. package/lib/execution/engine/mock.js +6 -6
  150. package/lib/execution/engine/mock.js.map +1 -1
  151. package/lib/execution/engine/payloadIdCache.d.ts +6 -1
  152. package/lib/execution/engine/payloadIdCache.d.ts.map +1 -1
  153. package/lib/execution/engine/payloadIdCache.js +7 -2
  154. package/lib/execution/engine/payloadIdCache.js.map +1 -1
  155. package/lib/execution/engine/restHttpClient.d.ts.map +1 -1
  156. package/lib/execution/engine/restHttpClient.js +9 -5
  157. package/lib/execution/engine/restHttpClient.js.map +1 -1
  158. package/lib/execution/engine/restTransport.d.ts +2 -2
  159. package/lib/execution/engine/restTransport.d.ts.map +1 -1
  160. package/lib/execution/engine/restTransport.js +4 -4
  161. package/lib/execution/engine/restTransport.js.map +1 -1
  162. package/lib/execution/engine/signal.d.ts +6 -0
  163. package/lib/execution/engine/signal.d.ts.map +1 -0
  164. package/lib/execution/engine/signal.js +24 -0
  165. package/lib/execution/engine/signal.js.map +1 -0
  166. package/lib/execution/engine/transport.d.ts +2 -2
  167. package/lib/execution/engine/transport.d.ts.map +1 -1
  168. package/lib/index.d.ts +1 -1
  169. package/lib/index.d.ts.map +1 -1
  170. package/lib/index.js +1 -1
  171. package/lib/index.js.map +1 -1
  172. package/lib/metrics/metrics/beacon.d.ts +5 -0
  173. package/lib/metrics/metrics/beacon.d.ts.map +1 -1
  174. package/lib/metrics/metrics/beacon.js +5 -0
  175. package/lib/metrics/metrics/beacon.js.map +1 -1
  176. package/lib/metrics/metrics/lodestar.d.ts +1 -0
  177. package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
  178. package/lib/metrics/metrics/lodestar.js +5 -0
  179. package/lib/metrics/metrics/lodestar.js.map +1 -1
  180. package/lib/network/core/events.d.ts +6 -2
  181. package/lib/network/core/events.d.ts.map +1 -1
  182. package/lib/network/core/events.js +9 -0
  183. package/lib/network/core/events.js.map +1 -1
  184. package/lib/network/core/networkCoreWorkerHandler.d.ts.map +1 -1
  185. package/lib/network/core/networkCoreWorkerHandler.js +3 -2
  186. package/lib/network/core/networkCoreWorkerHandler.js.map +1 -1
  187. package/lib/network/gossip/gossipsub.d.ts +1 -0
  188. package/lib/network/gossip/gossipsub.d.ts.map +1 -1
  189. package/lib/network/gossip/gossipsub.js +5 -2
  190. package/lib/network/gossip/gossipsub.js.map +1 -1
  191. package/lib/network/gossip/topic.d.ts +1 -7
  192. package/lib/network/gossip/topic.d.ts.map +1 -1
  193. package/lib/network/gossip/topic.js +0 -13
  194. package/lib/network/gossip/topic.js.map +1 -1
  195. package/lib/network/network.d.ts +1 -0
  196. package/lib/network/network.d.ts.map +1 -1
  197. package/lib/network/network.js +26 -12
  198. package/lib/network/network.js.map +1 -1
  199. package/lib/network/peers/peerManager.d.ts.map +1 -1
  200. package/lib/network/peers/peerManager.js +22 -2
  201. package/lib/network/peers/peerManager.js.map +1 -1
  202. package/lib/network/peers/utils/prioritizePeers.d.ts +2 -0
  203. package/lib/network/peers/utils/prioritizePeers.d.ts.map +1 -1
  204. package/lib/network/peers/utils/prioritizePeers.js +11 -2
  205. package/lib/network/peers/utils/prioritizePeers.js.map +1 -1
  206. package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
  207. package/lib/network/processor/gossipHandlers.js +19 -6
  208. package/lib/network/processor/gossipHandlers.js.map +1 -1
  209. package/lib/network/processor/gossipValidatorFn.d.ts.map +1 -1
  210. package/lib/network/processor/gossipValidatorFn.js +4 -1
  211. package/lib/network/processor/gossipValidatorFn.js.map +1 -1
  212. package/lib/network/processor/index.d.ts.map +1 -1
  213. package/lib/network/processor/index.js +4 -2
  214. package/lib/network/processor/index.js.map +1 -1
  215. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js +1 -1
  216. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js.map +1 -1
  217. package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.js +1 -1
  218. package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.js.map +1 -1
  219. package/lib/network/reqresp/utils/collect.d.ts +4 -4
  220. package/lib/network/reqresp/utils/collect.d.ts.map +1 -1
  221. package/lib/network/reqresp/utils/collect.js +9 -8
  222. package/lib/network/reqresp/utils/collect.js.map +1 -1
  223. package/lib/network/reqresp/utils/collectSequentialBlocksInRange.d.ts +1 -1
  224. package/lib/network/reqresp/utils/collectSequentialBlocksInRange.d.ts.map +1 -1
  225. package/lib/network/reqresp/utils/collectSequentialBlocksInRange.js +2 -2
  226. package/lib/network/reqresp/utils/collectSequentialBlocksInRange.js.map +1 -1
  227. package/lib/sync/range/batch.d.ts +10 -0
  228. package/lib/sync/range/batch.d.ts.map +1 -1
  229. package/lib/sync/range/batch.js +29 -0
  230. package/lib/sync/range/batch.js.map +1 -1
  231. package/lib/sync/range/chain.d.ts +17 -2
  232. package/lib/sync/range/chain.d.ts.map +1 -1
  233. package/lib/sync/range/chain.js +60 -20
  234. package/lib/sync/range/chain.js.map +1 -1
  235. package/lib/sync/range/range.d.ts.map +1 -1
  236. package/lib/sync/range/range.js +44 -3
  237. package/lib/sync/range/range.js.map +1 -1
  238. package/lib/sync/range/utils/batches.d.ts +20 -4
  239. package/lib/sync/range/utils/batches.d.ts.map +1 -1
  240. package/lib/sync/range/utils/batches.js +31 -13
  241. package/lib/sync/range/utils/batches.js.map +1 -1
  242. package/lib/sync/range/utils/peerBalancer.d.ts +1 -1
  243. package/lib/sync/range/utils/peerBalancer.d.ts.map +1 -1
  244. package/lib/sync/range/utils/peerBalancer.js +5 -2
  245. package/lib/sync/range/utils/peerBalancer.js.map +1 -1
  246. package/lib/sync/types.d.ts +14 -1
  247. package/lib/sync/types.d.ts.map +1 -1
  248. package/lib/sync/types.js +2 -0
  249. package/lib/sync/types.js.map +1 -1
  250. package/lib/sync/unknownBlock.d.ts +28 -1
  251. package/lib/sync/unknownBlock.d.ts.map +1 -1
  252. package/lib/sync/unknownBlock.js +340 -27
  253. package/lib/sync/unknownBlock.js.map +1 -1
  254. package/lib/sync/utils/downloadByRange.d.ts +22 -1
  255. package/lib/sync/utils/downloadByRange.d.ts.map +1 -1
  256. package/lib/sync/utils/downloadByRange.js +55 -25
  257. package/lib/sync/utils/downloadByRange.js.map +1 -1
  258. package/lib/sync/utils/downloadByRoot.d.ts +24 -2
  259. package/lib/sync/utils/downloadByRoot.d.ts.map +1 -1
  260. package/lib/sync/utils/downloadByRoot.js +48 -5
  261. package/lib/sync/utils/downloadByRoot.js.map +1 -1
  262. package/lib/util/asyncIterableToEvents.d.ts +20 -3
  263. package/lib/util/asyncIterableToEvents.d.ts.map +1 -1
  264. package/lib/util/asyncIterableToEvents.js +76 -20
  265. package/lib/util/asyncIterableToEvents.js.map +1 -1
  266. package/lib/util/dataColumns.d.ts +1 -1
  267. package/lib/util/dataColumns.d.ts.map +1 -1
  268. package/lib/util/dataColumns.js +4 -1
  269. package/lib/util/dataColumns.js.map +1 -1
  270. package/lib/util/eventLoop.d.ts +3 -3
  271. package/lib/util/eventLoop.d.ts.map +1 -1
  272. package/lib/util/eventLoop.js +3 -3
  273. package/lib/util/eventLoop.js.map +1 -1
  274. package/package.json +27 -27
  275. package/src/api/impl/beacon/blocks/index.ts +53 -28
  276. package/src/api/impl/beacon/pool/index.ts +10 -8
  277. package/src/api/impl/beacon/state/utils.ts +2 -1
  278. package/src/api/impl/debug/index.ts +6 -2
  279. package/src/api/impl/validator/index.ts +17 -9
  280. package/src/chain/ColumnReconstructionTracker.ts +5 -0
  281. package/src/chain/archiveStore/historicalState/getHistoricalState.ts +9 -0
  282. package/src/chain/archiveStore/utils/archiveBlocks.ts +1 -1
  283. package/src/chain/archiveStore/utils/pruneHistory.ts +9 -4
  284. package/src/chain/blocks/importExecutionPayload.ts +9 -2
  285. package/src/chain/blocks/index.ts +3 -31
  286. package/src/chain/chain.ts +104 -42
  287. package/src/chain/errors/attestationError.ts +11 -1
  288. package/src/chain/errors/executionPayloadBid.ts +9 -2
  289. package/src/chain/errors/executionPayloadEnvelope.ts +58 -0
  290. package/src/chain/interface.ts +1 -1
  291. package/src/chain/lightClient/index.ts +108 -142
  292. package/src/chain/opPools/opPool.ts +6 -6
  293. package/src/chain/prepareNextSlot.ts +347 -89
  294. package/src/chain/produceBlock/produceBlockBody.ts +25 -16
  295. package/src/chain/seenCache/seenAttesters.ts +1 -1
  296. package/src/chain/seenCache/seenBlockAttesters.ts +48 -6
  297. package/src/chain/seenCache/seenExecutionPayloadBids.ts +35 -15
  298. package/src/chain/validation/aggregateAndProof.ts +24 -9
  299. package/src/chain/validation/attestation.ts +31 -20
  300. package/src/chain/validation/attesterSlashing.ts +4 -2
  301. package/src/chain/validation/block.ts +9 -1
  302. package/src/chain/validation/executionPayloadBid.ts +60 -44
  303. package/src/chain/validation/executionPayloadEnvelope.ts +115 -8
  304. package/src/chain/validation/payloadAttestationMessage.ts +10 -0
  305. package/src/chain/validation/proposerSlashing.ts +4 -2
  306. package/src/chain/validation/signatureSets/contributionAndProof.ts +4 -6
  307. package/src/chain/validation/signatureSets/syncCommittee.ts +2 -3
  308. package/src/chain/validation/signatureSets/syncCommitteeContribution.ts +2 -3
  309. package/src/chain/validation/signatureSets/syncCommitteeSelectionProof.ts +2 -3
  310. package/src/chain/validation/syncCommittee.ts +3 -5
  311. package/src/chain/validation/syncCommitteeContributionAndProof.ts +3 -3
  312. package/src/chain/validation/voluntaryExit.ts +44 -6
  313. package/src/chain/validatorMonitor.ts +43 -43
  314. package/src/execution/engine/blockHash.ts +27 -0
  315. package/src/execution/engine/http.ts +18 -10
  316. package/src/execution/engine/interface.ts +18 -3
  317. package/src/execution/engine/jsonRpcHttpClient.ts +26 -14
  318. package/src/execution/engine/jsonRpcTransport.ts +8 -4
  319. package/src/execution/engine/mock.ts +13 -8
  320. package/src/execution/engine/payloadIdCache.ts +12 -4
  321. package/src/execution/engine/restHttpClient.ts +17 -11
  322. package/src/execution/engine/restTransport.ts +5 -4
  323. package/src/execution/engine/signal.ts +28 -0
  324. package/src/execution/engine/transport.ts +3 -2
  325. package/src/index.ts +6 -1
  326. package/src/metrics/metrics/beacon.ts +9 -0
  327. package/src/metrics/metrics/lodestar.ts +5 -0
  328. package/src/network/core/events.ts +12 -0
  329. package/src/network/core/networkCoreWorkerHandler.ts +6 -2
  330. package/src/network/gossip/gossipsub.ts +6 -2
  331. package/src/network/gossip/topic.ts +1 -14
  332. package/src/network/network.ts +39 -13
  333. package/src/network/peers/peerManager.ts +26 -2
  334. package/src/network/peers/utils/prioritizePeers.ts +14 -1
  335. package/src/network/processor/gossipHandlers.ts +25 -13
  336. package/src/network/processor/gossipValidatorFn.ts +4 -0
  337. package/src/network/processor/index.ts +7 -2
  338. package/src/network/reqresp/handlers/dataColumnSidecarsByRange.ts +1 -1
  339. package/src/network/reqresp/handlers/dataColumnSidecarsByRoot.ts +1 -1
  340. package/src/network/reqresp/utils/collect.ts +16 -8
  341. package/src/network/reqresp/utils/collectSequentialBlocksInRange.ts +3 -2
  342. package/src/sync/range/batch.ts +33 -0
  343. package/src/sync/range/chain.ts +72 -17
  344. package/src/sync/range/range.ts +57 -3
  345. package/src/sync/range/utils/batches.ts +38 -13
  346. package/src/sync/range/utils/peerBalancer.ts +4 -1
  347. package/src/sync/types.ts +13 -0
  348. package/src/sync/unknownBlock.ts +389 -29
  349. package/src/sync/utils/downloadByRange.ts +89 -29
  350. package/src/sync/utils/downloadByRoot.ts +75 -7
  351. package/src/util/asyncIterableToEvents.ts +100 -21
  352. package/src/util/dataColumns.ts +4 -1
  353. package/src/util/eventLoop.ts +3 -3
@@ -2,6 +2,7 @@ import {EventEmitter} from "node:events";
2
2
  import {StrictEventEmitter} from "strict-event-emitter-types";
3
3
  import {ErrorAborted, Gauge, Histogram, TimeoutError, fetch, isValidHttpUrl, retry} from "@lodestar/utils";
4
4
  import {JwtClaim, encodeJwtToken} from "./jwt.js";
5
+ import {withRequestSignal} from "./signal.js";
5
6
  import {EngineTransportMetrics} from "./transportMetrics.js";
6
7
  import {IJson, RpcPayload} from "./utils.js";
7
8
 
@@ -54,6 +55,8 @@ export type ReqOpts = {
54
55
  retries?: number;
55
56
  retryDelay?: number;
56
57
  shouldRetry?: (lastError: Error) => boolean;
58
+ /** Aborts this request only, in addition to the signal of the client */
59
+ signal?: AbortSignal;
57
60
  };
58
61
 
59
62
  export type JsonRpcHttpClientMetrics = EngineTransportMetrics & {
@@ -157,19 +160,23 @@ export class JsonRpcHttpClient implements IJsonRpcHttpClient {
157
160
  return this.wrapWithEvents(async () => {
158
161
  const routeId = opts?.routeId ?? "unknown";
159
162
 
160
- const res = await retry<RpcResponse<R>>(
161
- async (_attempt) => {
162
- return this.fetchJson({jsonrpc: "2.0", id: this.id++, ...payload}, opts);
163
- },
164
- {
165
- retries: opts?.retries ?? this.opts?.retries ?? 0,
166
- retryDelay: opts?.retryDelay ?? this.opts?.retryDelay,
167
- shouldRetry: opts?.shouldRetry,
168
- signal: this.opts?.signal,
169
- onRetry: () => {
170
- this.opts?.metrics?.retryCount.inc({routeId});
163
+ // The delay between retries has to end with the request signal as well
164
+ const res = await withRequestSignal(this.opts?.signal, opts?.signal, (signal) =>
165
+ retry<RpcResponse<R>>(
166
+ async (_attempt) => {
167
+ return this.fetchJson({jsonrpc: "2.0", id: this.id++, ...payload}, opts);
171
168
  },
172
- }
169
+ {
170
+ retries: opts?.retries ?? this.opts?.retries ?? 0,
171
+ retryDelay: opts?.retryDelay ?? this.opts?.retryDelay,
172
+ // An aborted request is no longer of interest to its caller
173
+ shouldRetry: (lastError) => !opts?.signal?.aborted && (opts?.shouldRetry?.(lastError) ?? true),
174
+ signal,
175
+ onRetry: () => {
176
+ this.opts?.metrics?.retryCount.inc({routeId});
177
+ },
178
+ }
179
+ )
173
180
  );
174
181
  return parseRpcResponse(res, payload);
175
182
  }, payload);
@@ -244,6 +251,10 @@ export class JsonRpcHttpClient implements IJsonRpcHttpClient {
244
251
 
245
252
  const onParentSignalAbort = (): void => controller.abort();
246
253
  this.opts?.signal?.addEventListener("abort", onParentSignalAbort, {once: true});
254
+ opts?.signal?.addEventListener("abort", onParentSignalAbort, {once: true});
255
+ if (opts?.signal?.aborted) {
256
+ controller.abort();
257
+ }
247
258
 
248
259
  // Default to "unknown" to prevent mixing metrics with others.
249
260
  const routeId = opts?.routeId ?? "unknown";
@@ -306,8 +317,8 @@ export class JsonRpcHttpClient implements IJsonRpcHttpClient {
306
317
  } catch (e) {
307
318
  this.metrics?.requestErrors.inc({routeId});
308
319
  if (controller.signal.aborted) {
309
- // controller will abort on both parent signal abort + timeout of this specific request
310
- if (this.opts?.signal?.aborted) {
320
+ // controller will abort on parent signal abort, request signal abort + timeout of this specific request
321
+ if (this.opts?.signal?.aborted || opts?.signal?.aborted) {
311
322
  throw new ErrorAborted("request");
312
323
  }
313
324
  throw new TimeoutError("request");
@@ -319,6 +330,7 @@ export class JsonRpcHttpClient implements IJsonRpcHttpClient {
319
330
 
320
331
  clearTimeout(timeout);
321
332
  this.opts?.signal?.removeEventListener("abort", onParentSignalAbort);
333
+ opts?.signal?.removeEventListener("abort", onParentSignalAbort);
322
334
  }
323
335
  }
324
336
  }
@@ -141,7 +141,8 @@ export class JsonRpcEngineTransport implements IEngineTransport {
141
141
  headBlockHash: RootHex,
142
142
  safeBlockHash: RootHex,
143
143
  finalizedBlockHash: RootHex,
144
- payloadAttributes?: PayloadAttributes
144
+ payloadAttributes?: PayloadAttributes,
145
+ signal?: AbortSignal
145
146
  ): Promise<ForkchoiceUpdatedResult> {
146
147
  const method =
147
148
  ForkSeq[fork] >= ForkSeq.heze
@@ -161,12 +162,15 @@ export class JsonRpcEngineTransport implements IEngineTransport {
161
162
  const {payloadStatus, payloadId} = await this.rpc.fetchWithRetries<
162
163
  EngineApiRpcReturnTypes[typeof method],
163
164
  EngineApiRpcParamTypes[typeof method]
164
- >({method, params: [{headBlockHash, safeBlockHash, finalizedBlockHash}, payloadAttributesRpc]}, fcUReqOpts);
165
+ >(
166
+ {method, params: [{headBlockHash, safeBlockHash, finalizedBlockHash}, payloadAttributesRpc]},
167
+ {...fcUReqOpts, signal}
168
+ );
165
169
 
166
170
  return {payloadStatus, payloadId: payloadId && payloadId !== "0x" ? payloadId : null};
167
171
  }
168
172
 
169
- async getPayload(fork: ForkName, payloadId: PayloadId): Promise<GetPayloadResult> {
173
+ async getPayload(fork: ForkName, payloadId: PayloadId, signal?: AbortSignal): Promise<GetPayloadResult> {
170
174
  let method: keyof EngineApiRpcReturnTypes;
171
175
  switch (fork) {
172
176
  case ForkName.phase0:
@@ -193,7 +197,7 @@ export class JsonRpcEngineTransport implements IEngineTransport {
193
197
  const payloadResponse = await this.rpc.fetchWithRetries<
194
198
  EngineApiRpcReturnTypes[typeof method],
195
199
  EngineApiRpcParamTypes[typeof method]
196
- >({method, params: [payloadId]}, getPayloadOpts);
200
+ >({method, params: [payloadId]}, {...getPayloadOpts, signal});
197
201
  return parseExecutionPayload(fork, payloadResponse);
198
202
  }
199
203
 
@@ -10,14 +10,16 @@ import {
10
10
  ForkPostCapella,
11
11
  ForkSeq,
12
12
  SLOTS_PER_EPOCH,
13
+ isForkPostElectra,
13
14
  } from "@lodestar/params";
14
15
  import {computeTimeAtSlot} from "@lodestar/state-transition";
15
- import {ExecutionPayload, RootHex, bellatrix, deneb, gloas, ssz} from "@lodestar/types";
16
+ import {ExecutionPayload, RootHex, bellatrix, deneb, gloas, ssz, sszTypesFor} from "@lodestar/types";
16
17
  import {fromHex, toRootHex} from "@lodestar/utils";
17
18
  import {ZERO_HASH_HEX} from "../../constants/index.js";
18
19
  import {INTEROP_BLOCK_HASH} from "../../node/utils/interop/state.js";
19
20
  import {kzgCommitmentToVersionedHash} from "../../util/blobs.js";
20
21
  import {kzg} from "../../util/kzg.js";
22
+ import {computeExecutionBlockHash} from "./blockHash.js";
21
23
  import {ClientCode, ExecutionPayloadStatus, PayloadIdCache} from "./interface.js";
22
24
  import {
23
25
  BlobsBundleRpc,
@@ -351,7 +353,6 @@ export class ExecutionEngineMockBackend implements JsonRpcBackend {
351
353
  executionPayload.gasLimit = INTEROP_GAS_LIMIT;
352
354
  executionPayload.gasUsed = Math.floor(0.5 * INTEROP_GAS_LIMIT);
353
355
  executionPayload.timestamp = payloadAttributes.timestamp;
354
- executionPayload.blockHash = crypto.randomBytes(32);
355
356
  const transactions: Uint8Array[] = [];
356
357
 
357
358
  // Between 0 and 4 transactions for all forks
@@ -401,6 +402,15 @@ export class ExecutionEngineMockBackend implements JsonRpcBackend {
401
402
  (executionPayload as gloas.ExecutionPayload).slotNumber = payloadAttributes.slotNumber;
402
403
  }
403
404
 
405
+ const executionRequests = isForkPostElectra(fork) ? sszTypesFor(fork).ExecutionRequests.defaultValue() : null;
406
+
407
+ executionPayload.blockHash = computeExecutionBlockHash(
408
+ fork,
409
+ executionPayload,
410
+ payloadAttributes.parentBeaconBlockRoot ?? null,
411
+ executionRequests
412
+ );
413
+
404
414
  this.preparingPayloads.set(payloadId, {
405
415
  executionPayload: serializeExecutionPayload(fork, executionPayload),
406
416
  blobsBundle: serializeBlobsBundle({
@@ -408,12 +418,7 @@ export class ExecutionEngineMockBackend implements JsonRpcBackend {
408
418
  blobs,
409
419
  proofs,
410
420
  }),
411
- executionRequests: serializeExecutionRequests(
412
- fork,
413
- ForkSeq[fork] >= ForkSeq.gloas
414
- ? ssz.gloas.ExecutionRequests.defaultValue()
415
- : ssz.electra.ExecutionRequests.defaultValue()
416
- ),
421
+ executionRequests: executionRequests !== null ? serializeExecutionRequests(fork, executionRequests) : [],
417
422
  });
418
423
 
419
424
  // IF the payload is deemed VALID and the build process has begun
@@ -12,6 +12,9 @@ const MAX_PAYLOAD_IDS = SLOTS_PER_EPOCH;
12
12
  // Since we do no processing with this id, we have no need to deserialize it
13
13
  export type PayloadId = string;
14
14
 
15
+ /** Payload id returned by the engine and when the payload was requested from it, monotonic `performance.now()` ms */
16
+ export type PreparedPayloadId = {payloadId: PayloadId; preparedAtMs: number};
17
+
15
18
  export type WithdrawalV1 = {
16
19
  index: QUANTITY;
17
20
  validatorIndex: QUANTITY;
@@ -26,7 +29,7 @@ type FcuAttributes = {headBlockHash: DATA} & Omit<PayloadAttributesRpc, "withdra
26
29
  export class PayloadIdCache {
27
30
  private readonly payloadIdByFcuAttributes = new Map<
28
31
  string,
29
- {payloadId: PayloadId; fullKey: string; inclusionListTransactions?: bellatrix.Transactions}
32
+ PreparedPayloadId & {fullKey: string; inclusionListTransactions?: bellatrix.Transactions}
30
33
  >();
31
34
 
32
35
  getFullKey({headBlockHash, timestamp, prevRandao, suggestedFeeRecipient}: FcuAttributes): string {
@@ -45,7 +48,12 @@ export class PayloadIdCache {
45
48
  const key = this.getKey(fcuAttributes);
46
49
  const fullKey = this.getFullKey(fcuAttributes);
47
50
  const {inclusionListTransactions} = fcuAttributes;
48
- this.payloadIdByFcuAttributes.set(key, {payloadId, fullKey, inclusionListTransactions});
51
+ this.payloadIdByFcuAttributes.set(key, {
52
+ payloadId,
53
+ preparedAtMs: performance.now(),
54
+ fullKey,
55
+ inclusionListTransactions,
56
+ });
49
57
  }
50
58
 
51
59
  prune(): void {
@@ -53,13 +61,13 @@ export class PayloadIdCache {
53
61
  pruneSetToMax(this.payloadIdByFcuAttributes, MAX_PAYLOAD_IDS);
54
62
  }
55
63
 
56
- get(fcuAttributes: FcuAttributes): PayloadId | undefined {
64
+ get(fcuAttributes: FcuAttributes): PreparedPayloadId | undefined {
57
65
  const key = this.getKey(fcuAttributes);
58
66
  const fullKey = this.getFullKey(fcuAttributes);
59
67
  const payloadInfo = this.payloadIdByFcuAttributes.get(key);
60
68
  return payloadInfo?.fullKey === fullKey &&
61
69
  isSameInclusionList(payloadInfo.inclusionListTransactions, fcuAttributes.inclusionListTransactions)
62
- ? payloadInfo.payloadId
70
+ ? {payloadId: payloadInfo.payloadId, preparedAtMs: payloadInfo.preparedAtMs}
63
71
  : undefined;
64
72
  }
65
73
  }
@@ -6,6 +6,7 @@ import {
6
6
  ReqOpts,
7
7
  } from "./jsonRpcHttpClient.js";
8
8
  import {JwtClaim, encodeJwtToken} from "./jwt.js";
9
+ import {withRequestSignal} from "./signal.js";
9
10
  import {ExecutionForkName} from "./sszTypes.js";
10
11
 
11
12
  export const ENGINE_REST_BASE_PATH = "/engine/v1";
@@ -115,15 +116,18 @@ export class EngineRestHttpClient {
115
116
  /** Perform request with retries without emitting events, used to probe support for the REST API */
116
117
  async requestWithRetries(req: EngineRestRequest, opts?: ReqOpts): Promise<EngineRestResponse> {
117
118
  const routeId = opts?.routeId ?? "unknown";
118
- return retry(() => this.requestAnyUrl(req, opts), {
119
- retries: opts?.retries ?? this.opts.retries ?? 0,
120
- retryDelay: opts?.retryDelay ?? this.opts.retryDelay,
121
- shouldRetry: opts?.shouldRetry ?? isRetryableEngineRestError,
122
- signal: this.opts.signal,
123
- onRetry: () => {
124
- this.metrics?.retryCount.inc({routeId});
125
- },
126
- });
119
+ // The delay between retries has to end with the request signal as well
120
+ return withRequestSignal(this.opts.signal, opts?.signal, (signal) =>
121
+ retry(() => this.requestAnyUrl(req, opts), {
122
+ retries: opts?.retries ?? this.opts.retries ?? 0,
123
+ retryDelay: opts?.retryDelay ?? this.opts.retryDelay,
124
+ shouldRetry: opts?.shouldRetry ?? isRetryableEngineRestError,
125
+ signal,
126
+ onRetry: () => {
127
+ this.metrics?.retryCount.inc({routeId});
128
+ },
129
+ })
130
+ );
127
131
  }
128
132
 
129
133
  private async requestAnyUrl(req: EngineRestRequest, opts?: ReqOpts): Promise<EngineRestResponse> {
@@ -154,7 +158,8 @@ export class EngineRestHttpClient {
154
158
  // Not AbortSignal.any(), Node retains every composite until the long-lived parent signal aborts
155
159
  const onParentSignalAbort = (): void => controller.abort();
156
160
  this.opts.signal?.addEventListener("abort", onParentSignalAbort, {once: true});
157
- if (this.opts.signal?.aborted) {
161
+ opts?.signal?.addEventListener("abort", onParentSignalAbort, {once: true});
162
+ if (this.opts.signal?.aborted || opts?.signal?.aborted) {
158
163
  controller.abort();
159
164
  }
160
165
 
@@ -223,7 +228,7 @@ export class EngineRestHttpClient {
223
228
  } catch (e) {
224
229
  this.metrics?.requestErrors.inc({routeId});
225
230
  if (controller.signal.aborted) {
226
- if (this.opts.signal?.aborted) {
231
+ if (this.opts.signal?.aborted || opts?.signal?.aborted) {
227
232
  throw new ErrorAborted("request");
228
233
  }
229
234
  throw new TimeoutError("request");
@@ -235,6 +240,7 @@ export class EngineRestHttpClient {
235
240
 
236
241
  clearTimeout(timeout);
237
242
  this.opts.signal?.removeEventListener("abort", onParentSignalAbort);
243
+ opts?.signal?.removeEventListener("abort", onParentSignalAbort);
238
244
  }
239
245
  }
240
246
  }
@@ -241,7 +241,8 @@ export class RestEngineTransport implements IEngineTransport {
241
241
  headBlockHash: RootHex,
242
242
  safeBlockHash: RootHex,
243
243
  finalizedBlockHash: RootHex,
244
- payloadAttributes?: PayloadAttributes
244
+ payloadAttributes?: PayloadAttributes,
245
+ signal?: AbortSignal
245
246
  ): Promise<ForkchoiceUpdatedResult> {
246
247
  const forkchoiceState = {
247
248
  headBlockHash: fromHex(headBlockHash),
@@ -279,7 +280,7 @@ export class RestEngineTransport implements IEngineTransport {
279
280
 
280
281
  const res = await this.client.request(
281
282
  {method: "POST", path: "/forkchoice", executionFork: toExecutionForkName(fork), body, responseType: "ssz"},
282
- fcUReqOpts
283
+ {...fcUReqOpts, signal}
283
284
  );
284
285
  const {payloadStatus, payloadId} = deserializeResponse(
285
286
  ForkchoiceUpdateResponse,
@@ -293,14 +294,14 @@ export class RestEngineTransport implements IEngineTransport {
293
294
  };
294
295
  }
295
296
 
296
- async getPayload(fork: ForkName, payloadId: PayloadId): Promise<GetPayloadResult> {
297
+ async getPayload(fork: ForkName, payloadId: PayloadId, signal?: AbortSignal): Promise<GetPayloadResult> {
297
298
  if (!PAYLOAD_ID_REGEX.test(payloadId)) {
298
299
  throw Error(`Invalid payloadId=${payloadId}, expected 0x prefixed 8 bytes hex`);
299
300
  }
300
301
 
301
302
  const res = await this.client.request(
302
303
  {method: "GET", path: `/payloads/${payloadId}`, executionFork: toExecutionForkName(fork), responseType: "ssz"},
303
- getPayloadOpts
304
+ {...getPayloadOpts, signal}
304
305
  );
305
306
 
306
307
  if (ForkSeq[fork] >= ForkSeq.gloas) {
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Runs `fn` with a signal that aborts with either the signal of the client or the signal of a single request.
3
+ * Not AbortSignal.any(), Node retains every composite until the long-lived client signal aborts.
4
+ */
5
+ export async function withRequestSignal<T>(
6
+ clientSignal: AbortSignal | undefined,
7
+ requestSignal: AbortSignal | undefined,
8
+ fn: (signal: AbortSignal | undefined) => Promise<T>
9
+ ): Promise<T> {
10
+ if (requestSignal === undefined) {
11
+ return fn(clientSignal);
12
+ }
13
+
14
+ const controller = new AbortController();
15
+ const onAbort = (): void => controller.abort();
16
+ clientSignal?.addEventListener("abort", onAbort, {once: true});
17
+ requestSignal.addEventListener("abort", onAbort, {once: true});
18
+ if (clientSignal?.aborted || requestSignal.aborted) {
19
+ controller.abort();
20
+ }
21
+
22
+ try {
23
+ return await fn(controller.signal);
24
+ } finally {
25
+ clientSignal?.removeEventListener("abort", onAbort);
26
+ requestSignal.removeEventListener("abort", onAbort);
27
+ }
28
+ }
@@ -42,10 +42,11 @@ export interface IEngineTransport {
42
42
  headBlockHash: RootHex,
43
43
  safeBlockHash: RootHex,
44
44
  finalizedBlockHash: RootHex,
45
- payloadAttributes?: PayloadAttributes
45
+ payloadAttributes?: PayloadAttributes,
46
+ signal?: AbortSignal
46
47
  ): Promise<ForkchoiceUpdatedResult>;
47
48
 
48
- getPayload(fork: ForkName, payloadId: PayloadId): Promise<GetPayloadResult>;
49
+ getPayload(fork: ForkName, payloadId: PayloadId, signal?: AbortSignal): Promise<GetPayloadResult>;
49
50
 
50
51
  getPayloadBodiesByHashV2(blockHashes: RootHex[]): Promise<(ExecutionPayloadBodyV2 | null)[]>;
51
52
 
package/src/index.ts CHANGED
@@ -7,7 +7,12 @@ export {DbCPStateDatastore} from "./chain/stateCache/datastore/db.js";
7
7
  export {FileCPStateDatastore} from "./chain/stateCache/datastore/file.js";
8
8
  export {BeaconDb, type IBeaconDb} from "./db/index.js";
9
9
  // Export execution engine to make it usable by builder
10
- export {ExecutionPayloadStatus, initializeExecutionEngine} from "./execution/index.js";
10
+ export {
11
+ ExecutionEngineError,
12
+ ExecutionEngineErrorCode,
13
+ ExecutionPayloadStatus,
14
+ initializeExecutionEngine,
15
+ } from "./execution/index.js";
11
16
  // Export metrics utilities to de-duplicate validator metrics
12
17
  export {
13
18
  type HttpMetricsServer,
@@ -1,6 +1,7 @@
1
1
  import {ProducedBlockSource} from "@lodestar/types";
2
2
  import {BlockSelectionResult} from "../../api/impl/validator/index.js";
3
3
  import {InclusionListSource} from "../../chain/blocks/types.js";
4
+ import {PreparePayloadReason} from "../../chain/prepareNextSlot.js";
4
5
  import {BlockProductionStep, PayloadPreparationType} from "../../chain/produceBlock/index.js";
5
6
  import {RegistryMetricCreator} from "../utils/registryMetricCreator.js";
6
7
 
@@ -164,6 +165,14 @@ export function createBeaconMetrics(register: RegistryMetricCreator) {
164
165
  help: "Time for preparing payload in advance",
165
166
  buckets: [0.1, 1, 3, 5, 10],
166
167
  }),
168
+ payloadReprepare: register.counter<{
169
+ reason: PreparePayloadReason;
170
+ result: "changed" | "unchanged" | "dropped" | "error";
171
+ }>({
172
+ name: "beacon_block_payload_reprepare_total",
173
+ help: "Re-runs of the next slot payload preparation after the scheduled run, by reason and result: prepared again as the head or its parent payload changed, unchanged, dropped as the proposal slot started, or failed",
174
+ labelNames: ["reason", "result"],
175
+ }),
167
176
  executionPayloadEnvelopeProcessingTime: register.histogram({
168
177
  name: "beacon_block_payload_envelope_processing_seconds",
169
178
  help: "Time to process execution payload envelope during block production",
@@ -1068,6 +1068,11 @@ export function createLodestarMetrics(
1068
1068
  help: "Count of errors, by error type, while processing execution payload envelopes",
1069
1069
  labelNames: ["error"],
1070
1070
  }),
1071
+ blockHashTime: register.histogram({
1072
+ name: "lodestar_gossip_execution_payload_envelope_block_hash_seconds",
1073
+ help: "Time to compute the execution block hash of a gossip execution payload envelope",
1074
+ buckets: [0.001, 0.002, 0.005, 0.01, 0.025, 0.05, 0.1, 0.5, 1],
1075
+ }),
1071
1076
  executionPayload: {
1072
1077
  recvToValidation: register.histogram({
1073
1078
  name: "lodestar_gossip_execution_payload_envelope_received_to_execution_payload_verification_seconds",
@@ -5,6 +5,7 @@ import {
5
5
  IteratorEvent,
6
6
  RequestCancelEvent,
7
7
  RequestEvent,
8
+ ResponsePullEvent,
8
9
  } from "../../util/asyncIterableToEvents.js";
9
10
  import {StrictEventEmitterSingleArg} from "../../util/strictEvents.js";
10
11
  import {EventDirection} from "../events.js";
@@ -14,18 +15,22 @@ export enum ReqRespBridgeEvent {
14
15
  outgoingRequest = "reqresp.outgoingRequest",
15
16
  outgoingRequestCancel = "reqresp.outgoingRequestCancel",
16
17
  outgoingResponse = "reqresp.outgoingResponse",
18
+ outgoingResponsePull = "reqresp.outgoingResponsePull",
17
19
  incomingRequest = "reqresp.incomingRequest",
18
20
  incomingRequestCancel = "reqresp.incomingRequestCancel",
19
21
  incomingResponse = "reqresp.incomingResponse",
22
+ incomingResponsePull = "reqresp.incomingResponsePull",
20
23
  }
21
24
 
22
25
  export type ReqRespBridgeEventData = {
23
26
  [ReqRespBridgeEvent.outgoingRequest]: RequestEvent<OutgoingRequestArgs>;
24
27
  [ReqRespBridgeEvent.outgoingRequestCancel]: RequestCancelEvent;
25
28
  [ReqRespBridgeEvent.outgoingResponse]: IteratorEvent<ResponseOutgoing>;
29
+ [ReqRespBridgeEvent.outgoingResponsePull]: ResponsePullEvent;
26
30
  [ReqRespBridgeEvent.incomingRequest]: RequestEvent<IncomingRequestArgs>;
27
31
  [ReqRespBridgeEvent.incomingRequestCancel]: RequestCancelEvent;
28
32
  [ReqRespBridgeEvent.incomingResponse]: IteratorEvent<ResponseIncoming>;
33
+ [ReqRespBridgeEvent.incomingResponsePull]: ResponsePullEvent;
29
34
  };
30
35
 
31
36
  type IReqRespBridgeEventBus = StrictEventEmitterSingleArg<ReqRespBridgeEventData>;
@@ -37,9 +42,12 @@ export const reqRespBridgeEventDirection: Record<ReqRespBridgeEvent, EventDirect
37
42
  [ReqRespBridgeEvent.outgoingRequest]: EventDirection.mainToWorker,
38
43
  [ReqRespBridgeEvent.outgoingRequestCancel]: EventDirection.mainToWorker,
39
44
  [ReqRespBridgeEvent.outgoingResponse]: EventDirection.mainToWorker,
45
+ // Credit flows from the consumer back to the producer, opposite the response it paces
46
+ [ReqRespBridgeEvent.outgoingResponsePull]: EventDirection.workerToMain,
40
47
  [ReqRespBridgeEvent.incomingRequest]: EventDirection.workerToMain,
41
48
  [ReqRespBridgeEvent.incomingRequestCancel]: EventDirection.workerToMain,
42
49
  [ReqRespBridgeEvent.incomingResponse]: EventDirection.workerToMain,
50
+ [ReqRespBridgeEvent.incomingResponsePull]: EventDirection.mainToWorker,
43
51
  };
44
52
 
45
53
  export function getReqRespBridgeReqEvents(
@@ -49,9 +57,11 @@ export function getReqRespBridgeReqEvents(
49
57
  emitRequest: (data) => events.emit(ReqRespBridgeEvent.outgoingRequest, data),
50
58
  emitRequestCancel: (data) => events.emit(ReqRespBridgeEvent.outgoingRequestCancel, data),
51
59
  emitResponse: (data) => events.emit(ReqRespBridgeEvent.incomingResponse, data),
60
+ emitResponsePull: (data) => events.emit(ReqRespBridgeEvent.incomingResponsePull, data),
52
61
  onRequest: (cb) => events.on(ReqRespBridgeEvent.outgoingRequest, cb),
53
62
  onRequestCancel: (cb) => events.on(ReqRespBridgeEvent.outgoingRequestCancel, cb),
54
63
  onResponse: (cb) => events.on(ReqRespBridgeEvent.incomingResponse, cb),
64
+ onResponsePull: (cb) => events.on(ReqRespBridgeEvent.incomingResponsePull, cb),
55
65
  };
56
66
  }
57
67
 
@@ -62,9 +72,11 @@ export function getReqRespBridgeRespEvents(
62
72
  emitRequest: (data) => events.emit(ReqRespBridgeEvent.incomingRequest, data),
63
73
  emitRequestCancel: (data) => events.emit(ReqRespBridgeEvent.incomingRequestCancel, data),
64
74
  emitResponse: (data) => events.emit(ReqRespBridgeEvent.outgoingResponse, data),
75
+ emitResponsePull: (data) => events.emit(ReqRespBridgeEvent.outgoingResponsePull, data),
65
76
  onRequest: (cb) => events.on(ReqRespBridgeEvent.incomingRequest, cb),
66
77
  onRequestCancel: (cb) => events.on(ReqRespBridgeEvent.incomingRequestCancel, cb),
67
78
  onResponse: (cb) => events.on(ReqRespBridgeEvent.outgoingResponse, cb),
79
+ onResponsePull: (cb) => events.on(ReqRespBridgeEvent.outgoingResponsePull, cb),
68
80
  };
69
81
  }
70
82
 
@@ -74,8 +74,12 @@ export class WorkerNetworkCore implements INetworkCore {
74
74
  private readonly reqRespBridgeEventBus = new ReqRespBridgeEventBus();
75
75
 
76
76
  constructor(private readonly modules: WorkerNetworkCoreModules) {
77
- // Get called from main thread to issue a ReqResp request, and emits event to worker
78
- this.reqRespBridgeReqCaller = new AsyncIterableBridgeCaller(getReqRespBridgeReqEvents(this.reqRespBridgeEventBus));
77
+ // Get called from main thread to issue a ReqResp request, and emits event to worker. Unbounded: we
78
+ // buffer the whole response into an array anyway, so pacing the worker only risks a read buffer overflow
79
+ this.reqRespBridgeReqCaller = new AsyncIterableBridgeCaller(
80
+ getReqRespBridgeReqEvents(this.reqRespBridgeEventBus),
81
+ Infinity
82
+ );
79
83
  // Handles ReqResp response from worker and calls async generator in main thread
80
84
  this.reqRespBridgeRespHandler = new AsyncIterableBridgeHandler(
81
85
  getReqRespBridgeRespEvents(this.reqRespBridgeEventBus),
@@ -25,7 +25,7 @@ import {getSlotDurations} from "@lodestar/state-transition";
25
25
  import {SubnetID} from "@lodestar/types";
26
26
  import {Logger, Map2d, Map2dArr} from "@lodestar/utils";
27
27
  import {RegistryMetricCreator} from "../../metrics/index.js";
28
- import {callImmediate, callInNextEventLoop} from "../../util/eventLoop.js";
28
+ import {callAfterIO, callInNextEventLoop} from "../../util/eventLoop.js";
29
29
  import {NetworkEvent, NetworkEventBus, NetworkEventData} from "../events.js";
30
30
  import {Libp2p} from "../interface.js";
31
31
  import {NetworkConfig} from "../networkConfig.js";
@@ -433,7 +433,7 @@ export class Eth2Gossipsub {
433
433
  // See https://github.com/ChainSafe/lodestar/issues/5604
434
434
  // A block arrives once per slot and cannot cause that lag, so it skips the 1ms timer delay
435
435
  if (topic.type === GossipType.beacon_block) {
436
- callImmediate(emitPendingMessage);
436
+ callAfterIO(emitPendingMessage);
437
437
  } else {
438
438
  callInNextEventLoop(emitPendingMessage);
439
439
  }
@@ -505,6 +505,10 @@ export class Eth2Gossipsub {
505
505
  getDirectPeers(): string[] {
506
506
  return Array.from(this.gossipsub.direct);
507
507
  }
508
+
509
+ isDirectPeer(peerIdStr: string): boolean {
510
+ return this.gossipsub.direct.has(peerIdStr);
511
+ }
508
512
  }
509
513
 
510
514
  /**
@@ -12,7 +12,7 @@ import {
12
12
  isForkPostGloas,
13
13
  } from "@lodestar/params";
14
14
  import {TypeSizes} from "@lodestar/reqresp";
15
- import {Attestation, SingleAttestation, ssz, sszTypesFor} from "@lodestar/types";
15
+ import {SingleAttestation, ssz, sszTypesFor} from "@lodestar/types";
16
16
  import {GossipAction, GossipActionError, GossipErrorCode} from "../../chain/errors/gossipValidation.js";
17
17
  import {computeMaxGloasDataColumnSidecarSize} from "../../util/sszBytes.js";
18
18
  import {NetworkConfig} from "../networkConfig.js";
@@ -173,19 +173,6 @@ export function sszDeserialize<T extends GossipTopic>(topic: T, serializedData:
173
173
  }
174
174
  }
175
175
 
176
- /**
177
- * @deprecated
178
- * Deserialize a gossip serialized data into an Attestation object.
179
- * No longer used post-electra. Use `sszDeserializeSingleAttestation` instead
180
- */
181
- export function sszDeserializeAttestation(fork: ForkName, serializedData: Uint8Array): Attestation {
182
- try {
183
- return sszTypesFor(fork).Attestation.deserialize(serializedData);
184
- } catch (_e) {
185
- throw new GossipActionError(GossipAction.REJECT, {code: GossipErrorCode.INVALID_SERIALIZED_BYTES_ERROR_CODE});
186
- }
187
- }
188
-
189
176
  /**
190
177
  * Deserialize a gossip seralized data into an SingleAttestation object.
191
178
  */