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

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 (268) hide show
  1. package/lib/api/impl/beacon/blocks/index.d.ts.map +1 -1
  2. package/lib/api/impl/beacon/blocks/index.js +20 -0
  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 +4 -0
  6. package/lib/api/impl/beacon/pool/index.js.map +1 -1
  7. package/lib/api/impl/beacon/state/index.d.ts.map +1 -1
  8. package/lib/api/impl/beacon/state/index.js +13 -10
  9. package/lib/api/impl/beacon/state/index.js.map +1 -1
  10. package/lib/api/impl/lodestar/attesterSlashing.d.ts +8 -0
  11. package/lib/api/impl/lodestar/attesterSlashing.d.ts.map +1 -0
  12. package/lib/api/impl/lodestar/attesterSlashing.js +29 -0
  13. package/lib/api/impl/lodestar/attesterSlashing.js.map +1 -0
  14. package/lib/api/impl/lodestar/index.d.ts.map +1 -1
  15. package/lib/api/impl/lodestar/index.js +39 -0
  16. package/lib/api/impl/lodestar/index.js.map +1 -1
  17. package/lib/api/impl/validator/index.d.ts.map +1 -1
  18. package/lib/api/impl/validator/index.js +11 -4
  19. package/lib/api/impl/validator/index.js.map +1 -1
  20. package/lib/chain/GetBlobsTracker.d.ts +1 -1
  21. package/lib/chain/GetBlobsTracker.d.ts.map +1 -1
  22. package/lib/chain/GetBlobsTracker.js +1 -2
  23. package/lib/chain/GetBlobsTracker.js.map +1 -1
  24. package/lib/chain/archiveStore/strategies/frequencyStateArchiveStrategy.d.ts.map +1 -1
  25. package/lib/chain/archiveStore/strategies/frequencyStateArchiveStrategy.js +2 -4
  26. package/lib/chain/archiveStore/strategies/frequencyStateArchiveStrategy.js.map +1 -1
  27. package/lib/chain/blocks/importBlock.d.ts.map +1 -1
  28. package/lib/chain/blocks/importBlock.js +29 -35
  29. package/lib/chain/blocks/importBlock.js.map +1 -1
  30. package/lib/chain/blocks/importExecutionPayload.d.ts +1 -1
  31. package/lib/chain/blocks/importExecutionPayload.d.ts.map +1 -1
  32. package/lib/chain/blocks/importExecutionPayload.js +24 -13
  33. package/lib/chain/blocks/importExecutionPayload.js.map +1 -1
  34. package/lib/chain/blocks/index.js +2 -2
  35. package/lib/chain/blocks/index.js.map +1 -1
  36. package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.d.ts +3 -0
  37. package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.d.ts.map +1 -1
  38. package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.js +20 -0
  39. package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.js.map +1 -1
  40. package/lib/chain/blocks/payloadEnvelopeProcessor.d.ts +5 -0
  41. package/lib/chain/blocks/payloadEnvelopeProcessor.d.ts.map +1 -1
  42. package/lib/chain/blocks/payloadEnvelopeProcessor.js +6 -4
  43. package/lib/chain/blocks/payloadEnvelopeProcessor.js.map +1 -1
  44. package/lib/chain/blocks/types.d.ts +4 -4
  45. package/lib/chain/blocks/types.d.ts.map +1 -1
  46. package/lib/chain/blocks/verifyBlocksExecutionPayloads.d.ts.map +1 -1
  47. package/lib/chain/blocks/verifyBlocksExecutionPayloads.js +3 -2
  48. package/lib/chain/blocks/verifyBlocksExecutionPayloads.js.map +1 -1
  49. package/lib/chain/blocks/verifyBlocksSignatures.d.ts.map +1 -1
  50. package/lib/chain/blocks/verifyBlocksSignatures.js +4 -2
  51. package/lib/chain/blocks/verifyBlocksSignatures.js.map +1 -1
  52. package/lib/chain/blocks/verifyPayloadsDataAvailability.d.ts +14 -0
  53. package/lib/chain/blocks/verifyPayloadsDataAvailability.d.ts.map +1 -0
  54. package/lib/chain/blocks/verifyPayloadsDataAvailability.js +25 -0
  55. package/lib/chain/blocks/verifyPayloadsDataAvailability.js.map +1 -0
  56. package/lib/chain/chain.d.ts +2 -1
  57. package/lib/chain/chain.d.ts.map +1 -1
  58. package/lib/chain/chain.js +30 -36
  59. package/lib/chain/chain.js.map +1 -1
  60. package/lib/chain/emitter.d.ts +13 -1
  61. package/lib/chain/emitter.d.ts.map +1 -1
  62. package/lib/chain/emitter.js +5 -0
  63. package/lib/chain/emitter.js.map +1 -1
  64. package/lib/chain/errors/attestationError.d.ts +8 -1
  65. package/lib/chain/errors/attestationError.d.ts.map +1 -1
  66. package/lib/chain/errors/attestationError.js +4 -0
  67. package/lib/chain/errors/attestationError.js.map +1 -1
  68. package/lib/chain/errors/blockError.d.ts +11 -1
  69. package/lib/chain/errors/blockError.d.ts.map +1 -1
  70. package/lib/chain/errors/blockError.js +4 -0
  71. package/lib/chain/errors/blockError.js.map +1 -1
  72. package/lib/chain/forkChoice/index.d.ts.map +1 -1
  73. package/lib/chain/forkChoice/index.js +22 -12
  74. package/lib/chain/forkChoice/index.js.map +1 -1
  75. package/lib/chain/interface.d.ts +2 -1
  76. package/lib/chain/interface.d.ts.map +1 -1
  77. package/lib/chain/interface.js.map +1 -1
  78. package/lib/chain/lightClient/index.d.ts +2 -2
  79. package/lib/chain/lightClient/index.d.ts.map +1 -1
  80. package/lib/chain/lightClient/index.js +7 -0
  81. package/lib/chain/lightClient/index.js.map +1 -1
  82. package/lib/chain/opPools/aggregatedAttestationPool.d.ts.map +1 -1
  83. package/lib/chain/opPools/aggregatedAttestationPool.js +5 -2
  84. package/lib/chain/opPools/aggregatedAttestationPool.js.map +1 -1
  85. package/lib/chain/opPools/executionPayloadBidPool.d.ts +2 -2
  86. package/lib/chain/opPools/executionPayloadBidPool.d.ts.map +1 -1
  87. package/lib/chain/opPools/executionPayloadBidPool.js +2 -2
  88. package/lib/chain/opPools/executionPayloadBidPool.js.map +1 -1
  89. package/lib/chain/prepareNextSlot.d.ts.map +1 -1
  90. package/lib/chain/prepareNextSlot.js +22 -10
  91. package/lib/chain/prepareNextSlot.js.map +1 -1
  92. package/lib/chain/produceBlock/computeNewStateRoot.d.ts +1 -7
  93. package/lib/chain/produceBlock/computeNewStateRoot.d.ts.map +1 -1
  94. package/lib/chain/produceBlock/computeNewStateRoot.js +1 -28
  95. package/lib/chain/produceBlock/computeNewStateRoot.js.map +1 -1
  96. package/lib/chain/produceBlock/produceBlockBody.d.ts +5 -10
  97. package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
  98. package/lib/chain/produceBlock/produceBlockBody.js +46 -19
  99. package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
  100. package/lib/chain/regen/errors.d.ts +1 -11
  101. package/lib/chain/regen/errors.d.ts.map +1 -1
  102. package/lib/chain/regen/errors.js +0 -2
  103. package/lib/chain/regen/errors.js.map +1 -1
  104. package/lib/chain/regen/interface.d.ts +6 -12
  105. package/lib/chain/regen/interface.d.ts.map +1 -1
  106. package/lib/chain/regen/queued.d.ts +6 -11
  107. package/lib/chain/regen/queued.d.ts.map +1 -1
  108. package/lib/chain/regen/queued.js +8 -40
  109. package/lib/chain/regen/queued.js.map +1 -1
  110. package/lib/chain/regen/regen.d.ts +0 -5
  111. package/lib/chain/regen/regen.d.ts.map +1 -1
  112. package/lib/chain/regen/regen.js +7 -34
  113. package/lib/chain/regen/regen.js.map +1 -1
  114. package/lib/chain/stateCache/datastore/db.d.ts +5 -4
  115. package/lib/chain/stateCache/datastore/db.d.ts.map +1 -1
  116. package/lib/chain/stateCache/datastore/db.js +10 -32
  117. package/lib/chain/stateCache/datastore/db.js.map +1 -1
  118. package/lib/chain/stateCache/datastore/file.d.ts +1 -1
  119. package/lib/chain/stateCache/datastore/file.d.ts.map +1 -1
  120. package/lib/chain/stateCache/datastore/file.js +5 -5
  121. package/lib/chain/stateCache/datastore/file.js.map +1 -1
  122. package/lib/chain/stateCache/datastore/types.d.ts +1 -1
  123. package/lib/chain/stateCache/datastore/types.d.ts.map +1 -1
  124. package/lib/chain/stateCache/fifoBlockStateCache.d.ts +1 -7
  125. package/lib/chain/stateCache/fifoBlockStateCache.d.ts.map +1 -1
  126. package/lib/chain/stateCache/fifoBlockStateCache.js +0 -8
  127. package/lib/chain/stateCache/fifoBlockStateCache.js.map +1 -1
  128. package/lib/chain/stateCache/persistentCheckpointsCache.d.ts +13 -30
  129. package/lib/chain/stateCache/persistentCheckpointsCache.d.ts.map +1 -1
  130. package/lib/chain/stateCache/persistentCheckpointsCache.js +120 -216
  131. package/lib/chain/stateCache/persistentCheckpointsCache.js.map +1 -1
  132. package/lib/chain/stateCache/types.d.ts +8 -15
  133. package/lib/chain/stateCache/types.d.ts.map +1 -1
  134. package/lib/chain/stateCache/types.js.map +1 -1
  135. package/lib/chain/validation/aggregateAndProof.js +12 -0
  136. package/lib/chain/validation/aggregateAndProof.js.map +1 -1
  137. package/lib/chain/validation/attestation.d.ts.map +1 -1
  138. package/lib/chain/validation/attestation.js +12 -0
  139. package/lib/chain/validation/attestation.js.map +1 -1
  140. package/lib/chain/validation/block.d.ts.map +1 -1
  141. package/lib/chain/validation/block.js +27 -5
  142. package/lib/chain/validation/block.js.map +1 -1
  143. package/lib/chain/validation/executionPayloadBid.d.ts.map +1 -1
  144. package/lib/chain/validation/executionPayloadBid.js +7 -4
  145. package/lib/chain/validation/executionPayloadBid.js.map +1 -1
  146. package/lib/chain/validation/executionPayloadEnvelope.d.ts.map +1 -1
  147. package/lib/chain/validation/executionPayloadEnvelope.js +8 -3
  148. package/lib/chain/validation/executionPayloadEnvelope.js.map +1 -1
  149. package/lib/chain/validation/payloadAttestationMessage.d.ts.map +1 -1
  150. package/lib/chain/validation/payloadAttestationMessage.js +8 -4
  151. package/lib/chain/validation/payloadAttestationMessage.js.map +1 -1
  152. package/lib/chain/validation/syncCommittee.d.ts.map +1 -1
  153. package/lib/chain/validation/syncCommittee.js +4 -0
  154. package/lib/chain/validation/syncCommittee.js.map +1 -1
  155. package/lib/chain/validation/syncCommitteeContributionAndProof.js +4 -1
  156. package/lib/chain/validation/syncCommitteeContributionAndProof.js.map +1 -1
  157. package/lib/chain/validatorMonitor.d.ts.map +1 -1
  158. package/lib/chain/validatorMonitor.js +3 -3
  159. package/lib/chain/validatorMonitor.js.map +1 -1
  160. package/lib/execution/engine/http.d.ts.map +1 -1
  161. package/lib/execution/engine/http.js +21 -14
  162. package/lib/execution/engine/http.js.map +1 -1
  163. package/lib/execution/engine/interface.d.ts +1 -0
  164. package/lib/execution/engine/interface.d.ts.map +1 -1
  165. package/lib/execution/engine/mock.d.ts.map +1 -1
  166. package/lib/execution/engine/mock.js +3 -0
  167. package/lib/execution/engine/mock.js.map +1 -1
  168. package/lib/execution/engine/types.d.ts +20 -0
  169. package/lib/execution/engine/types.d.ts.map +1 -1
  170. package/lib/execution/engine/types.js +18 -0
  171. package/lib/execution/engine/types.js.map +1 -1
  172. package/lib/network/gossip/topic.d.ts +2 -0
  173. package/lib/network/gossip/topic.d.ts.map +1 -1
  174. package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
  175. package/lib/network/processor/gossipHandlers.js +23 -3
  176. package/lib/network/processor/gossipHandlers.js.map +1 -1
  177. package/lib/network/reqresp/handlers/beaconBlocksByRange.d.ts.map +1 -1
  178. package/lib/network/reqresp/handlers/beaconBlocksByRange.js +2 -1
  179. package/lib/network/reqresp/handlers/beaconBlocksByRange.js.map +1 -1
  180. package/lib/network/reqresp/handlers/beaconBlocksByRoot.d.ts.map +1 -1
  181. package/lib/network/reqresp/handlers/beaconBlocksByRoot.js +2 -0
  182. package/lib/network/reqresp/handlers/beaconBlocksByRoot.js.map +1 -1
  183. package/lib/network/reqresp/handlers/blobSidecarsByRange.d.ts +2 -2
  184. package/lib/network/reqresp/handlers/blobSidecarsByRange.d.ts.map +1 -1
  185. package/lib/network/reqresp/handlers/blobSidecarsByRange.js +7 -3
  186. package/lib/network/reqresp/handlers/blobSidecarsByRange.js.map +1 -1
  187. package/lib/network/reqresp/handlers/blobSidecarsByRoot.d.ts.map +1 -1
  188. package/lib/network/reqresp/handlers/blobSidecarsByRoot.js +6 -0
  189. package/lib/network/reqresp/handlers/blobSidecarsByRoot.js.map +1 -1
  190. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.d.ts +2 -2
  191. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.d.ts.map +1 -1
  192. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js +7 -3
  193. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js.map +1 -1
  194. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.d.ts.map +1 -1
  195. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.js +2 -1
  196. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.js.map +1 -1
  197. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRoot.d.ts.map +1 -1
  198. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRoot.js +3 -8
  199. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRoot.js.map +1 -1
  200. package/lib/node/nodejs.d.ts.map +1 -1
  201. package/lib/node/nodejs.js +6 -1
  202. package/lib/node/nodejs.js.map +1 -1
  203. package/lib/node/notifier.d.ts.map +1 -1
  204. package/lib/node/notifier.js +2 -2
  205. package/lib/node/notifier.js.map +1 -1
  206. package/package.json +16 -16
  207. package/src/api/impl/beacon/blocks/index.ts +29 -0
  208. package/src/api/impl/beacon/pool/index.ts +4 -0
  209. package/src/api/impl/beacon/state/index.ts +15 -15
  210. package/src/api/impl/lodestar/attesterSlashing.ts +43 -0
  211. package/src/api/impl/lodestar/index.ts +51 -1
  212. package/src/api/impl/validator/index.ts +13 -5
  213. package/src/chain/GetBlobsTracker.ts +1 -2
  214. package/src/chain/archiveStore/strategies/frequencyStateArchiveStrategy.ts +2 -4
  215. package/src/chain/blocks/importBlock.ts +33 -42
  216. package/src/chain/blocks/importExecutionPayload.ts +26 -12
  217. package/src/chain/blocks/index.ts +2 -2
  218. package/src/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.ts +27 -0
  219. package/src/chain/blocks/payloadEnvelopeProcessor.ts +6 -5
  220. package/src/chain/blocks/types.ts +4 -4
  221. package/src/chain/blocks/verifyBlocksExecutionPayloads.ts +2 -1
  222. package/src/chain/blocks/verifyBlocksSignatures.ts +9 -2
  223. package/src/chain/blocks/verifyPayloadsDataAvailability.ts +38 -0
  224. package/src/chain/chain.ts +38 -47
  225. package/src/chain/emitter.ts +12 -0
  226. package/src/chain/errors/attestationError.ts +6 -1
  227. package/src/chain/errors/blockError.ts +7 -1
  228. package/src/chain/forkChoice/index.ts +23 -12
  229. package/src/chain/interface.ts +5 -0
  230. package/src/chain/lightClient/index.ts +15 -3
  231. package/src/chain/opPools/aggregatedAttestationPool.ts +6 -1
  232. package/src/chain/opPools/executionPayloadBidPool.ts +3 -3
  233. package/src/chain/prepareNextSlot.ts +26 -9
  234. package/src/chain/produceBlock/computeNewStateRoot.ts +1 -37
  235. package/src/chain/produceBlock/produceBlockBody.ts +71 -23
  236. package/src/chain/regen/errors.ts +1 -6
  237. package/src/chain/regen/interface.ts +6 -12
  238. package/src/chain/regen/queued.ts +12 -48
  239. package/src/chain/regen/regen.ts +8 -36
  240. package/src/chain/stateCache/datastore/db.ts +10 -33
  241. package/src/chain/stateCache/datastore/file.ts +5 -6
  242. package/src/chain/stateCache/datastore/types.ts +2 -3
  243. package/src/chain/stateCache/fifoBlockStateCache.ts +1 -10
  244. package/src/chain/stateCache/persistentCheckpointsCache.ts +139 -247
  245. package/src/chain/stateCache/types.ts +8 -14
  246. package/src/chain/validation/aggregateAndProof.ts +13 -0
  247. package/src/chain/validation/attestation.ts +13 -0
  248. package/src/chain/validation/block.ts +30 -7
  249. package/src/chain/validation/executionPayloadBid.ts +7 -3
  250. package/src/chain/validation/executionPayloadEnvelope.ts +12 -3
  251. package/src/chain/validation/payloadAttestationMessage.ts +9 -3
  252. package/src/chain/validation/syncCommittee.ts +5 -1
  253. package/src/chain/validation/syncCommitteeContributionAndProof.ts +5 -1
  254. package/src/chain/validatorMonitor.ts +3 -2
  255. package/src/execution/engine/http.ts +21 -14
  256. package/src/execution/engine/interface.ts +1 -0
  257. package/src/execution/engine/mock.ts +3 -0
  258. package/src/execution/engine/types.ts +41 -0
  259. package/src/network/processor/gossipHandlers.ts +28 -7
  260. package/src/network/reqresp/handlers/beaconBlocksByRange.ts +3 -1
  261. package/src/network/reqresp/handlers/beaconBlocksByRoot.ts +3 -0
  262. package/src/network/reqresp/handlers/blobSidecarsByRange.ts +15 -3
  263. package/src/network/reqresp/handlers/blobSidecarsByRoot.ts +11 -0
  264. package/src/network/reqresp/handlers/dataColumnSidecarsByRange.ts +19 -3
  265. package/src/network/reqresp/handlers/executionPayloadEnvelopesByRange.ts +3 -1
  266. package/src/network/reqresp/handlers/executionPayloadEnvelopesByRoot.ts +3 -12
  267. package/src/node/nodejs.ts +7 -2
  268. package/src/node/notifier.ts +7 -2
