@lodestar/beacon-node 1.52.0-dev.9c81d25e01 → 1.52.0-dev.a3cc0e0e58

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 (353) hide show
  1. package/lib/api/impl/beacon/blocks/index.d.ts.map +1 -1
  2. package/lib/api/impl/beacon/blocks/index.js +64 -39
  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 -2
  6. package/lib/api/impl/beacon/pool/index.js.map +1 -1
  7. package/lib/api/impl/beacon/state/utils.d.ts.map +1 -1
  8. package/lib/api/impl/beacon/state/utils.js +2 -1
  9. package/lib/api/impl/beacon/state/utils.js.map +1 -1
  10. package/lib/api/impl/debug/index.d.ts.map +1 -1
  11. package/lib/api/impl/debug/index.js +6 -2
  12. package/lib/api/impl/debug/index.js.map +1 -1
  13. package/lib/api/impl/validator/index.d.ts.map +1 -1
  14. package/lib/api/impl/validator/index.js +91 -51
  15. package/lib/api/impl/validator/index.js.map +1 -1
  16. package/lib/chain/ColumnReconstructionTracker.d.ts +4 -0
  17. package/lib/chain/ColumnReconstructionTracker.d.ts.map +1 -1
  18. package/lib/chain/ColumnReconstructionTracker.js +4 -0
  19. package/lib/chain/ColumnReconstructionTracker.js.map +1 -1
  20. package/lib/chain/archiveStore/historicalState/getHistoricalState.d.ts.map +1 -1
  21. package/lib/chain/archiveStore/historicalState/getHistoricalState.js +7 -0
  22. package/lib/chain/archiveStore/historicalState/getHistoricalState.js.map +1 -1
  23. package/lib/chain/archiveStore/utils/archiveBlocks.js +1 -1
  24. package/lib/chain/archiveStore/utils/archiveBlocks.js.map +1 -1
  25. package/lib/chain/archiveStore/utils/pruneHistory.d.ts.map +1 -1
  26. package/lib/chain/archiveStore/utils/pruneHistory.js +8 -4
  27. package/lib/chain/archiveStore/utils/pruneHistory.js.map +1 -1
  28. package/lib/chain/blocks/importExecutionPayload.d.ts +1 -1
  29. package/lib/chain/blocks/importExecutionPayload.d.ts.map +1 -1
  30. package/lib/chain/blocks/importExecutionPayload.js +9 -3
  31. package/lib/chain/blocks/importExecutionPayload.js.map +1 -1
  32. package/lib/chain/blocks/index.d.ts.map +1 -1
  33. package/lib/chain/blocks/index.js +3 -17
  34. package/lib/chain/blocks/index.js.map +1 -1
  35. package/lib/chain/chain.d.ts +7 -6
  36. package/lib/chain/chain.d.ts.map +1 -1
  37. package/lib/chain/chain.js +92 -47
  38. package/lib/chain/chain.js.map +1 -1
  39. package/lib/chain/errors/attestationError.d.ts +15 -1
  40. package/lib/chain/errors/attestationError.d.ts.map +1 -1
  41. package/lib/chain/errors/attestationError.js +8 -0
  42. package/lib/chain/errors/attestationError.js.map +1 -1
  43. package/lib/chain/errors/executionPayloadBid.d.ts +9 -3
  44. package/lib/chain/errors/executionPayloadBid.d.ts.map +1 -1
  45. package/lib/chain/errors/executionPayloadBid.js +2 -1
  46. package/lib/chain/errors/executionPayloadBid.js.map +1 -1
  47. package/lib/chain/errors/executionPayloadEnvelope.d.ts +55 -0
  48. package/lib/chain/errors/executionPayloadEnvelope.d.ts.map +1 -1
  49. package/lib/chain/errors/executionPayloadEnvelope.js +8 -0
  50. package/lib/chain/errors/executionPayloadEnvelope.js.map +1 -1
  51. package/lib/chain/interface.d.ts +1 -1
  52. package/lib/chain/interface.d.ts.map +1 -1
  53. package/lib/chain/lightClient/index.d.ts +13 -6
  54. package/lib/chain/lightClient/index.d.ts.map +1 -1
  55. package/lib/chain/lightClient/index.js +95 -115
  56. package/lib/chain/lightClient/index.js.map +1 -1
  57. package/lib/chain/opPools/opPool.js +6 -6
  58. package/lib/chain/opPools/opPool.js.map +1 -1
  59. package/lib/chain/prepareNextSlot.d.ts +45 -0
  60. package/lib/chain/prepareNextSlot.d.ts.map +1 -1
  61. package/lib/chain/prepareNextSlot.js +265 -69
  62. package/lib/chain/prepareNextSlot.js.map +1 -1
  63. package/lib/chain/produceBlock/produceBlockBody.d.ts +6 -2
  64. package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
  65. package/lib/chain/produceBlock/produceBlockBody.js +54 -64
  66. package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
  67. package/lib/chain/seenCache/seenAttesters.d.ts +1 -0
  68. package/lib/chain/seenCache/seenAttesters.d.ts.map +1 -1
  69. package/lib/chain/seenCache/seenAttesters.js +1 -1
  70. package/lib/chain/seenCache/seenAttesters.js.map +1 -1
  71. package/lib/chain/seenCache/seenBlockAttesters.d.ts +8 -2
  72. package/lib/chain/seenCache/seenBlockAttesters.d.ts.map +1 -1
  73. package/lib/chain/seenCache/seenBlockAttesters.js +43 -6
  74. package/lib/chain/seenCache/seenBlockAttesters.js.map +1 -1
  75. package/lib/chain/seenCache/seenExecutionPayloadBids.d.ts +13 -4
  76. package/lib/chain/seenCache/seenExecutionPayloadBids.d.ts.map +1 -1
  77. package/lib/chain/seenCache/seenExecutionPayloadBids.js +13 -12
  78. package/lib/chain/seenCache/seenExecutionPayloadBids.js.map +1 -1
  79. package/lib/chain/validation/aggregateAndProof.d.ts.map +1 -1
  80. package/lib/chain/validation/aggregateAndProof.js +24 -7
  81. package/lib/chain/validation/aggregateAndProof.js.map +1 -1
  82. package/lib/chain/validation/attestation.d.ts.map +1 -1
  83. package/lib/chain/validation/attestation.js +32 -16
  84. package/lib/chain/validation/attestation.js.map +1 -1
  85. package/lib/chain/validation/attesterSlashing.d.ts.map +1 -1
  86. package/lib/chain/validation/attesterSlashing.js +4 -2
  87. package/lib/chain/validation/attesterSlashing.js.map +1 -1
  88. package/lib/chain/validation/block.d.ts.map +1 -1
  89. package/lib/chain/validation/block.js +9 -1
  90. package/lib/chain/validation/block.js.map +1 -1
  91. package/lib/chain/validation/executionPayloadBid.d.ts.map +1 -1
  92. package/lib/chain/validation/executionPayloadBid.js +47 -42
  93. package/lib/chain/validation/executionPayloadBid.js.map +1 -1
  94. package/lib/chain/validation/executionPayloadEnvelope.d.ts.map +1 -1
  95. package/lib/chain/validation/executionPayloadEnvelope.js +100 -9
  96. package/lib/chain/validation/executionPayloadEnvelope.js.map +1 -1
  97. package/lib/chain/validation/payloadAttestationMessage.js +9 -0
  98. package/lib/chain/validation/payloadAttestationMessage.js.map +1 -1
  99. package/lib/chain/validation/proposerSlashing.js +4 -2
  100. package/lib/chain/validation/proposerSlashing.js.map +1 -1
  101. package/lib/chain/validation/signatureSets/contributionAndProof.d.ts +2 -2
  102. package/lib/chain/validation/signatureSets/contributionAndProof.d.ts.map +1 -1
  103. package/lib/chain/validation/signatureSets/contributionAndProof.js +2 -2
  104. package/lib/chain/validation/signatureSets/contributionAndProof.js.map +1 -1
  105. package/lib/chain/validation/signatureSets/syncCommittee.d.ts +2 -2
  106. package/lib/chain/validation/signatureSets/syncCommittee.d.ts.map +1 -1
  107. package/lib/chain/validation/signatureSets/syncCommittee.js +2 -2
  108. package/lib/chain/validation/signatureSets/syncCommittee.js.map +1 -1
  109. package/lib/chain/validation/signatureSets/syncCommitteeContribution.d.ts +2 -2
  110. package/lib/chain/validation/signatureSets/syncCommitteeContribution.d.ts.map +1 -1
  111. package/lib/chain/validation/signatureSets/syncCommitteeContribution.js +2 -2
  112. package/lib/chain/validation/signatureSets/syncCommitteeContribution.js.map +1 -1
  113. package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.d.ts +2 -2
  114. package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.d.ts.map +1 -1
  115. package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.js +2 -2
  116. package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.js.map +1 -1
  117. package/lib/chain/validation/syncCommittee.d.ts +1 -1
  118. package/lib/chain/validation/syncCommittee.d.ts.map +1 -1
  119. package/lib/chain/validation/syncCommittee.js +5 -5
  120. package/lib/chain/validation/syncCommittee.js.map +1 -1
  121. package/lib/chain/validation/syncCommitteeContributionAndProof.js +3 -3
  122. package/lib/chain/validation/syncCommitteeContributionAndProof.js.map +1 -1
  123. package/lib/chain/validation/voluntaryExit.d.ts.map +1 -1
  124. package/lib/chain/validation/voluntaryExit.js +39 -6
  125. package/lib/chain/validation/voluntaryExit.js.map +1 -1
  126. package/lib/chain/validatorMonitor.js +43 -43
  127. package/lib/chain/validatorMonitor.js.map +1 -1
  128. package/lib/execution/engine/blockHash.d.ts +12 -0
  129. package/lib/execution/engine/blockHash.d.ts.map +1 -0
  130. package/lib/execution/engine/blockHash.js +17 -0
  131. package/lib/execution/engine/blockHash.js.map +1 -0
  132. package/lib/execution/engine/http.d.ts +2 -2
  133. package/lib/execution/engine/http.d.ts.map +1 -1
  134. package/lib/execution/engine/http.js +13 -7
  135. package/lib/execution/engine/http.js.map +1 -1
  136. package/lib/execution/engine/interface.d.ts +16 -3
  137. package/lib/execution/engine/interface.d.ts.map +1 -1
  138. package/lib/execution/engine/interface.js +11 -0
  139. package/lib/execution/engine/interface.js.map +1 -1
  140. package/lib/execution/engine/jsonRpcHttpClient.d.ts +2 -0
  141. package/lib/execution/engine/jsonRpcHttpClient.d.ts.map +1 -1
  142. package/lib/execution/engine/jsonRpcHttpClient.js +14 -6
  143. package/lib/execution/engine/jsonRpcHttpClient.js.map +1 -1
  144. package/lib/execution/engine/jsonRpcTransport.d.ts +2 -2
  145. package/lib/execution/engine/jsonRpcTransport.d.ts.map +1 -1
  146. package/lib/execution/engine/jsonRpcTransport.js +4 -4
  147. package/lib/execution/engine/jsonRpcTransport.js.map +1 -1
  148. package/lib/execution/engine/mock.d.ts.map +1 -1
  149. package/lib/execution/engine/mock.js +6 -6
  150. package/lib/execution/engine/mock.js.map +1 -1
  151. package/lib/execution/engine/payloadIdCache.d.ts +6 -1
  152. package/lib/execution/engine/payloadIdCache.d.ts.map +1 -1
  153. package/lib/execution/engine/payloadIdCache.js +7 -2
  154. package/lib/execution/engine/payloadIdCache.js.map +1 -1
  155. package/lib/execution/engine/restHttpClient.d.ts.map +1 -1
  156. package/lib/execution/engine/restHttpClient.js +9 -5
  157. package/lib/execution/engine/restHttpClient.js.map +1 -1
  158. package/lib/execution/engine/restTransport.d.ts +2 -2
  159. package/lib/execution/engine/restTransport.d.ts.map +1 -1
  160. package/lib/execution/engine/restTransport.js +4 -4
  161. package/lib/execution/engine/restTransport.js.map +1 -1
  162. package/lib/execution/engine/signal.d.ts +6 -0
  163. package/lib/execution/engine/signal.d.ts.map +1 -0
  164. package/lib/execution/engine/signal.js +24 -0
  165. package/lib/execution/engine/signal.js.map +1 -0
  166. package/lib/execution/engine/transport.d.ts +2 -2
  167. package/lib/execution/engine/transport.d.ts.map +1 -1
  168. package/lib/index.d.ts +1 -1
  169. package/lib/index.d.ts.map +1 -1
  170. package/lib/index.js +1 -1
  171. package/lib/index.js.map +1 -1
  172. package/lib/metrics/metrics/beacon.d.ts +5 -0
  173. package/lib/metrics/metrics/beacon.d.ts.map +1 -1
  174. package/lib/metrics/metrics/beacon.js +5 -0
  175. package/lib/metrics/metrics/beacon.js.map +1 -1
  176. package/lib/metrics/metrics/lodestar.d.ts +1 -0
  177. package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
  178. package/lib/metrics/metrics/lodestar.js +5 -0
  179. package/lib/metrics/metrics/lodestar.js.map +1 -1
  180. package/lib/network/core/events.d.ts +6 -2
  181. package/lib/network/core/events.d.ts.map +1 -1
  182. package/lib/network/core/events.js +9 -0
  183. package/lib/network/core/events.js.map +1 -1
  184. package/lib/network/core/networkCoreWorkerHandler.d.ts.map +1 -1
  185. package/lib/network/core/networkCoreWorkerHandler.js +3 -2
  186. package/lib/network/core/networkCoreWorkerHandler.js.map +1 -1
  187. package/lib/network/gossip/gossipsub.d.ts +1 -0
  188. package/lib/network/gossip/gossipsub.d.ts.map +1 -1
  189. package/lib/network/gossip/gossipsub.js +5 -2
  190. package/lib/network/gossip/gossipsub.js.map +1 -1
  191. package/lib/network/gossip/topic.d.ts +1 -7
  192. package/lib/network/gossip/topic.d.ts.map +1 -1
  193. package/lib/network/gossip/topic.js +0 -13
  194. package/lib/network/gossip/topic.js.map +1 -1
  195. package/lib/network/network.d.ts +1 -0
  196. package/lib/network/network.d.ts.map +1 -1
  197. package/lib/network/network.js +32 -18
  198. package/lib/network/network.js.map +1 -1
  199. package/lib/network/peers/peerManager.d.ts.map +1 -1
  200. package/lib/network/peers/peerManager.js +22 -2
  201. package/lib/network/peers/peerManager.js.map +1 -1
  202. package/lib/network/peers/utils/prioritizePeers.d.ts +2 -0
  203. package/lib/network/peers/utils/prioritizePeers.d.ts.map +1 -1
  204. package/lib/network/peers/utils/prioritizePeers.js +11 -2
  205. package/lib/network/peers/utils/prioritizePeers.js.map +1 -1
  206. package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
  207. package/lib/network/processor/gossipHandlers.js +19 -6
  208. package/lib/network/processor/gossipHandlers.js.map +1 -1
  209. package/lib/network/processor/gossipValidatorFn.d.ts.map +1 -1
  210. package/lib/network/processor/gossipValidatorFn.js +4 -1
  211. package/lib/network/processor/gossipValidatorFn.js.map +1 -1
  212. package/lib/network/processor/index.d.ts.map +1 -1
  213. package/lib/network/processor/index.js +4 -2
  214. package/lib/network/processor/index.js.map +1 -1
  215. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js +1 -1
  216. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js.map +1 -1
  217. package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.js +1 -1
  218. package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.js.map +1 -1
  219. package/lib/network/reqresp/utils/collect.d.ts +4 -4
  220. package/lib/network/reqresp/utils/collect.d.ts.map +1 -1
  221. package/lib/network/reqresp/utils/collect.js +9 -8
  222. package/lib/network/reqresp/utils/collect.js.map +1 -1
  223. package/lib/network/reqresp/utils/collectSequentialBlocksInRange.d.ts +1 -1
  224. package/lib/network/reqresp/utils/collectSequentialBlocksInRange.d.ts.map +1 -1
  225. package/lib/network/reqresp/utils/collectSequentialBlocksInRange.js +2 -2
  226. package/lib/network/reqresp/utils/collectSequentialBlocksInRange.js.map +1 -1
  227. package/lib/sync/range/batch.d.ts +10 -0
  228. package/lib/sync/range/batch.d.ts.map +1 -1
  229. package/lib/sync/range/batch.js +29 -0
  230. package/lib/sync/range/batch.js.map +1 -1
  231. package/lib/sync/range/chain.d.ts +17 -2
  232. package/lib/sync/range/chain.d.ts.map +1 -1
  233. package/lib/sync/range/chain.js +60 -20
  234. package/lib/sync/range/chain.js.map +1 -1
  235. package/lib/sync/range/range.d.ts.map +1 -1
  236. package/lib/sync/range/range.js +44 -3
  237. package/lib/sync/range/range.js.map +1 -1
  238. package/lib/sync/range/utils/batches.d.ts +20 -4
  239. package/lib/sync/range/utils/batches.d.ts.map +1 -1
  240. package/lib/sync/range/utils/batches.js +31 -13
  241. package/lib/sync/range/utils/batches.js.map +1 -1
  242. package/lib/sync/range/utils/peerBalancer.d.ts +1 -1
  243. package/lib/sync/range/utils/peerBalancer.d.ts.map +1 -1
  244. package/lib/sync/range/utils/peerBalancer.js +5 -2
  245. package/lib/sync/range/utils/peerBalancer.js.map +1 -1
  246. package/lib/sync/types.d.ts +14 -1
  247. package/lib/sync/types.d.ts.map +1 -1
  248. package/lib/sync/types.js +2 -0
  249. package/lib/sync/types.js.map +1 -1
  250. package/lib/sync/unknownBlock.d.ts +28 -1
  251. package/lib/sync/unknownBlock.d.ts.map +1 -1
  252. package/lib/sync/unknownBlock.js +340 -27
  253. package/lib/sync/unknownBlock.js.map +1 -1
  254. package/lib/sync/utils/downloadByRange.d.ts +22 -1
  255. package/lib/sync/utils/downloadByRange.d.ts.map +1 -1
  256. package/lib/sync/utils/downloadByRange.js +55 -25
  257. package/lib/sync/utils/downloadByRange.js.map +1 -1
  258. package/lib/sync/utils/downloadByRoot.d.ts +24 -2
  259. package/lib/sync/utils/downloadByRoot.d.ts.map +1 -1
  260. package/lib/sync/utils/downloadByRoot.js +48 -5
  261. package/lib/sync/utils/downloadByRoot.js.map +1 -1
  262. package/lib/util/asyncIterableToEvents.d.ts +20 -3
  263. package/lib/util/asyncIterableToEvents.d.ts.map +1 -1
  264. package/lib/util/asyncIterableToEvents.js +76 -20
  265. package/lib/util/asyncIterableToEvents.js.map +1 -1
  266. package/lib/util/dataColumns.d.ts +1 -1
  267. package/lib/util/dataColumns.d.ts.map +1 -1
  268. package/lib/util/dataColumns.js +4 -1
  269. package/lib/util/dataColumns.js.map +1 -1
  270. package/lib/util/eventLoop.d.ts +3 -3
  271. package/lib/util/eventLoop.d.ts.map +1 -1
  272. package/lib/util/eventLoop.js +3 -3
  273. package/lib/util/eventLoop.js.map +1 -1
  274. package/package.json +27 -27
  275. package/src/api/impl/beacon/blocks/index.ts +75 -47
  276. package/src/api/impl/beacon/pool/index.ts +10 -8
  277. package/src/api/impl/beacon/state/utils.ts +2 -1
  278. package/src/api/impl/debug/index.ts +6 -2
  279. package/src/api/impl/validator/index.ts +126 -68
  280. package/src/chain/ColumnReconstructionTracker.ts +5 -0
  281. package/src/chain/archiveStore/historicalState/getHistoricalState.ts +9 -0
  282. package/src/chain/archiveStore/utils/archiveBlocks.ts +1 -1
  283. package/src/chain/archiveStore/utils/pruneHistory.ts +9 -4
  284. package/src/chain/blocks/importExecutionPayload.ts +9 -2
  285. package/src/chain/blocks/index.ts +3 -31
  286. package/src/chain/chain.ts +124 -84
  287. package/src/chain/errors/attestationError.ts +11 -1
  288. package/src/chain/errors/executionPayloadBid.ts +9 -2
  289. package/src/chain/errors/executionPayloadEnvelope.ts +58 -0
  290. package/src/chain/interface.ts +1 -1
  291. package/src/chain/lightClient/index.ts +108 -142
  292. package/src/chain/opPools/opPool.ts +6 -6
  293. package/src/chain/prepareNextSlot.ts +347 -89
  294. package/src/chain/produceBlock/produceBlockBody.ts +69 -80
  295. package/src/chain/seenCache/seenAttesters.ts +1 -1
  296. package/src/chain/seenCache/seenBlockAttesters.ts +48 -6
  297. package/src/chain/seenCache/seenExecutionPayloadBids.ts +35 -15
  298. package/src/chain/validation/aggregateAndProof.ts +24 -9
  299. package/src/chain/validation/attestation.ts +31 -20
  300. package/src/chain/validation/attesterSlashing.ts +4 -2
  301. package/src/chain/validation/block.ts +9 -1
  302. package/src/chain/validation/executionPayloadBid.ts +60 -44
  303. package/src/chain/validation/executionPayloadEnvelope.ts +115 -8
  304. package/src/chain/validation/payloadAttestationMessage.ts +10 -0
  305. package/src/chain/validation/proposerSlashing.ts +4 -2
  306. package/src/chain/validation/signatureSets/contributionAndProof.ts +4 -6
  307. package/src/chain/validation/signatureSets/syncCommittee.ts +2 -3
  308. package/src/chain/validation/signatureSets/syncCommitteeContribution.ts +2 -3
  309. package/src/chain/validation/signatureSets/syncCommitteeSelectionProof.ts +2 -3
  310. package/src/chain/validation/syncCommittee.ts +3 -5
  311. package/src/chain/validation/syncCommitteeContributionAndProof.ts +3 -3
  312. package/src/chain/validation/voluntaryExit.ts +44 -6
  313. package/src/chain/validatorMonitor.ts +43 -43
  314. package/src/execution/engine/blockHash.ts +27 -0
  315. package/src/execution/engine/http.ts +18 -10
  316. package/src/execution/engine/interface.ts +18 -3
  317. package/src/execution/engine/jsonRpcHttpClient.ts +26 -14
  318. package/src/execution/engine/jsonRpcTransport.ts +8 -4
  319. package/src/execution/engine/mock.ts +13 -8
  320. package/src/execution/engine/payloadIdCache.ts +12 -4
  321. package/src/execution/engine/restHttpClient.ts +17 -11
  322. package/src/execution/engine/restTransport.ts +5 -4
  323. package/src/execution/engine/signal.ts +28 -0
  324. package/src/execution/engine/transport.ts +3 -2
  325. package/src/index.ts +6 -1
  326. package/src/metrics/metrics/beacon.ts +9 -0
  327. package/src/metrics/metrics/lodestar.ts +5 -0
  328. package/src/network/core/events.ts +12 -0
  329. package/src/network/core/networkCoreWorkerHandler.ts +6 -2
  330. package/src/network/gossip/gossipsub.ts +6 -2
  331. package/src/network/gossip/topic.ts +1 -14
  332. package/src/network/network.ts +45 -19
  333. package/src/network/peers/peerManager.ts +26 -2
  334. package/src/network/peers/utils/prioritizePeers.ts +14 -1
  335. package/src/network/processor/gossipHandlers.ts +25 -13
  336. package/src/network/processor/gossipValidatorFn.ts +4 -0
  337. package/src/network/processor/index.ts +7 -2
  338. package/src/network/reqresp/handlers/dataColumnSidecarsByRange.ts +1 -1
  339. package/src/network/reqresp/handlers/dataColumnSidecarsByRoot.ts +1 -1
  340. package/src/network/reqresp/utils/collect.ts +16 -8
  341. package/src/network/reqresp/utils/collectSequentialBlocksInRange.ts +3 -2
  342. package/src/sync/range/batch.ts +33 -0
  343. package/src/sync/range/chain.ts +72 -17
  344. package/src/sync/range/range.ts +57 -3
  345. package/src/sync/range/utils/batches.ts +38 -13
  346. package/src/sync/range/utils/peerBalancer.ts +4 -1
  347. package/src/sync/types.ts +13 -0
  348. package/src/sync/unknownBlock.ts +389 -29
  349. package/src/sync/utils/downloadByRange.ts +89 -29
  350. package/src/sync/utils/downloadByRoot.ts +75 -7
  351. package/src/util/asyncIterableToEvents.ts +100 -21
  352. package/src/util/dataColumns.ts +4 -1
  353. package/src/util/eventLoop.ts +3 -3
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/api/impl/validator/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,eAAe,CAAC;AACrC,OAAO,EAAC,kBAAkB,EAAC,MAAM,sBAAsB,CAAC;AAmCxD,OAAO,EAQL,mBAAmB,EAUpB,MAAM,iBAAiB,CAAC;AAmDzB,OAAO,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AAG5C,OAAO,EAAC,UAAU,EAAC,MAAM,aAAa,CAAC;AAmBvC;;;;GAIG;AACH,eAAO,MAAM,sCAAsC,OAAO,CAAC;AA8D3D;;GAEG;AACH,oBAAY,0BAA0B;IACpC,eAAe,qBAAqB;IACpC,YAAY,kBAAkB;IAC9B,cAAc,oBAAoB;IAClC,cAAc,oBAAoB;IAClC,YAAY,mBAAmB;IAC/B,qBAAqB,4BAA4B;IACjD,iBAAiB,uBAAuB;IACxC,UAAU,gBAAgB;IAC1B,eAAe,qBAAqB;CACrC;AAED;;GAEG;AACH,oBAAY,2BAA2B;IACrC,cAAc,oBAAoB;IAClC,WAAW,iBAAiB;IAC5B,aAAa,mBAAmB;IAChC,UAAU,gBAAgB;IAC1B,gBAAgB,sBAAsB;CACvC;AAED,MAAM,MAAM,oBAAoB,GAC5B;IACE,MAAM,EAAE,mBAAmB,CAAC,MAAM,CAAC;IACnC,MAAM,EAAE,0BAA0B,CAAC;CACpC,GACD;IACE,MAAM,EAAE,mBAAmB,CAAC,OAAO,CAAC;IACpC,MAAM,EAAE,2BAA2B,CAAC;CACrC,CAAC;AAEN;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,UAAU,EAChB,EAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAC,EAAE,UAAU,GAC1D,kBAAkB,CAAC,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC,CAsnEhD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/api/impl/validator/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,eAAe,CAAC;AACrC,OAAO,EAAC,kBAAkB,EAAC,MAAM,sBAAsB,CAAC;AAoCxD,OAAO,EAQL,mBAAmB,EAUpB,MAAM,iBAAiB,CAAC;AAmDzB,OAAO,EAAC,UAAU,EAAC,MAAM,kBAAkB,CAAC;AAG5C,OAAO,EAAC,UAAU,EAAC,MAAM,aAAa,CAAC;AAmBvC;;;;GAIG;AACH,eAAO,MAAM,sCAAsC,OAAO,CAAC;AA8D3D;;GAEG;AACH,oBAAY,0BAA0B;IACpC,eAAe,qBAAqB;IACpC,YAAY,kBAAkB;IAC9B,cAAc,oBAAoB;IAClC,cAAc,oBAAoB;IAClC,YAAY,mBAAmB;IAC/B,qBAAqB,4BAA4B;IACjD,iBAAiB,uBAAuB;IACxC,UAAU,gBAAgB;IAC1B,eAAe,qBAAqB;CACrC;AAED;;GAEG;AACH,oBAAY,2BAA2B;IACrC,cAAc,oBAAoB;IAClC,WAAW,iBAAiB;IAC5B,aAAa,mBAAmB;IAChC,UAAU,gBAAgB;IAC1B,gBAAgB,sBAAsB;CACvC;AAED,MAAM,MAAM,oBAAoB,GAC5B;IACE,MAAM,EAAE,mBAAmB,CAAC,MAAM,CAAC;IACnC,MAAM,EAAE,0BAA0B,CAAC;CACpC,GACD;IACE,MAAM,EAAE,mBAAmB,CAAC,OAAO,CAAC;IACpC,MAAM,EAAE,2BAA2B,CAAC;CACrC,CAAC;AAEN;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,UAAU,EAChB,EAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAC,EAAE,UAAU,GAC1D,kBAAkB,CAAC,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC,CA+qEhD"}
@@ -1,6 +1,6 @@
1
1
  import { routes } from "@lodestar/api";
