@lodestar/beacon-node 1.43.0-dev.abc719ddc1 → 1.43.0-dev.ac258a8def

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 (379) hide show
  1. package/lib/api/impl/beacon/blocks/index.d.ts.map +1 -1
  2. package/lib/api/impl/beacon/blocks/index.js +17 -9
  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 +45 -2
  6. package/lib/api/impl/beacon/pool/index.js.map +1 -1
  7. package/lib/api/impl/beacon/state/utils.d.ts +2 -2
  8. package/lib/api/impl/beacon/state/utils.d.ts.map +1 -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 +0 -1
  12. package/lib/api/impl/debug/index.js.map +1 -1
  13. package/lib/api/impl/lodestar/index.js +1 -1
  14. package/lib/api/impl/lodestar/index.js.map +1 -1
  15. package/lib/api/impl/validator/index.d.ts.map +1 -1
  16. package/lib/api/impl/validator/index.js +68 -6
  17. package/lib/api/impl/validator/index.js.map +1 -1
  18. package/lib/chain/archiveStore/archiveStore.d.ts.map +1 -1
  19. package/lib/chain/archiveStore/archiveStore.js.map +1 -1
  20. package/lib/chain/archiveStore/interface.d.ts +4 -4
  21. package/lib/chain/archiveStore/interface.d.ts.map +1 -1
  22. package/lib/chain/archiveStore/strategies/frequencyStateArchiveStrategy.d.ts +4 -4
  23. package/lib/chain/archiveStore/strategies/frequencyStateArchiveStrategy.d.ts.map +1 -1
  24. package/lib/chain/archiveStore/strategies/frequencyStateArchiveStrategy.js.map +1 -1
  25. package/lib/chain/archiveStore/utils/archiveBlocks.d.ts +2 -2
  26. package/lib/chain/archiveStore/utils/archiveBlocks.d.ts.map +1 -1
  27. package/lib/chain/archiveStore/utils/archiveBlocks.js +110 -58
  28. package/lib/chain/archiveStore/utils/archiveBlocks.js.map +1 -1
  29. package/lib/chain/blocks/blockInput/blockInput.d.ts +3 -0
  30. package/lib/chain/blocks/blockInput/blockInput.d.ts.map +1 -1
  31. package/lib/chain/blocks/blockInput/blockInput.js +4 -1
  32. package/lib/chain/blocks/blockInput/blockInput.js.map +1 -1
  33. package/lib/chain/blocks/importBlock.d.ts.map +1 -1
  34. package/lib/chain/blocks/importBlock.js +16 -28
  35. package/lib/chain/blocks/importBlock.js.map +1 -1
  36. package/lib/chain/blocks/importExecutionPayload.d.ts +32 -14
  37. package/lib/chain/blocks/importExecutionPayload.d.ts.map +1 -1
  38. package/lib/chain/blocks/importExecutionPayload.js +100 -91
  39. package/lib/chain/blocks/importExecutionPayload.js.map +1 -1
  40. package/lib/chain/blocks/index.d.ts +5 -3
  41. package/lib/chain/blocks/index.d.ts.map +1 -1
  42. package/lib/chain/blocks/index.js +58 -26
  43. package/lib/chain/blocks/index.js.map +1 -1
  44. package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.d.ts +12 -1
  45. package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.d.ts.map +1 -1
  46. package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.js +28 -2
  47. package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.js.map +1 -1
  48. package/lib/chain/blocks/payloadEnvelopeInput/types.d.ts +17 -0
  49. package/lib/chain/blocks/payloadEnvelopeInput/types.d.ts.map +1 -1
  50. package/lib/chain/blocks/payloadEnvelopeProcessor.js +2 -2
  51. package/lib/chain/blocks/payloadEnvelopeProcessor.js.map +1 -1
  52. package/lib/chain/blocks/types.d.ts +15 -20
  53. package/lib/chain/blocks/types.d.ts.map +1 -1
  54. package/lib/chain/blocks/utils/chainSegment.d.ts +21 -2
  55. package/lib/chain/blocks/utils/chainSegment.d.ts.map +1 -1
  56. package/lib/chain/blocks/utils/chainSegment.js +92 -12
  57. package/lib/chain/blocks/utils/chainSegment.js.map +1 -1
  58. package/lib/chain/blocks/verifyBlock.d.ts +5 -3
  59. package/lib/chain/blocks/verifyBlock.d.ts.map +1 -1
  60. package/lib/chain/blocks/verifyBlock.js +50 -7
  61. package/lib/chain/blocks/verifyBlock.js.map +1 -1
  62. package/lib/chain/blocks/verifyBlocksExecutionPayloads.d.ts +0 -4
  63. package/lib/chain/blocks/verifyBlocksExecutionPayloads.d.ts.map +1 -1
  64. package/lib/chain/blocks/verifyBlocksExecutionPayloads.js +5 -2
  65. package/lib/chain/blocks/verifyBlocksExecutionPayloads.js.map +1 -1
  66. package/lib/chain/blocks/verifyBlocksSanityChecks.d.ts +2 -1
  67. package/lib/chain/blocks/verifyBlocksSanityChecks.d.ts.map +1 -1
  68. package/lib/chain/blocks/verifyBlocksSanityChecks.js +25 -5
  69. package/lib/chain/blocks/verifyBlocksSanityChecks.js.map +1 -1
  70. package/lib/chain/blocks/verifyExecutionPayloadEnvelope.d.ts +24 -0
  71. package/lib/chain/blocks/verifyExecutionPayloadEnvelope.d.ts.map +1 -0
  72. package/lib/chain/blocks/verifyExecutionPayloadEnvelope.js +80 -0
  73. package/lib/chain/blocks/verifyExecutionPayloadEnvelope.js.map +1 -0
  74. package/lib/chain/blocks/verifyPayloadsDataAvailability.d.ts.map +1 -1
  75. package/lib/chain/blocks/verifyPayloadsDataAvailability.js +8 -3
  76. package/lib/chain/blocks/verifyPayloadsDataAvailability.js.map +1 -1
  77. package/lib/chain/blocks/writePayloadEnvelopeInputToDb.d.ts +1 -1
  78. package/lib/chain/blocks/writePayloadEnvelopeInputToDb.d.ts.map +1 -1
  79. package/lib/chain/blocks/writePayloadEnvelopeInputToDb.js +2 -11
  80. package/lib/chain/blocks/writePayloadEnvelopeInputToDb.js.map +1 -1
  81. package/lib/chain/chain.d.ts +8 -6
  82. package/lib/chain/chain.d.ts.map +1 -1
  83. package/lib/chain/chain.js +44 -14
  84. package/lib/chain/chain.js.map +1 -1
  85. package/lib/chain/emitter.d.ts +3 -14
  86. package/lib/chain/emitter.d.ts.map +1 -1
  87. package/lib/chain/emitter.js +0 -4
  88. package/lib/chain/emitter.js.map +1 -1
  89. package/lib/chain/errors/blockError.d.ts +8 -1
  90. package/lib/chain/errors/blockError.d.ts.map +1 -1
  91. package/lib/chain/errors/blockError.js +2 -0
  92. package/lib/chain/errors/blockError.js.map +1 -1
  93. package/lib/chain/errors/executionPayloadBid.d.ts +5 -0
  94. package/lib/chain/errors/executionPayloadBid.d.ts.map +1 -1
  95. package/lib/chain/errors/executionPayloadBid.js +1 -0
  96. package/lib/chain/errors/executionPayloadBid.js.map +1 -1
  97. package/lib/chain/errors/executionPayloadEnvelope.d.ts +5 -0
  98. package/lib/chain/errors/executionPayloadEnvelope.d.ts.map +1 -1
  99. package/lib/chain/errors/executionPayloadEnvelope.js +1 -0
  100. package/lib/chain/errors/executionPayloadEnvelope.js.map +1 -1
  101. package/lib/chain/errors/index.d.ts +1 -0
  102. package/lib/chain/errors/index.d.ts.map +1 -1
  103. package/lib/chain/errors/index.js +1 -0
  104. package/lib/chain/errors/index.js.map +1 -1
  105. package/lib/chain/errors/proposerPreferences.d.ts +40 -0
  106. package/lib/chain/errors/proposerPreferences.d.ts.map +1 -0
  107. package/lib/chain/errors/proposerPreferences.js +14 -0
  108. package/lib/chain/errors/proposerPreferences.js.map +1 -0
  109. package/lib/chain/forkChoice/index.d.ts.map +1 -1
  110. package/lib/chain/forkChoice/index.js +5 -17
  111. package/lib/chain/forkChoice/index.js.map +1 -1
  112. package/lib/chain/initState.d.ts.map +1 -1
  113. package/lib/chain/initState.js +6 -1
  114. package/lib/chain/initState.js.map +1 -1
  115. package/lib/chain/interface.d.ts +7 -5
  116. package/lib/chain/interface.d.ts.map +1 -1
  117. package/lib/chain/interface.js.map +1 -1
  118. package/lib/chain/opPools/payloadAttestationPool.d.ts +3 -2
  119. package/lib/chain/opPools/payloadAttestationPool.d.ts.map +1 -1
  120. package/lib/chain/opPools/payloadAttestationPool.js +26 -4
  121. package/lib/chain/opPools/payloadAttestationPool.js.map +1 -1
  122. package/lib/chain/prepareNextSlot.d.ts.map +1 -1
  123. package/lib/chain/prepareNextSlot.js +31 -13
  124. package/lib/chain/prepareNextSlot.js.map +1 -1
  125. package/lib/chain/produceBlock/produceBlockBody.d.ts +11 -1
  126. package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
  127. package/lib/chain/produceBlock/produceBlockBody.js +52 -14
  128. package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
  129. package/lib/chain/regen/interface.d.ts +1 -0
  130. package/lib/chain/regen/interface.d.ts.map +1 -1
  131. package/lib/chain/regen/interface.js +1 -0
  132. package/lib/chain/regen/interface.js.map +1 -1
  133. package/lib/chain/regen/queued.d.ts.map +1 -1
  134. package/lib/chain/regen/queued.js +1 -4
  135. package/lib/chain/regen/queued.js.map +1 -1
  136. package/lib/chain/regen/regen.d.ts.map +1 -1
  137. package/lib/chain/regen/regen.js +1 -4
  138. package/lib/chain/regen/regen.js.map +1 -1
  139. package/lib/chain/seenCache/index.d.ts +1 -0
  140. package/lib/chain/seenCache/index.d.ts.map +1 -1
  141. package/lib/chain/seenCache/index.js +1 -0
  142. package/lib/chain/seenCache/index.js.map +1 -1
  143. package/lib/chain/seenCache/seenPayloadEnvelopeInput.d.ts +24 -7
  144. package/lib/chain/seenCache/seenPayloadEnvelopeInput.d.ts.map +1 -1
  145. package/lib/chain/seenCache/seenPayloadEnvelopeInput.js +69 -17
  146. package/lib/chain/seenCache/seenPayloadEnvelopeInput.js.map +1 -1
  147. package/lib/chain/seenCache/seenProposerPreferences.d.ts +16 -0
  148. package/lib/chain/seenCache/seenProposerPreferences.d.ts.map +1 -0
  149. package/lib/chain/seenCache/seenProposerPreferences.js +26 -0
  150. package/lib/chain/seenCache/seenProposerPreferences.js.map +1 -0
  151. package/lib/chain/validation/block.d.ts.map +1 -1
  152. package/lib/chain/validation/block.js +1 -0
  153. package/lib/chain/validation/block.js.map +1 -1
  154. package/lib/chain/validation/executionPayloadBid.d.ts.map +1 -1
  155. package/lib/chain/validation/executionPayloadBid.js +24 -9
  156. package/lib/chain/validation/executionPayloadBid.js.map +1 -1
  157. package/lib/chain/validation/executionPayloadEnvelope.d.ts.map +1 -1
  158. package/lib/chain/validation/executionPayloadEnvelope.js +19 -9
  159. package/lib/chain/validation/executionPayloadEnvelope.js.map +1 -1
  160. package/lib/chain/validation/proposerPreferences.d.ts +8 -0
  161. package/lib/chain/validation/proposerPreferences.d.ts.map +1 -0
  162. package/lib/chain/validation/proposerPreferences.js +91 -0
  163. package/lib/chain/validation/proposerPreferences.js.map +1 -0
  164. package/lib/db/repositories/executionPayloadEnvelopeArchive.js +1 -1
  165. package/lib/db/repositories/executionPayloadEnvelopeArchive.js.map +1 -1
  166. package/lib/execution/engine/http.d.ts.map +1 -1
  167. package/lib/execution/engine/http.js +21 -14
  168. package/lib/execution/engine/http.js.map +1 -1
  169. package/lib/execution/engine/interface.d.ts +1 -0
  170. package/lib/execution/engine/interface.d.ts.map +1 -1
  171. package/lib/execution/engine/mock.d.ts.map +1 -1
  172. package/lib/execution/engine/mock.js +6 -0
  173. package/lib/execution/engine/mock.js.map +1 -1
  174. package/lib/execution/engine/types.d.ts +20 -0
  175. package/lib/execution/engine/types.d.ts.map +1 -1
  176. package/lib/execution/engine/types.js +18 -0
  177. package/lib/execution/engine/types.js.map +1 -1
  178. package/lib/metrics/metrics/lodestar.d.ts +1 -0
  179. package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
  180. package/lib/metrics/metrics/lodestar.js +4 -0
  181. package/lib/metrics/metrics/lodestar.js.map +1 -1
  182. package/lib/network/gossip/interface.d.ts +7 -1
  183. package/lib/network/gossip/interface.d.ts.map +1 -1
  184. package/lib/network/gossip/interface.js +1 -0
  185. package/lib/network/gossip/interface.js.map +1 -1
  186. package/lib/network/gossip/scoringParameters.d.ts.map +1 -1
  187. package/lib/network/gossip/scoringParameters.js +12 -1
  188. package/lib/network/gossip/scoringParameters.js.map +1 -1
  189. package/lib/network/gossip/topic.d.ts +32 -748
  190. package/lib/network/gossip/topic.d.ts.map +1 -1
  191. package/lib/network/gossip/topic.js +6 -0
  192. package/lib/network/gossip/topic.js.map +1 -1
  193. package/lib/network/interface.d.ts +2 -0
  194. package/lib/network/interface.d.ts.map +1 -1
  195. package/lib/network/network.d.ts +2 -0
  196. package/lib/network/network.d.ts.map +1 -1
  197. package/lib/network/network.js +9 -1
  198. package/lib/network/network.js.map +1 -1
  199. package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
  200. package/lib/network/processor/gossipHandlers.js +41 -19
  201. package/lib/network/processor/gossipHandlers.js.map +1 -1
  202. package/lib/network/processor/gossipQueues/index.d.ts.map +1 -1
  203. package/lib/network/processor/gossipQueues/index.js +5 -0
  204. package/lib/network/processor/gossipQueues/index.js.map +1 -1
  205. package/lib/network/processor/index.d.ts.map +1 -1
  206. package/lib/network/processor/index.js +6 -5
  207. package/lib/network/processor/index.js.map +1 -1
  208. package/lib/network/reqresp/ReqRespBeaconNode.d.ts.map +1 -1
  209. package/lib/network/reqresp/ReqRespBeaconNode.js +1 -1
  210. package/lib/network/reqresp/ReqRespBeaconNode.js.map +1 -1
  211. package/lib/network/reqresp/handlers/beaconBlocksByHead.d.ts +9 -0
  212. package/lib/network/reqresp/handlers/beaconBlocksByHead.d.ts.map +1 -0
  213. package/lib/network/reqresp/handlers/beaconBlocksByHead.js +61 -0
  214. package/lib/network/reqresp/handlers/beaconBlocksByHead.js.map +1 -0
  215. package/lib/network/reqresp/handlers/beaconBlocksByRange.d.ts.map +1 -1
  216. package/lib/network/reqresp/handlers/beaconBlocksByRange.js +14 -6
  217. package/lib/network/reqresp/handlers/beaconBlocksByRange.js.map +1 -1
  218. package/lib/network/reqresp/handlers/blobSidecarsByRange.d.ts.map +1 -1
  219. package/lib/network/reqresp/handlers/blobSidecarsByRange.js +11 -5
  220. package/lib/network/reqresp/handlers/blobSidecarsByRange.js.map +1 -1
  221. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.d.ts.map +1 -1
  222. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js +17 -5
  223. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js.map +1 -1
  224. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.d.ts.map +1 -1
  225. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.js +7 -4
  226. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.js.map +1 -1
  227. package/lib/network/reqresp/handlers/index.d.ts.map +1 -1
  228. package/lib/network/reqresp/handlers/index.js +5 -0
  229. package/lib/network/reqresp/handlers/index.js.map +1 -1
  230. package/lib/network/reqresp/interface.d.ts +1 -1
  231. package/lib/network/reqresp/interface.js +1 -1
  232. package/lib/network/reqresp/protocols.d.ts +1 -0
  233. package/lib/network/reqresp/protocols.d.ts.map +1 -1
  234. package/lib/network/reqresp/protocols.js +5 -0
  235. package/lib/network/reqresp/protocols.js.map +1 -1
  236. package/lib/network/reqresp/rateLimit.d.ts.map +1 -1
  237. package/lib/network/reqresp/rateLimit.js +4 -0
  238. package/lib/network/reqresp/rateLimit.js.map +1 -1
  239. package/lib/network/reqresp/score.d.ts.map +1 -1
  240. package/lib/network/reqresp/score.js +1 -0
  241. package/lib/network/reqresp/score.js.map +1 -1
  242. package/lib/network/reqresp/types.d.ts +3 -0
  243. package/lib/network/reqresp/types.d.ts.map +1 -1
  244. package/lib/network/reqresp/types.js +3 -0
  245. package/lib/network/reqresp/types.js.map +1 -1
  246. package/lib/node/nodejs.js +2 -2
  247. package/lib/node/nodejs.js.map +1 -1
  248. package/lib/sync/constants.d.ts +7 -1
  249. package/lib/sync/constants.d.ts.map +1 -1
  250. package/lib/sync/constants.js +7 -4
  251. package/lib/sync/constants.js.map +1 -1
  252. package/lib/sync/range/batch.d.ts +35 -5
  253. package/lib/sync/range/batch.d.ts.map +1 -1
  254. package/lib/sync/range/batch.js +240 -59
  255. package/lib/sync/range/batch.js.map +1 -1
  256. package/lib/sync/range/chain.d.ts +22 -4
  257. package/lib/sync/range/chain.d.ts.map +1 -1
  258. package/lib/sync/range/chain.js +102 -10
  259. package/lib/sync/range/chain.js.map +1 -1
  260. package/lib/sync/range/range.d.ts.map +1 -1
  261. package/lib/sync/range/range.js +71 -11
  262. package/lib/sync/range/range.js.map +1 -1
  263. package/lib/sync/sync.d.ts.map +1 -1
  264. package/lib/sync/sync.js +13 -0
  265. package/lib/sync/sync.js.map +1 -1
  266. package/lib/sync/types.d.ts +34 -0
  267. package/lib/sync/types.d.ts.map +1 -1
  268. package/lib/sync/types.js +34 -0
  269. package/lib/sync/types.js.map +1 -1
  270. package/lib/sync/unknownBlock.d.ts +29 -1
  271. package/lib/sync/unknownBlock.d.ts.map +1 -1
  272. package/lib/sync/unknownBlock.js +727 -61
  273. package/lib/sync/unknownBlock.js.map +1 -1
  274. package/lib/sync/utils/downloadByRange.d.ts +73 -10
  275. package/lib/sync/utils/downloadByRange.d.ts.map +1 -1
  276. package/lib/sync/utils/downloadByRange.js +213 -26
  277. package/lib/sync/utils/downloadByRange.js.map +1 -1
  278. package/lib/sync/utils/downloadByRoot.d.ts.map +1 -1
  279. package/lib/sync/utils/downloadByRoot.js +16 -2
  280. package/lib/sync/utils/downloadByRoot.js.map +1 -1
  281. package/lib/sync/utils/pendingBlocksTree.d.ts +0 -1
  282. package/lib/sync/utils/pendingBlocksTree.d.ts.map +1 -1
  283. package/lib/sync/utils/pendingBlocksTree.js +0 -9
  284. package/lib/sync/utils/pendingBlocksTree.js.map +1 -1
  285. package/lib/sync/utils/rateLimit.d.ts +2 -0
  286. package/lib/sync/utils/rateLimit.d.ts.map +1 -0
  287. package/lib/sync/utils/rateLimit.js +15 -0
  288. package/lib/sync/utils/rateLimit.js.map +1 -0
  289. package/lib/util/sszBytes.d.ts.map +1 -1
  290. package/lib/util/sszBytes.js +20 -5
  291. package/lib/util/sszBytes.js.map +1 -1
  292. package/package.json +17 -16
  293. package/src/api/impl/beacon/blocks/index.ts +22 -9
  294. package/src/api/impl/beacon/pool/index.ts +83 -1
  295. package/src/api/impl/beacon/state/utils.ts +2 -2
  296. package/src/api/impl/debug/index.ts +0 -1
  297. package/src/api/impl/lodestar/index.ts +1 -1
  298. package/src/api/impl/validator/index.ts +82 -5
  299. package/src/chain/archiveStore/archiveStore.ts +5 -5
  300. package/src/chain/archiveStore/interface.ts +4 -4
  301. package/src/chain/archiveStore/strategies/frequencyStateArchiveStrategy.ts +4 -4
  302. package/src/chain/archiveStore/utils/archiveBlocks.ts +153 -94
  303. package/src/chain/blocks/blockInput/blockInput.ts +4 -1
  304. package/src/chain/blocks/importBlock.ts +16 -48
  305. package/src/chain/blocks/importExecutionPayload.ts +126 -110
  306. package/src/chain/blocks/index.ts +71 -23
  307. package/src/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.ts +37 -3
  308. package/src/chain/blocks/payloadEnvelopeInput/types.ts +18 -0
  309. package/src/chain/blocks/payloadEnvelopeProcessor.ts +2 -2
  310. package/src/chain/blocks/types.ts +15 -25
  311. package/src/chain/blocks/utils/chainSegment.ts +117 -17
  312. package/src/chain/blocks/verifyBlock.ts +70 -9
  313. package/src/chain/blocks/verifyBlocksExecutionPayloads.ts +6 -4
  314. package/src/chain/blocks/verifyBlocksSanityChecks.ts +26 -7
  315. package/src/chain/blocks/verifyExecutionPayloadEnvelope.ts +137 -0
  316. package/src/chain/blocks/verifyPayloadsDataAvailability.ts +7 -4
  317. package/src/chain/blocks/writePayloadEnvelopeInputToDb.ts +9 -18
  318. package/src/chain/chain.ts +65 -26
  319. package/src/chain/emitter.ts +3 -14
  320. package/src/chain/errors/blockError.ts +4 -1
  321. package/src/chain/errors/executionPayloadBid.ts +6 -0
  322. package/src/chain/errors/executionPayloadEnvelope.ts +6 -0
  323. package/src/chain/errors/index.ts +1 -0
  324. package/src/chain/errors/proposerPreferences.ts +47 -0
  325. package/src/chain/forkChoice/index.ts +2 -22
  326. package/src/chain/initState.ts +9 -1
  327. package/src/chain/interface.ts +11 -3
  328. package/src/chain/opPools/payloadAttestationPool.ts +29 -8
  329. package/src/chain/prepareNextSlot.ts +36 -14
  330. package/src/chain/produceBlock/produceBlockBody.ts +63 -13
  331. package/src/chain/regen/interface.ts +1 -0
  332. package/src/chain/regen/queued.ts +2 -7
  333. package/src/chain/regen/regen.ts +2 -7
  334. package/src/chain/seenCache/index.ts +1 -0
  335. package/src/chain/seenCache/seenPayloadEnvelopeInput.ts +89 -21
  336. package/src/chain/seenCache/seenProposerPreferences.ts +32 -0
  337. package/src/chain/validation/block.ts +1 -0
  338. package/src/chain/validation/executionPayloadBid.ts +25 -8
  339. package/src/chain/validation/executionPayloadEnvelope.ts +20 -10
  340. package/src/chain/validation/proposerPreferences.ts +110 -0
  341. package/src/db/repositories/executionPayloadEnvelopeArchive.ts +1 -1
  342. package/src/execution/engine/http.ts +21 -14
  343. package/src/execution/engine/interface.ts +1 -0
  344. package/src/execution/engine/mock.ts +8 -1
  345. package/src/execution/engine/types.ts +41 -0
  346. package/src/metrics/metrics/lodestar.ts +4 -0
  347. package/src/network/gossip/interface.ts +6 -0
  348. package/src/network/gossip/scoringParameters.ts +14 -1
  349. package/src/network/gossip/topic.ts +6 -0
  350. package/src/network/interface.ts +2 -0
  351. package/src/network/network.ts +24 -1
  352. package/src/network/processor/gossipHandlers.ts +56 -20
  353. package/src/network/processor/gossipQueues/index.ts +5 -0
  354. package/src/network/processor/index.ts +6 -5
  355. package/src/network/reqresp/ReqRespBeaconNode.ts +1 -0
  356. package/src/network/reqresp/handlers/beaconBlocksByHead.ts +91 -0
  357. package/src/network/reqresp/handlers/beaconBlocksByRange.ts +14 -6
  358. package/src/network/reqresp/handlers/blobSidecarsByRange.ts +11 -5
  359. package/src/network/reqresp/handlers/dataColumnSidecarsByRange.ts +17 -5
  360. package/src/network/reqresp/handlers/executionPayloadEnvelopesByRange.ts +7 -4
  361. package/src/network/reqresp/handlers/index.ts +5 -0
  362. package/src/network/reqresp/interface.ts +1 -1
  363. package/src/network/reqresp/protocols.ts +6 -0
  364. package/src/network/reqresp/rateLimit.ts +4 -0
  365. package/src/network/reqresp/score.ts +1 -0
  366. package/src/network/reqresp/types.ts +5 -0
  367. package/src/node/nodejs.ts +2 -2
  368. package/src/sync/constants.ts +8 -4
  369. package/src/sync/range/batch.ts +320 -67
  370. package/src/sync/range/chain.ts +130 -13
  371. package/src/sync/range/range.ts +86 -11
  372. package/src/sync/sync.ts +13 -1
  373. package/src/sync/types.ts +72 -0
  374. package/src/sync/unknownBlock.ts +915 -65
  375. package/src/sync/utils/downloadByRange.ts +386 -39
  376. package/src/sync/utils/downloadByRoot.ts +24 -2
  377. package/src/sync/utils/pendingBlocksTree.ts +0 -15
  378. package/src/sync/utils/rateLimit.ts +16 -0
  379. package/src/util/sszBytes.ts +25 -5
