@lodestar/beacon-node 1.52.0-dev.6ab73fec0a → 1.52.0-dev.6c1c955421

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 (358) hide show
  1. package/lib/api/impl/beacon/blocks/index.d.ts.map +1 -1
  2. package/lib/api/impl/beacon/blocks/index.js +63 -39
  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 +3 -1
  6. package/lib/api/impl/beacon/pool/index.js.map +1 -1
  7. package/lib/api/impl/beacon/state/utils.d.ts.map +1 -1
  8. package/lib/api/impl/beacon/state/utils.js +2 -1
  9. package/lib/api/impl/beacon/state/utils.js.map +1 -1
  10. package/lib/api/impl/debug/index.d.ts.map +1 -1
  11. package/lib/api/impl/debug/index.js +6 -2
  12. package/lib/api/impl/debug/index.js.map +1 -1
  13. package/lib/api/impl/validator/index.d.ts.map +1 -1
  14. package/lib/api/impl/validator/index.js +19 -11
  15. package/lib/api/impl/validator/index.js.map +1 -1
  16. package/lib/chain/ColumnReconstructionTracker.d.ts +4 -0
  17. package/lib/chain/ColumnReconstructionTracker.d.ts.map +1 -1
  18. package/lib/chain/ColumnReconstructionTracker.js +4 -0
  19. package/lib/chain/ColumnReconstructionTracker.js.map +1 -1
  20. package/lib/chain/archiveStore/historicalState/getHistoricalState.d.ts.map +1 -1
  21. package/lib/chain/archiveStore/historicalState/getHistoricalState.js +7 -0
  22. package/lib/chain/archiveStore/historicalState/getHistoricalState.js.map +1 -1
  23. package/lib/chain/archiveStore/utils/archiveBlocks.js +1 -1
  24. package/lib/chain/archiveStore/utils/archiveBlocks.js.map +1 -1
  25. package/lib/chain/archiveStore/utils/pruneHistory.d.ts.map +1 -1
  26. package/lib/chain/archiveStore/utils/pruneHistory.js +8 -4
  27. package/lib/chain/archiveStore/utils/pruneHistory.js.map +1 -1
  28. package/lib/chain/blocks/blockInput/blockInput.d.ts.map +1 -1
  29. package/lib/chain/blocks/blockInput/blockInput.js +3 -1
  30. package/lib/chain/blocks/blockInput/blockInput.js.map +1 -1
  31. package/lib/chain/blocks/importExecutionPayload.d.ts +1 -1
  32. package/lib/chain/blocks/importExecutionPayload.d.ts.map +1 -1
  33. package/lib/chain/blocks/importExecutionPayload.js +25 -5
  34. package/lib/chain/blocks/importExecutionPayload.js.map +1 -1
  35. package/lib/chain/blocks/index.d.ts.map +1 -1
  36. package/lib/chain/blocks/index.js +3 -17
  37. package/lib/chain/blocks/index.js.map +1 -1
  38. package/lib/chain/blocks/verifyBlock.d.ts.map +1 -1
  39. package/lib/chain/blocks/verifyBlock.js +21 -17
  40. package/lib/chain/blocks/verifyBlock.js.map +1 -1
  41. package/lib/chain/blocks/verifyBlocksDataAvailability.d.ts +2 -2
  42. package/lib/chain/blocks/verifyBlocksDataAvailability.d.ts.map +1 -1
  43. package/lib/chain/blocks/verifyBlocksDataAvailability.js +3 -3
  44. package/lib/chain/blocks/verifyBlocksDataAvailability.js.map +1 -1
  45. package/lib/chain/blocks/verifyBlocksExecutionPayloads.d.ts.map +1 -1
  46. package/lib/chain/blocks/verifyBlocksExecutionPayloads.js +7 -5
  47. package/lib/chain/blocks/verifyBlocksExecutionPayloads.js.map +1 -1
  48. package/lib/chain/blocks/verifyBlocksSignatures.d.ts +2 -2
  49. package/lib/chain/blocks/verifyBlocksSignatures.d.ts.map +1 -1
  50. package/lib/chain/blocks/verifyBlocksSignatures.js +2 -1
  51. package/lib/chain/blocks/verifyBlocksSignatures.js.map +1 -1
  52. package/lib/chain/blocks/verifyPayloadsDataAvailability.d.ts +2 -2
  53. package/lib/chain/blocks/verifyPayloadsDataAvailability.d.ts.map +1 -1
  54. package/lib/chain/blocks/verifyPayloadsDataAvailability.js +3 -3
  55. package/lib/chain/blocks/verifyPayloadsDataAvailability.js.map +1 -1
  56. package/lib/chain/bls/utils.js +1 -1
  57. package/lib/chain/bls/utils.js.map +1 -1
  58. package/lib/chain/chain.d.ts +6 -5
  59. package/lib/chain/chain.d.ts.map +1 -1
  60. package/lib/chain/chain.js +83 -31
  61. package/lib/chain/chain.js.map +1 -1
  62. package/lib/chain/errors/attestationError.d.ts +15 -1
  63. package/lib/chain/errors/attestationError.d.ts.map +1 -1
  64. package/lib/chain/errors/attestationError.js +8 -0
  65. package/lib/chain/errors/attestationError.js.map +1 -1
  66. package/lib/chain/errors/executionPayloadBid.d.ts +9 -3
  67. package/lib/chain/errors/executionPayloadBid.d.ts.map +1 -1
  68. package/lib/chain/errors/executionPayloadBid.js +2 -1
  69. package/lib/chain/errors/executionPayloadBid.js.map +1 -1
  70. package/lib/chain/errors/executionPayloadEnvelope.d.ts +55 -0
  71. package/lib/chain/errors/executionPayloadEnvelope.d.ts.map +1 -1
  72. package/lib/chain/errors/executionPayloadEnvelope.js +8 -0
  73. package/lib/chain/errors/executionPayloadEnvelope.js.map +1 -1
  74. package/lib/chain/forkChoice/index.d.ts +1 -4
  75. package/lib/chain/forkChoice/index.d.ts.map +1 -1
  76. package/lib/chain/forkChoice/index.js +1 -4
  77. package/lib/chain/forkChoice/index.js.map +1 -1
  78. package/lib/chain/forkChoiceExecutionEngine.d.ts +5 -3
  79. package/lib/chain/forkChoiceExecutionEngine.d.ts.map +1 -1
  80. package/lib/chain/forkChoiceExecutionEngine.js +34 -11
  81. package/lib/chain/forkChoiceExecutionEngine.js.map +1 -1
  82. package/lib/chain/interface.d.ts +1 -1
  83. package/lib/chain/interface.d.ts.map +1 -1
  84. package/lib/chain/lightClient/index.d.ts +13 -6
  85. package/lib/chain/lightClient/index.d.ts.map +1 -1
  86. package/lib/chain/lightClient/index.js +95 -115
  87. package/lib/chain/lightClient/index.js.map +1 -1
  88. package/lib/chain/opPools/inclusionListStore.d.ts +4 -1
  89. package/lib/chain/opPools/inclusionListStore.d.ts.map +1 -1
  90. package/lib/chain/opPools/inclusionListStore.js +5 -2
  91. package/lib/chain/opPools/inclusionListStore.js.map +1 -1
  92. package/lib/chain/opPools/opPool.js +6 -6
  93. package/lib/chain/opPools/opPool.js.map +1 -1
  94. package/lib/chain/options.js +1 -1
  95. package/lib/chain/options.js.map +1 -1
  96. package/lib/chain/prepareNextSlot.d.ts +45 -0
  97. package/lib/chain/prepareNextSlot.d.ts.map +1 -1
  98. package/lib/chain/prepareNextSlot.js +265 -69
  99. package/lib/chain/prepareNextSlot.js.map +1 -1
  100. package/lib/chain/produceBlock/produceBlockBody.d.ts +1 -0
  101. package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
  102. package/lib/chain/produceBlock/produceBlockBody.js +23 -15
  103. package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
  104. package/lib/chain/seenCache/seenAttesters.d.ts +1 -0
  105. package/lib/chain/seenCache/seenAttesters.d.ts.map +1 -1
  106. package/lib/chain/seenCache/seenAttesters.js +1 -1
  107. package/lib/chain/seenCache/seenAttesters.js.map +1 -1
  108. package/lib/chain/seenCache/seenBlockAttesters.d.ts +8 -2
  109. package/lib/chain/seenCache/seenBlockAttesters.d.ts.map +1 -1
  110. package/lib/chain/seenCache/seenBlockAttesters.js +43 -6
  111. package/lib/chain/seenCache/seenBlockAttesters.js.map +1 -1
  112. package/lib/chain/seenCache/seenExecutionPayloadBids.d.ts +13 -4
  113. package/lib/chain/seenCache/seenExecutionPayloadBids.d.ts.map +1 -1
  114. package/lib/chain/seenCache/seenExecutionPayloadBids.js +13 -12
  115. package/lib/chain/seenCache/seenExecutionPayloadBids.js.map +1 -1
  116. package/lib/chain/shufflingCache.d.ts +5 -0
  117. package/lib/chain/shufflingCache.d.ts.map +1 -1
  118. package/lib/chain/shufflingCache.js +39 -1
  119. package/lib/chain/shufflingCache.js.map +1 -1
  120. package/lib/chain/validation/aggregateAndProof.d.ts.map +1 -1
  121. package/lib/chain/validation/aggregateAndProof.js +37 -9
  122. package/lib/chain/validation/aggregateAndProof.js.map +1 -1
  123. package/lib/chain/validation/attestation.d.ts.map +1 -1
  124. package/lib/chain/validation/attestation.js +32 -16
  125. package/lib/chain/validation/attestation.js.map +1 -1
  126. package/lib/chain/validation/block.d.ts.map +1 -1
  127. package/lib/chain/validation/block.js +9 -1
  128. package/lib/chain/validation/block.js.map +1 -1
  129. package/lib/chain/validation/dataColumnSidecar.d.ts.map +1 -1
  130. package/lib/chain/validation/dataColumnSidecar.js +8 -1
  131. package/lib/chain/validation/dataColumnSidecar.js.map +1 -1
  132. package/lib/chain/validation/executionPayloadBid.d.ts.map +1 -1
  133. package/lib/chain/validation/executionPayloadBid.js +47 -42
  134. package/lib/chain/validation/executionPayloadBid.js.map +1 -1
  135. package/lib/chain/validation/executionPayloadEnvelope.d.ts.map +1 -1
  136. package/lib/chain/validation/executionPayloadEnvelope.js +100 -9
  137. package/lib/chain/validation/executionPayloadEnvelope.js.map +1 -1
  138. package/lib/chain/validation/payloadAttestationMessage.js +9 -0
  139. package/lib/chain/validation/payloadAttestationMessage.js.map +1 -1
  140. package/lib/chain/validation/voluntaryExit.d.ts.map +1 -1
  141. package/lib/chain/validation/voluntaryExit.js +39 -6
  142. package/lib/chain/validation/voluntaryExit.js.map +1 -1
  143. package/lib/execution/engine/blockHash.d.ts +12 -0
  144. package/lib/execution/engine/blockHash.d.ts.map +1 -0
  145. package/lib/execution/engine/blockHash.js +17 -0
  146. package/lib/execution/engine/blockHash.js.map +1 -0
  147. package/lib/execution/engine/http.d.ts +2 -2
  148. package/lib/execution/engine/http.d.ts.map +1 -1
  149. package/lib/execution/engine/http.js +13 -7
  150. package/lib/execution/engine/http.js.map +1 -1
  151. package/lib/execution/engine/interface.d.ts +16 -3
  152. package/lib/execution/engine/interface.d.ts.map +1 -1
  153. package/lib/execution/engine/interface.js +11 -0
  154. package/lib/execution/engine/interface.js.map +1 -1
  155. package/lib/execution/engine/jsonRpcHttpClient.d.ts +2 -0
  156. package/lib/execution/engine/jsonRpcHttpClient.d.ts.map +1 -1
  157. package/lib/execution/engine/jsonRpcHttpClient.js +14 -6
  158. package/lib/execution/engine/jsonRpcHttpClient.js.map +1 -1
  159. package/lib/execution/engine/jsonRpcTransport.d.ts +2 -2
  160. package/lib/execution/engine/jsonRpcTransport.d.ts.map +1 -1
  161. package/lib/execution/engine/jsonRpcTransport.js +4 -4
  162. package/lib/execution/engine/jsonRpcTransport.js.map +1 -1
  163. package/lib/execution/engine/mock.d.ts.map +1 -1
  164. package/lib/execution/engine/mock.js +6 -6
  165. package/lib/execution/engine/mock.js.map +1 -1
  166. package/lib/execution/engine/payloadIdCache.d.ts +6 -1
  167. package/lib/execution/engine/payloadIdCache.d.ts.map +1 -1
  168. package/lib/execution/engine/payloadIdCache.js +7 -2
  169. package/lib/execution/engine/payloadIdCache.js.map +1 -1
  170. package/lib/execution/engine/restHttpClient.d.ts.map +1 -1
  171. package/lib/execution/engine/restHttpClient.js +9 -5
  172. package/lib/execution/engine/restHttpClient.js.map +1 -1
  173. package/lib/execution/engine/restTransport.d.ts +2 -2
  174. package/lib/execution/engine/restTransport.d.ts.map +1 -1
  175. package/lib/execution/engine/restTransport.js +4 -4
  176. package/lib/execution/engine/restTransport.js.map +1 -1
  177. package/lib/execution/engine/signal.d.ts +6 -0
  178. package/lib/execution/engine/signal.d.ts.map +1 -0
  179. package/lib/execution/engine/signal.js +24 -0
  180. package/lib/execution/engine/signal.js.map +1 -0
  181. package/lib/execution/engine/transport.d.ts +2 -2
  182. package/lib/execution/engine/transport.d.ts.map +1 -1
  183. package/lib/index.d.ts +1 -1
  184. package/lib/index.d.ts.map +1 -1
  185. package/lib/index.js +1 -1
  186. package/lib/index.js.map +1 -1
  187. package/lib/metrics/metrics/beacon.d.ts +9 -0
  188. package/lib/metrics/metrics/beacon.d.ts.map +1 -1
  189. package/lib/metrics/metrics/beacon.js +16 -2
  190. package/lib/metrics/metrics/beacon.js.map +1 -1
  191. package/lib/metrics/metrics/lodestar.d.ts +3 -0
  192. package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
  193. package/lib/metrics/metrics/lodestar.js +42 -28
  194. package/lib/metrics/metrics/lodestar.js.map +1 -1
  195. package/lib/network/gossip/gossipsub.d.ts +1 -0
  196. package/lib/network/gossip/gossipsub.d.ts.map +1 -1
  197. package/lib/network/gossip/gossipsub.js +5 -2
  198. package/lib/network/gossip/gossipsub.js.map +1 -1
  199. package/lib/network/gossip/topic.d.ts +1 -7
  200. package/lib/network/gossip/topic.d.ts.map +1 -1
  201. package/lib/network/gossip/topic.js +0 -13
  202. package/lib/network/gossip/topic.js.map +1 -1
  203. package/lib/network/network.d.ts +1 -0
  204. package/lib/network/network.d.ts.map +1 -1
  205. package/lib/network/network.js +26 -12
  206. package/lib/network/network.js.map +1 -1
  207. package/lib/network/peers/peerManager.d.ts.map +1 -1
  208. package/lib/network/peers/peerManager.js +22 -2
  209. package/lib/network/peers/peerManager.js.map +1 -1
  210. package/lib/network/peers/utils/prioritizePeers.d.ts +2 -0
  211. package/lib/network/peers/utils/prioritizePeers.d.ts.map +1 -1
  212. package/lib/network/peers/utils/prioritizePeers.js +11 -2
  213. package/lib/network/peers/utils/prioritizePeers.js.map +1 -1
  214. package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
  215. package/lib/network/processor/gossipHandlers.js +19 -6
  216. package/lib/network/processor/gossipHandlers.js.map +1 -1
  217. package/lib/network/processor/gossipValidatorFn.d.ts.map +1 -1
  218. package/lib/network/processor/gossipValidatorFn.js +4 -1
  219. package/lib/network/processor/gossipValidatorFn.js.map +1 -1
  220. package/lib/network/processor/index.d.ts.map +1 -1
  221. package/lib/network/processor/index.js +4 -2
  222. package/lib/network/processor/index.js.map +1 -1
  223. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js +1 -1
  224. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js.map +1 -1
  225. package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.js +1 -1
  226. package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.js.map +1 -1
  227. package/lib/network/reqresp/utils/collect.d.ts +4 -4
  228. package/lib/network/reqresp/utils/collect.d.ts.map +1 -1
  229. package/lib/network/reqresp/utils/collect.js +9 -8
  230. package/lib/network/reqresp/utils/collect.js.map +1 -1
  231. package/lib/network/reqresp/utils/collectSequentialBlocksInRange.d.ts +1 -1
  232. package/lib/network/reqresp/utils/collectSequentialBlocksInRange.d.ts.map +1 -1
  233. package/lib/network/reqresp/utils/collectSequentialBlocksInRange.js +2 -2
  234. package/lib/network/reqresp/utils/collectSequentialBlocksInRange.js.map +1 -1
  235. package/lib/sync/range/batch.d.ts +10 -0
  236. package/lib/sync/range/batch.d.ts.map +1 -1
  237. package/lib/sync/range/batch.js +29 -0
  238. package/lib/sync/range/batch.js.map +1 -1
  239. package/lib/sync/range/chain.d.ts +17 -2
  240. package/lib/sync/range/chain.d.ts.map +1 -1
  241. package/lib/sync/range/chain.js +60 -20
  242. package/lib/sync/range/chain.js.map +1 -1
  243. package/lib/sync/range/range.d.ts.map +1 -1
  244. package/lib/sync/range/range.js +44 -3
  245. package/lib/sync/range/range.js.map +1 -1
  246. package/lib/sync/range/utils/batches.d.ts +20 -4
  247. package/lib/sync/range/utils/batches.d.ts.map +1 -1
  248. package/lib/sync/range/utils/batches.js +31 -13
  249. package/lib/sync/range/utils/batches.js.map +1 -1
  250. package/lib/sync/range/utils/peerBalancer.d.ts +1 -1
  251. package/lib/sync/range/utils/peerBalancer.d.ts.map +1 -1
  252. package/lib/sync/range/utils/peerBalancer.js +5 -2
  253. package/lib/sync/range/utils/peerBalancer.js.map +1 -1
  254. package/lib/sync/types.d.ts +14 -1
  255. package/lib/sync/types.d.ts.map +1 -1
  256. package/lib/sync/types.js +2 -0
  257. package/lib/sync/types.js.map +1 -1
  258. package/lib/sync/unknownBlock.d.ts +28 -1
  259. package/lib/sync/unknownBlock.d.ts.map +1 -1
  260. package/lib/sync/unknownBlock.js +340 -27
  261. package/lib/sync/unknownBlock.js.map +1 -1
  262. package/lib/sync/utils/downloadByRange.d.ts +22 -1
  263. package/lib/sync/utils/downloadByRange.d.ts.map +1 -1
  264. package/lib/sync/utils/downloadByRange.js +55 -25
  265. package/lib/sync/utils/downloadByRange.js.map +1 -1
  266. package/lib/sync/utils/downloadByRoot.d.ts +24 -2
  267. package/lib/sync/utils/downloadByRoot.d.ts.map +1 -1
  268. package/lib/sync/utils/downloadByRoot.js +48 -5
  269. package/lib/sync/utils/downloadByRoot.js.map +1 -1
  270. package/lib/util/dataColumns.d.ts +1 -1
  271. package/lib/util/dataColumns.d.ts.map +1 -1
  272. package/lib/util/dataColumns.js +4 -1
  273. package/lib/util/dataColumns.js.map +1 -1
  274. package/lib/util/eventLoop.d.ts +3 -3
  275. package/lib/util/eventLoop.d.ts.map +1 -1
  276. package/lib/util/eventLoop.js +3 -3
  277. package/lib/util/eventLoop.js.map +1 -1
  278. package/package.json +27 -27
  279. package/src/api/impl/beacon/blocks/index.ts +74 -47
  280. package/src/api/impl/beacon/pool/index.ts +9 -7
  281. package/src/api/impl/beacon/state/utils.ts +2 -1
  282. package/src/api/impl/debug/index.ts +6 -2
  283. package/src/api/impl/validator/index.ts +21 -11
  284. package/src/chain/ColumnReconstructionTracker.ts +5 -0
  285. package/src/chain/archiveStore/historicalState/getHistoricalState.ts +9 -0
  286. package/src/chain/archiveStore/utils/archiveBlocks.ts +1 -1
  287. package/src/chain/archiveStore/utils/pruneHistory.ts +9 -4
  288. package/src/chain/blocks/blockInput/blockInput.ts +4 -1
  289. package/src/chain/blocks/importExecutionPayload.ts +30 -4
  290. package/src/chain/blocks/index.ts +3 -31
  291. package/src/chain/blocks/verifyBlock.ts +24 -17
  292. package/src/chain/blocks/verifyBlocksDataAvailability.ts +4 -4
  293. package/src/chain/blocks/verifyBlocksExecutionPayloads.ts +7 -4
  294. package/src/chain/blocks/verifyBlocksSignatures.ts +3 -0
  295. package/src/chain/blocks/verifyPayloadsDataAvailability.ts +5 -4
  296. package/src/chain/bls/utils.ts +1 -1
  297. package/src/chain/chain.ts +116 -48
  298. package/src/chain/errors/attestationError.ts +11 -1
  299. package/src/chain/errors/executionPayloadBid.ts +9 -2
  300. package/src/chain/errors/executionPayloadEnvelope.ts +58 -0
  301. package/src/chain/forkChoice/index.ts +1 -4
  302. package/src/chain/forkChoiceExecutionEngine.ts +48 -15
  303. package/src/chain/interface.ts +1 -1
  304. package/src/chain/lightClient/index.ts +108 -142
  305. package/src/chain/opPools/inclusionListStore.ts +5 -2
  306. package/src/chain/opPools/opPool.ts +6 -6
  307. package/src/chain/options.ts +1 -1
  308. package/src/chain/prepareNextSlot.ts +347 -89
  309. package/src/chain/produceBlock/produceBlockBody.ts +25 -16
  310. package/src/chain/seenCache/seenAttesters.ts +1 -1
  311. package/src/chain/seenCache/seenBlockAttesters.ts +48 -6
  312. package/src/chain/seenCache/seenExecutionPayloadBids.ts +35 -15
  313. package/src/chain/shufflingCache.ts +40 -1
  314. package/src/chain/validation/aggregateAndProof.ts +43 -14
  315. package/src/chain/validation/attestation.ts +31 -20
  316. package/src/chain/validation/block.ts +9 -1
  317. package/src/chain/validation/dataColumnSidecar.ts +7 -1
  318. package/src/chain/validation/executionPayloadBid.ts +60 -44
  319. package/src/chain/validation/executionPayloadEnvelope.ts +115 -8
  320. package/src/chain/validation/payloadAttestationMessage.ts +10 -0
  321. package/src/chain/validation/voluntaryExit.ts +44 -6
  322. package/src/execution/engine/blockHash.ts +27 -0
  323. package/src/execution/engine/http.ts +18 -10
  324. package/src/execution/engine/interface.ts +18 -3
  325. package/src/execution/engine/jsonRpcHttpClient.ts +26 -14
  326. package/src/execution/engine/jsonRpcTransport.ts +8 -4
  327. package/src/execution/engine/mock.ts +13 -8
  328. package/src/execution/engine/payloadIdCache.ts +12 -4
  329. package/src/execution/engine/restHttpClient.ts +17 -11
  330. package/src/execution/engine/restTransport.ts +5 -4
  331. package/src/execution/engine/signal.ts +28 -0
  332. package/src/execution/engine/transport.ts +3 -2
  333. package/src/index.ts +6 -1
  334. package/src/metrics/metrics/beacon.ts +20 -2
  335. package/src/metrics/metrics/lodestar.ts +42 -28
  336. package/src/network/gossip/gossipsub.ts +6 -2
  337. package/src/network/gossip/topic.ts +1 -14
  338. package/src/network/network.ts +39 -13
  339. package/src/network/peers/peerManager.ts +26 -2
  340. package/src/network/peers/utils/prioritizePeers.ts +14 -1
  341. package/src/network/processor/gossipHandlers.ts +25 -13
  342. package/src/network/processor/gossipValidatorFn.ts +4 -0
  343. package/src/network/processor/index.ts +7 -2
  344. package/src/network/reqresp/handlers/dataColumnSidecarsByRange.ts +1 -1
  345. package/src/network/reqresp/handlers/dataColumnSidecarsByRoot.ts +1 -1
  346. package/src/network/reqresp/utils/collect.ts +16 -8
  347. package/src/network/reqresp/utils/collectSequentialBlocksInRange.ts +3 -2
  348. package/src/sync/range/batch.ts +33 -0
  349. package/src/sync/range/chain.ts +72 -17
  350. package/src/sync/range/range.ts +57 -3
  351. package/src/sync/range/utils/batches.ts +38 -13
  352. package/src/sync/range/utils/peerBalancer.ts +4 -1
  353. package/src/sync/types.ts +13 -0
  354. package/src/sync/unknownBlock.ts +389 -29
  355. package/src/sync/utils/downloadByRange.ts +89 -29
  356. package/src/sync/utils/downloadByRoot.ts +75 -7
  357. package/src/util/dataColumns.ts +4 -1
  358. package/src/util/eventLoop.ts +3 -3
