@lodestar/beacon-node 1.43.0-dev.4fb05c546d → 1.43.0-dev.549a5b8115

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 (305) 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/pool/index.d.ts.map +1 -1
  4. package/lib/api/impl/beacon/pool/index.js +45 -2
  5. package/lib/api/impl/beacon/pool/index.js.map +1 -1
  6. package/lib/api/impl/beacon/state/utils.d.ts +2 -2
  7. package/lib/api/impl/beacon/state/utils.d.ts.map +1 -1
  8. package/lib/api/impl/beacon/state/utils.js.map +1 -1
  9. package/lib/api/impl/lodestar/index.js +1 -1
  10. package/lib/api/impl/lodestar/index.js.map +1 -1
  11. package/lib/api/impl/validator/index.d.ts.map +1 -1
  12. package/lib/api/impl/validator/index.js +66 -5
  13. package/lib/api/impl/validator/index.js.map +1 -1
  14. package/lib/chain/archiveStore/archiveStore.d.ts.map +1 -1
  15. package/lib/chain/archiveStore/archiveStore.js.map +1 -1
  16. package/lib/chain/archiveStore/interface.d.ts +4 -4
  17. package/lib/chain/archiveStore/interface.d.ts.map +1 -1
  18. package/lib/chain/archiveStore/strategies/frequencyStateArchiveStrategy.d.ts +4 -4
  19. package/lib/chain/archiveStore/strategies/frequencyStateArchiveStrategy.d.ts.map +1 -1
  20. package/lib/chain/archiveStore/strategies/frequencyStateArchiveStrategy.js.map +1 -1
  21. package/lib/chain/archiveStore/utils/archiveBlocks.d.ts +2 -2
  22. package/lib/chain/archiveStore/utils/archiveBlocks.d.ts.map +1 -1
  23. package/lib/chain/archiveStore/utils/archiveBlocks.js +110 -58
  24. package/lib/chain/archiveStore/utils/archiveBlocks.js.map +1 -1
  25. package/lib/chain/blocks/importBlock.d.ts.map +1 -1
  26. package/lib/chain/blocks/importBlock.js +3 -2
  27. package/lib/chain/blocks/importBlock.js.map +1 -1
  28. package/lib/chain/blocks/importExecutionPayload.d.ts +28 -14
  29. package/lib/chain/blocks/importExecutionPayload.d.ts.map +1 -1
  30. package/lib/chain/blocks/importExecutionPayload.js +86 -86
  31. package/lib/chain/blocks/importExecutionPayload.js.map +1 -1
  32. package/lib/chain/blocks/index.d.ts +5 -3
  33. package/lib/chain/blocks/index.d.ts.map +1 -1
  34. package/lib/chain/blocks/index.js +31 -11
  35. package/lib/chain/blocks/index.js.map +1 -1
  36. package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.d.ts +1 -0
  37. package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.d.ts.map +1 -1
  38. package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.js +4 -1
  39. package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.js.map +1 -1
  40. package/lib/chain/blocks/payloadEnvelopeInput/types.d.ts +1 -0
  41. package/lib/chain/blocks/payloadEnvelopeInput/types.d.ts.map +1 -1
  42. package/lib/chain/blocks/payloadEnvelopeProcessor.js +2 -2
  43. package/lib/chain/blocks/payloadEnvelopeProcessor.js.map +1 -1
  44. package/lib/chain/blocks/types.d.ts +14 -20
  45. package/lib/chain/blocks/types.d.ts.map +1 -1
  46. package/lib/chain/blocks/utils/chainSegment.d.ts +23 -2
  47. package/lib/chain/blocks/utils/chainSegment.d.ts.map +1 -1
  48. package/lib/chain/blocks/utils/chainSegment.js +81 -12
  49. package/lib/chain/blocks/utils/chainSegment.js.map +1 -1
  50. package/lib/chain/blocks/verifyBlock.d.ts +5 -3
  51. package/lib/chain/blocks/verifyBlock.d.ts.map +1 -1
  52. package/lib/chain/blocks/verifyBlock.js +51 -7
  53. package/lib/chain/blocks/verifyBlock.js.map +1 -1
  54. package/lib/chain/blocks/verifyBlocksSanityChecks.d.ts.map +1 -1
  55. package/lib/chain/blocks/verifyBlocksSanityChecks.js +15 -4
  56. package/lib/chain/blocks/verifyBlocksSanityChecks.js.map +1 -1
  57. package/lib/chain/blocks/verifyExecutionPayloadEnvelope.d.ts +24 -0
  58. package/lib/chain/blocks/verifyExecutionPayloadEnvelope.d.ts.map +1 -0
  59. package/lib/chain/blocks/verifyExecutionPayloadEnvelope.js +76 -0
  60. package/lib/chain/blocks/verifyExecutionPayloadEnvelope.js.map +1 -0
  61. package/lib/chain/blocks/verifyPayloadsDataAvailability.d.ts.map +1 -1
  62. package/lib/chain/blocks/verifyPayloadsDataAvailability.js +8 -3
  63. package/lib/chain/blocks/verifyPayloadsDataAvailability.js.map +1 -1
  64. package/lib/chain/blocks/writePayloadEnvelopeInputToDb.d.ts +1 -1
  65. package/lib/chain/blocks/writePayloadEnvelopeInputToDb.d.ts.map +1 -1
  66. package/lib/chain/blocks/writePayloadEnvelopeInputToDb.js +2 -11
  67. package/lib/chain/blocks/writePayloadEnvelopeInputToDb.js.map +1 -1
  68. package/lib/chain/chain.d.ts +8 -6
  69. package/lib/chain/chain.d.ts.map +1 -1
  70. package/lib/chain/chain.js +21 -6
  71. package/lib/chain/chain.js.map +1 -1
  72. package/lib/chain/emitter.d.ts +3 -3
  73. package/lib/chain/emitter.d.ts.map +1 -1
  74. package/lib/chain/errors/blockError.d.ts +8 -1
  75. package/lib/chain/errors/blockError.d.ts.map +1 -1
  76. package/lib/chain/errors/blockError.js +2 -0
  77. package/lib/chain/errors/blockError.js.map +1 -1
  78. package/lib/chain/errors/executionPayloadBid.d.ts +5 -0
  79. package/lib/chain/errors/executionPayloadBid.d.ts.map +1 -1
  80. package/lib/chain/errors/executionPayloadBid.js +1 -0
  81. package/lib/chain/errors/executionPayloadBid.js.map +1 -1
  82. package/lib/chain/errors/executionPayloadEnvelope.d.ts +5 -0
  83. package/lib/chain/errors/executionPayloadEnvelope.d.ts.map +1 -1
  84. package/lib/chain/errors/executionPayloadEnvelope.js +1 -0
  85. package/lib/chain/errors/executionPayloadEnvelope.js.map +1 -1
  86. package/lib/chain/errors/index.d.ts +1 -0
  87. package/lib/chain/errors/index.d.ts.map +1 -1
  88. package/lib/chain/errors/index.js +1 -0
  89. package/lib/chain/errors/index.js.map +1 -1
  90. package/lib/chain/errors/proposerPreferences.d.ts +33 -0
  91. package/lib/chain/errors/proposerPreferences.d.ts.map +1 -0
  92. package/lib/chain/errors/proposerPreferences.js +13 -0
  93. package/lib/chain/errors/proposerPreferences.js.map +1 -0
  94. package/lib/chain/forkChoice/index.d.ts.map +1 -1
  95. package/lib/chain/forkChoice/index.js +5 -17
  96. package/lib/chain/forkChoice/index.js.map +1 -1
  97. package/lib/chain/interface.d.ts +7 -5
  98. package/lib/chain/interface.d.ts.map +1 -1
  99. package/lib/chain/interface.js.map +1 -1
  100. package/lib/chain/opPools/payloadAttestationPool.d.ts +3 -2
  101. package/lib/chain/opPools/payloadAttestationPool.d.ts.map +1 -1
  102. package/lib/chain/opPools/payloadAttestationPool.js +26 -4
  103. package/lib/chain/opPools/payloadAttestationPool.js.map +1 -1
  104. package/lib/chain/prepareNextSlot.d.ts.map +1 -1
  105. package/lib/chain/prepareNextSlot.js +30 -10
  106. package/lib/chain/prepareNextSlot.js.map +1 -1
  107. package/lib/chain/produceBlock/produceBlockBody.d.ts +3 -2
  108. package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
  109. package/lib/chain/produceBlock/produceBlockBody.js +40 -15
  110. package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
  111. package/lib/chain/regen/interface.d.ts +1 -0
  112. package/lib/chain/regen/interface.d.ts.map +1 -1
  113. package/lib/chain/regen/interface.js +1 -0
  114. package/lib/chain/regen/interface.js.map +1 -1
  115. package/lib/chain/seenCache/index.d.ts +1 -0
  116. package/lib/chain/seenCache/index.d.ts.map +1 -1
  117. package/lib/chain/seenCache/index.js +1 -0
  118. package/lib/chain/seenCache/index.js.map +1 -1
  119. package/lib/chain/seenCache/seenPayloadEnvelopeInput.d.ts +19 -6
  120. package/lib/chain/seenCache/seenPayloadEnvelopeInput.d.ts.map +1 -1
  121. package/lib/chain/seenCache/seenPayloadEnvelopeInput.js +28 -20
  122. package/lib/chain/seenCache/seenPayloadEnvelopeInput.js.map +1 -1
  123. package/lib/chain/seenCache/seenProposerPreferences.d.ts +15 -0
  124. package/lib/chain/seenCache/seenProposerPreferences.d.ts.map +1 -0
  125. package/lib/chain/seenCache/seenProposerPreferences.js +25 -0
  126. package/lib/chain/seenCache/seenProposerPreferences.js.map +1 -0
  127. package/lib/chain/stateCache/persistentCheckpointsCache.d.ts.map +1 -1
  128. package/lib/chain/stateCache/persistentCheckpointsCache.js +4 -1
  129. package/lib/chain/stateCache/persistentCheckpointsCache.js.map +1 -1
  130. package/lib/chain/validation/block.d.ts.map +1 -1
  131. package/lib/chain/validation/block.js +1 -0
  132. package/lib/chain/validation/block.js.map +1 -1
  133. package/lib/chain/validation/executionPayloadBid.d.ts.map +1 -1
  134. package/lib/chain/validation/executionPayloadBid.js +13 -1
  135. package/lib/chain/validation/executionPayloadBid.js.map +1 -1
  136. package/lib/chain/validation/executionPayloadEnvelope.d.ts.map +1 -1
  137. package/lib/chain/validation/executionPayloadEnvelope.js +19 -9
  138. package/lib/chain/validation/executionPayloadEnvelope.js.map +1 -1
  139. package/lib/chain/validation/proposerPreferences.d.ts +8 -0
  140. package/lib/chain/validation/proposerPreferences.d.ts.map +1 -0
  141. package/lib/chain/validation/proposerPreferences.js +69 -0
  142. package/lib/chain/validation/proposerPreferences.js.map +1 -0
  143. package/lib/db/repositories/executionPayloadEnvelopeArchive.js +1 -1
  144. package/lib/db/repositories/executionPayloadEnvelopeArchive.js.map +1 -1
  145. package/lib/execution/engine/http.d.ts.map +1 -1
  146. package/lib/execution/engine/http.js +21 -14
  147. package/lib/execution/engine/http.js.map +1 -1
  148. package/lib/execution/engine/interface.d.ts +1 -0
  149. package/lib/execution/engine/interface.d.ts.map +1 -1
  150. package/lib/execution/engine/mock.d.ts.map +1 -1
  151. package/lib/execution/engine/mock.js +6 -0
  152. package/lib/execution/engine/mock.js.map +1 -1
  153. package/lib/execution/engine/types.d.ts +20 -0
  154. package/lib/execution/engine/types.d.ts.map +1 -1
  155. package/lib/execution/engine/types.js +18 -0
  156. package/lib/execution/engine/types.js.map +1 -1
  157. package/lib/metrics/metrics/lodestar.d.ts +1 -0
  158. package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
  159. package/lib/metrics/metrics/lodestar.js +4 -0
  160. package/lib/metrics/metrics/lodestar.js.map +1 -1
  161. package/lib/network/gossip/interface.d.ts +7 -1
  162. package/lib/network/gossip/interface.d.ts.map +1 -1
  163. package/lib/network/gossip/interface.js +1 -0
  164. package/lib/network/gossip/interface.js.map +1 -1
  165. package/lib/network/gossip/scoringParameters.d.ts.map +1 -1
  166. package/lib/network/gossip/scoringParameters.js +12 -1
  167. package/lib/network/gossip/scoringParameters.js.map +1 -1
  168. package/lib/network/gossip/topic.d.ts +11 -2
  169. package/lib/network/gossip/topic.d.ts.map +1 -1
  170. package/lib/network/gossip/topic.js +6 -0
  171. package/lib/network/gossip/topic.js.map +1 -1
  172. package/lib/network/interface.d.ts +1 -0
  173. package/lib/network/interface.d.ts.map +1 -1
  174. package/lib/network/network.d.ts +1 -0
  175. package/lib/network/network.d.ts.map +1 -1
  176. package/lib/network/network.js +6 -1
  177. package/lib/network/network.js.map +1 -1
  178. package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
  179. package/lib/network/processor/gossipHandlers.js +17 -12
  180. package/lib/network/processor/gossipHandlers.js.map +1 -1
  181. package/lib/network/processor/gossipQueues/index.d.ts.map +1 -1
  182. package/lib/network/processor/gossipQueues/index.js +5 -0
  183. package/lib/network/processor/gossipQueues/index.js.map +1 -1
  184. package/lib/network/processor/index.d.ts.map +1 -1
  185. package/lib/network/processor/index.js +1 -0
  186. package/lib/network/processor/index.js.map +1 -1
  187. package/lib/network/reqresp/handlers/beaconBlocksByRange.d.ts.map +1 -1
  188. package/lib/network/reqresp/handlers/beaconBlocksByRange.js +14 -6
  189. package/lib/network/reqresp/handlers/beaconBlocksByRange.js.map +1 -1
  190. package/lib/network/reqresp/handlers/blobSidecarsByRange.d.ts.map +1 -1
  191. package/lib/network/reqresp/handlers/blobSidecarsByRange.js +11 -5
  192. package/lib/network/reqresp/handlers/blobSidecarsByRange.js.map +1 -1
  193. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.d.ts.map +1 -1
  194. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js +17 -5
  195. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js.map +1 -1
  196. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.d.ts.map +1 -1
  197. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.js +7 -4
  198. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.js.map +1 -1
  199. package/lib/node/notifier.js +7 -1
  200. package/lib/node/notifier.js.map +1 -1
  201. package/lib/sync/range/batch.d.ts +12 -2
  202. package/lib/sync/range/batch.d.ts.map +1 -1
  203. package/lib/sync/range/batch.js +56 -30
  204. package/lib/sync/range/batch.js.map +1 -1
  205. package/lib/sync/range/chain.d.ts +6 -2
  206. package/lib/sync/range/chain.d.ts.map +1 -1
  207. package/lib/sync/range/chain.js +4 -3
  208. package/lib/sync/range/chain.js.map +1 -1
  209. package/lib/sync/range/range.d.ts.map +1 -1
  210. package/lib/sync/range/range.js +17 -6
  211. package/lib/sync/range/range.js.map +1 -1
  212. package/lib/sync/types.d.ts +34 -0
  213. package/lib/sync/types.d.ts.map +1 -1
  214. package/lib/sync/types.js +34 -0
  215. package/lib/sync/types.js.map +1 -1
  216. package/lib/sync/unknownBlock.d.ts +24 -1
  217. package/lib/sync/unknownBlock.d.ts.map +1 -1
  218. package/lib/sync/unknownBlock.js +649 -53
  219. package/lib/sync/unknownBlock.js.map +1 -1
  220. package/lib/sync/utils/downloadByRange.d.ts +46 -10
  221. package/lib/sync/utils/downloadByRange.d.ts.map +1 -1
  222. package/lib/sync/utils/downloadByRange.js +147 -24
  223. package/lib/sync/utils/downloadByRange.js.map +1 -1
  224. package/lib/sync/utils/downloadByRoot.d.ts.map +1 -1
  225. package/lib/sync/utils/downloadByRoot.js +6 -2
  226. package/lib/sync/utils/downloadByRoot.js.map +1 -1
  227. package/lib/sync/utils/pendingBlocksTree.d.ts +0 -1
  228. package/lib/sync/utils/pendingBlocksTree.d.ts.map +1 -1
  229. package/lib/sync/utils/pendingBlocksTree.js +0 -9
  230. package/lib/sync/utils/pendingBlocksTree.js.map +1 -1
  231. package/lib/util/sszBytes.d.ts.map +1 -1
  232. package/lib/util/sszBytes.js +16 -3
  233. package/lib/util/sszBytes.js.map +1 -1
  234. package/package.json +16 -15
  235. package/src/api/impl/beacon/blocks/index.ts +9 -9
  236. package/src/api/impl/beacon/pool/index.ts +83 -1
  237. package/src/api/impl/beacon/state/utils.ts +2 -2
  238. package/src/api/impl/lodestar/index.ts +1 -1
  239. package/src/api/impl/validator/index.ts +80 -4
  240. package/src/chain/archiveStore/archiveStore.ts +5 -5
  241. package/src/chain/archiveStore/interface.ts +4 -4
  242. package/src/chain/archiveStore/strategies/frequencyStateArchiveStrategy.ts +4 -4
  243. package/src/chain/archiveStore/utils/archiveBlocks.ts +153 -94
  244. package/src/chain/blocks/importBlock.ts +3 -2
  245. package/src/chain/blocks/importExecutionPayload.ts +107 -101
  246. package/src/chain/blocks/index.ts +54 -15
  247. package/src/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.ts +5 -1
  248. package/src/chain/blocks/payloadEnvelopeInput/types.ts +1 -0
  249. package/src/chain/blocks/payloadEnvelopeProcessor.ts +2 -2
  250. package/src/chain/blocks/types.ts +14 -25
  251. package/src/chain/blocks/utils/chainSegment.ts +106 -17
  252. package/src/chain/blocks/verifyBlock.ts +68 -9
  253. package/src/chain/blocks/verifyBlocksSanityChecks.ts +16 -7
  254. package/src/chain/blocks/verifyExecutionPayloadEnvelope.ts +129 -0
  255. package/src/chain/blocks/verifyPayloadsDataAvailability.ts +7 -4
  256. package/src/chain/blocks/writePayloadEnvelopeInputToDb.ts +9 -18
  257. package/src/chain/chain.ts +38 -19
  258. package/src/chain/emitter.ts +3 -3
  259. package/src/chain/errors/blockError.ts +4 -1
  260. package/src/chain/errors/executionPayloadBid.ts +6 -0
  261. package/src/chain/errors/executionPayloadEnvelope.ts +6 -0
  262. package/src/chain/errors/index.ts +1 -0
  263. package/src/chain/errors/proposerPreferences.ts +39 -0
  264. package/src/chain/forkChoice/index.ts +2 -22
  265. package/src/chain/interface.ts +11 -3
  266. package/src/chain/opPools/payloadAttestationPool.ts +29 -8
  267. package/src/chain/prepareNextSlot.ts +42 -12
  268. package/src/chain/produceBlock/produceBlockBody.ts +47 -13
  269. package/src/chain/regen/interface.ts +1 -0
  270. package/src/chain/seenCache/index.ts +1 -0
  271. package/src/chain/seenCache/seenPayloadEnvelopeInput.ts +35 -23
  272. package/src/chain/seenCache/seenProposerPreferences.ts +29 -0
  273. package/src/chain/stateCache/persistentCheckpointsCache.ts +4 -1
  274. package/src/chain/validation/block.ts +1 -0
  275. package/src/chain/validation/executionPayloadBid.ts +14 -0
  276. package/src/chain/validation/executionPayloadEnvelope.ts +20 -10
  277. package/src/chain/validation/proposerPreferences.ts +91 -0
  278. package/src/db/repositories/executionPayloadEnvelopeArchive.ts +1 -1
  279. package/src/execution/engine/http.ts +21 -14
  280. package/src/execution/engine/interface.ts +1 -0
  281. package/src/execution/engine/mock.ts +8 -1
  282. package/src/execution/engine/types.ts +41 -0
  283. package/src/metrics/metrics/lodestar.ts +4 -0
  284. package/src/network/gossip/interface.ts +6 -0
  285. package/src/network/gossip/scoringParameters.ts +14 -1
  286. package/src/network/gossip/topic.ts +6 -0
  287. package/src/network/interface.ts +1 -0
  288. package/src/network/network.ts +12 -1
  289. package/src/network/processor/gossipHandlers.ts +26 -13
  290. package/src/network/processor/gossipQueues/index.ts +5 -0
  291. package/src/network/processor/index.ts +1 -0
  292. package/src/network/reqresp/handlers/beaconBlocksByRange.ts +14 -6
  293. package/src/network/reqresp/handlers/blobSidecarsByRange.ts +11 -5
  294. package/src/network/reqresp/handlers/dataColumnSidecarsByRange.ts +17 -5
  295. package/src/network/reqresp/handlers/executionPayloadEnvelopesByRange.ts +7 -4
  296. package/src/node/notifier.ts +8 -1
  297. package/src/sync/range/batch.ts +90 -35
  298. package/src/sync/range/chain.ts +13 -5
  299. package/src/sync/range/range.ts +18 -6
  300. package/src/sync/types.ts +72 -0
  301. package/src/sync/unknownBlock.ts +810 -57
  302. package/src/sync/utils/downloadByRange.ts +256 -39
  303. package/src/sync/utils/downloadByRoot.ts +12 -2
  304. package/src/sync/utils/pendingBlocksTree.ts +0 -15
  305. package/src/util/sszBytes.ts +21 -3
