@lodestar/beacon-node 1.43.0-dev.433e692fd9 → 1.43.0-dev.4358217e12

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 (311) hide show
  1. package/lib/api/impl/beacon/blocks/index.js +7 -9
  2. package/lib/api/impl/beacon/blocks/index.js.map +1 -1
  3. package/lib/api/impl/beacon/state/utils.d.ts +2 -2
  4. package/lib/api/impl/beacon/state/utils.d.ts.map +1 -1
  5. package/lib/api/impl/beacon/state/utils.js.map +1 -1
  6. package/lib/api/impl/lodestar/index.js +1 -1
  7. package/lib/api/impl/lodestar/index.js.map +1 -1
  8. package/lib/api/impl/validator/index.d.ts.map +1 -1
  9. package/lib/api/impl/validator/index.js +0 -4
  10. package/lib/api/impl/validator/index.js.map +1 -1
  11. package/lib/chain/GetBlobsTracker.d.ts +1 -1
  12. package/lib/chain/GetBlobsTracker.d.ts.map +1 -1
  13. package/lib/chain/GetBlobsTracker.js +1 -2
  14. package/lib/chain/GetBlobsTracker.js.map +1 -1
  15. package/lib/chain/archiveStore/archiveStore.d.ts.map +1 -1
  16. package/lib/chain/archiveStore/archiveStore.js.map +1 -1
  17. package/lib/chain/archiveStore/interface.d.ts +4 -4
  18. package/lib/chain/archiveStore/interface.d.ts.map +1 -1
  19. package/lib/chain/archiveStore/strategies/frequencyStateArchiveStrategy.d.ts +4 -4
  20. package/lib/chain/archiveStore/strategies/frequencyStateArchiveStrategy.d.ts.map +1 -1
  21. package/lib/chain/archiveStore/strategies/frequencyStateArchiveStrategy.js.map +1 -1
  22. package/lib/chain/archiveStore/utils/archiveBlocks.d.ts +2 -2
  23. package/lib/chain/archiveStore/utils/archiveBlocks.d.ts.map +1 -1
  24. package/lib/chain/archiveStore/utils/archiveBlocks.js +110 -58
  25. package/lib/chain/archiveStore/utils/archiveBlocks.js.map +1 -1
  26. package/lib/chain/blocks/importBlock.d.ts.map +1 -1
  27. package/lib/chain/blocks/importBlock.js +9 -10
  28. package/lib/chain/blocks/importBlock.js.map +1 -1
  29. package/lib/chain/blocks/importExecutionPayload.d.ts +26 -13
  30. package/lib/chain/blocks/importExecutionPayload.d.ts.map +1 -1
  31. package/lib/chain/blocks/importExecutionPayload.js +86 -84
  32. package/lib/chain/blocks/importExecutionPayload.js.map +1 -1
  33. package/lib/chain/blocks/index.d.ts +5 -3
  34. package/lib/chain/blocks/index.d.ts.map +1 -1
  35. package/lib/chain/blocks/index.js +28 -10
  36. package/lib/chain/blocks/index.js.map +1 -1
  37. package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.d.ts +3 -0
  38. package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.d.ts.map +1 -1
  39. package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.js +20 -0
  40. package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.js.map +1 -1
  41. package/lib/chain/blocks/payloadEnvelopeProcessor.d.ts +5 -0
  42. package/lib/chain/blocks/payloadEnvelopeProcessor.d.ts.map +1 -1
  43. package/lib/chain/blocks/payloadEnvelopeProcessor.js +7 -5
  44. package/lib/chain/blocks/payloadEnvelopeProcessor.js.map +1 -1
  45. package/lib/chain/blocks/types.d.ts +14 -20
  46. package/lib/chain/blocks/types.d.ts.map +1 -1
  47. package/lib/chain/blocks/utils/chainSegment.d.ts +23 -2
  48. package/lib/chain/blocks/utils/chainSegment.d.ts.map +1 -1
  49. package/lib/chain/blocks/utils/chainSegment.js +81 -12
  50. package/lib/chain/blocks/utils/chainSegment.js.map +1 -1
  51. package/lib/chain/blocks/verifyBlock.d.ts +3 -2
  52. package/lib/chain/blocks/verifyBlock.d.ts.map +1 -1
  53. package/lib/chain/blocks/verifyBlock.js +30 -5
  54. package/lib/chain/blocks/verifyBlock.js.map +1 -1
  55. package/lib/chain/blocks/verifyBlocksSanityChecks.d.ts.map +1 -1
  56. package/lib/chain/blocks/verifyBlocksSanityChecks.js +15 -4
  57. package/lib/chain/blocks/verifyBlocksSanityChecks.js.map +1 -1
  58. package/lib/chain/blocks/verifyExecutionPayloadEnvelope.d.ts +24 -0
  59. package/lib/chain/blocks/verifyExecutionPayloadEnvelope.d.ts.map +1 -0
  60. package/lib/chain/blocks/verifyExecutionPayloadEnvelope.js +76 -0
  61. package/lib/chain/blocks/verifyExecutionPayloadEnvelope.js.map +1 -0
  62. package/lib/chain/blocks/verifyPayloadsDataAvailability.d.ts +14 -0
  63. package/lib/chain/blocks/verifyPayloadsDataAvailability.d.ts.map +1 -0
  64. package/lib/chain/blocks/verifyPayloadsDataAvailability.js +25 -0
  65. package/lib/chain/blocks/verifyPayloadsDataAvailability.js.map +1 -0
  66. package/lib/chain/blocks/writePayloadEnvelopeInputToDb.d.ts +1 -1
  67. package/lib/chain/blocks/writePayloadEnvelopeInputToDb.d.ts.map +1 -1
  68. package/lib/chain/blocks/writePayloadEnvelopeInputToDb.js +2 -11
  69. package/lib/chain/blocks/writePayloadEnvelopeInputToDb.js.map +1 -1
  70. package/lib/chain/chain.d.ts +8 -6
  71. package/lib/chain/chain.d.ts.map +1 -1
  72. package/lib/chain/chain.js +19 -6
  73. package/lib/chain/chain.js.map +1 -1
  74. package/lib/chain/emitter.d.ts +16 -4
  75. package/lib/chain/emitter.d.ts.map +1 -1
  76. package/lib/chain/emitter.js +5 -0
  77. package/lib/chain/emitter.js.map +1 -1
  78. package/lib/chain/errors/blockError.d.ts +8 -1
  79. package/lib/chain/errors/blockError.d.ts.map +1 -1
  80. package/lib/chain/errors/blockError.js +2 -0
  81. package/lib/chain/errors/blockError.js.map +1 -1
  82. package/lib/chain/errors/executionPayloadBid.d.ts +5 -0
  83. package/lib/chain/errors/executionPayloadBid.d.ts.map +1 -1
  84. package/lib/chain/errors/executionPayloadBid.js +1 -0
  85. package/lib/chain/errors/executionPayloadBid.js.map +1 -1
  86. package/lib/chain/errors/executionPayloadEnvelope.d.ts +5 -0
  87. package/lib/chain/errors/executionPayloadEnvelope.d.ts.map +1 -1
  88. package/lib/chain/errors/executionPayloadEnvelope.js +1 -0
  89. package/lib/chain/errors/executionPayloadEnvelope.js.map +1 -1
  90. package/lib/chain/errors/index.d.ts +1 -0
  91. package/lib/chain/errors/index.d.ts.map +1 -1
  92. package/lib/chain/errors/index.js +1 -0
  93. package/lib/chain/errors/index.js.map +1 -1
  94. package/lib/chain/errors/proposerPreferences.d.ts +33 -0
  95. package/lib/chain/errors/proposerPreferences.d.ts.map +1 -0
  96. package/lib/chain/errors/proposerPreferences.js +13 -0
  97. package/lib/chain/errors/proposerPreferences.js.map +1 -0
  98. package/lib/chain/forkChoice/index.d.ts.map +1 -1
  99. package/lib/chain/forkChoice/index.js +11 -19
  100. package/lib/chain/forkChoice/index.js.map +1 -1
  101. package/lib/chain/interface.d.ts +7 -5
  102. package/lib/chain/interface.d.ts.map +1 -1
  103. package/lib/chain/interface.js.map +1 -1
  104. package/lib/chain/opPools/payloadAttestationPool.d.ts +2 -2
  105. package/lib/chain/opPools/payloadAttestationPool.d.ts.map +1 -1
  106. package/lib/chain/opPools/payloadAttestationPool.js +4 -4
  107. package/lib/chain/opPools/payloadAttestationPool.js.map +1 -1
  108. package/lib/chain/prepareNextSlot.d.ts.map +1 -1
  109. package/lib/chain/prepareNextSlot.js +46 -16
  110. package/lib/chain/prepareNextSlot.js.map +1 -1
  111. package/lib/chain/produceBlock/produceBlockBody.d.ts +4 -2
  112. package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
  113. package/lib/chain/produceBlock/produceBlockBody.js +56 -26
  114. package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
  115. package/lib/chain/regen/interface.d.ts +1 -0
  116. package/lib/chain/regen/interface.d.ts.map +1 -1
  117. package/lib/chain/regen/interface.js +1 -0
  118. package/lib/chain/regen/interface.js.map +1 -1
  119. package/lib/chain/seenCache/index.d.ts +1 -0
  120. package/lib/chain/seenCache/index.d.ts.map +1 -1
  121. package/lib/chain/seenCache/index.js +1 -0
  122. package/lib/chain/seenCache/index.js.map +1 -1
  123. package/lib/chain/seenCache/seenPayloadEnvelopeInput.d.ts +11 -4
  124. package/lib/chain/seenCache/seenPayloadEnvelopeInput.d.ts.map +1 -1
  125. package/lib/chain/seenCache/seenPayloadEnvelopeInput.js +20 -18
  126. package/lib/chain/seenCache/seenPayloadEnvelopeInput.js.map +1 -1
  127. package/lib/chain/seenCache/seenProposerPreferences.d.ts +15 -0
  128. package/lib/chain/seenCache/seenProposerPreferences.d.ts.map +1 -0
  129. package/lib/chain/seenCache/seenProposerPreferences.js +25 -0
  130. package/lib/chain/seenCache/seenProposerPreferences.js.map +1 -0
  131. package/lib/chain/stateCache/persistentCheckpointsCache.d.ts.map +1 -1
  132. package/lib/chain/stateCache/persistentCheckpointsCache.js +4 -1
  133. package/lib/chain/stateCache/persistentCheckpointsCache.js.map +1 -1
  134. package/lib/chain/validation/block.d.ts.map +1 -1
  135. package/lib/chain/validation/block.js +1 -0
  136. package/lib/chain/validation/block.js.map +1 -1
  137. package/lib/chain/validation/executionPayloadBid.d.ts.map +1 -1
  138. package/lib/chain/validation/executionPayloadBid.js +13 -1
  139. package/lib/chain/validation/executionPayloadBid.js.map +1 -1
  140. package/lib/chain/validation/executionPayloadEnvelope.d.ts.map +1 -1
  141. package/lib/chain/validation/executionPayloadEnvelope.js +19 -9
  142. package/lib/chain/validation/executionPayloadEnvelope.js.map +1 -1
  143. package/lib/chain/validation/payloadAttestationMessage.d.ts.map +1 -1
  144. package/lib/chain/validation/payloadAttestationMessage.js +4 -3
  145. package/lib/chain/validation/payloadAttestationMessage.js.map +1 -1
  146. package/lib/chain/validation/proposerPreferences.d.ts +8 -0
  147. package/lib/chain/validation/proposerPreferences.d.ts.map +1 -0
  148. package/lib/chain/validation/proposerPreferences.js +69 -0
  149. package/lib/chain/validation/proposerPreferences.js.map +1 -0
  150. package/lib/db/repositories/executionPayloadEnvelopeArchive.js +1 -1
  151. package/lib/db/repositories/executionPayloadEnvelopeArchive.js.map +1 -1
  152. package/lib/execution/engine/http.d.ts.map +1 -1
  153. package/lib/execution/engine/http.js +21 -14
  154. package/lib/execution/engine/http.js.map +1 -1
  155. package/lib/execution/engine/interface.d.ts +1 -0
  156. package/lib/execution/engine/interface.d.ts.map +1 -1
  157. package/lib/execution/engine/mock.d.ts.map +1 -1
  158. package/lib/execution/engine/mock.js +6 -0
  159. package/lib/execution/engine/mock.js.map +1 -1
  160. package/lib/execution/engine/types.d.ts +20 -0
  161. package/lib/execution/engine/types.d.ts.map +1 -1
  162. package/lib/execution/engine/types.js +18 -0
  163. package/lib/execution/engine/types.js.map +1 -1
  164. package/lib/metrics/metrics/lodestar.d.ts +1 -0
  165. package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
  166. package/lib/metrics/metrics/lodestar.js +4 -0
  167. package/lib/metrics/metrics/lodestar.js.map +1 -1
  168. package/lib/network/gossip/interface.d.ts +7 -1
  169. package/lib/network/gossip/interface.d.ts.map +1 -1
  170. package/lib/network/gossip/interface.js +1 -0
  171. package/lib/network/gossip/interface.js.map +1 -1
  172. package/lib/network/gossip/scoringParameters.d.ts.map +1 -1
  173. package/lib/network/gossip/scoringParameters.js +12 -1
  174. package/lib/network/gossip/scoringParameters.js.map +1 -1
  175. package/lib/network/gossip/topic.d.ts +11 -2
  176. package/lib/network/gossip/topic.d.ts.map +1 -1
  177. package/lib/network/gossip/topic.js +6 -0
  178. package/lib/network/gossip/topic.js.map +1 -1
  179. package/lib/network/network.js +1 -1
  180. package/lib/network/network.js.map +1 -1
  181. package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
  182. package/lib/network/processor/gossipHandlers.js +32 -12
  183. package/lib/network/processor/gossipHandlers.js.map +1 -1
  184. package/lib/network/processor/gossipQueues/index.d.ts.map +1 -1
  185. package/lib/network/processor/gossipQueues/index.js +5 -0
  186. package/lib/network/processor/gossipQueues/index.js.map +1 -1
  187. package/lib/network/processor/index.d.ts.map +1 -1
  188. package/lib/network/processor/index.js +1 -0
  189. package/lib/network/processor/index.js.map +1 -1
  190. package/lib/network/reqresp/handlers/beaconBlocksByRange.d.ts.map +1 -1
  191. package/lib/network/reqresp/handlers/beaconBlocksByRange.js +14 -6
  192. package/lib/network/reqresp/handlers/beaconBlocksByRange.js.map +1 -1
  193. package/lib/network/reqresp/handlers/blobSidecarsByRange.d.ts.map +1 -1
  194. package/lib/network/reqresp/handlers/blobSidecarsByRange.js +11 -5
  195. package/lib/network/reqresp/handlers/blobSidecarsByRange.js.map +1 -1
  196. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.d.ts.map +1 -1
  197. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js +17 -5
  198. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js.map +1 -1
  199. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.d.ts.map +1 -1
  200. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.js +7 -4
  201. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.js.map +1 -1
  202. package/lib/node/nodejs.d.ts.map +1 -1
  203. package/lib/node/nodejs.js +4 -2
  204. package/lib/node/nodejs.js.map +1 -1
  205. package/lib/node/notifier.js +7 -1
  206. package/lib/node/notifier.js.map +1 -1
  207. package/lib/sync/range/batch.d.ts +12 -2
  208. package/lib/sync/range/batch.d.ts.map +1 -1
  209. package/lib/sync/range/batch.js +56 -30
  210. package/lib/sync/range/batch.js.map +1 -1
  211. package/lib/sync/range/chain.d.ts +6 -2
  212. package/lib/sync/range/chain.d.ts.map +1 -1
  213. package/lib/sync/range/chain.js +4 -3
  214. package/lib/sync/range/chain.js.map +1 -1
  215. package/lib/sync/range/range.d.ts.map +1 -1
  216. package/lib/sync/range/range.js +17 -6
  217. package/lib/sync/range/range.js.map +1 -1
  218. package/lib/sync/types.d.ts +34 -0
  219. package/lib/sync/types.d.ts.map +1 -1
  220. package/lib/sync/types.js +34 -0
  221. package/lib/sync/types.js.map +1 -1
  222. package/lib/sync/unknownBlock.d.ts +24 -1
  223. package/lib/sync/unknownBlock.d.ts.map +1 -1
  224. package/lib/sync/unknownBlock.js +649 -53
  225. package/lib/sync/unknownBlock.js.map +1 -1
  226. package/lib/sync/utils/downloadByRange.d.ts +46 -10
  227. package/lib/sync/utils/downloadByRange.d.ts.map +1 -1
  228. package/lib/sync/utils/downloadByRange.js +147 -24
  229. package/lib/sync/utils/downloadByRange.js.map +1 -1
  230. package/lib/sync/utils/downloadByRoot.d.ts.map +1 -1
  231. package/lib/sync/utils/downloadByRoot.js +6 -2
  232. package/lib/sync/utils/downloadByRoot.js.map +1 -1
  233. package/lib/sync/utils/pendingBlocksTree.d.ts +0 -1
  234. package/lib/sync/utils/pendingBlocksTree.d.ts.map +1 -1
  235. package/lib/sync/utils/pendingBlocksTree.js +0 -9
  236. package/lib/sync/utils/pendingBlocksTree.js.map +1 -1
  237. package/lib/util/sszBytes.d.ts.map +1 -1
  238. package/lib/util/sszBytes.js +16 -3
  239. package/lib/util/sszBytes.js.map +1 -1
  240. package/package.json +17 -16
  241. package/src/api/impl/beacon/blocks/index.ts +9 -9
  242. package/src/api/impl/beacon/state/utils.ts +2 -2
  243. package/src/api/impl/lodestar/index.ts +1 -1
  244. package/src/api/impl/validator/index.ts +0 -4
  245. package/src/chain/GetBlobsTracker.ts +1 -2
  246. package/src/chain/archiveStore/archiveStore.ts +5 -5
  247. package/src/chain/archiveStore/interface.ts +4 -4
  248. package/src/chain/archiveStore/strategies/frequencyStateArchiveStrategy.ts +4 -4
  249. package/src/chain/archiveStore/utils/archiveBlocks.ts +153 -94
  250. package/src/chain/blocks/importBlock.ts +7 -13
  251. package/src/chain/blocks/importExecutionPayload.ts +106 -103
  252. package/src/chain/blocks/index.ts +44 -13
  253. package/src/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.ts +27 -0
  254. package/src/chain/blocks/payloadEnvelopeProcessor.ts +7 -6
  255. package/src/chain/blocks/types.ts +14 -25
  256. package/src/chain/blocks/utils/chainSegment.ts +106 -17
  257. package/src/chain/blocks/verifyBlock.ts +35 -6
  258. package/src/chain/blocks/verifyBlocksSanityChecks.ts +16 -7
  259. package/src/chain/blocks/verifyExecutionPayloadEnvelope.ts +129 -0
  260. package/src/chain/blocks/verifyPayloadsDataAvailability.ts +38 -0
  261. package/src/chain/blocks/writePayloadEnvelopeInputToDb.ts +9 -18
  262. package/src/chain/chain.ts +36 -19
  263. package/src/chain/emitter.ts +15 -3
  264. package/src/chain/errors/blockError.ts +4 -1
  265. package/src/chain/errors/executionPayloadBid.ts +6 -0
  266. package/src/chain/errors/executionPayloadEnvelope.ts +6 -0
  267. package/src/chain/errors/index.ts +1 -0
  268. package/src/chain/errors/proposerPreferences.ts +39 -0
  269. package/src/chain/forkChoice/index.ts +8 -24
  270. package/src/chain/interface.ts +11 -3
  271. package/src/chain/opPools/payloadAttestationPool.ts +4 -8
  272. package/src/chain/prepareNextSlot.ts +60 -17
  273. package/src/chain/produceBlock/produceBlockBody.ts +77 -23
  274. package/src/chain/regen/interface.ts +1 -0
  275. package/src/chain/seenCache/index.ts +1 -0
  276. package/src/chain/seenCache/seenPayloadEnvelopeInput.ts +22 -20
  277. package/src/chain/seenCache/seenProposerPreferences.ts +29 -0
  278. package/src/chain/stateCache/persistentCheckpointsCache.ts +4 -1
  279. package/src/chain/validation/block.ts +1 -0
  280. package/src/chain/validation/executionPayloadBid.ts +14 -0
  281. package/src/chain/validation/executionPayloadEnvelope.ts +20 -10
  282. package/src/chain/validation/payloadAttestationMessage.ts +5 -3
  283. package/src/chain/validation/proposerPreferences.ts +91 -0
  284. package/src/db/repositories/executionPayloadEnvelopeArchive.ts +1 -1
  285. package/src/execution/engine/http.ts +21 -14
  286. package/src/execution/engine/interface.ts +1 -0
  287. package/src/execution/engine/mock.ts +8 -1
  288. package/src/execution/engine/types.ts +41 -0
  289. package/src/metrics/metrics/lodestar.ts +4 -0
  290. package/src/network/gossip/interface.ts +6 -0
  291. package/src/network/gossip/scoringParameters.ts +14 -1
  292. package/src/network/gossip/topic.ts +6 -0
  293. package/src/network/network.ts +1 -1
  294. package/src/network/processor/gossipHandlers.ts +41 -16
  295. package/src/network/processor/gossipQueues/index.ts +5 -0
  296. package/src/network/processor/index.ts +1 -0
  297. package/src/network/reqresp/handlers/beaconBlocksByRange.ts +14 -6
  298. package/src/network/reqresp/handlers/blobSidecarsByRange.ts +11 -5
  299. package/src/network/reqresp/handlers/dataColumnSidecarsByRange.ts +17 -5
  300. package/src/network/reqresp/handlers/executionPayloadEnvelopesByRange.ts +7 -4
  301. package/src/node/nodejs.ts +4 -2
  302. package/src/node/notifier.ts +8 -1
  303. package/src/sync/range/batch.ts +90 -35
  304. package/src/sync/range/chain.ts +13 -5
  305. package/src/sync/range/range.ts +18 -6
  306. package/src/sync/types.ts +72 -0
  307. package/src/sync/unknownBlock.ts +810 -57
  308. package/src/sync/utils/downloadByRange.ts +256 -39
  309. package/src/sync/utils/downloadByRoot.ts +12 -2
  310. package/src/sync/utils/pendingBlocksTree.ts +0 -15
  311. package/src/util/sszBytes.ts +21 -3
