@lodestar/beacon-node 1.43.0-dev.9c8becae00 → 1.43.0-dev.9f5db5b9c7

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 (331) 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 +24 -20
  35. package/lib/chain/blocks/importBlock.js.map +1 -1
  36. package/lib/chain/blocks/importExecutionPayload.d.ts +28 -14
  37. package/lib/chain/blocks/importExecutionPayload.d.ts.map +1 -1
  38. package/lib/chain/blocks/importExecutionPayload.js +88 -90
  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 +59 -26
  43. package/lib/chain/blocks/index.js.map +1 -1
  44. package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.d.ts +4 -0
  45. package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.d.ts.map +1 -1
  46. package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.js +9 -2
  47. package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.js.map +1 -1
  48. package/lib/chain/blocks/payloadEnvelopeInput/types.d.ts +1 -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 +23 -2
  55. package/lib/chain/blocks/utils/chainSegment.d.ts.map +1 -1
  56. package/lib/chain/blocks/utils/chainSegment.js +89 -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 +79 -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 +21 -6
  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/interface.d.ts +7 -5
  113. package/lib/chain/interface.d.ts.map +1 -1
  114. package/lib/chain/interface.js.map +1 -1
  115. package/lib/chain/opPools/payloadAttestationPool.d.ts +3 -2
  116. package/lib/chain/opPools/payloadAttestationPool.d.ts.map +1 -1
  117. package/lib/chain/opPools/payloadAttestationPool.js +26 -4
  118. package/lib/chain/opPools/payloadAttestationPool.js.map +1 -1
  119. package/lib/chain/prepareNextSlot.d.ts.map +1 -1
  120. package/lib/chain/prepareNextSlot.js +31 -13
  121. package/lib/chain/prepareNextSlot.js.map +1 -1
  122. package/lib/chain/produceBlock/produceBlockBody.d.ts +11 -1
  123. package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
  124. package/lib/chain/produceBlock/produceBlockBody.js +52 -14
  125. package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
  126. package/lib/chain/regen/interface.d.ts +1 -0
  127. package/lib/chain/regen/interface.d.ts.map +1 -1
  128. package/lib/chain/regen/interface.js +1 -0
  129. package/lib/chain/regen/interface.js.map +1 -1
  130. package/lib/chain/regen/queued.d.ts.map +1 -1
  131. package/lib/chain/regen/queued.js +1 -4
  132. package/lib/chain/regen/queued.js.map +1 -1
  133. package/lib/chain/regen/regen.d.ts.map +1 -1
  134. package/lib/chain/regen/regen.js +1 -4
  135. package/lib/chain/regen/regen.js.map +1 -1
  136. package/lib/chain/seenCache/index.d.ts +1 -0
  137. package/lib/chain/seenCache/index.d.ts.map +1 -1
  138. package/lib/chain/seenCache/index.js +1 -0
  139. package/lib/chain/seenCache/index.js.map +1 -1
  140. package/lib/chain/seenCache/seenPayloadEnvelopeInput.d.ts +19 -6
  141. package/lib/chain/seenCache/seenPayloadEnvelopeInput.d.ts.map +1 -1
  142. package/lib/chain/seenCache/seenPayloadEnvelopeInput.js +40 -22
  143. package/lib/chain/seenCache/seenPayloadEnvelopeInput.js.map +1 -1
  144. package/lib/chain/seenCache/seenProposerPreferences.d.ts +16 -0
  145. package/lib/chain/seenCache/seenProposerPreferences.d.ts.map +1 -0
  146. package/lib/chain/seenCache/seenProposerPreferences.js +26 -0
  147. package/lib/chain/seenCache/seenProposerPreferences.js.map +1 -0
  148. package/lib/chain/stateCache/persistentCheckpointsCache.d.ts.map +1 -1
  149. package/lib/chain/stateCache/persistentCheckpointsCache.js +4 -1
  150. package/lib/chain/stateCache/persistentCheckpointsCache.js.map +1 -1
  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 +13 -2
  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 +1 -0
  194. package/lib/network/interface.d.ts.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 +6 -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 +27 -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/handlers/beaconBlocksByRange.d.ts.map +1 -1
  209. package/lib/network/reqresp/handlers/beaconBlocksByRange.js +14 -6
  210. package/lib/network/reqresp/handlers/beaconBlocksByRange.js.map +1 -1
  211. package/lib/network/reqresp/handlers/blobSidecarsByRange.d.ts.map +1 -1
  212. package/lib/network/reqresp/handlers/blobSidecarsByRange.js +11 -5
  213. package/lib/network/reqresp/handlers/blobSidecarsByRange.js.map +1 -1
  214. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.d.ts.map +1 -1
  215. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js +17 -5
  216. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js.map +1 -1
  217. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.d.ts.map +1 -1
  218. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.js +7 -4
  219. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.js.map +1 -1
  220. package/lib/node/nodejs.js +2 -2
  221. package/lib/node/nodejs.js.map +1 -1
  222. package/lib/sync/range/batch.d.ts +23 -2
  223. package/lib/sync/range/batch.d.ts.map +1 -1
  224. package/lib/sync/range/batch.js +132 -44
  225. package/lib/sync/range/batch.js.map +1 -1
  226. package/lib/sync/range/chain.d.ts +6 -2
  227. package/lib/sync/range/chain.d.ts.map +1 -1
  228. package/lib/sync/range/chain.js +26 -7
  229. package/lib/sync/range/chain.js.map +1 -1
  230. package/lib/sync/range/range.d.ts.map +1 -1
  231. package/lib/sync/range/range.js +17 -6
  232. package/lib/sync/range/range.js.map +1 -1
  233. package/lib/sync/types.d.ts +34 -0
  234. package/lib/sync/types.d.ts.map +1 -1
  235. package/lib/sync/types.js +34 -0
  236. package/lib/sync/types.js.map +1 -1
  237. package/lib/sync/unknownBlock.d.ts +22 -1
  238. package/lib/sync/unknownBlock.d.ts.map +1 -1
  239. package/lib/sync/unknownBlock.js +602 -53
  240. package/lib/sync/unknownBlock.js.map +1 -1
  241. package/lib/sync/utils/downloadByRange.d.ts +46 -10
  242. package/lib/sync/utils/downloadByRange.d.ts.map +1 -1
  243. package/lib/sync/utils/downloadByRange.js +162 -24
  244. package/lib/sync/utils/downloadByRange.js.map +1 -1
  245. package/lib/sync/utils/downloadByRoot.d.ts.map +1 -1
  246. package/lib/sync/utils/downloadByRoot.js +16 -2
  247. package/lib/sync/utils/downloadByRoot.js.map +1 -1
  248. package/lib/sync/utils/pendingBlocksTree.d.ts +0 -1
  249. package/lib/sync/utils/pendingBlocksTree.d.ts.map +1 -1
  250. package/lib/sync/utils/pendingBlocksTree.js +0 -9
  251. package/lib/sync/utils/pendingBlocksTree.js.map +1 -1
  252. package/lib/util/sszBytes.d.ts.map +1 -1
  253. package/lib/util/sszBytes.js +20 -5
  254. package/lib/util/sszBytes.js.map +1 -1
  255. package/package.json +16 -15
  256. package/src/api/impl/beacon/blocks/index.ts +22 -9
  257. package/src/api/impl/beacon/pool/index.ts +83 -1
  258. package/src/api/impl/beacon/state/utils.ts +2 -2
  259. package/src/api/impl/debug/index.ts +0 -1
  260. package/src/api/impl/lodestar/index.ts +1 -1
  261. package/src/api/impl/validator/index.ts +82 -5
  262. package/src/chain/archiveStore/archiveStore.ts +5 -5
  263. package/src/chain/archiveStore/interface.ts +4 -4
  264. package/src/chain/archiveStore/strategies/frequencyStateArchiveStrategy.ts +4 -4
  265. package/src/chain/archiveStore/utils/archiveBlocks.ts +153 -94
  266. package/src/chain/blocks/blockInput/blockInput.ts +4 -1
  267. package/src/chain/blocks/importBlock.ts +24 -38
  268. package/src/chain/blocks/importExecutionPayload.ts +109 -105
  269. package/src/chain/blocks/index.ts +73 -23
  270. package/src/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.ts +10 -2
  271. package/src/chain/blocks/payloadEnvelopeInput/types.ts +1 -0
  272. package/src/chain/blocks/payloadEnvelopeProcessor.ts +2 -2
  273. package/src/chain/blocks/types.ts +15 -25
  274. package/src/chain/blocks/utils/chainSegment.ts +114 -17
  275. package/src/chain/blocks/verifyBlock.ts +70 -9
  276. package/src/chain/blocks/verifyBlocksExecutionPayloads.ts +6 -4
  277. package/src/chain/blocks/verifyBlocksSanityChecks.ts +26 -7
  278. package/src/chain/blocks/verifyExecutionPayloadEnvelope.ts +134 -0
  279. package/src/chain/blocks/verifyPayloadsDataAvailability.ts +7 -4
  280. package/src/chain/blocks/writePayloadEnvelopeInputToDb.ts +9 -18
  281. package/src/chain/chain.ts +38 -19
  282. package/src/chain/emitter.ts +3 -14
  283. package/src/chain/errors/blockError.ts +4 -1
  284. package/src/chain/errors/executionPayloadBid.ts +6 -0
  285. package/src/chain/errors/executionPayloadEnvelope.ts +6 -0
  286. package/src/chain/errors/index.ts +1 -0
  287. package/src/chain/errors/proposerPreferences.ts +47 -0
  288. package/src/chain/forkChoice/index.ts +2 -22
  289. package/src/chain/interface.ts +11 -3
  290. package/src/chain/opPools/payloadAttestationPool.ts +29 -8
  291. package/src/chain/prepareNextSlot.ts +36 -14
  292. package/src/chain/produceBlock/produceBlockBody.ts +63 -13
  293. package/src/chain/regen/interface.ts +1 -0
  294. package/src/chain/regen/queued.ts +2 -7
  295. package/src/chain/regen/regen.ts +2 -7
  296. package/src/chain/seenCache/index.ts +1 -0
  297. package/src/chain/seenCache/seenPayloadEnvelopeInput.ts +47 -25
  298. package/src/chain/seenCache/seenProposerPreferences.ts +32 -0
  299. package/src/chain/stateCache/persistentCheckpointsCache.ts +4 -1
  300. package/src/chain/validation/block.ts +1 -0
  301. package/src/chain/validation/executionPayloadBid.ts +25 -8
  302. package/src/chain/validation/executionPayloadEnvelope.ts +20 -10
  303. package/src/chain/validation/proposerPreferences.ts +110 -0
  304. package/src/db/repositories/executionPayloadEnvelopeArchive.ts +1 -1
  305. package/src/execution/engine/http.ts +21 -14
  306. package/src/execution/engine/interface.ts +1 -0
  307. package/src/execution/engine/mock.ts +8 -1
  308. package/src/execution/engine/types.ts +41 -0
  309. package/src/metrics/metrics/lodestar.ts +4 -0
  310. package/src/network/gossip/interface.ts +6 -0
  311. package/src/network/gossip/scoringParameters.ts +14 -1
  312. package/src/network/gossip/topic.ts +6 -0
  313. package/src/network/interface.ts +1 -0
  314. package/src/network/network.ts +12 -1
  315. package/src/network/processor/gossipHandlers.ts +38 -20
  316. package/src/network/processor/gossipQueues/index.ts +5 -0
  317. package/src/network/processor/index.ts +6 -5
  318. package/src/network/reqresp/handlers/beaconBlocksByRange.ts +14 -6
  319. package/src/network/reqresp/handlers/blobSidecarsByRange.ts +11 -5
  320. package/src/network/reqresp/handlers/dataColumnSidecarsByRange.ts +17 -5
  321. package/src/network/reqresp/handlers/executionPayloadEnvelopesByRange.ts +7 -4
  322. package/src/node/nodejs.ts +2 -2
  323. package/src/sync/range/batch.ts +188 -49
  324. package/src/sync/range/chain.ts +37 -9
  325. package/src/sync/range/range.ts +18 -6
  326. package/src/sync/types.ts +72 -0
  327. package/src/sync/unknownBlock.ts +760 -57
  328. package/src/sync/utils/downloadByRange.ts +272 -39
  329. package/src/sync/utils/downloadByRoot.ts +24 -2
  330. package/src/sync/utils/pendingBlocksTree.ts +0 -15
  331. package/src/util/sszBytes.ts +25 -5
