@lodestar/beacon-node 1.52.0-dev.9c81d25e01 → 1.52.0-dev.a3cc0e0e58

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 (353) hide show
  1. package/lib/api/impl/beacon/blocks/index.d.ts.map +1 -1
  2. package/lib/api/impl/beacon/blocks/index.js +64 -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 +4 -2
  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 +91 -51
  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/importExecutionPayload.d.ts +1 -1
  29. package/lib/chain/blocks/importExecutionPayload.d.ts.map +1 -1
  30. package/lib/chain/blocks/importExecutionPayload.js +9 -3
  31. package/lib/chain/blocks/importExecutionPayload.js.map +1 -1
  32. package/lib/chain/blocks/index.d.ts.map +1 -1
  33. package/lib/chain/blocks/index.js +3 -17
  34. package/lib/chain/blocks/index.js.map +1 -1
  35. package/lib/chain/chain.d.ts +7 -6
  36. package/lib/chain/chain.d.ts.map +1 -1
  37. package/lib/chain/chain.js +92 -47
  38. package/lib/chain/chain.js.map +1 -1
  39. package/lib/chain/errors/attestationError.d.ts +15 -1
  40. package/lib/chain/errors/attestationError.d.ts.map +1 -1
  41. package/lib/chain/errors/attestationError.js +8 -0
  42. package/lib/chain/errors/attestationError.js.map +1 -1
  43. package/lib/chain/errors/executionPayloadBid.d.ts +9 -3
  44. package/lib/chain/errors/executionPayloadBid.d.ts.map +1 -1
  45. package/lib/chain/errors/executionPayloadBid.js +2 -1
  46. package/lib/chain/errors/executionPayloadBid.js.map +1 -1
  47. package/lib/chain/errors/executionPayloadEnvelope.d.ts +55 -0
  48. package/lib/chain/errors/executionPayloadEnvelope.d.ts.map +1 -1
  49. package/lib/chain/errors/executionPayloadEnvelope.js +8 -0
  50. package/lib/chain/errors/executionPayloadEnvelope.js.map +1 -1
  51. package/lib/chain/interface.d.ts +1 -1
  52. package/lib/chain/interface.d.ts.map +1 -1
  53. package/lib/chain/lightClient/index.d.ts +13 -6
  54. package/lib/chain/lightClient/index.d.ts.map +1 -1
  55. package/lib/chain/lightClient/index.js +95 -115
  56. package/lib/chain/lightClient/index.js.map +1 -1
  57. package/lib/chain/opPools/opPool.js +6 -6
  58. package/lib/chain/opPools/opPool.js.map +1 -1
  59. package/lib/chain/prepareNextSlot.d.ts +45 -0
  60. package/lib/chain/prepareNextSlot.d.ts.map +1 -1
  61. package/lib/chain/prepareNextSlot.js +265 -69
  62. package/lib/chain/prepareNextSlot.js.map +1 -1
  63. package/lib/chain/produceBlock/produceBlockBody.d.ts +6 -2
  64. package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
  65. package/lib/chain/produceBlock/produceBlockBody.js +54 -64
  66. package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
  67. package/lib/chain/seenCache/seenAttesters.d.ts +1 -0
  68. package/lib/chain/seenCache/seenAttesters.d.ts.map +1 -1
  69. package/lib/chain/seenCache/seenAttesters.js +1 -1
  70. package/lib/chain/seenCache/seenAttesters.js.map +1 -1
  71. package/lib/chain/seenCache/seenBlockAttesters.d.ts +8 -2
  72. package/lib/chain/seenCache/seenBlockAttesters.d.ts.map +1 -1
  73. package/lib/chain/seenCache/seenBlockAttesters.js +43 -6
  74. package/lib/chain/seenCache/seenBlockAttesters.js.map +1 -1
  75. package/lib/chain/seenCache/seenExecutionPayloadBids.d.ts +13 -4
  76. package/lib/chain/seenCache/seenExecutionPayloadBids.d.ts.map +1 -1
  77. package/lib/chain/seenCache/seenExecutionPayloadBids.js +13 -12
  78. package/lib/chain/seenCache/seenExecutionPayloadBids.js.map +1 -1
  79. package/lib/chain/validation/aggregateAndProof.d.ts.map +1 -1
  80. package/lib/chain/validation/aggregateAndProof.js +24 -7
  81. package/lib/chain/validation/aggregateAndProof.js.map +1 -1
  82. package/lib/chain/validation/attestation.d.ts.map +1 -1
  83. package/lib/chain/validation/attestation.js +32 -16
  84. package/lib/chain/validation/attestation.js.map +1 -1
  85. package/lib/chain/validation/attesterSlashing.d.ts.map +1 -1
  86. package/lib/chain/validation/attesterSlashing.js +4 -2
  87. package/lib/chain/validation/attesterSlashing.js.map +1 -1
  88. package/lib/chain/validation/block.d.ts.map +1 -1
  89. package/lib/chain/validation/block.js +9 -1
  90. package/lib/chain/validation/block.js.map +1 -1
  91. package/lib/chain/validation/executionPayloadBid.d.ts.map +1 -1
  92. package/lib/chain/validation/executionPayloadBid.js +47 -42
  93. package/lib/chain/validation/executionPayloadBid.js.map +1 -1
  94. package/lib/chain/validation/executionPayloadEnvelope.d.ts.map +1 -1
  95. package/lib/chain/validation/executionPayloadEnvelope.js +100 -9
  96. package/lib/chain/validation/executionPayloadEnvelope.js.map +1 -1
  97. package/lib/chain/validation/payloadAttestationMessage.js +9 -0
  98. package/lib/chain/validation/payloadAttestationMessage.js.map +1 -1
  99. package/lib/chain/validation/proposerSlashing.js +4 -2
  100. package/lib/chain/validation/proposerSlashing.js.map +1 -1
  101. package/lib/chain/validation/signatureSets/contributionAndProof.d.ts +2 -2
  102. package/lib/chain/validation/signatureSets/contributionAndProof.d.ts.map +1 -1
  103. package/lib/chain/validation/signatureSets/contributionAndProof.js +2 -2
  104. package/lib/chain/validation/signatureSets/contributionAndProof.js.map +1 -1
  105. package/lib/chain/validation/signatureSets/syncCommittee.d.ts +2 -2
  106. package/lib/chain/validation/signatureSets/syncCommittee.d.ts.map +1 -1
  107. package/lib/chain/validation/signatureSets/syncCommittee.js +2 -2
  108. package/lib/chain/validation/signatureSets/syncCommittee.js.map +1 -1
  109. package/lib/chain/validation/signatureSets/syncCommitteeContribution.d.ts +2 -2
  110. package/lib/chain/validation/signatureSets/syncCommitteeContribution.d.ts.map +1 -1
  111. package/lib/chain/validation/signatureSets/syncCommitteeContribution.js +2 -2
  112. package/lib/chain/validation/signatureSets/syncCommitteeContribution.js.map +1 -1
  113. package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.d.ts +2 -2
  114. package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.d.ts.map +1 -1
  115. package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.js +2 -2
  116. package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.js.map +1 -1
  117. package/lib/chain/validation/syncCommittee.d.ts +1 -1
  118. package/lib/chain/validation/syncCommittee.d.ts.map +1 -1
  119. package/lib/chain/validation/syncCommittee.js +5 -5
  120. package/lib/chain/validation/syncCommittee.js.map +1 -1
  121. package/lib/chain/validation/syncCommitteeContributionAndProof.js +3 -3
  122. package/lib/chain/validation/syncCommitteeContributionAndProof.js.map +1 -1
  123. package/lib/chain/validation/voluntaryExit.d.ts.map +1 -1
  124. package/lib/chain/validation/voluntaryExit.js +39 -6
  125. package/lib/chain/validation/voluntaryExit.js.map +1 -1
  126. package/lib/chain/validatorMonitor.js +43 -43
  127. package/lib/chain/validatorMonitor.js.map +1 -1
  128. package/lib/execution/engine/blockHash.d.ts +12 -0
  129. package/lib/execution/engine/blockHash.d.ts.map +1 -0
  130. package/lib/execution/engine/blockHash.js +17 -0
  131. package/lib/execution/engine/blockHash.js.map +1 -0
  132. package/lib/execution/engine/http.d.ts +2 -2
  133. package/lib/execution/engine/http.d.ts.map +1 -1
  134. package/lib/execution/engine/http.js +13 -7
  135. package/lib/execution/engine/http.js.map +1 -1
  136. package/lib/execution/engine/interface.d.ts +16 -3
  137. package/lib/execution/engine/interface.d.ts.map +1 -1
  138. package/lib/execution/engine/interface.js +11 -0
  139. package/lib/execution/engine/interface.js.map +1 -1
  140. package/lib/execution/engine/jsonRpcHttpClient.d.ts +2 -0
  141. package/lib/execution/engine/jsonRpcHttpClient.d.ts.map +1 -1
  142. package/lib/execution/engine/jsonRpcHttpClient.js +14 -6
  143. package/lib/execution/engine/jsonRpcHttpClient.js.map +1 -1
  144. package/lib/execution/engine/jsonRpcTransport.d.ts +2 -2
  145. package/lib/execution/engine/jsonRpcTransport.d.ts.map +1 -1
  146. package/lib/execution/engine/jsonRpcTransport.js +4 -4
  147. package/lib/execution/engine/jsonRpcTransport.js.map +1 -1
  148. package/lib/execution/engine/mock.d.ts.map +1 -1
  149. package/lib/execution/engine/mock.js +6 -6
  150. package/lib/execution/engine/mock.js.map +1 -1
  151. package/lib/execution/engine/payloadIdCache.d.ts +6 -1
  152. package/lib/execution/engine/payloadIdCache.d.ts.map +1 -1
  153. package/lib/execution/engine/payloadIdCache.js +7 -2
  154. package/lib/execution/engine/payloadIdCache.js.map +1 -1
  155. package/lib/execution/engine/restHttpClient.d.ts.map +1 -1
  156. package/lib/execution/engine/restHttpClient.js +9 -5
  157. package/lib/execution/engine/restHttpClient.js.map +1 -1
  158. package/lib/execution/engine/restTransport.d.ts +2 -2
  159. package/lib/execution/engine/restTransport.d.ts.map +1 -1
  160. package/lib/execution/engine/restTransport.js +4 -4
  161. package/lib/execution/engine/restTransport.js.map +1 -1
  162. package/lib/execution/engine/signal.d.ts +6 -0
  163. package/lib/execution/engine/signal.d.ts.map +1 -0
  164. package/lib/execution/engine/signal.js +24 -0
  165. package/lib/execution/engine/signal.js.map +1 -0
  166. package/lib/execution/engine/transport.d.ts +2 -2
  167. package/lib/execution/engine/transport.d.ts.map +1 -1
  168. package/lib/index.d.ts +1 -1
  169. package/lib/index.d.ts.map +1 -1
  170. package/lib/index.js +1 -1
  171. package/lib/index.js.map +1 -1
  172. package/lib/metrics/metrics/beacon.d.ts +5 -0
  173. package/lib/metrics/metrics/beacon.d.ts.map +1 -1
  174. package/lib/metrics/metrics/beacon.js +5 -0
  175. package/lib/metrics/metrics/beacon.js.map +1 -1
  176. package/lib/metrics/metrics/lodestar.d.ts +1 -0
  177. package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
  178. package/lib/metrics/metrics/lodestar.js +5 -0
  179. package/lib/metrics/metrics/lodestar.js.map +1 -1
  180. package/lib/network/core/events.d.ts +6 -2
  181. package/lib/network/core/events.d.ts.map +1 -1
  182. package/lib/network/core/events.js +9 -0
  183. package/lib/network/core/events.js.map +1 -1
  184. package/lib/network/core/networkCoreWorkerHandler.d.ts.map +1 -1
  185. package/lib/network/core/networkCoreWorkerHandler.js +3 -2
  186. package/lib/network/core/networkCoreWorkerHandler.js.map +1 -1
  187. package/lib/network/gossip/gossipsub.d.ts +1 -0
  188. package/lib/network/gossip/gossipsub.d.ts.map +1 -1
  189. package/lib/network/gossip/gossipsub.js +5 -2
  190. package/lib/network/gossip/gossipsub.js.map +1 -1
  191. package/lib/network/gossip/topic.d.ts +1 -7
  192. package/lib/network/gossip/topic.d.ts.map +1 -1
  193. package/lib/network/gossip/topic.js +0 -13
  194. package/lib/network/gossip/topic.js.map +1 -1
  195. package/lib/network/network.d.ts +1 -0
  196. package/lib/network/network.d.ts.map +1 -1
  197. package/lib/network/network.js +32 -18
  198. package/lib/network/network.js.map +1 -1
  199. package/lib/network/peers/peerManager.d.ts.map +1 -1
  200. package/lib/network/peers/peerManager.js +22 -2
  201. package/lib/network/peers/peerManager.js.map +1 -1
  202. package/lib/network/peers/utils/prioritizePeers.d.ts +2 -0
  203. package/lib/network/peers/utils/prioritizePeers.d.ts.map +1 -1
  204. package/lib/network/peers/utils/prioritizePeers.js +11 -2
  205. package/lib/network/peers/utils/prioritizePeers.js.map +1 -1
  206. package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
  207. package/lib/network/processor/gossipHandlers.js +19 -6
  208. package/lib/network/processor/gossipHandlers.js.map +1 -1
  209. package/lib/network/processor/gossipValidatorFn.d.ts.map +1 -1
  210. package/lib/network/processor/gossipValidatorFn.js +4 -1
  211. package/lib/network/processor/gossipValidatorFn.js.map +1 -1
  212. package/lib/network/processor/index.d.ts.map +1 -1
  213. package/lib/network/processor/index.js +4 -2
  214. package/lib/network/processor/index.js.map +1 -1
  215. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js +1 -1
  216. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js.map +1 -1
  217. package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.js +1 -1
  218. package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.js.map +1 -1
  219. package/lib/network/reqresp/utils/collect.d.ts +4 -4
  220. package/lib/network/reqresp/utils/collect.d.ts.map +1 -1
  221. package/lib/network/reqresp/utils/collect.js +9 -8
  222. package/lib/network/reqresp/utils/collect.js.map +1 -1
  223. package/lib/network/reqresp/utils/collectSequentialBlocksInRange.d.ts +1 -1
  224. package/lib/network/reqresp/utils/collectSequentialBlocksInRange.d.ts.map +1 -1
  225. package/lib/network/reqresp/utils/collectSequentialBlocksInRange.js +2 -2
  226. package/lib/network/reqresp/utils/collectSequentialBlocksInRange.js.map +1 -1
  227. package/lib/sync/range/batch.d.ts +10 -0
  228. package/lib/sync/range/batch.d.ts.map +1 -1
  229. package/lib/sync/range/batch.js +29 -0
  230. package/lib/sync/range/batch.js.map +1 -1
  231. package/lib/sync/range/chain.d.ts +17 -2
  232. package/lib/sync/range/chain.d.ts.map +1 -1
  233. package/lib/sync/range/chain.js +60 -20
  234. package/lib/sync/range/chain.js.map +1 -1
  235. package/lib/sync/range/range.d.ts.map +1 -1
  236. package/lib/sync/range/range.js +44 -3
  237. package/lib/sync/range/range.js.map +1 -1
  238. package/lib/sync/range/utils/batches.d.ts +20 -4
  239. package/lib/sync/range/utils/batches.d.ts.map +1 -1
  240. package/lib/sync/range/utils/batches.js +31 -13
  241. package/lib/sync/range/utils/batches.js.map +1 -1
  242. package/lib/sync/range/utils/peerBalancer.d.ts +1 -1
  243. package/lib/sync/range/utils/peerBalancer.d.ts.map +1 -1
  244. package/lib/sync/range/utils/peerBalancer.js +5 -2
  245. package/lib/sync/range/utils/peerBalancer.js.map +1 -1
  246. package/lib/sync/types.d.ts +14 -1
  247. package/lib/sync/types.d.ts.map +1 -1
  248. package/lib/sync/types.js +2 -0
  249. package/lib/sync/types.js.map +1 -1
  250. package/lib/sync/unknownBlock.d.ts +28 -1
  251. package/lib/sync/unknownBlock.d.ts.map +1 -1
  252. package/lib/sync/unknownBlock.js +340 -27
  253. package/lib/sync/unknownBlock.js.map +1 -1
  254. package/lib/sync/utils/downloadByRange.d.ts +22 -1
  255. package/lib/sync/utils/downloadByRange.d.ts.map +1 -1
  256. package/lib/sync/utils/downloadByRange.js +55 -25
  257. package/lib/sync/utils/downloadByRange.js.map +1 -1
  258. package/lib/sync/utils/downloadByRoot.d.ts +24 -2
  259. package/lib/sync/utils/downloadByRoot.d.ts.map +1 -1
  260. package/lib/sync/utils/downloadByRoot.js +48 -5
  261. package/lib/sync/utils/downloadByRoot.js.map +1 -1
  262. package/lib/util/asyncIterableToEvents.d.ts +20 -3
  263. package/lib/util/asyncIterableToEvents.d.ts.map +1 -1
  264. package/lib/util/asyncIterableToEvents.js +76 -20
  265. package/lib/util/asyncIterableToEvents.js.map +1 -1
  266. package/lib/util/dataColumns.d.ts +1 -1
  267. package/lib/util/dataColumns.d.ts.map +1 -1
  268. package/lib/util/dataColumns.js +4 -1
  269. package/lib/util/dataColumns.js.map +1 -1
  270. package/lib/util/eventLoop.d.ts +3 -3
  271. package/lib/util/eventLoop.d.ts.map +1 -1
  272. package/lib/util/eventLoop.js +3 -3
  273. package/lib/util/eventLoop.js.map +1 -1
  274. package/package.json +27 -27
  275. package/src/api/impl/beacon/blocks/index.ts +75 -47
  276. package/src/api/impl/beacon/pool/index.ts +10 -8
  277. package/src/api/impl/beacon/state/utils.ts +2 -1
  278. package/src/api/impl/debug/index.ts +6 -2
  279. package/src/api/impl/validator/index.ts +126 -68
  280. package/src/chain/ColumnReconstructionTracker.ts +5 -0
  281. package/src/chain/archiveStore/historicalState/getHistoricalState.ts +9 -0
  282. package/src/chain/archiveStore/utils/archiveBlocks.ts +1 -1
  283. package/src/chain/archiveStore/utils/pruneHistory.ts +9 -4
  284. package/src/chain/blocks/importExecutionPayload.ts +9 -2
  285. package/src/chain/blocks/index.ts +3 -31
  286. package/src/chain/chain.ts +124 -84
  287. package/src/chain/errors/attestationError.ts +11 -1
  288. package/src/chain/errors/executionPayloadBid.ts +9 -2
  289. package/src/chain/errors/executionPayloadEnvelope.ts +58 -0
  290. package/src/chain/interface.ts +1 -1
  291. package/src/chain/lightClient/index.ts +108 -142
  292. package/src/chain/opPools/opPool.ts +6 -6
  293. package/src/chain/prepareNextSlot.ts +347 -89
  294. package/src/chain/produceBlock/produceBlockBody.ts +69 -80
  295. package/src/chain/seenCache/seenAttesters.ts +1 -1
  296. package/src/chain/seenCache/seenBlockAttesters.ts +48 -6
  297. package/src/chain/seenCache/seenExecutionPayloadBids.ts +35 -15
  298. package/src/chain/validation/aggregateAndProof.ts +24 -9
  299. package/src/chain/validation/attestation.ts +31 -20
  300. package/src/chain/validation/attesterSlashing.ts +4 -2
  301. package/src/chain/validation/block.ts +9 -1
  302. package/src/chain/validation/executionPayloadBid.ts +60 -44
  303. package/src/chain/validation/executionPayloadEnvelope.ts +115 -8
  304. package/src/chain/validation/payloadAttestationMessage.ts +10 -0
  305. package/src/chain/validation/proposerSlashing.ts +4 -2
  306. package/src/chain/validation/signatureSets/contributionAndProof.ts +4 -6
  307. package/src/chain/validation/signatureSets/syncCommittee.ts +2 -3
  308. package/src/chain/validation/signatureSets/syncCommitteeContribution.ts +2 -3
  309. package/src/chain/validation/signatureSets/syncCommitteeSelectionProof.ts +2 -3
  310. package/src/chain/validation/syncCommittee.ts +3 -5
  311. package/src/chain/validation/syncCommitteeContributionAndProof.ts +3 -3
  312. package/src/chain/validation/voluntaryExit.ts +44 -6
  313. package/src/chain/validatorMonitor.ts +43 -43
  314. package/src/execution/engine/blockHash.ts +27 -0
  315. package/src/execution/engine/http.ts +18 -10
  316. package/src/execution/engine/interface.ts +18 -3
  317. package/src/execution/engine/jsonRpcHttpClient.ts +26 -14
  318. package/src/execution/engine/jsonRpcTransport.ts +8 -4
  319. package/src/execution/engine/mock.ts +13 -8
  320. package/src/execution/engine/payloadIdCache.ts +12 -4
  321. package/src/execution/engine/restHttpClient.ts +17 -11
  322. package/src/execution/engine/restTransport.ts +5 -4
  323. package/src/execution/engine/signal.ts +28 -0
  324. package/src/execution/engine/transport.ts +3 -2
  325. package/src/index.ts +6 -1
  326. package/src/metrics/metrics/beacon.ts +9 -0
  327. package/src/metrics/metrics/lodestar.ts +5 -0
  328. package/src/network/core/events.ts +12 -0
  329. package/src/network/core/networkCoreWorkerHandler.ts +6 -2
  330. package/src/network/gossip/gossipsub.ts +6 -2
  331. package/src/network/gossip/topic.ts +1 -14
  332. package/src/network/network.ts +45 -19
  333. package/src/network/peers/peerManager.ts +26 -2
  334. package/src/network/peers/utils/prioritizePeers.ts +14 -1
  335. package/src/network/processor/gossipHandlers.ts +25 -13
  336. package/src/network/processor/gossipValidatorFn.ts +4 -0
  337. package/src/network/processor/index.ts +7 -2
  338. package/src/network/reqresp/handlers/dataColumnSidecarsByRange.ts +1 -1
  339. package/src/network/reqresp/handlers/dataColumnSidecarsByRoot.ts +1 -1
  340. package/src/network/reqresp/utils/collect.ts +16 -8
  341. package/src/network/reqresp/utils/collectSequentialBlocksInRange.ts +3 -2
  342. package/src/sync/range/batch.ts +33 -0
  343. package/src/sync/range/chain.ts +72 -17
  344. package/src/sync/range/range.ts +57 -3
  345. package/src/sync/range/utils/batches.ts +38 -13
  346. package/src/sync/range/utils/peerBalancer.ts +4 -1
  347. package/src/sync/types.ts +13 -0
  348. package/src/sync/unknownBlock.ts +389 -29
  349. package/src/sync/utils/downloadByRange.ts +89 -29
  350. package/src/sync/utils/downloadByRoot.ts +75 -7
  351. package/src/util/asyncIterableToEvents.ts +100 -21
  352. package/src/util/dataColumns.ts +4 -1
  353. package/src/util/eventLoop.ts +3 -3