@@ -1,12 +1,13 @@
1
1
  import {EventEmitter} from "node:events";
2
2
  import {StrictEventEmitter} from "strict-event-emitter-types";
3
3
  import {routes} from "@lodestar/api";
4
- import {CheckpointWithPayloadStatus} from "@lodestar/fork-choice";
4
+ import {CheckpointWithHex} from "@lodestar/fork-choice";
5
5
  import {IBeaconStateView} from "@lodestar/state-transition";
6
6
  import {DataColumnSidecar, RootHex, deneb, phase0} from "@lodestar/types";
7
7
  import {SignedExecutionPayloadEnvelope} from "@lodestar/types/gloas";
8
8
  import {PeerIdStr} from "../util/peerId.js";
9
9
  import {BlockInputSource, IBlockInput} from "./blocks/blockInput/types.js";
10
+ import {PayloadEnvelopeInput} from "./blocks/payloadEnvelopeInput/payloadEnvelopeInput.js";
10
11
 
11
12
  /**
12
13
  * Important chain events that occur during normal chain operation.
@@ -76,6 +77,11 @@ export enum ChainEvent {
76
77
  * cut-off window passes for waiting on gossip
77
78
  */
78
79
  incompleteBlockInput = "incompleteBlockInput",
80
+ /**
81
+ * Post-gloas: trigger BlockInputSync for payload envelopes whose envelope and/or sampled columns are partially
82
+ * received via gossip but are not complete by time the cut-off window passes for waiting on gossip
83
+ */
84
+ incompletePayloadEnvelope = "incompletePayloadEnvelope",
79
85
  }