2
2
  import { ExecutionStatus, PayloadStatus } from "@lodestar/fork-choice";
3
- import { BUILDER_INDEX_SELF_BUILD, ForkName, ForkSeq, GENESIS_SLOT, SLOTS_PER_EPOCH, SLOTS_PER_HISTORICAL_ROOT, SYNC_COMMITTEE_SUBNET_SIZE, isForkPostBellatrix, isForkPostDeneb, isForkPostElectra, isForkPostFulu, isForkPostGloas, isForkPostHeze, } from "@lodestar/params";
3
+ import { BUILDER_INDEX_SELF_BUILD, ForkName, ForkSeq, GENESIS_EPOCH, GENESIS_SLOT, SLOTS_PER_EPOCH, SLOTS_PER_HISTORICAL_ROOT, SYNC_COMMITTEE_SUBNET_SIZE, isForkPostBellatrix, isForkPostDeneb, isForkPostElectra, isForkPostFulu, isForkPostGloas, isForkPostHeze, } from "@lodestar/params";
4
4
  import { DataAvailabilityStatus, beaconBlockToBlinded, calculateCommitteeAssignments, computeEpochAtSlot, computeStartSlotAtEpoch, computeTimeAtSlot, getCurrentSlot, getInclusionListCommittee, isStatePostAltair, isStatePostGloas, proposerShufflingDecisionRoot, } from "@lodestar/state-transition";