@@ -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;
@@ -178,6 +177,8 @@ function compareBidCandidates(a: BidCandidate, b: BidCandidate): number {
178
177
  return a.receivedMs - b.receivedMs;
179
178
  }
180
179
 
180
+ type ParentStates = {parentState: IBeaconStateView; parentStateWithPayload: IBeaconStateView};
181
+
181
182
  type ProduceBlockContentsRes = {executionPayloadValue: Wei; consensusBlockValue: Wei} & {
182
183
  data: BlockContents<ForkPreGloas>;
183
184
  version: ForkPreGloas;
@@ -408,7 +409,7 @@ export function getValidatorApi(
408
409
  * Both the above scenarios could be problematic and hence validator shouldn't participate
409
410
  * or weigh its vote on a head till it resolves to a Valid execution status.
410
411
  * Following activities should be skipped on an Optimistic head (with Syncing status):
411
- * 1. Attestation if targetRoot is optimistic
412
+ * 1. Attestation if the head block voted for (post-gloas the variant voted for) or the targetRoot is optimistic
412
413
  * 2. SyncCommitteeContribution if if the root for which to produce contribution is Optimistic.
413
414
  * 3. ProduceBlock if the parentRoot (chain's current head) is optimistic. Must be checked
414
415
  * explicitly as only local payload production consults the EL, blinded blocks from an
@@ -449,9 +450,11 @@ export function getValidatorApi(
449
450
  {
450
451
  commonBlockBodyPromise,
451
452
  parentBlock,
453
+ parentStatesPromise,
452
454
  }: Omit<routes.validator.ExtraProduceBlockOpts, "builderSelection"> & {
453
455
  commonBlockBodyPromise: Promise<CommonBlockBody>;
454
456
  parentBlock: ProtoBlock;
457
+ parentStatesPromise: Promise<ParentStates>;
455
458
  }
456
459
  ): Promise<ProduceBlindedBlockRes> {
457
460
  const version = config.getForkName(slot);
@@ -486,6 +489,7 @@ export function getValidatorApi(
486
489
  randaoReveal,
487
490
  graffiti,
488
491
  commonBlockBodyPromise,
492
+ ...(await parentStatesPromise),
489
493
  });
490
494
 
491
495
  metrics?.blockProductionSuccess.inc({source});
@@ -518,9 +522,11 @@ export function getValidatorApi(
518
522
  strictFeeRecipientCheck,
519
523
  commonBlockBodyPromise,
520
524
  parentBlock,
525
+ parentStatesPromise,
521
526
  }: Omit<routes.validator.ExtraProduceBlockOpts, "builderSelection"> & {
522
527
  commonBlockBodyPromise: Promise<CommonBlockBody>;
523
528
  parentBlock: ProtoBlock;
529
+ parentStatesPromise: Promise<ParentStates>;
524
530
  }
525
531
  ): Promise<ProduceBlockContentsRes & {shouldOverrideBuilder?: boolean}> {
526
532
  const version = config.getForkName(slot);
@@ -540,6 +546,7 @@ export function getValidatorApi(
540
546
  graffiti,
541
547
  feeRecipient,
542
548
  commonBlockBodyPromise,
549
+ ...(await parentStatesPromise),
543
550
  });
544
551
  if (strictFeeRecipientCheck && feeRecipient && isForkPostBellatrix(version)) {
545
552
  const blockFeeRecipient = toHex((block as bellatrix.BeaconBlock).body.executionPayload.feeRecipient);
@@ -635,6 +642,13 @@ export function getValidatorApi(
635
642
  notOnOutOfRangeData(parentBlockRoot);
636
643
  metrics?.blockProductionSlotDelta.set(slot - parentSlot);
637
644
 
645
+ // Fetch the production state once and thread it to all downstream production calls, not awaited so each
646
+ // block source includes it in its production time. Only reached for pre-gloas slots (produceBlockV3 rejects
647
+ // post-gloas forks), the execution payload is part of the parent block so its state already includes it
648
+ const parentStatesPromise: Promise<ParentStates> = chain.regen
649
+ .getBlockSlotState(parentBlock, slot, {dontTransferCache: true}, RegenCaller.produceBlock)
650
+ .then((parentState) => ({parentState, parentStateWithPayload: parentState}));
651
+
638
652
  const fork = config.getForkName(slot);
639
653
 
640
654
  const isBuilderEnabled =
@@ -677,6 +691,7 @@ export function getValidatorApi(
677
691
  strictFeeRecipientCheck: false,
678
692
  commonBlockBodyPromise,
679
693
  parentBlock,
694
+ parentStatesPromise,
680
695
  })
681
696
  : Promise.reject(new Error("Builder disabled"));
682
697
 
@@ -685,6 +700,7 @@ export function getValidatorApi(
685
700
  strictFeeRecipientCheck,
686
701
  commonBlockBodyPromise,
687
702
  parentBlock,
703
+ parentStatesPromise,
688
704
  }).then((engineBlock) => {
689
705
  // Once the engine returns a block, in the event of either:
690
706
  // - suspected builder censorship
@@ -720,28 +736,28 @@ export function getValidatorApi(
720
736
  });
721
737
 
722
738
  // Ensure builder and engine HTTP requests are sent before starting common block body production
723
- // by deferring the call to next event loop iteration, allowing pending I/O operations like
724
- // HTTP requests to be processed first and sent out early in slot.
725
- callInNextEventLoop(() => {
726
- logger.verbose("Producing common block body", loggerContext);
727
- const commonBlockBodyStartedAt = Date.now();
728
-
729
- chain
730
- .produceCommonBlockBody({
731
- slot,
732
- parentBlock,
733
- randaoReveal,
734
- graffiti: graffitiBytes,
735
- })
736
- .then((commonBlockBody) => {
737
- deferredCommonBlockBody.resolve(commonBlockBody);
738
- logger.verbose("Produced common block body", {
739
- ...loggerContext,
740
- durationMs: Date.now() - commonBlockBodyStartedAt,
741
- });
742
- })
743
- .catch(deferredCommonBlockBody.reject);
744
- });
739
+ // by deferring the call to next event loop iteration once the state is available, allowing pending
740
+ // I/O operations like HTTP requests to be processed first and sent out early in slot.
741
+ parentStatesPromise.then(
742
+ (parentStates) =>
743
+ callInNextEventLoop(() => {
744
+ logger.verbose("Producing common block body", loggerContext);
745
+ const commonBlockBodyStartedAt = Date.now();
746
+
747
+ chain
748
+ .produceCommonBlockBody({slot, parentBlock, randaoReveal, graffiti: graffitiBytes, ...parentStates})
749
+ .then((commonBlockBody) => {
750
+ deferredCommonBlockBody.resolve(commonBlockBody);
751
+ logger.verbose("Produced common block body", {
752
+ ...loggerContext,
753
+ durationMs: Date.now() - commonBlockBodyStartedAt,
754
+ });
755
+ })
756
+ .catch(deferredCommonBlockBody.reject);
757
+ }),
758
+ // Both block sources fail on the state themselves and do not await the common block body
759
+ () => {}
760
+ );
745
761
 
746
762
  const [builder, engine] = await blockProductionRacePromise;
747
763
 
@@ -1009,19 +1025,23 @@ export function getValidatorApi(
1009
1025
  (!circuitBreakerActive &&
1010
1026
  chain.executionPayloadBidPool.getBestBid(slot, bidParentBlockHash, parentBlockRootHex) !== null);
1011
1027
 
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
- );
1028
+ // Cutoff time into the slot, ensures a slow local payload build does not delay the proposal when a
1029
+ // builder bid block is available (and vice versa). Each timer waits for the time left until the cutoff
1030
+ const cutoffMs = config.getSlotComponentDurationMs(fork, BLOCK_PRODUCTION_RACE_CUTOFF_GLOAS_BPS);
1031
+ const msToCutoff = (): number => Math.max(0, cutoffMs - chain.clock.msFromSlot(slot));
1018
1032
 
1019
1033
  // Give p2p bids the same time to bid up as granted to builder API bid requests via the advertised
1020
1034
  // deadline, the pool is read once the deadline passed and the bid requests settled. A late request
1021
1035
  // does not wait past the race cutoff, a pooled bid is still the fastest fallback if the local block fails
1022
1036
  const bidDeadlinePromise = circuitBreakerActive
1023
1037
  ? Promise.resolve()
1024
- : sleep(Math.min(chain.builderApiClient.bidDeadline, cutoffMs));
1038
+ : sleep(Math.min(chain.builderApiClient.bidDeadline, msToCutoff()));
1039
+
1040
+ let parentExecutionRequestsPromise: Promise<gloas.ExecutionRequests> | null = null;
1041
+ const getParentExecutionRequests = (): Promise<gloas.ExecutionRequests> => {
1042
+ parentExecutionRequestsPromise ??= chain.getParentExecutionRequests(parentSlot, parentBlockRootHex);
1043
+ return parentExecutionRequestsPromise;
1044
+ };
1025
1045
 
1026
1046
  // Candidates are ranked by their boosted counted total payment, the p2p bid is governed
1027
1047
  // by the top-level factors and each builder API bid by its own entry. Ties prefer the
@@ -1031,10 +1051,9 @@ export function getValidatorApi(
1031
1051
  // Past the race cutoff a pooled p2p bid is used right away rather than waiting for pending
1032
1052
  // builder API requests, the local block is selected at the cutoff anyway if it is ready
1033
1053
  let [builderApiBids] = await Promise.all([
1034
- Promise.race([builderApiBidsPromise, sleep(cutoffMs).then(() => null)]),
1054
+ Promise.race([builderApiBidsPromise, sleep(msToCutoff()).then(() => null)]),
1035
1055
  bidDeadlinePromise,
1036
1056
  ]);
1037
- let parentExecutionRequestsPromise: Promise<gloas.ExecutionRequests> | null = null;
1038
1057
 
1039
1058
  let p2pBid: PooledExecutionPayloadBid | null = circuitBreakerActive
1040
1059
  ? null
@@ -1063,10 +1082,7 @@ export function getValidatorApi(
1063
1082
  parentBlockHash: bidParentBlockHash,
1064
1083
  parentBlockRoot: parentBlockRootHex,
1065
1084
  entry,
1066
- getParentExecutionRequests: () => {
1067
- parentExecutionRequestsPromise ??= chain.getParentExecutionRequests(parentSlot, parentBlockRootHex);
1068
- return parentExecutionRequestsPromise;
1069
- },
1085
+ getParentExecutionRequests,
1070
1086
  });
1071
1087
  return {
1072
1088
  signedBid,
@@ -1115,23 +1131,6 @@ export function getValidatorApi(
1115
1131
  return rankedCandidates[0];
1116
1132
  })();
1117
1133
 
1118
- const commonBlockBodyPromise = chain.produceCommonBlockBody({
1119
- slot,
1120
- parentBlock,
1121
- randaoReveal,
1122
- graffiti: graffitiBytes,
1123
- });
1124
-
1125
- const baseAttrs = {
1126
- slot,
1127
- parentBlock,
1128
- randaoReveal,
1129
- graffiti: graffitiBytes,
1130
- feeRecipient,
1131
- strictFeeRecipientCheck,
1132
- commonBlockBodyPromise,
1133
- };
1134
-
1135
1134
  metrics?.blockProductionRequests.inc({source: ProducedBlockSource.engine});
1136
1135
 
1137
1136
  const timed = <T>(source: ProducedBlockSource, fn: () => Promise<T>): Promise<T> => {
@@ -1139,11 +1138,59 @@ export function getValidatorApi(
1139
1138
  return fn().finally(() => t?.({source}));
1140
1139
  };
1141
1140
 
1141
+ // Fetch the production state once and apply the parent execution payload once here, so all
1142
+ // downstream consumers share a single state: the un-applied `parentState` (for `computeNewStateRoot`)
1143
+ // and the applied `parentStateWithPayload` (for attestation scoring and execution-payload prep).
1144
+ // Not awaited, the race below covers it and both blocks are produced from it
1145
+ const baseAttrsPromise = (async () => {
1146
+ const parentState = await chain.regen.getBlockSlotState(
1147
+ parentBlock,
1148
+ slot,
1149
+ {dontTransferCache: true},
1150
+ RegenCaller.produceBlock
1151
+ );
1152
+ // Fetch the parent's execution requests once here and thread them via blockAttributes: they are
1153
+ // used both to apply the parent payload below and as the block's `parentExecutionRequests` field
1154
+ // (so both are guaranteed consistent). Only needed when building on FULL; empty parent has none.
1155
+ const parentExecutionRequests =
1156
+ isBuildingOnFull && isStatePostGloas(parentState)
1157
+ ? await getParentExecutionRequests()
1158
+ : ssz.gloas.ExecutionRequests.defaultValue();
1159
+ // When building on EMPTY there is nothing to apply, so it stays the same view as parentState
1160
+ // (the availability bit for parentSlot stays false, which is correct).
1161
+ const parentStateWithPayload =
1162
+ isBuildingOnFull && isStatePostGloas(parentState)
1163
+ ? parentState.withParentPayloadApplied(parentExecutionRequests)
1164
+ : parentState;
1165
+
1166
+ const commonBlockBodyPromise = chain.produceCommonBlockBody({
1167
+ slot,
1168
+ parentBlock,
1169
+ randaoReveal,
1170
+ graffiti: graffitiBytes,
1171
+ parentState,
1172
+ parentStateWithPayload,
1173
+ });
1174
+
1175
+ return {
1176
+ slot,
1177
+ parentBlock,
1178
+ randaoReveal,
1179
+ graffiti: graffitiBytes,
1180
+ feeRecipient,
1181
+ strictFeeRecipientCheck,
1182
+ commonBlockBodyPromise,
1183
+ parentState,
1184
+ parentStateWithPayload,
1185
+ parentExecutionRequests,
1186
+ };
1187
+ })();
1188
+
1142
1189
  // use abort controller to stop waiting for the bid block if the engine block will be selected
1143
1190
  const controller = new AbortController();
1144
1191
 
1145
- const enginePromise: ReturnType<typeof chain.produceBlock> = timed(ProducedBlockSource.engine, () =>
1146
- chain.produceBlock(baseAttrs)
1192
+ const enginePromise: ReturnType<typeof chain.produceBlock> = timed(ProducedBlockSource.engine, async () =>
1193
+ chain.produceBlock(await baseAttrsPromise)
1147
1194
  ).then((engineBlock) => {
1148
1195
  // No need to wait for the bid block if the engine block will always be selected, either
1149
1196
  // due to suspected builder censorship, or because no builders are configured and the
@@ -1155,16 +1202,16 @@ export function getValidatorApi(
1155
1202
  });
1156
1203
  const bidBlockPromise: ReturnType<typeof chain.produceBlock> = bestBidPromise.then((candidate) => {
1157
1204
  if (candidate === null) {
1158
- throw new Error(NO_BID_AVAILABLE);
1205
+ throw new NoBidReceived();
1159
1206
  }
1160
1207
  metrics?.blockProductionRequests.inc({source: ProducedBlockSource.builder});
1161
- return timed(ProducedBlockSource.builder, () =>
1162
- chain.produceBlock({...baseAttrs, builderBid: candidate.signedBid})
1208
+ return timed(ProducedBlockSource.builder, async () =>
1209
+ chain.produceBlock({...(await baseAttrsPromise), builderBid: candidate.signedBid})
1163
1210
  );
1164
1211
  });
1165
1212
 
1166
1213
  const [engineResult, bidBlockResult] = await resolveOrRacePromises([enginePromise, bidBlockPromise], {
1167
- resolveTimeoutMs: cutoffMs,
1214
+ resolveTimeoutMs: msToCutoff(),
1168
1215
  raceTimeoutMs: config.getSlotDurationMs(fork),
1169
1216
  signal: controller.signal,
1170
1217
  });
@@ -1269,7 +1316,7 @@ export function getValidatorApi(
1269
1316
  source = ProducedBlockSource.engine;
1270
1317
  bestResult = engineResult;
1271
1318
  const reason =
1272
- bidBlockResult.status === "rejected" && (bidBlockResult.reason as Error).message === NO_BID_AVAILABLE
1319
+ bidBlockResult.status === "rejected" && bidBlockResult.reason instanceof NoBidReceived
1273
1320
  ? EngineBlockSelectionReason.BuilderNoBid
1274
1321
  : bidBlockResult.status === "pending"
1275
1322
  ? EngineBlockSelectionReason.BuilderPending
@@ -1396,10 +1443,18 @@ export function getValidatorApi(
1396
1443
  // After Gloas, attestation.data.index signals payload status in fork-choice:
1397
1444
  // - 0 = EMPTY / not present, 1 = FULL / present
1398
1445
  // - same-slot attestations must always use index = 0
1446
+ // Validator shouldn't vote on an optimistic head, post-gloas that is the variant voted for
1399
1447
  if (canonicalBlock.slot !== slot) {
1400
1448
  index = canonicalBlock.payloadStatus === PayloadStatus.FULL ? 1 : 0;
1449
+ if (isOptimisticBlock(canonicalBlock)) {
1450
+ throw new NodeIsSyncing(
1451
+ `Head block's execution payload not yet validated, executionPayloadBlockHash=${canonicalBlock.executionPayloadBlockHash}`
1452
+ );
1453
+ }
1401
1454
  } else {
1402
1455
  index = 0;
1456
+ // Same-slot votes support the PENDING variant, which does not depend on the block's own payload
1457
+ notOnOptimisticBlockRoot(beaconBlockRoot);
1403
1458
  }
1404
1459
  } else if (isForkPostElectra(fork)) {
1405
1460
  index = 0;
@@ -1417,8 +1472,11 @@ export function getValidatorApi(
1417
1472
  headBlockRoot
1418
1473
  : headState.getBlockRootAtSlot(targetSlot);
1419
1474
 
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
1475
+ // Check the execution status as validator shouldn't vote on an optimistic head, post-gloas the
1476
+ // variant voted for is checked above. Check on target is sufficient for a valid source
1477
+ if (!isForkPostGloas(fork)) {
1478
+ notOnOptimisticBlockRoot(beaconBlockRoot);
1479
+ }
1422
1480
  notOnOptimisticBlockRoot(targetRoot);
1423
1481
  notOnOutOfRangeData(targetRoot);
1424
1482
 
@@ -1684,7 +1742,8 @@ export function getValidatorApi(
1684
1742
 
1685
1743
  // should not compare to headEpoch in order to handle skipped slots
1686
1744
  // Check if the epoch is in the future after waiting for requested slot
1687
- if (epoch > chain.clock.currentEpoch + 1) {
1745
+ // Before genesis the clock epoch is negative, treat it as GENESIS_EPOCH so the next epoch can be requested
1746
+ if (epoch > Math.max(chain.clock.currentEpoch, GENESIS_EPOCH) + 1) {
1688
1747
  throw new ApiError(400, "Cannot get duties for epoch more than one ahead");
1689
1748
  }
1690
1749
 
@@ -1747,7 +1806,7 @@ export function getValidatorApi(
1747
1806
 
1748
1807
  await waitForNextClosestEpoch();
1749
1808
 
1750
- if (epoch > chain.clock.currentEpoch + 1) {
1809
+ if (epoch > Math.max(chain.clock.currentEpoch, GENESIS_EPOCH) + 1) {
1751
1810
  throw new ApiError(400, "Cannot get PTC duties for epoch more than one ahead");
1752
1811
  }
1753
1812
 
@@ -2324,8 +2383,7 @@ export function getValidatorApi(
2324
2383
  metrics?.inclusionListsValid.inc({source: InclusionListSource.api});
2325
2384
  metrics?.inclusionListsValidSize.inc(totalBytes);
2326
2385
 
2327
- const isTimely =
2328
- secFromSlot >= 0 && secFromSlot * 1000 < chain.config.getInclusionListDueMs(chain.config.getForkName(slot));
2386
+ const isTimely = secFromSlot * 1000 < chain.config.getInclusionListDueMs(chain.config.getForkName(slot));
2329
2387
  chain.inclusionListStore.process(signedInclusionList, committeeIndices, isTimely);
2330
2388
 
2331
2389
  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
 
@@ -7,6 +7,7 @@ import {
7
7
  InvalidBlockCode,
8
8
  LVHInvalidJudged,
9
9
  PayloadExecutionStatus,
10
+ PayloadStatus,
10
11
  getFinalizedExecutionBlockHash,
11
12
  getSafeExecutionBlockHash,
12
13
  } from "@lodestar/fork-choice";
@@ -117,7 +118,7 @@ function toForkChoiceExecutionStatus(status: ExecutionPayloadStatus): PayloadExe
117
118
  * 3. Regenerate state for envelope verification
118
119
  * 4. Verify envelope (fields against state, signature, and EL in parallel where possible)
119
120
  * 5. Persist verified payload envelope to hot DB (waits for write-queue space for backpressure)
120
- * 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
121
122
  * 7. Queue notifyForkchoiceUpdate to engine api
122
123
  * 8. Record metrics for payload envelope and column sources
123
124
  * 9. Emit `execution_payload` event
@@ -356,6 +357,7 @@ export async function importExecutionPayload(
356
357
 
357
358
  // 6. Update fork choice, transitions the block's PENDING variant to FULL
358
359
  const execStatus = toForkChoiceExecutionStatus(execResult.status);
360
+ const prevHead = this.forkChoice.getHead();
359
361
  try {
360
362
  this.forkChoice.onExecutionPayload(
361
363
  blockRootHex,
@@ -376,12 +378,17 @@ export async function importExecutionPayload(
376
378
  }
377
379
  throw e;
378
380
  }
381
+ const head = this.forkChoice.getHead();
382
+ this.emitHeadEvents(prevHead, head);
383
+ if (head.blockRoot !== prevHead.blockRoot) {
384
+ this.onHeadChanged(prevHead, head);
385
+ }
379
386
 
380
387
  // 7. Queue notifyForkchoiceUpdate to engine api
381
- const head = this.forkChoice.getHead();
382
388
  if (
383
389
  !this.opts.disableImportExecutionFcU &&
384
390
  blockRootHex === head.blockRoot &&
391
+ head.payloadStatus === PayloadStatus.FULL &&
385
392
  // Skip a payload that does not satisfy the inclusion list constraints, fork choice keeps the EMPTY
386
393
  // variant as head and the next prepare fcU keeps the engine on the parent payload
387
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;