80
86
 
81
87
  export type HeadEventData = routes.events.EventData[routes.events.EventType.head];
@@ -93,14 +99,19 @@ export type ChainEventData = {
93
99
  };
94
100
  [ChainEvent.unknownBlockRoot]: {rootHex: RootHex; peer?: PeerIdStr; source: BlockInputSource};
95
101
  [ChainEvent.incompleteBlockInput]: {blockInput: IBlockInput; peer: PeerIdStr; source: BlockInputSource};
102
+ [ChainEvent.incompletePayloadEnvelope]: {
103
+ payloadInput: PayloadEnvelopeInput;
104
+ peer: PeerIdStr;
105
+ source: BlockInputSource;
106
+ };
96
107
  [ChainEvent.unknownEnvelopeBlockRoot]: {rootHex: RootHex; peer?: PeerIdStr; source: BlockInputSource};
97
108
  };
98
109
 
99
110
  export type IChainEvents = ApiEvents & {
100
111
  [ChainEvent.checkpoint]: (checkpoint: phase0.Checkpoint, state: IBeaconStateView) => void;
101
112
 
102
- [ChainEvent.forkChoiceJustified]: (checkpoint: CheckpointWithPayloadStatus) => void;
103
- [ChainEvent.forkChoiceFinalized]: (checkpoint: CheckpointWithPayloadStatus) => void;
113
+ [ChainEvent.forkChoiceJustified]: (checkpoint: CheckpointWithHex) => void;
114
+ [ChainEvent.forkChoiceFinalized]: (checkpoint: CheckpointWithHex) => void;
104
115
 
105
116
  [ChainEvent.updateTargetCustodyGroupCount]: (targetGroupCount: number) => void;
106
117
 
@@ -116,6 +127,7 @@ export type IChainEvents = ApiEvents & {
116
127
  [ChainEvent.envelopeUnknownBlock]: (data: ChainEventData[ChainEvent.envelopeUnknownBlock]) => void;
117
128
  [ChainEvent.unknownBlockRoot]: (data: ChainEventData[ChainEvent.unknownBlockRoot]) => void;
118
129
  [ChainEvent.incompleteBlockInput]: (data: ChainEventData[ChainEvent.incompleteBlockInput]) => void;
130
+ [ChainEvent.incompletePayloadEnvelope]: (data: ChainEventData[ChainEvent.incompletePayloadEnvelope]) => void;
119
131
  [ChainEvent.unknownEnvelopeBlockRoot]: (data: ChainEventData[ChainEvent.unknownEnvelopeBlockRoot]) => void;
120
132
  };
121
133
 
@@ -74,6 +74,8 @@ export enum BlockErrorCode {
74
74
  PARENT_EXECUTION_INVALID = "BLOCK_ERROR_PARENT_EXECUTION_INVALID",
75
75
  /** The block's parent execution payload (defined by bid.parent_block_hash) has not been seen */
76
76
  PARENT_PAYLOAD_UNKNOWN = "BLOCK_ERROR_PARENT_PAYLOAD_UNKNOWN",
77
+ /** An execution payload envelope in the chain segment references a block root that does not match its slot's block */
78
+ ENVELOPE_BLOCK_ROOT_MISMATCH = "BLOCK_ERROR_ENVELOPE_BLOCK_ROOT_MISMATCH",
77
79
  }
78
80
 
79
81
  type ExecutionErrorStatus = Exclude<
@@ -107,6 +109,7 @@ export type BlockErrorType =
107
109
  | {code: BlockErrorCode.NOT_LATER_THAN_PARENT; parentSlot: Slot; slot: Slot}
108
110
  | {code: BlockErrorCode.NON_LINEAR_PARENT_ROOTS}
109
111
  | {code: BlockErrorCode.NON_LINEAR_SLOTS}
112
+ | {code: BlockErrorCode.ENVELOPE_BLOCK_ROOT_MISMATCH; envelopeBlockRoot: RootHex; blockRoot: RootHex}
110
113
  | {code: BlockErrorCode.PER_BLOCK_PROCESSING_ERROR; error: Error}
111
114
  | {code: BlockErrorCode.BEACON_CHAIN_ERROR; error: Error}
112
115
  | {code: BlockErrorCode.KNOWN_BAD_BLOCK}
@@ -120,7 +123,7 @@ export type BlockErrorType =
120
123
  | {code: BlockErrorCode.TOO_MANY_KZG_COMMITMENTS; blobKzgCommitmentsLen: number; commitmentLimit: number}
121
124
  | {code: BlockErrorCode.BID_PARENT_ROOT_MISMATCH; bidParentRoot: RootHex; blockParentRoot: RootHex}
122
125
  | {code: BlockErrorCode.PARENT_EXECUTION_INVALID; parentRoot: RootHex}
123
- | {code: BlockErrorCode.PARENT_PAYLOAD_UNKNOWN; parentBlockHash: RootHex};
126
+ | {code: BlockErrorCode.PARENT_PAYLOAD_UNKNOWN; parentRoot: RootHex; parentBlockHash: RootHex};
124
127
 
125
128
  export class BlockGossipError extends GossipActionError<BlockErrorType> {}
126
129
 
@@ -7,6 +7,7 @@ export enum ExecutionPayloadBidErrorCode {
7
7
  BID_ALREADY_KNOWN = "EXECUTION_PAYLOAD_BID_ERROR_BID_ALREADY_KNOWN",
8
8
  BID_TOO_LOW = "EXECUTION_PAYLOAD_BID_ERROR_BID_TOO_LOW",
9
9
  BID_TOO_HIGH = "EXECUTION_PAYLOAD_BID_ERROR_BID_TOO_HIGH",
10
+ TOO_MANY_KZG_COMMITMENTS = "EXECUTION_PAYLOAD_BID_ERROR_TOO_MANY_KZG_COMMITMENTS",
10
11
  UNKNOWN_BLOCK_ROOT = "EXECUTION_PAYLOAD_BID_ERROR_UNKNOWN_BLOCK_ROOT",
11
12
  INVALID_SLOT = "EXECUTION_PAYLOAD_BID_ERROR_INVALID_SLOT",
12
13
  INVALID_SIGNATURE = "EXECUTION_PAYLOAD_BID_ERROR_INVALID_SIGNATURE",
@@ -28,6 +29,11 @@ export type ExecutionPayloadBidErrorType =
28
29
  }
29
30
  | {code: ExecutionPayloadBidErrorCode.BID_TOO_LOW; bidValue: number; currentHighestBid: number}
30
31
  | {code: ExecutionPayloadBidErrorCode.BID_TOO_HIGH; bidValue: number; builderBalance: number}
32
+ | {
33
+ code: ExecutionPayloadBidErrorCode.TOO_MANY_KZG_COMMITMENTS;
34
+ blobKzgCommitmentsLen: number;
35
+ commitmentLimit: number;
36
+ }
31
37
  | {code: ExecutionPayloadBidErrorCode.UNKNOWN_BLOCK_ROOT; parentBlockRoot: RootHex}
32
38
  | {code: ExecutionPayloadBidErrorCode.INVALID_SLOT; builderIndex: BuilderIndex; slot: Slot}
33
39
  | {code: ExecutionPayloadBidErrorCode.INVALID_SIGNATURE; builderIndex: BuilderIndex; slot: Slot};
@@ -11,6 +11,7 @@ export enum ExecutionPayloadEnvelopeErrorCode {
11
11
  SLOT_MISMATCH = "EXECUTION_PAYLOAD_ENVELOPE_ERROR_SLOT_MISMATCH",
12
12
  BUILDER_INDEX_MISMATCH = "EXECUTION_PAYLOAD_ENVELOPE_ERROR_BUILDER_INDEX_MISMATCH",
13
13
  BLOCK_HASH_MISMATCH = "EXECUTION_PAYLOAD_ENVELOPE_ERROR_BLOCK_HASH_MISMATCH",
14
+ EXECUTION_REQUESTS_ROOT_MISMATCH = "EXECUTION_PAYLOAD_ENVELOPE_ERROR_EXECUTION_REQUESTS_ROOT_MISMATCH",
14
15
  INVALID_SIGNATURE = "EXECUTION_PAYLOAD_ENVELOPE_ERROR_INVALID_SIGNATURE",
15
16
  PAYLOAD_ENVELOPE_INPUT_MISSING = "EXECUTION_PAYLOAD_ENVELOPE_ERROR_PAYLOAD_ENVELOPE_INPUT_MISSING",
16
17
  }
@@ -36,6 +37,11 @@ export type ExecutionPayloadEnvelopeErrorType =
36
37
  envelopeBlockHash: RootHex;
37
38
  bidBlockHash: RootHex | null;
38
39
  }
