@lodestar/beacon-node 1.43.0-dev.aef3645690 → 1.43.0-dev.b05ea98d04

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 (401) hide show
  1. package/lib/api/impl/beacon/blocks/index.d.ts.map +1 -1
  2. package/lib/api/impl/beacon/blocks/index.js +17 -9
  3. package/lib/api/impl/beacon/blocks/index.js.map +1 -1
  4. package/lib/api/impl/beacon/pool/index.d.ts.map +1 -1
  5. package/lib/api/impl/beacon/pool/index.js +45 -2
  6. package/lib/api/impl/beacon/pool/index.js.map +1 -1
  7. package/lib/api/impl/beacon/state/utils.d.ts +2 -2
  8. package/lib/api/impl/beacon/state/utils.d.ts.map +1 -1
  9. package/lib/api/impl/beacon/state/utils.js.map +1 -1
  10. package/lib/api/impl/debug/index.d.ts.map +1 -1
  11. package/lib/api/impl/debug/index.js +0 -1
  12. package/lib/api/impl/debug/index.js.map +1 -1
  13. package/lib/api/impl/lodestar/index.js +1 -1
  14. package/lib/api/impl/lodestar/index.js.map +1 -1
  15. package/lib/api/impl/validator/index.d.ts.map +1 -1
  16. package/lib/api/impl/validator/index.js +68 -5
  17. package/lib/api/impl/validator/index.js.map +1 -1
  18. package/lib/chain/GetBlobsTracker.d.ts +1 -1
  19. package/lib/chain/GetBlobsTracker.d.ts.map +1 -1
  20. package/lib/chain/GetBlobsTracker.js +1 -2
  21. package/lib/chain/GetBlobsTracker.js.map +1 -1
  22. package/lib/chain/archiveStore/archiveStore.d.ts.map +1 -1
  23. package/lib/chain/archiveStore/archiveStore.js.map +1 -1
  24. package/lib/chain/archiveStore/interface.d.ts +4 -4
  25. package/lib/chain/archiveStore/interface.d.ts.map +1 -1
  26. package/lib/chain/archiveStore/strategies/frequencyStateArchiveStrategy.d.ts +4 -4
  27. package/lib/chain/archiveStore/strategies/frequencyStateArchiveStrategy.d.ts.map +1 -1
  28. package/lib/chain/archiveStore/strategies/frequencyStateArchiveStrategy.js +2 -4
  29. package/lib/chain/archiveStore/strategies/frequencyStateArchiveStrategy.js.map +1 -1
  30. package/lib/chain/archiveStore/utils/archiveBlocks.d.ts +2 -2
  31. package/lib/chain/archiveStore/utils/archiveBlocks.d.ts.map +1 -1
  32. package/lib/chain/archiveStore/utils/archiveBlocks.js +110 -58
  33. package/lib/chain/archiveStore/utils/archiveBlocks.js.map +1 -1
  34. package/lib/chain/blocks/blockInput/blockInput.d.ts +3 -0
  35. package/lib/chain/blocks/blockInput/blockInput.d.ts.map +1 -1
  36. package/lib/chain/blocks/blockInput/blockInput.js +4 -1
  37. package/lib/chain/blocks/blockInput/blockInput.js.map +1 -1
  38. package/lib/chain/blocks/importBlock.d.ts.map +1 -1
  39. package/lib/chain/blocks/importBlock.js +38 -58
  40. package/lib/chain/blocks/importBlock.js.map +1 -1
  41. package/lib/chain/blocks/importExecutionPayload.d.ts +28 -14
  42. package/lib/chain/blocks/importExecutionPayload.d.ts.map +1 -1
  43. package/lib/chain/blocks/importExecutionPayload.js +89 -89
  44. package/lib/chain/blocks/importExecutionPayload.js.map +1 -1
  45. package/lib/chain/blocks/index.d.ts +5 -3
  46. package/lib/chain/blocks/index.d.ts.map +1 -1
  47. package/lib/chain/blocks/index.js +59 -26
  48. package/lib/chain/blocks/index.js.map +1 -1
  49. package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.d.ts +7 -0
  50. package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.d.ts.map +1 -1
  51. package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.js +29 -2
  52. package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.js.map +1 -1
  53. package/lib/chain/blocks/payloadEnvelopeInput/types.d.ts +1 -0
  54. package/lib/chain/blocks/payloadEnvelopeInput/types.d.ts.map +1 -1
  55. package/lib/chain/blocks/payloadEnvelopeProcessor.d.ts +5 -0
  56. package/lib/chain/blocks/payloadEnvelopeProcessor.d.ts.map +1 -1
  57. package/lib/chain/blocks/payloadEnvelopeProcessor.js +7 -5
  58. package/lib/chain/blocks/payloadEnvelopeProcessor.js.map +1 -1
  59. package/lib/chain/blocks/types.d.ts +16 -21
  60. package/lib/chain/blocks/types.d.ts.map +1 -1
  61. package/lib/chain/blocks/utils/chainSegment.d.ts +23 -2
  62. package/lib/chain/blocks/utils/chainSegment.d.ts.map +1 -1
  63. package/lib/chain/blocks/utils/chainSegment.js +89 -12
  64. package/lib/chain/blocks/utils/chainSegment.js.map +1 -1
  65. package/lib/chain/blocks/verifyBlock.d.ts +5 -3
  66. package/lib/chain/blocks/verifyBlock.d.ts.map +1 -1
  67. package/lib/chain/blocks/verifyBlock.js +50 -7
  68. package/lib/chain/blocks/verifyBlock.js.map +1 -1
  69. package/lib/chain/blocks/verifyBlocksExecutionPayloads.d.ts +0 -4
  70. package/lib/chain/blocks/verifyBlocksExecutionPayloads.d.ts.map +1 -1
  71. package/lib/chain/blocks/verifyBlocksExecutionPayloads.js +5 -2
  72. package/lib/chain/blocks/verifyBlocksExecutionPayloads.js.map +1 -1
  73. package/lib/chain/blocks/verifyBlocksSanityChecks.d.ts +2 -1
  74. package/lib/chain/blocks/verifyBlocksSanityChecks.d.ts.map +1 -1
  75. package/lib/chain/blocks/verifyBlocksSanityChecks.js +25 -5
  76. package/lib/chain/blocks/verifyBlocksSanityChecks.js.map +1 -1
  77. package/lib/chain/blocks/verifyExecutionPayloadEnvelope.d.ts +24 -0
  78. package/lib/chain/blocks/verifyExecutionPayloadEnvelope.d.ts.map +1 -0
  79. package/lib/chain/blocks/verifyExecutionPayloadEnvelope.js +79 -0
  80. package/lib/chain/blocks/verifyExecutionPayloadEnvelope.js.map +1 -0
  81. package/lib/chain/blocks/verifyPayloadsDataAvailability.d.ts +14 -0
  82. package/lib/chain/blocks/verifyPayloadsDataAvailability.d.ts.map +1 -0
  83. package/lib/chain/blocks/verifyPayloadsDataAvailability.js +30 -0
  84. package/lib/chain/blocks/verifyPayloadsDataAvailability.js.map +1 -0
  85. package/lib/chain/blocks/writePayloadEnvelopeInputToDb.d.ts +1 -1
  86. package/lib/chain/blocks/writePayloadEnvelopeInputToDb.d.ts.map +1 -1
  87. package/lib/chain/blocks/writePayloadEnvelopeInputToDb.js +2 -11
  88. package/lib/chain/blocks/writePayloadEnvelopeInputToDb.js.map +1 -1
  89. package/lib/chain/chain.d.ts +8 -6
  90. package/lib/chain/chain.d.ts.map +1 -1
  91. package/lib/chain/chain.js +46 -50
  92. package/lib/chain/chain.js.map +1 -1
  93. package/lib/chain/emitter.d.ts +16 -15
  94. package/lib/chain/emitter.d.ts.map +1 -1
  95. package/lib/chain/emitter.js +5 -4
  96. package/lib/chain/emitter.js.map +1 -1
  97. package/lib/chain/errors/attestationError.d.ts +8 -1
  98. package/lib/chain/errors/attestationError.d.ts.map +1 -1
  99. package/lib/chain/errors/attestationError.js +4 -0
  100. package/lib/chain/errors/attestationError.js.map +1 -1
  101. package/lib/chain/errors/blockError.d.ts +8 -1
  102. package/lib/chain/errors/blockError.d.ts.map +1 -1
  103. package/lib/chain/errors/blockError.js +2 -0
  104. package/lib/chain/errors/blockError.js.map +1 -1
  105. package/lib/chain/errors/executionPayloadBid.d.ts +5 -0
  106. package/lib/chain/errors/executionPayloadBid.d.ts.map +1 -1
  107. package/lib/chain/errors/executionPayloadBid.js +1 -0
  108. package/lib/chain/errors/executionPayloadBid.js.map +1 -1
  109. package/lib/chain/errors/executionPayloadEnvelope.d.ts +5 -0
  110. package/lib/chain/errors/executionPayloadEnvelope.d.ts.map +1 -1
  111. package/lib/chain/errors/executionPayloadEnvelope.js +1 -0
  112. package/lib/chain/errors/executionPayloadEnvelope.js.map +1 -1
  113. package/lib/chain/errors/index.d.ts +1 -0
  114. package/lib/chain/errors/index.d.ts.map +1 -1
  115. package/lib/chain/errors/index.js +1 -0
  116. package/lib/chain/errors/index.js.map +1 -1
  117. package/lib/chain/errors/proposerPreferences.d.ts +40 -0
  118. package/lib/chain/errors/proposerPreferences.d.ts.map +1 -0
  119. package/lib/chain/errors/proposerPreferences.js +14 -0
  120. package/lib/chain/errors/proposerPreferences.js.map +1 -0
  121. package/lib/chain/forkChoice/index.d.ts.map +1 -1
  122. package/lib/chain/forkChoice/index.js +11 -15
  123. package/lib/chain/forkChoice/index.js.map +1 -1
  124. package/lib/chain/initState.d.ts.map +1 -1
  125. package/lib/chain/initState.js +6 -1
  126. package/lib/chain/initState.js.map +1 -1
  127. package/lib/chain/interface.d.ts +7 -5
  128. package/lib/chain/interface.d.ts.map +1 -1
  129. package/lib/chain/interface.js.map +1 -1
  130. package/lib/chain/opPools/payloadAttestationPool.d.ts +3 -2
  131. package/lib/chain/opPools/payloadAttestationPool.d.ts.map +1 -1
  132. package/lib/chain/opPools/payloadAttestationPool.js +26 -4
  133. package/lib/chain/opPools/payloadAttestationPool.js.map +1 -1
  134. package/lib/chain/prepareNextSlot.d.ts.map +1 -1
  135. package/lib/chain/prepareNextSlot.js +47 -23
  136. package/lib/chain/prepareNextSlot.js.map +1 -1
  137. package/lib/chain/produceBlock/computeNewStateRoot.d.ts +3 -9
  138. package/lib/chain/produceBlock/computeNewStateRoot.d.ts.map +1 -1
  139. package/lib/chain/produceBlock/computeNewStateRoot.js +5 -32
  140. package/lib/chain/produceBlock/computeNewStateRoot.js.map +1 -1
  141. package/lib/chain/produceBlock/produceBlockBody.d.ts +13 -8
  142. package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
  143. package/lib/chain/produceBlock/produceBlockBody.js +68 -25
  144. package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
  145. package/lib/chain/regen/errors.d.ts +1 -11
  146. package/lib/chain/regen/errors.d.ts.map +1 -1
  147. package/lib/chain/regen/errors.js +0 -2
  148. package/lib/chain/regen/errors.js.map +1 -1
  149. package/lib/chain/regen/interface.d.ts +7 -12
  150. package/lib/chain/regen/interface.d.ts.map +1 -1
  151. package/lib/chain/regen/interface.js +1 -0
  152. package/lib/chain/regen/interface.js.map +1 -1
  153. package/lib/chain/regen/queued.d.ts +6 -11
  154. package/lib/chain/regen/queued.d.ts.map +1 -1
  155. package/lib/chain/regen/queued.js +9 -44
  156. package/lib/chain/regen/queued.js.map +1 -1
  157. package/lib/chain/regen/regen.d.ts +0 -5
  158. package/lib/chain/regen/regen.d.ts.map +1 -1
  159. package/lib/chain/regen/regen.js +8 -38
  160. package/lib/chain/regen/regen.js.map +1 -1
  161. package/lib/chain/seenCache/index.d.ts +1 -0
  162. package/lib/chain/seenCache/index.d.ts.map +1 -1
  163. package/lib/chain/seenCache/index.js +1 -0
  164. package/lib/chain/seenCache/index.js.map +1 -1
  165. package/lib/chain/seenCache/seenPayloadEnvelopeInput.d.ts +22 -6
  166. package/lib/chain/seenCache/seenPayloadEnvelopeInput.d.ts.map +1 -1
  167. package/lib/chain/seenCache/seenPayloadEnvelopeInput.js +53 -17
  168. package/lib/chain/seenCache/seenPayloadEnvelopeInput.js.map +1 -1
  169. package/lib/chain/seenCache/seenProposerPreferences.d.ts +16 -0
  170. package/lib/chain/seenCache/seenProposerPreferences.d.ts.map +1 -0
  171. package/lib/chain/seenCache/seenProposerPreferences.js +26 -0
  172. package/lib/chain/seenCache/seenProposerPreferences.js.map +1 -0
  173. package/lib/chain/stateCache/datastore/db.d.ts +5 -4
  174. package/lib/chain/stateCache/datastore/db.d.ts.map +1 -1
  175. package/lib/chain/stateCache/datastore/db.js +10 -32
  176. package/lib/chain/stateCache/datastore/db.js.map +1 -1
  177. package/lib/chain/stateCache/datastore/file.d.ts +1 -1
  178. package/lib/chain/stateCache/datastore/file.d.ts.map +1 -1
  179. package/lib/chain/stateCache/datastore/file.js +5 -5
  180. package/lib/chain/stateCache/datastore/file.js.map +1 -1
  181. package/lib/chain/stateCache/datastore/types.d.ts +1 -1
  182. package/lib/chain/stateCache/datastore/types.d.ts.map +1 -1
  183. package/lib/chain/stateCache/fifoBlockStateCache.d.ts +1 -7
  184. package/lib/chain/stateCache/fifoBlockStateCache.d.ts.map +1 -1
  185. package/lib/chain/stateCache/fifoBlockStateCache.js +0 -8
  186. package/lib/chain/stateCache/fifoBlockStateCache.js.map +1 -1
  187. package/lib/chain/stateCache/persistentCheckpointsCache.d.ts +13 -30
  188. package/lib/chain/stateCache/persistentCheckpointsCache.d.ts.map +1 -1
  189. package/lib/chain/stateCache/persistentCheckpointsCache.js +120 -216
  190. package/lib/chain/stateCache/persistentCheckpointsCache.js.map +1 -1
  191. package/lib/chain/stateCache/types.d.ts +8 -15
  192. package/lib/chain/stateCache/types.d.ts.map +1 -1
  193. package/lib/chain/stateCache/types.js.map +1 -1
  194. package/lib/chain/validation/aggregateAndProof.js +12 -0
  195. package/lib/chain/validation/aggregateAndProof.js.map +1 -1
  196. package/lib/chain/validation/attestation.d.ts.map +1 -1
  197. package/lib/chain/validation/attestation.js +12 -0
  198. package/lib/chain/validation/attestation.js.map +1 -1
  199. package/lib/chain/validation/block.d.ts.map +1 -1
  200. package/lib/chain/validation/block.js +1 -0
  201. package/lib/chain/validation/block.js.map +1 -1
  202. package/lib/chain/validation/executionPayloadBid.d.ts.map +1 -1
  203. package/lib/chain/validation/executionPayloadBid.js +24 -9
  204. package/lib/chain/validation/executionPayloadBid.js.map +1 -1
  205. package/lib/chain/validation/executionPayloadEnvelope.d.ts.map +1 -1
  206. package/lib/chain/validation/executionPayloadEnvelope.js +21 -11
  207. package/lib/chain/validation/executionPayloadEnvelope.js.map +1 -1
  208. package/lib/chain/validation/payloadAttestationMessage.d.ts.map +1 -1
  209. package/lib/chain/validation/payloadAttestationMessage.js +4 -3
  210. package/lib/chain/validation/payloadAttestationMessage.js.map +1 -1
  211. package/lib/chain/validation/proposerPreferences.d.ts +8 -0
  212. package/lib/chain/validation/proposerPreferences.d.ts.map +1 -0
  213. package/lib/chain/validation/proposerPreferences.js +91 -0
  214. package/lib/chain/validation/proposerPreferences.js.map +1 -0
  215. package/lib/db/repositories/executionPayloadEnvelopeArchive.js +1 -1
  216. package/lib/db/repositories/executionPayloadEnvelopeArchive.js.map +1 -1
  217. package/lib/execution/engine/http.d.ts.map +1 -1
  218. package/lib/execution/engine/http.js +21 -14
  219. package/lib/execution/engine/http.js.map +1 -1
  220. package/lib/execution/engine/interface.d.ts +1 -0
  221. package/lib/execution/engine/interface.d.ts.map +1 -1
  222. package/lib/execution/engine/mock.d.ts.map +1 -1
  223. package/lib/execution/engine/mock.js +6 -0
  224. package/lib/execution/engine/mock.js.map +1 -1
  225. package/lib/execution/engine/types.d.ts +20 -0
  226. package/lib/execution/engine/types.d.ts.map +1 -1
  227. package/lib/execution/engine/types.js +18 -0
  228. package/lib/execution/engine/types.js.map +1 -1
  229. package/lib/metrics/metrics/lodestar.d.ts +1 -0
  230. package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
  231. package/lib/metrics/metrics/lodestar.js +4 -0
  232. package/lib/metrics/metrics/lodestar.js.map +1 -1
  233. package/lib/network/gossip/interface.d.ts +7 -1
  234. package/lib/network/gossip/interface.d.ts.map +1 -1
  235. package/lib/network/gossip/interface.js +1 -0
  236. package/lib/network/gossip/interface.js.map +1 -1
  237. package/lib/network/gossip/scoringParameters.d.ts.map +1 -1
  238. package/lib/network/gossip/scoringParameters.js +12 -1
  239. package/lib/network/gossip/scoringParameters.js.map +1 -1
  240. package/lib/network/gossip/topic.d.ts +32 -748
  241. package/lib/network/gossip/topic.d.ts.map +1 -1
  242. package/lib/network/gossip/topic.js +6 -0
  243. package/lib/network/gossip/topic.js.map +1 -1
  244. package/lib/network/interface.d.ts +1 -0
  245. package/lib/network/interface.d.ts.map +1 -1
  246. package/lib/network/network.d.ts +1 -0
  247. package/lib/network/network.d.ts.map +1 -1
  248. package/lib/network/network.js +6 -1
  249. package/lib/network/network.js.map +1 -1
  250. package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
  251. package/lib/network/processor/gossipHandlers.js +60 -22
  252. package/lib/network/processor/gossipHandlers.js.map +1 -1
  253. package/lib/network/processor/gossipQueues/index.d.ts.map +1 -1
  254. package/lib/network/processor/gossipQueues/index.js +5 -0
  255. package/lib/network/processor/gossipQueues/index.js.map +1 -1
  256. package/lib/network/processor/index.d.ts.map +1 -1
  257. package/lib/network/processor/index.js +6 -5
  258. package/lib/network/processor/index.js.map +1 -1
  259. package/lib/network/reqresp/handlers/beaconBlocksByRange.d.ts.map +1 -1
  260. package/lib/network/reqresp/handlers/beaconBlocksByRange.js +14 -6
  261. package/lib/network/reqresp/handlers/beaconBlocksByRange.js.map +1 -1
  262. package/lib/network/reqresp/handlers/blobSidecarsByRange.d.ts.map +1 -1
  263. package/lib/network/reqresp/handlers/blobSidecarsByRange.js +11 -5
  264. package/lib/network/reqresp/handlers/blobSidecarsByRange.js.map +1 -1
  265. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.d.ts.map +1 -1
  266. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js +17 -5
  267. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js.map +1 -1
  268. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.d.ts.map +1 -1
  269. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.js +7 -4
  270. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.js.map +1 -1
  271. package/lib/node/nodejs.d.ts.map +1 -1
  272. package/lib/node/nodejs.js +6 -4
  273. package/lib/node/nodejs.js.map +1 -1
  274. package/lib/sync/constants.d.ts +3 -1
  275. package/lib/sync/constants.d.ts.map +1 -1
  276. package/lib/sync/constants.js +3 -4
  277. package/lib/sync/constants.js.map +1 -1
  278. package/lib/sync/range/batch.d.ts +28 -2
  279. package/lib/sync/range/batch.d.ts.map +1 -1
  280. package/lib/sync/range/batch.js +146 -44
  281. package/lib/sync/range/batch.js.map +1 -1
  282. package/lib/sync/range/chain.d.ts +12 -2
  283. package/lib/sync/range/chain.d.ts.map +1 -1
  284. package/lib/sync/range/chain.js +53 -9
  285. package/lib/sync/range/chain.js.map +1 -1
  286. package/lib/sync/range/range.d.ts.map +1 -1
  287. package/lib/sync/range/range.js +17 -6
  288. package/lib/sync/range/range.js.map +1 -1
  289. package/lib/sync/types.d.ts +34 -0
  290. package/lib/sync/types.d.ts.map +1 -1
  291. package/lib/sync/types.js +34 -0
  292. package/lib/sync/types.js.map +1 -1
  293. package/lib/sync/unknownBlock.d.ts +22 -1
  294. package/lib/sync/unknownBlock.d.ts.map +1 -1
  295. package/lib/sync/unknownBlock.js +604 -53
  296. package/lib/sync/unknownBlock.js.map +1 -1
  297. package/lib/sync/utils/downloadByRange.d.ts +46 -10
  298. package/lib/sync/utils/downloadByRange.d.ts.map +1 -1
  299. package/lib/sync/utils/downloadByRange.js +162 -24
  300. package/lib/sync/utils/downloadByRange.js.map +1 -1
  301. package/lib/sync/utils/downloadByRoot.d.ts.map +1 -1
  302. package/lib/sync/utils/downloadByRoot.js +16 -2
  303. package/lib/sync/utils/downloadByRoot.js.map +1 -1
  304. package/lib/sync/utils/pendingBlocksTree.d.ts +0 -1
  305. package/lib/sync/utils/pendingBlocksTree.d.ts.map +1 -1
  306. package/lib/sync/utils/pendingBlocksTree.js +0 -9
  307. package/lib/sync/utils/pendingBlocksTree.js.map +1 -1
  308. package/lib/util/sszBytes.d.ts.map +1 -1
  309. package/lib/util/sszBytes.js +20 -5
  310. package/lib/util/sszBytes.js.map +1 -1
  311. package/package.json +17 -16
  312. package/src/api/impl/beacon/blocks/index.ts +22 -9
  313. package/src/api/impl/beacon/pool/index.ts +83 -1
  314. package/src/api/impl/beacon/state/utils.ts +2 -2
  315. package/src/api/impl/debug/index.ts +0 -1
  316. package/src/api/impl/lodestar/index.ts +1 -1
  317. package/src/api/impl/validator/index.ts +84 -6
  318. package/src/chain/GetBlobsTracker.ts +1 -2
  319. package/src/chain/archiveStore/archiveStore.ts +5 -5
  320. package/src/chain/archiveStore/interface.ts +4 -4
  321. package/src/chain/archiveStore/strategies/frequencyStateArchiveStrategy.ts +6 -8
  322. package/src/chain/archiveStore/utils/archiveBlocks.ts +153 -94
  323. package/src/chain/blocks/blockInput/blockInput.ts +4 -1
  324. package/src/chain/blocks/importBlock.ts +38 -83
  325. package/src/chain/blocks/importExecutionPayload.ts +110 -102
  326. package/src/chain/blocks/index.ts +74 -24
  327. package/src/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.ts +37 -2
  328. package/src/chain/blocks/payloadEnvelopeInput/types.ts +1 -0
  329. package/src/chain/blocks/payloadEnvelopeProcessor.ts +7 -6
  330. package/src/chain/blocks/types.ts +16 -26
  331. package/src/chain/blocks/utils/chainSegment.ts +114 -17
  332. package/src/chain/blocks/verifyBlock.ts +70 -9
  333. package/src/chain/blocks/verifyBlocksExecutionPayloads.ts +6 -4
  334. package/src/chain/blocks/verifyBlocksSanityChecks.ts +26 -7
  335. package/src/chain/blocks/verifyExecutionPayloadEnvelope.ts +134 -0
  336. package/src/chain/blocks/verifyPayloadsDataAvailability.ts +41 -0
  337. package/src/chain/blocks/writePayloadEnvelopeInputToDb.ts +9 -18
  338. package/src/chain/chain.ts +63 -72
  339. package/src/chain/emitter.ts +15 -14
  340. package/src/chain/errors/attestationError.ts +6 -1
  341. package/src/chain/errors/blockError.ts +4 -1
  342. package/src/chain/errors/executionPayloadBid.ts +6 -0
  343. package/src/chain/errors/executionPayloadEnvelope.ts +6 -0
  344. package/src/chain/errors/index.ts +1 -0
  345. package/src/chain/errors/proposerPreferences.ts +47 -0
  346. package/src/chain/forkChoice/index.ts +8 -20
  347. package/src/chain/initState.ts +9 -1
  348. package/src/chain/interface.ts +11 -3
  349. package/src/chain/opPools/payloadAttestationPool.ts +29 -8
  350. package/src/chain/prepareNextSlot.ts +55 -24
  351. package/src/chain/produceBlock/computeNewStateRoot.ts +6 -43
  352. package/src/chain/produceBlock/produceBlockBody.ts +91 -27
  353. package/src/chain/regen/errors.ts +1 -6
  354. package/src/chain/regen/interface.ts +7 -12
  355. package/src/chain/regen/queued.ts +14 -55
  356. package/src/chain/regen/regen.ts +10 -43
  357. package/src/chain/seenCache/index.ts +1 -0
  358. package/src/chain/seenCache/seenPayloadEnvelopeInput.ts +71 -20
  359. package/src/chain/seenCache/seenProposerPreferences.ts +32 -0
  360. package/src/chain/stateCache/datastore/db.ts +10 -33
  361. package/src/chain/stateCache/datastore/file.ts +5 -6
  362. package/src/chain/stateCache/datastore/types.ts +2 -3
  363. package/src/chain/stateCache/fifoBlockStateCache.ts +1 -10
  364. package/src/chain/stateCache/persistentCheckpointsCache.ts +139 -247
  365. package/src/chain/stateCache/types.ts +8 -14
  366. package/src/chain/validation/aggregateAndProof.ts +13 -0
  367. package/src/chain/validation/attestation.ts +13 -0
  368. package/src/chain/validation/block.ts +1 -0
  369. package/src/chain/validation/executionPayloadBid.ts +25 -8
  370. package/src/chain/validation/executionPayloadEnvelope.ts +22 -12
  371. package/src/chain/validation/payloadAttestationMessage.ts +5 -3
  372. package/src/chain/validation/proposerPreferences.ts +110 -0
  373. package/src/db/repositories/executionPayloadEnvelopeArchive.ts +1 -1
  374. package/src/execution/engine/http.ts +21 -14
  375. package/src/execution/engine/interface.ts +1 -0
  376. package/src/execution/engine/mock.ts +8 -1
  377. package/src/execution/engine/types.ts +41 -0
  378. package/src/metrics/metrics/lodestar.ts +4 -0
  379. package/src/network/gossip/interface.ts +6 -0
  380. package/src/network/gossip/scoringParameters.ts +14 -1
  381. package/src/network/gossip/topic.ts +6 -0
  382. package/src/network/interface.ts +1 -0
  383. package/src/network/network.ts +12 -1
  384. package/src/network/processor/gossipHandlers.ts +79 -27
  385. package/src/network/processor/gossipQueues/index.ts +5 -0
  386. package/src/network/processor/index.ts +6 -5
  387. package/src/network/reqresp/handlers/beaconBlocksByRange.ts +14 -6
  388. package/src/network/reqresp/handlers/blobSidecarsByRange.ts +11 -5
  389. package/src/network/reqresp/handlers/dataColumnSidecarsByRange.ts +17 -5
  390. package/src/network/reqresp/handlers/executionPayloadEnvelopesByRange.ts +7 -4
  391. package/src/node/nodejs.ts +6 -4
  392. package/src/sync/constants.ts +4 -4
  393. package/src/sync/range/batch.ts +204 -49
  394. package/src/sync/range/chain.ts +69 -11
  395. package/src/sync/range/range.ts +18 -6
  396. package/src/sync/types.ts +72 -0
  397. package/src/sync/unknownBlock.ts +762 -57
  398. package/src/sync/utils/downloadByRange.ts +272 -39
  399. package/src/sync/utils/downloadByRoot.ts +24 -2
  400. package/src/sync/utils/pendingBlocksTree.ts +0 -15
  401. package/src/util/sszBytes.ts +25 -5
