@lodestar/beacon-node 1.43.0-dev.0bc48d3b54 → 1.43.0-dev.1213f9c92d

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 (291) 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 -14
  73. package/lib/chain/emitter.d.ts.map +1 -1
  74. package/lib/chain/emitter.js +0 -4
  75. package/lib/chain/emitter.js.map +1 -1
  76. package/lib/chain/errors/blockError.d.ts +8 -1
  77. package/lib/chain/errors/blockError.d.ts.map +1 -1
  78. package/lib/chain/errors/blockError.js +2 -0
  79. package/lib/chain/errors/blockError.js.map +1 -1
  80. package/lib/chain/errors/executionPayloadBid.d.ts +5 -0
  81. package/lib/chain/errors/executionPayloadBid.d.ts.map +1 -1
  82. package/lib/chain/errors/executionPayloadBid.js +1 -0
  83. package/lib/chain/errors/executionPayloadBid.js.map +1 -1
  84. package/lib/chain/errors/executionPayloadEnvelope.d.ts +5 -0
  85. package/lib/chain/errors/executionPayloadEnvelope.d.ts.map +1 -1
  86. package/lib/chain/errors/executionPayloadEnvelope.js +1 -0
  87. package/lib/chain/errors/executionPayloadEnvelope.js.map +1 -1
  88. package/lib/chain/errors/index.d.ts +1 -0
  89. package/lib/chain/errors/index.d.ts.map +1 -1
  90. package/lib/chain/errors/index.js +1 -0
  91. package/lib/chain/errors/index.js.map +1 -1
  92. package/lib/chain/errors/proposerPreferences.d.ts +33 -0
  93. package/lib/chain/errors/proposerPreferences.d.ts.map +1 -0
  94. package/lib/chain/errors/proposerPreferences.js +13 -0
  95. package/lib/chain/errors/proposerPreferences.js.map +1 -0
  96. package/lib/chain/forkChoice/index.d.ts.map +1 -1
  97. package/lib/chain/forkChoice/index.js +5 -17
  98. package/lib/chain/forkChoice/index.js.map +1 -1
  99. package/lib/chain/interface.d.ts +7 -5
  100. package/lib/chain/interface.d.ts.map +1 -1
  101. package/lib/chain/interface.js.map +1 -1
  102. package/lib/chain/opPools/payloadAttestationPool.d.ts +3 -2
  103. package/lib/chain/opPools/payloadAttestationPool.d.ts.map +1 -1
  104. package/lib/chain/opPools/payloadAttestationPool.js +26 -4
  105. package/lib/chain/opPools/payloadAttestationPool.js.map +1 -1
  106. package/lib/chain/prepareNextSlot.d.ts.map +1 -1
  107. package/lib/chain/prepareNextSlot.js +31 -13
  108. package/lib/chain/prepareNextSlot.js.map +1 -1
  109. package/lib/chain/produceBlock/produceBlockBody.d.ts +10 -1
  110. package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
  111. package/lib/chain/produceBlock/produceBlockBody.js +55 -15
  112. package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
  113. package/lib/chain/regen/interface.d.ts +1 -0
  114. package/lib/chain/regen/interface.d.ts.map +1 -1
  115. package/lib/chain/regen/interface.js +1 -0
  116. package/lib/chain/regen/interface.js.map +1 -1
  117. package/lib/chain/seenCache/index.d.ts +1 -0
  118. package/lib/chain/seenCache/index.d.ts.map +1 -1
  119. package/lib/chain/seenCache/index.js +1 -0
  120. package/lib/chain/seenCache/index.js.map +1 -1
  121. package/lib/chain/seenCache/seenPayloadEnvelopeInput.d.ts +19 -6
  122. package/lib/chain/seenCache/seenPayloadEnvelopeInput.d.ts.map +1 -1
  123. package/lib/chain/seenCache/seenPayloadEnvelopeInput.js +28 -20
  124. package/lib/chain/seenCache/seenPayloadEnvelopeInput.js.map +1 -1
  125. package/lib/chain/seenCache/seenProposerPreferences.d.ts +15 -0
  126. package/lib/chain/seenCache/seenProposerPreferences.d.ts.map +1 -0
  127. package/lib/chain/seenCache/seenProposerPreferences.js +25 -0
  128. package/lib/chain/seenCache/seenProposerPreferences.js.map +1 -0
  129. package/lib/chain/validation/block.d.ts.map +1 -1
  130. package/lib/chain/validation/block.js +1 -0
  131. package/lib/chain/validation/block.js.map +1 -1
  132. package/lib/chain/validation/executionPayloadBid.d.ts.map +1 -1
  133. package/lib/chain/validation/executionPayloadBid.js +13 -1
  134. package/lib/chain/validation/executionPayloadBid.js.map +1 -1
  135. package/lib/chain/validation/executionPayloadEnvelope.d.ts.map +1 -1
  136. package/lib/chain/validation/executionPayloadEnvelope.js +19 -9
  137. package/lib/chain/validation/executionPayloadEnvelope.js.map +1 -1
  138. package/lib/chain/validation/proposerPreferences.d.ts +8 -0
  139. package/lib/chain/validation/proposerPreferences.d.ts.map +1 -0
  140. package/lib/chain/validation/proposerPreferences.js +69 -0
  141. package/lib/chain/validation/proposerPreferences.js.map +1 -0
  142. package/lib/db/repositories/executionPayloadEnvelopeArchive.js +1 -1
  143. package/lib/db/repositories/executionPayloadEnvelopeArchive.js.map +1 -1
  144. package/lib/execution/engine/mock.d.ts.map +1 -1
  145. package/lib/execution/engine/mock.js +3 -0
  146. package/lib/execution/engine/mock.js.map +1 -1
  147. package/lib/metrics/metrics/lodestar.d.ts +1 -0
  148. package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
  149. package/lib/metrics/metrics/lodestar.js +4 -0
  150. package/lib/metrics/metrics/lodestar.js.map +1 -1
  151. package/lib/network/gossip/interface.d.ts +7 -1
  152. package/lib/network/gossip/interface.d.ts.map +1 -1
  153. package/lib/network/gossip/interface.js +1 -0
  154. package/lib/network/gossip/interface.js.map +1 -1
  155. package/lib/network/gossip/scoringParameters.d.ts.map +1 -1
  156. package/lib/network/gossip/scoringParameters.js +12 -1
  157. package/lib/network/gossip/scoringParameters.js.map +1 -1
  158. package/lib/network/gossip/topic.d.ts +28 -748
  159. package/lib/network/gossip/topic.d.ts.map +1 -1
  160. package/lib/network/gossip/topic.js +6 -0
  161. package/lib/network/gossip/topic.js.map +1 -1
  162. package/lib/network/interface.d.ts +1 -0
  163. package/lib/network/interface.d.ts.map +1 -1
  164. package/lib/network/network.d.ts +1 -0
  165. package/lib/network/network.d.ts.map +1 -1
  166. package/lib/network/network.js +6 -1
  167. package/lib/network/network.js.map +1 -1
  168. package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
  169. package/lib/network/processor/gossipHandlers.js +17 -19
  170. package/lib/network/processor/gossipHandlers.js.map +1 -1
  171. package/lib/network/processor/gossipQueues/index.d.ts.map +1 -1
  172. package/lib/network/processor/gossipQueues/index.js +5 -0
  173. package/lib/network/processor/gossipQueues/index.js.map +1 -1
  174. package/lib/network/processor/index.d.ts.map +1 -1
  175. package/lib/network/processor/index.js +6 -5
  176. package/lib/network/processor/index.js.map +1 -1
  177. package/lib/network/reqresp/handlers/beaconBlocksByRange.d.ts.map +1 -1
  178. package/lib/network/reqresp/handlers/beaconBlocksByRange.js +14 -6
  179. package/lib/network/reqresp/handlers/beaconBlocksByRange.js.map +1 -1
  180. package/lib/network/reqresp/handlers/blobSidecarsByRange.d.ts.map +1 -1
  181. package/lib/network/reqresp/handlers/blobSidecarsByRange.js +11 -5
  182. package/lib/network/reqresp/handlers/blobSidecarsByRange.js.map +1 -1
  183. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.d.ts.map +1 -1
  184. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js +17 -5
  185. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js.map +1 -1
  186. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.d.ts.map +1 -1
  187. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.js +7 -4
  188. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.js.map +1 -1
  189. package/lib/node/notifier.js +7 -1
  190. package/lib/node/notifier.js.map +1 -1
  191. package/lib/sync/range/batch.d.ts +23 -2
  192. package/lib/sync/range/batch.d.ts.map +1 -1
  193. package/lib/sync/range/batch.js +84 -33
  194. package/lib/sync/range/batch.js.map +1 -1
  195. package/lib/sync/range/chain.d.ts +6 -2
  196. package/lib/sync/range/chain.d.ts.map +1 -1
  197. package/lib/sync/range/chain.js +26 -7
  198. package/lib/sync/range/chain.js.map +1 -1
  199. package/lib/sync/range/range.d.ts.map +1 -1
  200. package/lib/sync/range/range.js +17 -6
  201. package/lib/sync/range/range.js.map +1 -1
  202. package/lib/sync/types.d.ts +34 -0
  203. package/lib/sync/types.d.ts.map +1 -1
  204. package/lib/sync/types.js +34 -0
  205. package/lib/sync/types.js.map +1 -1
  206. package/lib/sync/unknownBlock.d.ts +22 -1
  207. package/lib/sync/unknownBlock.d.ts.map +1 -1
  208. package/lib/sync/unknownBlock.js +602 -53
  209. package/lib/sync/unknownBlock.js.map +1 -1
  210. package/lib/sync/utils/downloadByRange.d.ts +46 -10
  211. package/lib/sync/utils/downloadByRange.d.ts.map +1 -1
  212. package/lib/sync/utils/downloadByRange.js +147 -24
  213. package/lib/sync/utils/downloadByRange.js.map +1 -1
  214. package/lib/sync/utils/downloadByRoot.d.ts.map +1 -1
  215. package/lib/sync/utils/downloadByRoot.js +6 -2
  216. package/lib/sync/utils/downloadByRoot.js.map +1 -1
  217. package/lib/sync/utils/pendingBlocksTree.d.ts +0 -1
  218. package/lib/sync/utils/pendingBlocksTree.d.ts.map +1 -1
  219. package/lib/sync/utils/pendingBlocksTree.js +0 -9
  220. package/lib/sync/utils/pendingBlocksTree.js.map +1 -1
  221. package/lib/util/sszBytes.d.ts.map +1 -1
  222. package/lib/util/sszBytes.js +16 -3
  223. package/lib/util/sszBytes.js.map +1 -1
  224. package/package.json +16 -15
  225. package/src/api/impl/beacon/blocks/index.ts +9 -9
  226. package/src/api/impl/beacon/pool/index.ts +83 -1
  227. package/src/api/impl/beacon/state/utils.ts +2 -2
  228. package/src/api/impl/lodestar/index.ts +1 -1
  229. package/src/api/impl/validator/index.ts +80 -4
  230. package/src/chain/archiveStore/archiveStore.ts +5 -5
  231. package/src/chain/archiveStore/interface.ts +4 -4
  232. package/src/chain/archiveStore/strategies/frequencyStateArchiveStrategy.ts +4 -4
  233. package/src/chain/archiveStore/utils/archiveBlocks.ts +153 -94
  234. package/src/chain/blocks/importBlock.ts +3 -2
  235. package/src/chain/blocks/importExecutionPayload.ts +107 -101
  236. package/src/chain/blocks/index.ts +54 -15
  237. package/src/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.ts +5 -1
  238. package/src/chain/blocks/payloadEnvelopeInput/types.ts +1 -0
  239. package/src/chain/blocks/payloadEnvelopeProcessor.ts +2 -2
  240. package/src/chain/blocks/types.ts +14 -25
  241. package/src/chain/blocks/utils/chainSegment.ts +106 -17
  242. package/src/chain/blocks/verifyBlock.ts +68 -9
  243. package/src/chain/blocks/verifyBlocksSanityChecks.ts +16 -7
  244. package/src/chain/blocks/verifyExecutionPayloadEnvelope.ts +129 -0
  245. package/src/chain/blocks/verifyPayloadsDataAvailability.ts +7 -4
  246. package/src/chain/blocks/writePayloadEnvelopeInputToDb.ts +9 -18
  247. package/src/chain/chain.ts +38 -19
  248. package/src/chain/emitter.ts +3 -14
  249. package/src/chain/errors/blockError.ts +4 -1
  250. package/src/chain/errors/executionPayloadBid.ts +6 -0
  251. package/src/chain/errors/executionPayloadEnvelope.ts +6 -0
  252. package/src/chain/errors/index.ts +1 -0
  253. package/src/chain/errors/proposerPreferences.ts +39 -0
  254. package/src/chain/forkChoice/index.ts +2 -22
  255. package/src/chain/interface.ts +11 -3
  256. package/src/chain/opPools/payloadAttestationPool.ts +29 -8
  257. package/src/chain/prepareNextSlot.ts +36 -14
  258. package/src/chain/produceBlock/produceBlockBody.ts +64 -14
  259. package/src/chain/regen/interface.ts +1 -0
  260. package/src/chain/seenCache/index.ts +1 -0
  261. package/src/chain/seenCache/seenPayloadEnvelopeInput.ts +35 -23
  262. package/src/chain/seenCache/seenProposerPreferences.ts +29 -0
  263. package/src/chain/validation/block.ts +1 -0
  264. package/src/chain/validation/executionPayloadBid.ts +14 -0
  265. package/src/chain/validation/executionPayloadEnvelope.ts +20 -10
  266. package/src/chain/validation/proposerPreferences.ts +91 -0
  267. package/src/db/repositories/executionPayloadEnvelopeArchive.ts +1 -1
  268. package/src/execution/engine/mock.ts +5 -1
  269. package/src/metrics/metrics/lodestar.ts +4 -0
  270. package/src/network/gossip/interface.ts +6 -0
  271. package/src/network/gossip/scoringParameters.ts +14 -1
  272. package/src/network/gossip/topic.ts +6 -0
  273. package/src/network/interface.ts +1 -0
  274. package/src/network/network.ts +12 -1
  275. package/src/network/processor/gossipHandlers.ts +26 -20
  276. package/src/network/processor/gossipQueues/index.ts +5 -0
  277. package/src/network/processor/index.ts +6 -5
  278. package/src/network/reqresp/handlers/beaconBlocksByRange.ts +14 -6
  279. package/src/network/reqresp/handlers/blobSidecarsByRange.ts +11 -5
  280. package/src/network/reqresp/handlers/dataColumnSidecarsByRange.ts +17 -5
  281. package/src/network/reqresp/handlers/executionPayloadEnvelopesByRange.ts +7 -4
  282. package/src/node/notifier.ts +8 -1
  283. package/src/sync/range/batch.ts +142 -38
  284. package/src/sync/range/chain.ts +37 -9
  285. package/src/sync/range/range.ts +18 -6
  286. package/src/sync/types.ts +72 -0
  287. package/src/sync/unknownBlock.ts +760 -57
  288. package/src/sync/utils/downloadByRange.ts +256 -39
  289. package/src/sync/utils/downloadByRoot.ts +12 -2
  290. package/src/sync/utils/pendingBlocksTree.ts +0 -15
  291. 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,25 @@ 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