@@ -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;
@@ -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
  };
@@ -1,10 +1,11 @@
1
1
  import {ChainForkConfig} from "@lodestar/config";
2
- import {ForkName, isForkPostDeneb, isForkPostFulu} from "@lodestar/params";
2
+ import {ForkName, isForkPostDeneb, isForkPostFulu, isForkPostGloas} from "@lodestar/params";
3
3
  import {Epoch, RootHex, Slot, phase0} from "@lodestar/types";
4
- import {LodestarError} from "@lodestar/utils";
4
+ import {LodestarError, prettyPrintIndices} from "@lodestar/utils";
5
5
  import {isBlockInputColumns} from "../../chain/blocks/blockInput/blockInput.js";
6
6
  import {IBlockInput} from "../../chain/blocks/blockInput/types.js";
7
7
  import {isDaOutOfRange} from "../../chain/blocks/blockInput/utils.js";
8
+ import {PayloadEnvelopeInput} from "../../chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.js";
8
9
  import {BlockError, BlockErrorCode} from "../../chain/errors/index.js";
9
10
  import {PeerSyncMeta} from "../../network/peers/peersData.js";
10
11
  import {IClock} from "../../util/clock.js";
@@ -46,25 +47,68 @@ export type Attempt = {
46
47
  export type AwaitingDownloadState = {
47
48
  status: BatchStatus.AwaitingDownload;
48
49
  blocks: IBlockInput[];
50
+ payloadEnvelopes: Map<Slot, PayloadEnvelopeInput> | null;
49
51
  };
50
52
 
51
53
  export type DownloadSuccessState = {
52
54
  status: BatchStatus.AwaitingProcessing;
53
55
  blocks: IBlockInput[];
56
+ payloadEnvelopes: Map<Slot, PayloadEnvelopeInput> | null;
54
57
  };
55
58
 
56
59
  export type BatchState =
57
60
  | AwaitingDownloadState
58
- | {status: BatchStatus.Downloading; peer: PeerIdStr; blocks: IBlockInput[]}
61
+ | {
62
+ status: BatchStatus.Downloading;
63
+ peer: PeerIdStr;
64
+ blocks: IBlockInput[];
65
+ payloadEnvelopes: Map<Slot, PayloadEnvelopeInput> | null;
66
+ }
59
67
  | DownloadSuccessState
60
- | {status: BatchStatus.Processing; blocks: IBlockInput[]; attempt: Attempt}
61
- | {status: BatchStatus.AwaitingValidation; blocks: IBlockInput[]; attempt: Attempt};
68
+ | {
69
+ status: BatchStatus.Processing;
70
+ blocks: IBlockInput[];
71
+ payloadEnvelopes: Map<Slot, PayloadEnvelopeInput> | null;
72
+ attempt: Attempt;
73
+ }
74
+ | {
75
+ status: BatchStatus.AwaitingValidation;
76
+ blocks: IBlockInput[];
77
+ payloadEnvelopes: Map<Slot, PayloadEnvelopeInput> | null;
78
+ attempt: Attempt;
79
+ };
62
80
 
63
81
  export type BatchMetadata = {
82
+ // Batch-level slot window (always present)
64
83
  startEpoch: Epoch;
84
+ startSlot: Slot;
85
+ count: number;
65
86
  status: BatchStatus;
87
+
88
+ // Per-type outstanding request shapes; only present when that sub-request exists.
89
+ // Format: "startSlot=<n>,count=<n>" (plus ",cols=<indices>" for columns).
90
+ blocksReq?: string;
91
+ blobsReq?: string;
92
+ columnsReq?: string;
93
+ envelopesReq?: string;
94
+
95
+ // Retry counters
96
+ downloadAttempts: number;
97
+ processingAttempts: number;
98
+
99
+ // Cumulative peer attribution for failed attempts (only present when non-empty)
100
+ failedDownloadPeers?: string;
101
+ failedProcessingPeers?: string;
66
102
  };
67
103
 
104
+ function formatRangeReq(req: {startSlot: Slot; count: number}): string {
105
+ return `startSlot=${req.startSlot},count=${req.count}`;
106
+ }
107
+
108
+ function formatColumnsReq(req: {startSlot: Slot; count: number; columns: number[]}): string {
109
+ return `startSlot=${req.startSlot},count=${req.count},cols=${prettyPrintIndices(req.columns)}`;
110
+ }
111
+
68
112
  /**
69
113
  * Batches are downloaded at the first block of the epoch.
70
114
  *
@@ -85,7 +129,7 @@ export class Batch {
85
129
  /** Block, blob and column requests that are used to determine the best peer and are used in downloadByRange */
86
130
  requests: DownloadByRangeRequests;
87
131
  /** State of the batch. */
88
- state: BatchState = {status: BatchStatus.AwaitingDownload, blocks: []};
132
+ state: BatchState = {status: BatchStatus.AwaitingDownload, blocks: [], payloadEnvelopes: null};
89
133
  /** Peers that provided good data */
90
134
  goodPeers: PeerIdStr[] = [];
91
135
  /** The `Attempts` that have been made and failed to send us this batch. */
@@ -129,37 +173,36 @@ export class Batch {
129
173
  count: this.count,
130
174
  step: 1,
131
175
  };
132
- if (isForkPostFulu(this.forkName) && withinValidRequestWindow) {
133
- return {
134
- blocksRequest,
135
- columnsRequest: {
136
- startSlot: this.startSlot,
137
- count: this.count,
138
- columns: this.custodyConfig.sampledColumns,
139
- },
140
- };
176
+ const requests: DownloadByRangeRequests = {blocksRequest};
177
+
178
+ // Post-Gloas envelopes are required for block processing, independent of DA retention window.
179
+ if (isForkPostGloas(this.forkName)) {
180
+ requests.envelopesRequest = {startSlot: this.startSlot, count: this.count};
141
181
  }
142
- if (isForkPostDeneb(this.forkName) && withinValidRequestWindow) {
143
- return {
144
- blocksRequest,
145
- blobsRequest: {
146
- startSlot: this.startSlot,
147
- count: this.count,
148
- },
182
+
183
+ if (isForkPostFulu(this.forkName) && withinValidRequestWindow) {
184
+ requests.columnsRequest = {
185
+ startSlot: this.startSlot,
186
+ count: this.count,
187
+ columns: this.custodyConfig.sampledColumns,
149
188
  };
189
+ } else if (isForkPostDeneb(this.forkName) && withinValidRequestWindow) {
190
+ requests.blobsRequest = {startSlot: this.startSlot, count: this.count};
150
191
  }
151
- return {
152
- blocksRequest,
153
- };
192
+
193
+ return requests;
154
194
  }
155
195
 
156
196
  // subsequent request where part of the epoch has already been downloaded. Need to figure out what is the beginning
157
197
  // of the range where download needs to resume
158
198
  let blockStartSlot = this.startSlot;
159
199
  let dataStartSlot = this.startSlot;
200
+ let envelopeStartSlot = this.startSlot;
160
201
  const neededColumns = new Set<number>();
202
+ const envelopesBySlot = this.state.payloadEnvelopes ?? new Map<Slot, PayloadEnvelopeInput>();
161
203
 
162
204
  // ensure blocks are in slot-wise order
205
+ const isPostGloas = isForkPostGloas(this.forkName);
163
206
  for (const blockInput of blocks) {
164
207
  const blockSlot = blockInput.slot;
165
208
  // check if block/data is present (hasBlock/hasAllData). If present then check if startSlot is the same as
@@ -175,14 +218,36 @@ export class Batch {
175
218
  if (blockInput.hasBlock() && blockStartSlot === blockSlot) {
176
219
  blockStartSlot = blockSlot + 1;
177
220
  }
178
- if (!blockInput.hasAllData()) {
179
- if (isBlockInputColumns(blockInput)) {
180
- for (const index of blockInput.getMissingSampledColumnMeta().missing) {
221
+
222
+ // Range sync uses hasComputedAllData (all sampled columns physically present), not hasAllData
223
+ // which flips at the reconstruction threshold. Sync never triggers reconstruction, so accepting
224
+ // a half-downloaded block here makes writeBlockInputToDb later block on waitForComputedAllData.
225
+ if (isPostGloas) {
226
+ // Post-Gloas: column data lives on PayloadEnvelopeInput, not on BlockInputNoData.
227
+ const payloadInput = envelopesBySlot.get(blockSlot);
228
+ if (blockInput.hasBlock() && envelopeStartSlot === blockSlot && payloadInput?.hasPayloadEnvelope()) {
229
+ envelopeStartSlot = blockSlot + 1;
230
+ }
231
+ if (payloadInput && !payloadInput.hasComputedAllData()) {
232
+ for (const index of payloadInput.getMissingSampledColumnMeta().missing) {
181
233
  neededColumns.add(index);
182
234
  }
235
+ } else if (payloadInput?.hasComputedAllData() && dataStartSlot === blockSlot) {
236
+ // Only advance dataStartSlot when we know columns for this slot are complete. If
237
+ // payloadInput is missing entirely we cannot tell, so stop here so the next round
238
+ // re-requests columns (and envelopes) starting at this slot.
239
+ dataStartSlot = blockSlot + 1;
240
+ }
241
+ } else {
242
+ if (isBlockInputColumns(blockInput) ? !blockInput.hasComputedAllData() : !blockInput.hasAllData()) {
243
+ if (isBlockInputColumns(blockInput)) {
244
+ for (const index of blockInput.getMissingSampledColumnMeta().missing) {
245
+ neededColumns.add(index);
246
+ }
247
+ }
248
+ } else if (dataStartSlot === blockSlot) {
249
+ dataStartSlot = blockSlot + 1;
183
250
  }
184
- } else if (dataStartSlot === blockSlot) {
185
- dataStartSlot = blockSlot + 1;
186
251
  }
187
252
  }
188
253
 
@@ -202,11 +267,15 @@ export class Batch {
202
267
  // range of 40 - 63, startSlot will be inclusive but subtraction will exclusive so need to + 1
203
268
  const count = endSlot - dataStartSlot + 1;
204
269
  if (isForkPostFulu(this.forkName) && withinValidRequestWindow) {
205
- requests.columnsRequest = {
206
- count,
207
- startSlot: dataStartSlot,
208
- columns: Array.from(neededColumns),
209
- };
270
+ // Skip the column re-request when we have no specific column indices outstanding.
271
+ // Peer rejects an empty `columns` list
272
+ if (neededColumns.size > 0) {
273
+ requests.columnsRequest = {
274
+ count,
275
+ startSlot: dataStartSlot,
276
+ columns: Array.from(neededColumns),
277
+ };
278
+ }
210
279
  } else if (isForkPostDeneb(this.forkName) && withinValidRequestWindow) {
211
280
  requests.blobsRequest = {
212
281
  count,
@@ -216,6 +285,13 @@ export class Batch {
216
285
  // dataSlot will still have a value but do not create a request for preDeneb forks
217
286
  }
218
287
 
288
+ if (isForkPostGloas(this.forkName) && envelopeStartSlot <= endSlot) {
289
+ requests.envelopesRequest = {
290
+ startSlot: envelopeStartSlot,
291
+ count: endSlot - envelopeStartSlot + 1,
292
+ };
293
+ }
294
+
219
295
  return requests;
220
296
  }
221
297
 
@@ -256,13 +332,36 @@ export class Batch {
256
332
  }
257
333
 
258
334
  getMetadata(): BatchMetadata {
259
- return {startEpoch: this.startEpoch, status: this.state.status};
335
+ const {blocksRequest, blobsRequest, columnsRequest, envelopesRequest} = this.requests;
336
+ const failedProcessingPeerList = this.failedProcessingAttempts.flatMap((a) => a.peers);
337
+ return {
338
+ startEpoch: this.startEpoch,
339
+ startSlot: this.startSlot,
340
+ count: this.count,
341
+ status: this.state.status,
342
+ ...(blocksRequest && {blocksReq: formatRangeReq(blocksRequest)}),
343
+ ...(blobsRequest && {blobsReq: formatRangeReq(blobsRequest)}),
344
+ ...(columnsRequest && {columnsReq: formatColumnsReq(columnsRequest)}),
345
+ ...(envelopesRequest && {envelopesReq: formatRangeReq(envelopesRequest)}),
346
+ downloadAttempts: this.failedDownloadAttempts.length,
347
+ processingAttempts: this.failedProcessingAttempts.length,
348
+ ...(this.failedDownloadAttempts.length > 0 && {
349
+ failedDownloadPeers: this.failedDownloadAttempts.join(","),
350
+ }),
351
+ ...(failedProcessingPeerList.length > 0 && {
352
+ failedProcessingPeers: failedProcessingPeerList.join(","),
353
+ }),
354
+ };
260
355
  }
261
356
 
262
357
  getBlocks(): IBlockInput[] {
263
358
  return this.state.blocks;
264
359
  }
265
360
 
361
+ getPayloadEnvelopes(): Map<Slot, PayloadEnvelopeInput> | null {
362
+ return this.state.payloadEnvelopes;
363
+ }
364
+
266
365
  /**
267
366
  * AwaitingDownload -> Downloading
268
367
  */
@@ -271,13 +370,22 @@ export class Batch {
271
370
  throw new BatchError(this.wrongStatusErrorType(BatchStatus.AwaitingDownload));
272
371
  }
273
372
 
274
- this.state = {status: BatchStatus.Downloading, peer, blocks: this.state.blocks};
373
+ this.state = {
374
+ status: BatchStatus.Downloading,
375
+ peer,
376
+ blocks: this.state.blocks,
377
+ payloadEnvelopes: this.state.payloadEnvelopes,
378
+ };
275
379
  }
276
380
 
277
381
  /**
278
382
  * Downloading -> AwaitingProcessing
279
383
  */
280
- downloadingSuccess(peer: PeerIdStr, blocks: IBlockInput[]): DownloadSuccessState {
384
+ downloadingSuccess(
385
+ peer: PeerIdStr,
386
+ blocks: IBlockInput[],
387
+ payloadEnvelopes: Map<Slot, PayloadEnvelopeInput> | null
388
+ ): DownloadSuccessState {
281
389
  if (this.state.status !== BatchStatus.Downloading) {
282
390
  throw new BatchError(this.wrongStatusErrorType(BatchStatus.Downloading));
283
391
  }
@@ -291,7 +399,11 @@ export class Batch {
291
399
  const slots = new Set<number>();
292
400
  for (const block of blocks) {
293
401
  slots.add(block.slot);
294
- if (!block.hasBlockAndAllData()) {
402
+ const dataComplete = isBlockInputColumns(block)
403
+ ? // by_range needs to download all columns
404
+ block.hasBlock() && block.hasComputedAllData()
405
+ : block.hasBlockAndAllData();
406
+ if (!dataComplete) {
295
407
  allComplete = false;
296
408
  }
297
409
  }
@@ -305,11 +417,24 @@ export class Batch {
305
417
  status: this.state.status,
306
418
  });
307
419
  }
420
+ const newPayloadEnvelopes = payloadEnvelopes ?? this.state.payloadEnvelopes;
421
+
422
+ if (allComplete && isForkPostGloas(this.forkName)) {
423
+ for (const block of blocks) {
424
+ const payloadInput = newPayloadEnvelopes?.get(block.slot);
425
+ // by_range needs to download all columns
426
+ if (!payloadInput?.hasPayloadEnvelope() || !payloadInput.hasComputedAllData()) {
427
+ allComplete = false;
428
+ break;
429
+ }
430
+ }
431
+ }
432
+
308
433
  if (allComplete) {
309
- this.state = {status: BatchStatus.AwaitingProcessing, blocks};
434
+ this.state = {status: BatchStatus.AwaitingProcessing, blocks, payloadEnvelopes: newPayloadEnvelopes};
310
435
  } else {
436
+ this.state = {status: BatchStatus.AwaitingDownload, blocks, payloadEnvelopes: newPayloadEnvelopes};
311
437
  this.requests = this.getRequests(blocks);
312
- this.state = {status: BatchStatus.AwaitingDownload, blocks};
313
438
  }
314
439
 
315
440
  return this.state as DownloadSuccessState;
@@ -328,25 +453,34 @@ export class Batch {
328
453
  throw new BatchError(this.errorType({code: BatchErrorCode.MAX_DOWNLOAD_ATTEMPTS}));
329
454
  }
330
455
 
331
- this.state = {status: BatchStatus.AwaitingDownload, blocks: this.state.blocks};
456
+ this.state = {
457
+ status: BatchStatus.AwaitingDownload,
458
+ blocks: this.state.blocks,
459
+ payloadEnvelopes: this.state.payloadEnvelopes,
460
+ };
332
461
  }
333
462
 
334
463
  /**
335
464
  * AwaitingProcessing -> Processing
336
465
  */
337
- startProcessing(): IBlockInput[] {
466
+ startProcessing(): {
467
+ blocks: IBlockInput[];
468
+ payloadEnvelopes: Map<Slot, PayloadEnvelopeInput> | null;
469
+ peers: PeerIdStr[];
470
+ } {
338
471
  if (this.state.status !== BatchStatus.AwaitingProcessing) {
339
472
  throw new BatchError(this.wrongStatusErrorType(BatchStatus.AwaitingProcessing));
340
473
  }
341
474
 
342
475
  const blocks = this.state.blocks;
476
+ const payloadEnvelopes = this.state.payloadEnvelopes;
343
477
  const hash = hashBlocks(blocks, this.config); // tracks blocks to report peer on processing error
344
478
  // Reset goodPeers in case another download attempt needs to be made. When Attempt is successful or not the peers
345
479
  // that the data came from will be handled by the Attempt that goes for processing
346
480
  const peers = this.goodPeers;
347
481
  this.goodPeers = [];
348
- this.state = {status: BatchStatus.Processing, blocks, attempt: {peers, hash}};
349
- return blocks;
482
+ this.state = {status: BatchStatus.Processing, blocks, payloadEnvelopes, attempt: {peers, hash}};
483
+ return {blocks, payloadEnvelopes, peers};
350
484
  }
351
485
 
352
486
  /**
@@ -357,7 +491,12 @@ export class Batch {
357
491
  throw new BatchError(this.wrongStatusErrorType(BatchStatus.Processing));
358
492
  }
359
493
 
360
- this.state = {status: BatchStatus.AwaitingValidation, blocks: this.state.blocks, attempt: this.state.attempt};
494
+ this.state = {
495
+ status: BatchStatus.AwaitingValidation,
496
+ blocks: this.state.blocks,
497
+ payloadEnvelopes: this.state.payloadEnvelopes,
498
+ attempt: this.state.attempt,
499
+ };
361
500
  }
362
501
 
363
502
  /**
@@ -408,7 +547,7 @@ export class Batch {
408
547
 
409
548
  // remove any downloaded blocks and re-attempt
410
549
  // TODO(fulu): need to remove the bad blocks from the SeenBlockInputCache
411
- this.state = {status: BatchStatus.AwaitingDownload, blocks: []};
550
+ this.state = {status: BatchStatus.AwaitingDownload, blocks: [], payloadEnvelopes: null};
412
551
  }
413
552
 
414
553
  private onProcessingError(attempt: Attempt): void {
@@ -419,12 +558,12 @@ export class Batch {
419
558
 
420
559
  // remove any downloaded blocks and re-attempt
421
560
  // TODO(fulu): need to remove the bad blocks from the SeenBlockInputCache
422
- this.state = {status: BatchStatus.AwaitingDownload, blocks: []};
561
+ this.state = {status: BatchStatus.AwaitingDownload, blocks: [], payloadEnvelopes: null};
423
562
  }
424
563
 
425
564
  /** Helper to construct typed BatchError. Stack traces are correct as the error is thrown above */
426
565
  private errorType(type: BatchErrorType): BatchErrorType & BatchErrorMetadata {
427
- return {...type, ...this.getMetadata()};
566
+ return {...type, startEpoch: this.startEpoch, status: this.state.status};
428
567
  }
429
568
 
430
569
  private wrongStatusErrorType(expectedStatus: BatchStatus): BatchErrorType & BatchErrorMetadata {