@lodestar/beacon-node 1.43.0-dev.abc719ddc1 → 1.43.0-dev.ac258a8def

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 (379) 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 -6
  17. package/lib/api/impl/validator/index.js.map +1 -1
  18. package/lib/chain/archiveStore/archiveStore.d.ts.map +1 -1
  19. package/lib/chain/archiveStore/archiveStore.js.map +1 -1
  20. package/lib/chain/archiveStore/interface.d.ts +4 -4
  21. package/lib/chain/archiveStore/interface.d.ts.map +1 -1
  22. package/lib/chain/archiveStore/strategies/frequencyStateArchiveStrategy.d.ts +4 -4
  23. package/lib/chain/archiveStore/strategies/frequencyStateArchiveStrategy.d.ts.map +1 -1
  24. package/lib/chain/archiveStore/strategies/frequencyStateArchiveStrategy.js.map +1 -1
  25. package/lib/chain/archiveStore/utils/archiveBlocks.d.ts +2 -2
  26. package/lib/chain/archiveStore/utils/archiveBlocks.d.ts.map +1 -1
  27. package/lib/chain/archiveStore/utils/archiveBlocks.js +110 -58
  28. package/lib/chain/archiveStore/utils/archiveBlocks.js.map +1 -1
  29. package/lib/chain/blocks/blockInput/blockInput.d.ts +3 -0
  30. package/lib/chain/blocks/blockInput/blockInput.d.ts.map +1 -1
  31. package/lib/chain/blocks/blockInput/blockInput.js +4 -1
  32. package/lib/chain/blocks/blockInput/blockInput.js.map +1 -1
  33. package/lib/chain/blocks/importBlock.d.ts.map +1 -1
  34. package/lib/chain/blocks/importBlock.js +16 -28
  35. package/lib/chain/blocks/importBlock.js.map +1 -1
  36. package/lib/chain/blocks/importExecutionPayload.d.ts +32 -14
  37. package/lib/chain/blocks/importExecutionPayload.d.ts.map +1 -1
  38. package/lib/chain/blocks/importExecutionPayload.js +100 -91
  39. package/lib/chain/blocks/importExecutionPayload.js.map +1 -1
  40. package/lib/chain/blocks/index.d.ts +5 -3
  41. package/lib/chain/blocks/index.d.ts.map +1 -1
  42. package/lib/chain/blocks/index.js +58 -26
  43. package/lib/chain/blocks/index.js.map +1 -1
  44. package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.d.ts +12 -1
  45. package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.d.ts.map +1 -1
  46. package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.js +28 -2
  47. package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.js.map +1 -1
  48. package/lib/chain/blocks/payloadEnvelopeInput/types.d.ts +17 -0
  49. package/lib/chain/blocks/payloadEnvelopeInput/types.d.ts.map +1 -1
  50. package/lib/chain/blocks/payloadEnvelopeProcessor.js +2 -2
  51. package/lib/chain/blocks/payloadEnvelopeProcessor.js.map +1 -1
  52. package/lib/chain/blocks/types.d.ts +15 -20
  53. package/lib/chain/blocks/types.d.ts.map +1 -1
  54. package/lib/chain/blocks/utils/chainSegment.d.ts +21 -2
  55. package/lib/chain/blocks/utils/chainSegment.d.ts.map +1 -1
  56. package/lib/chain/blocks/utils/chainSegment.js +92 -12
  57. package/lib/chain/blocks/utils/chainSegment.js.map +1 -1
  58. package/lib/chain/blocks/verifyBlock.d.ts +5 -3
  59. package/lib/chain/blocks/verifyBlock.d.ts.map +1 -1
  60. package/lib/chain/blocks/verifyBlock.js +50 -7
  61. package/lib/chain/blocks/verifyBlock.js.map +1 -1
  62. package/lib/chain/blocks/verifyBlocksExecutionPayloads.d.ts +0 -4
  63. package/lib/chain/blocks/verifyBlocksExecutionPayloads.d.ts.map +1 -1
  64. package/lib/chain/blocks/verifyBlocksExecutionPayloads.js +5 -2
  65. package/lib/chain/blocks/verifyBlocksExecutionPayloads.js.map +1 -1
  66. package/lib/chain/blocks/verifyBlocksSanityChecks.d.ts +2 -1
  67. package/lib/chain/blocks/verifyBlocksSanityChecks.d.ts.map +1 -1
  68. package/lib/chain/blocks/verifyBlocksSanityChecks.js +25 -5
  69. package/lib/chain/blocks/verifyBlocksSanityChecks.js.map +1 -1
  70. package/lib/chain/blocks/verifyExecutionPayloadEnvelope.d.ts +24 -0
  71. package/lib/chain/blocks/verifyExecutionPayloadEnvelope.d.ts.map +1 -0
  72. package/lib/chain/blocks/verifyExecutionPayloadEnvelope.js +80 -0
  73. package/lib/chain/blocks/verifyExecutionPayloadEnvelope.js.map +1 -0
  74. package/lib/chain/blocks/verifyPayloadsDataAvailability.d.ts.map +1 -1
  75. package/lib/chain/blocks/verifyPayloadsDataAvailability.js +8 -3
  76. package/lib/chain/blocks/verifyPayloadsDataAvailability.js.map +1 -1
  77. package/lib/chain/blocks/writePayloadEnvelopeInputToDb.d.ts +1 -1
  78. package/lib/chain/blocks/writePayloadEnvelopeInputToDb.d.ts.map +1 -1
  79. package/lib/chain/blocks/writePayloadEnvelopeInputToDb.js +2 -11
  80. package/lib/chain/blocks/writePayloadEnvelopeInputToDb.js.map +1 -1
  81. package/lib/chain/chain.d.ts +8 -6
  82. package/lib/chain/chain.d.ts.map +1 -1
  83. package/lib/chain/chain.js +44 -14
  84. package/lib/chain/chain.js.map +1 -1
  85. package/lib/chain/emitter.d.ts +3 -14
  86. package/lib/chain/emitter.d.ts.map +1 -1
  87. package/lib/chain/emitter.js +0 -4
  88. package/lib/chain/emitter.js.map +1 -1
  89. package/lib/chain/errors/blockError.d.ts +8 -1
  90. package/lib/chain/errors/blockError.d.ts.map +1 -1
  91. package/lib/chain/errors/blockError.js +2 -0
  92. package/lib/chain/errors/blockError.js.map +1 -1
  93. package/lib/chain/errors/executionPayloadBid.d.ts +5 -0
  94. package/lib/chain/errors/executionPayloadBid.d.ts.map +1 -1
  95. package/lib/chain/errors/executionPayloadBid.js +1 -0
  96. package/lib/chain/errors/executionPayloadBid.js.map +1 -1
  97. package/lib/chain/errors/executionPayloadEnvelope.d.ts +5 -0
  98. package/lib/chain/errors/executionPayloadEnvelope.d.ts.map +1 -1
  99. package/lib/chain/errors/executionPayloadEnvelope.js +1 -0
  100. package/lib/chain/errors/executionPayloadEnvelope.js.map +1 -1
  101. package/lib/chain/errors/index.d.ts +1 -0
  102. package/lib/chain/errors/index.d.ts.map +1 -1
  103. package/lib/chain/errors/index.js +1 -0
  104. package/lib/chain/errors/index.js.map +1 -1
  105. package/lib/chain/errors/proposerPreferences.d.ts +40 -0
  106. package/lib/chain/errors/proposerPreferences.d.ts.map +1 -0
  107. package/lib/chain/errors/proposerPreferences.js +14 -0
  108. package/lib/chain/errors/proposerPreferences.js.map +1 -0
  109. package/lib/chain/forkChoice/index.d.ts.map +1 -1
  110. package/lib/chain/forkChoice/index.js +5 -17
  111. package/lib/chain/forkChoice/index.js.map +1 -1
  112. package/lib/chain/initState.d.ts.map +1 -1
  113. package/lib/chain/initState.js +6 -1
  114. package/lib/chain/initState.js.map +1 -1
  115. package/lib/chain/interface.d.ts +7 -5
  116. package/lib/chain/interface.d.ts.map +1 -1
  117. package/lib/chain/interface.js.map +1 -1
  118. package/lib/chain/opPools/payloadAttestationPool.d.ts +3 -2
  119. package/lib/chain/opPools/payloadAttestationPool.d.ts.map +1 -1
  120. package/lib/chain/opPools/payloadAttestationPool.js +26 -4
  121. package/lib/chain/opPools/payloadAttestationPool.js.map +1 -1
  122. package/lib/chain/prepareNextSlot.d.ts.map +1 -1
  123. package/lib/chain/prepareNextSlot.js +31 -13
  124. package/lib/chain/prepareNextSlot.js.map +1 -1
  125. package/lib/chain/produceBlock/produceBlockBody.d.ts +11 -1
  126. package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
  127. package/lib/chain/produceBlock/produceBlockBody.js +52 -14
  128. package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
  129. package/lib/chain/regen/interface.d.ts +1 -0
  130. package/lib/chain/regen/interface.d.ts.map +1 -1
  131. package/lib/chain/regen/interface.js +1 -0
  132. package/lib/chain/regen/interface.js.map +1 -1
  133. package/lib/chain/regen/queued.d.ts.map +1 -1
  134. package/lib/chain/regen/queued.js +1 -4
  135. package/lib/chain/regen/queued.js.map +1 -1
  136. package/lib/chain/regen/regen.d.ts.map +1 -1
  137. package/lib/chain/regen/regen.js +1 -4
  138. package/lib/chain/regen/regen.js.map +1 -1
  139. package/lib/chain/seenCache/index.d.ts +1 -0
  140. package/lib/chain/seenCache/index.d.ts.map +1 -1
  141. package/lib/chain/seenCache/index.js +1 -0
  142. package/lib/chain/seenCache/index.js.map +1 -1
  143. package/lib/chain/seenCache/seenPayloadEnvelopeInput.d.ts +24 -7
  144. package/lib/chain/seenCache/seenPayloadEnvelopeInput.d.ts.map +1 -1
  145. package/lib/chain/seenCache/seenPayloadEnvelopeInput.js +69 -17
  146. package/lib/chain/seenCache/seenPayloadEnvelopeInput.js.map +1 -1
  147. package/lib/chain/seenCache/seenProposerPreferences.d.ts +16 -0
  148. package/lib/chain/seenCache/seenProposerPreferences.d.ts.map +1 -0
  149. package/lib/chain/seenCache/seenProposerPreferences.js +26 -0
  150. package/lib/chain/seenCache/seenProposerPreferences.js.map +1 -0
  151. package/lib/chain/validation/block.d.ts.map +1 -1
  152. package/lib/chain/validation/block.js +1 -0
  153. package/lib/chain/validation/block.js.map +1 -1
  154. package/lib/chain/validation/executionPayloadBid.d.ts.map +1 -1
  155. package/lib/chain/validation/executionPayloadBid.js +24 -9
  156. package/lib/chain/validation/executionPayloadBid.js.map +1 -1
  157. package/lib/chain/validation/executionPayloadEnvelope.d.ts.map +1 -1
  158. package/lib/chain/validation/executionPayloadEnvelope.js +19 -9
  159. package/lib/chain/validation/executionPayloadEnvelope.js.map +1 -1
  160. package/lib/chain/validation/proposerPreferences.d.ts +8 -0
  161. package/lib/chain/validation/proposerPreferences.d.ts.map +1 -0
  162. package/lib/chain/validation/proposerPreferences.js +91 -0
  163. package/lib/chain/validation/proposerPreferences.js.map +1 -0
  164. package/lib/db/repositories/executionPayloadEnvelopeArchive.js +1 -1
  165. package/lib/db/repositories/executionPayloadEnvelopeArchive.js.map +1 -1
  166. package/lib/execution/engine/http.d.ts.map +1 -1
  167. package/lib/execution/engine/http.js +21 -14
  168. package/lib/execution/engine/http.js.map +1 -1
  169. package/lib/execution/engine/interface.d.ts +1 -0
  170. package/lib/execution/engine/interface.d.ts.map +1 -1
  171. package/lib/execution/engine/mock.d.ts.map +1 -1
  172. package/lib/execution/engine/mock.js +6 -0
  173. package/lib/execution/engine/mock.js.map +1 -1
  174. package/lib/execution/engine/types.d.ts +20 -0
  175. package/lib/execution/engine/types.d.ts.map +1 -1
  176. package/lib/execution/engine/types.js +18 -0
  177. package/lib/execution/engine/types.js.map +1 -1
  178. package/lib/metrics/metrics/lodestar.d.ts +1 -0
  179. package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
  180. package/lib/metrics/metrics/lodestar.js +4 -0
  181. package/lib/metrics/metrics/lodestar.js.map +1 -1
  182. package/lib/network/gossip/interface.d.ts +7 -1
  183. package/lib/network/gossip/interface.d.ts.map +1 -1
  184. package/lib/network/gossip/interface.js +1 -0
  185. package/lib/network/gossip/interface.js.map +1 -1
  186. package/lib/network/gossip/scoringParameters.d.ts.map +1 -1
  187. package/lib/network/gossip/scoringParameters.js +12 -1
  188. package/lib/network/gossip/scoringParameters.js.map +1 -1
  189. package/lib/network/gossip/topic.d.ts +32 -748
  190. package/lib/network/gossip/topic.d.ts.map +1 -1
  191. package/lib/network/gossip/topic.js +6 -0
  192. package/lib/network/gossip/topic.js.map +1 -1
  193. package/lib/network/interface.d.ts +2 -0
  194. package/lib/network/interface.d.ts.map +1 -1
  195. package/lib/network/network.d.ts +2 -0
  196. package/lib/network/network.d.ts.map +1 -1
  197. package/lib/network/network.js +9 -1
  198. package/lib/network/network.js.map +1 -1
  199. package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
  200. package/lib/network/processor/gossipHandlers.js +41 -19
  201. package/lib/network/processor/gossipHandlers.js.map +1 -1
  202. package/lib/network/processor/gossipQueues/index.d.ts.map +1 -1
  203. package/lib/network/processor/gossipQueues/index.js +5 -0
  204. package/lib/network/processor/gossipQueues/index.js.map +1 -1
  205. package/lib/network/processor/index.d.ts.map +1 -1
  206. package/lib/network/processor/index.js +6 -5
  207. package/lib/network/processor/index.js.map +1 -1
  208. package/lib/network/reqresp/ReqRespBeaconNode.d.ts.map +1 -1
  209. package/lib/network/reqresp/ReqRespBeaconNode.js +1 -1
  210. package/lib/network/reqresp/ReqRespBeaconNode.js.map +1 -1
  211. package/lib/network/reqresp/handlers/beaconBlocksByHead.d.ts +9 -0
  212. package/lib/network/reqresp/handlers/beaconBlocksByHead.d.ts.map +1 -0
  213. package/lib/network/reqresp/handlers/beaconBlocksByHead.js +61 -0
  214. package/lib/network/reqresp/handlers/beaconBlocksByHead.js.map +1 -0
  215. package/lib/network/reqresp/handlers/beaconBlocksByRange.d.ts.map +1 -1
  216. package/lib/network/reqresp/handlers/beaconBlocksByRange.js +14 -6
  217. package/lib/network/reqresp/handlers/beaconBlocksByRange.js.map +1 -1
  218. package/lib/network/reqresp/handlers/blobSidecarsByRange.d.ts.map +1 -1
  219. package/lib/network/reqresp/handlers/blobSidecarsByRange.js +11 -5
  220. package/lib/network/reqresp/handlers/blobSidecarsByRange.js.map +1 -1
  221. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.d.ts.map +1 -1
  222. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js +17 -5
  223. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js.map +1 -1
  224. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.d.ts.map +1 -1
  225. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.js +7 -4
  226. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.js.map +1 -1
  227. package/lib/network/reqresp/handlers/index.d.ts.map +1 -1
  228. package/lib/network/reqresp/handlers/index.js +5 -0
  229. package/lib/network/reqresp/handlers/index.js.map +1 -1
  230. package/lib/network/reqresp/interface.d.ts +1 -1
  231. package/lib/network/reqresp/interface.js +1 -1
  232. package/lib/network/reqresp/protocols.d.ts +1 -0
  233. package/lib/network/reqresp/protocols.d.ts.map +1 -1
  234. package/lib/network/reqresp/protocols.js +5 -0
  235. package/lib/network/reqresp/protocols.js.map +1 -1
  236. package/lib/network/reqresp/rateLimit.d.ts.map +1 -1
  237. package/lib/network/reqresp/rateLimit.js +4 -0
  238. package/lib/network/reqresp/rateLimit.js.map +1 -1
  239. package/lib/network/reqresp/score.d.ts.map +1 -1
  240. package/lib/network/reqresp/score.js +1 -0
  241. package/lib/network/reqresp/score.js.map +1 -1
  242. package/lib/network/reqresp/types.d.ts +3 -0
  243. package/lib/network/reqresp/types.d.ts.map +1 -1
  244. package/lib/network/reqresp/types.js +3 -0
  245. package/lib/network/reqresp/types.js.map +1 -1
  246. package/lib/node/nodejs.js +2 -2
  247. package/lib/node/nodejs.js.map +1 -1
  248. package/lib/sync/constants.d.ts +7 -1
  249. package/lib/sync/constants.d.ts.map +1 -1
  250. package/lib/sync/constants.js +7 -4
  251. package/lib/sync/constants.js.map +1 -1
  252. package/lib/sync/range/batch.d.ts +35 -5
  253. package/lib/sync/range/batch.d.ts.map +1 -1
  254. package/lib/sync/range/batch.js +240 -59
  255. package/lib/sync/range/batch.js.map +1 -1
  256. package/lib/sync/range/chain.d.ts +22 -4
  257. package/lib/sync/range/chain.d.ts.map +1 -1
  258. package/lib/sync/range/chain.js +102 -10
  259. package/lib/sync/range/chain.js.map +1 -1
  260. package/lib/sync/range/range.d.ts.map +1 -1
  261. package/lib/sync/range/range.js +71 -11
  262. package/lib/sync/range/range.js.map +1 -1
  263. package/lib/sync/sync.d.ts.map +1 -1
  264. package/lib/sync/sync.js +13 -0
  265. package/lib/sync/sync.js.map +1 -1
  266. package/lib/sync/types.d.ts +34 -0
  267. package/lib/sync/types.d.ts.map +1 -1
  268. package/lib/sync/types.js +34 -0
  269. package/lib/sync/types.js.map +1 -1
  270. package/lib/sync/unknownBlock.d.ts +29 -1
  271. package/lib/sync/unknownBlock.d.ts.map +1 -1
  272. package/lib/sync/unknownBlock.js +727 -61
  273. package/lib/sync/unknownBlock.js.map +1 -1
  274. package/lib/sync/utils/downloadByRange.d.ts +73 -10
  275. package/lib/sync/utils/downloadByRange.d.ts.map +1 -1
  276. package/lib/sync/utils/downloadByRange.js +213 -26
  277. package/lib/sync/utils/downloadByRange.js.map +1 -1
  278. package/lib/sync/utils/downloadByRoot.d.ts.map +1 -1
  279. package/lib/sync/utils/downloadByRoot.js +16 -2
  280. package/lib/sync/utils/downloadByRoot.js.map +1 -1
  281. package/lib/sync/utils/pendingBlocksTree.d.ts +0 -1
  282. package/lib/sync/utils/pendingBlocksTree.d.ts.map +1 -1
  283. package/lib/sync/utils/pendingBlocksTree.js +0 -9
  284. package/lib/sync/utils/pendingBlocksTree.js.map +1 -1
  285. package/lib/sync/utils/rateLimit.d.ts +2 -0
  286. package/lib/sync/utils/rateLimit.d.ts.map +1 -0
  287. package/lib/sync/utils/rateLimit.js +15 -0
  288. package/lib/sync/utils/rateLimit.js.map +1 -0
  289. package/lib/util/sszBytes.d.ts.map +1 -1
  290. package/lib/util/sszBytes.js +20 -5
  291. package/lib/util/sszBytes.js.map +1 -1
  292. package/package.json +17 -16
  293. package/src/api/impl/beacon/blocks/index.ts +22 -9
  294. package/src/api/impl/beacon/pool/index.ts +83 -1
  295. package/src/api/impl/beacon/state/utils.ts +2 -2
  296. package/src/api/impl/debug/index.ts +0 -1
  297. package/src/api/impl/lodestar/index.ts +1 -1
  298. package/src/api/impl/validator/index.ts +82 -5
  299. package/src/chain/archiveStore/archiveStore.ts +5 -5
  300. package/src/chain/archiveStore/interface.ts +4 -4
  301. package/src/chain/archiveStore/strategies/frequencyStateArchiveStrategy.ts +4 -4
  302. package/src/chain/archiveStore/utils/archiveBlocks.ts +153 -94
  303. package/src/chain/blocks/blockInput/blockInput.ts +4 -1
  304. package/src/chain/blocks/importBlock.ts +16 -48
  305. package/src/chain/blocks/importExecutionPayload.ts +126 -110
  306. package/src/chain/blocks/index.ts +71 -23
  307. package/src/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.ts +37 -3
  308. package/src/chain/blocks/payloadEnvelopeInput/types.ts +18 -0
  309. package/src/chain/blocks/payloadEnvelopeProcessor.ts +2 -2
  310. package/src/chain/blocks/types.ts +15 -25
  311. package/src/chain/blocks/utils/chainSegment.ts +117 -17
  312. package/src/chain/blocks/verifyBlock.ts +70 -9
  313. package/src/chain/blocks/verifyBlocksExecutionPayloads.ts +6 -4
  314. package/src/chain/blocks/verifyBlocksSanityChecks.ts +26 -7
  315. package/src/chain/blocks/verifyExecutionPayloadEnvelope.ts +137 -0
  316. package/src/chain/blocks/verifyPayloadsDataAvailability.ts +7 -4
  317. package/src/chain/blocks/writePayloadEnvelopeInputToDb.ts +9 -18
  318. package/src/chain/chain.ts +65 -26
  319. package/src/chain/emitter.ts +3 -14
  320. package/src/chain/errors/blockError.ts +4 -1
  321. package/src/chain/errors/executionPayloadBid.ts +6 -0
  322. package/src/chain/errors/executionPayloadEnvelope.ts +6 -0
  323. package/src/chain/errors/index.ts +1 -0
  324. package/src/chain/errors/proposerPreferences.ts +47 -0
  325. package/src/chain/forkChoice/index.ts +2 -22
  326. package/src/chain/initState.ts +9 -1
  327. package/src/chain/interface.ts +11 -3
  328. package/src/chain/opPools/payloadAttestationPool.ts +29 -8
  329. package/src/chain/prepareNextSlot.ts +36 -14
  330. package/src/chain/produceBlock/produceBlockBody.ts +63 -13
  331. package/src/chain/regen/interface.ts +1 -0
  332. package/src/chain/regen/queued.ts +2 -7
  333. package/src/chain/regen/regen.ts +2 -7
  334. package/src/chain/seenCache/index.ts +1 -0
  335. package/src/chain/seenCache/seenPayloadEnvelopeInput.ts +89 -21
  336. package/src/chain/seenCache/seenProposerPreferences.ts +32 -0
  337. package/src/chain/validation/block.ts +1 -0
  338. package/src/chain/validation/executionPayloadBid.ts +25 -8
  339. package/src/chain/validation/executionPayloadEnvelope.ts +20 -10
  340. package/src/chain/validation/proposerPreferences.ts +110 -0
  341. package/src/db/repositories/executionPayloadEnvelopeArchive.ts +1 -1
  342. package/src/execution/engine/http.ts +21 -14
  343. package/src/execution/engine/interface.ts +1 -0
  344. package/src/execution/engine/mock.ts +8 -1
  345. package/src/execution/engine/types.ts +41 -0
  346. package/src/metrics/metrics/lodestar.ts +4 -0
  347. package/src/network/gossip/interface.ts +6 -0
  348. package/src/network/gossip/scoringParameters.ts +14 -1
  349. package/src/network/gossip/topic.ts +6 -0
  350. package/src/network/interface.ts +2 -0
  351. package/src/network/network.ts +24 -1
  352. package/src/network/processor/gossipHandlers.ts +56 -20
  353. package/src/network/processor/gossipQueues/index.ts +5 -0
  354. package/src/network/processor/index.ts +6 -5
  355. package/src/network/reqresp/ReqRespBeaconNode.ts +1 -0
  356. package/src/network/reqresp/handlers/beaconBlocksByHead.ts +91 -0
  357. package/src/network/reqresp/handlers/beaconBlocksByRange.ts +14 -6
  358. package/src/network/reqresp/handlers/blobSidecarsByRange.ts +11 -5
  359. package/src/network/reqresp/handlers/dataColumnSidecarsByRange.ts +17 -5
  360. package/src/network/reqresp/handlers/executionPayloadEnvelopesByRange.ts +7 -4
  361. package/src/network/reqresp/handlers/index.ts +5 -0
  362. package/src/network/reqresp/interface.ts +1 -1
  363. package/src/network/reqresp/protocols.ts +6 -0
  364. package/src/network/reqresp/rateLimit.ts +4 -0
  365. package/src/network/reqresp/score.ts +1 -0
  366. package/src/network/reqresp/types.ts +5 -0
  367. package/src/node/nodejs.ts +2 -2
  368. package/src/sync/constants.ts +8 -4
  369. package/src/sync/range/batch.ts +320 -67
  370. package/src/sync/range/chain.ts +130 -13
  371. package/src/sync/range/range.ts +86 -11
  372. package/src/sync/sync.ts +13 -1
  373. package/src/sync/types.ts +72 -0
  374. package/src/sync/unknownBlock.ts +915 -65
  375. package/src/sync/utils/downloadByRange.ts +386 -39
  376. package/src/sync/utils/downloadByRoot.ts +24 -2
  377. package/src/sync/utils/pendingBlocksTree.ts +0 -15
  378. package/src/sync/utils/rateLimit.ts +16 -0
  379. package/src/util/sszBytes.ts +25 -5