@@ -46,9 +46,10 @@ 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
- import {ZERO_HASH_HEX} from "../../constants/index.js";
52
+ import {ZERO_HASH, ZERO_HASH_HEX} from "../../constants/index.js";
52
53
  import {numToQuantity} from "../../execution/engine/utils.js";
53
54
  import {
54
55
  IExecutionBuilder,
@@ -213,9 +214,19 @@ export async function produceBlockBody<T extends BlockType>(
213
214
  });
214
215
 
215
216
  // Get execution payload from EL
216
- const parentBlockHash = this.forkChoice.shouldExtendPayload(toRootHex(parentBlockRoot))
217
+ const isExtendingPayload = this.forkChoice.shouldExtendPayload(toRootHex(parentBlockRoot));
218
+ let parentBlockHash = isExtendingPayload
217
219
  ? currentState.latestExecutionPayloadBid.blockHash
218
220
  : currentState.latestExecutionPayloadBid.parentBlockHash;
221
+ // At gloas genesis the committed bid has no prior EL block to reference
222
+ // (`bid.parentBlockHash` is zero). Fall back to `bid.blockHash` (= eth1 genesis hash) so the
223
+ // FCU to the EL carries a valid head. Post-genesis bids always reference a non-zero parent.
224
+ if (isStatePostGloas(currentState) && byteArrayEquals(parentBlockHash, ZERO_HASH)) {
225
+ parentBlockHash = currentState.latestExecutionPayloadBid.blockHash;
226
+ }
227
+ const parentExecutionRequests = isExtendingPayload
228
+ ? await this.getParentExecutionRequests(parentBlock.slot, parentBlock.blockRoot)
229
+ : ssz.electra.ExecutionRequests.defaultValue();
219
230
  const prepareRes = await prepareExecutionPayload(
220
231
  this,
221
232
  this.logger,
@@ -225,7 +236,8 @@ export async function produceBlockBody<T extends BlockType>(
225
236
  safeBlockHash,
226
237
  finalizedBlockHash ?? ZERO_HASH_HEX,
227
238
  currentState,
228
- feeRecipient
239
+ feeRecipient,
240
+ parentExecutionRequests
229
241
  );
230
242
 
231
243
  const {prepType, payloadId} = prepareRes;
@@ -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,11 @@ 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;
283
299
  blockBody = gloasBody as AssembledBodyType<T>;
284
300
 
285
301
  // Store execution payload data required to construct execution payload envelope later
@@ -616,7 +632,8 @@ export async function prepareExecutionPayload(
616
632
  safeBlockHash: RootHex,
617
633
  finalizedBlockHash: RootHex,
618
634
  state: IBeaconStateViewBellatrix,
619
- suggestedFeeRecipient: string
635
+ suggestedFeeRecipient: string,
636
+ parentExecutionRequests?: electra.ExecutionRequests
620
637
  ): Promise<{prepType: PayloadPreparationType; payloadId: PayloadId}> {
621
638
  const timestamp = computeTimeAtSlot(chain.config, state.slot, state.genesisTime);
622
639
  const prevRandao = state.getRandaoMix(state.epoch);
@@ -653,6 +670,7 @@ export async function prepareExecutionPayload(
653
670
  parentBlockRoot,
654
671
  parentBlockHash,
655
672
  feeRecipient: suggestedFeeRecipient,
673
+ parentExecutionRequests,
656
674
  });
657
675
 
658
676
  payloadId = await chain.executionEngine.notifyForkchoiceUpdate(
@@ -711,12 +729,14 @@ export function getPayloadAttributesForSSE(
711
729
  parentBlockRoot,
712
730
  parentBlockHash,
713
731
  feeRecipient,
732
+ parentExecutionRequests,
714
733
  }: {
715
734
  prepareState: IBeaconStateViewBellatrix;
716
735
  prepareSlot: Slot;
717
736
  parentBlockRoot: Root;
718
737
  parentBlockHash: Bytes32;
719
738
  feeRecipient: string;
739
+ parentExecutionRequests?: electra.ExecutionRequests;
720
740
  }
721
741
  ): SSEPayloadAttributes {
722
742
  const payloadAttributes = preparePayloadAttributes(fork, chain, {
@@ -725,6 +745,7 @@ export function getPayloadAttributesForSSE(
725
745
  parentBlockRoot,
726
746
  parentBlockHash,
727
747
  feeRecipient,
748
+ parentExecutionRequests,
728
749
  });
729
750
 
730
751
  let parentBlockNumber: number;
@@ -763,12 +784,14 @@ function preparePayloadAttributes(
763
784
  parentBlockRoot,
764
785
  parentBlockHash,
765
786
  feeRecipient,
787
+ parentExecutionRequests,
766
788
  }: {
767
789
  prepareState: IBeaconStateViewBellatrix;
768
790
  prepareSlot: Slot;
769
791
  parentBlockRoot: Root;
770
792
  parentBlockHash: Bytes32;
771
793
  feeRecipient: string;
794
+ parentExecutionRequests?: electra.ExecutionRequests;
772
795
  }
773
796
  ): SSEPayloadAttributes["payloadAttributes"] {
774
797
  const timestamp = computeTimeAtSlot(chain.config, prepareSlot, prepareState.genesisTime);
@@ -786,13 +809,20 @@ function preparePayloadAttributes(
786
809
 
787
810
  if (isStatePostGloas(prepareState)) {
788
811
  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;
812
+ if (isExtendingPayload) {
813
+ if (parentExecutionRequests === undefined) {
814
+ throw new Error("parentExecutionRequests required when extending full parent");
815
+ }
816
+ (payloadAttributes as capella.SSEPayloadAttributes["payloadAttributes"]).withdrawals =
817
+ prepareState.getExpectedWithdrawalsForFullParent(parentExecutionRequests);
818
+ } else {
819
+ // When the parent block is empty, state.payloadExpectedWithdrawals holds a batch
820
+ // already deducted from CL balances but never credited on the EL (the envelope
821
+ // was not delivered). The next payload must carry those same withdrawals to
822
+ // restore CL/EL consistency, otherwise validators permanently lose that balance.
823
+ (payloadAttributes as capella.SSEPayloadAttributes["payloadAttributes"]).withdrawals =
824
+ prepareState.payloadExpectedWithdrawals;
825
+ }
796
826
  } else {
797
827
  // withdrawals logic is now fork aware as it changes on electra fork post capella
798
828
  (payloadAttributes as capella.SSEPayloadAttributes["payloadAttributes"]).withdrawals =
@@ -804,6 +834,10 @@ function preparePayloadAttributes(
804
834
  (payloadAttributes as deneb.SSEPayloadAttributes["payloadAttributes"]).parentBeaconBlockRoot = parentBlockRoot;
805
835
  }
806
836
 
837
+ if (ForkSeq[fork] >= ForkSeq.gloas) {
838
+ (payloadAttributes as gloas.SSEPayloadAttributes["payloadAttributes"]).slotNumber = prepareSlot;
839
+ }
840
+
807
841
  return payloadAttributes;
808
842
  }
809
843
 
@@ -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
  }
@@ -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,9 +1,12 @@
1
+ import {ChainForkConfig} from "@lodestar/config";
1
2
  import {CheckpointWithHex} from "@lodestar/fork-choice";
2
3
  import {computeStartSlotAtEpoch} from "@lodestar/state-transition";
3
- import {RootHex} from "@lodestar/types";
4
+ import {RootHex, Slot} 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";
9
+ import {isDaOutOfRange} from "../blocks/blockInput/index.js";
7
10
  import {CreateFromBlockProps, PayloadEnvelopeInput} from "../blocks/payloadEnvelopeInput/index.js";
8
11
  import {ChainEvent, ChainEventEmitter} from "../emitter.js";
9
12
 
@@ -11,6 +14,8 @@ export type {PayloadEnvelopeInputState} from "../blocks/payloadEnvelopeInput/ind
11
14
  export {PayloadEnvelopeInput} from "../blocks/payloadEnvelopeInput/index.js";
12
15
 
13
16
  export type SeenPayloadEnvelopeInputModules = {
17
+ config: ChainForkConfig;
18
+ clock: IClock;
14
19
  chainEvents: ChainEventEmitter;
15
20
  signal: AbortSignal;
16
21
  serializedCache: SerializedCache;
@@ -21,10 +26,19 @@ export type SeenPayloadEnvelopeInputModules = {
21
26
  /**
22
27
  * Cache for tracking PayloadEnvelopeInput instances, keyed by beacon block root.
23
28
  *
24
- * Created during block import when a block is processed.
25
- * Pruned on finalization and after payload is written to DB.
29
+ * Created during block import when a block is processed. Two pruning paths:
30
+ * - `prepareNextSlot` calls `pruneBelow(headParentSlot)` every slot once the head we'll build
31
+ * on is known.
32
+ * - `onFinalized` calls `pruneBelow(finalizedSlot)` on every finalization for bulk cleanup.
33
+ *
34
+ * Steady state (linear chain, healthy progression): the cache holds ~2 entries — the head
35
+ * (parent for next-slot production) and its parent (proposer-boost-reorg fallback). It can
36
+ * transiently hold more during forks, range-sync bursts, or when `prepareNextSlot` skips
37
+ * ticks; subsequent ticks settle it back.
26
38
  */
27
39
  export class SeenPayloadEnvelopeInput {
40
+ private readonly config: ChainForkConfig;
41
+ private readonly clock: IClock;
28
42
  private readonly chainEvents: ChainEventEmitter;
29
43
  private readonly signal: AbortSignal;
30
44
  private readonly serializedCache: SerializedCache;
@@ -32,7 +46,9 @@ export class SeenPayloadEnvelopeInput {
32
46
  private readonly logger?: Logger;
33
47
  private payloadInputs = new Map<RootHex, PayloadEnvelopeInput>();
34
48
 
35
- constructor({chainEvents, signal, serializedCache, metrics, logger}: SeenPayloadEnvelopeInputModules) {
49
+ constructor({config, clock, chainEvents, signal, serializedCache, metrics, logger}: SeenPayloadEnvelopeInputModules) {
50
+ this.config = config;
51
+ this.clock = clock;
36
52
  this.chainEvents = chainEvents;
37
53
  this.signal = signal;
38
54
  this.serializedCache = serializedCache;
@@ -58,23 +74,15 @@ export class SeenPayloadEnvelopeInput {
58
74
  }
59
75
 
60
76
  private onFinalized = (checkpoint: CheckpointWithHex): void => {
61
- // Prune all entries with slot < finalized slot
62
- const finalizedSlot = computeStartSlotAtEpoch(checkpoint.epoch);
63
- let deletedCount = 0;
64
- for (const [, input] of this.payloadInputs) {
65
- if (input.slot < finalizedSlot) {
66
- this.evictPayloadInput(input);
67
- deletedCount++;
68
- }
69
- }
70
- this.logger?.debug("SeenPayloadEnvelopeInput.onFinalized deleted cached entries", {deletedCount});
77
+ this.pruneBelow(computeStartSlotAtEpoch(checkpoint.epoch));
71
78
  };
72
79
 
73
- add(props: CreateFromBlockProps): PayloadEnvelopeInput {
80
+ add(props: Omit<CreateFromBlockProps, "daOutOfRange">): PayloadEnvelopeInput {
74
81
  if (this.payloadInputs.has(props.blockRootHex)) {
75
82
  throw new Error(`PayloadEnvelopeInput already exists for block ${props.blockRootHex}`);
76
83
  }
77
- const input = PayloadEnvelopeInput.createFromBlock(props);
84
+ const daOutOfRange = isDaOutOfRange(this.config, props.forkName, props.block.message.slot, this.clock.currentEpoch);
85
+ const input = PayloadEnvelopeInput.createFromBlock({...props, daOutOfRange});
78
86
  this.payloadInputs.set(props.blockRootHex, input);
79
87
  this.metrics?.seenCache.payloadEnvelopeInput.created.inc();
80
88
  return input;
@@ -88,17 +96,21 @@ export class SeenPayloadEnvelopeInput {
88
96
  return this.payloadInputs.get(blockRootHex)?.hasPayloadEnvelope() ?? false;
89
97
  }
90
98
 
91
- prune(blockRootHex: RootHex): void {
92
- const payloadInput = this.payloadInputs.get(blockRootHex);
93
- if (payloadInput) {
94
- this.evictPayloadInput(payloadInput);
95
- }
96
- }
97
-
98
99
  size(): number {
99
100
  return this.payloadInputs.size;
100
101
  }
101
102
 
103
+ pruneBelow(slot: Slot): void {
104
+ let deletedCount = 0;
105
+ for (const [, input] of this.payloadInputs) {
106
+ if (input.slot < slot) {
107
+ this.evictPayloadInput(input);
108
+ deletedCount++;
109
+ }
110
+ }
111
+ this.logger?.debug("SeenPayloadEnvelopeInput.pruneBelow deleted entries", {slot, deletedCount});
112
+ }
113
+
102
114
  private evictPayloadInput(payloadInput: PayloadEnvelopeInput): void {
103
115
  this.serializedCache.delete(payloadInput.getSerializedCacheKeys());
104
116
  this.payloadInputs.delete(payloadInput.blockRootHex);
@@ -0,0 +1,29 @@
1
+ import {Slot, ValidatorIndex} from "@lodestar/types";
2
+ import {MapDef} from "@lodestar/utils";
3
+
4
+ /**
5
+ * Tracks signed proposer preferences we've already seen per (proposal_slot, validator_index).
6
+ */
7
+ export class SeenProposerPreferences {
8
+ private readonly validatorIndexesBySlot = new MapDef<Slot, Set<ValidatorIndex>>(() => new Set<ValidatorIndex>());
9
+
10
+ isKnown(proposalSlot: Slot, validatorIndex: ValidatorIndex): boolean {
11
+ return this.validatorIndexesBySlot.get(proposalSlot)?.has(validatorIndex) === true;
12
+ }
13
+
14
+ add(proposalSlot: Slot, validatorIndex: ValidatorIndex): void {
15
+ this.validatorIndexesBySlot.getOrDefault(proposalSlot).add(validatorIndex);
16
+ }
17
+
18
+ /**
19
+ * Entries are only load-bearing while `proposal_slot > state.slot`. Once the slot has passed the
20
+ * `[IGNORE] proposal_slot > state.slot` gossip rule takes over, so drop them on each slot tick.
21
+ */
22
+ prune(currentSlot: Slot): void {
23
+ for (const slot of this.validatorIndexesBySlot.keys()) {
24
+ if (slot < currentSlot) {
25
+ this.validatorIndexesBySlot.delete(slot);
26
+ }
27
+ }
28
+ }
29
+ }
@@ -226,7 +226,10 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
226
226
  }
227
227
  sszTimer?.();
228
228
  const timer = this.metrics?.cpStateCache.stateReloadDuration.startTimer();
229
- const newCachedState = seedState.loadOtherState(stateBytes, validatorsBytes);
229
+ // preload validators and balances for faster state transition
230
+ const newCachedState = seedState.loadOtherState(stateBytes, validatorsBytes, {
231
+ preloadValidatorsAndBalances: true,
232
+ });
230
233
  // hashTreeRoot() calls the commit() inside
231
234
  // there is no modification inside the state, it's just that we want to compute and cache all roots
232
235
  const stateRoot = toRootHex(newCachedState.hashTreeRoot());
@@ -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,
@@ -76,6 +77,19 @@ async function validateExecutionPayloadBid(
76
77
  // `SignedProposerPreferences` associated with `bid.slot`.
77
78
  // TODO GLOAS: Implement this along with proposer preference
78
79
 
80
+ // [REJECT] The length of KZG commitments is less than or equal to the limitation defined in the
81
+ // consensus layer -- i.e. validate that
82
+ // `len(bid.blob_kzg_commitments) <= get_blob_parameters(compute_epoch_at_slot(bid.slot)).max_blobs_per_block`.
83
+ const blobKzgCommitmentsLen = bid.blobKzgCommitments.length;
84
+ const maxBlobsPerBlock = chain.config.getMaxBlobsPerBlock(computeEpochAtSlot(bid.slot));
85
+ if (blobKzgCommitmentsLen > maxBlobsPerBlock) {
86
+ throw new ExecutionPayloadBidError(GossipAction.REJECT, {
87
+ code: ExecutionPayloadBidErrorCode.TOO_MANY_KZG_COMMITMENTS,
88
+ blobKzgCommitmentsLen,
89
+ commitmentLimit: maxBlobsPerBlock,
90
+ });
91
+ }
92
+
79
93
  // [IGNORE] this is the first signed bid seen with a valid signature from the given builder for this slot.
80
94
  if (chain.seenExecutionPayloadBids.isKnown(bid.slot, bid.builderIndex)) {
81
95
  throw new ExecutionPayloadBidError(GossipAction.IGNORE, {
@@ -4,8 +4,8 @@ import {
4
4
  getExecutionPayloadEnvelopeSignatureSet,
5
5
  isStatePostGloas,
6
6
  } from "@lodestar/state-transition";
7
- import {gloas} from "@lodestar/types";
8
- import {toRootHex} from "@lodestar/utils";
7
+ import {gloas, ssz} from "@lodestar/types";
8
+ import {byteArrayEquals, toRootHex} from "@lodestar/utils";
9
9
  import {ExecutionPayloadEnvelopeError, ExecutionPayloadEnvelopeErrorCode, GossipAction} from "../errors/index.js";
10
10
  import {IBeaconChain} from "../index.js";
11
11
  import {RegenCaller} from "../regen/index.js";
@@ -53,7 +53,7 @@ async function validateExecutionPayloadEnvelope(
53
53
  throw new ExecutionPayloadEnvelopeError(GossipAction.IGNORE, {
54
54
  code: ExecutionPayloadEnvelopeErrorCode.ENVELOPE_ALREADY_KNOWN,
55
55
  blockRoot: blockRootHex,
56
- slot: envelope.slot,
56
+ slot: payload.slotNumber,
57
57
  });
58
58
  }
59
59
 
@@ -65,13 +65,13 @@ async function validateExecutionPayloadEnvelope(
65
65
  });
66
66
  }
67
67
 
68
- // [IGNORE] The envelope is from a slot greater than or equal to the latest finalized slot -- i.e. validate that `envelope.slot >= compute_start_slot_at_epoch(store.finalized_checkpoint.epoch)`
68
+ // [IGNORE] The envelope is from a slot greater than or equal to the latest finalized slot -- i.e. validate that `payload.slotNumber >= compute_start_slot_at_epoch(store.finalized_checkpoint.epoch)`
69
69
  const finalizedCheckpoint = chain.forkChoice.getFinalizedCheckpoint();
70
70
  const finalizedSlot = computeStartSlotAtEpoch(finalizedCheckpoint.epoch);
71
- if (envelope.slot < finalizedSlot) {
71
+ if (payload.slotNumber < finalizedSlot) {
72
72
  throw new ExecutionPayloadEnvelopeError(GossipAction.IGNORE, {
73
73
  code: ExecutionPayloadEnvelopeErrorCode.BELONG_TO_FINALIZED_BLOCK,
74
- envelopeSlot: envelope.slot,
74
+ envelopeSlot: payload.slotNumber,
75
75
  finalizedSlot,
76
76
  });
77
77
  }
@@ -80,11 +80,11 @@ async function validateExecutionPayloadEnvelope(
80
80
  // TODO GLOAS: implement this. Technically if we cannot get proto block from fork choice,
81
81
  // it is possible that the block didn't pass the validation
82
82
 
83
- // [REJECT] `block.slot` equals `envelope.slot`.
84
- if (block.slot !== envelope.slot) {
83
+ // [REJECT] `block.slot` equals `payload.slotNumber`.
84
+ if (block.slot !== payload.slotNumber) {
85
85
  throw new ExecutionPayloadEnvelopeError(GossipAction.REJECT, {
86
86
  code: ExecutionPayloadEnvelopeErrorCode.SLOT_MISMATCH,
87
- envelopeSlot: envelope.slot,
87
+ envelopeSlot: payload.slotNumber,
88
88
  blockSlot: block.slot,
89
89
  });
90
90
  }
@@ -107,6 +107,16 @@ async function validateExecutionPayloadEnvelope(
107
107
  });
108
108
  }
109
109
 
110
+ // [REJECT] `hash_tree_root(envelope.execution_requests) == bid.execution_requests_root`
111
+ const requestsRoot = ssz.electra.ExecutionRequests.hashTreeRoot(envelope.executionRequests);
112
+ if (!byteArrayEquals(requestsRoot, payloadInput.getBid().executionRequestsRoot)) {
113
+ throw new ExecutionPayloadEnvelopeError(GossipAction.REJECT, {
114
+ code: ExecutionPayloadEnvelopeErrorCode.EXECUTION_REQUESTS_ROOT_MISMATCH,
115
+ envelopeRequestsRoot: toRootHex(requestsRoot),
116
+ bidRequestsRoot: toRootHex(payloadInput.getBid().executionRequestsRoot),
117
+ });
118
+ }
119
+
110
120
  // Get the block state to verify the builder's signature.
111
121
  const blockState = await chain.regen
112
122
  .getState(block.stateRoot, RegenCaller.validateGossipPayloadEnvelope)
@@ -114,7 +124,7 @@ async function validateExecutionPayloadEnvelope(
114
124
  throw new ExecutionPayloadEnvelopeError(GossipAction.IGNORE, {
115
125
  code: ExecutionPayloadEnvelopeErrorCode.UNKNOWN_BLOCK_STATE,
116
126
  blockRoot: blockRootHex,
117
- slot: envelope.slot,
127
+ slot: payload.slotNumber,
118
128
  });
119
129
  });
120
130
  if (!isStatePostGloas(blockState)) {
@@ -0,0 +1,91 @@
1
+ import {SLOTS_PER_EPOCH} from "@lodestar/params";
2
+ import {
3
+ computeEpochAtSlot,
4
+ createSingleSignatureSetFromComponents,
5
+ getProposerPreferencesSigningRoot,
6
+ isStatePostGloas,
7
+ } from "@lodestar/state-transition";
8
+ import {gloas} from "@lodestar/types";
9
+ import {GossipAction, ProposerPreferencesError, ProposerPreferencesErrorCode} from "../errors/index.js";
10
+ import {IBeaconChain} from "../index.js";
11
+ import {RegenCaller} from "../regen/index.js";
12
+
13
+ /**
14
+ * Validates a gossiped `SignedProposerPreferences` per
15
+ * https://github.com/ethereum/consensus-specs/blob/master/specs/gloas/p2p-interface.md#proposer_preferences
16
+ */
17
+ export async function validateGossipProposerPreferences(
18
+ chain: IBeaconChain,
19
+ signedProposerPreferences: gloas.SignedProposerPreferences
20
+ ): Promise<void> {
21
+ const preferences = signedProposerPreferences.message;
22
+ const {proposalSlot, validatorIndex} = preferences;
23
+ const proposalEpoch = computeEpochAtSlot(proposalSlot);
24
+
25
+ // [IGNORE] `preferences.proposal_slot` is in the current or next epoch.
26
+ const currentEpoch = chain.clock.currentEpoch;
27
+ if (proposalEpoch < currentEpoch || proposalEpoch > currentEpoch + 1) {
28
+ throw new ProposerPreferencesError(GossipAction.IGNORE, {
29
+ code: ProposerPreferencesErrorCode.INVALID_EPOCH,
30
+ proposalSlot,
31
+ currentEpoch,
32
+ });
33
+ }
34
+
35
+ // [IGNORE] `preferences.proposal_slot` has not already passed.
36
+ const currentSlot = chain.clock.currentSlot;
37
+ if (proposalSlot <= currentSlot) {
38
+ throw new ProposerPreferencesError(GossipAction.IGNORE, {
39
+ code: ProposerPreferencesErrorCode.PROPOSAL_SLOT_PASSED,
40
+ proposalSlot,
41
+ currentSlot,
42
+ });
43
+ }
44
+
45
+ const state = await chain.getHeadStateAtCurrentEpoch(RegenCaller.validateGossipProposerPreferences);
46
+ if (!isStatePostGloas(state)) {
47
+ throw new Error(`Expected gloas+ state for proposer preferences validation, got fork=${state.forkName}`);
48
+ }
49
+
50
+ // [REJECT] `preferences.validator_index` is present at the correct slot in the current or next
51
+ // epoch's portion of `state.proposer_lookahead` — i.e. `is_valid_proposal_slot(state, preferences)`
52
+ // returns True.
53
+ const epochOffset = proposalEpoch - state.epoch;
54
+ const proposers = epochOffset === 0 ? state.currentProposers : state.nextProposers;
55
+ const expectedProposer = proposers[proposalSlot % SLOTS_PER_EPOCH];
56
+ if (epochOffset < 0 || epochOffset > 1 || expectedProposer !== validatorIndex) {
57
+ throw new ProposerPreferencesError(GossipAction.REJECT, {
58
+ code: ProposerPreferencesErrorCode.INVALID_PROPOSER,
59
+ proposalSlot,
60
+ validatorIndex,
61
+ });
62
+ }
63
+
64
+ // [IGNORE] The `signed_proposer_preferences` is the first valid message received from the validator
65
+ // with index `preferences.validator_index` and the given slot `preferences.proposal_slot`.
66
+ if (chain.seenProposerPreferences.isKnown(proposalSlot, validatorIndex)) {
67
+ throw new ProposerPreferencesError(GossipAction.IGNORE, {
68
+ code: ProposerPreferencesErrorCode.ALREADY_KNOWN,
69
+ proposalSlot,
70
+ validatorIndex,
71
+ });
72
+ }
73
+
74
+ // [REJECT] `signed_proposer_preferences.signature` is valid with respect to the validator's public key.
75
+ const signatureSet = createSingleSignatureSetFromComponents(
76
+ chain.pubkeyCache.getOrThrow(validatorIndex),
77
+ getProposerPreferencesSigningRoot(chain.config, preferences),
78
+ signedProposerPreferences.signature
79
+ );
80
+
81
+ if (!(await chain.bls.verifySignatureSets([signatureSet], {batchable: true}))) {
82
+ throw new ProposerPreferencesError(GossipAction.REJECT, {
83
+ code: ProposerPreferencesErrorCode.INVALID_SIGNATURE,
84
+ proposalSlot,
85
+ validatorIndex,
86
+ });
87
+ }
88
+
89
+ // Valid
90
+ chain.seenProposerPreferences.add(proposalSlot, validatorIndex);
91
+ }
@@ -19,7 +19,7 @@ export class ExecutionPayloadEnvelopeArchiveRepository extends Repository<Slot,
19
19
  * Id is the slot from the envelope
20
20
  */
21
21
  getId(value: gloas.SignedExecutionPayloadEnvelope): Slot {
22
- return value.message.slot;
22
+ return value.message.payload.slotNumber;
23
23
  }
24
24
 
25
25
  encodeKey(id: Slot): Uint8Array {
@@ -216,13 +216,15 @@ export class ExecutionEngineHttp implements IExecutionEngine {
216
216
  executionRequests?: ExecutionRequests
217
217
  ): Promise<ExecutePayloadResponse> {
218
218
  const method =
219
- ForkSeq[fork] >= ForkSeq.electra
220
- ? "engine_newPayloadV4"
221
- : ForkSeq[fork] >= ForkSeq.deneb
222
- ? "engine_newPayloadV3"
223
- : ForkSeq[fork] >= ForkSeq.capella
224
- ? "engine_newPayloadV2"
225
- : "engine_newPayloadV1";
219
+ ForkSeq[fork] >= ForkSeq.gloas
220
+ ? "engine_newPayloadV5"
221
+ : ForkSeq[fork] >= ForkSeq.electra
222
+ ? "engine_newPayloadV4"
223
+ : ForkSeq[fork] >= ForkSeq.deneb
224
+ ? "engine_newPayloadV3"
225
+ : ForkSeq[fork] >= ForkSeq.capella
226
+ ? "engine_newPayloadV2"
227
+ : "engine_newPayloadV1";
226
228
 
227
229
  const serializedExecutionPayload = serializeExecutionPayload(fork, executionPayload);
228
230
 
@@ -244,7 +246,7 @@ export class ExecutionEngineHttp implements IExecutionEngine {
244
246
  }
245
247
  const serializedExecutionRequests = serializeExecutionRequests(executionRequests);
246
248
  engineRequest = {
247
- method: "engine_newPayloadV4",
249
+ method: ForkSeq[fork] >= ForkSeq.gloas ? "engine_newPayloadV5" : "engine_newPayloadV4",
248
250
  params: [
249
251
  serializedExecutionPayload,
250
252
  serializedVersionedHashes,
@@ -348,11 +350,13 @@ export class ExecutionEngineHttp implements IExecutionEngine {
348
350
  // Once on capella, should this need to be permanently switched to v2 when payload attrs
349
351
  // not provided
350
352
  const method =
351
- ForkSeq[fork] >= ForkSeq.deneb
352
- ? "engine_forkchoiceUpdatedV3"
353
- : ForkSeq[fork] >= ForkSeq.capella
354
- ? "engine_forkchoiceUpdatedV2"
355
- : "engine_forkchoiceUpdatedV1";
353
+ ForkSeq[fork] >= ForkSeq.gloas
354
+ ? "engine_forkchoiceUpdatedV4"
355
+ : ForkSeq[fork] >= ForkSeq.deneb
356
+ ? "engine_forkchoiceUpdatedV3"
357
+ : ForkSeq[fork] >= ForkSeq.capella
358
+ ? "engine_forkchoiceUpdatedV2"
359
+ : "engine_forkchoiceUpdatedV1";
356
360
  const payloadAttributesRpc = payloadAttributes ? serializePayloadAttributes(payloadAttributes) : undefined;
357
361
  // If we are just fcUing and not asking execution for payload, retry is not required
358
362
  // and we can move on, as the next fcU will be issued soon on the new slot
@@ -438,9 +442,12 @@ export class ExecutionEngineHttp implements IExecutionEngine {
438
442
  case ForkName.electra:
439
443
  method = "engine_getPayloadV4";
440
444
  break;
441
- default:
445
+ case ForkName.fulu:
442
446
  method = "engine_getPayloadV5";
443
447
  break;
448
+ default:
449
+ method = "engine_getPayloadV6";
450
+ break;
444
451
  }
445
452
  const payloadResponse = await this.rpc.fetchWithRetries<
446
453
  EngineApiRpcReturnTypes[typeof method],
@@ -87,6 +87,7 @@ export type PayloadAttributes = {
87
87
  suggestedFeeRecipient: string;
88
88
  withdrawals?: capella.Withdrawal[];
89
89
  parentBeaconBlockRoot?: Uint8Array;
90
+ slotNumber?: number; // EIP-7843
90
91
  };
91
92
 
92
93
  export type VersionedHashes = Uint8Array[];
@@ -11,7 +11,7 @@ import {
11
11
  SLOTS_PER_EPOCH,
12
12
  } from "@lodestar/params";
13
13
  import {computeTimeAtSlot} from "@lodestar/state-transition";
14
- import {ExecutionPayload, RootHex, bellatrix, deneb, ssz} from "@lodestar/types";
14
+ import {ExecutionPayload, RootHex, bellatrix, deneb, gloas, ssz} from "@lodestar/types";
15
15
  import {fromHex, toRootHex} from "@lodestar/utils";
16
16
  import {ZERO_HASH_HEX} from "../../constants/index.js";
17
17
  import {INTEROP_BLOCK_HASH} from "../../node/utils/interop/state.js";
@@ -132,14 +132,17 @@ export class ExecutionEngineMockBackend implements JsonRpcBackend {
132
132
  engine_newPayloadV2: this.notifyNewPayload.bind(this),
133
133
  engine_newPayloadV3: this.notifyNewPayload.bind(this),
134
134
  engine_newPayloadV4: this.notifyNewPayload.bind(this),
135
+ engine_newPayloadV5: this.notifyNewPayload.bind(this),
135
136
  engine_forkchoiceUpdatedV1: this.notifyForkchoiceUpdate.bind(this),
136
137
  engine_forkchoiceUpdatedV2: this.notifyForkchoiceUpdate.bind(this),
137
138
  engine_forkchoiceUpdatedV3: this.notifyForkchoiceUpdate.bind(this),
139
+ engine_forkchoiceUpdatedV4: this.notifyForkchoiceUpdate.bind(this),
138
140
  engine_getPayloadV1: this.getPayloadV1.bind(this),
139
141
  engine_getPayloadV2: this.getPayloadV5.bind(this),
140
142
  engine_getPayloadV3: this.getPayloadV5.bind(this),
141
143
  engine_getPayloadV4: this.getPayloadV5.bind(this),
142
144
  engine_getPayloadV5: this.getPayloadV5.bind(this),
145
+ engine_getPayloadV6: this.getPayloadV5.bind(this),
143
146
  engine_getPayloadBodiesByHashV1: this.getPayloadBodiesByHash.bind(this),
144
147
  engine_getPayloadBodiesByRangeV1: this.getPayloadBodiesByRange.bind(this),
145
148
  engine_getClientVersionV1: this.getClientVersionV1.bind(this),
@@ -379,6 +382,10 @@ export class ExecutionEngineMockBackend implements JsonRpcBackend {
379
382
  (executionPayload as ExecutionPayload<ForkPostCapella>).withdrawals = ssz.capella.Withdrawals.defaultValue();
380
383
  }
381
384
 
385
+ if (ForkSeq[fork] >= ForkSeq.gloas && payloadAttributes.slotNumber != null) {
386
+ (executionPayload as gloas.ExecutionPayload).slotNumber = payloadAttributes.slotNumber;
387
+ }
388
+
382
389
  this.preparingPayloads.set(payloadId, {
383
390
  executionPayload: serializeExecutionPayload(fork, executionPayload),
384
391
  blobsBundle: serializeBlobsBundle({