@@ -90,6 +90,19 @@ async function validateAggregateAndProof(
90
90
  });
91
91
  }
92
92
 
93
+ // [REJECT] If `aggregate.data.index == 1` (payload present for a past
94
+ // block), the execution payload for `block` passes validation.
95
+ // [IGNORE] When `aggregate.data.index == 1` (payload present for a past block),
96
+ // the corresponding execution payload for `block` has been seen (a client MAY queue
97
+ // attestations for processing once the payload is retrieved and SHOULD request the
98
+ // payload envelope via `ExecutionPayloadEnvelopesByRoot`).
99
+ if (block !== null && attData.index === 1 && !chain.seenPayloadEnvelope(toRootHex(attData.beaconBlockRoot))) {
100
+ throw new AttestationError(GossipAction.IGNORE, {
101
+ code: AttestationErrorCode.EXECUTION_PAYLOAD_NOT_SEEN,
102
+ beaconBlockRoot: toRootHex(attData.beaconBlockRoot),
103
+ });
104
+ }
105
+
93
106
  // [REJECT] len(committee_indices) == 1, where committee_indices = get_committee_indices(aggregate)
94
107
  committeeIndex = (aggregate as electra.Attestation).committeeBits.getSingleTrueBit();
95
108
  if (committeeIndex === null) {
@@ -315,6 +315,19 @@ async function validateAttestationNoSignatureCheck(
315
315
  code: AttestationErrorCode.PREMATURELY_INDICATED_PAYLOAD_PRESENT,
316
316
  });