@@ -4,6 +4,7 @@ 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,
@@ -83,7 +84,7 @@ export class PrepareNextSlotScheduler {
83
84
  const headBlock = this.chain.recomputeForkChoiceHead(ForkchoiceCaller.prepareNextSlot);
84
85
  const {slot: headSlot, blockRoot: headRoot} = headBlock;
85
86
  // may be updated below if we predict a proposer-boost-reorg
86
- let updatedHeadRoot = headRoot;
87
+ let updatedHead = headBlock;
87
88
 
88
89
  // PS: previously this was comparing slots, but that gave no leway on the skipped
89
90
  // slots on epoch bounday. Making it more fluid.
@@ -148,7 +149,7 @@ export class PrepareNextSlotScheduler {
148
149
  {dontTransferCache: !isEpochTransition},
149
150
  RegenCaller.predictProposerHead
150
151
  );
151
- updatedHeadRoot = proposerHeadRoot;
152
+ updatedHead = proposerHead;
152
153
  }
153
154
 
154
155
  // Update the builder status, if enabled shoot an api call to check status
@@ -165,10 +166,22 @@ export class PrepareNextSlotScheduler {
165
166
  }
166
167
 
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;
168
171
  if (isStatePostGloas(updatedPrepareState)) {
169
- parentBlockHash = this.chain.forkChoice.shouldExtendPayload(updatedHeadRoot)
170
- ? updatedPrepareState.latestExecutionPayloadBid.blockHash
171
- : updatedPrepareState.latestExecutionPayloadBid.parentBlockHash;
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
+ }
172
185
  } else {
173
186
  parentBlockHash = updatedPrepareState.latestExecutionPayloadHeader.blockHash;
174
187
  }