@@ -52,6 +52,8 @@ import {
52
52
  ExecutionPayloadEnvelopeErrorCode,
53
53
  GossipAction,
54
54
  GossipActionError,
55
+ PayloadAttestationError,
56
+ PayloadAttestationErrorCode,
55
57
  SyncCommitteeError,
56
58
  } from "../../chain/errors/index.js";
57
59
  import {IBeaconChain} from "../../chain/interface.js";
@@ -79,6 +81,7 @@ import {
79
81
  import {validateLightClientFinalityUpdate} from "../../chain/validation/lightClientFinalityUpdate.js";
80
82
  import {validateLightClientOptimisticUpdate} from "../../chain/validation/lightClientOptimisticUpdate.js";
81
83
  import {validateGossipPayloadAttestationMessage} from "../../chain/validation/payloadAttestationMessage.js";
84
+ import {validateGossipProposerPreferences} from "../../chain/validation/proposerPreferences.js";
82
85
  import {OpSource} from "../../chain/validatorMonitor.js";
83
86
  import {Metrics} from "../../metrics/index.js";
84
87
  import {kzgCommitmentToVersionedHash} from "../../util/blobs.js";
@@ -182,6 +185,18 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
182
185
  });
183
186
  try {
184
187
  await validateGossipBlock(config, chain, signedBlock, fork);
188
+
189
+ if (isForkPostGloas(fork)) {
190
+ chain.seenPayloadEnvelopeInputCache.add({
191
+ blockRootHex,
192
+ block: signedBlock as SignedBeaconBlock<ForkPostGloas>,
193
+ forkName: fork,
194
+ sampledColumns: chain.custodyConfig.sampledColumns,
195
+ custodyColumns: chain.custodyConfig.custodyColumns,
196
+ timeCreatedSec: seenTimestampSec,
197
+ });
198
+ }
199
+
185
200
  const blockInputMeta = blockInput.getLogMeta();
186
201
 
187
202
  const recvToValidation = Date.now() / 1000 - seenTimestampSec;
@@ -198,7 +213,10 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
198
213
  } catch (e) {
199
214
  if (e instanceof BlockGossipError) {
200
215
  logger.debug("Gossip block has error", {slot, root: blockShortHex, code: e.type.code});
201
- if (e.type.code === BlockErrorCode.PARENT_UNKNOWN && blockInput) {
216
+ if (
217
+ (e.type.code === BlockErrorCode.PARENT_UNKNOWN || e.type.code === BlockErrorCode.PARENT_PAYLOAD_UNKNOWN) &&
218
+ blockInput
219
+ ) {
202
220
  chain.emitter.emit(ChainEvent.blockUnknownParent, {
203
221
  blockInput,
204
222
  peer: peerIdStr,
@@ -589,6 +607,24 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
589
607
  // Returns the delay between the start of `block.slot` and `current time`
590
608
  const delaySec = chain.clock.secFromSlot(slot);
591
609
  metrics?.gossipBlock.elapsedTimeTillProcessed.observe(delaySec);
610
+
611
+ if (isForkPostGloas(blockInput.forkName)) {
612
+ const payloadInput = chain.seenPayloadEnvelopeInputCache.get(blockInput.blockRootHex);
613
+ // This payloadInput should have been created just after gossip validation
614
+ if (!payloadInput) {
615
+ throw Error(
616
+ `PayloadEnvelopeInput not seeded for block ${blockInput.blockRootHex} during gossip processing`
617
+ );
618
+ }
619
+
620
+ // Immediately attempt fetch of data columns from execution engine as the bid contains kzg commitments
621
+ // which is all the information we need so there is no reason to delay until execution payload arrives
622
+ // TODO GLOAS: If we want EL retries after this initial attempt, add an explicit retry policy here
623
+ // (for example later in the slot). Do not couple retries to incoming gossip columns.
624
+ // Columns fetched here feed payloadInput.addColumn, which resolves waitForAllData for any
625
+ // in-flight importExecutionPayload. No processExecutionPayload trigger needed from this path.
626
+ chain.getBlobsTracker.triggerGetBlobs(payloadInput);
627
+ }
592
628
  })
593
629
  .catch((e) => {
594
630
  // Adjust verbosity based on error type
@@ -1057,24 +1093,15 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
1057
1093
  const signedEnvelope = sszDeserialize(topic, serializedData);
1058
1094
  const envelope = signedEnvelope.message;
1059
1095
 
1060
- // TODO GLOAS: consider optimistically create PayloadEnvelopeInput here similar to how we do that for beacon_block
1061
- // so that UnknownBlockSync can handle backward sync
1062
- // the problem now is we cannot create a PayloadEnvelopeInput without the beacon block being known, we need at least the proposer index
1063
- // we can achieve that by looking into the EpochCache
1096
+ // unlike BlockInput, we send the envelope into UnknownBlockInput sync
1097
+ // inside the sync it'll reconcile into PayloadEnvelopeInput and share the same cache with gossip
1064
1098
  try {
1065
1099
  await validateGossipExecutionPayloadEnvelope(chain, signedEnvelope);
1066
1100
  } catch (e) {
1067
1101
  if (e instanceof ExecutionPayloadEnvelopeError) {
1068
- const {slot, beaconBlockRoot} = signedEnvelope.message;
1102
+ const {beaconBlockRoot} = signedEnvelope.message;
1103
+ const slot = signedEnvelope.message.payload.slotNumber;
1069
1104
  logger.debug("Gossip envelope has error", {slot, root: toRootHex(beaconBlockRoot), code: e.type.code});
1070
- if (e.type.code === ExecutionPayloadEnvelopeErrorCode.BLOCK_ROOT_UNKNOWN) {
1071
- // TODO GLOAS: UnknownBlockSync to handle this
1072
- chain.emitter.emit(ChainEvent.envelopeUnknownBlock, {
1073
- envelope: signedEnvelope,
1074
- peer: peerIdStr,
1075
- source: BlockInputSource.gossip,
1076
- });
1077
- }
1078
1105
 
1079
1106
  if (e.action === GossipAction.REJECT) {
1080
1107
  chain.persistInvalidSszValue(
@@ -1088,7 +1115,7 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
1088
1115
  throw e;
1089
1116
  }
1090
1117
 
1091
- const slot = envelope.slot;
1118
+ const slot = envelope.payload.slotNumber;
1092
1119
  const delaySec = seenTimestampSec - computeTimeAtSlot(config, slot, chain.genesisTime);
1093
1120
  metrics?.gossipExecutionPayloadEnvelope.elapsedTimeTillReceived.observe({source: OpSource.gossip}, delaySec);
1094
1121
  chain.validatorMonitor?.registerExecutionPayloadEnvelope(OpSource.gossip, delaySec, signedEnvelope);
@@ -1118,7 +1145,6 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
1118
1145
  builderIndex: envelope.builderIndex,
1119
1146
  blockHash: toRootHex(envelope.payload.blockHash),
1120
1147
  blockRoot: blockRootHex,
1121
- stateRoot: toRootHex(envelope.stateRoot),
1122
1148
  });
1123
1149
 
1124
1150
  chain.processExecutionPayload(payloadInput, {validSignature: true}).catch((e) => {
@@ -1170,6 +1196,14 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
1170
1196
  data: executionPayloadBid,
1171
1197
  });
1172
1198
  },
1199
+ [GossipType.proposer_preferences]: async ({
1200
+ gossipData,
1201
+ topic,
1202
+ }: GossipHandlerParamGeneric<GossipType.proposer_preferences>) => {
1203
+ const {serializedData} = gossipData;
1204
+ const signedProposerPreferences = sszDeserialize(topic, serializedData);
1205
+ await validateGossipProposerPreferences(chain, signedProposerPreferences);
1206
+ },
1173
1207
  };
1174
1208
  }
1175
1209
 
@@ -1292,10 +1326,12 @@ export async function validateGossipFnRetryUnknownRoot<T>(
1292
1326
  try {
1293
1327
  return await fn();
1294
1328
  } catch (e) {
1295
- if (
1296
- e instanceof AttestationError &&
1297
- e.type.code === AttestationErrorCode.UNKNOWN_OR_PREFINALIZED_BEACON_BLOCK_ROOT
1298
- ) {
1329
+ const isUnknownAttestationRoot =
1330
+ e instanceof AttestationError && e.type.code === AttestationErrorCode.UNKNOWN_OR_PREFINALIZED_BEACON_BLOCK_ROOT;
1331
+ const isUnknownPayloadAttestationRoot =
1332
+ e instanceof PayloadAttestationError && e.type.code === PayloadAttestationErrorCode.UNKNOWN_BLOCK_ROOT;
1333
+
1334
+ if (isUnknownAttestationRoot || isUnknownPayloadAttestationRoot) {
1299
1335
  if (unknownBlockRootRetries === 0) {
1300
1336
  // Trigger unknown block root search here
1301
1337
  const rootHex = toRootHex(blockRoot);
@@ -83,6 +83,11 @@ const linearGossipQueueOpts: {
83
83
  type: QueueType.FIFO,
84
84
  dropOpts: {type: DropType.count, count: 1},
85
85
  },
86
+ [GossipType.proposer_preferences]: {
87
+ maxLength: 1024,
88
+ type: QueueType.FIFO,
89
+ dropOpts: {type: DropType.count, count: 1},
90
+ },
86
91
  };
87
92
 
88
93
  const indexedGossipQueueOpts: {
@@ -76,6 +76,7 @@ type WorkOpts = {
76
76
  */
77
77
  const executeGossipWorkOrderObj: Record<GossipType, WorkOpts> = {
78
78
  [GossipType.beacon_block]: {bypassQueue: true},
79
+ [GossipType.execution_payload]: {bypassQueue: true},
79
80
  [GossipType.blob_sidecar]: {bypassQueue: true},
80
81
  [GossipType.data_column_sidecar]: {bypassQueue: true},
81
82
  [GossipType.beacon_aggregate_and_proof]: {},
@@ -88,9 +89,9 @@ const executeGossipWorkOrderObj: Record<GossipType, WorkOpts> = {
88
89
  [GossipType.sync_committee]: {},
89
90
  [GossipType.light_client_finality_update]: {},
90
91
  [GossipType.light_client_optimistic_update]: {},
91
- [GossipType.execution_payload]: {bypassQueue: true},
92
92
  [GossipType.payload_attestation_message]: {},
93
93
  [GossipType.execution_payload_bid]: {},
94
+ [GossipType.proposer_preferences]: {},
94
95
  };
95
96
  const executeGossipWorkOrder = Object.keys(executeGossipWorkOrderObj) as (keyof typeof executeGossipWorkOrderObj)[];
96
97
 
@@ -443,8 +444,7 @@ export class NetworkProcessor {
443
444
  }
444
445
  case GossipType.execution_payload: {
445
446
  // extractBlockSlotRootFn does not return a root for this topic.
446
- // Extract beacon_block_root directly and proactively trigger block sync if missing.
447
- // Do NOT await the block — the handler runs immediately; BlockInputSync handles recovery.
447
+ // Extract beacon_block_root directly
448
448
  const blockRoot = getBeaconBlockRootFromExecutionPayloadEnvelopeSerialized(message.msg.data);
449
449
  if (blockRoot && !this.chain.forkChoice.hasBlockHexUnsafe(blockRoot)) {
450
450
  this.searchUnknownBlock(
@@ -452,9 +452,10 @@ export class NetworkProcessor {
452
452
  BlockInputSource.network_processor,
453
453
  message.propagationSource.toString()
454
454
  );
455
+ // We always want to await the block
456
+ // This allows us to properly forward the payload envelope
457
+ preprocessResult = {action: PreprocessAction.AwaitBlock, root: blockRoot};
455
458
  }
456
- // do not await the block, we want UnknownBlockSync to handle it.
457
- preprocessResult = {action: PreprocessAction.PushToQueue};
458
459
  break;
459
460
  }
460
461
  case GossipType.execution_payload_bid: {
@@ -286,6 +286,7 @@ export class ReqRespBeaconNode extends ReqResp {
286
286
  // instead of protocol version. This is not easily fixable with our current architecture.
287
287
  // See https://github.com/ChainSafe/lodestar/pull/8168 for more details.
288
288
  [protocols.StatusV2(fork, this.config), this.onStatus.bind(this)],
289
+ [protocols.BeaconBlocksByHead(fork, this.config), this.getHandler(ReqRespMethod.BeaconBlocksByHead)],
289
290
  [
290
291
  protocols.DataColumnSidecarsByRoot(fork, this.config),
291
292
  this.getHandler(ReqRespMethod.DataColumnSidecarsByRoot),
@@ -0,0 +1,91 @@
1
+ import {PeerId} from "@libp2p/interface";
2
+ import {BeaconConfig} from "@lodestar/config";
3
+ import {ForkName, GENESIS_EPOCH, GENESIS_SLOT, isForkPostDeneb} from "@lodestar/params";
4
+ import {RespStatus, ResponseError, ResponseOutgoing} from "@lodestar/reqresp";
5
+ import {computeEpochAtSlot, computeStartSlotAtEpoch} from "@lodestar/state-transition";
6
+ import {fulu} from "@lodestar/types";
7
+ import {toRootHex} from "@lodestar/utils";
8
+ import {IBeaconChain} from "../../../chain/index.js";
9
+ import {getParentRootFromSignedBeaconBlockSerialized} from "../../../util/sszBytes.js";
10
+ import {prettyPrintPeerId} from "../../util.js";
11
+
12
+ // See https://github.com/ethereum/consensus-specs/pull/5181
13
+ export async function* onBeaconBlocksByHead(
14
+ request: fulu.BeaconBlocksByHeadRequest,
15
+ chain: IBeaconChain,
16
+ peerId: PeerId,
17
+ peerClient: string
18
+ ): AsyncIterable<ResponseOutgoing> {
19
+ const currentFork = chain.config.getForkName(chain.clock.currentSlot);
20
+ const {beaconRoot, count} = validateBeaconBlocksByHeadRequest(currentFork, chain.config, request);
21
+
22
+ const requestedRootHex = toRootHex(beaconRoot);
23
+ let blockRootHex = requestedRootHex;
24
+ const minimumRequestEpoch = Math.max(
25
+ GENESIS_EPOCH,
26
+ chain.clock.currentEpoch - chain.config.MIN_EPOCHS_FOR_BLOCK_REQUESTS
27
+ );
28
+ const minimumRequestSlot = computeStartSlotAtEpoch(minimumRequestEpoch);
29
+
30
+ for (let blocksSent = 0; blocksSent < count; blocksSent++) {
31
+ const blockBytes = await chain.getSerializedBlockByRoot(blockRootHex);
32
+ if (!blockBytes) {
33
+ if (blocksSent === 0) {
34
+ throw new ResponseError(RespStatus.RESOURCE_UNAVAILABLE, `Unknown block root ${requestedRootHex}`);
35
+ }
36
+ return;
37
+ }
38
+
39
+ if (blockBytes.slot < minimumRequestSlot) {
40
+ if (blocksSent === 0) {
41
+ chain.logger.verbose("Peer requested unavailable block for BeaconBlocksByHead", {
42
+ peer: prettyPrintPeerId(peerId),
43
+ client: peerClient,
44
+ requestedRoot: requestedRootHex,
45
+ slot: blockBytes.slot,
46
+ minimumRequestSlot,
47
+ });
48
+ }
49
+ return;
50
+ }
51
+
52
+ yield {
53
+ data: blockBytes.block,
54
+ boundary: chain.config.getForkBoundaryAtEpoch(computeEpochAtSlot(blockBytes.slot)),
55
+ };
56
+
57
+ if (blockBytes.slot === GENESIS_SLOT) {
58
+ return;
59
+ }
60
+
61
+ const parentRootHex = getParentRootFromSignedBeaconBlockSerialized(blockBytes.block);
62
+ if (parentRootHex === null) {
63
+ throw new ResponseError(
64
+ RespStatus.SERVER_ERROR,
65
+ `Invalid block bytes for root ${blockRootHex} slot ${blockBytes.slot}`
66
+ );
67
+ }
68
+ blockRootHex = parentRootHex;
69
+ }
70
+ }
71
+
72
+ export function validateBeaconBlocksByHeadRequest(
73
+ fork: ForkName,
74
+ config: BeaconConfig,
75
+ request: fulu.BeaconBlocksByHeadRequest
76
+ ): fulu.BeaconBlocksByHeadRequest {
77
+ const {beaconRoot} = request;
78
+ let {count} = request;
79
+
80
+ if (count < 1) {
81
+ throw new ResponseError(RespStatus.INVALID_REQUEST, "count < 1");
82
+ }
83
+
84
+ const maxRequestBlocks = isForkPostDeneb(fork) ? config.MAX_REQUEST_BLOCKS_DENEB : config.MAX_REQUEST_BLOCKS;
85
+
86
+ if (count > maxRequestBlocks) {
87
+ count = maxRequestBlocks;
88
+ }
89
+
90
+ return {beaconRoot, count};
91
+ }
@@ -24,6 +24,10 @@ export async function* onBeaconBlocksByRange(
24
24
  // in the case of initializing from a non-finalized state, we don't have the finalized block so this api does not work
25
25
  // chain.forkChoice.getFinalizeBlock().slot
26
26
  const finalizedSlot = chain.forkChoice.getFinalizedCheckpointSlot();
27
+ // Blocks are migrated to blockArchive at finalization (including the finalized block itself),
28
+ // so the archive loop serves up to AND INCLUDING finalizedSlot and the headChain loop
29
+ // starts above it to avoid duplicate yields. See archiveBlocks.ts for the migration logic.
30
+ const archiveMaxSlot = finalizedSlot;
27
31
 
28
32
  const forkName = chain.config.getForkName(startSlot);
29
33
  if (isForkPostFulu(forkName) && startSlot < chain.earliestAvailableSlot) {
@@ -35,9 +39,12 @@ export async function* onBeaconBlocksByRange(
35
39
  }
36
40
 
37
41
  // Finalized range of blocks
38
- if (startSlot <= finalizedSlot) {
42
+ if (startSlot <= archiveMaxSlot) {
39
43
  // Chain of blobs won't change
40
- for await (const {key, value} of finalized.binaryEntriesStream({gte: startSlot, lt: endSlot})) {
44
+ for await (const {key, value} of finalized.binaryEntriesStream({
45
+ gte: startSlot,
46
+ lt: Math.min(endSlot, archiveMaxSlot + 1),
47
+ })) {
41
48
  yield {
42
49
  data: value,
43
50
  boundary: chain.config.getForkBoundaryAtEpoch(computeEpochAtSlot(finalized.decodeKey(key))),
@@ -46,19 +53,20 @@ export async function* onBeaconBlocksByRange(
46
53
  }
47
54
 
48
55
  // Non-finalized range of blocks
49
- if (endSlot > finalizedSlot) {
56
+ if (endSlot > archiveMaxSlot) {
50
57
  const headBlock = chain.forkChoice.getHead();
51
58
  const headRoot = headBlock.blockRoot;
52
59
  // TODO DENEB: forkChoice should mantain an array of canonical blocks, and change only on reorg
53
60
  const headChain = chain.forkChoice.getAllAncestorBlocks(headRoot, headBlock.payloadStatus);
54
- // getAllAncestorBlocks response includes the head node, so it's the full chain.
61
+ // `getAllAncestorBlocks` includes both the head and the previous-finalized boundary.
55
62
 
56
63
  // Iterate head chain with ascending block numbers
57
64
  for (let i = headChain.length - 1; i >= 0; i--) {
58
65
  const block = headChain[i];
59
66
 
60
- // Must include only blocks in the range requested
61
- if (block.slot >= startSlot && block.slot < endSlot) {
67
+ // Must include only blocks in the range requested, and skip anything the archive loop
68
+ // above already served via the block.slot > archiveMaxSlot filter.
69
+ if (block.slot > archiveMaxSlot && block.slot >= startSlot && block.slot < endSlot) {
62
70
  // Note: Here the forkChoice head may change due to a re-org, so the headChain reflects the canonical chain
63
71
  // at the time of the start of the request. Spec is clear the chain of blobs must be consistent, but on
64
72
  // re-org there's no need to abort the request
@@ -20,31 +20,37 @@ export async function* onBlobSidecarsByRange(
20
20
  const finalized = db.blobSidecarsArchive;
21
21
  const unfinalized = db.blobSidecars;
22
22
  const finalizedSlot = chain.forkChoice.getFinalizedBlock().slot;
23
+ // Blobs are migrated to blobSidecarsArchive at finalization (including the finalized block
24
+ // itself), so the archive loop serves up to AND INCLUDING finalizedSlot and the headChain
25
+ // loop starts above it to avoid duplicate yields. See archiveBlocks.ts for the migration logic.
26
+ const archiveMaxSlot = finalizedSlot;
23
27
 
24
28
  // Finalized range of blobs
25
- if (startSlot <= finalizedSlot) {
29
+ if (startSlot <= archiveMaxSlot) {
26
30
  // Chain of blobs won't change
27
31
  for await (const {key, value: blobSideCarsBytesWrapped} of finalized.binaryEntriesStream({
28
32
  gte: startSlot,
29
- lt: endSlot,
33
+ lt: Math.min(endSlot, archiveMaxSlot + 1),
30
34
  })) {
31
35
  yield* iterateBlobBytesFromWrapper(chain, blobSideCarsBytesWrapped, finalized.decodeKey(key));
32
36
  }
33
37
  }
34
38
 
35
39
  // Non-finalized range of blobs
36
- if (endSlot > finalizedSlot) {
40
+ if (endSlot > archiveMaxSlot) {
37
41
  const headBlock = chain.forkChoice.getHead();
38
42
  const headRoot = headBlock.blockRoot;
39
43
  // TODO DENEB: forkChoice should mantain an array of canonical blocks, and change only on reorg
40
44
  const headChain = chain.forkChoice.getAllAncestorBlocks(headRoot, headBlock.payloadStatus);
45
+ // `getAllAncestorBlocks` includes both the head and the previous-finalized boundary.
41
46
 
42
47
  // Iterate head chain with ascending block numbers
43
48
  for (let i = headChain.length - 1; i >= 0; i--) {
44
49
  const block = headChain[i];
45
50
 
46
- // Must include only blobs in the range requested
47
- if (block.slot >= startSlot && block.slot < endSlot) {
51
+ // Must include only blobs in the range requested, and skip anything the archive loop
52
+ // above already served via the block.slot > archiveMaxSlot filter.
53
+ if (block.slot > archiveMaxSlot && block.slot >= startSlot && block.slot < endSlot) {
48
54
  // Note: Here the forkChoice head may change due to a re-org, so the headChain reflects the canonical chain
49
55
  // at the time of the start of the request. Spec is clear the chain of blobs must be consistent, but on
50
56
  // re-org there's no need to abort the request
@@ -1,6 +1,6 @@
1
1
  import {PeerId} from "@libp2p/interface";
2
2
  import {ChainConfig} from "@lodestar/config";
3
- import {GENESIS_SLOT} from "@lodestar/params";
3
+ import {ForkSeq, GENESIS_SLOT} from "@lodestar/params";
4
4
  import {RespStatus, ResponseError, ResponseOutgoing} from "@lodestar/reqresp";
5
5
  import {computeEpochAtSlot} from "@lodestar/state-transition";
6
6
  import {ColumnIndex, Epoch, fulu} from "@lodestar/types";
@@ -43,10 +43,19 @@ export async function* onDataColumnSidecarsByRange(
43
43
 
44
44
  const finalized = db.dataColumnSidecarArchive;
45
45
  const finalizedSlot = chain.forkChoice.getFinalizedBlock().slot;
46
+ // Columns of the last finalized block live in different DBs depending on fork:
47
+ // - Pre-gloas (fulu): migrated to dataColumnSidecarArchive in the same finalization run.
48
+ // - Post-gloas: stay in the hot db (db.dataColumnSidecar) until the next finalization run,
49
+ // because the migration filter requires payloadStatus === FULL for gloas blocks.
50
+ // archiveMaxSlot is the last slot whose columns are served by the archive loop below;
51
+ // anything above it is served by the headChain loop.
52
+ const isPostGloasFinalized = chain.config.getForkSeq(finalizedSlot) >= ForkSeq.gloas;
53
+ const archiveMaxSlot = isPostGloasFinalized ? finalizedSlot - 1 : finalizedSlot;
46
54
 
47
55
  // Finalized range of columns
48
- if (startSlot <= finalizedSlot) {
49
- for (let slot = startSlot; slot < endSlot; slot++) {
56
+ if (startSlot <= archiveMaxSlot) {
57
+ const archiveEnd = Math.min(endSlot, archiveMaxSlot + 1);
58
+ for (let slot = startSlot; slot < archiveEnd; slot++) {
50
59
  const dataColumnSidecars = await finalized.getManyBinary(slot, availableColumns);
51
60
 
52
61
  const unavailableColumnIndices: ColumnIndex[] = [];
@@ -81,9 +90,12 @@ export async function* onDataColumnSidecarsByRange(
81
90
  }
82
91
 
83
92
  // Non-finalized range of columns
84
- if (endSlot > finalizedSlot) {
93
+ if (endSlot > archiveMaxSlot) {
85
94
  const headBlock = chain.forkChoice.getHead();
86
95
  const headRoot = headBlock.blockRoot;
96
+ // getAllAncestorBlocks includes the last finalized block as its final element.
97
+ // Skip anything the archive loop above already served via the block.slot > archiveMaxSlot
98
+ // filter below (pre-gloas this skips finalizedSlot, post-gloas it keeps it).
87
99
  const headChain = chain.forkChoice.getAllAncestorBlocks(headRoot, headBlock.payloadStatus);
88
100
 
89
101
  // Iterate head chain with ascending block numbers
@@ -91,7 +103,7 @@ export async function* onDataColumnSidecarsByRange(
91
103
  const block = headChain[i];
92
104
 
93
105
  // Must include only columns in the range requested
94
- if (block.slot >= startSlot && block.slot < endSlot) {
106
+ if (block.slot > archiveMaxSlot && block.slot >= startSlot && block.slot < endSlot) {
95
107
  // Note: Here the forkChoice head may change due to a re-org, so the headChain reflects the canonical chain
96
108
  // at the time of the start of the request. Spec is clear the chain of columns must be consistent, but on
97
109
  // re-org there's no need to abort the request
@@ -21,12 +21,15 @@ export async function* onExecutionPayloadEnvelopesByRange(
21
21
 
22
22
  const finalized = db.executionPayloadEnvelopeArchive;
23
23
  const finalizedSlot = chain.forkChoice.getFinalizedCheckpointSlot();
24
+ // The current finalized block's envelope is still in the hot db; archive migration happens
25
+ // in the next finalization run (see migrateExecutionPayloadEnvelopesFromHotToColdDb).
26
+ const archiveMaxSlot = finalizedSlot - 1;
24
27
 
25
28
  // Finalized range of envelopes
26
- if (startSlot <= finalizedSlot) {
29
+ if (startSlot <= archiveMaxSlot) {
27
30
  for await (const {key, value: envelopeBytes} of finalized.binaryEntriesStream({
28
31
  gte: startSlot,
29
- lt: endSlot,
32
+ lt: Math.min(endSlot, archiveMaxSlot + 1),
30
33
  })) {
31
34
  const slot = finalized.decodeKey(key);
32
35
  yield {
@@ -37,7 +40,7 @@ export async function* onExecutionPayloadEnvelopesByRange(
37
40
  }
38
41
 
39
42
  // Non-finalized range of envelopes
40
- if (endSlot > finalizedSlot) {
43
+ if (endSlot > archiveMaxSlot) {
41
44
  const headBlock = chain.forkChoice.getHead();
42
45
  const headRoot = headBlock.blockRoot;
43
46
  const headChain = chain.forkChoice.getAllAncestorBlocks(headRoot, headBlock.payloadStatus);
@@ -46,7 +49,7 @@ export async function* onExecutionPayloadEnvelopesByRange(
46
49
  for (let i = headChain.length - 1; i >= 0; i--) {
47
50
  const block = headChain[i];
48
51
 
49
- if (block.slot >= startSlot && block.slot < endSlot) {
52
+ if (block.slot > archiveMaxSlot && block.slot >= startSlot && block.slot < endSlot) {
50
53
  // Skip EMPTY blocks
51
54
  if (block.payloadStatus !== PayloadStatus.FULL) {
52
55
  continue;
@@ -9,6 +9,7 @@ import {
9
9
  ExecutionPayloadEnvelopesByRootRequestType,
10
10
  } from "../../../util/types.js";
11
11
  import {GetReqRespHandlerFn, ReqRespMethod} from "../types.js";
12
+ import {onBeaconBlocksByHead} from "./beaconBlocksByHead.js";
12
13
  import {onBeaconBlocksByRange} from "./beaconBlocksByRange.js";
13
14
  import {onBeaconBlocksByRoot} from "./beaconBlocksByRoot.js";
14
15
  import {onBlobSidecarsByRange} from "./blobSidecarsByRange.js";
@@ -47,6 +48,10 @@ export function getReqRespHandlers({db, chain}: {db: IBeaconDb; chain: IBeaconCh
47
48
  const body = BeaconBlocksByRootRequestType(fork, chain.config).deserialize(req.data);
48
49
  return onBeaconBlocksByRoot(body, chain);
49
50
  },
51
+ [ReqRespMethod.BeaconBlocksByHead]: (req, peerId, peerClient) => {
52
+ const body = ssz.fulu.BeaconBlocksByHeadRequest.deserialize(req.data);
53
+ return onBeaconBlocksByHead(body, chain, peerId, peerClient);
54
+ },
50
55
  [ReqRespMethod.BlobSidecarsByRoot]: (req) => {
51
56
  const fork = chain.config.getForkName(chain.clock.currentSlot);
52
57
  const body = BlobSidecarsByRootRequestType(fork, chain.config).deserialize(req.data);
@@ -33,7 +33,7 @@ export enum RespStatus {
33
33
  */
34
34
  SERVER_ERROR = 2,
35
35
  /**
36
- * The responder does not have requested resource. The response payload adheres to the ErrorMessage schema (described below). Note: This response code is only valid as a response to BlocksByRange
36
+ * The responder does not have requested resource. The response payload adheres to the ErrorMessage schema.
37
37
  */
38
38
  RESOURCE_UNAVAILABLE = 3,
39
39
  /**
@@ -70,6 +70,12 @@ export const BeaconBlocksByRootV2 = toProtocol({
70
70
  contextBytesType: ContextBytesType.ForkDigest,
71
71
  });
72
72
 
73
+ export const BeaconBlocksByHead = toProtocol({
74
+ method: ReqRespMethod.BeaconBlocksByHead,
75
+ version: Version.V1,
76
+ contextBytesType: ContextBytesType.ForkDigest,
77
+ });
78
+
73
79
  export const BlobSidecarsByRange = toProtocol({
74
80
  method: ReqRespMethod.BlobSidecarsByRange,
75
81
  version: Version.V1,
@@ -40,6 +40,10 @@ export const rateLimitQuotas: (fork: ForkName, config: BeaconConfig) => Record<R
40
40
  },
41
41
  getRequestCount: getRequestCountFn(fork, config, ReqRespMethod.BeaconBlocksByRoot, (req) => req.length),
42
42
  },
43
+ [ReqRespMethod.BeaconBlocksByHead]: {
44
+ byPeer: {quota: config.MAX_REQUEST_BLOCKS_DENEB, quotaTimeMs: 10_000},
45
+ getRequestCount: getRequestCountFn(fork, config, ReqRespMethod.BeaconBlocksByHead, (req) => req.count),
46
+ },
43
47
  [ReqRespMethod.BlobSidecarsByRange]: {
44
48
  // Rationale: MAX_REQUEST_BLOCKS_DENEB * MAX_BLOBS_PER_BLOCK
45
49
  byPeer: {
@@ -46,6 +46,7 @@ export function onOutgoingReqRespError(e: RequestError, method: ReqRespMethod):
46
46
  return PeerAction.LowToleranceError;
47
47
  case ReqRespMethod.BeaconBlocksByRange:
48
48
  case ReqRespMethod.BeaconBlocksByRoot:
49
+ case ReqRespMethod.BeaconBlocksByHead:
49
50
  case ReqRespMethod.ExecutionPayloadEnvelopesByRoot:
50
51
  case ReqRespMethod.ExecutionPayloadEnvelopesByRange:
51
52
  return PeerAction.MidToleranceError;
@@ -42,6 +42,7 @@ export enum ReqRespMethod {
42
42
  Metadata = "metadata",
43
43
  BeaconBlocksByRange = "beacon_blocks_by_range",
44
44
  BeaconBlocksByRoot = "beacon_blocks_by_root",
45
+ BeaconBlocksByHead = "beacon_blocks_by_head",
45
46
  BlobSidecarsByRange = "blob_sidecars_by_range",
46
47
  BlobSidecarsByRoot = "blob_sidecars_by_root",
47
48
  DataColumnSidecarsByRange = "data_column_sidecars_by_range",
@@ -62,6 +63,7 @@ export type RequestBodyByMethod = {
62
63
  [ReqRespMethod.Metadata]: null;
63
64
  [ReqRespMethod.BeaconBlocksByRange]: phase0.BeaconBlocksByRangeRequest;
64
65
  [ReqRespMethod.BeaconBlocksByRoot]: BeaconBlocksByRootRequest;
66
+ [ReqRespMethod.BeaconBlocksByHead]: fulu.BeaconBlocksByHeadRequest;
65
67
  [ReqRespMethod.BlobSidecarsByRange]: deneb.BlobSidecarsByRangeRequest;
66
68
  [ReqRespMethod.BlobSidecarsByRoot]: BlobSidecarsByRootRequest;
67
69
  [ReqRespMethod.DataColumnSidecarsByRange]: fulu.DataColumnSidecarsByRangeRequest;
@@ -82,6 +84,7 @@ type ResponseBodyByMethod = {
82
84
  // Do not matter
83
85
  [ReqRespMethod.BeaconBlocksByRange]: SignedBeaconBlock;
84
86
  [ReqRespMethod.BeaconBlocksByRoot]: SignedBeaconBlock;
87
+ [ReqRespMethod.BeaconBlocksByHead]: SignedBeaconBlock;
85
88
  [ReqRespMethod.BlobSidecarsByRange]: deneb.BlobSidecar;
86
89
  [ReqRespMethod.BlobSidecarsByRoot]: deneb.BlobSidecar;
87
90
  [ReqRespMethod.DataColumnSidecarsByRange]: DataColumnSidecar;
@@ -111,6 +114,7 @@ export const requestSszTypeByMethod: (
111
114
 
112
115
  [ReqRespMethod.BeaconBlocksByRange]: ssz.phase0.BeaconBlocksByRangeRequest,
113
116
  [ReqRespMethod.BeaconBlocksByRoot]: BeaconBlocksByRootRequestType(fork, config),
117
+ [ReqRespMethod.BeaconBlocksByHead]: ssz.fulu.BeaconBlocksByHeadRequest,
114
118
  [ReqRespMethod.BlobSidecarsByRange]: ssz.deneb.BlobSidecarsByRangeRequest,
115
119
  [ReqRespMethod.BlobSidecarsByRoot]: BlobSidecarsByRootRequestType(fork, config),
116
120
  [ReqRespMethod.DataColumnSidecarsByRange]: ssz.fulu.DataColumnSidecarsByRangeRequest,
@@ -142,6 +146,7 @@ export const responseSszTypeByMethod: {[K in ReqRespMethod]: ResponseTypeGetter<
142
146
  version === Version.V1 ? ssz.phase0.Metadata : version === Version.V2 ? ssz.altair.Metadata : ssz.fulu.Metadata,
143
147
  [ReqRespMethod.BeaconBlocksByRange]: blocksResponseType,
144
148
  [ReqRespMethod.BeaconBlocksByRoot]: blocksResponseType,
149
+ [ReqRespMethod.BeaconBlocksByHead]: (fork) => ssz[fork].SignedBeaconBlock,
145
150
  [ReqRespMethod.BlobSidecarsByRange]: () => ssz.deneb.BlobSidecar,
146
151
  [ReqRespMethod.BlobSidecarsByRoot]: () => ssz.deneb.BlobSidecar,
147
152
  [ReqRespMethod.LightClientBootstrap]: (fork) => sszTypesFor(onlyPostAltairFork(fork)).LightClientBootstrap,
@@ -221,7 +221,7 @@ export class BeaconNode {
221
221
 
222
222
  let executionEngineOpts = opts.executionEngine;
223
223
  if (opts.executionEngine.mode === "mock") {
224
- const eth1BlockHash =
224
+ const latestEth1BlockHash =
225
225
  isStatePostBellatrix(anchorState) && anchorState.isExecutionStateType
226
226
  ? isStatePostGloas(anchorState)
227
227
  ? toRootHex(anchorState.latestBlockHash)
@@ -230,7 +230,7 @@ export class BeaconNode {
230
230
  executionEngineOpts = {
231
231
  ...opts.executionEngine,
232
232
  genesisBlockHash: ZERO_HASH_HEX,
233
- eth1BlockHash,
233
+ eth1BlockHash: opts.executionEngine.eth1BlockHash ?? latestEth1BlockHash,
234
234
  genesisTime: anchorState.genesisTime,
235
235
  config,
236
236
  };
@@ -5,10 +5,14 @@ export const PARALLEL_HEAD_CHAINS = 2;
5
5
  export const MIN_FINALIZED_CHAIN_VALIDATED_EPOCHS = 10;
6
6
 
7
7
  /** The number of times to retry a batch before it is considered failed. */
8
- // export const MAX_BATCH_DOWNLOAD_ATTEMPTS = 5;
9
- // this constant is increased a lot for peerDAS because we may have many failed download due to rate limit not implemented yet
10
- // TODO: change it back to 5 when this issue is implemented https://github.com/ChainSafe/lodestar/issues/8033
11
- export const MAX_BATCH_DOWNLOAD_ATTEMPTS = 20;
8
+ export const MAX_BATCH_DOWNLOAD_ATTEMPTS = 5;
9
+
10
+ /**
11
+ * Backoff before assigning more range-sync batches to a peer that rate-limited us.
12
+ *
13
+ * Note: this is used when rate limited due to MAX_CONCURRENT_REQUESTS
14
+ */
15
+ export const RATE_LIMITED_PEER_BACKOFF_MS = 5_000;
12
16
 
13
17
  /**
14
18
  * Consider batch faulty after downloading and processing this number of times