40
+ | {
41
+ code: ExecutionPayloadEnvelopeErrorCode.EXECUTION_REQUESTS_ROOT_MISMATCH;
42
+ envelopeRequestsRoot: RootHex;
43
+ bidRequestsRoot: RootHex;
44
+ }
39
45
  | {code: ExecutionPayloadEnvelopeErrorCode.INVALID_SIGNATURE}
40
46
  | {code: ExecutionPayloadEnvelopeErrorCode.PAYLOAD_ENVELOPE_INPUT_MISSING; blockRoot: RootHex};
41
47
 
@@ -8,6 +8,7 @@ export * from "./executionPayloadBid.js";
8
8
  export * from "./executionPayloadEnvelope.js";
9
9
  export * from "./gossipValidation.js";
10
10
  export * from "./payloadAttestation.js";
11
+ export * from "./proposerPreferences.js";
11
12
  export * from "./proposerSlashingError.js";
12
13
  export * from "./syncCommitteeError.js";
13
14
  export * from "./voluntaryExitError.js";
@@ -0,0 +1,39 @@
1
+ import {Slot, ValidatorIndex} from "@lodestar/types";
2
+ import {GossipActionError} from "./gossipValidation.js";
3
+
4
+ export enum ProposerPreferencesErrorCode {
5
+ INVALID_EPOCH = "PROPOSER_PREFERENCES_ERROR_INVALID_EPOCH",
6
+ PROPOSAL_SLOT_PASSED = "PROPOSER_PREFERENCES_ERROR_PROPOSAL_SLOT_PASSED",
7
+ INVALID_PROPOSER = "PROPOSER_PREFERENCES_ERROR_INVALID_PROPOSER",
8
+ ALREADY_KNOWN = "PROPOSER_PREFERENCES_ERROR_ALREADY_KNOWN",
9
+ INVALID_SIGNATURE = "PROPOSER_PREFERENCES_ERROR_INVALID_SIGNATURE",
10
+ }
11
+
12
+ export type ProposerPreferencesErrorType =
13
+ | {
14
+ code: ProposerPreferencesErrorCode.INVALID_EPOCH;
15
+ proposalSlot: Slot;
16
+ currentEpoch: number;
17
+ }
18
+ | {
19
+ code: ProposerPreferencesErrorCode.PROPOSAL_SLOT_PASSED;
20
+ proposalSlot: Slot;
21
+ currentSlot: Slot;
22
+ }
23
+ | {
24
+ code: ProposerPreferencesErrorCode.INVALID_PROPOSER;
25
+ proposalSlot: Slot;
26
+ validatorIndex: ValidatorIndex;
27
+ }
28
+ | {
29
+ code: ProposerPreferencesErrorCode.ALREADY_KNOWN;
30
+ proposalSlot: Slot;
31
+ validatorIndex: ValidatorIndex;
32
+ }
33
+ | {
34
+ code: ProposerPreferencesErrorCode.INVALID_SIGNATURE;
35
+ proposalSlot: Slot;
36
+ validatorIndex: ValidatorIndex;
37
+ };
38
+
39
+ export class ProposerPreferencesError extends GossipActionError<ProposerPreferencesErrorType> {}
@@ -8,7 +8,6 @@ import {
8
8
  ProtoArray,
9
9
  ProtoBlock,
10
10
  ForkChoiceOpts as RawForkChoiceOpts,
11
- getCheckpointPayloadStatus,
12
11
  } from "@lodestar/fork-choice";