- ? currentState.latestExecutionPayloadBid.blockHash
218
- : currentState.latestExecutionPayloadBid.parentBlockHash;
217
+ let parentBlockHash: Bytes32;
218
+ let parentExecutionRequests: electra.ExecutionRequests;
219
+ // Apply parent payload once here as it's reused by EL prep and voluntary exit filtering below
220
+ let stateAfterParentPayload: IBeaconStateViewBellatrix = currentState;
221
+ const isExtendingPayload = this.forkChoice.shouldExtendPayload(toRootHex(parentBlockRoot));
222
+ if (isExtendingPayload) {
223
+ parentBlockHash = currentState.latestExecutionPayloadBid.blockHash;
224
+ parentExecutionRequests = await this.getParentExecutionRequests(parentBlock.slot, parentBlock.blockRoot);
225
+ stateAfterParentPayload = currentState.withParentPayloadApplied(parentExecutionRequests);
226
+ } else {
227
+ parentBlockHash = currentState.latestExecutionPayloadBid.parentBlockHash;
228
+ // At gloas genesis the committed bid has no prior EL block to reference
229
+ // (`bid.parentBlockHash` is zero). Fall back to `bid.blockHash` (= eth1 genesis hash) so the
230
+ // FCU to the EL carries a valid head. Post-genesis bids always reference a non-zero parent.
231
+ if (byteArrayEquals(parentBlockHash, ZERO_HASH)) {
232
+ parentBlockHash = currentState.latestExecutionPayloadBid.blockHash;
233
+ }
234
+ parentExecutionRequests = ssz.electra.ExecutionRequests.defaultValue();
235
+ }
219
236
  const prepareRes = await prepareExecutionPayload(
220
237
  this,
221
238
  this.logger,
@@ -224,7 +241,7 @@ export async function produceBlockBody<T extends BlockType>(
224
241
  parentBlockHash,
225
242
  safeBlockHash,
226
243
  finalizedBlockHash ?? ZERO_HASH_HEX,
227
- currentState,
244
+ stateAfterParentPayload,
228
245
  feeRecipient
229
246
  );
230
247
 
@@ -269,6 +286,7 @@ export async function produceBlockBody<T extends BlockType>(
269
286
  value: 0,
270
287
  executionPayment: 0,
271
288
  blobKzgCommitments: blobsBundle.commitments,
289
+ executionRequestsRoot: ssz.electra.ExecutionRequests.hashTreeRoot(executionRequests),
272
290
  };
273
291
  const signedBid: gloas.SignedExecutionPayloadBid = {
274
292
  message: bid,
@@ -278,8 +296,19 @@ export async function produceBlockBody<T extends BlockType>(
278
296
  const commonBlockBody = await commonBlockBodyPromise;
279
297
  const gloasBody = Object.assign({}, commonBlockBody) as gloas.BeaconBlockBody;
280
298
  gloasBody.signedExecutionPayloadBid = signedBid;
281
- // TODO GLOAS: Get payload attestations from pool for previous slot
282
- gloasBody.payloadAttestations = [];
299
+ gloasBody.payloadAttestations = this.payloadAttestationPool.getPayloadAttestationsForBlock(
300
+ parentBlock.blockRoot,
301
+ blockSlot - 1
302
+ );
303
+ gloasBody.parentExecutionRequests = parentExecutionRequests;
304
+ // Drop voluntary exits that parent_execution_requests have invalidated (e.g. a withdrawal
305
+ // request initiating an exit on the same validator). Op pool selected against the unapplied
306
+ // state, so re-validate against the post-apply state to avoid producing an invalid block.
307
+ if (isExtendingPayload && commonBlockBody.voluntaryExits.length > 0) {
308
+ gloasBody.voluntaryExits = commonBlockBody.voluntaryExits.filter((signedVoluntaryExit) =>
309
+ stateAfterParentPayload.isValidVoluntaryExit(signedVoluntaryExit, false)
310
+ );
311
+ }
283
312
  blockBody = gloasBody as AssembledBodyType<T>;
284
313
 
285
314
  // Store execution payload data required to construct execution payload envelope later
@@ -615,6 +644,10 @@ export async function prepareExecutionPayload(
615
644
  parentBlockHash: Bytes32,
616
645
  safeBlockHash: RootHex,
617
646
  finalizedBlockHash: RootHex,
647
+ /**
648
+ * Post-gloas, when extending a full parent, callers must apply
649
+ * parent execution payload first (see `withParentPayloadApplied`).
650
+ */
618
651
  state: IBeaconStateViewBellatrix,
619
652
  suggestedFeeRecipient: string
620
653
  ): Promise<{prepType: PayloadPreparationType; payloadId: PayloadId}> {
@@ -712,6 +745,10 @@ export function getPayloadAttributesForSSE(
712
745
  parentBlockHash,
713
746
  feeRecipient,
714
747
  }: {
748
+ /**
749
+ * Post-gloas, when extending a full parent, callers must apply
750
+ * parent execution payload first (see `withParentPayloadApplied`).
751
+ */
715
752
  prepareState: IBeaconStateViewBellatrix;
716
753
  prepareSlot: Slot;
717
754
  parentBlockRoot: Root;
@@ -764,6 +801,10 @@ function preparePayloadAttributes(
764
801
  parentBlockHash,
765
802
  feeRecipient,
766
803
  }: {
804
+ /**
805
+ * Post-gloas, when extending a full parent, callers must apply
806
+ * parent execution payload first (see `withParentPayloadApplied`).
807
+ */
767
808
  prepareState: IBeaconStateViewBellatrix;
768
809
  prepareSlot: Slot;
769
810
  parentBlockRoot: Root;
@@ -786,13 +827,22 @@ function preparePayloadAttributes(
786
827
 
787
828
  if (isStatePostGloas(prepareState)) {
788
829
  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;
830
+ if (isExtendingPayload) {
831
+ // applyParentExecutionPayload sets latestBlockHash = parentBid.blockHash, so a mismatch
832
+ // here means the caller did not apply parent payload to prepareState
833
+ if (!byteArrayEquals(prepareState.latestBlockHash, prepareState.latestExecutionPayloadBid.blockHash)) {
834
+ throw new Error("Expected state with parent execution payload applied for withdrawals");
835
+ }
836
+ (payloadAttributes as capella.SSEPayloadAttributes["payloadAttributes"]).withdrawals =
837
+ prepareState.getExpectedWithdrawals().expectedWithdrawals;
838
+ } else {
839
+ // When the parent block is empty, state.payloadExpectedWithdrawals holds a batch
840
+ // already deducted from CL balances but never credited on the EL (the envelope
841
+ // was not delivered). The next payload must carry those same withdrawals to
842
+ // restore CL/EL consistency, otherwise validators permanently lose that balance.
843
+ (payloadAttributes as capella.SSEPayloadAttributes["payloadAttributes"]).withdrawals =
844
+ prepareState.payloadExpectedWithdrawals;
845
+ }
796
846
  } else {
797
847
  // withdrawals logic is now fork aware as it changes on electra fork post capella
798
848
  (payloadAttributes as capella.SSEPayloadAttributes["payloadAttributes"]).withdrawals =
@@ -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
+ }
@@ -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 {
@@ -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";
@@ -382,6 +382,10 @@ export class ExecutionEngineMockBackend implements JsonRpcBackend {
382
382
  (executionPayload as ExecutionPayload<ForkPostCapella>).withdrawals = ssz.capella.Withdrawals.defaultValue();
383
383
  }
384
384
 
385
+ if (ForkSeq[fork] >= ForkSeq.gloas && payloadAttributes.slotNumber != null) {
386
+ (executionPayload as gloas.ExecutionPayload).slotNumber = payloadAttributes.slotNumber;
387
+ }
388
+
385
389
  this.preparingPayloads.set(payloadId, {
386
390
  executionPayload: serializeExecutionPayload(fork, executionPayload),
387
391
  blobsBundle: serializeBlobsBundle({
@@ -613,6 +613,10 @@ export function createLodestarMetrics(
613
613
  name: "lodestar_sync_unknown_block_pending_blocks_size",
614
614
  help: "Current size of UnknownBlockSync pending blocks cache",
615
615
  }),
616
+ pendingPayloads: register.gauge({
617
+ name: "lodestar_sync_unknown_block_pending_payloads_size",
618
+ help: "Current size of UnknownBlockSync pending payloads cache",
619
+ }),
616
620
  knownBadBlocks: register.gauge({
617
621
  name: "lodestar_sync_unknown_block_known_bad_blocks_size",
618
622
  help: "Current size of UnknownBlockSync known bad blocks cache",
@@ -41,6 +41,7 @@ export enum GossipType {
41
41
  execution_payload = "execution_payload",
42
42
  payload_attestation_message = "payload_attestation_message",
43
43
  execution_payload_bid = "execution_payload_bid",
44
+ proposer_preferences = "proposer_preferences",
44
45
  }
45
46
 
46
47
  export type SequentialGossipType = Exclude<GossipType, GossipType.beacon_attestation>;
@@ -78,6 +79,7 @@ export type GossipTopicTypeMap = {
78
79
  [GossipType.execution_payload]: {type: GossipType.execution_payload};
79
80
  [GossipType.payload_attestation_message]: {type: GossipType.payload_attestation_message};
80
81
  [GossipType.execution_payload_bid]: {type: GossipType.execution_payload_bid};
82
+ [GossipType.proposer_preferences]: {type: GossipType.proposer_preferences};
81
83
  };
82
84
 
83
85
  export type GossipTopicMap = {
@@ -110,6 +112,7 @@ export type GossipTypeMap = {
110
112
  [GossipType.execution_payload]: gloas.SignedExecutionPayloadEnvelope;
111
113
  [GossipType.payload_attestation_message]: gloas.PayloadAttestationMessage;
112
114
  [GossipType.execution_payload_bid]: gloas.SignedExecutionPayloadBid;
115
+ [GossipType.proposer_preferences]: gloas.SignedProposerPreferences;
113
116
  };
114
117
 
115
118
  export type GossipFnByType = {
@@ -141,6 +144,9 @@ export type GossipFnByType = {
141
144
  payloadAttestationMessage: gloas.PayloadAttestationMessage
142
145
  ) => Promise<void> | void;
143
146
  [GossipType.execution_payload_bid]: (executionPayloadBid: gloas.SignedExecutionPayloadBid) => Promise<void> | void;
147
+ [GossipType.proposer_preferences]: (
148
+ signedProposerPreferences: gloas.SignedProposerPreferences
149
+ ) => Promise<void> | void;
144
150
  };
145
151
 
146
152
  export type GossipFn = GossipFnByType[keyof GossipFnByType];
@@ -27,6 +27,7 @@ const BLS_TO_EXECUTION_CHANGE_WEIGHT = 0.05;
27
27
  const EXECUTION_PAYLOAD_WEIGHT = 0.5;
28
28
  const PAYLOAD_ATTESTATION_WEIGHT = 0.05;
29
29
  const EXECUTION_PAYLOAD_BID_WEIGHT = 0.05;
30
+ const PROPOSER_PREFERENCES_WEIGHT = 0.05;
30
31
 
31
32
  const beaconAttestationSubnetWeight = 1 / ATTESTATION_SUBNET_COUNT;
32
33
  const maxPositiveScore =
@@ -40,7 +41,8 @@ const maxPositiveScore =
40
41
  BLS_TO_EXECUTION_CHANGE_WEIGHT +
41
42
  EXECUTION_PAYLOAD_WEIGHT +
42
43
  PAYLOAD_ATTESTATION_WEIGHT +
43
- EXECUTION_PAYLOAD_BID_WEIGHT);
44
+ EXECUTION_PAYLOAD_BID_WEIGHT +
45
+ PROPOSER_PREFERENCES_WEIGHT);
44
46
 
45
47
  /**
46
48
  * The following params is implemented by Lighthouse at
@@ -198,6 +200,17 @@ function getAllTopicsScoreParams(
198
200
  expectedMessageRate: 1024, // TODO GLOAS: Need an estimate for this
199
201
  firstMessageDecayTime: epochDurationMs * 100,
200
202
  });
203
+ topicsParams[
204
+ stringifyGossipTopic(config, {
205
+ type: GossipType.proposer_preferences,
206
+ boundary,
207
+ })
208
+ ] = getTopicScoreParams(config, precomputedParams, {
209
+ topicWeight: PROPOSER_PREFERENCES_WEIGHT,
210
+ // Upper bound ~64 messages per epoch: one per proposer across the current + next epoch.
211
+ expectedMessageRate: 64 / SLOTS_PER_EPOCH,
212
+ firstMessageDecayTime: epochDurationMs * 100,
213
+ });
201
214
 
202
215
  // other topics
203
216
  topicsParams[
@@ -73,6 +73,7 @@ function stringifyGossipTopicType(topic: GossipTopic): string {
73
73
  case GossipType.execution_payload:
74
74
  case GossipType.payload_attestation_message:
75
75
  case GossipType.execution_payload_bid:
76
+ case GossipType.proposer_preferences:
76
77
  return topic.type;
77
78
  case GossipType.beacon_attestation:
78
79
  case GossipType.sync_committee:
@@ -124,6 +125,8 @@ export function getGossipSSZType(topic: GossipTopic) {
124
125
  return ssz.gloas.PayloadAttestationMessage;
125
126
  case GossipType.execution_payload_bid:
126
127
  return ssz.gloas.SignedExecutionPayloadBid;
128
+ case GossipType.proposer_preferences:
129
+ return ssz.gloas.SignedProposerPreferences;
127
130
  }
128
131
  }
129
132
 
@@ -203,6 +206,7 @@ export function parseGossipTopic(forkDigestContext: ForkDigestContext, topicStr:
203
206
  case GossipType.execution_payload:
204
207
  case GossipType.payload_attestation_message:
205
208
  case GossipType.execution_payload_bid:
209
+ case GossipType.proposer_preferences:
206
210
  return {type: gossipTypeStr, boundary, encoding};
207
211
  }
208
212
 
@@ -257,6 +261,7 @@ export function getCoreTopicsAtFork(
257
261
  topics.push({type: GossipType.execution_payload});
258
262
  topics.push({type: GossipType.payload_attestation_message});
259
263
  topics.push({type: GossipType.execution_payload_bid});
264
+ topics.push({type: GossipType.proposer_preferences});
260
265
  }
261
266
 
262
267
  // After fulu also track data_column_sidecar_{index}
@@ -351,4 +356,5 @@ export const gossipTopicIgnoreDuplicatePublishError: Record<GossipType, boolean>
351
356
  [GossipType.execution_payload]: true,
352
357
  [GossipType.payload_attestation_message]: true,
353
358
  [GossipType.execution_payload_bid]: true,
359
+ [GossipType.proposer_preferences]: true,
354
360
  };
@@ -112,6 +112,7 @@ export interface INetwork extends INetworkCorePublic {
112
112
  publishLightClientFinalityUpdate(update: LightClientFinalityUpdate): Promise<number>;
113
113
  publishLightClientOptimisticUpdate(update: LightClientOptimisticUpdate): Promise<number>;
114
114
  publishSignedExecutionPayloadEnvelope(signedEnvelope: gloas.SignedExecutionPayloadEnvelope): Promise<number>;
115
+ publishPayloadAttestationMessage(payloadAttestationMessage: gloas.PayloadAttestationMessage): Promise<number>;
115
116
 
116
117
  // Debug
117
118
  dumpGossipQueue(gossipType: GossipType): Promise<PendingGossipsubMessage[]>;