317
317
  }
318
+
319
+ // [REJECT] If `attestation.data.index == 1` (payload present for a past
320
+ // block), the execution payload for `block` passes validation.
321
+ // [IGNORE] When `attestation.data.index == 1` (payload present for a past block),
322
+ // the corresponding execution payload for `block` has been seen (a client MAY queue
323
+ // attestations for processing once the payload is retrieved and SHOULD request the
324
+ // payload envelope via `ExecutionPayloadEnvelopesByRoot`).
325
+ if (block !== null && attData.index === 1 && !chain.seenPayloadEnvelope(toRootHex(attData.beaconBlockRoot))) {
326
+ throw new AttestationError(GossipAction.IGNORE, {
327
+ code: AttestationErrorCode.EXECUTION_PAYLOAD_NOT_SEEN,
328
+ beaconBlockRoot: toRootHex(attData.beaconBlockRoot),
329
+ });
330
+ }
318
331
  } else {
319
332
  // [REJECT] attestation.data.index == 0
320
333
  if (attData.index !== 0) {
@@ -1,4 +1,5 @@
1
1
  import {ChainForkConfig} from "@lodestar/config";
2
+ import {ExecutionStatus} from "@lodestar/fork-choice";
2
3
  import {ForkName, isForkPostBellatrix, isForkPostDeneb, isForkPostGloas} from "@lodestar/params";
3
4
  import {
4
5
  computeEpochAtSlot,
@@ -6,6 +7,7 @@ import {
6
7
  computeTimeAtSlot,
7
8
  getBlockProposerSignatureSet,
8
9
  isExecutionBlockBodyType,
10
+ isStatePostBellatrix,
9
11
  } from "@lodestar/state-transition";
10
12
  import {SignedBeaconBlock, deneb, gloas, isGloasBeaconBlock} from "@lodestar/types";
11
13
  import {byteArrayEquals, sleep, toRootHex} from "@lodestar/utils";
@@ -70,12 +72,7 @@ export async function validateGossipBlock(
70
72
  // [REJECT] The current finalized_checkpoint is an ancestor of block -- i.e.
71
73
  // get_ancestor(store, block.parent_root, compute_start_slot_at_epoch(store.finalized_checkpoint.epoch)) == store.finalized_checkpoint.root
72
74
  const parentRoot = toRootHex(block.parentRoot);
73
- const parentBlock = isGloasBeaconBlock(block)
74
- ? chain.forkChoice.getBlockHexAndBlockHash(
75
- parentRoot,
76
- toRootHex(block.body.signedExecutionPayloadBid.message.parentBlockHash)
77
- )
78
- : chain.forkChoice.getBlockHexDefaultStatus(parentRoot);
75
+ const parentBlock = chain.forkChoice.getBlockHexDefaultStatus(parentRoot);
79
76
  if (parentBlock === null) {
80
77
  // If fork choice does *not* consider the parent to be a descendant of the finalized block,
81
78
  // then there are two more cases:
@@ -90,6 +87,27 @@ export async function validateGossipBlock(
90
87
  throw new BlockGossipError(GossipAction.IGNORE, {code: BlockErrorCode.PARENT_UNKNOWN, parentRoot});
91
88
  }
92
89
 
90
+ // [IGNORE] The block's parent (defined by `block.parent_root`) passes all validation
91
+ // (including execution node verification of the `block.body.execution_payload`)
92
+ if (isForkPostBellatrix(fork) && parentBlock.executionStatus === ExecutionStatus.Invalid) {
93
+ throw new BlockGossipError(GossipAction.IGNORE, {
94
+ code: BlockErrorCode.PARENT_EXECUTION_INVALID,
95
+ parentRoot,
96
+ });
97
+ }
98
+
99
+ // [IGNORE] The block's parent execution payload (defined by bid.parent_block_hash) has been seen
100
+ // (via gossip or non-gossip sources) (a client MAY queue blocks for processing once the parent payload is retrieved).
101
+ if (isGloasBeaconBlock(block)) {
102
+ const parentBlockHashHex = toRootHex(block.body.signedExecutionPayloadBid.message.parentBlockHash);
103
+ if (chain.forkChoice.getBlockHexAndBlockHash(parentRoot, parentBlockHashHex) === null) {
104
+ throw new BlockGossipError(GossipAction.IGNORE, {
105
+ code: BlockErrorCode.PARENT_PAYLOAD_UNKNOWN,
106
+ parentBlockHash: parentBlockHashHex,
107
+ });
108
+ }
109
+ }
110
+
93
111
  // [IGNORE] The attestation head block is too far behind the attestation slot, causing many skip slots.
94
112
  // This is deemed a DoS risk because we need to get the proposerShuffling. To get the shuffling we have
95
113
  // to do a bunch of epoch transitions, the longer the distance between the parent and block,
@@ -174,7 +192,7 @@ export async function validateGossipBlock(
174
192
  if (isForkPostBellatrix(fork) && !isForkPostGloas(fork)) {
175
193
  if (!isExecutionBlockBodyType(block.body)) throw Error("Not execution block body type");
176
194
  const executionPayload = block.body.executionPayload;
177
- if (blockState.isExecutionStateType && blockState.isExecutionEnabled(block)) {
195
+ if (isStatePostBellatrix(blockState) && blockState.isExecutionStateType && blockState.isExecutionEnabled(block)) {
178
196
  const expectedTimestamp = computeTimeAtSlot(config, blockSlot, chain.genesisTime);
179
197
  if (executionPayload.timestamp !== computeTimeAtSlot(config, blockSlot, chain.genesisTime)) {
180
198
  throw new BlockGossipError(GossipAction.REJECT, {
@@ -186,6 +204,11 @@ export async function validateGossipBlock(
186
204
  }
187
205
  }
188
206
 
207
+ // [REJECT] The proposer index is a valid validator index
208
+ if (proposerIndex >= blockState.validatorCount) {
209
+ throw new BlockGossipError(GossipAction.REJECT, {code: BlockErrorCode.UNKNOWN_PROPOSER, proposerIndex});
210
+ }
211
+
189
212
  // [REJECT] The proposer signature, signed_beacon_block.signature, is valid with respect to the proposer_index pubkey.
190
213
  if (!chain.seenBlockInputCache.isVerifiedProposerSignature(blockSlot, blockRoot, signedBlock.signature)) {
191
214
  const signatureSet = getBlockProposerSignatureSet(chain.config, signedBlock);
@@ -3,6 +3,7 @@ import {
3
3
  createSingleSignatureSetFromComponents,
4
4
  getExecutionPayloadBidSigningRoot,
5
5
  isActiveBuilder,
6
+ isStatePostGloas,
6
7
  } from "@lodestar/state-transition";
7
8
  import {gloas} from "@lodestar/types";
8
9
  import {toRootHex} from "@lodestar/utils";
@@ -32,6 +33,9 @@ async function validateExecutionPayloadBid(
32
33
  const parentBlockRootHex = toRootHex(bid.parentBlockRoot);
33
34
  const parentBlockHashHex = toRootHex(bid.parentBlockHash);
34
35
  const state = await chain.getHeadStateAtCurrentEpoch(RegenCaller.validateGossipExecutionPayloadBid);
36
+ if (!isStatePostGloas(state)) {
37
+ throw new Error(`Expected gloas+ state for execution payload bid validation, got fork=${state.forkName}`);
38
+ }
35
39
 
36
40
  // [IGNORE] `bid.slot` is the current slot or the next slot.
37
41
  const currentSlot = chain.clock.currentSlot;
@@ -83,9 +87,9 @@ async function validateExecutionPayloadBid(
83
87
  });
84
88
  }
85
89
 
86
- // [IGNORE] this bid is the highest value bid seen for the corresponding slot
87
- // and the given parent block hash.
88
- const bestBid = chain.executionPayloadBidPool.getBestBid(parentBlockRootHex, parentBlockHashHex, bid.slot);
90
+ // [IGNORE] this bid is the highest value bid seen for the tuple
91
+ // `(bid.slot, bid.parent_block_hash, bid.parent_block_root)`.
92
+ const bestBid = chain.executionPayloadBidPool.getBestBid(bid.slot, parentBlockHashHex, parentBlockRootHex);
89
93
  if (bestBid !== null && bestBid.value >= bid.value) {
90
94
  throw new ExecutionPayloadBidError(GossipAction.IGNORE, {
91
95
  code: ExecutionPayloadBidErrorCode.BID_TOO_LOW,
@@ -1,5 +1,9 @@
1
1
  import {PayloadStatus} from "@lodestar/fork-choice";
2
- import {computeStartSlotAtEpoch, getExecutionPayloadEnvelopeSignatureSet} from "@lodestar/state-transition";
2
+ import {
3
+ computeStartSlotAtEpoch,
4
+ getExecutionPayloadEnvelopeSignatureSet,
5
+ isStatePostGloas,
6
+ } from "@lodestar/state-transition";
3
7
  import {gloas} from "@lodestar/types";
4
8
  import {toRootHex} from "@lodestar/utils";
5
9
  import {ExecutionPayloadEnvelopeError, ExecutionPayloadEnvelopeErrorCode, GossipAction} from "../errors/index.js";
@@ -28,7 +32,7 @@ async function validateExecutionPayloadEnvelope(
28
32
  const {payload} = envelope;
29
33
  const blockRootHex = toRootHex(envelope.beaconBlockRoot);
30
34
 
31
- // [IGNORE] The envelope's block root `envelope.block_root` has been seen (via
35
+ // [IGNORE] The envelope's block root `envelope.beacon_block_root` has been seen (via
32
36
  // gossip or non-gossip sources) (a client MAY queue payload for processing once
33
37
  // the block is retrieved).
34
38
  // TODO GLOAS: Need to review this, we should queue the envelope for later
@@ -103,7 +107,7 @@ async function validateExecutionPayloadEnvelope(
103
107
  });
104
108
  }
105
109
 
106
- // Get the post block state which is the pre-payload state to verify the builder's signature.
110
+ // Get the block state to verify the builder's signature.
107
111
  const blockState = await chain.regen
108
112
  .getState(block.stateRoot, RegenCaller.validateGossipPayloadEnvelope)
109
113
  .catch(() => {
@@ -113,7 +117,12 @@ async function validateExecutionPayloadEnvelope(
113
117
  slot: envelope.slot,
114
118
  });
115
119
  });
120
+ if (!isStatePostGloas(blockState)) {
121
+ throw new Error(`Expected gloas+ state for execution payload envelope validation, got fork=${blockState.forkName}`);
122
+ }
116
123
 
124
+ // [REJECT] `signed_execution_payload_envelope.signature` is valid as verified
125
+ // by `verify_execution_payload_envelope_signature`.
117
126
  const signatureSet = getExecutionPayloadEnvelopeSignatureSet(
118
127
  chain.config,
119
128
  chain.pubkeyCache,
@@ -2,6 +2,7 @@ import {
2
2
  computeEpochAtSlot,
3
3
  createSingleSignatureSetFromComponents,
4
4
  getPayloadAttestationDataSigningRoot,
5
+ isStatePostGloas,
5
6
  } from "@lodestar/state-transition";
6
7
  import {RootHex, gloas, ssz} from "@lodestar/types";
7
8
  import {toRootHex} from "@lodestar/utils";
@@ -17,7 +18,8 @@ export async function validateApiPayloadAttestationMessage(
17
18
  chain: IBeaconChain,
18
19
  payloadAttestationMessage: gloas.PayloadAttestationMessage
19
20
  ): Promise<PayloadAttestationValidationResult> {
20
- return validatePayloadAttestationMessage(chain, payloadAttestationMessage);
21
+ const prioritizeBls = true;
22
+ return validatePayloadAttestationMessage(chain, payloadAttestationMessage, prioritizeBls);
21
23
  }
22
24
 
23
25
  export async function validateGossipPayloadAttestationMessage(
@@ -29,7 +31,8 @@ export async function validateGossipPayloadAttestationMessage(
29
31
 
30
32
  async function validatePayloadAttestationMessage(
31
33
  chain: IBeaconChain,
32
- payloadAttestationMessage: gloas.PayloadAttestationMessage
34
+ payloadAttestationMessage: gloas.PayloadAttestationMessage,
35
+ prioritizeBls = false
33
36
  ): Promise<PayloadAttestationValidationResult> {
34
37
  const {data, validatorIndex} = payloadAttestationMessage;
35
38
  const epoch = computeEpochAtSlot(data.slot);
@@ -66,6 +69,9 @@ async function validatePayloadAttestationMessage(
66
69
  }
67
70
 
68
71
  const state = chain.getHeadState();
72
+ if (!isStatePostGloas(state)) {
73
+ throw new Error(`Expected gloas+ state for payload attestation validation, got fork=${state.forkName}`);
74
+ }
69
75
 
70
76
  // [REJECT] The message's block `data.beacon_block_root` passes validation.
71
77
  // TODO GLOAS: implement this. Technically if we cannot get proto block from fork choice,
@@ -98,7 +104,7 @@ async function validatePayloadAttestationMessage(
98
104
  payloadAttestationMessage.signature
99
105
  );
100
106
 
101
- if (!(await chain.bls.verifySignatureSets([signatureSet]))) {
107
+ if (!(await chain.bls.verifySignatureSets([signatureSet], {batchable: true, priority: prioritizeBls}))) {
102
108
  throw new PayloadAttestationError(GossipAction.REJECT, {
103
109
  code: PayloadAttestationErrorCode.INVALID_SIGNATURE,
104
110
  });
@@ -1,5 +1,5 @@
1
1
  import {SYNC_COMMITTEE_SUBNET_COUNT, SYNC_COMMITTEE_SUBNET_SIZE} from "@lodestar/params";
2
- import {IBeaconStateView} from "@lodestar/state-transition";
2
+ import {IBeaconStateView, isStatePostAltair} from "@lodestar/state-transition";
3
3
  import {SubnetID, altair} from "@lodestar/types";
4
4
  import {toRootHex} from "@lodestar/utils";
5
5
  import {GossipAction, SyncCommitteeError, SyncCommitteeErrorCode} from "../errors/index.js";
@@ -148,6 +148,10 @@ function getIndicesInSubcommittee(
148
148
  subnet: SubnetID,
149
149
  data: Pick<altair.SyncCommitteeMessage, "slot" | "validatorIndex">
150
150
  ): IndexInSubcommittee[] | null {
151
+ if (!isStatePostAltair(headState)) {
152
+ return null;
153
+ }
154
+
151
155
  const syncCommittee = headState.getIndexedSyncCommittee(data.slot);
152
156
  const indexesInCommittee = syncCommittee.validatorIndexMap.get(data.validatorIndex);
153
157
  if (indexesInCommittee === undefined) {
@@ -1,5 +1,5 @@
1
1
  import {SYNC_COMMITTEE_SUBNET_SIZE} from "@lodestar/params";
2
- import {IBeaconStateView, isSyncCommitteeAggregator} from "@lodestar/state-transition";
2
+ import {IBeaconStateView, isStatePostAltair, isSyncCommitteeAggregator} from "@lodestar/state-transition";
3
3
  import {ValidatorIndex, altair} from "@lodestar/types";
4
4
  import {GossipAction, SyncCommitteeError, SyncCommitteeErrorCode} from "../errors/index.js";
5
5
  import {IBeaconChain} from "../interface.js";
@@ -107,6 +107,10 @@ function getContributionIndices(
107
107
  state: IBeaconStateView,
108
108
  contribution: altair.SyncCommitteeContribution
109
109
  ): ValidatorIndex[] {
110
+ if (!isStatePostAltair(state)) {
111
+ throw new Error("Expected Altair state for sync committee contribution");
112
+ }
113
+
110
114
  const startIndex = contribution.subcommitteeIndex * SYNC_COMMITTEE_SUBNET_SIZE;
111
115
 
112
116
  const syncCommittee = state.getIndexedSyncCommittee(contribution.slot);
@@ -1,5 +1,5 @@
1
1
  import {ChainForkConfig} from "@lodestar/config";
2
- import {ForkSeq, MIN_ATTESTATION_INCLUSION_DELAY, SLOTS_PER_EPOCH} from "@lodestar/params";
2
+ import {MIN_ATTESTATION_INCLUSION_DELAY, SLOTS_PER_EPOCH} from "@lodestar/params";
3
3
  import {
4
4
  IBeaconStateView,
5
5
  ParticipationFlags,
@@ -7,6 +7,7 @@ import {
7
7
  computeStartSlotAtEpoch,
8
8
  computeTimeAtSlot,
9
9
  getCurrentSlot,
10
+ isStatePostAltair,
10
11
  parseAttesterFlags,
11
12
  parseParticipationFlags,
12
13
  } from "@lodestar/state-transition";
@@ -740,7 +741,7 @@ export function createValidatorMonitor(
740
741
 
741
742
  const rootCache = new RootHexCache(headState);
742
743
 
743
- if (config.getForkSeq(headState.slot) >= ForkSeq.altair) {
744
+ if (isStatePostAltair(headState)) {
744
745
  const prevEpochStartSlot = computeStartSlotAtEpoch(prevEpoch);
745
746
  const prevEpochTargetRoot = toRootHex(headState.getBlockRootAtSlot(prevEpochStartSlot));
746
747
 
@@ -216,13 +216,15 @@ export class ExecutionEngineHttp implements IExecutionEngine {
216
216
  executionRequests?: ExecutionRequests
217
217
  ): Promise<ExecutePayloadResponse> {
218
218
  const method =
219
- ForkSeq[fork] >= ForkSeq.electra
220
- ? "engine_newPayloadV4"
221
- : ForkSeq[fork] >= ForkSeq.deneb
222
- ? "engine_newPayloadV3"
223
- : ForkSeq[fork] >= ForkSeq.capella
224
- ? "engine_newPayloadV2"
225
- : "engine_newPayloadV1";
219
+ ForkSeq[fork] >= ForkSeq.gloas
220
+ ? "engine_newPayloadV5"
221
+ : ForkSeq[fork] >= ForkSeq.electra
222
+ ? "engine_newPayloadV4"
223
+ : ForkSeq[fork] >= ForkSeq.deneb
224
+ ? "engine_newPayloadV3"
225
+ : ForkSeq[fork] >= ForkSeq.capella
226
+ ? "engine_newPayloadV2"
227
+ : "engine_newPayloadV1";
226
228
 
227
229
  const serializedExecutionPayload = serializeExecutionPayload(fork, executionPayload);
228
230
 
@@ -244,7 +246,7 @@ export class ExecutionEngineHttp implements IExecutionEngine {
244
246
  }
245
247
  const serializedExecutionRequests = serializeExecutionRequests(executionRequests);
246
248
  engineRequest = {
247
- method: "engine_newPayloadV4",
249
+ method: ForkSeq[fork] >= ForkSeq.gloas ? "engine_newPayloadV5" : "engine_newPayloadV4",
248
250
  params: [
249
251
  serializedExecutionPayload,
250
252
  serializedVersionedHashes,
@@ -348,11 +350,13 @@ export class ExecutionEngineHttp implements IExecutionEngine {
348
350
  // Once on capella, should this need to be permanently switched to v2 when payload attrs
349
351
  // not provided
350
352
  const method =
351
- ForkSeq[fork] >= ForkSeq.deneb
352
- ? "engine_forkchoiceUpdatedV3"
353
- : ForkSeq[fork] >= ForkSeq.capella
354
- ? "engine_forkchoiceUpdatedV2"
355
- : "engine_forkchoiceUpdatedV1";
353
+ ForkSeq[fork] >= ForkSeq.gloas
354
+ ? "engine_forkchoiceUpdatedV4"
355
+ : ForkSeq[fork] >= ForkSeq.deneb
356
+ ? "engine_forkchoiceUpdatedV3"
357
+ : ForkSeq[fork] >= ForkSeq.capella
358
+ ? "engine_forkchoiceUpdatedV2"
359
+ : "engine_forkchoiceUpdatedV1";
356
360
  const payloadAttributesRpc = payloadAttributes ? serializePayloadAttributes(payloadAttributes) : undefined;
357
361
  // If we are just fcUing and not asking execution for payload, retry is not required
358
362
  // and we can move on, as the next fcU will be issued soon on the new slot
@@ -438,9 +442,12 @@ export class ExecutionEngineHttp implements IExecutionEngine {
438
442
  case ForkName.electra:
439
443
  method = "engine_getPayloadV4";
440
444
  break;
441
- default:
445
+ case ForkName.fulu:
442
446
  method = "engine_getPayloadV5";
443
447
  break;
448
+ default:
449
+ method = "engine_getPayloadV6";
450
+ break;
444
451
  }
445
452
  const payloadResponse = await this.rpc.fetchWithRetries<
446
453
  EngineApiRpcReturnTypes[typeof method],
@@ -87,6 +87,7 @@ export type PayloadAttributes = {
87
87
  suggestedFeeRecipient: string;
88
88
  withdrawals?: capella.Withdrawal[];
89
89
  parentBeaconBlockRoot?: Uint8Array;
90
+ slotNumber?: number; // EIP-7843
90
91
  };
91
92
 
92
93
  export type VersionedHashes = Uint8Array[];
@@ -132,14 +132,17 @@ export class ExecutionEngineMockBackend implements JsonRpcBackend {
132
132
  engine_newPayloadV2: this.notifyNewPayload.bind(this),
133
133
  engine_newPayloadV3: this.notifyNewPayload.bind(this),
134
134
  engine_newPayloadV4: this.notifyNewPayload.bind(this),
135
+ engine_newPayloadV5: this.notifyNewPayload.bind(this),
135
136
  engine_forkchoiceUpdatedV1: this.notifyForkchoiceUpdate.bind(this),
136
137
  engine_forkchoiceUpdatedV2: this.notifyForkchoiceUpdate.bind(this),
137
138
  engine_forkchoiceUpdatedV3: this.notifyForkchoiceUpdate.bind(this),
139
+ engine_forkchoiceUpdatedV4: this.notifyForkchoiceUpdate.bind(this),
138
140
  engine_getPayloadV1: this.getPayloadV1.bind(this),
139
141
  engine_getPayloadV2: this.getPayloadV5.bind(this),
140
142
  engine_getPayloadV3: this.getPayloadV5.bind(this),
141
143
  engine_getPayloadV4: this.getPayloadV5.bind(this),
142
144
  engine_getPayloadV5: this.getPayloadV5.bind(this),
145
+ engine_getPayloadV6: this.getPayloadV5.bind(this),
143
146
  engine_getPayloadBodiesByHashV1: this.getPayloadBodiesByHash.bind(this),
144
147
  engine_getPayloadBodiesByRangeV1: this.getPayloadBodiesByRange.bind(this),
145
148
  engine_getClientVersionV1: this.getClientVersionV1.bind(this),
@@ -19,6 +19,7 @@ import {
19
19
  capella,
20
20
  deneb,
21
21
  electra,
22
+ gloas,
22
23
  ssz,
23
24
  } from "@lodestar/types";
24
25
  import {BlobAndProof} from "@lodestar/types/deneb";
@@ -50,6 +51,7 @@ export type EngineApiRpcParamTypes = {
50
51
  engine_newPayloadV2: [ExecutionPayloadRpc];
51
52
  engine_newPayloadV3: [ExecutionPayloadRpc, VersionedHashesRpc, DATA];
52
53
  engine_newPayloadV4: [ExecutionPayloadRpc, VersionedHashesRpc, DATA, ExecutionRequestsRpc];
54
+ engine_newPayloadV5: [ExecutionPayloadRpc, VersionedHashesRpc, DATA, ExecutionRequestsRpc];
53
55
  /**
54
56
  * 1. Object - Payload validity status with respect to the consensus rules:
55
57
  * - blockHash: DATA, 32 Bytes - block hash value of the payload
@@ -67,6 +69,10 @@ export type EngineApiRpcParamTypes = {
67
69
  forkChoiceData: {headBlockHash: DATA; safeBlockHash: DATA; finalizedBlockHash: DATA},
68
70
  payloadAttributes?: PayloadAttributesRpc,
69
71
  ];
72
+ engine_forkchoiceUpdatedV4: [
73
+ forkChoiceData: {headBlockHash: DATA; safeBlockHash: DATA; finalizedBlockHash: DATA},
74
+ payloadAttributes?: PayloadAttributesRpc,
75
+ ];
70
76
  /**
71
77
  * 1. payloadId: QUANTITY, 64 Bits - Identifier of the payload building process
72
78
  */
@@ -75,6 +81,7 @@ export type EngineApiRpcParamTypes = {
75
81
  engine_getPayloadV3: [QUANTITY];
76
82
  engine_getPayloadV4: [QUANTITY];
77
83
  engine_getPayloadV5: [QUANTITY];
84
+ engine_getPayloadV6: [QUANTITY];
78
85
 
79
86
  /**
80
87
  * 1. Array of DATA - Array of block_hash field values of the ExecutionPayload structure
@@ -111,6 +118,7 @@ export type EngineApiRpcReturnTypes = {
111
118
  engine_newPayloadV2: PayloadStatus;
112
119
  engine_newPayloadV3: PayloadStatus;
113
120
  engine_newPayloadV4: PayloadStatus;
121
+ engine_newPayloadV5: PayloadStatus;
114
122
  engine_forkchoiceUpdatedV1: {
115
123
  payloadStatus: PayloadStatus;
116
124
  payloadId: QUANTITY | null;
@@ -123,6 +131,10 @@ export type EngineApiRpcReturnTypes = {
123
131
  payloadStatus: PayloadStatus;
124
132
  payloadId: QUANTITY | null;
125
133
  };
134
+ engine_forkchoiceUpdatedV4: {
135
+ payloadStatus: PayloadStatus;
136
+ payloadId: QUANTITY | null;
137
+ };
126
138
  /**
127
139
  * payloadId | Error: QUANTITY, 64 Bits - Identifier of the payload building process
128
140
  */
@@ -131,6 +143,7 @@ export type EngineApiRpcReturnTypes = {
131
143
  engine_getPayloadV3: ExecutionPayloadResponse;
132
144
  engine_getPayloadV4: ExecutionPayloadResponse;
133
145
  engine_getPayloadV5: ExecutionPayloadResponse;
146
+ engine_getPayloadV6: ExecutionPayloadResponse;
134
147
 
135
148
  engine_getPayloadBodiesByHashV1: (ExecutionPayloadBodyRpc | null)[];
136
149
 
@@ -180,6 +193,8 @@ export type ExecutionPayloadRpc = {
180
193
  withdrawals?: WithdrawalRpc[]; // Capella hardfork
181
194
  blobGasUsed?: QUANTITY; // DENEB
182
195
  excessBlobGas?: QUANTITY; // DENEB
196
+ blockAccessList?: DATA; // GLOAS:EIP-7928
197
+ slotNumber?: QUANTITY; // GLOAS:EIP-7843
183
198
  };
184
199
 
185
200
  export type WithdrawalRpc = {
@@ -228,6 +243,8 @@ export type PayloadAttributesRpc = {
228
243
  withdrawals?: WithdrawalRpc[];
229
244
  /** DATA, 32 Bytes - value for the parentBeaconBlockRoot to be used for building block */
230
245
  parentBeaconBlockRoot?: DATA;
246
+ /** QUANTITY, 64 Bits - value for the slot number field of the new payload (EIP-7843) */
247
+ slotNumber?: QUANTITY;
231
248
  };
232
249
 
233
250
  export type ClientVersionRpc = {
@@ -280,6 +297,12 @@ export function serializeExecutionPayload(fork: ForkName, data: ExecutionPayload
280
297
 
281
298
  // No changes in Electra
282
299
 
300
+ if (ForkSeq[fork] >= ForkSeq.gloas) {
301
+ const {blockAccessList, slotNumber} = data as gloas.ExecutionPayload;
302
+ payload.blockAccessList = bytesToData(blockAccessList);
303
+ payload.slotNumber = numToQuantity(slotNumber);
304
+ }
305
+
283
306
  return payload;
284
307
  }
285
308
 
@@ -375,6 +398,22 @@ export function parseExecutionPayload(
375
398
 
376
399
  // No changes in Electra
377
400
 
401
+ if (ForkSeq[fork] >= ForkSeq.gloas) {
402
+ const {blockAccessList, slotNumber} = data;
403
+ if (blockAccessList == null) {
404
+ throw Error(
405
+ `blockAccessList missing for ${fork} >= gloas executionPayload number=${executionPayload.blockNumber} hash=${data.blockHash}`
406
+ );
407
+ }
408
+ if (slotNumber == null) {
409
+ throw Error(
410
+ `slotNumber missing for ${fork} >= gloas executionPayload number=${executionPayload.blockNumber} hash=${data.blockHash}`
411
+ );
412
+ }
413
+ (executionPayload as gloas.ExecutionPayload).blockAccessList = dataToBytes(blockAccessList, null);
414
+ (executionPayload as gloas.ExecutionPayload).slotNumber = quantityToNum(slotNumber);
415
+ }
416
+
378
417
  return {executionPayload, executionPayloadValue, blobsBundle, executionRequests, shouldOverrideBuilder};
379
418
  }
380
419
 
@@ -385,6 +424,7 @@ export function serializePayloadAttributes(data: PayloadAttributes): PayloadAttr
385
424
  suggestedFeeRecipient: data.suggestedFeeRecipient,
386
425
  withdrawals: data.withdrawals?.map(serializeWithdrawal),
387
426
  parentBeaconBlockRoot: data.parentBeaconBlockRoot ? bytesToData(data.parentBeaconBlockRoot) : undefined,
427
+ slotNumber: data.slotNumber !== undefined ? numToQuantity(data.slotNumber) : undefined,
388
428
  };
389
429
  }
390
430
 
@@ -401,6 +441,7 @@ export function deserializePayloadAttributes(data: PayloadAttributesRpc): Payloa
401
441
  suggestedFeeRecipient: data.suggestedFeeRecipient,
402
442
  withdrawals: data.withdrawals?.map((withdrawal) => deserializeWithdrawal(withdrawal)),
403
443
  parentBeaconBlockRoot: data.parentBeaconBlockRoot ? dataToBytes(data.parentBeaconBlockRoot, 32) : undefined,
444
+ slotNumber: data.slotNumber !== undefined ? quantityToNum(data.slotNumber) : undefined,
404
445
  };
405
446
  }
406
447
 
@@ -745,13 +745,29 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
745
745
  });
746
746
  }
747
747
 
748
- chain.processExecutionPayload(payloadInput, {validSignature: true}).catch((e) => {
749
- chain.logger.debug(
750
- "Error processing execution payload from gossip data column",
751
- {slot: dataColumnSlot, root: payloadInput.blockRootHex},
752
- e as Error
753
- );
754
- });
748
+ // NOTE: we do NOT call chain.processExecutionPayload here. That is triggered only by
749
+ // envelope arrival (gossip or API). An in-flight importExecutionPayload is awaiting
750
+ // payloadInput.waitForAllData(); addColumn above will resolve it once hasAllData flips.
751
+
752
+ if (!payloadInput.isComplete()) {
753
+ const cutoffTimeMs = getCutoffTimeMs(chain, dataColumnSlot, BLOCK_AVAILABILITY_CUTOFF_MS);
754
+ // do not await here to not delay gossip validation
755
+ payloadInput.waitForEnvelopeAndAllData(cutoffTimeMs).catch((_e) => {
756
+ chain.logger.debug(
757
+ "Waited for envelope and data after receiving gossip column. Cut-off reached so emitting incompletePayloadEnvelope",
758
+ {
759
+ dataColumnIndex: index,
760
+ ...payloadInputMeta,
761
+ }
762
+ );
763
+ // TODO GLOAS: UnknownBlockSync to handle this event
764
+ chain.emitter.emit(ChainEvent.incompletePayloadEnvelope, {
765
+ payloadInput,
766
+ peer: peerIdStr,
767
+ source: BlockInputSource.gossip,
768
+ });
769
+ });
770
+ }
755
771
  } else {
756
772
  if (config.getForkSeq(dataColumnSlot) < ForkSeq.fulu) {
757
773
  throw new GossipActionError(GossipAction.REJECT, {code: "PRE_FULU_BLOCK"});
@@ -1148,6 +1164,11 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
1148
1164
  } catch (e) {
1149
1165
  logger.error("Error adding to executionPayloadBid pool", {}, e as Error);
1150
1166
  }
1167
+
1168
+ chain.emitter.emit(routes.events.EventType.executionPayloadBid, {
1169
+ version: config.getForkName(executionPayloadBid.message.slot),
1170
+ data: executionPayloadBid,
1171
+ });
1151
1172
  },
1152
1173
  };
1153
1174
  }
@@ -96,11 +96,13 @@ export function validateBeaconBlocksByRangeRequest(
96
96
  if (count < 1) {
97
97
  throw new ResponseError(RespStatus.INVALID_REQUEST, "count < 1");
98
98
  }
99
- // TODO: validate against MIN_EPOCHS_FOR_BLOCK_REQUESTS
100
99
  if (startSlot < GENESIS_SLOT) {
101
100
  throw new ResponseError(RespStatus.INVALID_REQUEST, "startSlot < genesis");
102
101
  }
103
102
 
103
+ // The phase0 req/resp spec uses MIN_EPOCHS_FOR_BLOCK_REQUESTS to define the minimum range peers MUST serve.
104
+ // Archival nodes may still serve older retained blocks to allow genesis sync.
105
+
104
106
  // step > 1 is deprecated, see https://github.com/ethereum/consensus-specs/pull/2856
105
107
 
106
108
  const maxRequestBlocks = isForkPostDeneb(config.getForkName(startSlot))
@@ -8,6 +8,9 @@ export async function* onBeaconBlocksByRoot(
8
8
  requestBody: BeaconBlocksByRootRequest,
9
9
  chain: IBeaconChain
10
10
  ): AsyncIterable<ResponseOutgoing> {
11
+ // The phase0 req/resp spec uses MIN_EPOCHS_FOR_BLOCK_REQUESTS to define the minimum range peers MUST serve.
12
+ // Archival nodes may still serve older retained blocks to allow genesis sync.
13
+
11
14
  for (const blockRoot of requestBody) {
12
15
  const root = blockRoot;
13
16
  const block = await chain.getSerializedBlockByRoot(toRootHex(root));
@@ -2,7 +2,7 @@ import {ChainConfig} from "@lodestar/config";
2
2
  import {BLOB_SIDECAR_FIXED_SIZE, GENESIS_SLOT} from "@lodestar/params";
3
3
  import {RespStatus, ResponseError, ResponseOutgoing} from "@lodestar/reqresp";
4
4
  import {computeEpochAtSlot} from "@lodestar/state-transition";
5
- import {Slot, deneb} from "@lodestar/types";
5
+ import {Epoch, Slot, deneb} from "@lodestar/types";
6
6
  import {fromHex} from "@lodestar/utils";
7
7
  import {IBeaconChain} from "../../../chain/index.js";
8
8
  import {IBeaconDb} from "../../../db/index.js";
@@ -14,7 +14,7 @@ export async function* onBlobSidecarsByRange(
14
14
  db: IBeaconDb
15
15
  ): AsyncIterable<ResponseOutgoing> {
16
16
  // Non-finalized range of blobs
17
- const {startSlot, count} = validateBlobSidecarsByRangeRequest(chain.config, request);
17
+ const {startSlot, count} = validateBlobSidecarsByRangeRequest(chain.config, chain.clock.currentEpoch, request);
18
18
  const endSlot = startSlot + count;
19
19
 
20
20
  const finalized = db.blobSidecarsArchive;
@@ -94,6 +94,7 @@ export function* iterateBlobBytesFromWrapper(
94
94
 
95
95
  export function validateBlobSidecarsByRangeRequest(
96
96
  config: ChainConfig,
97
+ currentEpoch: Epoch,
97
98
  request: deneb.BlobSidecarsByRangeRequest
98
99
  ): deneb.BlobSidecarsByRangeRequest {
99
100
  const {startSlot} = request;
@@ -102,11 +103,22 @@ export function validateBlobSidecarsByRangeRequest(
102
103
  if (count < 1) {
103
104
  throw new ResponseError(RespStatus.INVALID_REQUEST, "count < 1");
104
105
  }
105
- // TODO: validate against MIN_EPOCHS_FOR_BLOCK_REQUESTS
106
106
  if (startSlot < GENESIS_SLOT) {
107
107
  throw new ResponseError(RespStatus.INVALID_REQUEST, "startSlot < genesis");
108
108
  }
109
109
 
110
+ // Spec: [max(current_epoch - MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS, DENEB_FORK_EPOCH), current_epoch]
111
+ const minimumRequestEpoch = Math.max(
112
+ currentEpoch - config.MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS,
113
+ config.DENEB_FORK_EPOCH
114
+ );
115
+ if (computeEpochAtSlot(startSlot) < minimumRequestEpoch) {
116
+ throw new ResponseError(
117
+ RespStatus.RESOURCE_UNAVAILABLE,
118
+ "startSlot is before MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS"
119
+ );
120
+ }
121
+
110
122
  if (count > config.MAX_REQUEST_BLOCKS_DENEB) {
111
123
  count = config.MAX_REQUEST_BLOCKS_DENEB;
112
124
  }