@lodestar/beacon-node 1.43.0-dev.38479366cc → 1.43.0-dev.38cd4b01e7

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 (292) hide show
  1. package/lib/api/impl/beacon/blocks/index.d.ts.map +1 -1
  2. package/lib/api/impl/beacon/blocks/index.js +13 -3
  3. package/lib/api/impl/beacon/blocks/index.js.map +1 -1
  4. package/lib/api/impl/beacon/pool/index.d.ts.map +1 -1
  5. package/lib/api/impl/beacon/pool/index.js +45 -2
  6. package/lib/api/impl/beacon/pool/index.js.map +1 -1
  7. package/lib/api/impl/debug/index.d.ts.map +1 -1
  8. package/lib/api/impl/debug/index.js +0 -1
  9. package/lib/api/impl/debug/index.js.map +1 -1
  10. package/lib/api/impl/validator/index.d.ts.map +1 -1
  11. package/lib/api/impl/validator/index.js +68 -2
  12. package/lib/api/impl/validator/index.js.map +1 -1
  13. package/lib/chain/blocks/blockInput/blockInput.d.ts +3 -0
  14. package/lib/chain/blocks/blockInput/blockInput.d.ts.map +1 -1
  15. package/lib/chain/blocks/blockInput/blockInput.js +4 -1
  16. package/lib/chain/blocks/blockInput/blockInput.js.map +1 -1
  17. package/lib/chain/blocks/importBlock.d.ts.map +1 -1
  18. package/lib/chain/blocks/importBlock.js +16 -31
  19. package/lib/chain/blocks/importBlock.js.map +1 -1
  20. package/lib/chain/blocks/importExecutionPayload.d.ts +9 -3
  21. package/lib/chain/blocks/importExecutionPayload.d.ts.map +1 -1
  22. package/lib/chain/blocks/importExecutionPayload.js +37 -15
  23. package/lib/chain/blocks/importExecutionPayload.js.map +1 -1
  24. package/lib/chain/blocks/index.d.ts.map +1 -1
  25. package/lib/chain/blocks/index.js +35 -21
  26. package/lib/chain/blocks/index.js.map +1 -1
  27. package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.d.ts +12 -1
  28. package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.d.ts.map +1 -1
  29. package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.js +28 -2
  30. package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.js.map +1 -1
  31. package/lib/chain/blocks/payloadEnvelopeInput/types.d.ts +17 -0
  32. package/lib/chain/blocks/payloadEnvelopeInput/types.d.ts.map +1 -1
  33. package/lib/chain/blocks/types.d.ts +2 -1
  34. package/lib/chain/blocks/types.d.ts.map +1 -1
  35. package/lib/chain/blocks/utils/chainSegment.d.ts +1 -3
  36. package/lib/chain/blocks/utils/chainSegment.d.ts.map +1 -1
  37. package/lib/chain/blocks/utils/chainSegment.js +34 -23
  38. package/lib/chain/blocks/utils/chainSegment.js.map +1 -1
  39. package/lib/chain/blocks/verifyBlock.d.ts +2 -1
  40. package/lib/chain/blocks/verifyBlock.d.ts.map +1 -1
  41. package/lib/chain/blocks/verifyBlock.js +30 -12
  42. package/lib/chain/blocks/verifyBlock.js.map +1 -1
  43. package/lib/chain/blocks/verifyBlocksExecutionPayloads.d.ts +0 -4
  44. package/lib/chain/blocks/verifyBlocksExecutionPayloads.d.ts.map +1 -1
  45. package/lib/chain/blocks/verifyBlocksExecutionPayloads.js +5 -2
  46. package/lib/chain/blocks/verifyBlocksExecutionPayloads.js.map +1 -1
  47. package/lib/chain/blocks/verifyBlocksSanityChecks.d.ts +2 -1
  48. package/lib/chain/blocks/verifyBlocksSanityChecks.d.ts.map +1 -1
  49. package/lib/chain/blocks/verifyBlocksSanityChecks.js +16 -7
  50. package/lib/chain/blocks/verifyBlocksSanityChecks.js.map +1 -1
  51. package/lib/chain/blocks/verifyExecutionPayloadEnvelope.d.ts +2 -2
  52. package/lib/chain/blocks/verifyExecutionPayloadEnvelope.d.ts.map +1 -1
  53. package/lib/chain/blocks/verifyExecutionPayloadEnvelope.js +10 -6
  54. package/lib/chain/blocks/verifyExecutionPayloadEnvelope.js.map +1 -1
  55. package/lib/chain/blocks/verifyPayloadsDataAvailability.d.ts.map +1 -1
  56. package/lib/chain/blocks/verifyPayloadsDataAvailability.js +8 -3
  57. package/lib/chain/blocks/verifyPayloadsDataAvailability.js.map +1 -1
  58. package/lib/chain/chain.d.ts +2 -1
  59. package/lib/chain/chain.d.ts.map +1 -1
  60. package/lib/chain/chain.js +28 -9
  61. package/lib/chain/chain.js.map +1 -1
  62. package/lib/chain/emitter.d.ts +0 -11
  63. package/lib/chain/emitter.d.ts.map +1 -1
  64. package/lib/chain/emitter.js +0 -4
  65. package/lib/chain/emitter.js.map +1 -1
  66. package/lib/chain/errors/index.d.ts +1 -0
  67. package/lib/chain/errors/index.d.ts.map +1 -1
  68. package/lib/chain/errors/index.js +1 -0
  69. package/lib/chain/errors/index.js.map +1 -1
  70. package/lib/chain/errors/proposerPreferences.d.ts +40 -0
  71. package/lib/chain/errors/proposerPreferences.d.ts.map +1 -0
  72. package/lib/chain/errors/proposerPreferences.js +14 -0
  73. package/lib/chain/errors/proposerPreferences.js.map +1 -0
  74. package/lib/chain/initState.d.ts.map +1 -1
  75. package/lib/chain/initState.js +6 -1
  76. package/lib/chain/initState.js.map +1 -1
  77. package/lib/chain/interface.d.ts +2 -1
  78. package/lib/chain/interface.d.ts.map +1 -1
  79. package/lib/chain/interface.js.map +1 -1
  80. package/lib/chain/lightClient/index.d.ts.map +1 -1
  81. package/lib/chain/lightClient/index.js +1 -1
  82. package/lib/chain/lightClient/index.js.map +1 -1
  83. package/lib/chain/opPools/payloadAttestationPool.d.ts +4 -3
  84. package/lib/chain/opPools/payloadAttestationPool.d.ts.map +1 -1
  85. package/lib/chain/opPools/payloadAttestationPool.js +56 -14
  86. package/lib/chain/opPools/payloadAttestationPool.js.map +1 -1
  87. package/lib/chain/prepareNextSlot.d.ts.map +1 -1
  88. package/lib/chain/prepareNextSlot.js +16 -18
  89. package/lib/chain/prepareNextSlot.js.map +1 -1
  90. package/lib/chain/produceBlock/produceBlockBody.d.ts +12 -3
  91. package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
  92. package/lib/chain/produceBlock/produceBlockBody.js +34 -22
  93. package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
  94. package/lib/chain/regen/interface.d.ts +1 -0
  95. package/lib/chain/regen/interface.d.ts.map +1 -1
  96. package/lib/chain/regen/interface.js +1 -0
  97. package/lib/chain/regen/interface.js.map +1 -1
  98. package/lib/chain/regen/queued.d.ts.map +1 -1
  99. package/lib/chain/regen/queued.js +1 -4
  100. package/lib/chain/regen/queued.js.map +1 -1
  101. package/lib/chain/regen/regen.d.ts.map +1 -1
  102. package/lib/chain/regen/regen.js +1 -4
  103. package/lib/chain/regen/regen.js.map +1 -1
  104. package/lib/chain/seenCache/index.d.ts +1 -0
  105. package/lib/chain/seenCache/index.d.ts.map +1 -1
  106. package/lib/chain/seenCache/index.js +1 -0
  107. package/lib/chain/seenCache/index.js.map +1 -1
  108. package/lib/chain/seenCache/seenPayloadEnvelopeInput.d.ts +21 -11
  109. package/lib/chain/seenCache/seenPayloadEnvelopeInput.d.ts.map +1 -1
  110. package/lib/chain/seenCache/seenPayloadEnvelopeInput.js +70 -20
  111. package/lib/chain/seenCache/seenPayloadEnvelopeInput.js.map +1 -1
  112. package/lib/chain/seenCache/seenProposerPreferences.d.ts +16 -0
  113. package/lib/chain/seenCache/seenProposerPreferences.d.ts.map +1 -0
  114. package/lib/chain/seenCache/seenProposerPreferences.js +26 -0
  115. package/lib/chain/seenCache/seenProposerPreferences.js.map +1 -0
  116. package/lib/chain/validation/executionPayloadBid.js +11 -8
  117. package/lib/chain/validation/executionPayloadBid.js.map +1 -1
  118. package/lib/chain/validation/payloadAttestationMessage.d.ts +1 -1
  119. package/lib/chain/validation/payloadAttestationMessage.d.ts.map +1 -1
  120. package/lib/chain/validation/payloadAttestationMessage.js +5 -3
  121. package/lib/chain/validation/payloadAttestationMessage.js.map +1 -1
  122. package/lib/chain/validation/proposerPreferences.d.ts +8 -0
  123. package/lib/chain/validation/proposerPreferences.d.ts.map +1 -0
  124. package/lib/chain/validation/proposerPreferences.js +91 -0
  125. package/lib/chain/validation/proposerPreferences.js.map +1 -0
  126. package/lib/metrics/metrics/lodestar.d.ts +4 -0
  127. package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
  128. package/lib/metrics/metrics/lodestar.js +5 -0
  129. package/lib/metrics/metrics/lodestar.js.map +1 -1
  130. package/lib/network/gossip/interface.d.ts +7 -1
  131. package/lib/network/gossip/interface.d.ts.map +1 -1
  132. package/lib/network/gossip/interface.js +1 -0
  133. package/lib/network/gossip/interface.js.map +1 -1
  134. package/lib/network/gossip/scoringParameters.d.ts.map +1 -1
  135. package/lib/network/gossip/scoringParameters.js +12 -1
  136. package/lib/network/gossip/scoringParameters.js.map +1 -1
  137. package/lib/network/gossip/topic.d.ts +10 -0
  138. package/lib/network/gossip/topic.d.ts.map +1 -1
  139. package/lib/network/gossip/topic.js +6 -0
  140. package/lib/network/gossip/topic.js.map +1 -1
  141. package/lib/network/interface.d.ts +2 -0
  142. package/lib/network/interface.d.ts.map +1 -1
  143. package/lib/network/network.d.ts +2 -0
  144. package/lib/network/network.d.ts.map +1 -1
  145. package/lib/network/network.js +8 -0
  146. package/lib/network/network.js.map +1 -1
  147. package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
  148. package/lib/network/processor/gossipHandlers.js +69 -18
  149. package/lib/network/processor/gossipHandlers.js.map +1 -1
  150. package/lib/network/processor/gossipQueues/index.d.ts.map +1 -1
  151. package/lib/network/processor/gossipQueues/index.js +5 -0
  152. package/lib/network/processor/gossipQueues/index.js.map +1 -1
  153. package/lib/network/processor/index.d.ts.map +1 -1
  154. package/lib/network/processor/index.js +6 -5
  155. package/lib/network/processor/index.js.map +1 -1
  156. package/lib/network/reqresp/ReqRespBeaconNode.d.ts.map +1 -1
  157. package/lib/network/reqresp/ReqRespBeaconNode.js +1 -1
  158. package/lib/network/reqresp/ReqRespBeaconNode.js.map +1 -1
  159. package/lib/network/reqresp/handlers/beaconBlocksByHead.d.ts +9 -0
  160. package/lib/network/reqresp/handlers/beaconBlocksByHead.d.ts.map +1 -0
  161. package/lib/network/reqresp/handlers/beaconBlocksByHead.js +61 -0
  162. package/lib/network/reqresp/handlers/beaconBlocksByHead.js.map +1 -0
  163. package/lib/network/reqresp/handlers/index.d.ts.map +1 -1
  164. package/lib/network/reqresp/handlers/index.js +5 -0
  165. package/lib/network/reqresp/handlers/index.js.map +1 -1
  166. package/lib/network/reqresp/interface.d.ts +1 -1
  167. package/lib/network/reqresp/interface.js +1 -1
  168. package/lib/network/reqresp/protocols.d.ts +1 -0
  169. package/lib/network/reqresp/protocols.d.ts.map +1 -1
  170. package/lib/network/reqresp/protocols.js +5 -0
  171. package/lib/network/reqresp/protocols.js.map +1 -1
  172. package/lib/network/reqresp/rateLimit.d.ts.map +1 -1
  173. package/lib/network/reqresp/rateLimit.js +4 -0
  174. package/lib/network/reqresp/rateLimit.js.map +1 -1
  175. package/lib/network/reqresp/score.d.ts.map +1 -1
  176. package/lib/network/reqresp/score.js +1 -0
  177. package/lib/network/reqresp/score.js.map +1 -1
  178. package/lib/network/reqresp/types.d.ts +3 -0
  179. package/lib/network/reqresp/types.d.ts.map +1 -1
  180. package/lib/network/reqresp/types.js +3 -0
  181. package/lib/network/reqresp/types.js.map +1 -1
  182. package/lib/node/nodejs.js +2 -2
  183. package/lib/node/nodejs.js.map +1 -1
  184. package/lib/node/notifier.js +1 -7
  185. package/lib/node/notifier.js.map +1 -1
  186. package/lib/sync/constants.d.ts +7 -1
  187. package/lib/sync/constants.d.ts.map +1 -1
  188. package/lib/sync/constants.js +7 -4
  189. package/lib/sync/constants.js.map +1 -1
  190. package/lib/sync/range/batch.d.ts +43 -6
  191. package/lib/sync/range/batch.d.ts.map +1 -1
  192. package/lib/sync/range/batch.js +243 -44
  193. package/lib/sync/range/batch.js.map +1 -1
  194. package/lib/sync/range/chain.d.ts +16 -2
  195. package/lib/sync/range/chain.d.ts.map +1 -1
  196. package/lib/sync/range/chain.js +100 -9
  197. package/lib/sync/range/chain.js.map +1 -1
  198. package/lib/sync/range/range.d.ts.map +1 -1
  199. package/lib/sync/range/range.js +54 -5
  200. package/lib/sync/range/range.js.map +1 -1
  201. package/lib/sync/range/utils/peerBalancer.d.ts +2 -1
  202. package/lib/sync/range/utils/peerBalancer.d.ts.map +1 -1
  203. package/lib/sync/range/utils/peerBalancer.js +8 -4
  204. package/lib/sync/range/utils/peerBalancer.js.map +1 -1
  205. package/lib/sync/sync.d.ts.map +1 -1
  206. package/lib/sync/sync.js +13 -0
  207. package/lib/sync/sync.js.map +1 -1
  208. package/lib/sync/unknownBlock.d.ts +7 -2
  209. package/lib/sync/unknownBlock.d.ts.map +1 -1
  210. package/lib/sync/unknownBlock.js +127 -57
  211. package/lib/sync/unknownBlock.js.map +1 -1
  212. package/lib/sync/utils/downloadByRange.d.ts +36 -9
  213. package/lib/sync/utils/downloadByRange.d.ts.map +1 -1
  214. package/lib/sync/utils/downloadByRange.js +106 -42
  215. package/lib/sync/utils/downloadByRange.js.map +1 -1
  216. package/lib/sync/utils/downloadByRoot.d.ts.map +1 -1
  217. package/lib/sync/utils/downloadByRoot.js +10 -0
  218. package/lib/sync/utils/downloadByRoot.js.map +1 -1
  219. package/lib/sync/utils/rateLimit.d.ts +2 -0
  220. package/lib/sync/utils/rateLimit.d.ts.map +1 -0
  221. package/lib/sync/utils/rateLimit.js +15 -0
  222. package/lib/sync/utils/rateLimit.js.map +1 -0
  223. package/lib/util/sszBytes.d.ts.map +1 -1
  224. package/lib/util/sszBytes.js +8 -6
  225. package/lib/util/sszBytes.js.map +1 -1
  226. package/package.json +15 -16
  227. package/src/api/impl/beacon/blocks/index.ts +16 -3
  228. package/src/api/impl/beacon/pool/index.ts +83 -1
  229. package/src/api/impl/debug/index.ts +0 -1
  230. package/src/api/impl/validator/index.ts +82 -1
  231. package/src/chain/blocks/blockInput/blockInput.ts +4 -1
  232. package/src/chain/blocks/importBlock.ts +16 -50
  233. package/src/chain/blocks/importExecutionPayload.ts +51 -20
  234. package/src/chain/blocks/index.ts +32 -15
  235. package/src/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.ts +37 -3
  236. package/src/chain/blocks/payloadEnvelopeInput/types.ts +18 -0
  237. package/src/chain/blocks/types.ts +2 -1
  238. package/src/chain/blocks/utils/chainSegment.ts +35 -24
  239. package/src/chain/blocks/verifyBlock.ts +45 -13
  240. package/src/chain/blocks/verifyBlocksExecutionPayloads.ts +6 -4
  241. package/src/chain/blocks/verifyBlocksSanityChecks.ts +16 -6
  242. package/src/chain/blocks/verifyExecutionPayloadEnvelope.ts +14 -6
  243. package/src/chain/blocks/verifyPayloadsDataAvailability.ts +7 -4
  244. package/src/chain/chain.ts +32 -7
  245. package/src/chain/emitter.ts +0 -11
  246. package/src/chain/errors/index.ts +1 -0
  247. package/src/chain/errors/proposerPreferences.ts +47 -0
  248. package/src/chain/initState.ts +9 -1
  249. package/src/chain/interface.ts +2 -0
  250. package/src/chain/lightClient/index.ts +6 -6
  251. package/src/chain/opPools/payloadAttestationPool.ts +63 -18
  252. package/src/chain/prepareNextSlot.ts +21 -29
  253. package/src/chain/produceBlock/produceBlockBody.ts +45 -27
  254. package/src/chain/regen/interface.ts +1 -0
  255. package/src/chain/regen/queued.ts +2 -7
  256. package/src/chain/regen/regen.ts +2 -7
  257. package/src/chain/seenCache/index.ts +1 -0
  258. package/src/chain/seenCache/seenPayloadEnvelopeInput.ts +90 -24
  259. package/src/chain/seenCache/seenProposerPreferences.ts +32 -0
  260. package/src/chain/validation/executionPayloadBid.ts +11 -8
  261. package/src/chain/validation/payloadAttestationMessage.ts +6 -4
  262. package/src/chain/validation/proposerPreferences.ts +110 -0
  263. package/src/metrics/metrics/lodestar.ts +6 -0
  264. package/src/network/gossip/interface.ts +6 -0
  265. package/src/network/gossip/scoringParameters.ts +14 -1
  266. package/src/network/gossip/topic.ts +6 -0
  267. package/src/network/interface.ts +2 -0
  268. package/src/network/network.ts +23 -0
  269. package/src/network/processor/gossipHandlers.ts +86 -19
  270. package/src/network/processor/gossipQueues/index.ts +5 -0
  271. package/src/network/processor/index.ts +6 -5
  272. package/src/network/reqresp/ReqRespBeaconNode.ts +1 -0
  273. package/src/network/reqresp/handlers/beaconBlocksByHead.ts +91 -0
  274. package/src/network/reqresp/handlers/index.ts +5 -0
  275. package/src/network/reqresp/interface.ts +1 -1
  276. package/src/network/reqresp/protocols.ts +6 -0
  277. package/src/network/reqresp/rateLimit.ts +4 -0
  278. package/src/network/reqresp/score.ts +1 -0
  279. package/src/network/reqresp/types.ts +5 -0
  280. package/src/node/nodejs.ts +2 -2
  281. package/src/node/notifier.ts +1 -8
  282. package/src/sync/constants.ts +8 -4
  283. package/src/sync/range/batch.ts +309 -51
  284. package/src/sync/range/chain.ts +119 -10
  285. package/src/sync/range/range.ts +68 -5
  286. package/src/sync/range/utils/peerBalancer.ts +9 -3
  287. package/src/sync/sync.ts +13 -1
  288. package/src/sync/unknownBlock.ts +157 -60
  289. package/src/sync/utils/downloadByRange.ts +174 -44
  290. package/src/sync/utils/downloadByRoot.ts +12 -0
  291. package/src/sync/utils/rateLimit.ts +16 -0
  292. package/src/util/sszBytes.ts +8 -6