13
12
  import {ZERO_HASH_HEX} from "@lodestar/params";
14
13
  import {
@@ -104,16 +103,6 @@ export function initializeForkChoiceFromFinalizedState(
104
103
 
105
104
  const isForkPostGloas = computeEpochAtSlot(state.slot) >= config.GLOAS_FORK_EPOCH;
106
105
 
107
- // Determine justified checkpoint payload status
108
- const justifiedPayloadStatus = isForkPostGloas
109
- ? PayloadStatus.PENDING
110
- : getCheckpointPayloadStatus(config, state, justifiedCheckpoint.epoch);
111
-
112
- // Determine finalized checkpoint payload status
113
- const finalizedPayloadStatus = isForkPostGloas
114
- ? PayloadStatus.PENDING
115
- : getCheckpointPayloadStatus(config, state, finalizedCheckpoint.epoch);
116
-
117
106
  return new forkchoiceConstructor(
118
107
  config,
119
108
 
@@ -123,8 +112,6 @@ export function initializeForkChoiceFromFinalizedState(
123
112
  finalizedCheckpoint,
124
113
  justifiedBalances,
125
114
  justifiedBalancesGetter,
126
- justifiedPayloadStatus,
127
- finalizedPayloadStatus,
128
115
  {
129
116
  onJustified: (cp) => emitter.emit(ChainEvent.forkChoiceJustified, cp),
130
117
  onFinalized: (cp) => emitter.emit(ChainEvent.forkChoiceFinalized, cp),
@@ -150,7 +137,9 @@ export function initializeForkChoiceFromFinalizedState(
150
137
 
151
138
  ...(isStatePostBellatrix(state) && state.isExecutionStateType && state.isMergeTransitionComplete
152
139
  ? {
153
- executionPayloadBlockHash: toRootHex(state.latestBlockHash),
140
+ executionPayloadBlockHash: isStatePostGloas(state)
141
+ ? toRootHex(state.latestBlockHash)
142
+ : toRootHex(state.latestExecutionPayloadHeader.blockHash),
154
143
  // TODO GLOAS: executionPayloadNumber is not tracked in BeaconState post-gloas (EIP-7732 removed
155
144
  // latestExecutionPayloadHeader). Using 0 as unavailable fallback until a solution is found.
156
145
  executionPayloadNumber: isStatePostGloas(state) ? 0 : state.payloadBlockNumber,
@@ -159,7 +148,7 @@ export function initializeForkChoiceFromFinalizedState(
159
148
  : {executionPayloadBlockHash: null, executionStatus: ExecutionStatus.PreMerge}),
160
149
 
161
150
  dataAvailabilityStatus: DataAvailabilityStatus.PreData,
162
- payloadStatus: isForkPostGloas ? PayloadStatus.PENDING : PayloadStatus.FULL, // TODO GLOAS: Post-gloas how do we know if the checkpoint payload is FULL or EMPTY?
151
+ payloadStatus: isForkPostGloas ? PayloadStatus.PENDING : PayloadStatus.FULL,
163
152
  parentBlockHash: isStatePostGloas(state) ? toRootHex(state.latestBlockHash) : null,
164
153
  },
165
154
  currentSlot
@@ -206,19 +195,12 @@ export function initializeForkChoiceFromUnfinalizedState(
206
195
 
207
196
  const isForkPostGloas = computeEpochAtSlot(unfinalizedState.slot) >= config.GLOAS_FORK_EPOCH;
208
197
 
209
- // For unfinalized state, use getCheckpointPayloadStatus to determine the correct status.
210
- // It checks state.execution_payload_availability to determine EMPTY vs FULL.
211
- const justifiedPayloadStatus = getCheckpointPayloadStatus(config, unfinalizedState, justifiedCheckpoint.epoch);
212
- const finalizedPayloadStatus = getCheckpointPayloadStatus(config, unfinalizedState, finalizedCheckpoint.epoch);
213
-
214
198
  const store = new ForkChoiceStore(
215
199
  currentSlot,
216
200
  justifiedCheckpoint,
217
201
  finalizedCheckpoint,
218
202
  justifiedBalances,
219
203
  justifiedBalancesGetter,
220
- justifiedPayloadStatus,
221
- finalizedPayloadStatus,
222
204
  {
223
205
  onJustified: (cp) => emitter.emit(ChainEvent.forkChoiceJustified, cp),
224
206
  onFinalized: (cp) => emitter.emit(ChainEvent.forkChoiceFinalized, cp),
@@ -247,7 +229,9 @@ export function initializeForkChoiceFromUnfinalizedState(
247
229
  unfinalizedState.isExecutionStateType &&
248
230
  unfinalizedState.isMergeTransitionComplete
249
231
  ? {
250
- executionPayloadBlockHash: toRootHex(unfinalizedState.latestBlockHash),
232
+ executionPayloadBlockHash: isStatePostGloas(unfinalizedState)
233
+ ? toRootHex(unfinalizedState.latestBlockHash)
234
+ : toRootHex(unfinalizedState.latestExecutionPayloadHeader.blockHash),
251
235
  // TODO GLOAS: executionPayloadNumber is not tracked in BeaconState post-gloas (EIP-7732 removed
252
236
  // latestExecutionPayloadHeader). Using 0 as unavailable fallback until a solution is found.
253
237
  executionPayloadNumber: isStatePostGloas(unfinalizedState) ? 0 : unfinalizedState.payloadBlockNumber,
@@ -256,7 +240,7 @@ export function initializeForkChoiceFromUnfinalizedState(
256
240
  : {executionPayloadBlockHash: null, executionStatus: ExecutionStatus.PreMerge}),
257
241
 
258
242
  dataAvailabilityStatus: DataAvailabilityStatus.PreData,
259
- payloadStatus: isForkPostGloas ? PayloadStatus.PENDING : PayloadStatus.FULL, // TODO GLOAS: Post-gloas how do we know if the checkpoint payload is FULL or EMPTY?
243
+ payloadStatus: isForkPostGloas ? PayloadStatus.PENDING : PayloadStatus.FULL,
260
244
  parentBlockHash: isStatePostGloas(unfinalizedState) ? toRootHex(unfinalizedState.latestBlockHash) : null,
261
245
  };
262
246
 
@@ -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,7 @@ 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)
123
119
  .map(fastToPayloadAttestation);
124
120
  }
125
121
 
@@ -8,8 +8,9 @@ import {
8
8
  computeEpochAtSlot,
9
9
  computeTimeAtSlot,
10
10
  isStatePostBellatrix,
11
+ isStatePostGloas,
11
12
  } from "@lodestar/state-transition";
12
- import {Slot} from "@lodestar/types";
13
+ import {Bytes32, Slot, electra} from "@lodestar/types";
13
14
  import {Logger, fromHex, isErrorAborted, sleep} from "@lodestar/utils";
14
15
  import {GENESIS_SLOT, ZERO_HASH_HEX} from "../constants/constants.js";
15
16
  import {BuilderStatus} from "../execution/builder/http.js";
@@ -81,6 +82,8 @@ export class PrepareNextSlotScheduler {
81
82
  // calling updateHead() here before we produce a block to reduce reorg possibility
82
83
  const headBlock = this.chain.recomputeForkChoiceHead(ForkchoiceCaller.prepareNextSlot);
83
84
  const {slot: headSlot, blockRoot: headRoot} = headBlock;
85
+ // may be updated below if we predict a proposer-boost-reorg
86
+ let updatedHead = headBlock;
84
87
 
85
88
  // PS: previously this was comparing slots, but that gave no leway on the skipped
86
89
  // slots on epoch bounday. Making it more fluid.
@@ -123,7 +126,6 @@ export class PrepareNextSlotScheduler {
123
126
  const proposerIndex = prepareState.getBeaconProposer(prepareSlot);
124
127
  const feeRecipient = this.chain.beaconProposerCache.get(proposerIndex);
125
128
  let updatedPrepareState = prepareState;
126
- let updatedHeadRoot = headRoot;
127
129
 
128
130
  if (feeRecipient) {
129
131
  // If we are proposing next slot, we need to predict if we can proposer-boost-reorg or not
@@ -146,7 +148,7 @@ export class PrepareNextSlotScheduler {
146
148
  {dontTransferCache: !isEpochTransition},
147
149
  RegenCaller.predictProposerHead
148
150
  );
149
- updatedHeadRoot = proposerHeadRoot;
151
+ updatedHead = proposerHead;
150
152
  }
151
153
 
152
154
  // Update the builder status, if enabled shoot an api call to check status
@@ -156,29 +158,56 @@ export class PrepareNextSlotScheduler {
156
158
  this.logger.error("Builder disabled as the check status api failed", {prepareSlot}, e as Error);
157
159
  });
158
160
  }
161
+ }
162
+
163
+ if (!isStatePostBellatrix(updatedPrepareState)) {
164
+ throw new Error("Expected Bellatrix state for payload attributes");
165
+ }
159
166
 
167
+ let parentBlockHash: Bytes32;
168
+ let isExtendingPayload = false;
169
+ if (isStatePostGloas(updatedPrepareState)) {
170
+ isExtendingPayload = this.chain.forkChoice.shouldExtendPayload(updatedHead.blockRoot);
171
+ parentBlockHash = isExtendingPayload
172
+ ? updatedPrepareState.latestExecutionPayloadBid.blockHash
173
+ : updatedPrepareState.latestExecutionPayloadBid.parentBlockHash;
174
+ } else {
175
+ parentBlockHash = updatedPrepareState.latestExecutionPayloadHeader.blockHash;
176
+ }
177
+
178
+ // Reused by the SSE emit below to avoid a second DB lookup on cache miss
179
+ let parentExecutionRequests: electra.ExecutionRequests | undefined;
180
+
181
+ if (feeRecipient) {
160
182
  const preparationTime =
161
183
  computeTimeAtSlot(this.config, prepareSlot, this.chain.genesisTime) - Date.now() / 1000;
162
184
  this.metrics?.blockPayload.payloadAdvancePrepTime.observe(preparationTime);
163
- if (!isStatePostBellatrix(updatedPrepareState)) {
164
- throw new Error("Expected Bellatrix state for payload preparation");
165
- }
166
185
 
167
186
  const safeBlockHash = getSafeExecutionBlockHash(this.chain.forkChoice);
168
187
  const finalizedBlockHash =
169
188
  this.chain.forkChoice.getFinalizedBlock().executionPayloadBlockHash ?? ZERO_HASH_HEX;
189
+
190
+ if (isExtendingPayload) {
191
+ parentExecutionRequests = await this.chain.getParentExecutionRequests(
192
+ updatedHead.slot,
193
+ updatedHead.blockRoot
194
+ );
195
+ }
196
+
170
197
  // 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
198
+ // left for scheduler and this gives nice semantics to catch and log errors in the
172
199
  // try/catch wrapper here.
173
200
  await prepareExecutionPayload(
174
201
  this.chain,
175
202
  this.logger,
176
203
  fork as ForkPostBellatrix, // State is of execution type
177
- fromHex(updatedHeadRoot),
204
+ fromHex(updatedHead.blockRoot),
205
+ parentBlockHash,
178
206
  safeBlockHash,
179
207
  finalizedBlockHash,
180
208
  updatedPrepareState,
181
- feeRecipient
209
+ feeRecipient,
210
+ parentExecutionRequests
182
211
  );
183
212
  this.logger.verbose("PrepareNextSlotScheduler prepared new payload", {
184
213
  prepareSlot,
@@ -187,24 +216,38 @@ 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.pruneBelow(updatedHeadParent.slot);
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
  ) {
237
+ // if we didn't fetch above (not proposing), SSE still needs it here
238
+ if (!parentExecutionRequests && isExtendingPayload) {
239
+ parentExecutionRequests = await this.chain.getParentExecutionRequests(
240
+ updatedHead.slot,
241
+ updatedHead.blockRoot
242
+ );
243
+ }
201
244
  const data = getPayloadAttributesForSSE(fork as ForkPostBellatrix, this.chain, {
202
245
  prepareState: updatedPrepareState,
203
246
  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",
247
+ parentBlockRoot: fromHex(updatedHead.blockRoot),
248
+ parentBlockHash,
249
+ feeRecipient: feeRecipient ?? "0x0000000000000000000000000000000000000000",
250
+ parentExecutionRequests,
208
251
  });
209
252
  this.chain.emitter.emit(routes.events.EventType.payloadAttributes, {data, version: fork});
210
253
  }