@@ -189,11 +202,11 @@ export class PrepareNextSlotScheduler {
189
202
  this.chain,
190
203
  this.logger,
191
204
  fork as ForkPostBellatrix, // State is of execution type
192
- fromHex(updatedHeadRoot),
205
+ fromHex(updatedHead.blockRoot),
193
206
  parentBlockHash,
194
207
  safeBlockHash,
195
208
  finalizedBlockHash,
196
- updatedPrepareState,
209
+ stateAfterParentPayload,
197
210
  feeRecipient
198
211
  );
199
212
  this.logger.verbose("PrepareNextSlotScheduler prepared new payload", {
@@ -203,21 +216,30 @@ export class PrepareNextSlotScheduler {
203
216
  });
204
217
  }
205
218
 
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
+ }
227
+ }
228
+
206
229
  this.computeStateHashTreeRoot(updatedPrepareState, isEpochTransition);
207
230
 
208
- // 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.
209
233
  if (
210
- this.chain.opts.emitPayloadAttributes === true &&
234
+ (feeRecipient || this.chain.opts.emitPayloadAttributes === true) &&
211
235
  this.chain.emitter.listenerCount(routes.events.EventType.payloadAttributes)
212
236
  ) {
213
237
  const data = getPayloadAttributesForSSE(fork as ForkPostBellatrix, this.chain, {
214
- prepareState: updatedPrepareState,
238
+ prepareState: stateAfterParentPayload,
215
239
  prepareSlot,
216
- parentBlockRoot: fromHex(headRoot),
240
+ parentBlockRoot: fromHex(updatedHead.blockRoot),
217
241
  parentBlockHash,
218
- // The likely consumers of this API are builders and will anyway ignore the
219
- // feeRecipient, so just pass zero hash for now till a real use case arises
220
- feeRecipient: "0x0000000000000000000000000000000000000000000000000000000000000000",
242
+ feeRecipient: feeRecipient ?? "0x0000000000000000000000000000000000000000",
221
243
  });
222
244
  this.chain.emitter.emit(routes.events.EventType.payloadAttributes, {data, version: fork});
223
245
  }
