@lodestar/beacon-node 1.51.0-dev.312812503e → 1.51.0-dev.36022cc5cb

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 (356) 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 -27
  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 +5 -2
  6. package/lib/api/impl/beacon/pool/index.js.map +1 -1
  7. package/lib/api/impl/beacon/state/utils.d.ts +1 -1
  8. package/lib/api/impl/beacon/state/utils.d.ts.map +1 -1
  9. package/lib/api/impl/validator/index.d.ts +6 -0
  10. package/lib/api/impl/validator/index.d.ts.map +1 -1
  11. package/lib/api/impl/validator/index.js +42 -26
  12. package/lib/api/impl/validator/index.js.map +1 -1
  13. package/lib/chain/GetBlobsTracker.d.ts +13 -2
  14. package/lib/chain/GetBlobsTracker.d.ts.map +1 -1
  15. package/lib/chain/GetBlobsTracker.js +85 -27
  16. package/lib/chain/GetBlobsTracker.js.map +1 -1
  17. package/lib/chain/archiveStore/archiveStore.d.ts.map +1 -1
  18. package/lib/chain/archiveStore/archiveStore.js +1 -0
  19. package/lib/chain/archiveStore/archiveStore.js.map +1 -1
  20. package/lib/chain/archiveStore/utils/archiveBlocks.d.ts +4 -0
  21. package/lib/chain/archiveStore/utils/archiveBlocks.d.ts.map +1 -1
  22. package/lib/chain/archiveStore/utils/archiveBlocks.js +61 -97
  23. package/lib/chain/archiveStore/utils/archiveBlocks.js.map +1 -1
  24. package/lib/chain/blocks/importBlock.d.ts.map +1 -1
  25. package/lib/chain/blocks/importBlock.js +21 -50
  26. package/lib/chain/blocks/importBlock.js.map +1 -1
  27. package/lib/chain/blocks/importExecutionPayload.d.ts +10 -11
  28. package/lib/chain/blocks/importExecutionPayload.d.ts.map +1 -1
  29. package/lib/chain/blocks/importExecutionPayload.js +32 -18
  30. package/lib/chain/blocks/importExecutionPayload.js.map +1 -1
  31. package/lib/chain/blocks/index.d.ts.map +1 -1
  32. package/lib/chain/blocks/index.js +4 -4
  33. package/lib/chain/blocks/index.js.map +1 -1
  34. package/lib/chain/blocks/payloadEnvelopeProcessor.d.ts +12 -9
  35. package/lib/chain/blocks/payloadEnvelopeProcessor.d.ts.map +1 -1
  36. package/lib/chain/blocks/payloadEnvelopeProcessor.js +24 -19
  37. package/lib/chain/blocks/payloadEnvelopeProcessor.js.map +1 -1
  38. package/lib/chain/blocks/types.d.ts +4 -1
  39. package/lib/chain/blocks/types.d.ts.map +1 -1
  40. package/lib/chain/blocks/verifyBlock.d.ts.map +1 -1
  41. package/lib/chain/blocks/verifyBlock.js +18 -7
  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 +8 -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/verifyBlocksSanityChecks.d.ts.map +1 -1
  49. package/lib/chain/blocks/verifyBlocksSanityChecks.js +4 -0
  50. package/lib/chain/blocks/verifyBlocksSanityChecks.js.map +1 -1
  51. package/lib/chain/blocks/verifyBlocksSignatures.d.ts.map +1 -1
  52. package/lib/chain/blocks/verifyBlocksSignatures.js +7 -5
  53. package/lib/chain/blocks/verifyBlocksSignatures.js.map +1 -1
  54. package/lib/chain/blocks/verifyPayloadsDataAvailability.d.ts +3 -3
  55. package/lib/chain/blocks/verifyPayloadsDataAvailability.d.ts.map +1 -1
  56. package/lib/chain/blocks/verifyPayloadsDataAvailability.js +11 -6
  57. package/lib/chain/blocks/verifyPayloadsDataAvailability.js.map +1 -1
  58. package/lib/chain/bls/interface.d.ts +2 -0
  59. package/lib/chain/bls/interface.d.ts.map +1 -1
  60. package/lib/chain/bls/multithread/index.d.ts.map +1 -1
  61. package/lib/chain/bls/multithread/index.js +13 -11
  62. package/lib/chain/bls/multithread/index.js.map +1 -1
  63. package/lib/chain/bls/multithread/types.d.ts +1 -1
  64. package/lib/chain/bls/multithread/types.d.ts.map +1 -1
  65. package/lib/chain/bls/multithread/worker.js +1 -1
  66. package/lib/chain/bls/multithread/worker.js.map +1 -1
  67. package/lib/chain/bls/singleThread.js +1 -1
  68. package/lib/chain/bls/singleThread.js.map +1 -1
  69. package/lib/chain/bls/utils.js +1 -1
  70. package/lib/chain/bls/utils.js.map +1 -1
  71. package/lib/chain/chain.d.ts +8 -2
  72. package/lib/chain/chain.d.ts.map +1 -1
  73. package/lib/chain/chain.js +57 -7
  74. package/lib/chain/chain.js.map +1 -1
  75. package/lib/chain/errors/blockError.d.ts +1 -1
  76. package/lib/chain/errors/blockError.d.ts.map +1 -1
  77. package/lib/chain/errors/blockError.js +1 -1
  78. package/lib/chain/errors/blockError.js.map +1 -1
  79. package/lib/chain/errors/executionPayloadEnvelope.d.ts +7 -0
  80. package/lib/chain/errors/executionPayloadEnvelope.d.ts.map +1 -1
  81. package/lib/chain/errors/executionPayloadEnvelope.js +1 -0
  82. package/lib/chain/errors/executionPayloadEnvelope.js.map +1 -1
  83. package/lib/chain/forkChoice/index.d.ts +11 -1
  84. package/lib/chain/forkChoice/index.d.ts.map +1 -1
  85. package/lib/chain/forkChoice/index.js +11 -0
  86. package/lib/chain/forkChoice/index.js.map +1 -1
  87. package/lib/chain/forkChoiceExecutionEngine.d.ts +53 -0
  88. package/lib/chain/forkChoiceExecutionEngine.d.ts.map +1 -0
  89. package/lib/chain/forkChoiceExecutionEngine.js +121 -0
  90. package/lib/chain/forkChoiceExecutionEngine.js.map +1 -0
  91. package/lib/chain/interface.d.ts +5 -5
  92. package/lib/chain/interface.d.ts.map +1 -1
  93. package/lib/chain/interface.js.map +1 -1
  94. package/lib/chain/opPools/aggregatedAttestationPool.d.ts.map +1 -1
  95. package/lib/chain/opPools/aggregatedAttestationPool.js +23 -10
  96. package/lib/chain/opPools/aggregatedAttestationPool.js.map +1 -1
  97. package/lib/chain/opPools/attestationPool.d.ts +1 -1
  98. package/lib/chain/opPools/attestationPool.d.ts.map +1 -1
  99. package/lib/chain/opPools/attestationPool.js +15 -4
  100. package/lib/chain/opPools/attestationPool.js.map +1 -1
  101. package/lib/chain/opPools/payloadAttestationPool.d.ts.map +1 -1
  102. package/lib/chain/opPools/payloadAttestationPool.js +17 -7
  103. package/lib/chain/opPools/payloadAttestationPool.js.map +1 -1
  104. package/lib/chain/opPools/syncCommitteeMessagePool.d.ts.map +1 -1
  105. package/lib/chain/opPools/syncCommitteeMessagePool.js +9 -3
  106. package/lib/chain/opPools/syncCommitteeMessagePool.js.map +1 -1
  107. package/lib/chain/opPools/syncContributionAndProofPool.d.ts.map +1 -1
  108. package/lib/chain/opPools/syncContributionAndProofPool.js +11 -3
  109. package/lib/chain/opPools/syncContributionAndProofPool.js.map +1 -1
  110. package/lib/chain/opPools/utils.d.ts +1 -1
  111. package/lib/chain/opPools/utils.d.ts.map +1 -1
  112. package/lib/chain/opPools/utils.js +1 -1
  113. package/lib/chain/opPools/utils.js.map +1 -1
  114. package/lib/chain/options.d.ts +0 -1
  115. package/lib/chain/options.d.ts.map +1 -1
  116. package/lib/chain/options.js +0 -1
  117. package/lib/chain/options.js.map +1 -1
  118. package/lib/chain/produceBlock/produceBlockBody.d.ts +3 -2
  119. package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
  120. package/lib/chain/produceBlock/produceBlockBody.js +1 -1
  121. package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
  122. package/lib/chain/regen/interface.d.ts +1 -1
  123. package/lib/chain/regen/interface.d.ts.map +1 -1
  124. package/lib/chain/regen/queued.d.ts +1 -1
  125. package/lib/chain/regen/queued.d.ts.map +1 -1
  126. package/lib/chain/regen/queued.js +5 -3
  127. package/lib/chain/regen/queued.js.map +1 -1
  128. package/lib/chain/validation/executionPayloadBid.js +13 -13
  129. package/lib/chain/validation/executionPayloadBid.js.map +1 -1
  130. package/lib/chain/validation/executionPayloadEnvelope.d.ts +6 -0
  131. package/lib/chain/validation/executionPayloadEnvelope.d.ts.map +1 -1
  132. package/lib/chain/validation/executionPayloadEnvelope.js +53 -0
  133. package/lib/chain/validation/executionPayloadEnvelope.js.map +1 -1
  134. package/lib/db/beacon.d.ts +7 -0
  135. package/lib/db/beacon.d.ts.map +1 -1
  136. package/lib/db/beacon.js +34 -0
  137. package/lib/db/beacon.js.map +1 -1
  138. package/lib/db/dataColumnStore.d.ts +1 -1
  139. package/lib/db/dataColumnStore.d.ts.map +1 -1
  140. package/lib/db/dataColumnStore.js +1 -4
  141. package/lib/db/dataColumnStore.js.map +1 -1
  142. package/lib/db/flatFileStore/flatFileStore.js +5 -5
  143. package/lib/db/flatFileStore/flatFileStore.js.map +1 -1
  144. package/lib/db/flatFileStore/slotIndex.d.ts.map +1 -1
  145. package/lib/db/flatFileStore/slotIndex.js +2 -2
  146. package/lib/db/flatFileStore/slotIndex.js.map +1 -1
  147. package/lib/db/interface.d.ts +1 -0
  148. package/lib/db/interface.d.ts.map +1 -1
  149. package/lib/db/repositories/dataColumnSidecarArchive.d.ts +6 -0
  150. package/lib/db/repositories/dataColumnSidecarArchive.d.ts.map +1 -1
  151. package/lib/db/repositories/dataColumnSidecarArchive.js +19 -0
  152. package/lib/db/repositories/dataColumnSidecarArchive.js.map +1 -1
  153. package/lib/execution/builder/apiClient.d.ts +14 -8
  154. package/lib/execution/builder/apiClient.d.ts.map +1 -1
  155. package/lib/execution/builder/apiClient.js +12 -10
  156. package/lib/execution/builder/apiClient.js.map +1 -1
  157. package/lib/execution/builder/http.d.ts +2 -0
  158. package/lib/execution/builder/http.d.ts.map +1 -1
  159. package/lib/execution/builder/http.js +2 -0
  160. package/lib/execution/builder/http.js.map +1 -1
  161. package/lib/execution/engine/http.d.ts +2 -2
  162. package/lib/execution/engine/http.d.ts.map +1 -1
  163. package/lib/execution/engine/http.js +5 -4
  164. package/lib/execution/engine/http.js.map +1 -1
  165. package/lib/execution/engine/index.d.ts +1 -1
  166. package/lib/execution/engine/index.d.ts.map +1 -1
  167. package/lib/execution/engine/index.js +1 -1
  168. package/lib/execution/engine/index.js.map +1 -1
  169. package/lib/execution/engine/interface.d.ts +17 -3
  170. package/lib/execution/engine/interface.d.ts.map +1 -1
  171. package/lib/execution/engine/interface.js.map +1 -1
  172. package/lib/execution/engine/jsonRpcTransport.d.ts +2 -2
  173. package/lib/execution/engine/jsonRpcTransport.d.ts.map +1 -1
  174. package/lib/execution/engine/jsonRpcTransport.js +1 -1
  175. package/lib/execution/engine/jsonRpcTransport.js.map +1 -1
  176. package/lib/execution/engine/restTransport.d.ts +2 -2
  177. package/lib/execution/engine/restTransport.d.ts.map +1 -1
  178. package/lib/execution/engine/restTransport.js.map +1 -1
  179. package/lib/execution/engine/transport.d.ts +1 -12
  180. package/lib/execution/engine/transport.d.ts.map +1 -1
  181. package/lib/execution/engine/types.d.ts.map +1 -1
  182. package/lib/execution/engine/types.js +2 -2
  183. package/lib/execution/engine/types.js.map +1 -1
  184. package/lib/execution/engine/utils.d.ts.map +1 -1
  185. package/lib/execution/engine/utils.js +3 -2
  186. package/lib/execution/engine/utils.js.map +1 -1
  187. package/lib/index.d.ts +1 -0
  188. package/lib/index.d.ts.map +1 -1
  189. package/lib/index.js +2 -0
  190. package/lib/index.js.map +1 -1
  191. package/lib/metrics/metrics/lodestar.d.ts +4 -0
  192. package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
  193. package/lib/metrics/metrics/lodestar.js +10 -0
  194. package/lib/metrics/metrics/lodestar.js.map +1 -1
  195. package/lib/metrics/server/http.js +5 -5
  196. package/lib/metrics/server/http.js.map +1 -1
  197. package/lib/monitoring/service.js +1 -1
  198. package/lib/monitoring/service.js.map +1 -1
  199. package/lib/network/core/networkCore.d.ts +2 -0
  200. package/lib/network/core/networkCore.d.ts.map +1 -1
  201. package/lib/network/core/networkCore.js +3 -0
  202. package/lib/network/core/networkCore.js.map +1 -1
  203. package/lib/network/core/networkCoreWorker.js +1 -0
  204. package/lib/network/core/networkCoreWorker.js.map +1 -1
  205. package/lib/network/core/networkCoreWorkerHandler.d.ts +2 -0
  206. package/lib/network/core/networkCoreWorkerHandler.d.ts.map +1 -1
  207. package/lib/network/core/networkCoreWorkerHandler.js +3 -0
  208. package/lib/network/core/networkCoreWorkerHandler.js.map +1 -1
  209. package/lib/network/core/types.d.ts +2 -0
  210. package/lib/network/core/types.d.ts.map +1 -1
  211. package/lib/network/gossip/gossipsub.d.ts +1 -0
  212. package/lib/network/gossip/gossipsub.d.ts.map +1 -1
  213. package/lib/network/gossip/gossipsub.js +10 -0
  214. package/lib/network/gossip/gossipsub.js.map +1 -1
  215. package/lib/network/interface.d.ts +2 -0
  216. package/lib/network/interface.d.ts.map +1 -1
  217. package/lib/network/libp2p/index.d.ts.map +1 -1
  218. package/lib/network/libp2p/index.js +5 -1
  219. package/lib/network/libp2p/index.js.map +1 -1
  220. package/lib/network/network.d.ts +4 -1
  221. package/lib/network/network.d.ts.map +1 -1
  222. package/lib/network/network.js +45 -15
  223. package/lib/network/network.js.map +1 -1
  224. package/lib/network/options.d.ts +2 -0
  225. package/lib/network/options.d.ts.map +1 -1
  226. package/lib/network/options.js.map +1 -1
  227. package/lib/network/peers/peerManager.d.ts +2 -1
  228. package/lib/network/peers/peerManager.d.ts.map +1 -1
  229. package/lib/network/peers/peerManager.js +28 -1
  230. package/lib/network/peers/peerManager.js.map +1 -1
  231. package/lib/network/peers/utils/assertPeerRelevance.d.ts +9 -1
  232. package/lib/network/peers/utils/assertPeerRelevance.d.ts.map +1 -1
  233. package/lib/network/peers/utils/assertPeerRelevance.js +32 -21
  234. package/lib/network/peers/utils/assertPeerRelevance.js.map +1 -1
  235. package/lib/network/peers/utils/prioritizePeers.d.ts +4 -1
  236. package/lib/network/peers/utils/prioritizePeers.d.ts.map +1 -1
  237. package/lib/network/peers/utils/prioritizePeers.js +8 -16
  238. package/lib/network/peers/utils/prioritizePeers.js.map +1 -1
  239. package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
  240. package/lib/network/processor/gossipHandlers.js +33 -19
  241. package/lib/network/processor/gossipHandlers.js.map +1 -1
  242. package/lib/network/processor/index.d.ts +6 -0
  243. package/lib/network/processor/index.d.ts.map +1 -1
  244. package/lib/network/processor/index.js +29 -3
  245. package/lib/network/processor/index.js.map +1 -1
  246. package/lib/node/nodejs.d.ts +3 -1
  247. package/lib/node/nodejs.d.ts.map +1 -1
  248. package/lib/node/nodejs.js +47 -21
  249. package/lib/node/nodejs.js.map +1 -1
  250. package/lib/node/options.d.ts +3 -1
  251. package/lib/node/options.d.ts.map +1 -1
  252. package/lib/node/options.js +4 -2
  253. package/lib/node/options.js.map +1 -1
  254. package/lib/sync/interface.d.ts.map +1 -1
  255. package/lib/sync/interface.js.map +1 -1
  256. package/lib/sync/sync.d.ts +7 -0
  257. package/lib/sync/sync.d.ts.map +1 -1
  258. package/lib/sync/sync.js +61 -3
  259. package/lib/sync/sync.js.map +1 -1
  260. package/lib/util/execution.d.ts +4 -4
  261. package/lib/util/execution.d.ts.map +1 -1
  262. package/lib/util/execution.js.map +1 -1
  263. package/lib/util/file.d.ts.map +1 -1
  264. package/lib/util/file.js +8 -9
  265. package/lib/util/file.js.map +1 -1
  266. package/lib/util/queue/itemQueue.js +1 -1
  267. package/lib/util/queue/itemQueue.js.map +1 -1
  268. package/lib/util/sszBytes.d.ts +5 -0
  269. package/lib/util/sszBytes.d.ts.map +1 -1
  270. package/lib/util/sszBytes.js +35 -2
  271. package/lib/util/sszBytes.js.map +1 -1
  272. package/package.json +16 -17
  273. package/src/api/impl/beacon/blocks/index.ts +35 -45
  274. package/src/api/impl/beacon/pool/index.ts +5 -1
  275. package/src/api/impl/beacon/state/utils.ts +1 -1
  276. package/src/api/impl/validator/index.ts +47 -30
  277. package/src/chain/GetBlobsTracker.ts +99 -40
  278. package/src/chain/archiveStore/archiveStore.ts +1 -0
  279. package/src/chain/archiveStore/utils/archiveBlocks.ts +76 -130
  280. package/src/chain/blocks/importBlock.ts +40 -71
  281. package/src/chain/blocks/importExecutionPayload.ts +55 -34
  282. package/src/chain/blocks/index.ts +11 -4
  283. package/src/chain/blocks/payloadEnvelopeProcessor.ts +35 -24
  284. package/src/chain/blocks/types.ts +4 -1
  285. package/src/chain/blocks/verifyBlock.ts +31 -16
  286. package/src/chain/blocks/verifyBlocksDataAvailability.ts +10 -1
  287. package/src/chain/blocks/verifyBlocksExecutionPayloads.ts +1 -1
  288. package/src/chain/blocks/verifyBlocksSanityChecks.ts +4 -1
  289. package/src/chain/blocks/verifyBlocksSignatures.ts +7 -5
  290. package/src/chain/blocks/verifyPayloadsDataAvailability.ts +14 -6
  291. package/src/chain/bls/interface.ts +2 -0
  292. package/src/chain/bls/multithread/index.ts +14 -10
  293. package/src/chain/bls/multithread/types.ts +1 -1
  294. package/src/chain/bls/multithread/worker.ts +1 -5
  295. package/src/chain/bls/singleThread.ts +1 -1
  296. package/src/chain/bls/utils.ts +1 -1
  297. package/src/chain/chain.ts +67 -8
  298. package/src/chain/errors/blockError.ts +1 -1
  299. package/src/chain/errors/executionPayloadEnvelope.ts +8 -0
  300. package/src/chain/forkChoice/index.ts +11 -0
  301. package/src/chain/forkChoiceExecutionEngine.ts +197 -0
  302. package/src/chain/interface.ts +5 -5
  303. package/src/chain/opPools/aggregatedAttestationPool.ts +25 -9
  304. package/src/chain/opPools/attestationPool.ts +16 -4
  305. package/src/chain/opPools/payloadAttestationPool.ts +18 -7
  306. package/src/chain/opPools/syncCommitteeMessagePool.ts +10 -3
  307. package/src/chain/opPools/syncContributionAndProofPool.ts +13 -3
  308. package/src/chain/opPools/utils.ts +1 -1
  309. package/src/chain/options.ts +0 -2
  310. package/src/chain/produceBlock/produceBlockBody.ts +4 -2
  311. package/src/chain/regen/interface.ts +1 -1
  312. package/src/chain/regen/queued.ts +6 -4
  313. package/src/chain/validation/executionPayloadBid.ts +14 -13
  314. package/src/chain/validation/executionPayloadEnvelope.ts +68 -1
  315. package/src/db/beacon.ts +44 -0
  316. package/src/db/dataColumnStore.ts +2 -4
  317. package/src/db/flatFileStore/flatFileStore.ts +7 -7
  318. package/src/db/flatFileStore/slotIndex.ts +4 -3
  319. package/src/db/interface.ts +2 -0
  320. package/src/db/repositories/dataColumnSidecarArchive.ts +20 -0
  321. package/src/execution/builder/apiClient.ts +16 -13
  322. package/src/execution/builder/http.ts +4 -0
  323. package/src/execution/engine/http.ts +12 -13
  324. package/src/execution/engine/index.ts +1 -1
  325. package/src/execution/engine/interface.ts +19 -3
  326. package/src/execution/engine/jsonRpcTransport.ts +10 -2
  327. package/src/execution/engine/restTransport.ts +3 -1
  328. package/src/execution/engine/transport.ts +8 -14
  329. package/src/execution/engine/types.ts +3 -1
  330. package/src/execution/engine/utils.ts +4 -2
  331. package/src/index.ts +2 -0
  332. package/src/metrics/metrics/lodestar.ts +10 -0
  333. package/src/metrics/server/http.ts +5 -5
  334. package/src/monitoring/service.ts +1 -1
  335. package/src/network/core/networkCore.ts +5 -0
  336. package/src/network/core/networkCoreWorker.ts +1 -0
  337. package/src/network/core/networkCoreWorkerHandler.ts +4 -0
  338. package/src/network/core/types.ts +2 -0
  339. package/src/network/gossip/gossipsub.ts +11 -0
  340. package/src/network/interface.ts +2 -0
  341. package/src/network/libp2p/index.ts +5 -1
  342. package/src/network/network.ts +45 -19
  343. package/src/network/options.ts +2 -0
  344. package/src/network/peers/peerManager.ts +28 -3
  345. package/src/network/peers/utils/assertPeerRelevance.ts +39 -23
  346. package/src/network/peers/utils/prioritizePeers.ts +14 -22
  347. package/src/network/processor/gossipHandlers.ts +38 -21
  348. package/src/network/processor/index.ts +25 -3
  349. package/src/node/nodejs.ts +58 -22
  350. package/src/node/options.ts +9 -6
  351. package/src/sync/interface.ts +1 -0
  352. package/src/sync/sync.ts +65 -4
  353. package/src/util/execution.ts +6 -6
  354. package/src/util/file.ts +8 -9
  355. package/src/util/queue/itemQueue.ts +1 -1
  356. package/src/util/sszBytes.ts +42 -2