@@ -49,7 +49,7 @@ import {
49
49
  ssz,
50
50
  } from "@lodestar/types";
51
51
  import {Logger, byteArrayEquals, fromHex, sleep, toHex, toPubkeyHex, toRootHex} from "@lodestar/utils";
52
- import {ZERO_HASH, ZERO_HASH_HEX} from "../../constants/index.js";
52
+ import {ZERO_HASH_HEX} from "../../constants/index.js";
53
53
  import {numToQuantity} from "../../execution/engine/utils.js";
54
54
  import {
55
55
  IExecutionBuilder,
@@ -111,6 +111,7 @@ export type ProduceFullGloas = {
111
111
  executionRequests: electra.ExecutionRequests;
112
112
  blobsBundle: BlobsBundle<ForkPostGloas>;
113
113
  cells: fulu.Cell[][];
114
+ parentBlockRoot: Root;
114
115
  };
115
116
  export type ProduceFullFulu = {
116
117
  type: BlockType.Full;
@@ -214,19 +215,19 @@ export async function produceBlockBody<T extends BlockType>(
214
215
  });
215
216
 
216
217
  // Get execution payload from EL
218
+ let parentBlockHash: Bytes32;
219
+ let parentExecutionRequests: electra.ExecutionRequests;
220
+ // Apply parent payload once here as it's reused by EL prep and voluntary exit filtering below
221
+ let stateAfterParentPayload: IBeaconStateViewBellatrix = currentState;
217
222
  const isExtendingPayload = this.forkChoice.shouldExtendPayload(toRootHex(parentBlockRoot));
218
- let parentBlockHash = isExtendingPayload
219
- ? currentState.latestExecutionPayloadBid.blockHash
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)) {
223
+ if (isExtendingPayload) {
225
224
  parentBlockHash = currentState.latestExecutionPayloadBid.blockHash;
225
+ parentExecutionRequests = await this.getParentExecutionRequests(parentBlock.slot, parentBlock.blockRoot);
226
+ stateAfterParentPayload = currentState.withParentPayloadApplied(parentExecutionRequests);
227
+ } else {
228
+ parentBlockHash = currentState.latestExecutionPayloadBid.parentBlockHash;
229
+ parentExecutionRequests = ssz.electra.ExecutionRequests.defaultValue();
226
230
  }
227
- const parentExecutionRequests = isExtendingPayload
228
- ? await this.getParentExecutionRequests(parentBlock.slot, parentBlock.blockRoot)
229
- : ssz.electra.ExecutionRequests.defaultValue();
230
231
  const prepareRes = await prepareExecutionPayload(
231
232
  this,
232
233
  this.logger,
@@ -235,9 +236,8 @@ export async function produceBlockBody<T extends BlockType>(
235
236
  parentBlockHash,
236
237
  safeBlockHash,
237
238
  finalizedBlockHash ?? ZERO_HASH_HEX,
238
- currentState,
239
- feeRecipient,
240
- parentExecutionRequests
239
+ stateAfterParentPayload,
240
+ feeRecipient
241
241
  );
242
242
 
243
243
  const {prepType, payloadId} = prepareRes;
@@ -291,9 +291,19 @@ export async function produceBlockBody<T extends BlockType>(
291
291
  const commonBlockBody = await commonBlockBodyPromise;
292
292
  const gloasBody = Object.assign({}, commonBlockBody) as gloas.BeaconBlockBody;
293
293
  gloasBody.signedExecutionPayloadBid = signedBid;
294
- // TODO GLOAS: Get payload attestations from pool for previous slot
295
- gloasBody.payloadAttestations = [];
294
+ gloasBody.payloadAttestations = this.payloadAttestationPool.getPayloadAttestationsForBlock(
295
+ parentBlock.blockRoot,
296
+ blockSlot - 1
297
+ );
296
298
  gloasBody.parentExecutionRequests = parentExecutionRequests;
299
+ // Drop voluntary exits that parent_execution_requests have invalidated (e.g. a withdrawal
300
+ // request initiating an exit on the same validator). Op pool selected against the unapplied
301
+ // state, so re-validate against the post-apply state to avoid producing an invalid block.
302
+ if (isExtendingPayload && commonBlockBody.voluntaryExits.length > 0) {
303
+ gloasBody.voluntaryExits = commonBlockBody.voluntaryExits.filter((signedVoluntaryExit) =>
304
+ stateAfterParentPayload.isValidVoluntaryExit(signedVoluntaryExit, false)
305
+ );
306
+ }
297
307
  blockBody = gloasBody as AssembledBodyType<T>;
298
308
 
299
309
  // Store execution payload data required to construct execution payload envelope later
@@ -302,6 +312,7 @@ export async function produceBlockBody<T extends BlockType>(
302
312
  gloasResult.executionRequests = executionRequests;
303
313
  gloasResult.blobsBundle = blobsBundle;
304
314
  gloasResult.cells = cells;
315
+ gloasResult.parentBlockRoot = fromHex(parentBlock.blockRoot);
305
316
 
306
317
  const fetchedTime = Date.now() / 1000 - computeTimeAtSlot(this.config, blockSlot, this.genesisTime);
307
318
  this.metrics?.blockPayload.payloadFetchedTime.observe({prepType}, fetchedTime);
@@ -629,9 +640,12 @@ export async function prepareExecutionPayload(
629
640
  parentBlockHash: Bytes32,
630
641
  safeBlockHash: RootHex,
631
642
  finalizedBlockHash: RootHex,
643
+ /**
644
+ * Post-gloas, when extending a full parent, callers must apply
645
+ * parent execution payload first (see `withParentPayloadApplied`).
646
+ */
632
647
  state: IBeaconStateViewBellatrix,
633
- suggestedFeeRecipient: string,
634
- parentExecutionRequests?: electra.ExecutionRequests
648
+ suggestedFeeRecipient: string
635
649
  ): Promise<{prepType: PayloadPreparationType; payloadId: PayloadId}> {
636
650
  const timestamp = computeTimeAtSlot(chain.config, state.slot, state.genesisTime);
637
651
  const prevRandao = state.getRandaoMix(state.epoch);
@@ -668,7 +682,6 @@ export async function prepareExecutionPayload(
668
682
  parentBlockRoot,
669
683
  parentBlockHash,
670
684
  feeRecipient: suggestedFeeRecipient,
671
- parentExecutionRequests,
672
685
  });
673
686
 
674
687
  payloadId = await chain.executionEngine.notifyForkchoiceUpdate(
@@ -727,14 +740,16 @@ export function getPayloadAttributesForSSE(
727
740
  parentBlockRoot,
728
741
  parentBlockHash,
729
742
  feeRecipient,
730
- parentExecutionRequests,
731
743
  }: {
744
+ /**
745
+ * Post-gloas, when extending a full parent, callers must apply
746
+ * parent execution payload first (see `withParentPayloadApplied`).
747
+ */
732
748
  prepareState: IBeaconStateViewBellatrix;
733
749
  prepareSlot: Slot;
734
750
  parentBlockRoot: Root;
735
751
  parentBlockHash: Bytes32;
736
752
  feeRecipient: string;
737
- parentExecutionRequests?: electra.ExecutionRequests;
738
753
  }
739
754
  ): SSEPayloadAttributes {
740
755
  const payloadAttributes = preparePayloadAttributes(fork, chain, {
@@ -743,7 +758,6 @@ export function getPayloadAttributesForSSE(
743
758
  parentBlockRoot,
744
759
  parentBlockHash,
745
760
  feeRecipient,
746
- parentExecutionRequests,
747
761
  });
748
762
 
749
763
  let parentBlockNumber: number;
@@ -782,14 +796,16 @@ function preparePayloadAttributes(
782
796
  parentBlockRoot,
783
797
  parentBlockHash,
784
798
  feeRecipient,
785
- parentExecutionRequests,
786
799
  }: {
800
+ /**
801
+ * Post-gloas, when extending a full parent, callers must apply
802
+ * parent execution payload first (see `withParentPayloadApplied`).
803
+ */
787
804
  prepareState: IBeaconStateViewBellatrix;
788
805
  prepareSlot: Slot;
789
806
  parentBlockRoot: Root;
790
807
  parentBlockHash: Bytes32;
791
808
  feeRecipient: string;
792
- parentExecutionRequests?: electra.ExecutionRequests;
793
809
  }
794
810
  ): SSEPayloadAttributes["payloadAttributes"] {
795
811
  const timestamp = computeTimeAtSlot(chain.config, prepareSlot, prepareState.genesisTime);
@@ -808,11 +824,13 @@ function preparePayloadAttributes(
808
824
  if (isStatePostGloas(prepareState)) {
809
825
  const isExtendingPayload = byteArrayEquals(parentBlockHash, prepareState.latestExecutionPayloadBid.blockHash);
810
826
  if (isExtendingPayload) {
811
- if (parentExecutionRequests === undefined) {
812
- throw new Error("parentExecutionRequests required when extending full parent");
827
+ // applyParentExecutionPayload sets latestBlockHash = parentBid.blockHash, so a mismatch
828
+ // here means the caller did not apply parent payload to prepareState
829
+ if (!byteArrayEquals(prepareState.latestBlockHash, prepareState.latestExecutionPayloadBid.blockHash)) {
830
+ throw new Error("Expected state with parent execution payload applied for withdrawals");
813
831
  }
814
832
  (payloadAttributes as capella.SSEPayloadAttributes["payloadAttributes"]).withdrawals =
815
- prepareState.getExpectedWithdrawalsForFullParent(parentExecutionRequests);
833
+ prepareState.getExpectedWithdrawals().expectedWithdrawals;
816
834
  } else {
817
835
  // When the parent block is empty, state.payloadExpectedWithdrawals holds a batch
818
836
  // already deducted from CL balances but never credited on the EL (the envelope
@@ -21,6 +21,7 @@ export enum RegenCaller {
21
21
  validateGossipAttestation = "validateGossipAttestation",
22
22
  validateGossipVoluntaryExit = "validateGossipVoluntaryExit",
23
23
  validateGossipExecutionPayloadBid = "validateGossipExecutionPayloadBid",
24
+ validateGossipProposerPreferences = "validateGossipProposerPreferences",
24
25
  onForkChoiceFinalized = "onForkChoiceFinalized",
25
26
  restApi = "restApi",
26
27
  }
@@ -1,7 +1,7 @@
1
1
  import {routes} from "@lodestar/api";
2
2
  import {IForkChoice, ProtoBlock} from "@lodestar/fork-choice";
3
3
  import {IBeaconStateView, computeEpochAtSlot} from "@lodestar/state-transition";
4
- import {BeaconBlock, Epoch, RootHex, Slot, isGloasBeaconBlock, phase0} from "@lodestar/types";
4
+ import {BeaconBlock, Epoch, RootHex, Slot, phase0} from "@lodestar/types";
5
5
  import {Logger, toRootHex} from "@lodestar/utils";
6
6
  import {Metrics} from "../../metrics/index.js";
7
7
  import {JobItemQueue} from "../../util/queue/index.js";
@@ -88,12 +88,7 @@ export class QueuedStateRegenerator implements IStateRegenerator {
88
88
  */
89
89
  getPreStateSync(block: BeaconBlock): IBeaconStateView | null {
90
90
  const parentRoot = toRootHex(block.parentRoot);
91
- const parentBlock = isGloasBeaconBlock(block)
92
- ? this.forkChoice.getBlockHexAndBlockHash(
93
- parentRoot,
94
- toRootHex(block.body.signedExecutionPayloadBid.message.parentBlockHash)
95
- )
96
- : this.forkChoice.getBlockHexDefaultStatus(parentRoot);
91
+ const parentBlock = this.forkChoice.getBlockHexDefaultStatus(parentRoot);
97
92
  if (!parentBlock) {
98
93
  throw new RegenError({
99
94
  code: RegenErrorCode.BLOCK_NOT_IN_FORKCHOICE,
@@ -9,7 +9,7 @@ import {
9
9
  computeEpochAtSlot,
10
10
  computeStartSlotAtEpoch,
11
11
  } from "@lodestar/state-transition";
12
- import {BeaconBlock, RootHex, SignedBeaconBlock, Slot, isGloasBeaconBlock} from "@lodestar/types";
12
+ import {BeaconBlock, RootHex, SignedBeaconBlock, Slot} from "@lodestar/types";
13
13
  import {Logger, fromHex, toRootHex} from "@lodestar/utils";
14
14
  import {IBeaconDb} from "../../db/index.js";
15
15
  import {Metrics} from "../../metrics/index.js";
@@ -57,12 +57,7 @@ export class StateRegenerator implements IStateRegeneratorInternal {
57
57
  regenCaller: RegenCaller
58
58
  ): Promise<IBeaconStateView> {
59
59
  const parentRoot = toRootHex(block.parentRoot);
60
- const parentBlock = isGloasBeaconBlock(block)
61
- ? this.modules.forkChoice.getBlockHexAndBlockHash(
62
- parentRoot,
63
- toRootHex(block.body.signedExecutionPayloadBid.message.parentBlockHash)
64
- )
65
- : this.modules.forkChoice.getBlockHexDefaultStatus(parentRoot);
60
+ const parentBlock = this.modules.forkChoice.getBlockHexDefaultStatus(parentRoot);
66
61
  if (!parentBlock) {
67
62
  throw new RegenError({
68
63
  code: RegenErrorCode.BLOCK_NOT_IN_FORKCHOICE,
@@ -5,3 +5,4 @@ export {SeenContributionAndProof} from "./seenCommitteeContribution.js";
5
5
  export {SeenExecutionPayloadBids} from "./seenExecutionPayloadBids.js";
6
6
  export {SeenBlockInput} from "./seenGossipBlockInput.js";
7
7
  export {PayloadEnvelopeInput, SeenPayloadEnvelopeInput} from "./seenPayloadEnvelopeInput.js";
8
+ export {SeenProposerPreferences} from "./seenProposerPreferences.js";
@@ -1,16 +1,22 @@
1
- import {CheckpointWithHex} from "@lodestar/fork-choice";
1
+ import {ChainForkConfig} from "@lodestar/config";
2
+ import {CheckpointWithHex, IForkChoice, ProtoBlock} from "@lodestar/fork-choice";
2
3
  import {computeStartSlotAtEpoch} from "@lodestar/state-transition";
3
- import {RootHex, Slot} from "@lodestar/types";
4
+ import {RootHex} from "@lodestar/types";
4
5
  import {Logger} from "@lodestar/utils";
5
6
  import {Metrics} from "../../metrics/metrics.js";
7
+ import {IClock} from "../../util/clock.js";
6
8
  import {SerializedCache} from "../../util/serializedCache.js";
7
- import {CreateFromBlockProps, PayloadEnvelopeInput} from "../blocks/payloadEnvelopeInput/index.js";
9
+ import {isDaOutOfRange} from "../blocks/blockInput/index.js";
10
+ import {CreateFromBidProps, CreateFromBlockProps, PayloadEnvelopeInput} from "../blocks/payloadEnvelopeInput/index.js";
8
11
  import {ChainEvent, ChainEventEmitter} from "../emitter.js";
9
12
 
10
13
  export type {PayloadEnvelopeInputState} from "../blocks/payloadEnvelopeInput/index.js";
11
14
  export {PayloadEnvelopeInput} from "../blocks/payloadEnvelopeInput/index.js";
12
15
 
13
16
  export type SeenPayloadEnvelopeInputModules = {
17
+ config: ChainForkConfig;
18
+ clock: IClock;
19
+ forkChoice: IForkChoice;
14
20
  chainEvents: ChainEventEmitter;
15
21
  signal: AbortSignal;
16
22
  serializedCache: SerializedCache;
@@ -21,17 +27,16 @@ export type SeenPayloadEnvelopeInputModules = {
21
27
  /**
22
28
  * Cache for tracking PayloadEnvelopeInput instances, keyed by beacon block root.
23
29
  *
24
- * Created during block import when a block is processed. Two pruning paths:
25
- * - `prepareNextSlot` calls `pruneBelow(headParentSlot)` every slot once the head we'll build
26
- * on is known.
27
- * - `onFinalized` calls `pruneBelow(finalizedSlot)` on every finalization for bulk cleanup.
28
- *
30
+ * Created whenever we have a block because it needs block bid.
29
31
  * Steady state (linear chain, healthy progression): the cache holds ~2 entries — the head
30
32
  * (parent for next-slot production) and its parent (proposer-boost-reorg fallback). It can
31
33
  * transiently hold more during forks, range-sync bursts, or when `prepareNextSlot` skips
32
34
  * ticks; subsequent ticks settle it back.
33
35
  */
34
36
  export class SeenPayloadEnvelopeInput {
37
+ private readonly config: ChainForkConfig;
38
+ private readonly clock: IClock;
39
+ private readonly forkChoice: IForkChoice;
35
40
  private readonly chainEvents: ChainEventEmitter;
36
41
  private readonly signal: AbortSignal;
37
42
  private readonly serializedCache: SerializedCache;
@@ -39,7 +44,19 @@ export class SeenPayloadEnvelopeInput {
39
44
  private readonly logger?: Logger;
40
45
  private payloadInputs = new Map<RootHex, PayloadEnvelopeInput>();
41
46
 
42
- constructor({chainEvents, signal, serializedCache, metrics, logger}: SeenPayloadEnvelopeInputModules) {
47
+ constructor({
48
+ config,
49
+ clock,
50
+ forkChoice,
51
+ chainEvents,
52
+ signal,
53
+ serializedCache,
54
+ metrics,
55
+ logger,
56
+ }: SeenPayloadEnvelopeInputModules) {
57
+ this.config = config;
58
+ this.clock = clock;
59
+ this.forkChoice = forkChoice;
43
60
  this.chainEvents = chainEvents;
44
61
  this.signal = signal;
45
62
  this.serializedCache = serializedCache;
@@ -58,23 +75,68 @@ export class SeenPayloadEnvelopeInput {
58
75
  });
59
76
  }
60
77
 
61
- this.chainEvents.on(ChainEvent.forkChoiceFinalized, this.onFinalized);
78
+ this.chainEvents.on(ChainEvent.forkChoiceFinalized, this.pruneFinalized);
62
79
  this.signal.addEventListener("abort", () => {
63
- this.chainEvents.off(ChainEvent.forkChoiceFinalized, this.onFinalized);
80
+ this.chainEvents.off(ChainEvent.forkChoiceFinalized, this.pruneFinalized);
64
81
  });
65
82
  }
66
83
 
67
- private onFinalized = (checkpoint: CheckpointWithHex): void => {
68
- this.pruneBelow(computeStartSlotAtEpoch(checkpoint.epoch));
84
+ private pruneFinalized = (checkpoint: CheckpointWithHex): void => {
85
+ const finalizedSlot = computeStartSlotAtEpoch(checkpoint.epoch);
86
+ let deletedCount = 0;
87
+ for (const [, input] of this.payloadInputs) {
88
+ if (input.slot < finalizedSlot) {
89
+ this.evictPayloadInput(input);
90
+ deletedCount++;
91
+ }
92
+ }
93
+
94
+ this.logger?.debug("SeenPayloadEnvelopeInput.pruneFinalized deleted entries", {
95
+ finalizedSlot,
96
+ finalizedRoot: checkpoint.rootHex,
97
+ deletedCount,
98
+ });
69
99
  };
70
100
 
71
- add(props: CreateFromBlockProps): PayloadEnvelopeInput {
72
- if (this.payloadInputs.has(props.blockRootHex)) {
73
- throw new Error(`PayloadEnvelopeInput already exists for block ${props.blockRootHex}`);
101
+ add(props: Omit<CreateFromBlockProps, "daOutOfRange">): PayloadEnvelopeInput {
102
+ const existing = this.payloadInputs.get(props.blockRootHex);
103
+ if (existing !== undefined) {
104
+ this.logger?.verbose("SeenPayloadEnvelopeInput.add reused existing entry", {
105
+ slot: existing.slot,
106
+ root: props.blockRootHex,
107
+ });
108
+ return existing;
109
+ }
110
+ const daOutOfRange = isDaOutOfRange(this.config, props.forkName, props.block.message.slot, this.clock.currentEpoch);
111
+ const input = PayloadEnvelopeInput.createFromBlock({...props, daOutOfRange});
112
+ this.payloadInputs.set(props.blockRootHex, input);
113
+ this.metrics?.seenCache.payloadEnvelopeInput.created.inc();
114
+ this.logger?.verbose("SeenPayloadEnvelopeInput.add created new entry", {
115
+ slot: input.slot,
116
+ root: props.blockRootHex,
117
+ daOutOfRange,
118
+ });
119
+ return input;
120
+ }
121
+
122
+ /**
123
+ * Used at chain initialization to seed the anchor block's PayloadEnvelopeInput from
124
+ * `state.latestExecutionPayloadBid`.
125
+ */
126
+ addFromBid(props: Omit<CreateFromBidProps, "daOutOfRange">): PayloadEnvelopeInput {
127
+ const existing = this.payloadInputs.get(props.blockRootHex);
128
+ if (existing !== undefined) {
129
+ return existing;
74
130
  }
75
- const input = PayloadEnvelopeInput.createFromBlock(props);
131
+ const daOutOfRange = isDaOutOfRange(this.config, props.forkName, props.slot, this.clock.currentEpoch);
132
+ const input = PayloadEnvelopeInput.createFromBid({...props, daOutOfRange});
76
133
  this.payloadInputs.set(props.blockRootHex, input);
77
134
  this.metrics?.seenCache.payloadEnvelopeInput.created.inc();
135
+ this.logger?.verbose("SeenPayloadEnvelopeInput.addFromBid created new entry", {
136
+ slot: input.slot,
137
+ root: props.blockRootHex,
138
+ daOutOfRange,
139
+ });
78
140
  return input;
79
141
  }
80
142
 
@@ -90,15 +152,19 @@ export class SeenPayloadEnvelopeInput {
90
152
  return this.payloadInputs.size;
91
153
  }
92
154
 
93
- pruneBelow(slot: Slot): void {
94
- let deletedCount = 0;
95
- for (const [, input] of this.payloadInputs) {
96
- if (input.slot < slot) {
97
- this.evictPayloadInput(input);
98
- deletedCount++;
155
+ pruneBelowParent(parentBlock: ProtoBlock): void {
156
+ for (const block of this.forkChoice.getAllAncestorBlocks(parentBlock.blockRoot, parentBlock.payloadStatus)) {
157
+ if (block.slot < parentBlock.slot) {
158
+ const input = this.payloadInputs.get(block.blockRoot);
159
+ if (input) {
160
+ this.evictPayloadInput(input);
161
+ this.logger?.verbose("SeenPayloadEnvelopeInput.pruneBelowParent deleted", {
162
+ slot: block.slot,
163
+ root: block.blockRoot,
164
+ });
165
+ }
99
166
  }
100
167
  }
101
- this.logger?.debug("SeenPayloadEnvelopeInput.pruneBelow deleted entries", {slot, deletedCount});
102
168
  }
103
169
 
104
170
  private evictPayloadInput(payloadInput: PayloadEnvelopeInput): void {
@@ -0,0 +1,32 @@
1
+ import {RootHex, Slot, ValidatorIndex} from "@lodestar/types";
2
+ import {MapDef} from "@lodestar/utils";
3
+
4
+ /**
5
+ * Tracks signed proposer preferences we've already seen per (dependent_root, proposal_slot, validator_index).
6
+ */
7
+ export class SeenProposerPreferences {
8
+ private readonly validatorByDependentRootBySlot = new MapDef<Slot, Map<RootHex, ValidatorIndex>>(
9
+ () => new Map<RootHex, ValidatorIndex>()
10
+ );
11
+
12
+ isKnown(dependentRoot: RootHex, proposalSlot: Slot, validatorIndex: ValidatorIndex): boolean {
13
+ return this.validatorByDependentRootBySlot.get(proposalSlot)?.get(dependentRoot) === validatorIndex;
14
+ }
15
+
16
+ add(dependentRoot: RootHex, proposalSlot: Slot, validatorIndex: ValidatorIndex): void {
17
+ this.validatorByDependentRootBySlot.getOrDefault(proposalSlot).set(dependentRoot, validatorIndex);
18
+ }
19
+
20
+ /**
21
+ * Entries are only load-bearing while `proposal_slot > current_slot`. Once the slot has
22
+ * passed the `[IGNORE] proposal_slot > current_slot` gossip rule takes over, so drop them
23
+ * on each slot tick.
24
+ */
25
+ prune(currentSlot: Slot): void {
26
+ for (const slot of this.validatorByDependentRootBySlot.keys()) {
27
+ if (slot < currentSlot) {
28
+ this.validatorByDependentRootBySlot.delete(slot);
29
+ }
30
+ }
31
+ }
32
+ }
@@ -48,9 +48,12 @@ async function validateExecutionPayloadBid(
48
48
  });
49
49
  }
50
50
 
51
- // [IGNORE] the `SignedProposerPreferences` where `preferences.proposal_slot`
52
- // is equal to `bid.slot` has been seen.
53
- // TODO GLOAS: Implement this along with proposer preference
51
+ // [IGNORE] A `SignedProposerPreferences` matching `bid.slot` and the bid's branch has been
52
+ // seen i.e. `proposal_slot == bid.slot` AND `dependent_root ==
53
+ // get_proposer_dependent_root(parent_state, compute_epoch_at_slot(bid.slot))`,
54
+ // where `parent_state` is the post-state of `bid.parent_block_root`.
55
+ // This is the message referenced as `proposer_preferences` in the following REJECT rules.
56
+ // TODO GLOAS: Implement once a ProposerPreferencesPool exists.
54
57
 
55
58
  // [REJECT] `bid.builder_index` is a valid/active builder index -- i.e.
56
59
  // `is_active_builder(state, bid.builder_index)` returns `True`.
@@ -71,11 +74,11 @@ async function validateExecutionPayloadBid(
71
74
  });
72
75
  }
73
76
 
74
- // [REJECT] `bid.fee_recipient` matches the `fee_recipient` from the proposer's
75
- // `SignedProposerPreferences` associated with `bid.slot`.
76
- // [REJECT] `bid.gas_limit` matches the `gas_limit` from the proposer's
77
- // `SignedProposerPreferences` associated with `bid.slot`.
78
- // TODO GLOAS: Implement this along with proposer preference
77
+ // [REJECT] `bid.fee_recipient == proposer_preferences.fee_recipient`.
78
+ // [REJECT] `bid.gas_limit == proposer_preferences.gas_limit`.
79
+ // Both compared against the matching `proposer_preferences` defined above (same branch
80
+ // via dependent_root, same proposal_slot).
81
+ // TODO GLOAS: Implement once a ProposerPreferencesPool exists.
79
82
 
80
83
  // [REJECT] The length of KZG commitments is less than or equal to the limitation defined in the
81
84
  // consensus layer -- i.e. validate that
@@ -11,7 +11,7 @@ import {IBeaconChain} from "../index.js";
11
11
 
12
12
  export type PayloadAttestationValidationResult = {
13
13
  attDataRootHex: RootHex;
14
- validatorCommitteeIndex: number;
14
+ validatorCommitteeIndices: number[];
15
15
  };
16
16
 
17
17
  export async function validateApiPayloadAttestationMessage(
@@ -80,9 +80,11 @@ async function validatePayloadAttestationMessage(
80
80
  // [REJECT] The message's validator index is within the payload committee in
81
81
  // `get_ptc(state, data.slot)`. The `state` is the head state corresponding to
82
82
  // processing the block up to the current slot as determined by the fork choice.
83
- const validatorCommitteeIndex = state.getIndexInPayloadTimelinessCommittee(validatorIndex, data.slot);
83
+ // The validator may occupy multiple PTC positions because `compute_ptc` samples
84
+ // by effective balance — collect all of them so duplicate votes are counted.
85
+ const validatorCommitteeIndices = state.getIndicesInPayloadTimelinessCommittee(validatorIndex, data.slot);
84
86
 
85
- if (validatorCommitteeIndex === -1) {
87
+ if (validatorCommitteeIndices.length === 0) {
86
88
  throw new PayloadAttestationError(GossipAction.REJECT, {
87
89
  code: PayloadAttestationErrorCode.INVALID_ATTESTER,
88
90
  attesterIndex: validatorIndex,
@@ -115,6 +117,6 @@ async function validatePayloadAttestationMessage(
115
117
 
116
118
  return {
117
119
  attDataRootHex: toRootHex(ssz.gloas.PayloadAttestationData.hashTreeRoot(data)),
118
- validatorCommitteeIndex,
120
+ validatorCommitteeIndices,
119
121
  };
120
122
  }
@@ -0,0 +1,110 @@
1
+ import {SLOTS_PER_EPOCH} from "@lodestar/params";
2
+ import {
3
+ computeEpochAtSlot,
4
+ createSingleSignatureSetFromComponents,
5
+ getProposerPreferencesSigningRoot,
6
+ } from "@lodestar/state-transition";
7
+ import {ValidatorIndex, gloas} from "@lodestar/types";
8
+ import {toRootHex} from "@lodestar/utils";
9
+ import {GossipAction, ProposerPreferencesError, ProposerPreferencesErrorCode} from "../errors/index.js";
10
+ import {IBeaconChain} from "../index.js";
11
+
12
+ /**
13
+ * Validates a gossiped `SignedProposerPreferences` per
14
+ * https://github.com/ethereum/consensus-specs/blob/master/specs/gloas/p2p-interface.md#proposer_preferences
15
+ */
16
+ export async function validateGossipProposerPreferences(
17
+ chain: IBeaconChain,
18
+ signedProposerPreferences: gloas.SignedProposerPreferences
19
+ ): Promise<void> {
20
+ const preferences = signedProposerPreferences.message;
21
+ const {proposalSlot, validatorIndex, dependentRoot} = preferences;
22
+ const dependentRootHex = toRootHex(dependentRoot);
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
+ // [IGNORE] The block with root `dependent_root` has been seen by the node.
46
+ // Resolve the proposer lookahead for the message's branch via head state (fast path) or
47
+ // the previous-root checkpoint state (populated by `processSlotsToNearestCheckpoint` for
48
+ // any imported branch crossing into `proposalEpoch - 1`). The head-state path also handles
49
+ // narrow timing windows where the checkpoint state isn't yet populated.
50
+ const headState = chain.getHeadState();
51
+ let proposers: ValidatorIndex[] | null = null;
52
+ if (headState.epoch === proposalEpoch && headState.currentDecisionRoot === dependentRootHex) {
53
+ proposers = headState.currentProposers;
54
+ } else if (headState.epoch === proposalEpoch - 1 && headState.nextDecisionRoot === dependentRootHex) {
55
+ proposers = headState.nextProposers;
56
+ } else {
57
+ // Sync lookup only to not trigger disk reload from gossip input.
58
+ const checkpointState = chain.regen.getCheckpointStateSync({epoch: proposalEpoch - 1, rootHex: dependentRootHex});
59
+ if (checkpointState !== null) {
60
+ // State is at `proposalEpoch - 1`, so proposers for `proposalSlot` (next epoch from
61
+ // the state's perspective) live in `nextProposers`.
62
+ proposers = checkpointState.nextProposers;
63
+ }
64
+ }
65
+ if (proposers === null) {
66
+ throw new ProposerPreferencesError(GossipAction.IGNORE, {
67
+ code: ProposerPreferencesErrorCode.UNKNOWN_DEPENDENT_ROOT,
68
+ proposalSlot,
69
+ dependentRoot: dependentRootHex,
70
+ });
71
+ }
72
+
73
+ // [REJECT] `is_valid_proposal_slot(state, preferences)` returns True.
74
+ if (proposers[proposalSlot % SLOTS_PER_EPOCH] !== validatorIndex) {
75
+ throw new ProposerPreferencesError(GossipAction.REJECT, {
76
+ code: ProposerPreferencesErrorCode.INVALID_PROPOSER,
77
+ proposalSlot,
78
+ validatorIndex,
79
+ dependentRoot: dependentRootHex,
80
+ });
81
+ }
82
+
83
+ // [IGNORE] First valid message for (dependent_root, proposal_slot, validator_index).
84
+ if (chain.seenProposerPreferences.isKnown(dependentRootHex, proposalSlot, validatorIndex)) {
85
+ throw new ProposerPreferencesError(GossipAction.IGNORE, {
86
+ code: ProposerPreferencesErrorCode.ALREADY_KNOWN,
87
+ proposalSlot,
88
+ validatorIndex,
89
+ dependentRoot: dependentRootHex,
90
+ });
91
+ }
92
+
93
+ // [REJECT] `signed_proposer_preferences.signature` is valid with respect to the validator's public key.
94
+ const signatureSet = createSingleSignatureSetFromComponents(
95
+ chain.pubkeyCache.getOrThrow(validatorIndex),
96
+ getProposerPreferencesSigningRoot(chain.config, preferences),
97
+ signedProposerPreferences.signature
98
+ );
99
+
100
+ if (!(await chain.bls.verifySignatureSets([signatureSet], {batchable: true}))) {
101
+ throw new ProposerPreferencesError(GossipAction.REJECT, {
102
+ code: ProposerPreferencesErrorCode.INVALID_SIGNATURE,
103
+ proposalSlot,
104
+ validatorIndex,
105
+ });
106
+ }
107
+
108
+ // Valid
109
+ chain.seenProposerPreferences.add(dependentRootHex, proposalSlot, validatorIndex);
110
+ }
@@ -3,6 +3,7 @@ import {NotReorgedReason} from "@lodestar/fork-choice";
3
3
  import {ArchiveStoreTask} from "../../chain/archiveStore/archiveStore.js";
4
4
  import {FrequencyStateArchiveStep} from "../../chain/archiveStore/strategies/frequencyStateArchiveStrategy.js";
5
5
  import {BlockInputSource} from "../../chain/blocks/blockInput/index.js";
6
+ import {PayloadErrorCode} from "../../chain/blocks/importExecutionPayload.js";
6
7
  import {PayloadEnvelopeInputSource} from "../../chain/blocks/payloadEnvelopeInput/index.js";
7
8
  import {JobQueueItemType} from "../../chain/bls/index.js";
8
9
  import {AttestationErrorCode, BlockErrorCode} from "../../chain/errors/index.js";
@@ -890,6 +891,11 @@ export function createLodestarMetrics(
890
891
  labelNames: ["source"],
891
892
  buckets: [0.5, 1, 2, 4, 6, 12],
892
893
  }),
894
+ processPayloadErrors: register.gauge<{error: PayloadErrorCode | "NOT_PAYLOAD_ERROR"}>({
895
+ name: "lodestar_gossip_execution_payload_envelope_process_payload_errors",
896
+ help: "Count of errors, by error type, while processing execution payload envelopes",
897
+ labelNames: ["error"],
898
+ }),
893
899
  },
894
900
  // recovery in the case of specific blob rows required
895
901
  recoverBlobSidecars: {