@lodestar/beacon-node 1.51.0-dev.d422f387ac → 1.51.0-dev.d5620be4a1

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 (430) hide show
  1. package/lib/api/impl/beacon/blocks/index.d.ts.map +1 -1
  2. package/lib/api/impl/beacon/blocks/index.js +19 -61
  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 +17 -0
  6. package/lib/api/impl/beacon/pool/index.js.map +1 -1
  7. package/lib/api/impl/validator/index.d.ts +6 -0
  8. package/lib/api/impl/validator/index.d.ts.map +1 -1
  9. package/lib/api/impl/validator/index.js +38 -25
  10. package/lib/api/impl/validator/index.js.map +1 -1
  11. package/lib/chain/GetBlobsTracker.d.ts +2 -2
  12. package/lib/chain/GetBlobsTracker.d.ts.map +1 -1
  13. package/lib/chain/GetBlobsTracker.js +7 -31
  14. package/lib/chain/GetBlobsTracker.js.map +1 -1
  15. package/lib/chain/blocks/blockInput/blockInput.d.ts +11 -56
  16. package/lib/chain/blocks/blockInput/blockInput.d.ts.map +1 -1
  17. package/lib/chain/blocks/blockInput/blockInput.js +5 -241
  18. package/lib/chain/blocks/blockInput/blockInput.js.map +1 -1
  19. package/lib/chain/blocks/blockInput/errors.d.ts +2 -4
  20. package/lib/chain/blocks/blockInput/errors.d.ts.map +1 -1
  21. package/lib/chain/blocks/blockInput/errors.js.map +1 -1
  22. package/lib/chain/blocks/blockInput/types.d.ts +2 -18
  23. package/lib/chain/blocks/blockInput/types.d.ts.map +1 -1
  24. package/lib/chain/blocks/blockInput/types.js +0 -1
  25. package/lib/chain/blocks/blockInput/types.js.map +1 -1
  26. package/lib/chain/blocks/importBlock.d.ts.map +1 -1
  27. package/lib/chain/blocks/importBlock.js +36 -53
  28. package/lib/chain/blocks/importBlock.js.map +1 -1
  29. package/lib/chain/blocks/importExecutionPayload.d.ts +4 -0
  30. package/lib/chain/blocks/importExecutionPayload.d.ts.map +1 -1
  31. package/lib/chain/blocks/importExecutionPayload.js +24 -3
  32. package/lib/chain/blocks/importExecutionPayload.js.map +1 -1
  33. package/lib/chain/blocks/index.d.ts.map +1 -1
  34. package/lib/chain/blocks/index.js +2 -2
  35. package/lib/chain/blocks/index.js.map +1 -1
  36. package/lib/chain/blocks/types.d.ts +4 -20
  37. package/lib/chain/blocks/types.d.ts.map +1 -1
  38. package/lib/chain/blocks/types.js +0 -24
  39. package/lib/chain/blocks/types.js.map +1 -1
  40. package/lib/chain/blocks/verifyBlock.d.ts.map +1 -1
  41. package/lib/chain/blocks/verifyBlock.js +17 -6
  42. package/lib/chain/blocks/verifyBlock.js.map +1 -1
  43. package/lib/chain/blocks/verifyBlocksDataAvailability.d.ts.map +1 -1
  44. package/lib/chain/blocks/verifyBlocksDataAvailability.js +6 -1
  45. package/lib/chain/blocks/verifyBlocksDataAvailability.js.map +1 -1
  46. package/lib/chain/blocks/verifyBlocksExecutionPayloads.d.ts +1 -1
  47. package/lib/chain/blocks/verifyBlocksExecutionPayloads.d.ts.map +1 -1
  48. package/lib/chain/blocks/verifyBlocksExecutionPayloads.js +7 -3
  49. package/lib/chain/blocks/verifyBlocksExecutionPayloads.js.map +1 -1
  50. package/lib/chain/blocks/verifyBlocksSanityChecks.d.ts.map +1 -1
  51. package/lib/chain/blocks/verifyBlocksSanityChecks.js +4 -0
  52. package/lib/chain/blocks/verifyBlocksSanityChecks.js.map +1 -1
  53. package/lib/chain/blocks/verifyBlocksSignatures.d.ts.map +1 -1
  54. package/lib/chain/blocks/verifyBlocksSignatures.js +10 -5
  55. package/lib/chain/blocks/verifyBlocksSignatures.js.map +1 -1
  56. package/lib/chain/blocks/writeBlockInputToDb.d.ts +0 -2
  57. package/lib/chain/blocks/writeBlockInputToDb.d.ts.map +1 -1
  58. package/lib/chain/blocks/writeBlockInputToDb.js +6 -24
  59. package/lib/chain/blocks/writeBlockInputToDb.js.map +1 -1
  60. package/lib/chain/bls/interface.d.ts +2 -0
  61. package/lib/chain/bls/interface.d.ts.map +1 -1
  62. package/lib/chain/bls/multithread/index.d.ts +1 -1
  63. package/lib/chain/bls/multithread/index.d.ts.map +1 -1
  64. package/lib/chain/bls/multithread/index.js +45 -17
  65. package/lib/chain/bls/multithread/index.js.map +1 -1
  66. package/lib/chain/chain.d.ts +24 -3
  67. package/lib/chain/chain.d.ts.map +1 -1
  68. package/lib/chain/chain.js +120 -39
  69. package/lib/chain/chain.js.map +1 -1
  70. package/lib/chain/emitter.d.ts +7 -7
  71. package/lib/chain/emitter.d.ts.map +1 -1
  72. package/lib/chain/emitter.js +5 -5
  73. package/lib/chain/emitter.js.map +1 -1
  74. package/lib/chain/errors/executionPayloadEnvelope.d.ts +7 -0
  75. package/lib/chain/errors/executionPayloadEnvelope.d.ts.map +1 -1
  76. package/lib/chain/errors/executionPayloadEnvelope.js +1 -0
  77. package/lib/chain/errors/executionPayloadEnvelope.js.map +1 -1
  78. package/lib/chain/errors/index.d.ts +0 -1
  79. package/lib/chain/errors/index.d.ts.map +1 -1
  80. package/lib/chain/errors/index.js +0 -1
  81. package/lib/chain/errors/index.js.map +1 -1
  82. package/lib/chain/forkChoice/index.d.ts +11 -1
  83. package/lib/chain/forkChoice/index.d.ts.map +1 -1
  84. package/lib/chain/forkChoice/index.js +11 -0
  85. package/lib/chain/forkChoice/index.js.map +1 -1
  86. package/lib/chain/forkChoiceExecutionEngine.d.ts +51 -0
  87. package/lib/chain/forkChoiceExecutionEngine.d.ts.map +1 -0
  88. package/lib/chain/forkChoiceExecutionEngine.js +117 -0
  89. package/lib/chain/forkChoiceExecutionEngine.js.map +1 -0
  90. package/lib/chain/interface.d.ts +7 -4
  91. package/lib/chain/interface.d.ts.map +1 -1
  92. package/lib/chain/interface.js.map +1 -1
  93. package/lib/chain/opPools/aggregatedAttestationPool.d.ts +17 -4
  94. package/lib/chain/opPools/aggregatedAttestationPool.d.ts.map +1 -1
  95. package/lib/chain/opPools/aggregatedAttestationPool.js +177 -37
  96. package/lib/chain/opPools/aggregatedAttestationPool.js.map +1 -1
  97. package/lib/chain/opPools/index.d.ts +1 -0
  98. package/lib/chain/opPools/index.d.ts.map +1 -1
  99. package/lib/chain/opPools/index.js +1 -0
  100. package/lib/chain/opPools/index.js.map +1 -1
  101. package/lib/chain/opPools/singleAttestationPool.d.ts +77 -0
  102. package/lib/chain/opPools/singleAttestationPool.d.ts.map +1 -0
  103. package/lib/chain/opPools/singleAttestationPool.js +209 -0
  104. package/lib/chain/opPools/singleAttestationPool.js.map +1 -0
  105. package/lib/chain/options.d.ts +5 -2
  106. package/lib/chain/options.d.ts.map +1 -1
  107. package/lib/chain/options.js.map +1 -1
  108. package/lib/chain/produceBlock/produceBlockBody.d.ts +3 -2
  109. package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
  110. package/lib/chain/produceBlock/produceBlockBody.js +3 -2
  111. package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
  112. package/lib/chain/proposerTracker.d.ts +31 -0
  113. package/lib/chain/proposerTracker.d.ts.map +1 -0
  114. package/lib/chain/proposerTracker.js +75 -0
  115. package/lib/chain/proposerTracker.js.map +1 -0
  116. package/lib/chain/regen/interface.d.ts +1 -1
  117. package/lib/chain/regen/interface.d.ts.map +1 -1
  118. package/lib/chain/regen/queued.d.ts +1 -1
  119. package/lib/chain/regen/queued.d.ts.map +1 -1
  120. package/lib/chain/regen/queued.js +5 -3
  121. package/lib/chain/regen/queued.js.map +1 -1
  122. package/lib/chain/seenCache/seenGossipBlockInput.d.ts +7 -14
  123. package/lib/chain/seenCache/seenGossipBlockInput.d.ts.map +1 -1
  124. package/lib/chain/seenCache/seenGossipBlockInput.js +6 -65
  125. package/lib/chain/seenCache/seenGossipBlockInput.js.map +1 -1
  126. package/lib/chain/validation/executionPayloadEnvelope.d.ts +6 -0
  127. package/lib/chain/validation/executionPayloadEnvelope.d.ts.map +1 -1
  128. package/lib/chain/validation/executionPayloadEnvelope.js +53 -0
  129. package/lib/chain/validation/executionPayloadEnvelope.js.map +1 -1
  130. package/lib/chain/validatorMonitor.d.ts +1 -2
  131. package/lib/chain/validatorMonitor.d.ts.map +1 -1
  132. package/lib/chain/validatorMonitor.js +0 -3
  133. package/lib/chain/validatorMonitor.js.map +1 -1
  134. package/lib/db/repositories/blobSidecars.d.ts +0 -1
  135. package/lib/db/repositories/blobSidecars.d.ts.map +1 -1
  136. package/lib/db/repositories/blobSidecars.js +0 -1
  137. package/lib/db/repositories/blobSidecars.js.map +1 -1
  138. package/lib/execution/builder/apiClient.d.ts +14 -8
  139. package/lib/execution/builder/apiClient.d.ts.map +1 -1
  140. package/lib/execution/builder/apiClient.js +12 -10
  141. package/lib/execution/builder/apiClient.js.map +1 -1
  142. package/lib/execution/builder/http.d.ts +2 -0
  143. package/lib/execution/builder/http.d.ts.map +1 -1
  144. package/lib/execution/builder/http.js +2 -0
  145. package/lib/execution/builder/http.js.map +1 -1
  146. package/lib/execution/engine/http.d.ts +4 -6
  147. package/lib/execution/engine/http.d.ts.map +1 -1
  148. package/lib/execution/engine/http.js +8 -10
  149. package/lib/execution/engine/http.js.map +1 -1
  150. package/lib/execution/engine/interface.d.ts +17 -5
  151. package/lib/execution/engine/interface.d.ts.map +1 -1
  152. package/lib/execution/engine/interface.js.map +1 -1
  153. package/lib/execution/engine/jsonRpcTransport.d.ts +2 -4
  154. package/lib/execution/engine/jsonRpcTransport.d.ts.map +1 -1
  155. package/lib/execution/engine/jsonRpcTransport.js +2 -12
  156. package/lib/execution/engine/jsonRpcTransport.js.map +1 -1
  157. package/lib/execution/engine/mock.d.ts +0 -1
  158. package/lib/execution/engine/mock.d.ts.map +1 -1
  159. package/lib/execution/engine/mock.js +0 -4
  160. package/lib/execution/engine/mock.js.map +1 -1
  161. package/lib/execution/engine/restTransport.d.ts +2 -4
  162. package/lib/execution/engine/restTransport.d.ts.map +1 -1
  163. package/lib/execution/engine/restTransport.js +1 -15
  164. package/lib/execution/engine/restTransport.js.map +1 -1
  165. package/lib/execution/engine/sszTypes.d.ts +0 -9
  166. package/lib/execution/engine/sszTypes.d.ts.map +1 -1
  167. package/lib/execution/engine/sszTypes.js +0 -5
  168. package/lib/execution/engine/sszTypes.js.map +1 -1
  169. package/lib/execution/engine/transport.d.ts +1 -14
  170. package/lib/execution/engine/transport.d.ts.map +1 -1
  171. package/lib/execution/engine/types.d.ts +0 -8
  172. package/lib/execution/engine/types.d.ts.map +1 -1
  173. package/lib/execution/engine/types.js +0 -8
  174. package/lib/execution/engine/types.js.map +1 -1
  175. package/lib/execution/engine/utils.d.ts.map +1 -1
  176. package/lib/execution/engine/utils.js +3 -2
  177. package/lib/execution/engine/utils.js.map +1 -1
  178. package/lib/index.d.ts +1 -1
  179. package/lib/index.d.ts.map +1 -1
  180. package/lib/index.js +1 -1
  181. package/lib/index.js.map +1 -1
  182. package/lib/metrics/metrics/beacon.d.ts +0 -9
  183. package/lib/metrics/metrics/beacon.d.ts.map +1 -1
  184. package/lib/metrics/metrics/beacon.js +0 -30
  185. package/lib/metrics/metrics/beacon.js.map +1 -1
  186. package/lib/metrics/metrics/lodestar.d.ts +27 -8
  187. package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
  188. package/lib/metrics/metrics/lodestar.js +74 -18
  189. package/lib/metrics/metrics/lodestar.js.map +1 -1
  190. package/lib/metrics/server/http.js +5 -5
  191. package/lib/metrics/server/http.js.map +1 -1
  192. package/lib/network/core/networkCore.d.ts +2 -1
  193. package/lib/network/core/networkCore.d.ts.map +1 -1
  194. package/lib/network/core/networkCore.js +4 -0
  195. package/lib/network/core/networkCore.js.map +1 -1
  196. package/lib/network/core/networkCoreWorker.js +1 -0
  197. package/lib/network/core/networkCoreWorker.js.map +1 -1
  198. package/lib/network/core/networkCoreWorkerHandler.d.ts +2 -1
  199. package/lib/network/core/networkCoreWorkerHandler.d.ts.map +1 -1
  200. package/lib/network/core/networkCoreWorkerHandler.js +3 -0
  201. package/lib/network/core/networkCoreWorkerHandler.js.map +1 -1
  202. package/lib/network/core/types.d.ts +4 -1
  203. package/lib/network/core/types.d.ts.map +1 -1
  204. package/lib/network/gossip/gossipsub.d.ts +1 -0
  205. package/lib/network/gossip/gossipsub.d.ts.map +1 -1
  206. package/lib/network/gossip/gossipsub.js +10 -0
  207. package/lib/network/gossip/gossipsub.js.map +1 -1
  208. package/lib/network/gossip/interface.d.ts +1 -8
  209. package/lib/network/gossip/interface.d.ts.map +1 -1
  210. package/lib/network/gossip/interface.js +0 -1
  211. package/lib/network/gossip/interface.js.map +1 -1
  212. package/lib/network/gossip/topic.d.ts +0 -16
  213. package/lib/network/gossip/topic.d.ts.map +1 -1
  214. package/lib/network/gossip/topic.js +0 -23
  215. package/lib/network/gossip/topic.js.map +1 -1
  216. package/lib/network/interface.d.ts +2 -5
  217. package/lib/network/interface.d.ts.map +1 -1
  218. package/lib/network/network.d.ts +6 -7
  219. package/lib/network/network.d.ts.map +1 -1
  220. package/lib/network/network.js +50 -37
  221. package/lib/network/network.js.map +1 -1
  222. package/lib/network/options.d.ts.map +1 -1
  223. package/lib/network/options.js +2 -0
  224. package/lib/network/options.js.map +1 -1
  225. package/lib/network/peers/peerManager.d.ts.map +1 -1
  226. package/lib/network/peers/peerManager.js +28 -1
  227. package/lib/network/peers/peerManager.js.map +1 -1
  228. package/lib/network/peers/utils/prioritizePeers.d.ts +4 -1
  229. package/lib/network/peers/utils/prioritizePeers.d.ts.map +1 -1
  230. package/lib/network/peers/utils/prioritizePeers.js +8 -16
  231. package/lib/network/peers/utils/prioritizePeers.js.map +1 -1
  232. package/lib/network/peers/utils/subnetMap.d.ts +5 -2
  233. package/lib/network/peers/utils/subnetMap.d.ts.map +1 -1
  234. package/lib/network/peers/utils/subnetMap.js +6 -3
  235. package/lib/network/peers/utils/subnetMap.js.map +1 -1
  236. package/lib/network/processor/extractSlotRootFns.d.ts.map +1 -1
  237. package/lib/network/processor/extractSlotRootFns.js +1 -8
  238. package/lib/network/processor/extractSlotRootFns.js.map +1 -1
  239. package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
  240. package/lib/network/processor/gossipHandlers.js +43 -123
  241. package/lib/network/processor/gossipHandlers.js.map +1 -1
  242. package/lib/network/processor/gossipQueues/index.d.ts.map +1 -1
  243. package/lib/network/processor/gossipQueues/index.js +0 -6
  244. package/lib/network/processor/gossipQueues/index.js.map +1 -1
  245. package/lib/network/processor/gossipValidatorFn.d.ts.map +1 -1
  246. package/lib/network/processor/gossipValidatorFn.js +1 -5
  247. package/lib/network/processor/gossipValidatorFn.js.map +1 -1
  248. package/lib/network/processor/index.d.ts +6 -0
  249. package/lib/network/processor/index.d.ts.map +1 -1
  250. package/lib/network/processor/index.js +29 -4
  251. package/lib/network/processor/index.js.map +1 -1
  252. package/lib/network/reqresp/ReqRespBeaconNode.d.ts.map +1 -1
  253. package/lib/network/reqresp/ReqRespBeaconNode.js +0 -3
  254. package/lib/network/reqresp/ReqRespBeaconNode.js.map +1 -1
  255. package/lib/network/reqresp/handlers/beaconBlocksByRange.d.ts +2 -2
  256. package/lib/network/reqresp/handlers/beaconBlocksByRange.d.ts.map +1 -1
  257. package/lib/network/reqresp/handlers/index.d.ts.map +1 -1
  258. package/lib/network/reqresp/handlers/index.js +1 -12
  259. package/lib/network/reqresp/handlers/index.js.map +1 -1
  260. package/lib/network/reqresp/protocols.d.ts +0 -2
  261. package/lib/network/reqresp/protocols.d.ts.map +1 -1
  262. package/lib/network/reqresp/protocols.js +0 -10
  263. package/lib/network/reqresp/protocols.js.map +1 -1
  264. package/lib/network/reqresp/rateLimit.d.ts.map +1 -1
  265. package/lib/network/reqresp/rateLimit.js +1 -17
  266. package/lib/network/reqresp/rateLimit.js.map +1 -1
  267. package/lib/network/reqresp/types.d.ts +2 -8
  268. package/lib/network/reqresp/types.d.ts.map +1 -1
  269. package/lib/network/reqresp/types.js +1 -7
  270. package/lib/network/reqresp/types.js.map +1 -1
  271. package/lib/network/subnets/attnetsService.d.ts +35 -5
  272. package/lib/network/subnets/attnetsService.d.ts.map +1 -1
  273. package/lib/network/subnets/attnetsService.js +84 -6
  274. package/lib/network/subnets/attnetsService.js.map +1 -1
  275. package/lib/network/subnets/interface.d.ts +7 -0
  276. package/lib/network/subnets/interface.d.ts.map +1 -1
  277. package/lib/network/subnets/interface.js.map +1 -1
  278. package/lib/node/nodejs.d.ts +2 -0
  279. package/lib/node/nodejs.d.ts.map +1 -1
  280. package/lib/node/nodejs.js +37 -19
  281. package/lib/node/nodejs.js.map +1 -1
  282. package/lib/node/options.d.ts +3 -1
  283. package/lib/node/options.d.ts.map +1 -1
  284. package/lib/node/options.js +4 -2
  285. package/lib/node/options.js.map +1 -1
  286. package/lib/sync/range/batch.d.ts +2 -3
  287. package/lib/sync/range/batch.d.ts.map +1 -1
  288. package/lib/sync/range/batch.js +9 -22
  289. package/lib/sync/range/batch.js.map +1 -1
  290. package/lib/sync/range/chain.d.ts.map +1 -1
  291. package/lib/sync/range/chain.js +2 -15
  292. package/lib/sync/range/chain.js.map +1 -1
  293. package/lib/sync/unknownBlock.d.ts.map +1 -1
  294. package/lib/sync/unknownBlock.js +1 -7
  295. package/lib/sync/unknownBlock.js.map +1 -1
  296. package/lib/sync/utils/downloadByRange.d.ts +6 -34
  297. package/lib/sync/utils/downloadByRange.d.ts.map +1 -1
  298. package/lib/sync/utils/downloadByRange.js +24 -128
  299. package/lib/sync/utils/downloadByRange.js.map +1 -1
  300. package/lib/sync/utils/downloadByRoot.d.ts +2 -18
  301. package/lib/sync/utils/downloadByRoot.d.ts.map +1 -1
  302. package/lib/sync/utils/downloadByRoot.js +14 -99
  303. package/lib/sync/utils/downloadByRoot.js.map +1 -1
  304. package/lib/util/blobs.d.ts +1 -7
  305. package/lib/util/blobs.d.ts.map +1 -1
  306. package/lib/util/blobs.js +0 -19
  307. package/lib/util/blobs.js.map +1 -1
  308. package/lib/util/execution.d.ts +3 -4
  309. package/lib/util/execution.d.ts.map +1 -1
  310. package/lib/util/execution.js +1 -73
  311. package/lib/util/execution.js.map +1 -1
  312. package/lib/util/sszBytes.d.ts +5 -1
  313. package/lib/util/sszBytes.d.ts.map +1 -1
  314. package/lib/util/sszBytes.js +34 -17
  315. package/lib/util/sszBytes.js.map +1 -1
  316. package/lib/util/types.d.ts +0 -5
  317. package/lib/util/types.d.ts.map +1 -1
  318. package/lib/util/types.js +1 -2
  319. package/lib/util/types.js.map +1 -1
  320. package/package.json +16 -16
  321. package/src/api/impl/beacon/blocks/index.ts +24 -64
  322. package/src/api/impl/beacon/pool/index.ts +26 -0
  323. package/src/api/impl/validator/index.ts +43 -29
  324. package/src/chain/GetBlobsTracker.ts +10 -39
  325. package/src/chain/blocks/blockInput/blockInput.ts +11 -343
  326. package/src/chain/blocks/blockInput/errors.ts +1 -2
  327. package/src/chain/blocks/blockInput/types.ts +2 -20
  328. package/src/chain/blocks/importBlock.ts +56 -72
  329. package/src/chain/blocks/importExecutionPayload.ts +42 -13
  330. package/src/chain/blocks/index.ts +5 -2
  331. package/src/chain/blocks/types.ts +5 -31
  332. package/src/chain/blocks/verifyBlock.ts +30 -16
  333. package/src/chain/blocks/verifyBlocksDataAvailability.ts +6 -1
  334. package/src/chain/blocks/verifyBlocksExecutionPayloads.ts +9 -6
  335. package/src/chain/blocks/verifyBlocksSanityChecks.ts +4 -1
  336. package/src/chain/blocks/verifyBlocksSignatures.ts +10 -5
  337. package/src/chain/blocks/writeBlockInputToDb.ts +6 -29
  338. package/src/chain/bls/interface.ts +2 -0
  339. package/src/chain/bls/multithread/index.ts +43 -19
  340. package/src/chain/chain.ts +135 -37
  341. package/src/chain/emitter.ts +8 -8
  342. package/src/chain/errors/executionPayloadEnvelope.ts +8 -0
  343. package/src/chain/errors/index.ts +0 -1
  344. package/src/chain/forkChoice/index.ts +11 -0
  345. package/src/chain/forkChoiceExecutionEngine.ts +183 -0
  346. package/src/chain/interface.ts +7 -3
  347. package/src/chain/opPools/aggregatedAttestationPool.ts +222 -35
  348. package/src/chain/opPools/index.ts +1 -0
  349. package/src/chain/opPools/singleAttestationPool.ts +287 -0
  350. package/src/chain/options.ts +5 -2
  351. package/src/chain/produceBlock/produceBlockBody.ts +7 -3
  352. package/src/chain/proposerTracker.ts +94 -0
  353. package/src/chain/regen/interface.ts +1 -1
  354. package/src/chain/regen/queued.ts +6 -4
  355. package/src/chain/seenCache/seenGossipBlockInput.ts +9 -93
  356. package/src/chain/validation/executionPayloadEnvelope.ts +68 -1
  357. package/src/chain/validatorMonitor.ts +0 -6
  358. package/src/db/repositories/blobSidecars.ts +0 -1
  359. package/src/execution/builder/apiClient.ts +16 -13
  360. package/src/execution/builder/http.ts +4 -0
  361. package/src/execution/engine/http.ts +19 -42
  362. package/src/execution/engine/interface.ts +18 -9
  363. package/src/execution/engine/jsonRpcTransport.ts +10 -22
  364. package/src/execution/engine/mock.ts +0 -7
  365. package/src/execution/engine/restTransport.ts +3 -22
  366. package/src/execution/engine/sszTypes.ts +0 -9
  367. package/src/execution/engine/transport.ts +8 -17
  368. package/src/execution/engine/types.ts +0 -17
  369. package/src/execution/engine/utils.ts +4 -2
  370. package/src/index.ts +1 -1
  371. package/src/metrics/metrics/beacon.ts +0 -30
  372. package/src/metrics/metrics/lodestar.ts +75 -18
  373. package/src/metrics/server/http.ts +5 -5
  374. package/src/network/core/networkCore.ts +6 -1
  375. package/src/network/core/networkCoreWorker.ts +1 -0
  376. package/src/network/core/networkCoreWorkerHandler.ts +4 -1
  377. package/src/network/core/types.ts +4 -1
  378. package/src/network/gossip/gossipsub.ts +11 -0
  379. package/src/network/gossip/interface.ts +0 -5
  380. package/src/network/gossip/topic.ts +0 -25
  381. package/src/network/interface.ts +0 -5
  382. package/src/network/network.ts +50 -60
  383. package/src/network/options.ts +2 -0
  384. package/src/network/peers/peerManager.ts +27 -2
  385. package/src/network/peers/utils/prioritizePeers.ts +14 -22
  386. package/src/network/peers/utils/subnetMap.ts +6 -3
  387. package/src/network/processor/extractSlotRootFns.ts +0 -9
  388. package/src/network/processor/gossipHandlers.ts +56 -156
  389. package/src/network/processor/gossipQueues/index.ts +0 -6
  390. package/src/network/processor/gossipValidatorFn.ts +0 -5
  391. package/src/network/processor/index.ts +25 -4
  392. package/src/network/reqresp/ReqRespBeaconNode.ts +0 -7
  393. package/src/network/reqresp/handlers/beaconBlocksByRange.ts +2 -2
  394. package/src/network/reqresp/handlers/index.ts +0 -17
  395. package/src/network/reqresp/protocols.ts +0 -12
  396. package/src/network/reqresp/rateLimit.ts +1 -17
  397. package/src/network/reqresp/types.ts +0 -13
  398. package/src/network/subnets/attnetsService.ts +94 -6
  399. package/src/network/subnets/interface.ts +7 -0
  400. package/src/node/nodejs.ts +34 -15
  401. package/src/node/options.ts +5 -1
  402. package/src/sync/range/batch.ts +9 -21
  403. package/src/sync/range/chain.ts +2 -14
  404. package/src/sync/unknownBlock.ts +1 -8
  405. package/src/sync/utils/downloadByRange.ts +31 -230
  406. package/src/sync/utils/downloadByRoot.ts +15 -142
  407. package/src/util/blobs.ts +0 -34
  408. package/src/util/execution.ts +8 -102
  409. package/src/util/sszBytes.ts +40 -22
  410. package/src/util/types.ts +1 -8
  411. package/lib/chain/errors/blobSidecarError.d.ts +0 -108
  412. package/lib/chain/errors/blobSidecarError.d.ts.map +0 -1
  413. package/lib/chain/errors/blobSidecarError.js +0 -38
  414. package/lib/chain/errors/blobSidecarError.js.map +0 -1
  415. package/lib/chain/validation/blobSidecar.d.ts +0 -16
  416. package/lib/chain/validation/blobSidecar.d.ts.map +0 -1
  417. package/lib/chain/validation/blobSidecar.js +0 -276
  418. package/lib/chain/validation/blobSidecar.js.map +0 -1
  419. package/lib/network/reqresp/handlers/blobSidecarsByRange.d.ts +0 -9
  420. package/lib/network/reqresp/handlers/blobSidecarsByRange.d.ts.map +0 -1
  421. package/lib/network/reqresp/handlers/blobSidecarsByRange.js +0 -91
  422. package/lib/network/reqresp/handlers/blobSidecarsByRange.js.map +0 -1
  423. package/lib/network/reqresp/handlers/blobSidecarsByRoot.d.ts +0 -5
  424. package/lib/network/reqresp/handlers/blobSidecarsByRoot.d.ts.map +0 -1
  425. package/lib/network/reqresp/handlers/blobSidecarsByRoot.js +0 -46
  426. package/lib/network/reqresp/handlers/blobSidecarsByRoot.js.map +0 -1
  427. package/src/chain/errors/blobSidecarError.ts +0 -70
  428. package/src/chain/validation/blobSidecar.ts +0 -357
  429. package/src/network/reqresp/handlers/blobSidecarsByRange.ts +0 -133
  430. package/src/network/reqresp/handlers/blobSidecarsByRoot.ts +0 -69
