@lodestar/beacon-node 1.52.0-dev.269cf1aa5b → 1.52.0-dev.31011e1c39

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 +47 -26
  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 +87 -48
  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 +80 -41
  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 +26 -12
  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 +53 -28
  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 +122 -66
  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 +112 -78
  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 +39 -13
  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
@@ -16,38 +16,12 @@ import {ExecutionPayloadBidError, ExecutionPayloadBidErrorCode, GossipAction} fr
16
16
  import {IBeaconChain} from "../index.js";
17
17
  import {RegenCaller} from "../regen/index.js";
18
18
 
19
- /**
20
- * Relative increment over the current highest bid required to forward a bid, in basis points.
21
- * With 3%, laddering from 1 gwei to 1 ETH takes ~256 bids given the floor and cap below, see
22
- * https://github.com/ethereum/consensus-specs/pull/4792#issuecomment-3714553549.
23
- */
24
- const BID_INCREMENT_BPS = 300;
25
- /**
26
- * Minimum absolute increment (0.0001 ETH). Covers low bid values where the relative increment
27
- * is tiny and provides weak spam protection.
28
- */
29
- const BID_INCREMENT_FLOOR_GWEI = 100_000;
30
- /**
31
- * Maximum absolute increment (0.01 ETH). Bounds the barrier for legitimate competition on
32
- * high value blocks where the relative increment would suppress closely competing bids.
33
- */
34
- const BID_INCREMENT_CAP_GWEI = 10_000_000;
35
-
36
- /**
37
- * Return the minimum value a new bid must have to be forwarded given the current highest bid.
38
- * Division before multiplication to stay within safe integer range for max gwei values.
39
- */
40
- function getMinBidValue(currentHighestBid: number): number {
41
- const relativeIncrement = Math.floor(currentHighestBid / 10_000) * BID_INCREMENT_BPS;
42
- const increment = Math.min(Math.max(BID_INCREMENT_FLOOR_GWEI, relativeIncrement), BID_INCREMENT_CAP_GWEI);
43
- return currentHighestBid + increment;
44
- }
45
-
46
19
  /**
47
20
  * Check whether a bid builds on one of the paths compatible with the local head branch.
48
21
  *
49
- * Building directly on the parent is allowed for proposer-boost reorgs, including at epoch
50
- * boundaries when the head is weak enough that a reorg onto the strong parent is predicted.
22
+ * Building directly on the parent is allowed for the slot after the head if the head was late or
23
+ * its proposer equivocated, the conditions under which a proposer may re-org the head. At epoch
24
+ * boundaries the parent must also be the predicted proposer head.
51
25
  * Otherwise the bid must build on the local head's full or empty payload variant, as selected for its slot.
52
26
  */
53
27
  function isBidCompatibleWithHead(
@@ -61,6 +35,11 @@ function isBidCompatibleWithHead(
61
35
  const buildsOnParentPayload = bidParentBlockHash === head.parentBlockHash;
62
36
 
63
37
  if (buildsOnParentBlock && buildsOnParentPayload) {
38
+ const bidSlotOk = head.slot + 1 === bidSlot;
39
+ const headLate = !head.timeliness;
40
+ if (!bidSlotOk || !(headLate || chain.forkChoice.isProposerEquivocation(head))) {
41
+ return false;
42
+ }
64
43
  if (!isStartSlotOfEpoch(bidSlot)) {
65
44
  return true;
66
45
  }
@@ -141,6 +120,18 @@ async function validateExecutionPayloadBid(
141
120
  });
142
121
  }
143
122
 
123
+ // [IGNORE] The bid is received after the payload attestation deadline of `bid.slot - 1`
124
+ if (
125
+ chain.clock.msFromSlot(bid.slot - 1) <
126
+ chain.config.getPayloadAttestationDueMs(chain.config.getForkName(bid.slot - 1))
127
+ ) {
128
+ throw new ExecutionPayloadBidError(GossipAction.IGNORE, {
129
+ code: ExecutionPayloadBidErrorCode.BEFORE_PAYLOAD_ATTESTATION_DEADLINE,
130
+ builderIndex: bid.builderIndex,
131
+ slot: bid.slot,
132
+ });
133
+ }
134
+
144
135
  // [IGNORE] The bid is received after the inclusion list deadline of `bid.slot - 1`
145
136
  if (
146
137
  isForkPostHeze(chain.config.getForkName(bid.slot)) &&
@@ -165,27 +156,30 @@ async function validateExecutionPayloadBid(
165
156
  });
166
157
  }
167
158
 