@@ -25,6 +25,7 @@ import {
25
25
  } from "@lodestar/state-transition";
26
26
  import {
27
27
  ProducedBlockSource,
28
+ RootHex,
28
29
  SignedBeaconBlock,
29
30
  SignedBlindedBeaconBlock,
30
31
  SignedBlockContents,
@@ -190,28 +191,31 @@ export function getBeaconBlockApi(
190
191
 
191
192
  switch (broadcastValidation) {
192
193
  case routes.beacon.BroadcastValidation.gossip: {
193
- if (!blockLocallyProduced) {
194
- try {
194
+ try {
195
+ if (blockLocallyProduced) {
196
+ // Block production does not cover the proposer signature, the validator client signs the block
197
+ await verifyBlockProposerSignature(chain, signedBlock, blockRoot);
198
+ } else {
195
199
  await validateGossipBlock(config, chain, signedBlock, fork);
196
- } catch (error) {
197
- if (error instanceof BlockGossipError) {
198
- switch (error.type.code) {
199
- case BlockErrorCode.ALREADY_KNOWN:
200
- // Block has already been seen, e.g. via gossip racing the publish API. Benign.
201
- chain.logger.debug("Ignoring already-known block during publishing", valLogMeta);
202
- return;
203
- }
200
+ }
201
+ } catch (error) {
202
+ if (error instanceof BlockGossipError) {
203
+ switch (error.type.code) {
204
+ case BlockErrorCode.ALREADY_KNOWN:
205
+ // Block has already been seen, e.g. via gossip racing the publish API. Benign.
206
+ chain.logger.debug("Ignoring already-known block during publishing", valLogMeta);
207
+ return;
204
208
  }
205
-
206
- chain.logger.error("Gossip validations failed while publishing the block", valLogMeta, error as Error);
207
- chain.persistInvalidSszValue(
208
- chain.config.getForkTypes(slot).SignedBeaconBlock,
209
- signedBlock,
210
- "api_reject_gossip_failure",
211
- blockRoot
212
- );
213
- throw error;
214
209
  }
210
+
211
+ chain.logger.error("Gossip validations failed while publishing the block", valLogMeta, error as Error);
212
+ chain.persistInvalidSszValue(
213
+ chain.config.getForkTypes(slot).SignedBeaconBlock,
214
+ signedBlock,
215
+ "api_reject_gossip_failure",
216
+ blockRoot
217
+ );
218
+ throw error;
215
219
  }
216
220
  chain.logger.debug("Gossip checks validated while publishing the block", valLogMeta);
217
221
  break;
@@ -507,26 +511,32 @@ export function getBeaconBlockApi(
507
511
 
508
512
  const result: routes.beacon.BlockHeaderResponse[] = [];
509
513
  if (parentRoot) {
514
+ let finalizedRoot: RootHex | null = null;
510
515
  const finalizedBlock = await db.blockArchive.getByParentRoot(fromHex(parentRoot));
511
516
  if (finalizedBlock) {
512
- result.push(toBeaconHeaderResponse(config, finalizedBlock, true));
517
+ const header = toBeaconHeaderResponse(config, finalizedBlock, true);
518
+ finalizedRoot = toRootHex(header.root);
519
+ result.push(header);
513
520
  }
514
521
  const nonFinalizedBlocks = chain.forkChoice.getBlockSummariesByParentRoot(parentRoot);
515
522
  await Promise.all(
516
523
  nonFinalizedBlocks.map(async (summary) => {
524
+ // The finalized block stays in fork choice as its anchor after it is archived
525
+ if (summary.blockRoot === finalizedRoot) {
526
+ return;
527
+ }
517
528
  const blockResult = await chain.getBlockByRoot(summary.blockRoot);
518
529
  if (blockResult) {
530
+ // There is no canonical block at the slot of a child that was reorged out by a later sibling
519
531
  const canonical = chain.forkChoice.getCanonicalBlockAtSlot(blockResult.block.message.slot);
520
- if (canonical) {
521
- result.push(
522
- toBeaconHeaderResponse(config, blockResult.block, canonical.blockRoot === summary.blockRoot)
523
- );
524
- if (isOptimisticBlock(canonical)) {
525
- executionOptimistic = true;
526
- }
527
- // Block from hot db which only contains unfinalized blocks
528
- finalized = false;
532
+ result.push(
533
+ toBeaconHeaderResponse(config, blockResult.block, canonical?.blockRoot === summary.blockRoot)
534
+ );
535
+ if (isOptimisticBlock(summary)) {
536
+ executionOptimistic = true;
529
537
  }
538
+ // Block from hot db which only contains unfinalized blocks
539
+ finalized = false;
530
540
  }
531
541
  })
532
542
  );
@@ -551,21 +561,18 @@ export function getBeaconBlockApi(
551
561
  return {data: [], meta: {executionOptimistic: false, finalized: false}};
552
562
  }
553
563
 
564
+ let canonicalRoot: RootHex | null = null;
554
565
  const canonicalBlock = await chain.getCanonicalBlockAtSlot(slot);
555
- // skip slot
556
- if (!canonicalBlock) {
557
- return {data: [], meta: {executionOptimistic: false, finalized: false}};
558
- }
559
- const canonicalRoot = config
560
- .getForkTypes(canonicalBlock.block.message.slot)
561
- .BeaconBlock.hashTreeRoot(canonicalBlock.block.message);
562
- result.push(toBeaconHeaderResponse(config, canonicalBlock.block, true));
563
- if (!canonicalBlock.finalized) {
564
- finalized = false;
566
+ if (canonicalBlock) {
567
+ const header = toBeaconHeaderResponse(config, canonicalBlock.block, true);
568
+ canonicalRoot = toRootHex(header.root);
569
+ result.push(header);
570
+ if (!canonicalBlock.finalized) {
571
+ finalized = false;
572
+ }
565
573
  }
566
574
 
567
- // fork blocks
568
- // TODO: What is this logic?
575
+ // Non-canonical blocks at the slot, also if the canonical chain skipped it
569
576
  await Promise.all(
570
577
  chain.forkChoice.getBlockSummariesAtSlot(slot).map(async (summary) => {
571
578
  if (isOptimisticBlock(summary)) {
@@ -573,7 +580,7 @@ export function getBeaconBlockApi(
573
580
  }
574
581
  finalized = false;
575
582
 
576
- if (summary.blockRoot !== toRootHex(canonicalRoot)) {
583
+ if (summary.blockRoot !== canonicalRoot) {
577
584
  const blockResult = await chain.getBlockByRoot(summary.blockRoot);
578
585
  if (blockResult) {
579
586
  result.push(toBeaconHeaderResponse(config, blockResult.block));
@@ -581,6 +588,11 @@ export function getBeaconBlockApi(
581
588
  }
582
589
  })
583
590
  );
591
+
592
+ // skip slot
593
+ if (result.length === 0) {
594
+ return {data: [], meta: {executionOptimistic: false, finalized: false}};
595
+ }
584
596
  }
585
597
 
586
598
  return {
@@ -646,11 +658,15 @@ export function getBeaconBlockApi(
646
658
  : parseInt(blockId, 10);
647
659
  if (!Number.isNaN(slot)) {
648
660
  const head = chain.forkChoice.getHead();
661
+ // The head can be the FULL variant, a block reports the status of the payload it builds on
662
+ const executionOptimistic = isOptimisticBlock(
663
+ chain.forkChoice.getBlockHexDefaultStatus(head.blockRoot) ?? head
664
+ );
649
665
 
650
666
  if (slot === head.slot) {
651
667
  return {
652
668
  data: {root: fromHex(head.blockRoot)},
653
- meta: {executionOptimistic: isOptimisticBlock(head), finalized: false},
669
+ meta: {executionOptimistic, finalized: false},
654
670
  };
655
671
  }
656
672
 
@@ -659,7 +675,7 @@ export function getBeaconBlockApi(
659
675
  return {
660
676
  data: {root: state.getBlockRootAtSlot(slot)},
661
677
  meta: {
662
- executionOptimistic: isOptimisticBlock(head),
678
+ executionOptimistic,
663
679
  finalized: computeEpochAtSlot(slot) <= chain.forkChoice.getFinalizedCheckpoint().epoch,
664
680
  },
665
681
  };
@@ -668,7 +684,10 @@ export function getBeaconBlockApi(
668
684
  const head = chain.forkChoice.getHead();
669
685
  return {
670
686
  data: {root: fromHex(head.blockRoot)},
671
- meta: {executionOptimistic: isOptimisticBlock(head), finalized: false},
687
+ meta: {
688
+ executionOptimistic: isOptimisticBlock(chain.forkChoice.getBlockHexDefaultStatus(head.blockRoot) ?? head),
689
+ finalized: false,
690
+ },
672
691
  };
673
692
  }
674
693
 
@@ -1183,10 +1202,14 @@ export function getBeaconBlockApi(
1183
1202
  data = [];
1184
1203
  }
1185
1204
 
1205
+ // Post-gloas sidecars belong to the block's own payload, its FULL variant only exists once imported
1206
+ const payload = finalized ? null : chain.forkChoice.getBlockHex(blockRootHex, PayloadStatus.FULL);
1186
1207
  return {
1187
1208
  data,
1188
1209
  meta: {
1189
- executionOptimistic,
1210
+ executionOptimistic: isForkPostGloas(fork)
1211
+ ? !finalized && (payload === null || isOptimisticBlock(payload))
1212
+ : executionOptimistic,
1190
1213
  finalized,
1191
1214
  version: config.getForkName(block.message.slot),
1192
1215
  },
@@ -1284,10 +1307,14 @@ export function getBeaconBlockApi(
1284
1307
  blobs = [];
1285
1308
  }
1286
1309
 
1310
+ // Post-gloas blobs belong to the block's own payload, its FULL variant only exists once imported
1311
+ const payload = finalized ? null : chain.forkChoice.getBlockHex(blockRootHex, PayloadStatus.FULL);
1287
1312
  return {
1288
1313
  data: blobs,
1289
1314
  meta: {
1290
- executionOptimistic,
1315
+ executionOptimistic: isForkPostGloas(fork)
1316
+ ? !finalized && (payload === null || isOptimisticBlock(payload))
1317
+ : executionOptimistic,
1291
1318
  finalized,
1292
1319
  },
1293
1320
  };
@@ -289,13 +289,15 @@ export function getBeaconPoolApi({
289
289
  );
290
290
  metrics?.opPool.payloadAttestationPool.apiInsertOutcome.inc({insertOutcome});
291
291
 
292
- chain.forkChoice.notifyPtcMessages(
293
- toRootHex(payloadAttestationMessage.data.beaconBlockRoot),
294
- payloadAttestationMessage.data.slot,
295
- validatorCommitteeIndices,
296
- payloadAttestationMessage.data.payloadPresent,
297
- payloadAttestationMessage.data.blobDataAvailable
298
- );
292
+ if (slot === chain.clock.currentSlot) {
293
+ chain.forkChoice.notifyPtcMessages(
294
+ toRootHex(payloadAttestationMessage.data.beaconBlockRoot),
295
+ payloadAttestationMessage.data.slot,
296
+ validatorCommitteeIndices,
297
+ payloadAttestationMessage.data.payloadPresent,
298
+ payloadAttestationMessage.data.blobDataAvailable
299
+ );
300
+ }
299
301
 
300
302
  chain.emitter.emit(routes.events.EventType.payloadAttestationMessage, {
301
303
  version: chain.config.getForkName(slot),
@@ -75,7 +75,8 @@ export async function getStateResponseWithRegen(
75
75
  const finalizedEpoch = chain.forkChoice.getFinalizedCheckpoint().epoch;
76
76
  return {
77
77
  state,
78
- executionOptimistic: isOptimisticBlock(head),
78
+ // The head can be the FULL variant, a state reports the status of the payload its block builds on
79
+ executionOptimistic: isOptimisticBlock(chain.forkChoice.getBlockHexDefaultStatus(head.blockRoot) ?? head),
79
80
  finalized: state.epoch <= finalizedEpoch && finalizedEpoch !== GENESIS_EPOCH,
80
81
  };
81
82
  }
@@ -1,7 +1,7 @@
1
1
  import {routes} from "@lodestar/api";
2
2
  import {ApplicationMethods} from "@lodestar/api/server";
3
3
  import {ExecutionStatus, PayloadStatus} from "@lodestar/fork-choice";
4
- import {ForkPostDeneb, ZERO_HASH_HEX, isForkPostDeneb, isForkPostFulu} from "@lodestar/params";
4
+ import {ForkPostDeneb, ZERO_HASH_HEX, isForkPostDeneb, isForkPostFulu, isForkPostGloas} from "@lodestar/params";
5
5
  import {computeTimeAtSlot} from "@lodestar/state-transition";
6
6
  import {BeaconState, DataColumnSidecar, DataColumnSidecars, type SignedBeaconBlock, sszTypesFor} from "@lodestar/types";
7
7
  import {fromHex, toRootHex} from "@lodestar/utils";
@@ -190,12 +190,16 @@ export function getDebugApi({
190
190
  dataColumnSidecars = [];
191
191
  }
192
192
 
193
+ // Post-gloas sidecars belong to the block's own payload, its FULL variant only exists once imported
194
+ const payload = finalized ? null : chain.forkChoice.getBlockHex(toRootHex(blockRoot), PayloadStatus.FULL);
193
195
  return {
194
196
  data: (indices
195
197
  ? dataColumnSidecars.filter(({index}) => indices.includes(index))
196
198
  : dataColumnSidecars) as DataColumnSidecars,
197
199
  meta: {
198
- executionOptimistic,
200
+ executionOptimistic: isForkPostGloas(fork)
201
+ ? !finalized && (payload === null || isOptimisticBlock(payload))
202
+ : executionOptimistic,
199
203
  finalized,
200
204
  version: fork,
201
205
  },
@@ -9,6 +9,7 @@ import {
9
9
  ForkPreDeneb,
10
10
  ForkPreGloas,
11
11
  ForkSeq,
12
+ GENESIS_EPOCH,
12
13
  GENESIS_SLOT,
13
14
  SLOTS_PER_EPOCH,
14
15
  SLOTS_PER_HISTORICAL_ROOT,
@@ -131,8 +132,6 @@ const BLOCK_PRODUCTION_RACE_CUTOFF_BPS = 1667;
131
132
  * TODO GLOAS: revisit, the block propagates faster as it only commits to a bid and the attestation deadline changed
132
133
  */
133
134
  export const BLOCK_PRODUCTION_RACE_CUTOFF_GLOAS_BPS = 1667;
134
- /** Rejection message of the bid block branch when there is no viable bid to commit to */
135
- const NO_BID_AVAILABLE = "No builder bid available";
136
135
 
137
136
  type BidCandidate = {
138
137
  signedBid: gloas.SignedExecutionPayloadBid;
@@ -408,7 +407,7 @@ export function getValidatorApi(
408
407
  * Both the above scenarios could be problematic and hence validator shouldn't participate
409
408
  * or weigh its vote on a head till it resolves to a Valid execution status.
410
409
  * Following activities should be skipped on an Optimistic head (with Syncing status):
411
- * 1. Attestation if targetRoot is optimistic
410
+ * 1. Attestation if the head block voted for (post-gloas the variant voted for) or the targetRoot is optimistic
412
411
  * 2. SyncCommitteeContribution if if the root for which to produce contribution is Optimistic.
413
412
  * 3. ProduceBlock if the parentRoot (chain's current head) is optimistic. Must be checked
414
413
  * explicitly as only local payload production consults the EL, blinded blocks from an
@@ -1155,7 +1154,7 @@ export function getValidatorApi(
1155
1154
  });
1156
1155
  const bidBlockPromise: ReturnType<typeof chain.produceBlock> = bestBidPromise.then((candidate) => {
1157
1156
  if (candidate === null) {
1158
- throw new Error(NO_BID_AVAILABLE);
1157
+ throw new NoBidReceived();
1159
1158
  }
1160
1159
  metrics?.blockProductionRequests.inc({source: ProducedBlockSource.builder});
1161
1160
  return timed(ProducedBlockSource.builder, () =>
@@ -1269,7 +1268,7 @@ export function getValidatorApi(
1269
1268
  source = ProducedBlockSource.engine;
1270
1269
  bestResult = engineResult;
1271
1270
  const reason =
1272
- bidBlockResult.status === "rejected" && (bidBlockResult.reason as Error).message === NO_BID_AVAILABLE
1271
+ bidBlockResult.status === "rejected" && bidBlockResult.reason instanceof NoBidReceived
1273
1272
  ? EngineBlockSelectionReason.BuilderNoBid
1274
1273
  : bidBlockResult.status === "pending"
1275
1274
  ? EngineBlockSelectionReason.BuilderPending
@@ -1396,10 +1395,18 @@ export function getValidatorApi(
1396
1395
  // After Gloas, attestation.data.index signals payload status in fork-choice:
1397
1396
  // - 0 = EMPTY / not present, 1 = FULL / present
1398
1397
  // - same-slot attestations must always use index = 0
1398
+ // Validator shouldn't vote on an optimistic head, post-gloas that is the variant voted for
1399
1399
  if (canonicalBlock.slot !== slot) {
1400
1400
  index = canonicalBlock.payloadStatus === PayloadStatus.FULL ? 1 : 0;
1401
+ if (isOptimisticBlock(canonicalBlock)) {
1402
+ throw new NodeIsSyncing(
1403
+ `Head block's execution payload not yet validated, executionPayloadBlockHash=${canonicalBlock.executionPayloadBlockHash}`
1404
+ );
1405
+ }
1401
1406
  } else {
1402
1407
  index = 0;
1408
+ // Same-slot votes support the PENDING variant, which does not depend on the block's own payload
1409
+ notOnOptimisticBlockRoot(beaconBlockRoot);
1403
1410
  }
1404
1411
  } else if (isForkPostElectra(fork)) {
1405
1412
  index = 0;
@@ -1417,8 +1424,11 @@ export function getValidatorApi(
1417
1424
  headBlockRoot
1418
1425
  : headState.getBlockRootAtSlot(targetSlot);
1419
1426
 
1420
- // Check the execution status as validator shouldn't vote on an optimistic head
1421
- // Check on target is sufficient as a valid target would imply a valid source
1427
+ // Check the execution status as validator shouldn't vote on an optimistic head, post-gloas the
1428
+ // variant voted for is checked above. Check on target is sufficient for a valid source
1429
+ if (!isForkPostGloas(fork)) {
1430
+ notOnOptimisticBlockRoot(beaconBlockRoot);
1431
+ }
1422
1432
  notOnOptimisticBlockRoot(targetRoot);
1423
1433
  notOnOutOfRangeData(targetRoot);
1424
1434
 
@@ -1684,7 +1694,8 @@ export function getValidatorApi(
1684
1694
 
1685
1695
  // should not compare to headEpoch in order to handle skipped slots
1686
1696
  // Check if the epoch is in the future after waiting for requested slot
1687
- if (epoch > chain.clock.currentEpoch + 1) {
1697
+ // Before genesis the clock epoch is negative, treat it as GENESIS_EPOCH so the next epoch can be requested
1698
+ if (epoch > Math.max(chain.clock.currentEpoch, GENESIS_EPOCH) + 1) {
1688
1699
  throw new ApiError(400, "Cannot get duties for epoch more than one ahead");
1689
1700
  }
1690
1701
 
@@ -1747,7 +1758,7 @@ export function getValidatorApi(
1747
1758
 
1748
1759
  await waitForNextClosestEpoch();
1749
1760
 
1750
- if (epoch > chain.clock.currentEpoch + 1) {
1761
+ if (epoch > Math.max(chain.clock.currentEpoch, GENESIS_EPOCH) + 1) {
1751
1762
  throw new ApiError(400, "Cannot get PTC duties for epoch more than one ahead");
1752
1763
  }
1753
1764
 
@@ -2324,8 +2335,7 @@ export function getValidatorApi(
2324
2335
  metrics?.inclusionListsValid.inc({source: InclusionListSource.api});
2325
2336
  metrics?.inclusionListsValidSize.inc(totalBytes);
2326
2337
 
2327
- const isTimely =
2328
- secFromSlot >= 0 && secFromSlot * 1000 < chain.config.getInclusionListDueMs(chain.config.getForkName(slot));
2338
+ const isTimely = secFromSlot * 1000 < chain.config.getInclusionListDueMs(chain.config.getForkName(slot));
2329
2339
  chain.inclusionListStore.process(signedInclusionList, committeeIndices, isTimely);
2330
2340
 
2331
2341
  chain.emitter.emit(routes.events.EventType.inclusionList, {
@@ -19,6 +19,11 @@ const RECONSTRUCTION_DELAY_MIN_BPS = 667;
19
19
  */
20
20
  const RECONSTRUCTION_DELAY_MAX_BPS = 1000;
21
21
 
22
+ /**
23
+ * Maximum time a column request waits for a pending reconstruction, covers the delay and the recovery itself
24
+ */
25
+ export const RECONSTRUCTED_COLUMNS_WAIT_BPS = 2500;
26
+
22
27
  const QUEUE_MAX_LENGTH = 16;
23
28
 
24
29
  export type ColumnReconstructionInput = BlockInputColumns | PayloadEnvelopeInput;
@@ -50,6 +50,15 @@ export async function getHistoricalState(
50
50
  const transitionTimer = metrics?.stateTransitionTime.startTimer();
51
51
  let blockCount = 0;
52
52
  for await (const block of db.blockArchive.valuesStream({gt: state.slot, lte: slot})) {
53
+ // Pruned history keeps the genesis state but not the blocks after it, without this check the
54
+ // first block would only be rejected after processing every slot in between
55
+ if (
56
+ blockCount === 0 &&
57
+ !byteArrayEquals(block.message.parentRoot, state.computeAnchorCheckpoint().checkpoint.root)
58
+ ) {
59
+ metrics?.regenErrorCount.inc({reason: RegenErrorType.blockProcessing});
60
+ throw Error(`Archived blocks do not extend nearest state slot=${state.slot} blockSlot=${block.message.slot}`);
61
+ }
53
62
  try {
54
63
  state = state.stateTransition(
55
64
  {block},
@@ -284,7 +284,7 @@ export async function archiveBlocks(
284
284
  }
285
285
 
286
286
  // Delete expired data column sidecars
287
- // Keep only `[min(compute_blob_data_retention_start_epoch(current_epoch), current_epoch - archiveDataEpochs)]`
287
+ // Keep only `[current_epoch - max(MIN_EPOCHS_FOR_DATA_COLUMN_SIDECARS_REQUESTS, archiveDataEpochs)]`
288
288
  if (finalizedPostFulu) {
289
289
  if (archiveDataEpochs !== Infinity) {
290
290
  const dataColumnSidecarsMinEpoch = getDataColumnSidecarsMinEpoch(config, currentEpoch, archiveDataEpochs);
@@ -1,4 +1,5 @@
1
1
  import {ChainForkConfig} from "@lodestar/config";
2
+ import {GENESIS_SLOT} from "@lodestar/params";
2
3
  import {computeStartSlotAtEpoch} from "@lodestar/state-transition";
3
4
  import {Epoch, Slot} from "@lodestar/types";
4
5
  import {Logger, prettyPrintIndices} from "@lodestar/utils";
@@ -13,6 +14,9 @@ import {Metrics} from "../../../metrics/index.js";
13
14
  */
14
15
  export const MAX_PRUNE_BLOCK_SLOTS_PER_RUN = 4096;
15
16
 
17
+ // Genesis is kept so the block and state stay available via the API, e.g. for checkpoint providers
18
+ const FIRST_PRUNABLE_SLOT = GENESIS_SLOT + 1;
19
+
16
20
  export async function pruneHistory(
17
21
  config: ChainForkConfig,
18
22
  db: IBeaconDb,
@@ -30,11 +34,12 @@ export async function pruneHistory(
30
34
  // ensure that during (extremely lol) long periods of non-finality we don't delete unfinalized epoch data
31
35
  finalizedEpoch
32
36
  );
33
- const firstBlockSlot = (await db.blockArchive.firstKey()) ?? 0;
37
+ const [firstBlockSlot = FIRST_PRUNABLE_SLOT] = await db.blockArchive.keys({gte: FIRST_PRUNABLE_SLOT, limit: 1});
34
38
  const blockCutoffSlot = Math.min(computeStartSlotAtEpoch(blockCutoffEpoch), firstBlockSlot + maxBlockSlots);
35
39
  // The latest archived state is the anchor on restart and can trail finalization by a few epochs
36
40
  const lastArchivedStateSlot = (await db.stateArchive.lastKey()) ?? 0;
37
41
  const stateCutoffSlot = Math.min(computeStartSlotAtEpoch(finalizedEpoch), lastArchivedStateSlot);
42
+ const stateStartSlot = Math.max(statePruneFromSlot, FIRST_PRUNABLE_SLOT);
38
43
 
39
44
  logger.debug("Preparing to prune history", {
40
45
  currentEpoch,
@@ -46,9 +51,9 @@ export async function pruneHistory(
46
51
 
47
52
  const step0 = metrics?.pruneHistory.fetchKeys.startTimer();
48
53
  const [blocks, envelopes, states] = await Promise.all([
49
- db.blockArchive.keys({gte: 0, lt: blockCutoffSlot}),
50
- db.executionPayloadEnvelopeArchive.keys({gte: 0, lt: blockCutoffSlot}),
51
- stateCutoffSlot > statePruneFromSlot ? db.stateArchive.keys({gte: statePruneFromSlot, lt: stateCutoffSlot}) : [],
54
+ db.blockArchive.keys({gte: FIRST_PRUNABLE_SLOT, lt: blockCutoffSlot}),
55
+ db.executionPayloadEnvelopeArchive.keys({gte: FIRST_PRUNABLE_SLOT, lt: blockCutoffSlot}),
56
+ stateCutoffSlot > stateStartSlot ? db.stateArchive.keys({gte: stateStartSlot, lt: stateCutoffSlot}) : [],
52
57
  ]);
53
58
  step0?.();
54
59
 
@@ -493,12 +493,15 @@ export class BlockInputColumns extends AbstractBlockInput<ForkColumnsDA, fulu.Da
493
493
  const hasComputedAllData =
494
494
  // has all sampled columns
495
495
  sampledColumns.length === this.sampledColumns.length;
496
+ // A column after the block and its data were complete does not move the completion time
497
+ const timeCompleteSec =
498
+ this.state.hasBlock && this.state.hasAllData ? this.state.timeCompleteSec : seenTimestampSec;
496
499
 
497
500
  this.state = {
498
501
  ...this.state,
499
502
  hasAllData: hasAllData || this.state.hasAllData,
500
503
  hasComputedAllData: hasComputedAllData || this.state.hasComputedAllData,
501
- timeCompleteSec: hasAllData ? seenTimestampSec : undefined,
504
+ timeCompleteSec: hasAllData ? timeCompleteSec : undefined,
502
505
  } as BlockInputColumnsState;
503
506
 
504
507
  if (hasAllData && sampledColumns !== null) {
@@ -5,7 +5,9 @@ import {
5
5
  ForkChoiceError,
6
6
  ForkChoiceErrorCode,
7
7
  InvalidBlockCode,
8
+ LVHInvalidJudged,
8
9
  PayloadExecutionStatus,
10
+ PayloadStatus,
9
11
  getFinalizedExecutionBlockHash,
10
12
  getSafeExecutionBlockHash,
11
13
  } from "@lodestar/fork-choice";
@@ -16,11 +18,12 @@ import {
16
18
  isStatePostHeze,
17
19
  } from "@lodestar/state-transition";
18
20
  import {RootHex, bellatrix} from "@lodestar/types";
19
- import {isErrorAborted} from "@lodestar/utils";
21
+ import {isErrorAborted, toRootHex} from "@lodestar/utils";
20
22
  import {ExecutionPayloadStatus} from "../../execution/index.js";
21
23
  import {getShufflingDependentRoot} from "../../util/dependentRoot.js";
22
24
  import {isQueueErrorAborted} from "../../util/queue/index.js";
23
25
  import {BeaconChain} from "../chain.js";
26
+ import {ExecutionInvalidSource} from "../forkChoice/index.js";
24
27
  import {RegenCaller} from "../regen/interface.js";
25
28
  import {PayloadEnvelopeInput} from "../seenCache/seenPayloadEnvelopeInput.js";
26
29
  import {PayloadEnvelopeInputSource} from "./payloadEnvelopeInput/index.js";
@@ -115,7 +118,7 @@ function toForkChoiceExecutionStatus(status: ExecutionPayloadStatus): PayloadExe
115
118
  * 3. Regenerate state for envelope verification
116
119
  * 4. Verify envelope (fields against state, signature, and EL in parallel where possible)
117
120
  * 5. Persist verified payload envelope to hot DB (waits for write-queue space for backpressure)
118
- * 6. Update fork choice (transitions the block's PENDING variant to FULL)
121
+ * 6. Update fork choice (transitions the block's PENDING variant to FULL) and emit head events if the head changed
119
122
  * 7. Queue notifyForkchoiceUpdate to engine api
120
123
  * 8. Record metrics for payload envelope and column sources
121
124
  * 9. Emit `execution_payload` event
@@ -267,12 +270,29 @@ export async function importExecutionPayload(
267
270
  case ExecutionPayloadStatus.VALID:
268
271
  break;
269
272
 
270
- case ExecutionPayloadStatus.INVALID:
273
+ case ExecutionPayloadStatus.INVALID: {
274
+ // An LVH above the parent means the payload chain this block builds on is invalid too. The rejected payload
275
+ // itself never enters fork choice, so an LVH equal to the parent hash changes nothing
276
+ const parentHashHex = toRootHex(envelope.payload.parentHash);
277
+ if (execResult.latestValidHash !== null && execResult.latestValidHash !== parentHashHex) {
278
+ this.executionEngine.invalidateExecutionPayloads(
279
+ {
280
+ executionStatus: ExecutionStatus.Invalid,
281
+ latestValidExecHash: execResult.latestValidHash,
282
+ invalidateFromBlockRoot: protoBlock.parentRoot,
283
+ invalidateFromBlockHash: parentHashHex,
284
+ judged: LVHInvalidJudged.ChildPayload,
285
+ },
286
+ ExecutionInvalidSource.newPayload,
287
+ {slot, root: blockRootHex, payloadBlockHash: blockHashHex}
288
+ );
289
+ }
271
290
  throw new PayloadError(payloadInput, {
272
291
  code: PayloadErrorCode.EXECUTION_ENGINE_INVALID,
273
292
  execStatus: execResult.status,
274
293
  errorMessage: execResult.validationError ?? "",
275
294
  });
295
+ }
276
296
 
277
297
  case ExecutionPayloadStatus.ACCEPTED:
278
298
  case ExecutionPayloadStatus.SYNCING:
@@ -337,6 +357,7 @@ export async function importExecutionPayload(
337
357
 
338
358
  // 6. Update fork choice, transitions the block's PENDING variant to FULL
339
359
  const execStatus = toForkChoiceExecutionStatus(execResult.status);
360
+ const prevHead = this.forkChoice.getHead();
340
361
  try {
341
362
  this.forkChoice.onExecutionPayload(
342
363
  blockRootHex,
@@ -357,12 +378,17 @@ export async function importExecutionPayload(
357
378
  }
358
379
  throw e;
359
380
  }
381
+ const head = this.forkChoice.getHead();
382
+ this.emitHeadEvents(prevHead, head);
383
+ if (head.blockRoot !== prevHead.blockRoot) {
384
+ this.onHeadChanged(prevHead, head);
385
+ }
360
386
 
361
387
  // 7. Queue notifyForkchoiceUpdate to engine api
362
- const head = this.forkChoice.getHead();
363
388
  if (
364
389
  !this.opts.disableImportExecutionFcU &&
365
390
  blockRootHex === head.blockRoot &&
391
+ head.payloadStatus === PayloadStatus.FULL &&
366
392
  // Skip a payload that does not satisfy the inclusion list constraints, fork choice keeps the EMPTY
367
393
  // variant as head and the next prepare fcU keeps the engine on the parent payload
368
394
  this.forkChoice.isPayloadInclusionListSatisfied(blockRootHex)
@@ -1,7 +1,7 @@
1
1
  import {PayloadStatus} from "@lodestar/fork-choice";
2
2
  import {computeEpochAtSlot} from "@lodestar/state-transition";
3
3
  import {SignedBeaconBlock, Slot} from "@lodestar/types";
4
- import {isErrorAborted, toRootHex} from "@lodestar/utils";
4
+ import {isErrorAborted} from "@lodestar/utils";
5
5
  import {Metrics} from "../../metrics/metrics.js";
6
6
  import {nextEventLoop} from "../../util/eventLoop.js";
7
7
  import {JobItemQueue, isQueueErrorAborted} from "../../util/queue/index.js";
@@ -208,36 +208,9 @@ export async function processBlocks(
208
208
  this.logger.debug("Block error", {slot: err.signedBlock.message.slot}, err);
209
209
 
210
210
  if (err.type.code === BlockErrorCode.INVALID_SIGNATURE) {
211
- const {signedBlock} = err;
212
- const blockSlot = signedBlock.message.slot;
213
- const {state} = err.type;
214
- const forkTypes = this.config.getForkTypes(blockSlot);
215
- const blockRootHex = toRootHex(forkTypes.BeaconBlock.hashTreeRoot(signedBlock.message));
216
- this.persistInvalidSszValue(
217
- forkTypes.SignedBeaconBlock,
218
- signedBlock,
219
- `${blockSlot}_invalid_signature`,
220
- blockRootHex
221
- );
222
- this.persistInvalidSszBytes(
223
- "BeaconState",
224
- state.serialize(),
225
- toRootHex(state.hashTreeRoot()),
226
- `${state.slot}_invalid_signature`
227
- );
211
+ void this.persistInvalidSignature(err.type.state, err.signedBlock);
228
212
  } else if (err.type.code === BlockErrorCode.INVALID_STATE_ROOT) {
229
- const {signedBlock} = err;
230
- const blockSlot = signedBlock.message.slot;
231
- const {preState, postState} = err.type;
232
- const preRoot = preState.hashTreeRoot();
233
- const postRoot = postState.hashTreeRoot();
234
- this.persistInvalidStateRoot(preState, postState, signedBlock).catch((e) => {
235
- this.logger.error(
236
- "Error persisting invalid state root objects",
237
- {slot: blockSlot, preStateRoot: toRootHex(preRoot), postStateRoot: toRootHex(postRoot)},
238
- e
239
- );
240
- });
213
+ void this.persistInvalidStateRoot(err.type.preState, err.type.postState, err.signedBlock);
241
214
  }
242
215
  }
243
216
 
@@ -307,7 +280,6 @@ async function importPayloadEnvelopesOfKnownBlocks(
307
280
  });
308
281
  await importExecutionPayload.call(this, payloadInputs[i], dataAvailabilityStatuses[i], {validSignature: false});
309
282
  }
310
- // the new FULL variants are not seen by the head cached from the last block import
311
283
  this.recomputeForkChoiceHead(ForkchoiceCaller.importBlock);
312
284
 
313
285
  return result;