@@ -1,357 +0,0 @@
1
- import {ChainConfig} from "@lodestar/config";
2
- import {
3
- ForkName,
4
- KZG_COMMITMENT_INCLUSION_PROOF_DEPTH,
5
- KZG_COMMITMENT_SUBTREE_INDEX0,
6
- isForkPostElectra,
7
- } from "@lodestar/params";
8
- import {
9
- computeEpochAtSlot,
10
- computeStartSlotAtEpoch,
11
- getBlockHeaderProposerSignatureSetByHeaderSlot,
12
- getBlockHeaderProposerSignatureSetByParentStateSlot,
13
- } from "@lodestar/state-transition";
14
- import {BlobIndex, Root, Slot, SubnetID, deneb, ssz} from "@lodestar/types";
15
- import {byteArrayEquals, toRootHex, verifyMerkleBranch} from "@lodestar/utils";
16
- import {kzg} from "../../util/kzg.js";
17
- import {BlobSidecarErrorCode, BlobSidecarGossipError, BlobSidecarValidationError} from "../errors/blobSidecarError.js";
18
- import {GossipAction} from "../errors/gossipValidation.js";
19
- import {IBeaconChain} from "../interface.js";
20
- import {RegenCaller} from "../regen/index.js";
21
-
22
- export async function validateGossipBlobSidecar(
23
- fork: ForkName,
24
- chain: IBeaconChain,
25
- blobSidecar: deneb.BlobSidecar,
26
- subnet: SubnetID
27
- ): Promise<void> {
28
- const blobSlot = blobSidecar.signedBlockHeader.message.slot;
29
-
30
- // [REJECT] The sidecar's index is consistent with `MAX_BLOBS_PER_BLOCK` -- i.e. `blob_sidecar.index < MAX_BLOBS_PER_BLOCK`.
31
- const maxBlobsPerBlock = chain.config.getMaxBlobsPerBlock(computeEpochAtSlot(blobSlot));
32
- if (blobSidecar.index >= maxBlobsPerBlock) {
33
- throw new BlobSidecarGossipError(GossipAction.REJECT, {
34
- code: BlobSidecarErrorCode.INDEX_TOO_LARGE,
35
- blobIdx: blobSidecar.index,
36
- maxBlobsPerBlock,
37
- });
38
- }
39
-
40
- // [REJECT] The sidecar is for the correct subnet -- i.e. `compute_subnet_for_blob_sidecar(sidecar.index) == subnet_id`.
41
- if (computeSubnetForBlobSidecar(fork, chain.config, blobSidecar.index) !== subnet) {
42
- throw new BlobSidecarGossipError(GossipAction.REJECT, {
43
- code: BlobSidecarErrorCode.INVALID_INDEX,
44
- blobIdx: blobSidecar.index,
45
- subnet,
46
- });
47
- }
48
-
49
- // [IGNORE] The sidecar is not from a future slot (with a MAXIMUM_GOSSIP_CLOCK_DISPARITY allowance) --
50
- // i.e. validate that sidecar.slot <= current_slot (a client MAY queue future blocks for processing at
51
- // the appropriate slot).
52
- const currentSlotWithGossipDisparity = chain.clock.currentSlotWithGossipDisparity;
53
- if (currentSlotWithGossipDisparity < blobSlot) {
54
- throw new BlobSidecarGossipError(GossipAction.IGNORE, {
55
- code: BlobSidecarErrorCode.FUTURE_SLOT,
56
- currentSlot: currentSlotWithGossipDisparity,
57
- blockSlot: blobSlot,
58
- });
59
- }
60
-
61
- // [IGNORE] The sidecar is from a slot greater than the latest finalized slot -- i.e. validate that
62
- // sidecar.slot > compute_start_slot_at_epoch(state.finalized_checkpoint.epoch)
63
- const finalizedCheckpoint = chain.forkChoice.getFinalizedCheckpoint();
64
- const finalizedSlot = computeStartSlotAtEpoch(finalizedCheckpoint.epoch);
65
- if (blobSlot <= finalizedSlot) {
66
- throw new BlobSidecarGossipError(GossipAction.IGNORE, {
67
- code: BlobSidecarErrorCode.WOULD_REVERT_FINALIZED_SLOT,
68
- blockSlot: blobSlot,
69
- finalizedSlot,
70
- });
71
- }
72
-
73
- // Check if the block is already known. We know it is post-finalization, so it is sufficient to check the fork choice.
74
- //
75
- // In normal operation this isn't necessary, however it is useful immediately after a
76
- // reboot if the `observed_block_producers` cache is empty. In that case, without this
77
- // check, we will load the parent and state from disk only to find out later that we
78
- // already know this block.
79
- const blockRoot = ssz.phase0.BeaconBlockHeader.hashTreeRoot(blobSidecar.signedBlockHeader.message);
80
- const blockHex = toRootHex(blockRoot);
81
- if (chain.forkChoice.getBlockHexDefaultStatus(blockHex) !== null) {
82
- throw new BlobSidecarGossipError(GossipAction.IGNORE, {code: BlobSidecarErrorCode.ALREADY_KNOWN, root: blockHex});
83
- }
84
-
85
- // TODO: freetheblobs - check for badblock
86
- // TODO: freetheblobs - check that its first blob with valid signature
87
-
88
- // _[IGNORE]_ The blob's block's parent (defined by `sidecar.block_parent_root`) has been seen (via both
89
- // gossip and non-gossip sources) (a client MAY queue blocks for processing once the parent block is
90
- // retrieved).
91
- const parentRoot = toRootHex(blobSidecar.signedBlockHeader.message.parentRoot);
92
- const parentBlock = chain.forkChoice.getBlockHexDefaultStatus(parentRoot);
93
- if (parentBlock === null) {
94
- // If fork choice does *not* consider the parent to be a descendant of the finalized block,
95
- // then there are two more cases:
96
- //
97
- // 1. We have the parent stored in our database. Because fork-choice has confirmed the
98
- // parent is *not* in our post-finalization DAG, all other blocks must be either
99
- // pre-finalization or conflicting with finalization.
100
- // 2. The parent is unknown to us, we probably want to download it since it might actually
101
- // descend from the finalized root.
102
- // (Non-Lighthouse): Since we prune all blocks non-descendant from finalized checking the `db.block` database won't be useful to guard
103
- // against known bad fork blocks, so we throw PARENT_UNKNOWN for cases (1) and (2)
104
- throw new BlobSidecarGossipError(GossipAction.IGNORE, {
105
- code: BlobSidecarErrorCode.PARENT_UNKNOWN,
106
- parentRoot,
107
- blockRoot: blockHex,
108
- slot: blobSlot,
109
- });
110
- }
111
-
112
- // [REJECT] The blob is from a higher slot than its parent.
113
- if (parentBlock.slot >= blobSlot) {
114
- throw new BlobSidecarGossipError(GossipAction.REJECT, {
115
- code: BlobSidecarErrorCode.NOT_LATER_THAN_PARENT,
116
- parentSlot: parentBlock.slot,
117
- slot: blobSlot,
118
- });
119
- }
120
-
121
- // getBlockSlotState also checks for whether the current finalized checkpoint is an ancestor of the block.
122
- // As a result, we throw an IGNORE (whereas the spec says we should REJECT for this scenario).
123
- // this is something we should change this in the future to make the code airtight to the spec.
124
- // [IGNORE] The block's parent (defined by block.parent_root) has been seen (via both gossip and non-gossip sources) (a client MAY queue blocks for processing once the parent block is retrieved).
125
- // [REJECT] The block's parent (defined by block.parent_root) passes validation.
126
- const blockState = await chain.regen
127
- .getBlockSlotState(parentBlock, blobSlot, {dontTransferCache: true}, RegenCaller.validateGossipBlock)
128
- .catch(() => {
129
- throw new BlobSidecarGossipError(GossipAction.IGNORE, {
130
- code: BlobSidecarErrorCode.PARENT_UNKNOWN,
131
- parentRoot,
132
- blockRoot: blockHex,
133
- slot: blobSlot,
134
- });
135
- });
136
-
137
- // [REJECT] The proposer signature, signed_beacon_block.signature, is valid with respect to the proposer_index pubkey.
138
- const signature = blobSidecar.signedBlockHeader.signature;
139
- if (!chain.seenBlockInputCache.isVerifiedProposerSignature(blobSlot, blockHex, signature)) {
140
- const signatureSet = getBlockHeaderProposerSignatureSetByParentStateSlot(
141
- chain.config,
142
- blockState.slot,
143
- blobSidecar.signedBlockHeader
144
- );
145
- // Don't batch so verification is not delayed
146
- if (!(await chain.bls.verifySignatureSets([signatureSet], {verifyOnMainThread: true}))) {
147
- throw new BlobSidecarGossipError(GossipAction.REJECT, {
148
- code: BlobSidecarErrorCode.PROPOSAL_SIGNATURE_INVALID,
149
- blockRoot: blockHex,
150
- index: blobSidecar.index,
151
- slot: blobSlot,
152
- });
153
- }
154
-
155
- chain.seenBlockInputCache.markVerifiedProposerSignature(blobSlot, blockHex, signature);
156
- }
157
-
158
- // verify if the blob inclusion proof is correct
159
- if (!validateBlobSidecarInclusionProof(blobSidecar)) {
160
- throw new BlobSidecarGossipError(GossipAction.REJECT, {
161
- code: BlobSidecarErrorCode.INCLUSION_PROOF_INVALID,
162
- slot: blobSidecar.signedBlockHeader.message.slot,
163
- blobIdx: blobSidecar.index,
164
- });
165
- }
166
-
167
- // _[IGNORE]_ The sidecar is the only sidecar with valid signature received for the tuple
168
- // `(sidecar.block_root, sidecar.index)`
169
- //
170
- // This is already taken care of by the way we group the blobs in getFullBlockInput helper
171
- // but may be an error can be thrown there for this
172
-
173
- // _[REJECT]_ The sidecar is proposed by the expected `proposer_index` for the block's slot in the
174
- // context of the current shuffling (defined by `block_parent_root`/`slot`)
175
- // If the `proposer_index` cannot immediately be verified against the expected shuffling, the sidecar
176
- // MAY be queued for later processing while proposers for the block's branch are calculated -- in such
177
- // a case _do not_ `REJECT`, instead `IGNORE` this message.
178
- const proposerIndex = blobSidecar.signedBlockHeader.message.proposerIndex;
179
- if (blockState.getBeaconProposer(blobSlot) !== proposerIndex) {
180
- throw new BlobSidecarGossipError(GossipAction.REJECT, {
181
- code: BlobSidecarErrorCode.INCORRECT_PROPOSER,
182
- proposerIndex,
183
- });
184
- }
185
-
186
- // blob, proof and commitment as a valid BLS G1 point gets verified in batch validation
187
- try {
188
- await validateBlobsAndBlobProofs([blobSidecar.kzgCommitment], [blobSidecar.blob], [blobSidecar.kzgProof]);
189
- } catch (_e) {
190
- throw new BlobSidecarGossipError(GossipAction.REJECT, {
191
- code: BlobSidecarErrorCode.INVALID_KZG_PROOF,
192
- blobIdx: blobSidecar.index,
193
- });
194
- }
195
- }
196
-
197
- /**
198
- * Validate some blob sidecars in a block
199
- *
200
- * Requires the block to be known to the node
201
- *
202
- * NOTE: chain is optional to skip signature verification. Helpful for testing purposes and so that can control whether
203
- * signature gets checked depending on the reqresp method that is being checked
204
- */
205
- export async function validateBlockBlobSidecars(
206
- chain: IBeaconChain | null,
207
- blockSlot: Slot,
208
- blockRoot: Root,
209
- blockBlobCount: number,
210
- blobSidecars: deneb.BlobSidecars
211
- ): Promise<void> {
212
- if (blobSidecars.length === 0) {
213
- return;
214
- }
215
-
216
- if (blockBlobCount === 0) {
217
- throw new BlobSidecarValidationError({
218
- code: BlobSidecarErrorCode.INCORRECT_SIDECAR_COUNT,
219
- slot: blockSlot,
220
- expected: blockBlobCount,
221
- actual: blobSidecars.length,
222
- });
223
- }
224
-
225
- // Hash the first sidecar block header and compare the rest via (cheaper) equality
226
- const firstSidecarSignedBlockHeader = blobSidecars[0].signedBlockHeader;
227
- const firstSidecarBlockHeader = firstSidecarSignedBlockHeader.message;
228
- const firstBlockRoot = ssz.phase0.BeaconBlockHeader.hashTreeRoot(firstSidecarBlockHeader);
229
- if (!byteArrayEquals(blockRoot, firstBlockRoot)) {
230
- throw new BlobSidecarValidationError(
231
- {
232
- code: BlobSidecarErrorCode.INCORRECT_BLOCK,
233
- slot: blockSlot,
234
- blobIdx: 0,
235
- expected: toRootHex(blockRoot),
236
- actual: toRootHex(firstBlockRoot),
237
- },
238
- "BlobSidecar doesn't match corresponding block"
239
- );
240
- }
241
-
242
- if (chain !== null) {
243
- const blockRootHex = toRootHex(blockRoot);
244
- const signature = firstSidecarSignedBlockHeader.signature;
245
- if (!chain.seenBlockInputCache.isVerifiedProposerSignature(blockSlot, blockRootHex, signature)) {
246
- const signatureSet = getBlockHeaderProposerSignatureSetByHeaderSlot(chain.config, firstSidecarSignedBlockHeader);
247
-
248
- if (
249
- !(await chain.bls.verifySignatureSets([signatureSet], {
250
- verifyOnMainThread: true,
251
- }))
252
- ) {
253
- throw new BlobSidecarValidationError({
254
- code: BlobSidecarErrorCode.PROPOSAL_SIGNATURE_INVALID,
255
- blockRoot: blockRootHex,
256
- slot: blockSlot,
257
- index: blobSidecars[0].index,
258
- });
259
- }
260
-
261
- chain.seenBlockInputCache.markVerifiedProposerSignature(blockSlot, blockRootHex, signature);
262
- }
263
- }
264
-
265
- const commitments = [];
266
- const blobs = [];
267
- const proofs = [];
268
- for (let i = 0; i < blobSidecars.length; i++) {
269
- const blobSidecar = blobSidecars[i];
270
- const blobIndex = blobSidecar.index;
271
-
272
- if (
273
- i !== 0 &&
274
- !ssz.phase0.SignedBeaconBlockHeader.equals(blobSidecar.signedBlockHeader, firstSidecarSignedBlockHeader)
275
- ) {
276
- throw new BlobSidecarValidationError(
277
- {
278
- code: BlobSidecarErrorCode.INCORRECT_BLOCK,
279
- slot: blockSlot,
280
- blobIdx: blobIndex,
281
- expected: toRootHex(blockRoot),
282
- actual: "unknown - compared via equality",
283
- },
284
- "BlobSidecar doesn't match corresponding block"
285
- );
286
- }
287
-
288
- if (!validateBlobSidecarInclusionProof(blobSidecar)) {
289
- throw new BlobSidecarValidationError(
290
- {
291
- code: BlobSidecarErrorCode.INCLUSION_PROOF_INVALID,
292
- slot: blockSlot,
293
- blobIdx: blobIndex,
294
- },
295
- "BlobSidecar inclusion proof invalid"
296
- );
297
- }
298
-
299
- commitments.push(blobSidecar.kzgCommitment);
300
- blobs.push(blobSidecar.blob);
301
- proofs.push(blobSidecar.kzgProof);
302
- }
303
-
304
- // Final batch KZG proof verification
305
- let reason: string | undefined = undefined;
306
- try {
307
- if (!(await kzg.asyncVerifyBlobKzgProofBatch(blobs, commitments, proofs))) {
308
- reason = "Invalid verifyBlobKzgProofBatch";
309
- }
310
- } catch (e) {
311
- reason = (e as Error).message;
312
- }
313
- if (reason !== undefined) {
314
- throw new BlobSidecarValidationError(
315
- {
316
- code: BlobSidecarErrorCode.INVALID_KZG_PROOF_BATCH,
317
- slot: blockSlot,
318
- reason,
319
- },
320
- "BlobSidecar has invalid KZG proof batch"
321
- );
322
- }
323
- }
324
-
325
- export async function validateBlobsAndBlobProofs(
326
- expectedKzgCommitments: deneb.BlobKzgCommitments,
327
- blobs: deneb.Blobs,
328
- proofs: deneb.KZGProofs
329
- ): Promise<void> {
330
- // assert verify_aggregate_kzg_proof(blobs, expected_kzg_commitments, kzg_aggregated_proof)
331
- let isProofValid: boolean;
332
- try {
333
- isProofValid = await kzg.asyncVerifyBlobKzgProofBatch(blobs, expectedKzgCommitments, proofs);
334
- } catch (e) {
335
- (e as Error).message = `Error on verifyBlobKzgProofBatch: ${(e as Error).message}`;
336
- throw e;
337
- }
338
- if (!isProofValid) {
339
- throw Error("Invalid verifyBlobKzgProofBatch");
340
- }
341
- }
342
-
343
- export function validateBlobSidecarInclusionProof(blobSidecar: deneb.BlobSidecar): boolean {
344
- return verifyMerkleBranch(
345
- ssz.deneb.KZGCommitment.hashTreeRoot(blobSidecar.kzgCommitment),
346
- blobSidecar.kzgCommitmentInclusionProof,
347
- KZG_COMMITMENT_INCLUSION_PROOF_DEPTH,
348
- KZG_COMMITMENT_SUBTREE_INDEX0 + blobSidecar.index,
349
- blobSidecar.signedBlockHeader.message.bodyRoot
350
- );
351
- }
352
-
353
- function computeSubnetForBlobSidecar(fork: ForkName, config: ChainConfig, blobIndex: BlobIndex): SubnetID {
354
- return (
355
- blobIndex % (isForkPostElectra(fork) ? config.BLOB_SIDECAR_SUBNET_COUNT_ELECTRA : config.BLOB_SIDECAR_SUBNET_COUNT)
356
- );
357
- }
@@ -1,133 +0,0 @@
1
- import {ChainConfig} from "@lodestar/config";
2
- import {BLOB_SIDECAR_FIXED_SIZE, GENESIS_SLOT} from "@lodestar/params";
3
- import {RespStatus, ResponseError, ResponseOutgoing} from "@lodestar/reqresp";
4
- import {computeEpochAtSlot} from "@lodestar/state-transition";
5
- import {Epoch, Slot, deneb} from "@lodestar/types";
6
- import {fromHex} from "@lodestar/utils";
7
- import {IBeaconChain} from "../../../chain/index.js";
8
- import {IBeaconDb} from "../../../db/index.js";
9
- import {BLOB_SIDECARS_IN_WRAPPER_INDEX} from "../../../db/repositories/blobSidecars.js";
10
-
11
- export async function* onBlobSidecarsByRange(
12
- request: deneb.BlobSidecarsByRangeRequest,
13
- chain: IBeaconChain,
14
- db: IBeaconDb
15
- ): AsyncIterable<ResponseOutgoing> {
16
- // Non-finalized range of blobs
17
- const {startSlot, count} = validateBlobSidecarsByRangeRequest(chain.config, chain.clock.currentEpoch, request);
18
- const endSlot = startSlot + count;
19
-
20
- const finalized = db.blobSidecarsArchive;
21
- const unfinalized = db.blobSidecars;
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;
27
-
28
- // Finalized range of blobs
29
- if (startSlot <= archiveMaxSlot) {
30
- // Chain of blobs won't change
31
- for await (const {key, value: blobSideCarsBytesWrapped} of finalized.binaryEntriesStream({
32
- gte: startSlot,
33
- lt: Math.min(endSlot, archiveMaxSlot + 1),
34
- })) {
35
- yield* iterateBlobBytesFromWrapper(chain, blobSideCarsBytesWrapped, finalized.decodeKey(key));
36
- }
37
- }
38
-
39
- // Non-finalized range of blobs
40
- if (endSlot > archiveMaxSlot) {
41
- const headBlock = chain.forkChoice.getHead();
42
- const headRoot = headBlock.blockRoot;
43
- // TODO DENEB: forkChoice should mantain an array of canonical blocks, and change only on reorg
44
- const headChain = chain.forkChoice.getAllAncestorBlocks(headRoot, headBlock.payloadStatus);
45
- // `getAllAncestorBlocks` includes both the head and the previous-finalized boundary.
46
-
47
- // Iterate head chain with ascending block numbers
48
- for (let i = headChain.length - 1; i >= 0; i--) {
49
- const block = headChain[i];
50
-
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) {
54
- // Note: Here the forkChoice head may change due to a re-org, so the headChain reflects the canonical chain
55
- // at the time of the start of the request. Spec is clear the chain of blobs must be consistent, but on
56
- // re-org there's no need to abort the request
57
- // Spec: https://github.com/ethereum/consensus-specs/blob/a1e46d1ae47dd9d097725801575b46907c12a1f8/specs/eip4844/p2p-interface.md#blobssidecarsbyrange-v1
58
-
59
- const blobSideCarsBytesWrapped = await unfinalized.getBinary(fromHex(block.blockRoot));
60
- if (!blobSideCarsBytesWrapped) {
61
- // Handle the same to onBeaconBlocksByRange
62
- throw new ResponseError(RespStatus.SERVER_ERROR, `No item for root ${block.blockRoot} slot ${block.slot}`);
63
- }
64
- yield* iterateBlobBytesFromWrapper(chain, blobSideCarsBytesWrapped, block.slot);
65
- }
66
-
67
- // If block is after endSlot, stop iterating
68
- else if (block.slot >= endSlot) {
69
- break;
70
- }
71
- }
72
- }
73
- }
74
-
75
- export function* iterateBlobBytesFromWrapper(
76
- chain: IBeaconChain,
77
- blobSideCarsBytesWrapped: Uint8Array,
78
- blockSlot: Slot
79
- ): Iterable<ResponseOutgoing> {
80
- const allBlobSideCarsBytes = blobSideCarsBytesWrapped.slice(BLOB_SIDECARS_IN_WRAPPER_INDEX);
81
- const blobsLen = allBlobSideCarsBytes.length / BLOB_SIDECAR_FIXED_SIZE;
82
-
83
- for (let index = 0; index < blobsLen; index++) {
84
- const blobSideCarBytes = allBlobSideCarsBytes.slice(
85
- index * BLOB_SIDECAR_FIXED_SIZE,
86
- (index + 1) * BLOB_SIDECAR_FIXED_SIZE
87
- );
88
- if (blobSideCarBytes.length !== BLOB_SIDECAR_FIXED_SIZE) {
89
- throw new ResponseError(
90
- RespStatus.SERVER_ERROR,
91
- `Invalid blobSidecar index=${index} bytes length=${blobSideCarBytes.length} expected=${BLOB_SIDECAR_FIXED_SIZE} for slot ${blockSlot} blobsLen=${blobsLen}`
92
- );
93
- }
94
- yield {
95
- data: blobSideCarBytes,
96
- boundary: chain.config.getForkBoundaryAtEpoch(computeEpochAtSlot(blockSlot)),
97
- };
98
- }
99
- }
100
-
101
- export function validateBlobSidecarsByRangeRequest(
102
- config: ChainConfig,
103
- currentEpoch: Epoch,
104
- request: deneb.BlobSidecarsByRangeRequest
105
- ): deneb.BlobSidecarsByRangeRequest {
106
- const {startSlot} = request;
107
- let {count} = request;
108
-
109
- if (count < 1) {
110
- throw new ResponseError(RespStatus.INVALID_REQUEST, "count < 1");
111
- }
112
- if (startSlot < GENESIS_SLOT) {
113
- throw new ResponseError(RespStatus.INVALID_REQUEST, "startSlot < genesis");
114
- }
115
-
116
- // Spec: [max(current_epoch - MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS, DENEB_FORK_EPOCH), current_epoch]
117
- const minimumRequestEpoch = Math.max(
118
- currentEpoch - config.MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS,
119
- config.DENEB_FORK_EPOCH
120
- );
121
- if (computeEpochAtSlot(startSlot) < minimumRequestEpoch) {
122
- throw new ResponseError(
123
- RespStatus.RESOURCE_UNAVAILABLE,
124
- "startSlot is before MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS"
125
- );
126
- }
127
-
128
- if (count > config.MAX_REQUEST_BLOCKS_DENEB) {
129
- count = config.MAX_REQUEST_BLOCKS_DENEB;
130
- }
131
-
132
- return {startSlot, count};
133
- }
@@ -1,69 +0,0 @@
1
- import {BLOB_SIDECAR_FIXED_SIZE} from "@lodestar/params";
2
- import {RespStatus, ResponseError, ResponseOutgoing} from "@lodestar/reqresp";
3
- import {computeEpochAtSlot} from "@lodestar/state-transition";
4
- import {RootHex} from "@lodestar/types";
5
- import {toRootHex} from "@lodestar/utils";
6
- import {IBeaconChain} from "../../../chain/index.js";
7
- import {BlobSidecarsByRootRequest} from "../../../util/types.js";
8
-
9
- export async function* onBlobSidecarsByRoot(
10
- requestBody: BlobSidecarsByRootRequest,
11
- chain: IBeaconChain
12
- ): AsyncIterable<ResponseOutgoing> {
13
- const finalizedSlot = chain.forkChoice.getFinalizedBlock().slot;
14
-
15
- // Spec: [max(current_epoch - MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS, DENEB_FORK_EPOCH), current_epoch]
16
- const currentEpoch = chain.clock.currentEpoch;
17
- const minimumRequestEpoch = Math.max(
18
- currentEpoch - chain.config.MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS,
19
- chain.config.DENEB_FORK_EPOCH
20
- );
21
-
22
- // In sidecars by root request, it can be expected that sidecar requests will be come
23
- // clustured by blockroots, and this helps us save db lookups once we load sidecars
24
- // for a root
25
- let lastFetchedSideCars: {blockRoot: RootHex; bytes: Uint8Array} | null = null;
26
-
27
- for (const blobIdentifier of requestBody) {
28
- const {blockRoot, index} = blobIdentifier;
29
- const blockRootHex = toRootHex(blockRoot);
30
- const block = chain.forkChoice.getBlockHexDefaultStatus(blockRootHex);
31
-
32
- // NOTE: Only support non-finalized blocks.
33
- // SPEC: Clients MUST support requesting blocks and sidecars since the latest finalized epoch.
34
- // https://github.com/ethereum/consensus-specs/blob/11a037fd9227e29ee809c9397b09f8cc3383a8c0/specs/eip4844/p2p-interface.md#beaconblockandblobssidecarbyroot-v1
35
- if (!block || block.slot <= finalizedSlot) {
36
- continue;
37
- }
38
-
39
- if (computeEpochAtSlot(block.slot) < minimumRequestEpoch) {
40
- continue;
41
- }
42
-
43
- // Check if we need to load sidecars for a new block root
44
- if (lastFetchedSideCars === null || lastFetchedSideCars.blockRoot !== blockRootHex) {
45
- const blobSidecarsBytes = await chain.getSerializedBlobSidecars(block.slot, blockRootHex);
46
- if (!blobSidecarsBytes) {
47
- // Handle the same to onBeaconBlocksByRange
48
- throw new ResponseError(RespStatus.SERVER_ERROR, `No item for root ${block.blockRoot} slot ${block.slot}`);
49
- }
50
-
51
- lastFetchedSideCars = {blockRoot: blockRootHex, bytes: blobSidecarsBytes};
52
- }
53
-
54
- const blobSidecarBytes = lastFetchedSideCars.bytes.slice(
55
- index * BLOB_SIDECAR_FIXED_SIZE,
56
- (index + 1) * BLOB_SIDECAR_FIXED_SIZE
57
- );
58
- if (blobSidecarBytes.length !== BLOB_SIDECAR_FIXED_SIZE) {
59
- throw Error(
60
- `Inconsistent state, blobSidecar blockRoot=${blockRootHex} index=${index} blobSidecarBytes=${blobSidecarBytes.length} expected=${BLOB_SIDECAR_FIXED_SIZE}`
61
- );
62
- }
63
-
64
- yield {
65
- data: blobSidecarBytes,
66
- boundary: chain.config.getForkBoundaryAtEpoch(computeEpochAtSlot(block.slot)),
67
- };
68
- }
69
- }