5
5
  import { ProducedBlockSource, getValidatorStatus, ssz, } from "@lodestar/types";
6
6
  import { GWEI_TO_WEI, TimeoutError, byteArrayEquals, defer, formatWeiToEth, fromHex, prettyGweiToEth, prettyWeiToEth, resolveOrRacePromises, sleep, toHex, toPrintableUrl, toRootHex, } from "@lodestar/utils";
@@ -44,8 +44,6 @@ const BLOCK_PRODUCTION_RACE_CUTOFF_BPS = 1667;
44
44
  * TODO GLOAS: revisit, the block propagates faster as it only commits to a bid and the attestation deadline changed
45
45
  */
46
46
  export const BLOCK_PRODUCTION_RACE_CUTOFF_GLOAS_BPS = 1667;
47
- /** Rejection message of the bid block branch when there is no viable bid to commit to */
48
- const NO_BID_AVAILABLE = "No builder bid available";
49
47
  /**
50
48
  * Ranking value of a bid, the boosted total payment scaled by 100 as `boostFactor` is a percentage.
51
49
  * Kept scaled so bids that differ by less than a percent are not truncated into a tie.
@@ -256,7 +254,7 @@ export function getValidatorApi(opts, { chain, config, logger, metrics, network,
256
254
  * Both the above scenarios could be problematic and hence validator shouldn't participate
257
255
  * or weigh its vote on a head till it resolves to a Valid execution status.
258
256
  * Following activities should be skipped on an Optimistic head (with Syncing status):
259
- * 1. Attestation if targetRoot is optimistic
257
+ * 1. Attestation if the head block voted for (post-gloas the variant voted for) or the targetRoot is optimistic
260
258
  * 2. SyncCommitteeContribution if if the root for which to produce contribution is Optimistic.
261
259
  * 3. ProduceBlock if the parentRoot (chain's current head) is optimistic. Must be checked
262
260
  * explicitly as only local payload production consults the EL, blinded blocks from an
@@ -284,7 +282,7 @@ export function getValidatorApi(opts, { chain, config, logger, metrics, network,
284
282
  }
285
283
  async function produceBuilderBlindedBlock(slot, randaoReveal, graffiti,
286
284
  // as of now fee recipient checks can not be performed because builder does not return bid recipient
287
- { commonBlockBodyPromise, parentBlock, }) {
285
+ { commonBlockBodyPromise, parentBlock, parentStatesPromise, }) {
288
286
  const version = config.getForkName(slot);
289
287
  if (!isForkPostBellatrix(version)) {
290
288
  throw Error(`Invalid fork=${version} for produceBuilderBlindedBlock`);
@@ -313,6 +311,7 @@ export function getValidatorApi(opts, { chain, config, logger, metrics, network,
313
311
  randaoReveal,
314
312
  graffiti,
315
313
  commonBlockBodyPromise,
314
+ ...(await parentStatesPromise),
316
315
  });
317
316
  metrics?.blockProductionSuccess.inc({ source });
318
317
  metrics?.blockProductionNumAggregated.observe({ source }, block.body.attestations.length);
@@ -334,7 +333,7 @@ export function getValidatorApi(opts, { chain, config, logger, metrics, network,
334
333
  timer({ source });
335
334
  }
336
335
  }
337
- async function produceEngineBlockContents(slot, randaoReveal, graffiti, { feeRecipient, strictFeeRecipientCheck, commonBlockBodyPromise, parentBlock, }) {
336
+ async function produceEngineBlockContents(slot, randaoReveal, graffiti, { feeRecipient, strictFeeRecipientCheck, commonBlockBodyPromise, parentBlock, parentStatesPromise, }) {
338
337
  const version = config.getForkName(slot);
339
338
  if (isForkPostGloas(version)) {
340
339
  throw Error(`produceEngineBlockContents called for post-gloas fork=${version}`);
@@ -351,6 +350,7 @@ export function getValidatorApi(opts, { chain, config, logger, metrics, network,
351
350
  graffiti,
352
351
  feeRecipient,
353
352
  commonBlockBodyPromise,
353
+ ...(await parentStatesPromise),
354
354
  });
355
355
  if (strictFeeRecipientCheck && feeRecipient && isForkPostBellatrix(version)) {
356
356
  const blockFeeRecipient = toHex(block.body.executionPayload.feeRecipient);
@@ -432,6 +432,12 @@ export function getValidatorApi(opts, { chain, config, logger, metrics, network,
432
432
  }
433
433
  notOnOutOfRangeData(parentBlockRoot);
434
434
  metrics?.blockProductionSlotDelta.set(slot - parentSlot);
435
+ // Fetch the production state once and thread it to all downstream production calls, not awaited so each
436
+ // block source includes it in its production time. Only reached for pre-gloas slots (produceBlockV3 rejects
437
+ // post-gloas forks), the execution payload is part of the parent block so its state already includes it
438
+ const parentStatesPromise = chain.regen
439
+ .getBlockSlotState(parentBlock, slot, { dontTransferCache: true }, RegenCaller.produceBlock)
440
+ .then((parentState) => ({ parentState, parentStateWithPayload: parentState }));
435
441
  const fork = config.getForkName(slot);
436
442
  const isBuilderEnabled = ForkSeq[fork] >= ForkSeq.bellatrix &&
437
443
  chain.executionBuilder !== undefined &&
@@ -464,6 +470,7 @@ export function getValidatorApi(opts, { chain, config, logger, metrics, network,
464
470
  strictFeeRecipientCheck: false,
465
471
  commonBlockBodyPromise,
466
472
  parentBlock,
473
+ parentStatesPromise,
467
474
  })
468
475
  : Promise.reject(new Error("Builder disabled"));
469
476
  const enginePromise = produceEngineBlockContents(slot, randaoReveal, graffitiBytes, {
@@ -471,6 +478,7 @@ export function getValidatorApi(opts, { chain, config, logger, metrics, network,
471
478
  strictFeeRecipientCheck,
472
479
  commonBlockBodyPromise,
473
480
  parentBlock,
481
+ parentStatesPromise,
474
482
  }).then((engineBlock) => {
475
483
  // Once the engine returns a block, in the event of either:
476
484
  // - suspected builder censorship
@@ -497,18 +505,13 @@ export function getValidatorApi(opts, { chain, config, logger, metrics, network,
497
505
  signal: controller.signal,
498
506
  });
499
507
  // Ensure builder and engine HTTP requests are sent before starting common block body production
500
- // by deferring the call to next event loop iteration, allowing pending I/O operations like
501
- // HTTP requests to be processed first and sent out early in slot.
502
- callInNextEventLoop(() => {
508
+ // by deferring the call to next event loop iteration once the state is available, allowing pending
509
+ // I/O operations like HTTP requests to be processed first and sent out early in slot.
510
+ parentStatesPromise.then((parentStates) => callInNextEventLoop(() => {
503
511
  logger.verbose("Producing common block body", loggerContext);
504
512
  const commonBlockBodyStartedAt = Date.now();
505
513
  chain
506
- .produceCommonBlockBody({
507
- slot,
508
- parentBlock,
509
- randaoReveal,
510
- graffiti: graffitiBytes,
511
- })
514
+ .produceCommonBlockBody({ slot, parentBlock, randaoReveal, graffiti: graffitiBytes, ...parentStates })
512
515
  .then((commonBlockBody) => {
513
516
  deferredCommonBlockBody.resolve(commonBlockBody);
514
517
  logger.verbose("Produced common block body", {
@@ -517,7 +520,9 @@ export function getValidatorApi(opts, { chain, config, logger, metrics, network,
517
520
  });
518
521
  })
519
522
  .catch(deferredCommonBlockBody.reject);
520
- });
523
+ }),
524
+ // Both block sources fail on the state themselves and do not await the common block body
525
+ () => { });
521
526
  const [builder, engine] = await blockProductionRacePromise;
522
527
  if (builder.status === "pending" && engine.status === "pending") {
523
528
  throw Error("Builder and engine both failed to produce the block within timeout");
@@ -716,15 +721,21 @@ export function getValidatorApi(opts, { chain, config, logger, metrics, network,
716
721
  const builderBidExpected = builderConfig.builders.length > 0 ||
717
722
  (!circuitBreakerActive &&
718
723
  chain.executionPayloadBidPool.getBestBid(slot, bidParentBlockHash, parentBlockRootHex) !== null);
719
- // Calculate cutoff time based on start of the slot, ensures a slow local payload build does
720
- // not delay the proposal when a builder bid block is available (and vice versa)
721
- const cutoffMs = Math.max(0, config.getSlotComponentDurationMs(fork, BLOCK_PRODUCTION_RACE_CUTOFF_GLOAS_BPS) - chain.clock.msFromSlot(slot));
724
+ // Cutoff time into the slot, ensures a slow local payload build does not delay the proposal when a
725
+ // builder bid block is available (and vice versa). Each timer waits for the time left until the cutoff
726
+ const cutoffMs = config.getSlotComponentDurationMs(fork, BLOCK_PRODUCTION_RACE_CUTOFF_GLOAS_BPS);
727
+ const msToCutoff = () => Math.max(0, cutoffMs - chain.clock.msFromSlot(slot));
722
728
  // Give p2p bids the same time to bid up as granted to builder API bid requests via the advertised
723
729
  // deadline, the pool is read once the deadline passed and the bid requests settled. A late request
724
730
  // does not wait past the race cutoff, a pooled bid is still the fastest fallback if the local block fails
725
731
  const bidDeadlinePromise = circuitBreakerActive
726
732
  ? Promise.resolve()
727
- : sleep(Math.min(chain.builderApiClient.bidDeadline, cutoffMs));
733
+ : sleep(Math.min(chain.builderApiClient.bidDeadline, msToCutoff()));
734
+ let parentExecutionRequestsPromise = null;
735
+ const getParentExecutionRequests = () => {
736
+ parentExecutionRequestsPromise ??= chain.getParentExecutionRequests(parentSlot, parentBlockRootHex);
737
+ return parentExecutionRequestsPromise;
738
+ };
728
739
  // Candidates are ranked by their boosted counted total payment, the p2p bid is governed
729
740
  // by the top-level factors and each builder API bid by its own entry. Ties prefer the
730
741
  // earliest received builder API bid, so the signed block can be routed back to its
@@ -733,10 +744,9 @@ export function getValidatorApi(opts, { chain, config, logger, metrics, network,
733
744
  // Past the race cutoff a pooled p2p bid is used right away rather than waiting for pending
734
745
  // builder API requests, the local block is selected at the cutoff anyway if it is ready
735
746
  let [builderApiBids] = await Promise.all([
736
- Promise.race([builderApiBidsPromise, sleep(cutoffMs).then(() => null)]),
747
+ Promise.race([builderApiBidsPromise, sleep(msToCutoff()).then(() => null)]),
737
748
  bidDeadlinePromise,
738
749
  ]);
739
- let parentExecutionRequestsPromise = null;
740
750
  let p2pBid = circuitBreakerActive
741
751
  ? null
742
752
  : chain.executionPayloadBidPool.getBestBid(slot, bidParentBlockHash, parentBlockRootHex);
@@ -761,10 +771,7 @@ export function getValidatorApi(opts, { chain, config, logger, metrics, network,
761
771
  parentBlockHash: bidParentBlockHash,
762
772
  parentBlockRoot: parentBlockRootHex,
763
773
  entry,
764
- getParentExecutionRequests: () => {
765
- parentExecutionRequestsPromise ??= chain.getParentExecutionRequests(parentSlot, parentBlockRootHex);
766
- return parentExecutionRequestsPromise;
767
- },
774
+ getParentExecutionRequests,
768
775
  });
769
776
  return {
770
777
  signedBid,
@@ -808,29 +815,52 @@ export function getValidatorApi(opts, { chain, config, logger, metrics, network,
808
815
  }
809
816
  return rankedCandidates[0];
810
817
  })();
811
- const commonBlockBodyPromise = chain.produceCommonBlockBody({
812
- slot,
813
- parentBlock,
814
- randaoReveal,
815
- graffiti: graffitiBytes,
816
- });
817
- const baseAttrs = {
818
- slot,
819
- parentBlock,
820
- randaoReveal,
821
- graffiti: graffitiBytes,
822
- feeRecipient,
823
- strictFeeRecipientCheck,
824
- commonBlockBodyPromise,
825
- };
826
818
  metrics?.blockProductionRequests.inc({ source: ProducedBlockSource.engine });
827
819
  const timed = (source, fn) => {
828
820
  const t = metrics?.blockProductionTime.startTimer();
829
821
  return fn().finally(() => t?.({ source }));
830
822
  };
823
+ // Fetch the production state once and apply the parent execution payload once here, so all
824
+ // downstream consumers share a single state: the un-applied `parentState` (for `computeNewStateRoot`)
825
+ // and the applied `parentStateWithPayload` (for attestation scoring and execution-payload prep).
826
+ // Not awaited, the race below covers it and both blocks are produced from it
827
+ const baseAttrsPromise = (async () => {
828
+ const parentState = await chain.regen.getBlockSlotState(parentBlock, slot, { dontTransferCache: true }, RegenCaller.produceBlock);
829
+ // Fetch the parent's execution requests once here and thread them via blockAttributes: they are
830
+ // used both to apply the parent payload below and as the block's `parentExecutionRequests` field
831
+ // (so both are guaranteed consistent). Only needed when building on FULL; empty parent has none.
832
+ const parentExecutionRequests = isBuildingOnFull && isStatePostGloas(parentState)
833
+ ? await getParentExecutionRequests()
834
+ : ssz.gloas.ExecutionRequests.defaultValue();
835
+ // When building on EMPTY there is nothing to apply, so it stays the same view as parentState
836
+ // (the availability bit for parentSlot stays false, which is correct).
837
+ const parentStateWithPayload = isBuildingOnFull && isStatePostGloas(parentState)
838
+ ? parentState.withParentPayloadApplied(parentExecutionRequests)
839
+ : parentState;
840
+ const commonBlockBodyPromise = chain.produceCommonBlockBody({
841
+ slot,
842
+ parentBlock,
843
+ randaoReveal,
844
+ graffiti: graffitiBytes,
845
+ parentState,
846
+ parentStateWithPayload,
847
+ });
848
+ return {
849
+ slot,
850
+ parentBlock,
851
+ randaoReveal,
852
+ graffiti: graffitiBytes,
853
+ feeRecipient,
854
+ strictFeeRecipientCheck,
855
+ commonBlockBodyPromise,
856
+ parentState,
857
+ parentStateWithPayload,
858
+ parentExecutionRequests,
859
+ };
860
+ })();
831
861
  // use abort controller to stop waiting for the bid block if the engine block will be selected
832
862
  const controller = new AbortController();
833
- const enginePromise = timed(ProducedBlockSource.engine, () => chain.produceBlock(baseAttrs)).then((engineBlock) => {
863
+ const enginePromise = timed(ProducedBlockSource.engine, async () => chain.produceBlock(await baseAttrsPromise)).then((engineBlock) => {
834
864
  // No need to wait for the bid block if the engine block will always be selected, either
835
865
  // due to suspected builder censorship, or because no builders are configured and the
836
866
  // boost factor of 0 always prefers the local block over p2p bids
@@ -841,13 +871,13 @@ export function getValidatorApi(opts, { chain, config, logger, metrics, network,
841
871
  });
842
872
  const bidBlockPromise = bestBidPromise.then((candidate) => {
843
873
  if (candidate === null) {
844
- throw new Error(NO_BID_AVAILABLE);
874
+ throw new NoBidReceived();
845
875
  }
846
876
  metrics?.blockProductionRequests.inc({ source: ProducedBlockSource.builder });
847
- return timed(ProducedBlockSource.builder, () => chain.produceBlock({ ...baseAttrs, builderBid: candidate.signedBid }));
877
+ return timed(ProducedBlockSource.builder, async () => chain.produceBlock({ ...(await baseAttrsPromise), builderBid: candidate.signedBid }));
848
878
  });
849
879
  const [engineResult, bidBlockResult] = await resolveOrRacePromises([enginePromise, bidBlockPromise], {
850
- resolveTimeoutMs: cutoffMs,
880
+ resolveTimeoutMs: msToCutoff(),
851
881
  raceTimeoutMs: config.getSlotDurationMs(fork),
852
882
  signal: controller.signal,
853
883
  });
@@ -947,7 +977,7 @@ export function getValidatorApi(opts, { chain, config, logger, metrics, network,
947
977
  else if (engineResult.status === "fulfilled") {
948
978
  source = ProducedBlockSource.engine;
949
979
  bestResult = engineResult;
950
- const reason = bidBlockResult.status === "rejected" && bidBlockResult.reason.message === NO_BID_AVAILABLE
980
+ const reason = bidBlockResult.status === "rejected" && bidBlockResult.reason instanceof NoBidReceived
951
981
  ? EngineBlockSelectionReason.BuilderNoBid
952
982
  : bidBlockResult.status === "pending"
953
983
  ? EngineBlockSelectionReason.BuilderPending
@@ -1054,11 +1084,17 @@ export function getValidatorApi(opts, { chain, config, logger, metrics, network,
1054
1084
  // After Gloas, attestation.data.index signals payload status in fork-choice:
1055
1085
  // - 0 = EMPTY / not present, 1 = FULL / present
1056
1086
  // - same-slot attestations must always use index = 0
1087
+ // Validator shouldn't vote on an optimistic head, post-gloas that is the variant voted for
1057
1088
  if (canonicalBlock.slot !== slot) {
1058
1089
  index = canonicalBlock.payloadStatus === PayloadStatus.FULL ? 1 : 0;
1090
+ if (isOptimisticBlock(canonicalBlock)) {
1091
+ throw new NodeIsSyncing(`Head block's execution payload not yet validated, executionPayloadBlockHash=${canonicalBlock.executionPayloadBlockHash}`);
1092
+ }
1059
1093
  }
1060
1094
  else {
1061
1095
  index = 0;
1096
+ // Same-slot votes support the PENDING variant, which does not depend on the block's own payload
1097
+ notOnOptimisticBlockRoot(beaconBlockRoot);
1062
1098
  }
1063
1099
  }
1064
1100
  else if (isForkPostElectra(fork)) {
@@ -1075,8 +1111,11 @@ export function getValidatorApi(opts, { chain, config, logger, metrics, network,
1075
1111
  ? // If the state is earlier than the target slot then the target *must* be the head block root.
1076
1112
  headBlockRoot
1077
1113
  : headState.getBlockRootAtSlot(targetSlot);
1078
- // Check the execution status as validator shouldn't vote on an optimistic head
1079
- // Check on target is sufficient as a valid target would imply a valid source
1114
+ // Check the execution status as validator shouldn't vote on an optimistic head, post-gloas the
1115
+ // variant voted for is checked above. Check on target is sufficient for a valid source
1116
+ if (!isForkPostGloas(fork)) {
1117
+ notOnOptimisticBlockRoot(beaconBlockRoot);
1118
+ }
1080
1119
  notOnOptimisticBlockRoot(targetRoot);
1081
1120
  notOnOutOfRangeData(targetRoot);
1082
1121
  // To get the correct source we must get a state in the same epoch as the attestation's epoch.
@@ -1295,7 +1334,8 @@ export function getValidatorApi(opts, { chain, config, logger, metrics, network,
1295
1334
  await waitForNextClosestEpoch();
1296
1335
  // should not compare to headEpoch in order to handle skipped slots
1297
1336
  // Check if the epoch is in the future after waiting for requested slot
1298
- if (epoch > chain.clock.currentEpoch + 1) {
1337
+ // Before genesis the clock epoch is negative, treat it as GENESIS_EPOCH so the next epoch can be requested
1338
+ if (epoch > Math.max(chain.clock.currentEpoch, GENESIS_EPOCH) + 1) {
1299
1339
  throw new ApiError(400, "Cannot get duties for epoch more than one ahead");
1300
1340
  }
1301
1341
  const head = chain.forkChoice.getHead();
@@ -1345,7 +1385,7 @@ export function getValidatorApi(opts, { chain, config, logger, metrics, network,
1345
1385
  throw new ApiError(400, `PTC duties are not supported before Gloas fork=${fork}`);
1346
1386
  }
1347
1387
  await waitForNextClosestEpoch();
1348
- if (epoch > chain.clock.currentEpoch + 1) {
1388
+ if (epoch > Math.max(chain.clock.currentEpoch, GENESIS_EPOCH) + 1) {
1349
1389
  throw new ApiError(400, "Cannot get PTC duties for epoch more than one ahead");
1350
1390
  }
1351
1391
  const head = chain.forkChoice.getHead();
@@ -1791,7 +1831,7 @@ export function getValidatorApi(opts, { chain, config, logger, metrics, network,
1791
1831
  const { committeeIndices, totalBytes } = validationResult;
1792
1832
  metrics?.inclusionListsValid.inc({ source: InclusionListSource.api });
1793
1833
  metrics?.inclusionListsValidSize.inc(totalBytes);
1794
- const isTimely = secFromSlot >= 0 && secFromSlot * 1000 < chain.config.getInclusionListDueMs(chain.config.getForkName(slot));
1834
+ const isTimely = secFromSlot * 1000 < chain.config.getInclusionListDueMs(chain.config.getForkName(slot));
1795
1835
  chain.inclusionListStore.process(signedInclusionList, committeeIndices, isTimely);
1796
1836
  chain.emitter.emit(routes.events.EventType.inclusionList, {
1797
1837
  version: chain.config.getForkName(slot),