@@ -17,6 +17,7 @@ import {
17
17
  PayloadAttestationError,
18
18
  PayloadAttestationErrorCode,
19
19
  SyncCommitteeError,
20
+ SyncCommitteeErrorCode,
20
21
  } from "../../../../chain/errors/index.js";
21
22
  import {validateApiAttesterSlashing} from "../../../../chain/validation/attesterSlashing.js";
22
23
  import {validateApiBlsToExecutionChange} from "../../../../chain/validation/blsToExecutionChange.js";
@@ -340,7 +341,10 @@ export function getBeaconPoolApi({
340
341
  const synCommittee = state.getIndexedSyncCommittee(signature.slot);
341
342
  const indexesInCommittee = synCommittee.validatorIndexMap.get(signature.validatorIndex);
342
343
  if (indexesInCommittee === undefined || indexesInCommittee.length === 0) {
343
- return; // Not a sync committee member
344
+ throw new SyncCommitteeError(GossipAction.REJECT, {
345
+ code: SyncCommitteeErrorCode.VALIDATOR_NOT_IN_SYNC_COMMITTEE,
346
+ validatorIndex: signature.validatorIndex,
347
+ });
344
348
  }
345
349
 
346
350
  // Verify signature only, all other data is very likely to be correct, since the `signature` object is created by this node.
@@ -1,6 +1,6 @@
1
- import {type PubkeyCache} from "@chainsafe/lodestar-z/pubkeys";
2
1
  import {routes} from "@lodestar/api";
3
2
  import {CheckpointWithHex, IForkChoice} from "@lodestar/fork-choice";
3
+ import {type PubkeyCache} from "@lodestar/native/pubkeys";
4
4
  import {GENESIS_SLOT} from "@lodestar/params";
5
5
  import {IBeaconStateView, IBeaconStateViewGloas} from "@lodestar/state-transition";
6
6
  import {
@@ -94,7 +94,7 @@ import {
94
94
  import {validateGossipProposerPreferences} from "../../../chain/validation/proposerPreferences.js";
95
95
  import {validateSyncCommitteeGossipContributionAndProof} from "../../../chain/validation/syncCommitteeContributionAndProof.js";
96
96
  import {ZERO_HASH} from "../../../constants/index.js";
97
- import {BUILDER_BID_DEADLINE_MS, BuilderApiBid, decodeBuilderUrl} from "../../../execution/builder/apiClient.js";
97
+ import {BuilderApiBid, decodeBuilderUrl} from "../../../execution/builder/apiClient.js";
98
98
  import {BuilderStatus, NoBidReceived} from "../../../execution/builder/http.js";
99
99
  import {getBuilderBidTotalGwei, validateBuilderApiExecutionPayloadBid} from "../../../execution/builder/validateBid.js";
100
100
  import {validateGossipFnRetryUnknownRoot} from "../../../network/processor/gossipHandlers.js";
@@ -123,10 +123,14 @@ import {
123
123
  * A cutoff of 1667 BPS (2 seconds for 12s slots) gives enough time and if there are unexpected delays
124
124
  * it ensures we publish in time as proposals after the attestation deadline will likely be orphaned
125
125
  * due to proposer boost reorg.
126
- *
127
- * TODO GLOAS: re-evaluate cutoff timing due to attestation deadline changes in gloas
128
126
  */
129
127
  const BLOCK_PRODUCTION_RACE_CUTOFF_BPS = 1667;
128
+ /**
129
+ * Post-gloas cutoff, kept at 1667 BPS (2 seconds for 12s slots) for now.
130
+ *
131
+ * TODO GLOAS: revisit, the block propagates faster as it only commits to a bid and the attestation deadline changed
132
+ */
133
+ export const BLOCK_PRODUCTION_RACE_CUTOFF_GLOAS_BPS = 1667;
130
134
  /** Rejection message of the bid block branch when there is no viable bid to commit to */
131
135
  const NO_BID_AVAILABLE = "No builder bid available";
132
136
 
@@ -1005,33 +1009,50 @@ export function getValidatorApi(
1005
1009
  (!circuitBreakerActive &&
1006
1010
  chain.executionPayloadBidPool.getBestBid(slot, bidParentBlockHash, parentBlockRootHex) !== null);
1007
1011
 
1008
- // Select the p2p bid once builders had time to bid up, matching the deadline advertised
1009
- // on builder API bid requests, unless the circuit breaker is active
1010
- const p2pBidPromise: Promise<PooledExecutionPayloadBid | null> = circuitBreakerActive
1011
- ? Promise.resolve(null)
1012
- : sleep(Math.max(0, BUILDER_BID_DEADLINE_MS - chain.clock.msFromSlot(slot))).then(() => {
1013
- const p2pBid = chain.executionPayloadBidPool.getBestBid(slot, bidParentBlockHash, parentBlockRootHex);
1014
- // Discard p2p bids below the proposer's configured floor on the total payment.
1015
- // A p2p bid's total is just its value since gossip validation enforces executionPayment=0.
1016
- if (p2pBid !== null && BigInt(p2pBid.signedBid.message.value) < builderConfig.minBid) {
1017
- logger.info("Best p2p bid below configured minimum", {
1018
- slot,
1019
- bidValue: prettyGweiToEth(p2pBid.signedBid.message.value),
1020
- minBid: prettyGweiToEth(builderConfig.minBid),
1021
- });
1022
- return null;
1023
- }
1024
- return p2pBid;
1025
- });
1012
+ // Calculate cutoff time based on start of the slot, ensures a slow local payload build does
1013
+ // not delay the proposal when a builder bid block is available (and vice versa)
1014
+ const cutoffMs = Math.max(
1015
+ 0,
1016
+ config.getSlotComponentDurationMs(fork, BLOCK_PRODUCTION_RACE_CUTOFF_GLOAS_BPS) - chain.clock.msFromSlot(slot)
1017
+ );
1018
+
1019
+ // Give p2p bids the same time to bid up as granted to builder API bid requests via the advertised
1020
+ // deadline, the pool is read once the deadline passed and the bid requests settled. A late request
1021
+ // does not wait past the race cutoff, a pooled bid is still the fastest fallback if the local block fails
1022
+ const bidDeadlinePromise = circuitBreakerActive
1023
+ ? Promise.resolve()
1024
+ : sleep(Math.min(chain.builderApiClient.bidDeadline, cutoffMs));
1026
1025
 
1027
1026
  // Candidates are ranked by their boosted counted total payment, the p2p bid is governed
1028
1027
  // by the top-level factors and each builder API bid by its own entry. Ties prefer the
1029
1028
  // earliest received builder API bid, so the signed block can be routed back to its
1030
1029
  // builder directly.
1031
1030
  const bestBidPromise: Promise<BidCandidate | null> = (async () => {
1032
- const [builderApiBids, p2pBid] = await Promise.all([builderApiBidsPromise, p2pBidPromise]);
1031
+ // Past the race cutoff a pooled p2p bid is used right away rather than waiting for pending
1032
+ // builder API requests, the local block is selected at the cutoff anyway if it is ready
1033
+ let [builderApiBids] = await Promise.all([
1034
+ Promise.race([builderApiBidsPromise, sleep(cutoffMs).then(() => null)]),
1035
+ bidDeadlinePromise,
1036
+ ]);
1033
1037
  let parentExecutionRequestsPromise: Promise<gloas.ExecutionRequests> | null = null;
1034
1038
 
1039
+ let p2pBid: PooledExecutionPayloadBid | null = circuitBreakerActive
1040
+ ? null
1041
+ : chain.executionPayloadBidPool.getBestBid(slot, bidParentBlockHash, parentBlockRootHex);
1042
+ // Discard p2p bids below the proposer's configured floor on the total payment.
1043
+ // A p2p bid's total is just its value since gossip validation enforces executionPayment=0.
1044
+ if (p2pBid !== null && BigInt(p2pBid.signedBid.message.value) < builderConfig.minBid) {
1045
+ logger.info("Best p2p bid below configured minimum", {
1046
+ slot,
1047
+ bidValue: prettyGweiToEth(p2pBid.signedBid.message.value),
1048
+ minBid: prettyGweiToEth(builderConfig.minBid),
1049
+ });
1050
+ p2pBid = null;
1051
+ }
1052
+ if (builderApiBids === null) {
1053
+ builderApiBids = p2pBid !== null ? [] : await builderApiBidsPromise;
1054
+ }
1055
+
1035
1056
  const candidates = (
1036
1057
  await Promise.all(
1037
1058
  builderApiBids.map(async ({url, entry, signedBid, receivedMs}): Promise<BidCandidate | null> => {
@@ -1118,13 +1139,6 @@ export function getValidatorApi(
1118
1139
  return fn().finally(() => t?.({source}));
1119
1140
  };
1120
1141
 
1121
- // Calculate cutoff time based on start of the slot, ensures a slow local payload build does
1122
- // not delay the proposal when a builder bid block is available (and vice versa)
1123
- const cutoffMs = Math.max(
1124
- 0,
1125
- config.getSlotComponentDurationMs(fork, BLOCK_PRODUCTION_RACE_CUTOFF_BPS) - chain.clock.msFromSlot(slot)
1126
- );
1127
-
1128
1142
  // use abort controller to stop waiting for the bid block if the engine block will be selected
1129
1143
  const controller = new AbortController();
1130
1144
 
@@ -1756,7 +1770,10 @@ export function getValidatorApi(
1756
1770
  }
1757
1771
  }
1758
1772
 
1759
- const dependentRoot = fromHex(state.getShufflingDecisionRoot(epoch));
1773
+ // The fork epoch PTC is computed at the fork from effective balances updated at the end of the
1774
+ // last pre-fork epoch, so its dependent root is one epoch later than for other epochs
1775
+ const dependentRootEpoch = epoch === config.GLOAS_FORK_EPOCH ? epoch + 1 : epoch;
1776
+ const dependentRoot = fromHex(state.getShufflingDecisionRoot(dependentRootEpoch));
1760
1777
 
1761
1778
  return {
1762
1779
  data: duties,
@@ -1,10 +1,9 @@
1
1
  import {ChainForkConfig} from "@lodestar/config";
2
2
  import {computeEpochAtSlot} from "@lodestar/state-transition";
3
- import {Logger} from "@lodestar/utils";
3
+ import {Logger, pruneSetToMax} from "@lodestar/utils";
4
4
  import {BLOB_AND_PROOF_V2_RPC_BYTES} from "../execution/engine/types.js";
5
5
  import {IExecutionEngine} from "../execution/index.js";
6
6
  import {Metrics} from "../metrics/metrics.js";
7
- import {callInNextEventLoop} from "../util/eventLoop.js";
8
7
  import {
9
8
  DataColumnEngineResult,
10
9
  getBlobSidecarsFromExecution,
@@ -14,9 +13,14 @@ import {IBlockInput, isBlockInputBlobs} from "./blocks/blockInput/index.js";
14
13
  import {PayloadEnvelopeInput} from "./blocks/payloadEnvelopeInput/index.js";
15
14
  import {ChainEventEmitter} from "./emitter.js";
16
15
 
16
+ /** A `null` answer only changes if the EL receives the transactions later, so retries are few and spaced out */
17
+ export const MAX_GET_BLOBS_ATTEMPTS = 3;
18
+ export const GET_BLOBS_RETRY_INTERVAL_MS = 1000;
19
+ const MAX_TRACKED_BLOCK_ROOTS = 64;
20
+
17
21
  export type GetBlobsTrackerInit = {
18
22
  logger: Logger;
19
- executionEngine: IExecutionEngine;
23
+ executionEngine: Pick<IExecutionEngine, "getBlobs">;
20
24
  emitter: ChainEventEmitter;
21
25
  metrics: Metrics | null;
22
26
  config: ChainForkConfig;
@@ -27,11 +31,13 @@ export type GetBlobsTrackerInit = {
27
31
  */
28
32
  export class GetBlobsTracker {
29
33
  logger: Logger;
30
- executionEngine: IExecutionEngine;
34
+ executionEngine: Pick<IExecutionEngine, "getBlobs">;
31
35
  emitter: ChainEventEmitter;
32
36
  metrics: Metrics | null;
33
37
  config: ChainForkConfig;
34
38
  activeReconstructions = new Set<string>();
39
+ failedAttempts = new Map<string, {count: number; lastAttemptMs: number; retryTimer?: NodeJS.Timeout}>();
40
+ pendingTriggers = new Set<string>();
35
41
  // Preallocate buffers for getBlobsV2 RPC calls
36
42
  // See https://github.com/ChainSafe/lodestar/pull/8282 for context
37
43
  blobsAndProofsBuffers: {buffers: Uint8Array[]; inUse: boolean}[] = [];
@@ -46,23 +52,55 @@ export class GetBlobsTracker {
46
52
 
47
53
  triggerGetBlobs(input: IBlockInput | PayloadEnvelopeInput): void {
48
54
  if (this.activeReconstructions.has(input.blockRootHex)) {
55
+ this.pendingTriggers.add(input.blockRootHex);
49
56
  return;
50
57
  }
51
58
 
59
+ const failed = this.failedAttempts.get(input.blockRootHex);
60
+ if (failed) {
61
+ if (failed.count >= MAX_GET_BLOBS_ATTEMPTS) {
62
+ return;
63
+ }
64
+ const waitMs = GET_BLOBS_RETRY_INTERVAL_MS - (Date.now() - failed.lastAttemptMs);
65
+ if (waitMs > 0) {
66
+ // Columns tend to arrive in one burst, so keep a single trailing retry instead of relying on a later trigger
67
+ failed.retryTimer ??= setTimeout(() => {
68
+ failed.retryTimer = undefined;
69
+ if (this.failedAttempts.get(input.blockRootHex) === failed && !input.hasAllData()) {
70
+ this.triggerGetBlobs(input);
71
+ }
72
+ }, waitMs).unref();
73
+ return;
74
+ }
75
+ }
76
+
77
+ // The request is sent right away, before block processing issues newPayload: ELs that drop a
78
+ // transaction's blobs once the payload is validated can only answer a request that gets there first
52
79
  if (!(input instanceof PayloadEnvelopeInput) && isBlockInputBlobs(input)) {
53
80
  // there is not preallocation for blob sidecars like there is for columns sidecars so no need to
54
81
  // store the index for the preallocated buffers
55
82
  this.activeReconstructions.add(input.blockRootHex);
56
- callInNextEventLoop(() => {
57
- const logCtx = {slot: input.slot, root: input.blockRootHex};
58
- this.logger.verbose("Trigger getBlobsV1 for block", logCtx);
59
- getBlobSidecarsFromExecution(this.config, this.executionEngine, this.metrics, this.emitter, input).finally(
60
- () => {
61
- this.logger.verbose("Completed getBlobsV1 for block", logCtx);
62
- this.activeReconstructions.delete(input.blockRootHex);
83
+ const logCtx = {slot: input.slot, root: input.blockRootHex};
84
+ this.logger.verbose("Trigger getBlobsV1 for block", logCtx);
85
+ let requestFailed = false;
86
+ getBlobSidecarsFromExecution(this.config, this.executionEngine, this.metrics, this.emitter, input)
87
+ .then(() => {
88
+ // EL errors and misses are handled inside the helper, blobs still missing means the attempt failed
89
+ if (!input.hasAllData()) {
90
+ requestFailed = true;
91
+ this.recordFailedAttempt(input.blockRootHex);
63
92
  }
64
- );
65
- });
93
+ })
94
+ .catch((error) => {
95
+ this.logger.debug("Error during getBlobsV1 for block", logCtx, error as Error);
96
+ requestFailed = true;
97
+ this.recordFailedAttempt(input.blockRootHex);
98
+ })
99
+ .finally(() => {
100
+ this.logger.verbose("Completed getBlobsV1 for block", logCtx);
101
+ this.activeReconstructions.delete(input.blockRootHex);
102
+ this.retryPendingTrigger(input, requestFailed);
103
+ });
66
104
 
67
105
  return;
68
106
  }
@@ -83,34 +121,55 @@ export class GetBlobsTracker {
83
121
  }
84
122
  timer?.();
85
123
 
86
- // We don't care about the outcome of this call,
87
- // just that it has been triggered for this block root.
88
124
  this.activeReconstructions.add(input.blockRootHex);
89
125
  this.blobsAndProofsBuffers[freeIndex].inUse = true;
90
- callInNextEventLoop(() => {
91
- const logCtx = {slot: input.slot, root: input.blockRootHex};
92
- this.logger.verbose("Trigger getBlobsV2 for block", logCtx);
93
- getDataColumnSidecarsFromExecution(
94
- this.config,
95
- this.executionEngine,
96
- this.emitter,
97
- input,
98
- this.metrics,
99
- this.blobsAndProofsBuffers[freeIndex].buffers
100
- )
101
- .then((result) => {
102
- this.logger.debug("getBlobsV2 result for block", {...logCtx, result});
103
- this.metrics?.dataColumns.dataColumnEngineResult.inc({result});
104
- })
105
- .catch((error) => {
106
- this.logger.debug("Error during getBlobsV2 for block", logCtx, error as Error);
107
- this.metrics?.dataColumns.dataColumnEngineResult.inc({result: DataColumnEngineResult.Failed});
108
- })
109
- .finally(() => {
110
- this.logger.verbose("Completed getBlobsV2 for block", logCtx);
111
- this.activeReconstructions.delete(input.blockRootHex);
112
- this.blobsAndProofsBuffers[freeIndex].inUse = false;
113
- });
114
- });
126
+ const logCtx = {slot: input.slot, root: input.blockRootHex};
127
+ this.logger.verbose("Trigger getBlobsV2 for block", logCtx);
128
+ let requestFailed = false;
129
+ getDataColumnSidecarsFromExecution(
130
+ this.config,
131
+ this.executionEngine,
132
+ this.emitter,
133
+ input,
134
+ this.metrics,
135
+ this.blobsAndProofsBuffers[freeIndex].buffers
136
+ )
137
+ .then((result) => {
138
+ this.logger.debug("getBlobsV2 result for block", {...logCtx, result});
139
+ this.metrics?.dataColumns.dataColumnEngineResult.inc({result});
140
+ if (result === DataColumnEngineResult.NullResponse) {
141
+ requestFailed = true;
142
+ this.recordFailedAttempt(input.blockRootHex);
143
+ }
144
+ })
145
+ .catch((error) => {
146
+ this.logger.debug("Error during getBlobsV2 for block", logCtx, error as Error);
147
+ this.metrics?.dataColumns.dataColumnEngineResult.inc({result: DataColumnEngineResult.Failed});
148
+ requestFailed = true;
149
+ this.recordFailedAttempt(input.blockRootHex);
150
+ })
151
+ .finally(() => {
152
+ this.logger.verbose("Completed getBlobsV2 for block", logCtx);
153
+ this.activeReconstructions.delete(input.blockRootHex);
154
+ this.blobsAndProofsBuffers[freeIndex].inUse = false;
155
+ this.retryPendingTrigger(input, requestFailed);
156
+ });
157
+ }
158
+
159
+ private retryPendingTrigger(input: IBlockInput | PayloadEnvelopeInput, requestFailed: boolean): void {
160
+ // Triggers dropped while the request was in flight re-enter once it failed, the attempt that was just
161
+ // recorded makes this arm the trailing retry instead of sending another request right away.
162
+ // Post-gloas only the bid triggers a request, so every failed attempt re-enters to arm its own retry
163
+ const hadPendingTrigger = this.pendingTriggers.delete(input.blockRootHex);
164
+ if (requestFailed && (hadPendingTrigger || input instanceof PayloadEnvelopeInput)) {
165
+ this.triggerGetBlobs(input);
166
+ }
167
+ }
168
+
169
+ private recordFailedAttempt(blockRootHex: string): void {
170
+ const failed = this.failedAttempts.get(blockRootHex);
171
+ clearTimeout(failed?.retryTimer);
172
+ this.failedAttempts.set(blockRootHex, {count: (failed?.count ?? 0) + 1, lastAttemptMs: Date.now()});
173
+ pruneSetToMax(this.failedAttempts, MAX_TRACKED_BLOCK_ROOTS);
115
174
  }
116
175
  }
@@ -197,6 +197,7 @@ export class ArchiveStore {
197
197
  //
198
198
  // `jobQueue.push()` can throw synchronously (queue aborted / full) or reject asynchronously;
199
199
  // awaiting it inside the deferred callback funnels both failure modes into the one catch.
200
+ // biome-ignore lint/nursery/noMisusedPromises: the callback catches all errors itself
200
201
  callInNextEventLoop(async () => {
201
202
  try {
202
203
  await this.jobQueue.push(finalized);
@@ -1,11 +1,18 @@
1
1
  import path from "node:path";
2
2
  import {ChainForkConfig} from "@lodestar/config";
3
3
  import {KeyValue} from "@lodestar/db";
4
- import {CheckpointWithHex, ExecutionStatus, IForkChoice, PayloadStatus, ProtoBlock} from "@lodestar/fork-choice";
4
+ import {
5
+ CheckpointWithHex,
6
+ ExecutionStatus,
7
+ IForkChoice,
8
+ PayloadStatus,
9
+ ProtoBlock,
10
+ isGloasBlock,
11
+ } from "@lodestar/fork-choice";
5
12
  import {ForkSeq, SLOTS_PER_EPOCH} from "@lodestar/params";
6
13
  import {computeEpochAtSlot, computeStartSlotAtEpoch, getBlobDataRetentionStartEpoch} from "@lodestar/state-transition";
7
14
  import {Epoch, Slot} from "@lodestar/types";
8
- import {Logger, fromAsync, fromHex, prettyPrintIndices, toRootHex} from "@lodestar/utils";
15
+ import {Logger, fromHex, prettyPrintIndices, toRootHex} from "@lodestar/utils";
9
16
  import {IBeaconDb} from "../../../db/index.js";
10
17
  import {BlockArchiveBatchPutBinaryItem, encodeArchivedHeaderEnvelope} from "../../../db/repositories/index.js";
11
18
  import {Metrics} from "../../../metrics/metrics.js";
@@ -49,6 +56,17 @@ async function persistOrphanedBlock(
49
56
  await writeIfNotExist(filepath, bytes);
50
57
  }
51
58
 
59
+ /**
60
+ * Oldest epoch for which data column sidecars are kept
61
+ */
62
+ export function getDataColumnSidecarsMinEpoch(
63
+ config: ChainForkConfig,
64
+ currentEpoch: Epoch,
65
+ archiveDataEpochs?: number
66
+ ): Epoch {
67
+ return Math.min(getBlobDataRetentionStartEpoch(config, currentEpoch), currentEpoch - (archiveDataEpochs ?? 0));
68
+ }
69
+
52
70
  /**
53
71
  * Archives finalized blocks from active bucket to archive bucket.
54
72
  *
@@ -136,23 +154,6 @@ export async function archiveBlocks(
136
154
  logger.verbose("Migrated blobSidecars from hot DB to cold DB", {...logCtx, migratedEntries});
137
155
  }
138
156
 
139
- // Keep the normal LevelDB hot-to-cold flow for legacy columns. New columns are written
140
- // directly to flat files, so this only moves fallback data left by older versions.
141
- if (finalizedPostFulu) {
142
- const migratedSlots = await migrateDataColumnSidecarsFromHotToColdDb(
143
- config,
144
- db,
145
- logger,
146
- finalizedCanonicalBlocks,
147
- currentEpoch
148
- );
149
- logger.verbose("Migrated legacy dataColumnSidecars from hot DB to cold DB", {
150
- ...logCtx,
151
- migratedEntries: migratedSlots.length,
152
- slotRange: prettyPrintIndices(migratedSlots),
153
- });
154
- }
155
-
156
157
  if (finalizedPostGloas) {
157
158
  const migratedSlots = await migrateExecutionPayloadEnvelopesFromHotToColdDb(
158
159
  config,
@@ -169,44 +170,34 @@ export async function archiveBlocks(
169
170
  }
170
171
  }
171
172
 
172
- // deleteNonCanonicalBlocks
173
- // loop through forkchoice single time
173
+ const canonicalRoots = new Set(finalizedCanonicalBlocks.map((block) => block.blockRoot));
174
+ const orphanedBlocks: ProtoBlock[] = [];
175
+ const orphanedPayloads: ProtoBlock[] = [];
174
176
 
175
- const nonCanonicalBlockRoots = finalizedNonCanonicalBlocks.map((summary) => fromHex(summary.blockRoot));
176
- if (nonCanonicalBlockRoots.length > 0) {
177
- if (persistOrphanedBlocks) {
178
- // Persist orphaned blocks to disk before deleting them from hot db
179
- await Promise.all(
180
- nonCanonicalBlockRoots.map(async (root, index) => {
181
- const block = finalizedNonCanonicalBlocks[index];
182
- const blockBytes = await db.block.getBinary(root);
183
- const blockLogCtx = {slot: block.slot, root: block.blockRoot};
184
- if (blockBytes) {
185
- await persistOrphanedBlock(block.slot, block.blockRoot, blockBytes, {
186
- persistOrphanedBlocksDir: persistOrphanedBlocksDir ?? "orphaned_blocks",
187
- });
188
- logger.verbose("Persisted orphaned block", {...logCtx, ...blockLogCtx});
189
- } else {
190
- logger.warn("Tried to persist orphaned block but no block found", {...logCtx, ...blockLogCtx});
191
- }
192
- })
193
- );
177
+ for (const block of finalizedNonCanonicalBlocks) {
178
+ if (block.payloadStatus === PayloadStatus.FULL) {
179
+ orphanedPayloads.push(block);
194
180
  }
181
+ // Every Gloas block gets EMPTY before FULL. If only FULL survives pruning, an earlier archive run
182
+ // already handled the root's block-level data.
183
+ const isBlockNode = !isGloasBlock(block) || block.payloadStatus === PayloadStatus.EMPTY;
184
+ if (isBlockNode && !canonicalRoots.has(block.blockRoot)) {
185
+ orphanedBlocks.push(block);
186
+ }
187
+ }
188
+ const orphanedBlockRoots = orphanedBlocks.map((block) => fromHex(block.blockRoot));
195
189
 
196
- const nonCanonicalSlots = finalizedNonCanonicalBlocks.map((summary) => summary.slot).sort((a, b) => a - b);
197
- const nonCanonicalLogCtx = {
190
+ if (orphanedPayloads.length > 0) {
191
+ const orphanedPayloadRoots = orphanedPayloads.map((block) => fromHex(block.blockRoot));
192
+ const orphanedPayloadLogCtx = {
198
193
  ...logCtx,
199
- count: nonCanonicalBlockRoots.length,
200
- slotRange: prettyPrintIndices(nonCanonicalSlots),
194
+ count: orphanedPayloads.length,
195
+ slotRange: prettyPrintIndices(orphanedPayloads.map((block) => block.slot).sort((a, b) => a - b)),
201
196
  };
202
197
 
203
- const columnItems = finalizedNonCanonicalBlocks
204
- // Gloas EMPTY and FULL variants share a block root. EMPTY has no sidecars, so deleting by its root could
205
- // remove the canonical FULL variant's columns. Pre-Gloas blocks are always FULL.
206
- .filter(
207
- (summary) => config.getForkSeq(summary.slot) >= ForkSeq.fulu && summary.payloadStatus === PayloadStatus.FULL
208
- )
209
- .map((summary) => ({slot: summary.slot, blockRoot: summary.blockRoot}));
198
+ const columnItems = orphanedPayloads
199
+ .filter((block) => config.getForkSeq(block.slot) >= ForkSeq.fulu)
200
+ .map((block) => ({slot: block.slot, blockRoot: block.blockRoot}));
210
201
  if (columnItems.length > 0) {
211
202
  // Delete sidecars first so their block roots remain available to retry cleanup after a failure or crash.
212
203
  await db.dataColumns.deleteMany(columnItems);
@@ -217,20 +208,44 @@ export async function archiveBlocks(
217
208
  });
218
209
  }
219
210
 
220
- await db.block.batchDelete(nonCanonicalBlockRoots);
221
- logger.verbose("Deleted non canonical blocks from hot DB", nonCanonicalLogCtx);
222
-
223
211
  if (finalizedPostDeneb) {
224
- await db.blobSidecars.batchDelete(nonCanonicalBlockRoots);
225
- logger.verbose("Deleted non canonical blobSidecars from hot DB", nonCanonicalLogCtx);
212
+ await db.blobSidecars.batchDelete(orphanedPayloadRoots);
213
+ logger.verbose("Deleted non canonical blobSidecars from hot DB", orphanedPayloadLogCtx);
226
214
  }
227
215
 
228
216
  if (finalizedPostGloas) {
229
- await db.executionPayloadEnvelope.batchDelete(nonCanonicalBlockRoots);
230
- logger.verbose("Deleted non canonical executionPayloadEnvelopes from hot DB", nonCanonicalLogCtx);
217
+ await db.executionPayloadEnvelope.batchDelete(orphanedPayloadRoots);
218
+ logger.verbose("Deleted non canonical executionPayloadEnvelopes from hot DB", orphanedPayloadLogCtx);
231
219
  }
232
220
  }
233
221
 
222
+ if (orphanedBlocks.length > 0) {
223
+ if (persistOrphanedBlocks) {
224
+ // Persist orphaned blocks to disk before deleting them from hot db
225
+ await Promise.all(
226
+ orphanedBlocks.map(async (block) => {
227
+ const blockBytes = await db.block.getBinary(fromHex(block.blockRoot));
228
+ const blockLogCtx = {slot: block.slot, root: block.blockRoot};
229
+ if (blockBytes) {
230
+ await persistOrphanedBlock(block.slot, block.blockRoot, blockBytes, {
231
+ persistOrphanedBlocksDir: persistOrphanedBlocksDir ?? "orphaned_blocks",
232
+ });
233
+ logger.verbose("Persisted orphaned block", {...logCtx, ...blockLogCtx});
234
+ } else {
235
+ logger.debug("Tried to persist orphaned block but no block found", {...logCtx, ...blockLogCtx});
236
+ }
237
+ })
238
+ );
239
+ }
240
+
241
+ await db.block.batchDelete(orphanedBlockRoots);
242
+ logger.verbose("Deleted non canonical blocks from hot DB", {
243
+ ...logCtx,
244
+ count: orphanedBlocks.length,
245
+ slotRange: prettyPrintIndices(orphanedBlocks.map((block) => block.slot).sort((a, b) => a - b)),
246
+ });
247
+ }
248
+
234
249
  // Delete expired blobs
235
250
  // Keep only `[current_epoch - max(MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS, archiveDataEpochs)]`
236
251
  // if archiveDataEpochs set to Infinity do not prune`
@@ -256,10 +271,7 @@ export async function archiveBlocks(
256
271
  // Keep only `[min(compute_blob_data_retention_start_epoch(current_epoch), current_epoch - archiveDataEpochs)]`
257
272
  if (finalizedPostFulu) {
258
273
  if (archiveDataEpochs !== Infinity) {
259
- const dataColumnSidecarsMinEpoch = Math.min(
260
- getBlobDataRetentionStartEpoch(config, currentEpoch),
261
- currentEpoch - (archiveDataEpochs ?? 0)
262
- );
274
+ const dataColumnSidecarsMinEpoch = getDataColumnSidecarsMinEpoch(config, currentEpoch, archiveDataEpochs);
263
275
  if (dataColumnSidecarsMinEpoch >= config.FULU_FORK_EPOCH) {
264
276
  const columnsPruneSlot = computeStartSlotAtEpoch(dataColumnSidecarsMinEpoch);
265
277
  const prunedColumnSlots = await db.dataColumns.pruneBefore(columnsPruneSlot);
@@ -283,9 +295,9 @@ export async function archiveBlocks(
283
295
  }
284
296
  }
285
297
 
286
- // Prunning potential checkpoint data
298
+ // Pruning potential checkpoint data
287
299
  const finalizedCanonicalNonCheckpointBlocks = getNonCheckpointBlocks(finalizedCanonicalBlockRoots);
288
- const nonCheckpointBlockRoots: Uint8Array[] = [...nonCanonicalBlockRoots];
300
+ const nonCheckpointBlockRoots: Uint8Array[] = [...orphanedBlockRoots];
289
301
  for (const block of finalizedCanonicalNonCheckpointBlocks) {
290
302
  nonCheckpointBlockRoots.push(block.root);
291
303
  }
@@ -408,72 +420,6 @@ async function migrateBlobSidecarsFromHotToColdDb(
408
420
  return migratedWrappedBlobSidecars;
409
421
  }
410
422
 
411
- // TODO: This function can be simplified further by reducing layers of promises in a loop
412
- /**
413
- * Post-gloas the data columns of a Gloas block are tied to its execution payload envelope.
414
- * Columns only exist once the FULL variant of the block is in the proto-array. Pre-Gloas
415
- * blocks only have a FULL variant, so the payload-status filter passes them all.
416
- */
417
- async function migrateDataColumnSidecarsFromHotToColdDb(
418
- config: ChainForkConfig,
419
- db: IBeaconDb,
420
- logger: Logger,
421
- canonicalBlocks: ProtoBlock[],
422
- currentEpoch: Epoch
423
- ): Promise<Slot[]> {
424
- const columnBlocks = canonicalBlocks.filter(
425
- (block) => config.getForkSeq(block.slot) < ForkSeq.gloas || block.payloadStatus === PayloadStatus.FULL
426
- );
427
- if (columnBlocks.length === 0) return [];
428
- const blocks: BlockRootSlot[] = columnBlocks.map((block) => ({slot: block.slot, root: fromHex(block.blockRoot)}));
429
-
430
- const migratedSlots: Slot[] = [];
431
- for (let i = 0; i < blocks.length; i += BLOB_SIDECAR_BATCH_SIZE) {
432
- const toIdx = Math.min(i + BLOB_SIDECAR_BATCH_SIZE, blocks.length);
433
- const batch = blocks.slice(i, toIdx);
434
- if (batch.length === 0) break;
435
-
436
- const promises: Promise<void>[] = [];
437
- for (const block of batch) {
438
- const blockEpoch = computeEpochAtSlot(block.slot);
439
- if (
440
- config.getForkSeq(block.slot) < ForkSeq.fulu ||
441
- blockEpoch < getBlobDataRetentionStartEpoch(config, currentEpoch)
442
- ) {
443
- continue;
444
- }
445
-
446
- const dataColumnSidecarBytes = await fromAsync(db.dataColumnSidecar.valuesStreamBinary(block.root));
447
- if (dataColumnSidecarBytes.length === 0) {
448
- logger.debug("DataColumnSidecars in forkchoice but missing in hot db, could be already archived", {
449
- slot: block.slot,
450
- root: toRootHex(block.root),
451
- });
452
- continue;
453
- }
454
- logger.verbose("Migrated legacy dataColumnSidecars for block", {
455
- currentEpoch,
456
- slot: block.slot,
457
- root: toRootHex(block.root),
458
- numSidecars: dataColumnSidecarBytes.length,
459
- });
460
- promises.push(
461
- db.dataColumnSidecarArchive.putManyBinary(
462
- block.slot,
463
- dataColumnSidecarBytes.map((entry) => ({key: entry.id, value: entry.value}))
464
- )
465
- );
466
- migratedSlots.push(block.slot);
467
- }
468
-
469
- await Promise.all(promises);
470
- await db.dataColumnSidecar.deleteMany(batch.map((block) => block.root));
471
- }
472
-
473
- // Ancestor walk is newest to oldest; sort ascending so `prettyPrintIndices` renders cleanly.
474
- return migratedSlots.sort((a, b) => a - b);
475
- }
476
-
477
423
  /**
478
424
  * Post-gloas given a finalized checkpoint at a block root, payload of that block root
479
425
  * is not considered finalized, hence they are archived in the next run.