168
- // [IGNORE] this is the first signed bid seen with a valid signature from the given builder for
169
- // the tuple `(bid.slot, bid.parent_block_hash, bid.parent_block_root)`.
170
- // Entries are only added after signature verification, so known tuples can be dropped before
171
- // state regeneration and the other expensive validation steps.
172
- if (chain.seenExecutionPayloadBids.isKnown(bid.slot, bid.builderIndex, bidParentBlockHash, bidParentBlockRoot)) {
159
+ // [IGNORE] The builder has not reached its bid limit, checked against the limit of its last valid bid.
160
+ // Bids for the same slot and parent root are validated against the same state, so bids past the
161
+ // limit can be dropped before state regeneration and the other expensive validation steps.
162
+ const seenBids = chain.seenExecutionPayloadBids.get(
163
+ bid.slot,
164
+ bid.builderIndex,
165
+ bidParentBlockHash,
166
+ bidParentBlockRoot
167
+ );
168
+ if (seenBids !== undefined && seenBids.count >= seenBids.limit) {
173
169
  throw new ExecutionPayloadBidError(GossipAction.IGNORE, {
174
- code: ExecutionPayloadBidErrorCode.BID_ALREADY_KNOWN,
170
+ code: ExecutionPayloadBidErrorCode.BID_LIMIT_REACHED,
175
171
  builderIndex: bid.builderIndex,
176
172
  slot: bid.slot,
177
173
  parentBlockRoot: bidParentBlockRoot,
178
174
  parentBlockHash: bidParentBlockHash,
175
+ bidLimit: seenBids.limit,
179
176
  });
180
177
  }
181
178
 
182
179
  // [IGNORE] this bid is the highest value bid seen for the tuple
183
180
  // `(bid.slot, bid.parent_block_hash, bid.parent_block_root)`.
184
- // As a DoS prevention measure, the bid must also exceed the current highest bid by a minimum
185
- // increment, see https://github.com/ethereum/consensus-specs/pull/4831. This prevents spam
186
- // from builders submitting numerous bids with minimal value increments.
187
181
  const bestBid = chain.executionPayloadBidPool.getBestBid(bid.slot, bidParentBlockHash, bidParentBlockRoot);
188
- if (bestBid !== null && bid.value < getMinBidValue(bestBid.signedBid.message.value)) {
182
+ if (bestBid !== null && bid.value <= bestBid.signedBid.message.value) {
189
183
  throw new ExecutionPayloadBidError(GossipAction.IGNORE, {
190
184
  code: ExecutionPayloadBidErrorCode.BID_TOO_LOW,
191
185
  bidValue: bid.value,
@@ -366,6 +360,24 @@ async function validateExecutionPayloadBid(
366
360
  });
367
361
  }
368
362
 
363
+ // [IGNORE] The builder has not reached its bid limit for the tuple
364
+ // `(bid.slot, bid.parent_block_hash, bid.parent_block_root)` -- i.e. one bid per ETH of builder balance
365
+ // not owed in pending withdrawals, `get_builder_bid_limit(state, bid.builder_index)`.
366
+ const bidLimit = state.getBuilderBidLimit(bid.builderIndex);
367
+ if (
368
+ (chain.seenExecutionPayloadBids.get(bid.slot, bid.builderIndex, bidParentBlockHash, bidParentBlockRoot)?.count ??
369
+ 0) >= bidLimit
370
+ ) {
371
+ throw new ExecutionPayloadBidError(GossipAction.IGNORE, {
372
+ code: ExecutionPayloadBidErrorCode.BID_LIMIT_REACHED,
373
+ builderIndex: bid.builderIndex,
374
+ slot: bid.slot,
375
+ parentBlockRoot: bidParentBlockRoot,
376
+ parentBlockHash: bidParentBlockHash,
377
+ bidLimit,
378
+ });
379
+ }
380
+
369
381
  // [IGNORE] `bid.value` is less or equal than the builder's excess balance --
370
382
  // i.e. `can_builder_cover_bid(state, builder_index, amount)` returns `True`.
371
383
  if (!state.canBuilderCoverBid(bid.builderIndex, bid.value)) {
@@ -426,20 +438,24 @@ async function validateExecutionPayloadBid(
426
438
  });
427
439
  }
428
440
 
429
- // Repeat the seen check after the awaited signature verification to prevent concurrent bids
430
- // for the same builder and tuple from both passing validation.
431
- if (chain.seenExecutionPayloadBids.isKnown(bid.slot, bid.builderIndex, bidParentBlockHash, bidParentBlockRoot)) {
441
+ // Repeat the bid limit check after the awaited signature verification to prevent concurrent bids
442
+ // for the same builder and tuple from all passing validation.
443
+ if (
444
+ (chain.seenExecutionPayloadBids.get(bid.slot, bid.builderIndex, bidParentBlockHash, bidParentBlockRoot)?.count ??
445
+ 0) >= bidLimit
446
+ ) {
432
447
  throw new ExecutionPayloadBidError(GossipAction.IGNORE, {
433
- code: ExecutionPayloadBidErrorCode.BID_ALREADY_KNOWN,
448
+ code: ExecutionPayloadBidErrorCode.BID_LIMIT_REACHED,
434
449
  builderIndex: bid.builderIndex,
435
450
  slot: bid.slot,
436
451
  parentBlockRoot: bidParentBlockRoot,
437
452
  parentBlockHash: bidParentBlockHash,
453
+ bidLimit,
438
454
  });
439
455
  }
440
456
 
441
457
  // Valid
442
- chain.seenExecutionPayloadBids.add(bid.slot, bid.builderIndex, bidParentBlockHash, bidParentBlockRoot);
458
+ chain.seenExecutionPayloadBids.add(bid.slot, bid.builderIndex, bidParentBlockHash, bidParentBlockRoot, bidLimit);
443
459
 
444
460
  return {proposerIndex: proposerPreferences.message.validatorIndex};
445
461
  }
@@ -1,11 +1,13 @@
1
1
  import {PayloadStatus, ProtoBlock} from "@lodestar/fork-choice";
2
2
  import {
3
3
  computeStartSlotAtEpoch,
4
+ computeTimeAtSlot,
4
5
  getExecutionPayloadEnvelopeSignatureSet,
5
6
  isStatePostGloas,
6
7
  } from "@lodestar/state-transition";
7
8
  import {gloas, ssz} from "@lodestar/types";
8
9
  import {byteArrayEquals, toRootHex} from "@lodestar/utils";
10
+ import {computeExecutionBlockHash} from "../../execution/engine/blockHash.js";
9
11
  import {
10
12
  getBeaconBlockRootFromExecutionPayloadEnvelopeSerialized,
11
13
  getSlotFromExecutionPayloadEnvelopeSerialized,
@@ -54,7 +56,7 @@ export function validateGossipExecutionPayloadEnvelopeSerialized(
54
56
 
55
57
  const maxTransactionCount = getMaxTransactionCount(chain, block, payloadInput);
56
58
  if (BigInt(transactionCount) > maxTransactionCount) {
57
- throw new ExecutionPayloadEnvelopeError(GossipAction.IGNORE, {
59
+ throw new ExecutionPayloadEnvelopeError(GossipAction.REJECT, {
58
60
  code: ExecutionPayloadEnvelopeErrorCode.TOO_MANY_TRANSACTIONS,
59
61
  slot,
60
62
  root: blockRootHex,
@@ -129,6 +131,17 @@ async function validateExecutionPayloadEnvelope(
129
131
  });
130
132
  }
131
133
 
134
+ // [REJECT] `envelope.parent_beacon_block_root == block.parent_root`
135
+ if (toRootHex(envelope.parentBeaconBlockRoot) !== block.parentRoot) {
136
+ throw new ExecutionPayloadEnvelopeError(GossipAction.REJECT, {
137
+ code: ExecutionPayloadEnvelopeErrorCode.PARENT_BEACON_BLOCK_ROOT_MISMATCH,
138
+ slot: payload.slotNumber,
139
+ root: blockRootHex,
140
+ envelopeParentBeaconBlockRoot: toRootHex(envelope.parentBeaconBlockRoot),
141
+ blockParentRoot: block.parentRoot,
142
+ });
143
+ }
144
+
132
145
  // [REJECT] `envelope.builder_index == bid.builder_index`
133
146
  if (envelope.builderIndex !== payloadInput.getBuilderIndex()) {
134
147
  throw new ExecutionPayloadEnvelopeError(GossipAction.REJECT, {
@@ -140,6 +153,30 @@ async function validateExecutionPayloadEnvelope(
140
153
  });
141
154
  }
142
155
 
156
+ const bid = payloadInput.getBid();
157
+
158
+ // [REJECT] `payload.prev_randao == bid.prev_randao`
159
+ if (!byteArrayEquals(payload.prevRandao, bid.prevRandao)) {
160
+ throw new ExecutionPayloadEnvelopeError(GossipAction.REJECT, {
161
+ code: ExecutionPayloadEnvelopeErrorCode.PREV_RANDAO_MISMATCH,
162
+ slot: payload.slotNumber,
163
+ root: blockRootHex,
164
+ envelopePrevRandao: toRootHex(payload.prevRandao),
165
+ bidPrevRandao: toRootHex(bid.prevRandao),
166
+ });
167
+ }
168
+
169
+ // [REJECT] `payload.gas_limit == bid.gas_limit`
170
+ if (BigInt(payload.gasLimit) !== bid.gasLimit) {
171
+ throw new ExecutionPayloadEnvelopeError(GossipAction.REJECT, {
172
+ code: ExecutionPayloadEnvelopeErrorCode.GAS_LIMIT_MISMATCH,
173
+ slot: payload.slotNumber,
174
+ root: blockRootHex,
175
+ envelopeGasLimit: payload.gasLimit,
176
+ bidGasLimit: bid.gasLimit,
177
+ });
178
+ }
179
+
143
180
  // [REJECT] `payload.block_hash == bid.block_hash`
144
181
  if (toRootHex(payload.blockHash) !== payloadInput.getBlockHashHex()) {
145
182
  throw new ExecutionPayloadEnvelopeError(GossipAction.REJECT, {
@@ -153,22 +190,23 @@ async function validateExecutionPayloadEnvelope(
153
190
 
154
191
  // [REJECT] `hash_tree_root(envelope.execution_requests) == bid.execution_requests_root`
155
192
  const requestsRoot = ssz.gloas.ExecutionRequests.hashTreeRoot(envelope.executionRequests);
156
- if (!byteArrayEquals(requestsRoot, payloadInput.getBid().executionRequestsRoot)) {
193
+ if (!byteArrayEquals(requestsRoot, bid.executionRequestsRoot)) {
157
194
  throw new ExecutionPayloadEnvelopeError(GossipAction.REJECT, {
158
195
  code: ExecutionPayloadEnvelopeErrorCode.EXECUTION_REQUESTS_ROOT_MISMATCH,
159
196
  slot: payload.slotNumber,
160
197
  root: blockRootHex,
161
198
  envelopeRequestsRoot: toRootHex(requestsRoot),
162
- bidRequestsRoot: toRootHex(payloadInput.getBid().executionRequestsRoot),
199
+ bidRequestsRoot: toRootHex(bid.executionRequestsRoot),
163
200
  });
164
201
  }
165
202
 
166
- // [IGNORE] The number of transactions is within the limit implied by the parent payload's gas limit
167
- // TODO GLOAS: [REJECT] once https://github.com/ethereum/consensus-specs/pull/5802 is released,
168
- // also in validateGossipExecutionPayloadEnvelopeSerialized
203
+ // Execution request and withdrawal count limits are enforced by the SSZ list limits on decode
204
+
205
+ // [REJECT] The number of transactions is within the limit implied by the parent payload's gas limit,
206
+ // also checked before deserialization in validateGossipExecutionPayloadEnvelopeSerialized
169
207
  const maxTransactionCount = getMaxTransactionCount(chain, block, payloadInput);
170
208
  if (BigInt(payload.transactions.length) > maxTransactionCount) {
171
- throw new ExecutionPayloadEnvelopeError(GossipAction.IGNORE, {
209
+ throw new ExecutionPayloadEnvelopeError(GossipAction.REJECT, {
172
210
  code: ExecutionPayloadEnvelopeErrorCode.TOO_MANY_TRANSACTIONS,
173
211
  slot: payload.slotNumber,
174
212
  root: blockRootHex,
@@ -177,7 +215,7 @@ async function validateExecutionPayloadEnvelope(
177
215
  });
178
216
  }
179
217
 
180
- // Get the block state to verify the builder's signature.
218
+ // Get the block state to verify the payload against it and the builder's signature.
181
219
  const blockState = await chain.regen
182
220
  .getState(block.stateRoot, RegenCaller.validateGossipPayloadEnvelope)
183
221
  .catch(() => {
@@ -191,6 +229,75 @@ async function validateExecutionPayloadEnvelope(
191
229
  throw new Error(`Expected gloas+ state for execution payload envelope validation, got fork=${blockState.forkName}`);
192
230
  }
193
231
 
232
+ // [REJECT] `payload.parent_hash == state.latest_block_hash`
233
+ if (!byteArrayEquals(payload.parentHash, blockState.latestBlockHash)) {
234
+ throw new ExecutionPayloadEnvelopeError(GossipAction.REJECT, {
235
+ code: ExecutionPayloadEnvelopeErrorCode.PARENT_HASH_MISMATCH,
236
+ slot: payload.slotNumber,
237
+ root: blockRootHex,
238
+ envelopeParentHash: toRootHex(payload.parentHash),
239
+ latestBlockHash: toRootHex(blockState.latestBlockHash),
240
+ });
241
+ }
242
+
243
+ // [REJECT] `payload.timestamp == compute_time_at_slot(state.genesis_time, block.slot)`
244
+ const expectedTimestamp = computeTimeAtSlot(chain.config, block.slot, blockState.genesisTime);
245
+ if (payload.timestamp !== expectedTimestamp) {
246
+ throw new ExecutionPayloadEnvelopeError(GossipAction.REJECT, {
247
+ code: ExecutionPayloadEnvelopeErrorCode.INCORRECT_TIMESTAMP,
248
+ slot: payload.slotNumber,
249
+ root: blockRootHex,
250
+ envelopeTimestamp: payload.timestamp,
251
+ expectedTimestamp,
252
+ });
253
+ }
254
+
255
+ // [REJECT] The payload contains no empty transactions
256
+ // An empty transaction is a deletion in the transactions trie, so trailing empty transactions would not change
257
+ // the block hash. The EL rejects such a payload, as `verify_and_notify_new_payload` does before hashing.
258
+ for (let i = 0; i < payload.transactions.length; i++) {
259
+ if (payload.transactions.getSize(i) === 0) {
260
+ throw new ExecutionPayloadEnvelopeError(GossipAction.REJECT, {
261
+ code: ExecutionPayloadEnvelopeErrorCode.EMPTY_TRANSACTION,
262
+ slot: payload.slotNumber,
263
+ root: blockRootHex,
264
+ transactionIndex: i,
265
+ });
266
+ }
267
+ }
268
+
269
+ // [REJECT] `hash_tree_root(payload.withdrawals) == hash_tree_root(state.payload_expected_withdrawals)`
270
+ const withdrawalsRoot = ssz.gloas.Withdrawals.hashTreeRoot(payload.withdrawals);
271
+ const expectedWithdrawalsRoot = ssz.gloas.Withdrawals.hashTreeRoot(blockState.payloadExpectedWithdrawals);
272
+ if (!byteArrayEquals(withdrawalsRoot, expectedWithdrawalsRoot)) {
273
+ throw new ExecutionPayloadEnvelopeError(GossipAction.REJECT, {
274
+ code: ExecutionPayloadEnvelopeErrorCode.WITHDRAWALS_MISMATCH,
275
+ slot: payload.slotNumber,
276
+ root: blockRootHex,
277
+ envelopeWithdrawalsRoot: toRootHex(withdrawalsRoot),
278
+ expectedWithdrawalsRoot: toRootHex(expectedWithdrawalsRoot),
279
+ });
280
+ }
281
+
282
+ // [REJECT] The payload's block hash is computed correctly
283
+ const timer = chain.metrics?.gossipExecutionPayloadEnvelope.blockHashTime.startTimer();
284
+ const computedBlockHash = computeExecutionBlockHash(
285
+ blockState.forkName,
286
+ payload,
287
+ envelope.parentBeaconBlockRoot,
288
+ envelope.executionRequests
289
+ );
290
+ timer?.();
291
+ if (!byteArrayEquals(computedBlockHash, payload.blockHash)) {
292
+ throw new ExecutionPayloadEnvelopeError(GossipAction.REJECT, {
293
+ code: ExecutionPayloadEnvelopeErrorCode.INVALID_BLOCK_HASH,
294
+ slot: payload.slotNumber,
295
+ root: blockRootHex,
296
+ blockHash: toRootHex(payload.blockHash),
297
+ computedBlockHash: toRootHex(computedBlockHash),
298
+ });
299
+ }
300
+
194
301
  // [REJECT] `signed_execution_payload_envelope.signature` is valid as verified
195
302
  // by `verify_execution_payload_envelope_signature`.
196
303
  const signatureSet = getExecutionPayloadEnvelopeSignatureSet(
@@ -131,6 +131,16 @@ async function validatePayloadAttestationMessage(
131
131
  });
132
132
  }
133
133
 
134
+ // Re-check after the await: concurrent messages from the same validator all pass the check above
135
+ if (chain.seenPayloadAttesters.isKnown(data.slot, validatorIndex)) {
136
+ throw new PayloadAttestationError(GossipAction.IGNORE, {
137
+ code: PayloadAttestationErrorCode.PAYLOAD_ATTESTATION_ALREADY_KNOWN,
138
+ validatorIndex,
139
+ slot: data.slot,
140
+ blockRoot: toRootHex(data.beaconBlockRoot),
141
+ });
142
+ }
143
+
134
144
  // Valid
135
145
  chain.seenPayloadAttesters.add(data.slot, validatorIndex);
136
146
 
@@ -46,8 +46,10 @@ async function validateProposerSlashing(
46
46
  });
47
47
  }
48
48
 
49
- const signatureSets = getProposerSlashingSignatureSets(chain.config, state.slot, proposerSlashing);
50
- const verifiedDomain = getProposerSlashingSignatureDomain(chain.config, state.slot, proposerSlashing);
49
+ // Head state may lag behind a fork transition, verify against the fork of the clock slot
50
+ const currentSlot = chain.clock.currentSlot;
51
+ const signatureSets = getProposerSlashingSignatureSets(chain.config, currentSlot, proposerSlashing);
52
+ const verifiedDomain = getProposerSlashingSignatureDomain(chain.config, currentSlot, proposerSlashing);
51
53
  if (!(await chain.bls.verifySignatureSets(signatureSets, {batchable: true, priority: prioritizeBls}))) {
52
54
  throw new ProposerSlashingError(GossipAction.REJECT, {
53
55
  code: ProposerSlashingErrorCode.INVALID_SIGNATURE,
@@ -1,17 +1,15 @@
1
1
  import {BeaconConfig} from "@lodestar/config";
2
2
  import {DOMAIN_CONTRIBUTION_AND_PROOF} from "@lodestar/params";
3
- import {IBeaconStateView, ISignatureSet, SignatureSetType, computeSigningRoot} from "@lodestar/state-transition";
3
+ import {ISignatureSet, SignatureSetType, computeSigningRoot} from "@lodestar/state-transition";
4
4
  import {altair, ssz} from "@lodestar/types";
5
5
 
6
6
  export function getContributionAndProofSignatureSet(
7
7
  config: BeaconConfig,
8
- state: IBeaconStateView,
9
8
  signedContributionAndProof: altair.SignedContributionAndProof
10
9
  ): ISignatureSet {
11
- const domain = config.getDomain(
12
- state.slot,
13
- DOMAIN_CONTRIBUTION_AND_PROOF,
14
- signedContributionAndProof.message.contribution.slot
10
+ const domain = config.getDomainAtFork(
11
+ config.getForkName(signedContributionAndProof.message.contribution.slot),
12
+ DOMAIN_CONTRIBUTION_AND_PROOF
15
13
  );
16
14
  const signingData = signedContributionAndProof.message;
17
15
  return {
@@ -1,14 +1,13 @@
1
1
  import {BeaconConfig} from "@lodestar/config";
2
2
  import {DOMAIN_SYNC_COMMITTEE} from "@lodestar/params";
3
- import {IBeaconStateView, ISignatureSet, SignatureSetType, computeSigningRoot} from "@lodestar/state-transition";
3
+ import {ISignatureSet, SignatureSetType, computeSigningRoot} from "@lodestar/state-transition";
4
4
  import {altair, ssz} from "@lodestar/types";
5
5
 
6
6
  export function getSyncCommitteeSignatureSet(
7
7
  config: BeaconConfig,
8
- state: IBeaconStateView,
9
8
  syncCommittee: altair.SyncCommitteeMessage
10
9
  ): ISignatureSet {
11
- const domain = config.getDomain(state.slot, DOMAIN_SYNC_COMMITTEE, syncCommittee.slot);
10
+ const domain = config.getDomainAtFork(config.getForkName(syncCommittee.slot), DOMAIN_SYNC_COMMITTEE);
12
11
 
13
12
  return {
14
13
  type: SignatureSetType.indexed,
@@ -1,15 +1,14 @@
1
1
  import {BeaconConfig} from "@lodestar/config";
2
2
  import {DOMAIN_SYNC_COMMITTEE} from "@lodestar/params";
3
- import {IBeaconStateView, ISignatureSet, SignatureSetType, computeSigningRoot} from "@lodestar/state-transition";
3
+ import {ISignatureSet, SignatureSetType, computeSigningRoot} from "@lodestar/state-transition";
4
4
  import {altair, ssz} from "@lodestar/types";
5
5
 
6
6
  export function getSyncCommitteeContributionSignatureSet(
7
7
  config: BeaconConfig,
8
- state: IBeaconStateView,
9
8
  contribution: altair.SyncCommitteeContribution,
10
9
  participantIndices: number[]
11
10
  ): ISignatureSet {
12
- const domain = config.getDomain(state.slot, DOMAIN_SYNC_COMMITTEE, contribution.slot);
11
+ const domain = config.getDomainAtFork(config.getForkName(contribution.slot), DOMAIN_SYNC_COMMITTEE);
13
12
  return {
14
13
  type: SignatureSetType.aggregate,
15
14
  indices: participantIndices,
@@ -1,15 +1,14 @@
1
1
  import {BeaconConfig} from "@lodestar/config";
2
2
  import {DOMAIN_SYNC_COMMITTEE_SELECTION_PROOF} from "@lodestar/params";
3
- import {IBeaconStateView, ISignatureSet, SignatureSetType, computeSigningRoot} from "@lodestar/state-transition";
3
+ import {ISignatureSet, SignatureSetType, computeSigningRoot} from "@lodestar/state-transition";
4
4
  import {altair, ssz} from "@lodestar/types";
5
5
 
6
6
  export function getSyncCommitteeSelectionProofSignatureSet(
7
7
  config: BeaconConfig,
8
- state: IBeaconStateView,
9
8
  contributionAndProof: altair.ContributionAndProof
10
9
  ): ISignatureSet {
11
10
  const slot = contributionAndProof.contribution.slot;
12
- const domain = config.getDomain(state.slot, DOMAIN_SYNC_COMMITTEE_SELECTION_PROOF, slot);
11
+ const domain = config.getDomainAtFork(config.getForkName(slot), DOMAIN_SYNC_COMMITTEE_SELECTION_PROOF);
13
12
  const signingData: altair.SyncAggregatorSelectionData = {
14
13
  slot,
15
14
  subcommitteeIndex: contributionAndProof.contribution.subcommitteeIndex,
@@ -40,7 +40,7 @@ export async function validateGossipSyncCommittee(
40
40
  // > Checked in validateGossipSyncCommitteeExceptSig()
41
41
 
42
42
  // [REJECT] The signature is valid for the message beacon_block_root for the validator referenced by validator_index.
43
- await validateSyncCommitteeSigOnly(chain, headState, syncCommittee);
43
+ await validateSyncCommitteeSigOnly(chain, syncCommittee);
44
44
 
45
45
  // Re-check after the await: concurrent messages from the same validator all pass the check above.
46
46
  // Metrics were already counted by the first check.
@@ -89,11 +89,10 @@ function assertSyncCommitteeMessageNotKnown(
89
89
 
90
90
  export async function validateApiSyncCommittee(
91
91
  chain: IBeaconChain,
92
- headState: IBeaconStateView,
93
92
  syncCommittee: altair.SyncCommitteeMessage
94
93
  ): Promise<void> {
95
94
  const prioritizeBls = true;
96
- return validateSyncCommitteeSigOnly(chain, headState, syncCommittee, prioritizeBls);
95
+ return validateSyncCommitteeSigOnly(chain, syncCommittee, prioritizeBls);
97
96
  }
98
97
 
99
98
  /**
@@ -101,11 +100,10 @@ export async function validateApiSyncCommittee(
101
100
  */
102
101
  async function validateSyncCommitteeSigOnly(
103
102
  chain: IBeaconChain,
104
- headState: IBeaconStateView,
105
103
  syncCommittee: altair.SyncCommitteeMessage,
106
104
  prioritizeBls = false
107
105
  ): Promise<void> {
108
- const signatureSet = getSyncCommitteeSignatureSet(chain.config, headState, syncCommittee);
106
+ const signatureSet = getSyncCommitteeSignatureSet(chain.config, syncCommittee);
109
107
  if (!(await chain.bls.verifySignatureSets([signatureSet], {batchable: true, priority: prioritizeBls}))) {
110
108
  throw new SyncCommitteeError(GossipAction.REJECT, {
111
109
  code: SyncCommitteeErrorCode.INVALID_SIGNATURE,
@@ -76,14 +76,14 @@ export async function validateSyncCommitteeGossipContributionAndProof(
76
76
  const signatureSets = [
77
77
  // [REJECT] The contribution_and_proof.selection_proof is a valid signature of the SyncAggregatorSelectionData
78
78
  // derived from the contribution by the validator with index contribution_and_proof.aggregator_index.
79
- getSyncCommitteeSelectionProofSignatureSet(chain.config, headState, contributionAndProof),
79
+ getSyncCommitteeSelectionProofSignatureSet(chain.config, contributionAndProof),
80
80
 
81
81
  // [REJECT] The aggregator signature, signed_contribution_and_proof.signature, is valid.
82
- getContributionAndProofSignatureSet(chain.config, headState, signedContributionAndProof),
82
+ getContributionAndProofSignatureSet(chain.config, signedContributionAndProof),
83
83
 
84
84
  // [REJECT] The aggregate signature is valid for the message beacon_block_root and aggregate pubkey derived from
85
85
  // the participation info in aggregation_bits for the subcommittee specified by the contribution.subcommittee_index.
86
- getSyncCommitteeContributionSignatureSet(chain.config, headState, contribution, syncCommitteeParticipantIndices),
86
+ getSyncCommitteeContributionSignatureSet(chain.config, contribution, syncCommitteeParticipantIndices),
87
87
  ];
88
88
 
89
89
  if (!(await chain.bls.verifySignatureSets(signatureSets, {batchable: true}))) {
@@ -1,4 +1,5 @@
1
- import {VoluntaryExitValidity, getVoluntaryExitSignatureSet} from "@lodestar/state-transition";
1
+ import {FAR_FUTURE_EPOCH} from "@lodestar/params";
2
+ import {VoluntaryExitValidity, computeEpochAtSlot, getVoluntaryExitSignatureSet} from "@lodestar/state-transition";
2
3
  import {phase0} from "@lodestar/types";
3
4
  import {
4
5
  GossipAction,
@@ -99,19 +100,56 @@ async function validateVoluntaryExit(
99
100
  // The only condition that is time sensitive and may require a non-head state is
100
101
  // -> Validator is active && validator has not initiated exit
101
102
  // The voluntaryExit.epoch must be in the past but the validator's status may change in recent epochs.
102
- // We dial the head state to the current epoch to get the current status of the validator. This is
103
- // relevant on periods of many skipped slots.
104
- const state = await chain.getHeadStateAtCurrentEpoch(RegenCaller.validateGossipVoluntaryExit);
103
+ // We dial the head state to the current epoch (with a MAXIMUM_GOSSIP_CLOCK_DISPARITY allowance) to get the
104
+ // current status of the validator. This is relevant on periods of many skipped slots.
105
+ const state = await chain.getHeadStateAtEpoch(
106
+ computeEpochAtSlot(chain.clock.currentSlotWithGossipDisparity),
107
+ RegenCaller.validateGossipVoluntaryExit
108
+ );
105
109
 
106
- // [REJECT] All of the conditions within process_voluntary_exit pass validation.
107
110
  // verifySignature = false, verified in batch below
108
111
  const validity = state.getVoluntaryExitValidity(voluntaryExit, false);
109
112
  if (validity !== VoluntaryExitValidity.valid) {
110
- throw new VoluntaryExitError(GossipAction.REJECT, {
113
+ let action: GossipAction;
114
+ switch (validity) {
115
+ // [IGNORE] The voluntary exit epoch is not in the future
116
+ case VoluntaryExitValidity.earlyEpoch:
117
+ // [IGNORE] The validator has not already initiated exit
118
+ case VoluntaryExitValidity.alreadyExited:
119
+ // [IGNORE] The validator has no pending partial withdrawals
120
+ case VoluntaryExitValidity.pendingWithdrawals:
121
+ action = GossipAction.IGNORE;
122
+ break;
123
+ // [REJECT] The validator index is valid
124
+ // [REJECT] The validator is active
125
+ // An exit in a future epoch or of a validator past its exit epoch can also be reported as inactive,
126
+ // the spec checks both conditions first and ignores the exit
127
+ case VoluntaryExitValidity.inactive: {
128
+ const {epoch, validatorIndex} = voluntaryExit.message;
129
+ if (epoch > state.epoch) {
130
+ throw new VoluntaryExitError(GossipAction.IGNORE, {code: VoluntaryExitErrorCode.EARLY_EPOCH});
131
+ }
132
+ if (
133
+ validatorIndex < state.validatorCount &&
134
+ state.getValidator(validatorIndex).exitEpoch !== FAR_FUTURE_EPOCH
135
+ ) {
136
+ throw new VoluntaryExitError(GossipAction.IGNORE, {code: VoluntaryExitErrorCode.ALREADY_EXITED});
137
+ }
138
+ action = GossipAction.REJECT;
139
+ break;
140
+ }
141
+ // [REJECT] The validator has been active long enough
142
+ case VoluntaryExitValidity.shortTimeActive:
143
+ case VoluntaryExitValidity.invalidSignature:
144
+ action = GossipAction.REJECT;
145
+ break;
146
+ }
147
+ throw new VoluntaryExitError(action, {
111
148
  code: voluntaryExitValidityToErrorCode(validity),
112
149
  });
113
150
  }
114
151
 
152
+ // [REJECT] The signature is valid
115
153
  const signatureSet = getVoluntaryExitSignatureSet(chain.config, state, voluntaryExit);
116
154
  if (!(await chain.bls.verifySignatureSets([signatureSet], {batchable: true, priority: prioritizeBls}))) {
117
155
  throw new VoluntaryExitError(GossipAction.REJECT, {