@@ -1,6 +1,6 @@
1
1
  import {Type} from "@chainsafe/ssz";
2
2
  import {BeaconConfig} from "@lodestar/config";
3
- import {CheckpointWithHex, CheckpointWithPayloadStatus, IForkChoice, ProtoBlock} from "@lodestar/fork-choice";
3
+ import {CheckpointWithHex, IForkChoice, ProtoBlock} from "@lodestar/fork-choice";
4
4
  import {EpochShuffling, IBeaconStateView, PubkeyCache} from "@lodestar/state-transition";
5
5
  import {
6
6
  BeaconBlock,
@@ -18,6 +18,7 @@ import {
18
18
  altair,
19
19
  capella,
20
20
  deneb,
21
+ electra,
21
22
  gloas,
22
23
  phase0,
23
24
  rewards,
@@ -60,6 +61,7 @@ import {
60
61
  SeenContributionAndProof,
61
62
  SeenExecutionPayloadBids,
62
63
  SeenPayloadAttesters,
64
+ SeenProposerPreferences,
63
65
  SeenSyncCommitteeMessages,
64
66
  } from "./seenCache/index.js";
65
67
  import {SeenAggregatedAttestations} from "./seenCache/seenAggregateAndProof.js";
@@ -130,6 +132,7 @@ export interface IBeaconChain {
130
132
  readonly seenPayloadAttesters: SeenPayloadAttesters;
131
133
  readonly seenAggregatedAttestations: SeenAggregatedAttestations;
132
134
  readonly seenExecutionPayloadBids: SeenExecutionPayloadBids;
135
+ readonly seenProposerPreferences: SeenProposerPreferences;
133
136
  readonly seenBlockProposers: SeenBlockProposers;
134
137
  readonly seenSyncCommitteeMessages: SeenSyncCommitteeMessages;
135
138
  readonly seenContributionAndProof: SeenContributionAndProof;
@@ -195,7 +198,7 @@ export interface IBeaconChain {
195
198
  ): {state: IBeaconStateView; executionOptimistic: boolean; finalized: boolean} | null;
196
199
  /** Return state bytes by checkpoint */
197
200
  getStateOrBytesByCheckpoint(
198
- checkpoint: CheckpointWithPayloadStatus
201
+ checkpoint: CheckpointWithHex
199
202
  ): Promise<{state: IBeaconStateView | Uint8Array; executionOptimistic: boolean; finalized: boolean} | null>;
200
203
 
201
204
  /**
@@ -231,6 +234,7 @@ export interface IBeaconChain {
231
234
  blockSlot: Slot,
232
235
  blockRootHex: string
233
236
  ): Promise<gloas.SignedExecutionPayloadEnvelope | null>;
237
+ getParentExecutionRequests(parentBlockSlot: Slot, parentBlockRootHex: RootHex): Promise<electra.ExecutionRequests>;
234
238
 
235
239
  produceCommonBlockBody(blockAttributes: BlockAttributes): Promise<CommonBlockBody>;
236
240
  produceBlock(blockAttributes: BlockAttributes & {commonBlockBodyPromise: Promise<CommonBlockBody>}): Promise<{
@@ -248,7 +252,11 @@ export interface IBeaconChain {
248
252
  /** Process a block until complete */
249
253
  processBlock(block: IBlockInput, opts?: ImportBlockOpts): Promise<void>;
250
254
  /** Process a chain of blocks until complete */
251
- processChainSegment(blocks: IBlockInput[], opts?: ImportBlockOpts): Promise<void>;
255
+ processChainSegment(
256
+ blocks: IBlockInput[],
257
+ payloadEnvelopes: Map<Slot, PayloadEnvelopeInput> | null,
258
+ opts?: ImportBlockOpts
259
+ ): Promise<void>;
252
260
 
253
261
  /** Process execution payload envelope: verify, import to fork choice, and persist to DB */
254
262
  processExecutionPayload(payloadInput: PayloadEnvelopeInput, opts?: ImportPayloadOpts): Promise<void>;
@@ -1,7 +1,7 @@
1
1
  import {Signature, aggregateSignatures} from "@chainsafe/blst";
2
2
  import {BitArray} from "@chainsafe/ssz";
3
3
  import {ChainForkConfig} from "@lodestar/config";
4
- import {MAX_COMMITTEES_PER_SLOT, PTC_SIZE} from "@lodestar/params";
4
+ import {MAX_COMMITTEES_PER_SLOT, MAX_PAYLOAD_ATTESTATIONS, PTC_SIZE} from "@lodestar/params";
5
5
  import {RootHex, Slot, gloas} from "@lodestar/types";
6
6
  import {MapDef, toRootHex} from "@lodestar/utils";
7
7
  import {Metrics} from "../../metrics/metrics.js";
@@ -95,13 +95,9 @@ export class PayloadAttestationPool {
95
95
 
96
96
  /**
97
97
  * Get payload attestations to be included in a block.
98
- * Pick the top `maxAttestation` number of attestations with the most votes
98
+ * Pick the top `MAX_PAYLOAD_ATTESTATIONS` aggregates with the most votes.
99
99
  */
100
- getPayloadAttestationsForBlock(
101
- beaconBlockRoot: BlockRootHex,
102
- slot: Slot,
103
- maxAttestation: number
104
- ): gloas.PayloadAttestation[] {
100
+ getPayloadAttestationsForBlock(beaconBlockRoot: BlockRootHex, slot: Slot): gloas.PayloadAttestation[] {
105
101
  const aggregateByDataRootByBlockRoot = this.aggregateByDataRootByBlockRootBySlot.get(slot);
106
102
 
107
103
  if (!aggregateByDataRootByBlockRoot) {
@@ -119,7 +115,32 @@ export class PayloadAttestationPool {
119
115
  return Array.from(aggregateByDataRoot.values())
120
116
  .slice()
121
117
  .sort((a, b) => b.aggregationBits.getTrueBitIndexes().length - a.aggregationBits.getTrueBitIndexes().length)
122
- .slice(0, maxAttestation)
118
+ .slice(0, MAX_PAYLOAD_ATTESTATIONS)
119
+ .map(fastToPayloadAttestation);
120
+ }
121
+
122
+ getAll(slot?: Slot): gloas.PayloadAttestation[] {
123
+ const aggregates: AggregateFast[] = [];
124
+
125
+ const addAggregates = (aggregateByDataRootByBlockRoot: Map<BlockRootHex, Map<DataRootHex, AggregateFast>>) => {
126
+ for (const aggregateByDataRoot of aggregateByDataRootByBlockRoot.values()) {
127
+ aggregates.push(...aggregateByDataRoot.values());
128
+ }
129
+ };
130
+
131
+ if (slot !== undefined) {
132
+ const aggregateByDataRootByBlockRoot = this.aggregateByDataRootByBlockRootBySlot.get(slot);
133
+ if (aggregateByDataRootByBlockRoot) {
134
+ addAggregates(aggregateByDataRootByBlockRoot);
135
+ }
136
+ } else {
137
+ for (const aggregateByDataRootByBlockRoot of this.aggregateByDataRootByBlockRootBySlot.values()) {
138
+ addAggregates(aggregateByDataRootByBlockRoot);
139
+ }
140
+ }
141
+
142
+ return aggregates
143
+ .sort((a, b) => b.aggregationBits.getTrueBitIndexes().length - a.aggregationBits.getTrueBitIndexes().length)
123
144
  .map(fastToPayloadAttestation);
124
145
  }
125
146
 
@@ -1,15 +1,17 @@
1
1
  import {routes} from "@lodestar/api";
2
2
  import {ChainForkConfig} from "@lodestar/config";
3
- import {PayloadStatus, getSafeExecutionBlockHash} from "@lodestar/fork-choice";
3
+ import {getSafeExecutionBlockHash} from "@lodestar/fork-choice";
4
4
  import {ForkPostBellatrix, ForkSeq, SLOTS_PER_EPOCH, isForkPostBellatrix} from "@lodestar/params";
5
5
  import {
6
6
  IBeaconStateView,
7
+ IBeaconStateViewBellatrix,
7
8
  StateHashTreeRootSource,
8
9
  computeEpochAtSlot,
9
10
  computeTimeAtSlot,
10
11
  isStatePostBellatrix,
12
+ isStatePostGloas,
11
13
  } from "@lodestar/state-transition";
12
- import {Slot} from "@lodestar/types";
14
+ import {Bytes32, Slot} from "@lodestar/types";
13
15
  import {Logger, fromHex, isErrorAborted, sleep} from "@lodestar/utils";
14
16
  import {GENESIS_SLOT, ZERO_HASH_HEX} from "../constants/constants.js";
15
17
  import {BuilderStatus} from "../execution/builder/http.js";
@@ -81,6 +83,8 @@ export class PrepareNextSlotScheduler {
81
83
  // calling updateHead() here before we produce a block to reduce reorg possibility
82
84
  const headBlock = this.chain.recomputeForkChoiceHead(ForkchoiceCaller.prepareNextSlot);
83
85
  const {slot: headSlot, blockRoot: headRoot} = headBlock;
86
+ // may be updated below if we predict a proposer-boost-reorg
87
+ let updatedHead = headBlock;
84
88
 
85
89
  // PS: previously this was comparing slots, but that gave no leway on the skipped
86
90
  // slots on epoch bounday. Making it more fluid.
@@ -123,7 +127,6 @@ export class PrepareNextSlotScheduler {
123
127
  const proposerIndex = prepareState.getBeaconProposer(prepareSlot);
124
128
  const feeRecipient = this.chain.beaconProposerCache.get(proposerIndex);
125
129
  let updatedPrepareState = prepareState;
126
- let updatedHeadRoot = headRoot;
127
130
 
128
131
  if (feeRecipient) {
129
132
  // If we are proposing next slot, we need to predict if we can proposer-boost-reorg or not
@@ -146,7 +149,7 @@ export class PrepareNextSlotScheduler {
146
149
  {dontTransferCache: !isEpochTransition},
147
150
  RegenCaller.predictProposerHead
148
151
  );
149
- updatedHeadRoot = proposerHeadRoot;
152
+ updatedHead = proposerHead;
150
153
  }
151
154
 
152
155
  // Update the builder status, if enabled shoot an api call to check status
@@ -156,28 +159,54 @@ export class PrepareNextSlotScheduler {
156
159
  this.logger.error("Builder disabled as the check status api failed", {prepareSlot}, e as Error);
157
160
  });
158
161
  }
162
+ }
163
+
164
+ if (!isStatePostBellatrix(updatedPrepareState)) {
165
+ throw new Error("Expected Bellatrix state for payload attributes");
166
+ }
167
+
168
+ let parentBlockHash: Bytes32;
169
+ // Apply parent payload once here as it's reused by EL prep and SSE emit below
170
+ let stateAfterParentPayload: IBeaconStateViewBellatrix = updatedPrepareState;
171
+ if (isStatePostGloas(updatedPrepareState)) {
172
+ if (this.chain.forkChoice.shouldExtendPayload(updatedHead.blockRoot)) {
173
+ parentBlockHash = updatedPrepareState.latestExecutionPayloadBid.blockHash;
174
+ // Skip applying parent payload unless we're proposing the next slot or have to emit payload_attributes events
175
+ if (feeRecipient !== undefined || this.chain.opts.emitPayloadAttributes === true) {
176
+ const parentExecutionRequests = await this.chain.getParentExecutionRequests(
177
+ updatedHead.slot,
178
+ updatedHead.blockRoot
179
+ );
180
+ stateAfterParentPayload = updatedPrepareState.withParentPayloadApplied(parentExecutionRequests);
181
+ }
182
+ } else {
183
+ parentBlockHash = updatedPrepareState.latestExecutionPayloadBid.parentBlockHash;
184
+ }
185
+ } else {
186
+ parentBlockHash = updatedPrepareState.latestExecutionPayloadHeader.blockHash;
187
+ }
159
188
 
189
+ if (feeRecipient) {
160
190
  const preparationTime =
161
191
  computeTimeAtSlot(this.config, prepareSlot, this.chain.genesisTime) - Date.now() / 1000;
162
192
  this.metrics?.blockPayload.payloadAdvancePrepTime.observe(preparationTime);
163
- if (!isStatePostBellatrix(updatedPrepareState)) {
164
- throw new Error("Expected Bellatrix state for payload preparation");
165
- }
166
193
 
167
194
  const safeBlockHash = getSafeExecutionBlockHash(this.chain.forkChoice);
168
195
  const finalizedBlockHash =
169
196
  this.chain.forkChoice.getFinalizedBlock().executionPayloadBlockHash ?? ZERO_HASH_HEX;
197
+
170
198
  // awaiting here instead of throwing an async call because there is no other task
171
- // left for scheduler and this gives nice sematics to catch and log errors in the
199
+ // left for scheduler and this gives nice semantics to catch and log errors in the
172
200
  // try/catch wrapper here.
173
201
  await prepareExecutionPayload(
174
202
  this.chain,
175
203
  this.logger,
176
204
  fork as ForkPostBellatrix, // State is of execution type
177
- fromHex(updatedHeadRoot),
205
+ fromHex(updatedHead.blockRoot),
206
+ parentBlockHash,
178
207
  safeBlockHash,
179
208
  finalizedBlockHash,
180
- updatedPrepareState,
209
+ stateAfterParentPayload,
181
210
  feeRecipient
182
211
  );
183
212
  this.logger.verbose("PrepareNextSlotScheduler prepared new payload", {
@@ -187,24 +216,30 @@ export class PrepareNextSlotScheduler {
187
216
  });
188
217
  }
189
218
 
190
- if (!isStatePostBellatrix(updatedPrepareState)) {
191
- throw new Error("Expected Bellatrix state for payload attributes");
219
+ if (ForkSeq[fork] >= ForkSeq.gloas) {
220
+ // Cutoff = slot of the parent of the block we'll actually build on (post-reorg).
221
+ // Steady state: cache holds just 2 entries — head (parent for next-slot production)
222
+ // and head.parent (proposer-boost-reorg fallback). Anything older is evicted.
223
+ const updatedHeadParent = this.chain.forkChoice.getBlockHexDefaultStatus(updatedHead.parentRoot);
224
+ if (updatedHeadParent) {
225
+ this.chain.seenPayloadEnvelopeInputCache.pruneBelowParent(updatedHeadParent);
226
+ }
192
227
  }
193
228
 
194
229
  this.computeStateHashTreeRoot(updatedPrepareState, isEpochTransition);
195
230
 
196
- // If emitPayloadAttributes is true emit a SSE payloadAttributes event
231
+ // If emitPayloadAttributes is true emit a SSE payloadAttributes event for
232
+ // every slot. Without the flag, only emit the event if we are proposing in the next slot.
197
233
  if (
198
- this.chain.opts.emitPayloadAttributes === true &&
234
+ (feeRecipient || this.chain.opts.emitPayloadAttributes === true) &&
199
235
  this.chain.emitter.listenerCount(routes.events.EventType.payloadAttributes)
200
236
  ) {
201
237
  const data = getPayloadAttributesForSSE(fork as ForkPostBellatrix, this.chain, {
202
- prepareState: updatedPrepareState,
238
+ prepareState: stateAfterParentPayload,
203
239
  prepareSlot,
204
- parentBlockRoot: fromHex(headRoot),
205
- // The likely consumers of this API are builders and will anyway ignore the
206
- // feeRecipient, so just pass zero hash for now till a real use case arises
207
- feeRecipient: "0x0000000000000000000000000000000000000000000000000000000000000000",
240
+ parentBlockRoot: fromHex(updatedHead.blockRoot),
241
+ parentBlockHash,
242
+ feeRecipient: feeRecipient ?? "0x0000000000000000000000000000000000000000",
208
243
  });
209
244
  this.chain.emitter.emit(routes.events.EventType.payloadAttributes, {data, version: fork});
210
245
  }
@@ -217,11 +252,7 @@ export class PrepareNextSlotScheduler {
217
252
  // + if next slot is a skipped slot, it'd help getting target checkpoint state faster to validate attestations
218
253
  if (isEpochTransition) {
219
254
  this.metrics?.precomputeNextEpochTransition.count.inc({result: "success"}, 1);
220
- // Determine payloadPresent from head block's payload status
221
- // Pre-Gloas: payloadStatus is always FULL → payloadPresent = true
222
- // Post-Gloas: FULL → true, EMPTY → false, PENDING → false (conservative, treat as block state)
223
- const payloadPresent = headBlock.payloadStatus === PayloadStatus.FULL;
224
- const previousHits = this.chain.regen.updatePreComputedCheckpoint(headRoot, nextEpoch, payloadPresent);
255
+ const previousHits = this.chain.regen.updatePreComputedCheckpoint(headRoot, nextEpoch);
225
256
  if (previousHits === 0) {
226
257
  this.metrics?.precomputeNextEpochTransition.waste.inc();
227
258
  }
@@ -1,12 +1,10 @@
1
1
  import {
2
2
  DataAvailabilityStatus,
3
3
  ExecutionPayloadStatus,
4
- G2_POINT_AT_INFINITY,
5
4
  IBeaconStateView,
6
- IBeaconStateViewGloas,
7
5
  StateHashTreeRootSource,
8
6
  } from "@lodestar/state-transition";
9
- import {BeaconBlock, BlindedBeaconBlock, Gwei, Root, gloas} from "@lodestar/types";
7
+ import {BeaconBlock, BlindedBeaconBlock, Gwei, Root} from "@lodestar/types";
10
8
  import {ZERO_HASH} from "../../constants/index.js";
11
9
  import {Metrics} from "../../metrics/index.js";
12
10
 
@@ -19,11 +17,11 @@ export function computeNewStateRoot(
19
17
  metrics: Metrics | null,
20
18
  state: IBeaconStateView,
21
19
  block: BeaconBlock | BlindedBeaconBlock
22
- ): {newStateRoot: Root; proposerReward: Gwei; postBlockState: IBeaconStateView} {
20
+ ): {newStateRoot: Root; proposerReward: Gwei; postState: IBeaconStateView} {
23
21
  // Set signature to zero to re-use stateTransition() function which requires the SignedBeaconBlock type
24
22
  const blockEmptySig = {message: block, signature: ZERO_HASH};
25
23
 
26
- const postBlockState = state.stateTransition(
24
+ const postState = state.stateTransition(
27
25
  blockEmptySig,
28
26
  {
29
27
  // ExecutionPayloadStatus.valid: Assume payload valid, it has been produced by a trusted EL
@@ -42,49 +40,14 @@ export function computeNewStateRoot(
42
40
  {metrics}
43
41
  );
44
42
 
45
- const {attestations, syncAggregate, slashing} = postBlockState.proposerRewards;
43
+ const {attestations, syncAggregate, slashing} = postState.proposerRewards;
46
44
  const proposerReward = BigInt(attestations + syncAggregate + slashing);
47
45
 
48
46
  const hashTreeRootTimer = metrics?.stateHashTreeRootTime.startTimer({
49
47
  source: StateHashTreeRootSource.computeNewStateRoot,
50
48
  });
51
- const newStateRoot = postBlockState.hashTreeRoot();
49
+ const newStateRoot = postState.hashTreeRoot();
52
50
  hashTreeRootTimer?.();
53
51
 
54
- return {newStateRoot, proposerReward, postBlockState};
55
- }
56
-
57
- /**
58
- * Compute the state root after processing an execution payload envelope.
59
- * Similar to `computeNewStateRoot` but for payload envelope processing.
60
- *
61
- */
62
- export function computePayloadEnvelopeStateRoot(
63
- metrics: Metrics | null,
64
- postBlockState: IBeaconStateViewGloas,
65
- envelope: gloas.ExecutionPayloadEnvelope
66
- ): Root {
67
- const signedEnvelope: gloas.SignedExecutionPayloadEnvelope = {
68
- message: envelope,
69
- signature: G2_POINT_AT_INFINITY,
70
- };
71
-
72
- const processEnvelopeTimer = metrics?.blockPayload.executionPayloadEnvelopeProcessingTime.startTimer();
73
- const postPayloadState = postBlockState.processExecutionPayloadEnvelope(signedEnvelope, {
74
- // Signature is zero-ed (G2_POINT_AT_INFINITY), skip verification
75
- verifySignature: false,
76
- // State root is being computed here, the envelope doesn't have it yet
77
- verifyStateRoot: false,
78
- // Preserve cache in source state, since the resulting state is not added to the state cache
79
- dontTransferCache: true,
80
- });
81
- processEnvelopeTimer?.();
82
-
83
- const hashTreeRootTimer = metrics?.stateHashTreeRootTime.startTimer({
84
- source: StateHashTreeRootSource.computePayloadEnvelopeStateRoot,
85
- });
86
- const stateRoot = postPayloadState.hashTreeRoot();
87
- hashTreeRootTimer?.();
88
-
89
- return stateRoot;
52
+ return {newStateRoot, proposerReward, postState};
90
53
  }
@@ -19,7 +19,6 @@ import {
19
19
  IBeaconStateView,
20
20
  type IBeaconStateViewBellatrix,
21
21
  computeTimeAtSlot,
22
- isParentBlockFull,
23
22
  isStatePostBellatrix,
24
23
  isStatePostCapella,
25
24
  isStatePostGloas,
@@ -47,8 +46,9 @@ import {
47
46
  electra,
48
47
  fulu,
49
48
  gloas,
49
+ ssz,
50
50
  } from "@lodestar/types";
51
- import {Logger, fromHex, sleep, toHex, toPubkeyHex, toRootHex} from "@lodestar/utils";
51
+ import {Logger, byteArrayEquals, fromHex, sleep, toHex, toPubkeyHex, toRootHex} from "@lodestar/utils";
52
52
  import {ZERO_HASH_HEX} from "../../constants/index.js";
53
53
  import {numToQuantity} from "../../execution/engine/utils.js";
54
54
  import {
@@ -111,12 +111,7 @@ export type ProduceFullGloas = {
111
111
  executionRequests: electra.ExecutionRequests;
112
112
  blobsBundle: BlobsBundle<ForkPostGloas>;
113
113
  cells: fulu.Cell[][];
114
- /**
115
- * Cached payload envelope state root computed during block production.
116
- * This is the state root after running `processExecutionPayloadEnvelope` on the
117
- * post-block state, and later used to construct the `ExecutionPayloadEnvelope`.
118
- */
119
- payloadEnvelopeStateRoot: Root;
114
+ parentBlockRoot: Root;
120
115
  };
121
116
  export type ProduceFullFulu = {
122
117
  type: BlockType.Full;
@@ -220,14 +215,28 @@ export async function produceBlockBody<T extends BlockType>(
220
215
  });
221
216
 
222
217
  // Get execution payload from EL
218
+ let parentBlockHash: Bytes32;
219
+ let parentExecutionRequests: electra.ExecutionRequests;
220
+ // Apply parent payload once here as it's reused by EL prep and voluntary exit filtering below
221
+ let stateAfterParentPayload: IBeaconStateViewBellatrix = currentState;
222
+ const isExtendingPayload = this.forkChoice.shouldExtendPayload(toRootHex(parentBlockRoot));
223
+ if (isExtendingPayload) {
224
+ parentBlockHash = currentState.latestExecutionPayloadBid.blockHash;
225
+ parentExecutionRequests = await this.getParentExecutionRequests(parentBlock.slot, parentBlock.blockRoot);
226
+ stateAfterParentPayload = currentState.withParentPayloadApplied(parentExecutionRequests);
227
+ } else {
228
+ parentBlockHash = currentState.latestExecutionPayloadBid.parentBlockHash;
229
+ parentExecutionRequests = ssz.electra.ExecutionRequests.defaultValue();
230
+ }
223
231
  const prepareRes = await prepareExecutionPayload(
224
232
  this,
225
233
  this.logger,
226
234
  fork,
227
235
  parentBlockRoot,
236
+ parentBlockHash,
228
237
  safeBlockHash,
229
238
  finalizedBlockHash ?? ZERO_HASH_HEX,
230
- currentState,
239
+ stateAfterParentPayload,
231
240
  feeRecipient
232
241
  );
233
242
 
@@ -261,8 +270,8 @@ export async function produceBlockBody<T extends BlockType>(
261
270
 
262
271
  // Create self-build execution payload bid
263
272
  const bid: gloas.ExecutionPayloadBid = {
264
- parentBlockHash: currentState.latestBlockHash,
265
- parentBlockRoot: parentBlockRoot,
273
+ parentBlockHash,
274
+ parentBlockRoot,
266
275
  blockHash: executionPayload.blockHash,
267
276
  prevRandao: currentState.getRandaoMix(currentState.epoch),
268
277
  feeRecipient: executionPayload.feeRecipient,
@@ -272,6 +281,7 @@ export async function produceBlockBody<T extends BlockType>(
272
281
  value: 0,
273
282
  executionPayment: 0,
274
283
  blobKzgCommitments: blobsBundle.commitments,
284
+ executionRequestsRoot: ssz.electra.ExecutionRequests.hashTreeRoot(executionRequests),
275
285
  };
276
286
  const signedBid: gloas.SignedExecutionPayloadBid = {
277
287
  message: bid,
@@ -281,8 +291,19 @@ export async function produceBlockBody<T extends BlockType>(
281
291
  const commonBlockBody = await commonBlockBodyPromise;
282
292
  const gloasBody = Object.assign({}, commonBlockBody) as gloas.BeaconBlockBody;
283
293
  gloasBody.signedExecutionPayloadBid = signedBid;
284
- // TODO GLOAS: Get payload attestations from pool for previous slot
285
- gloasBody.payloadAttestations = [];
294
+ gloasBody.payloadAttestations = this.payloadAttestationPool.getPayloadAttestationsForBlock(
295
+ parentBlock.blockRoot,
296
+ blockSlot - 1
297
+ );
298
+ gloasBody.parentExecutionRequests = parentExecutionRequests;
299
+ // Drop voluntary exits that parent_execution_requests have invalidated (e.g. a withdrawal
300
+ // request initiating an exit on the same validator). Op pool selected against the unapplied
301
+ // state, so re-validate against the post-apply state to avoid producing an invalid block.
302
+ if (isExtendingPayload && commonBlockBody.voluntaryExits.length > 0) {
303
+ gloasBody.voluntaryExits = commonBlockBody.voluntaryExits.filter((signedVoluntaryExit) =>
304
+ stateAfterParentPayload.isValidVoluntaryExit(signedVoluntaryExit, false)
305
+ );
306
+ }
286
307
  blockBody = gloasBody as AssembledBodyType<T>;
287
308
 
288
309
  // Store execution payload data required to construct execution payload envelope later
@@ -291,6 +312,7 @@ export async function produceBlockBody<T extends BlockType>(
291
312
  gloasResult.executionRequests = executionRequests;
292
313
  gloasResult.blobsBundle = blobsBundle;
293
314
  gloasResult.cells = cells;
315
+ gloasResult.parentBlockRoot = fromHex(parentBlock.blockRoot);
294
316
 
295
317
  const fetchedTime = Date.now() / 1000 - computeTimeAtSlot(this.config, blockSlot, this.genesisTime);
296
318
  this.metrics?.blockPayload.payloadFetchedTime.observe({prepType}, fetchedTime);
@@ -340,6 +362,7 @@ export async function produceBlockBody<T extends BlockType>(
340
362
  this.logger,
341
363
  fork,
342
364
  parentBlockRoot,
365
+ currentState.latestExecutionPayloadHeader.blockHash,
343
366
  safeBlockHash,
344
367
  finalizedBlockHash ?? ZERO_HASH_HEX,
345
368
  currentState,
@@ -448,6 +471,7 @@ export async function produceBlockBody<T extends BlockType>(
448
471
  this.logger,
449
472
  fork,
450
473
  parentBlockRoot,
474
+ currentState.latestExecutionPayloadHeader.blockHash,
451
475
  safeBlockHash,
452
476
  finalizedBlockHash ?? ZERO_HASH_HEX,
453
477
  currentState,
@@ -613,17 +637,21 @@ export async function prepareExecutionPayload(
613
637
  logger: Logger,
614
638
  fork: ForkPostBellatrix,
615
639
  parentBlockRoot: Root,
640
+ parentBlockHash: Bytes32,
616
641
  safeBlockHash: RootHex,
617
642
  finalizedBlockHash: RootHex,
643
+ /**
644
+ * Post-gloas, when extending a full parent, callers must apply
645
+ * parent execution payload first (see `withParentPayloadApplied`).
646
+ */
618
647
  state: IBeaconStateViewBellatrix,
619
648
  suggestedFeeRecipient: string
620
649
  ): Promise<{prepType: PayloadPreparationType; payloadId: PayloadId}> {
621
- const parentHash = state.latestBlockHash;
622
650
  const timestamp = computeTimeAtSlot(chain.config, state.slot, state.genesisTime);
623
651
  const prevRandao = state.getRandaoMix(state.epoch);
624
652
 
625
653
  const payloadIdCached = chain.executionEngine.payloadIdCache.get({
626
- headBlockHash: toRootHex(parentHash),
654
+ headBlockHash: toRootHex(parentBlockHash),
627
655
  finalizedBlockHash,
628
656
  timestamp: numToQuantity(timestamp),
629
657
  prevRandao: toHex(prevRandao),
@@ -652,12 +680,13 @@ export async function prepareExecutionPayload(
652
680
  prepareState: state,
653
681
  prepareSlot: state.slot,
654
682
  parentBlockRoot,
683
+ parentBlockHash,
655
684
  feeRecipient: suggestedFeeRecipient,
656
685
  });
657
686
 
658
687
  payloadId = await chain.executionEngine.notifyForkchoiceUpdate(
659
688
  fork,
660
- toRootHex(parentHash),
689
+ toRootHex(parentBlockHash),
661
690
  safeBlockHash,
662
691
  finalizedBlockHash,
663
692
  attributes
@@ -709,20 +738,34 @@ export function getPayloadAttributesForSSE(
709
738
  prepareState,
710
739
  prepareSlot,
711
740
  parentBlockRoot,
741
+ parentBlockHash,
712
742
  feeRecipient,
713
- }: {prepareState: IBeaconStateViewBellatrix; prepareSlot: Slot; parentBlockRoot: Root; feeRecipient: string}
743
+ }: {
744
+ /**
745
+ * Post-gloas, when extending a full parent, callers must apply
746
+ * parent execution payload first (see `withParentPayloadApplied`).
747
+ */
748
+ prepareState: IBeaconStateViewBellatrix;
749
+ prepareSlot: Slot;
750
+ parentBlockRoot: Root;
751
+ parentBlockHash: Bytes32;
752
+ feeRecipient: string;
753
+ }
714
754
  ): SSEPayloadAttributes {
715
- const parentHash = prepareState.latestBlockHash;
716
755
  const payloadAttributes = preparePayloadAttributes(fork, chain, {
717
756
  prepareState,
718
757
  prepareSlot,
719
758
  parentBlockRoot,
759
+ parentBlockHash,
720
760
  feeRecipient,
721
761
  });
722
762
 
723
763
  let parentBlockNumber: number;
724
764
  if (isForkPostGloas(fork)) {
725
- const parentBlock = chain.forkChoice.getBlockHexAndBlockHash(toRootHex(parentBlockRoot), toRootHex(parentHash));
765
+ const parentBlock = chain.forkChoice.getBlockHexAndBlockHash(
766
+ toRootHex(parentBlockRoot),
767
+ toRootHex(parentBlockHash)
768
+ );
726
769
  if (parentBlock?.executionPayloadBlockHash == null) {
727
770
  throw Error(`Parent block not found in fork choice root=${toRootHex(parentBlockRoot)}`);
728
771
  }
@@ -736,7 +779,7 @@ export function getPayloadAttributesForSSE(
736
779
  proposalSlot: prepareSlot,
737
780
  parentBlockNumber,
738
781
  parentBlockRoot,
739
- parentBlockHash: parentHash,
782
+ parentBlockHash,
740
783
  payloadAttributes,
741
784
  };
742
785
  return ssePayloadAttributes;
@@ -751,11 +794,17 @@ function preparePayloadAttributes(
751
794
  prepareState,
752
795
  prepareSlot,
753
796
  parentBlockRoot,
797
+ parentBlockHash,
754
798
  feeRecipient,
755
799
  }: {
800
+ /**
801
+ * Post-gloas, when extending a full parent, callers must apply
802
+ * parent execution payload first (see `withParentPayloadApplied`).
803
+ */
756
804
  prepareState: IBeaconStateViewBellatrix;
757
805
  prepareSlot: Slot;
758
806
  parentBlockRoot: Root;
807
+ parentBlockHash: Bytes32;
759
808
  feeRecipient: string;
760
809
  }
761
810
  ): SSEPayloadAttributes["payloadAttributes"] {
@@ -772,13 +821,24 @@ function preparePayloadAttributes(
772
821
  throw new Error("Expected Capella state for withdrawals");
773
822
  }
774
823
 
775
- if (isStatePostGloas(prepareState) && !isParentBlockFull(prepareState)) {
776
- // When the parent block is empty, state.payloadExpectedWithdrawals holds a batch
777
- // already deducted from CL balances but never credited on the EL (the envelope
778
- // was not delivered). The next payload must carry those same withdrawals to
779
- // restore CL/EL consistency, otherwise validators permanently lose that balance.
780
- (payloadAttributes as capella.SSEPayloadAttributes["payloadAttributes"]).withdrawals =
781
- prepareState.payloadExpectedWithdrawals;
824
+ if (isStatePostGloas(prepareState)) {
825
+ const isExtendingPayload = byteArrayEquals(parentBlockHash, prepareState.latestExecutionPayloadBid.blockHash);
826
+ if (isExtendingPayload) {
827
+ // applyParentExecutionPayload sets latestBlockHash = parentBid.blockHash, so a mismatch
828
+ // here means the caller did not apply parent payload to prepareState
829
+ if (!byteArrayEquals(prepareState.latestBlockHash, prepareState.latestExecutionPayloadBid.blockHash)) {
830
+ throw new Error("Expected state with parent execution payload applied for withdrawals");
831
+ }
832
+ (payloadAttributes as capella.SSEPayloadAttributes["payloadAttributes"]).withdrawals =
833
+ prepareState.getExpectedWithdrawals().expectedWithdrawals;
834
+ } else {
835
+ // When the parent block is empty, state.payloadExpectedWithdrawals holds a batch
836
+ // already deducted from CL balances but never credited on the EL (the envelope
837
+ // was not delivered). The next payload must carry those same withdrawals to
838
+ // restore CL/EL consistency, otherwise validators permanently lose that balance.
839
+ (payloadAttributes as capella.SSEPayloadAttributes["payloadAttributes"]).withdrawals =
840
+ prepareState.payloadExpectedWithdrawals;
841
+ }
782
842
  } else {
783
843
  // withdrawals logic is now fork aware as it changes on electra fork post capella
784
844
  (payloadAttributes as capella.SSEPayloadAttributes["payloadAttributes"]).withdrawals =
@@ -790,6 +850,10 @@ function preparePayloadAttributes(
790
850
  (payloadAttributes as deneb.SSEPayloadAttributes["payloadAttributes"]).parentBeaconBlockRoot = parentBlockRoot;
791
851
  }
792
852
 
853
+ if (ForkSeq[fork] >= ForkSeq.gloas) {
854
+ (payloadAttributes as gloas.SSEPayloadAttributes["payloadAttributes"]).slotNumber = prepareSlot;
855
+ }
856
+
793
857
  return payloadAttributes;
794
858
  }
795
859
 
@@ -1,4 +1,3 @@
1
- import {PayloadStatus} from "@lodestar/fork-choice";
2
1
  import {Root, RootHex, Slot} from "@lodestar/types";
3
2
 
4
3
  export enum RegenErrorCode {
@@ -10,8 +9,6 @@ export enum RegenErrorCode {
10
9
  BLOCK_NOT_IN_DB = "REGEN_ERROR_BLOCK_NOT_IN_DB",
11
10
  STATE_TRANSITION_ERROR = "REGEN_ERROR_STATE_TRANSITION_ERROR",
12
11
  INVALID_STATE_ROOT = "REGEN_ERROR_INVALID_STATE_ROOT",
13
- UNEXPECTED_PAYLOAD_STATUS = "REGEN_ERROR_UNEXPECTED_PAYLOAD_STATUS",
14
- INTERNAL_ERROR = "REGEN_ERROR_INTERNAL_ERROR",
15
12
  }
16
13
 
17
14
  export type RegenErrorType =
@@ -22,9 +19,7 @@ export type RegenErrorType =
22
19
  | {code: RegenErrorCode.TOO_MANY_BLOCK_PROCESSED; stateRoot: RootHex | Root}
23
20
  | {code: RegenErrorCode.BLOCK_NOT_IN_DB; blockRoot: RootHex | Root}
24
21
  | {code: RegenErrorCode.STATE_TRANSITION_ERROR; error: Error}
25
- | {code: RegenErrorCode.INVALID_STATE_ROOT; slot: Slot; expected: RootHex; actual: RootHex}
26
- | {code: RegenErrorCode.UNEXPECTED_PAYLOAD_STATUS; blockRoot: RootHex | Root; payloadStatus: PayloadStatus}
27
- | {code: RegenErrorCode.INTERNAL_ERROR; message: string};
22
+ | {code: RegenErrorCode.INVALID_STATE_ROOT; slot: Slot; expected: RootHex; actual: RootHex};
28
23
 
29
24
  export class RegenError extends Error {
30
25
  type: RegenErrorType;