@@ -46,6 +46,7 @@ import {
46
46
  electra,
47
47
  fulu,
48
48
  gloas,
49
+ ssz,
49
50
  } from "@lodestar/types";
50
51
  import {Logger, byteArrayEquals, fromHex, sleep, toHex, toPubkeyHex, toRootHex} from "@lodestar/utils";
51
52
  import {ZERO_HASH_HEX} from "../../constants/index.js";
@@ -110,6 +111,7 @@ export type ProduceFullGloas = {
110
111
  executionRequests: electra.ExecutionRequests;
111
112
  blobsBundle: BlobsBundle<ForkPostGloas>;
112
113
  cells: fulu.Cell[][];
114
+ parentBlockRoot: Root;
113
115
  };
114
116
  export type ProduceFullFulu = {
115
117
  type: BlockType.Full;
@@ -213,9 +215,19 @@ export async function produceBlockBody<T extends BlockType>(
213
215
  });
214
216
 
215
217
  // Get execution payload from EL
216
- const parentBlockHash = this.forkChoice.shouldExtendPayload(toRootHex(parentBlockRoot))
217
- ? currentState.latestExecutionPayloadBid.blockHash
218
- : currentState.latestExecutionPayloadBid.parentBlockHash;
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
+ }
219
231
  const prepareRes = await prepareExecutionPayload(
220
232
  this,
221
233
  this.logger,
@@ -224,7 +236,7 @@ export async function produceBlockBody<T extends BlockType>(
224
236
  parentBlockHash,
225
237
  safeBlockHash,
226
238
  finalizedBlockHash ?? ZERO_HASH_HEX,
227
- currentState,
239
+ stateAfterParentPayload,
228
240
  feeRecipient
229
241
  );
230
242
 
@@ -269,6 +281,7 @@ export async function produceBlockBody<T extends BlockType>(
269
281
  value: 0,
270
282
  executionPayment: 0,
271
283
  blobKzgCommitments: blobsBundle.commitments,
284
+ executionRequestsRoot: ssz.electra.ExecutionRequests.hashTreeRoot(executionRequests),
272
285
  };
273
286
  const signedBid: gloas.SignedExecutionPayloadBid = {
274
287
  message: bid,
@@ -278,8 +291,19 @@ export async function produceBlockBody<T extends BlockType>(
278
291
  const commonBlockBody = await commonBlockBodyPromise;
279
292
  const gloasBody = Object.assign({}, commonBlockBody) as gloas.BeaconBlockBody;
280
293
  gloasBody.signedExecutionPayloadBid = signedBid;
281
- // TODO GLOAS: Get payload attestations from pool for previous slot
282
- 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
+ }
283
307
  blockBody = gloasBody as AssembledBodyType<T>;
284
308
 
285
309
  // Store execution payload data required to construct execution payload envelope later
@@ -288,6 +312,7 @@ export async function produceBlockBody<T extends BlockType>(
288
312
  gloasResult.executionRequests = executionRequests;
289
313
  gloasResult.blobsBundle = blobsBundle;
290
314
  gloasResult.cells = cells;
315
+ gloasResult.parentBlockRoot = fromHex(parentBlock.blockRoot);
291
316
 
292
317
  const fetchedTime = Date.now() / 1000 - computeTimeAtSlot(this.config, blockSlot, this.genesisTime);
293
318
  this.metrics?.blockPayload.payloadFetchedTime.observe({prepType}, fetchedTime);
@@ -615,6 +640,10 @@ export async function prepareExecutionPayload(
615
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}> {
@@ -712,6 +741,10 @@ export function getPayloadAttributesForSSE(
712
741
  parentBlockHash,
713
742
  feeRecipient,
714
743
  }: {
744
+ /**
745
+ * Post-gloas, when extending a full parent, callers must apply
746
+ * parent execution payload first (see `withParentPayloadApplied`).
747
+ */
715
748
  prepareState: IBeaconStateViewBellatrix;
716
749
  prepareSlot: Slot;
717
750
  parentBlockRoot: Root;
@@ -764,6 +797,10 @@ function preparePayloadAttributes(
764
797
  parentBlockHash,
765
798
  feeRecipient,
766
799
  }: {
800
+ /**
801
+ * Post-gloas, when extending a full parent, callers must apply
802
+ * parent execution payload first (see `withParentPayloadApplied`).
803
+ */
767
804
  prepareState: IBeaconStateViewBellatrix;
768
805
  prepareSlot: Slot;
769
806
  parentBlockRoot: Root;
@@ -786,13 +823,22 @@ function preparePayloadAttributes(
786
823
 
787
824
  if (isStatePostGloas(prepareState)) {
788
825
  const isExtendingPayload = byteArrayEquals(parentBlockHash, prepareState.latestExecutionPayloadBid.blockHash);
789
- // When the parent block is empty, state.payloadExpectedWithdrawals holds a batch
790
- // already deducted from CL balances but never credited on the EL (the envelope
791
- // was not delivered). The next payload must carry those same withdrawals to
792
- // restore CL/EL consistency, otherwise validators permanently lose that balance.
793
- (payloadAttributes as capella.SSEPayloadAttributes["payloadAttributes"]).withdrawals = isExtendingPayload
794
- ? prepareState.getExpectedWithdrawals().expectedWithdrawals
795
- : prepareState.payloadExpectedWithdrawals;
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
+ }
796
842
  } else {
797
843
  // withdrawals logic is now fork aware as it changes on electra fork post capella
798
844
  (payloadAttributes as capella.SSEPayloadAttributes["payloadAttributes"]).withdrawals =
@@ -804,6 +850,10 @@ function preparePayloadAttributes(
804
850
  (payloadAttributes as deneb.SSEPayloadAttributes["payloadAttributes"]).parentBeaconBlockRoot = parentBlockRoot;
805
851
  }
806
852
 
853
+ if (ForkSeq[fork] >= ForkSeq.gloas) {
854
+ (payloadAttributes as gloas.SSEPayloadAttributes["payloadAttributes"]).slotNumber = prepareSlot;
855
+ }
856
+
807
857
  return payloadAttributes;
808
858
  }
809
859
 
@@ -21,6 +21,7 @@ export enum RegenCaller {
21
21
  validateGossipAttestation = "validateGossipAttestation",
22
22
  validateGossipVoluntaryExit = "validateGossipVoluntaryExit",
23
23
  validateGossipExecutionPayloadBid = "validateGossipExecutionPayloadBid",
24
+ validateGossipProposerPreferences = "validateGossipProposerPreferences",
24
25
  onForkChoiceFinalized = "onForkChoiceFinalized",
25
26
  restApi = "restApi",
26
27
  }
@@ -1,7 +1,7 @@
1
1
  import {routes} from "@lodestar/api";
2
2
  import {IForkChoice, ProtoBlock} from "@lodestar/fork-choice";
3
3
  import {IBeaconStateView, computeEpochAtSlot} from "@lodestar/state-transition";
4
- import {BeaconBlock, Epoch, RootHex, Slot, isGloasBeaconBlock, phase0} from "@lodestar/types";
4
+ import {BeaconBlock, Epoch, RootHex, Slot, phase0} from "@lodestar/types";
5
5
  import {Logger, toRootHex} from "@lodestar/utils";
6
6
  import {Metrics} from "../../metrics/index.js";
7
7
  import {JobItemQueue} from "../../util/queue/index.js";
@@ -88,12 +88,7 @@ export class QueuedStateRegenerator implements IStateRegenerator {
88
88
  */
89
89
  getPreStateSync(block: BeaconBlock): IBeaconStateView | null {
90
90
  const parentRoot = toRootHex(block.parentRoot);
91
- const parentBlock = isGloasBeaconBlock(block)
92
- ? this.forkChoice.getBlockHexAndBlockHash(
93
- parentRoot,
94
- toRootHex(block.body.signedExecutionPayloadBid.message.parentBlockHash)
95
- )
96
- : this.forkChoice.getBlockHexDefaultStatus(parentRoot);
91
+ const parentBlock = this.forkChoice.getBlockHexDefaultStatus(parentRoot);
97
92
  if (!parentBlock) {
98
93
  throw new RegenError({
99
94
  code: RegenErrorCode.BLOCK_NOT_IN_FORKCHOICE,
@@ -9,7 +9,7 @@ import {
9
9
  computeEpochAtSlot,
10
10
  computeStartSlotAtEpoch,
11
11
  } from "@lodestar/state-transition";
12
- import {BeaconBlock, RootHex, SignedBeaconBlock, Slot, isGloasBeaconBlock} from "@lodestar/types";
12
+ import {BeaconBlock, RootHex, SignedBeaconBlock, Slot} from "@lodestar/types";
13
13
  import {Logger, fromHex, toRootHex} from "@lodestar/utils";
14
14
  import {IBeaconDb} from "../../db/index.js";
15
15
  import {Metrics} from "../../metrics/index.js";
@@ -57,12 +57,7 @@ export class StateRegenerator implements IStateRegeneratorInternal {
57
57
  regenCaller: RegenCaller
58
58
  ): Promise<IBeaconStateView> {
59
59
  const parentRoot = toRootHex(block.parentRoot);
60
- const parentBlock = isGloasBeaconBlock(block)
61
- ? this.modules.forkChoice.getBlockHexAndBlockHash(
62
- parentRoot,
63
- toRootHex(block.body.signedExecutionPayloadBid.message.parentBlockHash)
64
- )
65
- : this.modules.forkChoice.getBlockHexDefaultStatus(parentRoot);
60
+ const parentBlock = this.modules.forkChoice.getBlockHexDefaultStatus(parentRoot);
66
61
  if (!parentBlock) {
67
62
  throw new RegenError({
68
63
  code: RegenErrorCode.BLOCK_NOT_IN_FORKCHOICE,
@@ -5,3 +5,4 @@ export {SeenContributionAndProof} from "./seenCommitteeContribution.js";
5
5
  export {SeenExecutionPayloadBids} from "./seenExecutionPayloadBids.js";
6
6
  export {SeenBlockInput} from "./seenGossipBlockInput.js";
7
7
  export {PayloadEnvelopeInput, SeenPayloadEnvelopeInput} from "./seenPayloadEnvelopeInput.js";
8
+ export {SeenProposerPreferences} from "./seenProposerPreferences.js";
@@ -1,16 +1,22 @@
1
- import {CheckpointWithHex} from "@lodestar/fork-choice";
1
+ import {ChainForkConfig} from "@lodestar/config";
2
+ import {CheckpointWithHex, IForkChoice, ProtoBlock} from "@lodestar/fork-choice";
2
3
  import {computeStartSlotAtEpoch} from "@lodestar/state-transition";
3
4
  import {RootHex} from "@lodestar/types";
4
5
  import {Logger} from "@lodestar/utils";
5
6
  import {Metrics} from "../../metrics/metrics.js";
7
+ import {IClock} from "../../util/clock.js";
6
8
  import {SerializedCache} from "../../util/serializedCache.js";
7
- import {CreateFromBlockProps, PayloadEnvelopeInput} from "../blocks/payloadEnvelopeInput/index.js";
9
+ import {isDaOutOfRange} from "../blocks/blockInput/index.js";
10
+ import {CreateFromBidProps, CreateFromBlockProps, PayloadEnvelopeInput} from "../blocks/payloadEnvelopeInput/index.js";
8
11
  import {ChainEvent, ChainEventEmitter} from "../emitter.js";
9
12
 
10
13
  export type {PayloadEnvelopeInputState} from "../blocks/payloadEnvelopeInput/index.js";
11
14
  export {PayloadEnvelopeInput} from "../blocks/payloadEnvelopeInput/index.js";
12
15
 
13
16
  export type SeenPayloadEnvelopeInputModules = {
17
+ config: ChainForkConfig;
18
+ clock: IClock;
19
+ forkChoice: IForkChoice;
14
20
  chainEvents: ChainEventEmitter;
15
21
  signal: AbortSignal;
16
22
  serializedCache: SerializedCache;
@@ -21,10 +27,16 @@ export type SeenPayloadEnvelopeInputModules = {
21
27
  /**
22
28
  * Cache for tracking PayloadEnvelopeInput instances, keyed by beacon block root.
23
29
  *
24
- * Created during block import when a block is processed.
25
- * Pruned on finalization and after payload is written to DB.
30
+ * Created whenever we have a block because it needs block bid.
31
+ * Steady state (linear chain, healthy progression): the cache holds ~2 entries — the head
32
+ * (parent for next-slot production) and its parent (proposer-boost-reorg fallback). It can
33
+ * transiently hold more during forks, range-sync bursts, or when `prepareNextSlot` skips
34
+ * ticks; subsequent ticks settle it back.
26
35
  */
27
36
  export class SeenPayloadEnvelopeInput {
37
+ private readonly config: ChainForkConfig;
38
+ private readonly clock: IClock;
39
+ private readonly forkChoice: IForkChoice;
28
40
  private readonly chainEvents: ChainEventEmitter;
29
41
  private readonly signal: AbortSignal;
30
42
  private readonly serializedCache: SerializedCache;
@@ -32,7 +44,19 @@ export class SeenPayloadEnvelopeInput {
32
44
  private readonly logger?: Logger;
33
45
  private payloadInputs = new Map<RootHex, PayloadEnvelopeInput>();
34
46
 
35
- constructor({chainEvents, signal, serializedCache, metrics, logger}: SeenPayloadEnvelopeInputModules) {
47
+ constructor({
48
+ config,
49
+ clock,
50
+ forkChoice,
51
+ chainEvents,
52
+ signal,
53
+ serializedCache,
54
+ metrics,
55
+ logger,
56
+ }: SeenPayloadEnvelopeInputModules) {
57
+ this.config = config;
58
+ this.clock = clock;
59
+ this.forkChoice = forkChoice;
36
60
  this.chainEvents = chainEvents;
37
61
  this.signal = signal;
38
62
  this.serializedCache = serializedCache;
@@ -51,14 +75,13 @@ export class SeenPayloadEnvelopeInput {
51
75
  });
52
76
  }
53
77
 
54
- this.chainEvents.on(ChainEvent.forkChoiceFinalized, this.onFinalized);
78
+ this.chainEvents.on(ChainEvent.forkChoiceFinalized, this.pruneFinalized);
55
79
  this.signal.addEventListener("abort", () => {
56
- this.chainEvents.off(ChainEvent.forkChoiceFinalized, this.onFinalized);
80
+ this.chainEvents.off(ChainEvent.forkChoiceFinalized, this.pruneFinalized);
57
81
  });
58
82
  }
59
83
 
60
- private onFinalized = (checkpoint: CheckpointWithHex): void => {
61
- // Prune all entries with slot < finalized slot
84
+ private pruneFinalized = (checkpoint: CheckpointWithHex): void => {
62
85
  const finalizedSlot = computeStartSlotAtEpoch(checkpoint.epoch);
63
86
  let deletedCount = 0;
64
87
  for (const [, input] of this.payloadInputs) {
@@ -67,16 +90,53 @@ export class SeenPayloadEnvelopeInput {
67
90
  deletedCount++;
68
91
  }
69
92
  }
70
- this.logger?.debug("SeenPayloadEnvelopeInput.onFinalized deleted cached entries", {deletedCount});
93
+
94
+ this.logger?.debug("SeenPayloadEnvelopeInput.pruneFinalized deleted entries", {
95
+ finalizedSlot,
96
+ finalizedRoot: checkpoint.rootHex,
97
+ deletedCount,
98
+ });
71
99
  };
72
100
 
73
- add(props: CreateFromBlockProps): PayloadEnvelopeInput {
74
- if (this.payloadInputs.has(props.blockRootHex)) {
75
- throw new Error(`PayloadEnvelopeInput already exists for block ${props.blockRootHex}`);
101
+ add(props: Omit<CreateFromBlockProps, "daOutOfRange">): PayloadEnvelopeInput {
102
+ const existing = this.payloadInputs.get(props.blockRootHex);
103
+ if (existing !== undefined) {
104
+ this.logger?.verbose("SeenPayloadEnvelopeInput.add reused existing entry", {
105
+ slot: existing.slot,
106
+ root: props.blockRootHex,
107
+ });
108
+ return existing;
109
+ }
110
+ const daOutOfRange = isDaOutOfRange(this.config, props.forkName, props.block.message.slot, this.clock.currentEpoch);
111
+ const input = PayloadEnvelopeInput.createFromBlock({...props, daOutOfRange});
112
+ this.payloadInputs.set(props.blockRootHex, input);
113
+ this.metrics?.seenCache.payloadEnvelopeInput.created.inc();
114
+ this.logger?.verbose("SeenPayloadEnvelopeInput.add created new entry", {
115
+ slot: input.slot,
116
+ root: props.blockRootHex,
117
+ daOutOfRange,
118
+ });
119
+ return input;
120
+ }
121
+
122
+ /**
123
+ * Used at chain initialization to seed the anchor block's PayloadEnvelopeInput from
124
+ * `state.latestExecutionPayloadBid`.
125
+ */
126
+ addFromBid(props: Omit<CreateFromBidProps, "daOutOfRange">): PayloadEnvelopeInput {
127
+ const existing = this.payloadInputs.get(props.blockRootHex);
128
+ if (existing !== undefined) {
129
+ return existing;
76
130
  }
77
- const input = PayloadEnvelopeInput.createFromBlock(props);
131
+ const daOutOfRange = isDaOutOfRange(this.config, props.forkName, props.slot, this.clock.currentEpoch);
132
+ const input = PayloadEnvelopeInput.createFromBid({...props, daOutOfRange});
78
133
  this.payloadInputs.set(props.blockRootHex, input);
79
134
  this.metrics?.seenCache.payloadEnvelopeInput.created.inc();
135
+ this.logger?.verbose("SeenPayloadEnvelopeInput.addFromBid created new entry", {
136
+ slot: input.slot,
137
+ root: props.blockRootHex,
138
+ daOutOfRange,
139
+ });
80
140
  return input;
81
141
  }
82
142
 
@@ -88,17 +148,25 @@ export class SeenPayloadEnvelopeInput {
88
148
  return this.payloadInputs.get(blockRootHex)?.hasPayloadEnvelope() ?? false;
89
149
  }
90
150
 
91
- prune(blockRootHex: RootHex): void {
92
- const payloadInput = this.payloadInputs.get(blockRootHex);
93
- if (payloadInput) {
94
- this.evictPayloadInput(payloadInput);
95
- }
96
- }
97
-
98
151
  size(): number {
99
152
  return this.payloadInputs.size;
100
153
  }
101
154
 
155
+ pruneBelowParent(parentBlock: ProtoBlock): void {
156
+ for (const block of this.forkChoice.getAllAncestorBlocks(parentBlock.blockRoot, parentBlock.payloadStatus)) {
157
+ if (block.slot < parentBlock.slot) {
158
+ const input = this.payloadInputs.get(block.blockRoot);
159
+ if (input) {
160
+ this.evictPayloadInput(input);
161
+ this.logger?.verbose("SeenPayloadEnvelopeInput.pruneBelowParent deleted", {
162
+ slot: block.slot,
163
+ root: block.blockRoot,
164
+ });
165
+ }
166
+ }
167
+ }
168
+ }
169
+
102
170
  private evictPayloadInput(payloadInput: PayloadEnvelopeInput): void {
103
171
  this.serializedCache.delete(payloadInput.getSerializedCacheKeys());
104
172
  this.payloadInputs.delete(payloadInput.blockRootHex);
@@ -0,0 +1,32 @@
1
+ import {RootHex, Slot, ValidatorIndex} from "@lodestar/types";
2
+ import {MapDef} from "@lodestar/utils";
3
+
4
+ /**
5
+ * Tracks signed proposer preferences we've already seen per (dependent_root, proposal_slot, validator_index).
6
+ */
7
+ export class SeenProposerPreferences {
8
+ private readonly validatorByDependentRootBySlot = new MapDef<Slot, Map<RootHex, ValidatorIndex>>(
9
+ () => new Map<RootHex, ValidatorIndex>()
10
+ );
11
+
12
+ isKnown(dependentRoot: RootHex, proposalSlot: Slot, validatorIndex: ValidatorIndex): boolean {
13
+ return this.validatorByDependentRootBySlot.get(proposalSlot)?.get(dependentRoot) === validatorIndex;
14
+ }
15
+
16
+ add(dependentRoot: RootHex, proposalSlot: Slot, validatorIndex: ValidatorIndex): void {
17
+ this.validatorByDependentRootBySlot.getOrDefault(proposalSlot).set(dependentRoot, validatorIndex);
18
+ }
19
+
20
+ /**
21
+ * Entries are only load-bearing while `proposal_slot > current_slot`. Once the slot has
22
+ * passed the `[IGNORE] proposal_slot > current_slot` gossip rule takes over, so drop them
23
+ * on each slot tick.
24
+ */
25
+ prune(currentSlot: Slot): void {
26
+ for (const slot of this.validatorByDependentRootBySlot.keys()) {
27
+ if (slot < currentSlot) {
28
+ this.validatorByDependentRootBySlot.delete(slot);
29
+ }
30
+ }
31
+ }
32
+ }
@@ -103,6 +103,7 @@ export async function validateGossipBlock(
103
103
  if (chain.forkChoice.getBlockHexAndBlockHash(parentRoot, parentBlockHashHex) === null) {
104
104
  throw new BlockGossipError(GossipAction.IGNORE, {
105
105
  code: BlockErrorCode.PARENT_PAYLOAD_UNKNOWN,
106
+ parentRoot,
106
107
  parentBlockHash: parentBlockHashHex,
107
108
  });
108
109
  }
@@ -1,5 +1,6 @@
1
1
  import {PublicKey} from "@chainsafe/blst";
2
2
  import {
3
+ computeEpochAtSlot,
3
4
  createSingleSignatureSetFromComponents,
4
5
  getExecutionPayloadBidSigningRoot,
5
6
  isActiveBuilder,
@@ -47,9 +48,12 @@ async function validateExecutionPayloadBid(
47
48
  });
48
49
  }
49
50
 
50
- // [IGNORE] the `SignedProposerPreferences` where `preferences.proposal_slot`
51
- // is equal to `bid.slot` has been seen.
52
- // TODO GLOAS: Implement this along with proposer preference
51
+ // [IGNORE] A `SignedProposerPreferences` matching `bid.slot` and the bid's branch has been
52
+ // seen i.e. `proposal_slot == bid.slot` AND `dependent_root ==
53
+ // get_proposer_dependent_root(parent_state, compute_epoch_at_slot(bid.slot))`,
54
+ // where `parent_state` is the post-state of `bid.parent_block_root`.
55
+ // This is the message referenced as `proposer_preferences` in the following REJECT rules.
56
+ // TODO GLOAS: Implement once a ProposerPreferencesPool exists.
53
57
 
54
58
  // [REJECT] `bid.builder_index` is a valid/active builder index -- i.e.
55
59
  // `is_active_builder(state, bid.builder_index)` returns `True`.
@@ -70,11 +74,24 @@ async function validateExecutionPayloadBid(
70
74
  });
71
75
  }
72
76
 
73
- // [REJECT] `bid.fee_recipient` matches the `fee_recipient` from the proposer's
74
- // `SignedProposerPreferences` associated with `bid.slot`.
75
- // [REJECT] `bid.gas_limit` matches the `gas_limit` from the proposer's
76
- // `SignedProposerPreferences` associated with `bid.slot`.
77
- // TODO GLOAS: Implement this along with proposer preference
77
+ // [REJECT] `bid.fee_recipient == proposer_preferences.fee_recipient`.
78
+ // [REJECT] `bid.gas_limit == proposer_preferences.gas_limit`.
79
+ // Both compared against the matching `proposer_preferences` defined above (same branch
80
+ // via dependent_root, same proposal_slot).
81
+ // TODO GLOAS: Implement once a ProposerPreferencesPool exists.
82
+
83
+ // [REJECT] The length of KZG commitments is less than or equal to the limitation defined in the
84
+ // consensus layer -- i.e. validate that
85
+ // `len(bid.blob_kzg_commitments) <= get_blob_parameters(compute_epoch_at_slot(bid.slot)).max_blobs_per_block`.
86
+ const blobKzgCommitmentsLen = bid.blobKzgCommitments.length;
87
+ const maxBlobsPerBlock = chain.config.getMaxBlobsPerBlock(computeEpochAtSlot(bid.slot));
88
+ if (blobKzgCommitmentsLen > maxBlobsPerBlock) {
89
+ throw new ExecutionPayloadBidError(GossipAction.REJECT, {
90
+ code: ExecutionPayloadBidErrorCode.TOO_MANY_KZG_COMMITMENTS,
91
+ blobKzgCommitmentsLen,
92
+ commitmentLimit: maxBlobsPerBlock,
93
+ });
94
+ }
78
95
 
79
96
  // [IGNORE] this is the first signed bid seen with a valid signature from the given builder for this slot.
80
97
  if (chain.seenExecutionPayloadBids.isKnown(bid.slot, bid.builderIndex)) {