@lodestar/beacon-node 1.47.0-dev.cec7fd63e3 → 1.47.0-dev.d477ac6ef7

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 (356) 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 -18
  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 +25 -2
  6. package/lib/api/impl/beacon/pool/index.js.map +1 -1
  7. package/lib/api/impl/beacon/state/utils.d.ts +2 -1
  8. package/lib/api/impl/beacon/state/utils.d.ts.map +1 -1
  9. package/lib/api/impl/beacon/state/utils.js.map +1 -1
  10. package/lib/api/impl/events/index.d.ts +1 -1
  11. package/lib/api/impl/events/index.d.ts.map +1 -1
  12. package/lib/api/impl/events/index.js +12 -3
  13. package/lib/api/impl/events/index.js.map +1 -1
  14. package/lib/api/impl/lodestar/index.js +1 -1
  15. package/lib/api/impl/lodestar/index.js.map +1 -1
  16. package/lib/api/impl/validator/index.d.ts.map +1 -1
  17. package/lib/api/impl/validator/index.js +232 -49
  18. package/lib/api/impl/validator/index.js.map +1 -1
  19. package/lib/api/impl/validator/utils.js +1 -1
  20. package/lib/api/impl/validator/utils.js.map +1 -1
  21. package/lib/api/rest/base.d.ts.map +1 -1
  22. package/lib/api/rest/base.js +7 -0
  23. package/lib/api/rest/base.js.map +1 -1
  24. package/lib/chain/archiveStore/archiveStore.js +1 -1
  25. package/lib/chain/archiveStore/archiveStore.js.map +1 -1
  26. package/lib/chain/archiveStore/historicalState/metrics.d.ts.map +1 -1
  27. package/lib/chain/archiveStore/historicalState/metrics.js +21 -0
  28. package/lib/chain/archiveStore/historicalState/metrics.js.map +1 -1
  29. package/lib/chain/blocks/importBlock.d.ts.map +1 -1
  30. package/lib/chain/blocks/importBlock.js +2 -7
  31. package/lib/chain/blocks/importBlock.js.map +1 -1
  32. package/lib/chain/blocks/importExecutionPayload.d.ts +3 -2
  33. package/lib/chain/blocks/importExecutionPayload.d.ts.map +1 -1
  34. package/lib/chain/blocks/importExecutionPayload.js +11 -9
  35. package/lib/chain/blocks/importExecutionPayload.js.map +1 -1
  36. package/lib/chain/blocks/index.d.ts.map +1 -1
  37. package/lib/chain/blocks/index.js +21 -13
  38. package/lib/chain/blocks/index.js.map +1 -1
  39. package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.d.ts +2 -1
  40. package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.d.ts.map +1 -1
  41. package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.js +6 -2
  42. package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.js.map +1 -1
  43. package/lib/chain/blocks/payloadEnvelopeInput/types.d.ts +14 -5
  44. package/lib/chain/blocks/payloadEnvelopeInput/types.d.ts.map +1 -1
  45. package/lib/chain/blocks/payloadEnvelopeInput/types.js +5 -0
  46. package/lib/chain/blocks/payloadEnvelopeInput/types.js.map +1 -1
  47. package/lib/chain/blocks/verifyBlock.d.ts.map +1 -1
  48. package/lib/chain/blocks/verifyBlock.js +5 -2
  49. package/lib/chain/blocks/verifyBlock.js.map +1 -1
  50. package/lib/chain/blocks/verifyBlocksStateTransitionOnly.d.ts.map +1 -1
  51. package/lib/chain/blocks/verifyBlocksStateTransitionOnly.js +22 -12
  52. package/lib/chain/blocks/verifyBlocksStateTransitionOnly.js.map +1 -1
  53. package/lib/chain/blocks/verifyExecutionPayloadEnvelope.d.ts +2 -2
  54. package/lib/chain/blocks/verifyExecutionPayloadEnvelope.d.ts.map +1 -1
  55. package/lib/chain/blocks/verifyExecutionPayloadEnvelope.js +2 -2
  56. package/lib/chain/blocks/verifyExecutionPayloadEnvelope.js.map +1 -1
  57. package/lib/chain/bls/index.d.ts +1 -1
  58. package/lib/chain/bls/index.d.ts.map +1 -1
  59. package/lib/chain/bls/interface.d.ts +5 -5
  60. package/lib/chain/bls/interface.d.ts.map +1 -1
  61. package/lib/chain/bls/multithread/index.d.ts +5 -11
  62. package/lib/chain/bls/multithread/index.d.ts.map +1 -1
  63. package/lib/chain/bls/multithread/index.js +116 -101
  64. package/lib/chain/bls/multithread/index.js.map +1 -1
  65. package/lib/chain/bls/multithread/jobItem.d.ts +5 -19
  66. package/lib/chain/bls/multithread/jobItem.d.ts.map +1 -1
  67. package/lib/chain/bls/multithread/jobItem.js +10 -65
  68. package/lib/chain/bls/multithread/jobItem.js.map +1 -1
  69. package/lib/chain/bls/multithread/types.d.ts +29 -8
  70. package/lib/chain/bls/multithread/types.d.ts.map +1 -1
  71. package/lib/chain/bls/multithread/types.js +12 -0
  72. package/lib/chain/bls/multithread/types.js.map +1 -1
  73. package/lib/chain/bls/multithread/utils.d.ts +4 -0
  74. package/lib/chain/bls/multithread/utils.d.ts.map +1 -1
  75. package/lib/chain/bls/multithread/utils.js +10 -0
  76. package/lib/chain/bls/multithread/utils.js.map +1 -1
  77. package/lib/chain/bls/multithread/worker.js +49 -23
  78. package/lib/chain/bls/multithread/worker.js.map +1 -1
  79. package/lib/chain/bls/singleThread.d.ts +4 -10
  80. package/lib/chain/bls/singleThread.d.ts.map +1 -1
  81. package/lib/chain/bls/singleThread.js +8 -45
  82. package/lib/chain/bls/singleThread.js.map +1 -1
  83. package/lib/chain/bls/utils.d.ts +4 -4
  84. package/lib/chain/bls/utils.d.ts.map +1 -1
  85. package/lib/chain/bls/utils.js +18 -19
  86. package/lib/chain/bls/utils.js.map +1 -1
  87. package/lib/chain/chain.d.ts +9 -4
  88. package/lib/chain/chain.d.ts.map +1 -1
  89. package/lib/chain/chain.js +22 -8
  90. package/lib/chain/chain.js.map +1 -1
  91. package/lib/chain/errors/blockError.d.ts +1 -0
  92. package/lib/chain/errors/blockError.d.ts.map +1 -1
  93. package/lib/chain/errors/blockError.js +6 -1
  94. package/lib/chain/errors/blockError.js.map +1 -1
  95. package/lib/chain/errors/proposerPreferences.d.ts +6 -0
  96. package/lib/chain/errors/proposerPreferences.d.ts.map +1 -1
  97. package/lib/chain/errors/proposerPreferences.js +1 -0
  98. package/lib/chain/errors/proposerPreferences.js.map +1 -1
  99. package/lib/chain/forkChoice/index.d.ts.map +1 -1
  100. package/lib/chain/forkChoice/index.js +4 -0
  101. package/lib/chain/forkChoice/index.js.map +1 -1
  102. package/lib/chain/interface.d.ts +8 -4
  103. package/lib/chain/interface.d.ts.map +1 -1
  104. package/lib/chain/interface.js.map +1 -1
  105. package/lib/chain/opPools/aggregatedAttestationPool.js +1 -1
  106. package/lib/chain/opPools/aggregatedAttestationPool.js.map +1 -1
  107. package/lib/chain/opPools/attestationPool.d.ts +1 -1
  108. package/lib/chain/opPools/attestationPool.d.ts.map +1 -1
  109. package/lib/chain/opPools/attestationPool.js +1 -1
  110. package/lib/chain/opPools/attestationPool.js.map +1 -1
  111. package/lib/chain/opPools/deferredVoluntaryExitPool.d.ts +16 -0
  112. package/lib/chain/opPools/deferredVoluntaryExitPool.d.ts.map +1 -0
  113. package/lib/chain/opPools/deferredVoluntaryExitPool.js +57 -0
  114. package/lib/chain/opPools/deferredVoluntaryExitPool.js.map +1 -0
  115. package/lib/chain/opPools/executionPayloadBidPool.d.ts +7 -2
  116. package/lib/chain/opPools/executionPayloadBidPool.d.ts.map +1 -1
  117. package/lib/chain/opPools/executionPayloadBidPool.js +4 -4
  118. package/lib/chain/opPools/executionPayloadBidPool.js.map +1 -1
  119. package/lib/chain/opPools/index.d.ts +2 -1
  120. package/lib/chain/opPools/index.d.ts.map +1 -1
  121. package/lib/chain/opPools/index.js +1 -0
  122. package/lib/chain/opPools/index.js.map +1 -1
  123. package/lib/chain/opPools/payloadAttestationPool.js +3 -3
  124. package/lib/chain/opPools/payloadAttestationPool.js.map +1 -1
  125. package/lib/chain/opPools/syncCommitteeMessagePool.js +1 -1
  126. package/lib/chain/opPools/syncCommitteeMessagePool.js.map +1 -1
  127. package/lib/chain/opPools/syncContributionAndProofPool.js +1 -1
  128. package/lib/chain/opPools/syncContributionAndProofPool.js.map +1 -1
  129. package/lib/chain/opPools/utils.d.ts +1 -1
  130. package/lib/chain/opPools/utils.d.ts.map +1 -1
  131. package/lib/chain/opPools/utils.js +1 -1
  132. package/lib/chain/opPools/utils.js.map +1 -1
  133. package/lib/chain/prepareNextSlot.d.ts.map +1 -1
  134. package/lib/chain/prepareNextSlot.js +24 -6
  135. package/lib/chain/prepareNextSlot.js.map +1 -1
  136. package/lib/chain/produceBlock/computeNewStateRoot.d.ts.map +1 -1
  137. package/lib/chain/produceBlock/computeNewStateRoot.js +3 -25
  138. package/lib/chain/produceBlock/computeNewStateRoot.js.map +1 -1
  139. package/lib/chain/produceBlock/produceBlockBody.js +1 -1
  140. package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
  141. package/lib/chain/regen/interface.d.ts +5 -2
  142. package/lib/chain/regen/interface.d.ts.map +1 -1
  143. package/lib/chain/regen/interface.js +3 -0
  144. package/lib/chain/regen/interface.js.map +1 -1
  145. package/lib/chain/regen/queued.d.ts +2 -2
  146. package/lib/chain/regen/queued.d.ts.map +1 -1
  147. package/lib/chain/regen/queued.js +5 -5
  148. package/lib/chain/regen/queued.js.map +1 -1
  149. package/lib/chain/seenCache/seenAttesters.d.ts +9 -5
  150. package/lib/chain/seenCache/seenAttesters.d.ts.map +1 -1
  151. package/lib/chain/seenCache/seenAttesters.js +25 -4
  152. package/lib/chain/seenCache/seenAttesters.js.map +1 -1
  153. package/lib/chain/seenCache/seenPayloadEnvelopeInput.d.ts +28 -1
  154. package/lib/chain/seenCache/seenPayloadEnvelopeInput.d.ts.map +1 -1
  155. package/lib/chain/seenCache/seenPayloadEnvelopeInput.js +121 -13
  156. package/lib/chain/seenCache/seenPayloadEnvelopeInput.js.map +1 -1
  157. package/lib/chain/stateCache/fifoBlockStateCache.d.ts +5 -1
  158. package/lib/chain/stateCache/fifoBlockStateCache.d.ts.map +1 -1
  159. package/lib/chain/stateCache/fifoBlockStateCache.js +6 -0
  160. package/lib/chain/stateCache/fifoBlockStateCache.js.map +1 -1
  161. package/lib/chain/stateCache/persistentCheckpointsCache.d.ts +47 -5
  162. package/lib/chain/stateCache/persistentCheckpointsCache.d.ts.map +1 -1
  163. package/lib/chain/stateCache/persistentCheckpointsCache.js +117 -7
  164. package/lib/chain/stateCache/persistentCheckpointsCache.js.map +1 -1
  165. package/lib/chain/stateCache/types.d.ts +3 -3
  166. package/lib/chain/stateCache/types.d.ts.map +1 -1
  167. package/lib/chain/validation/attestation.d.ts.map +1 -1
  168. package/lib/chain/validation/attestation.js +1 -4
  169. package/lib/chain/validation/attestation.js.map +1 -1
  170. package/lib/chain/validation/attesterSlashing.d.ts.map +1 -1
  171. package/lib/chain/validation/attesterSlashing.js +1 -1
  172. package/lib/chain/validation/attesterSlashing.js.map +1 -1
  173. package/lib/chain/validation/block.d.ts.map +1 -1
  174. package/lib/chain/validation/block.js +40 -10
  175. package/lib/chain/validation/block.js.map +1 -1
  176. package/lib/chain/validation/executionPayloadBid.d.ts +13 -3
  177. package/lib/chain/validation/executionPayloadBid.d.ts.map +1 -1
  178. package/lib/chain/validation/executionPayloadBid.js +147 -12
  179. package/lib/chain/validation/executionPayloadBid.js.map +1 -1
  180. package/lib/chain/validation/executionPayloadEnvelope.js +1 -1
  181. package/lib/chain/validation/executionPayloadEnvelope.js.map +1 -1
  182. package/lib/chain/validation/payloadAttestationMessage.d.ts.map +1 -1
  183. package/lib/chain/validation/payloadAttestationMessage.js +5 -14
  184. package/lib/chain/validation/payloadAttestationMessage.js.map +1 -1
  185. package/lib/chain/validation/proposerPreferences.d.ts +1 -1
  186. package/lib/chain/validation/proposerPreferences.d.ts.map +1 -1
  187. package/lib/chain/validation/proposerPreferences.js +13 -4
  188. package/lib/chain/validation/proposerPreferences.js.map +1 -1
  189. package/lib/chain/validation/proposerSlashing.js +1 -1
  190. package/lib/chain/validation/proposerSlashing.js.map +1 -1
  191. package/lib/chain/validation/voluntaryExit.d.ts +9 -1
  192. package/lib/chain/validation/voluntaryExit.d.ts.map +1 -1
  193. package/lib/chain/validation/voluntaryExit.js +46 -1
  194. package/lib/chain/validation/voluntaryExit.js.map +1 -1
  195. package/lib/execution/builder/apiClient.d.ts +64 -0
  196. package/lib/execution/builder/apiClient.d.ts.map +1 -0
  197. package/lib/execution/builder/apiClient.js +184 -0
  198. package/lib/execution/builder/apiClient.js.map +1 -0
  199. package/lib/execution/builder/validateBid.d.ts +22 -0
  200. package/lib/execution/builder/validateBid.d.ts.map +1 -0
  201. package/lib/execution/builder/validateBid.js +111 -0
  202. package/lib/execution/builder/validateBid.js.map +1 -0
  203. package/lib/metrics/metrics/lodestar.d.ts +91 -23
  204. package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
  205. package/lib/metrics/metrics/lodestar.js +172 -55
  206. package/lib/metrics/metrics/lodestar.js.map +1 -1
  207. package/lib/network/gossip/topic.d.ts +13 -0
  208. package/lib/network/gossip/topic.d.ts.map +1 -1
  209. package/lib/network/gossip/topic.js +37 -0
  210. package/lib/network/gossip/topic.js.map +1 -1
  211. package/lib/network/libp2p/index.d.ts.map +1 -1
  212. package/lib/network/libp2p/index.js +10 -2
  213. package/lib/network/libp2p/index.js.map +1 -1
  214. package/lib/network/network.d.ts.map +1 -1
  215. package/lib/network/network.js +23 -43
  216. package/lib/network/network.js.map +1 -1
  217. package/lib/network/processor/constants.d.ts +7 -0
  218. package/lib/network/processor/constants.d.ts.map +1 -0
  219. package/lib/network/processor/constants.js +7 -0
  220. package/lib/network/processor/constants.js.map +1 -0
  221. package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
  222. package/lib/network/processor/gossipHandlers.js +13 -4
  223. package/lib/network/processor/gossipHandlers.js.map +1 -1
  224. package/lib/network/processor/gossipQueues/indexed.d.ts.map +1 -1
  225. package/lib/network/processor/gossipQueues/indexed.js +0 -1
  226. package/lib/network/processor/gossipQueues/indexed.js.map +1 -1
  227. package/lib/network/processor/index.d.ts +3 -0
  228. package/lib/network/processor/index.d.ts.map +1 -1
  229. package/lib/network/processor/index.js +52 -23
  230. package/lib/network/processor/index.js.map +1 -1
  231. package/lib/network/reqresp/score.d.ts.map +1 -1
  232. package/lib/network/reqresp/score.js +5 -11
  233. package/lib/network/reqresp/score.js.map +1 -1
  234. package/lib/network/util.d.ts +0 -1
  235. package/lib/network/util.d.ts.map +1 -1
  236. package/lib/network/util.js +0 -4
  237. package/lib/network/util.js.map +1 -1
  238. package/lib/node/deferredVoluntaryExitPublisher.d.ts +15 -0
  239. package/lib/node/deferredVoluntaryExitPublisher.d.ts.map +1 -0
  240. package/lib/node/deferredVoluntaryExitPublisher.js +38 -0
  241. package/lib/node/deferredVoluntaryExitPublisher.js.map +1 -0
  242. package/lib/node/nodejs.d.ts +2 -1
  243. package/lib/node/nodejs.d.ts.map +1 -1
  244. package/lib/node/nodejs.js +7 -0
  245. package/lib/node/nodejs.js.map +1 -1
  246. package/lib/sync/range/batch.d.ts +23 -5
  247. package/lib/sync/range/batch.d.ts.map +1 -1
  248. package/lib/sync/range/batch.js +61 -22
  249. package/lib/sync/range/batch.js.map +1 -1
  250. package/lib/sync/range/chain.d.ts +2 -1
  251. package/lib/sync/range/chain.d.ts.map +1 -1
  252. package/lib/sync/range/chain.js +32 -12
  253. package/lib/sync/range/chain.js.map +1 -1
  254. package/lib/sync/range/range.js +1 -1
  255. package/lib/sync/range/range.js.map +1 -1
  256. package/lib/sync/types.d.ts +32 -0
  257. package/lib/sync/types.d.ts.map +1 -1
  258. package/lib/sync/types.js +33 -0
  259. package/lib/sync/types.js.map +1 -1
  260. package/lib/sync/unknownBlock.d.ts +15 -2
  261. package/lib/sync/unknownBlock.d.ts.map +1 -1
  262. package/lib/sync/unknownBlock.js +220 -61
  263. package/lib/sync/unknownBlock.js.map +1 -1
  264. package/lib/sync/utils/downloadByRange.d.ts.map +1 -1
  265. package/lib/sync/utils/downloadByRange.js +16 -11
  266. package/lib/sync/utils/downloadByRange.js.map +1 -1
  267. package/lib/sync/utils/downloadByRoot.d.ts.map +1 -1
  268. package/lib/sync/utils/downloadByRoot.js +3 -1
  269. package/lib/sync/utils/downloadByRoot.js.map +1 -1
  270. package/package.json +35 -35
  271. package/src/api/impl/beacon/blocks/index.ts +55 -21
  272. package/src/api/impl/beacon/pool/index.ts +27 -2
  273. package/src/api/impl/beacon/state/utils.ts +2 -1
  274. package/src/api/impl/events/index.ts +12 -4
  275. package/src/api/impl/lodestar/index.ts +1 -1
  276. package/src/api/impl/validator/index.ts +285 -49
  277. package/src/api/impl/validator/utils.ts +1 -1
  278. package/src/api/rest/base.ts +7 -0
  279. package/src/chain/archiveStore/archiveStore.ts +1 -1
  280. package/src/chain/archiveStore/historicalState/metrics.ts +22 -0
  281. package/src/chain/blocks/importBlock.ts +1 -6
  282. package/src/chain/blocks/importExecutionPayload.ts +12 -11
  283. package/src/chain/blocks/index.ts +25 -13
  284. package/src/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.ts +8 -2
  285. package/src/chain/blocks/payloadEnvelopeInput/types.ts +17 -4
  286. package/src/chain/blocks/verifyBlock.ts +5 -2
  287. package/src/chain/blocks/verifyBlocksStateTransitionOnly.ts +25 -16
  288. package/src/chain/blocks/verifyExecutionPayloadEnvelope.ts +1 -9
  289. package/src/chain/bls/index.ts +1 -1
  290. package/src/chain/bls/interface.ts +7 -3
  291. package/src/chain/bls/multithread/index.ts +148 -120
  292. package/src/chain/bls/multithread/jobItem.ts +12 -82
  293. package/src/chain/bls/multithread/types.ts +33 -8
  294. package/src/chain/bls/multithread/utils.ts +11 -0
  295. package/src/chain/bls/multithread/worker.ts +85 -27
  296. package/src/chain/bls/singleThread.ts +11 -55
  297. package/src/chain/bls/utils.ts +23 -24
  298. package/src/chain/chain.ts +25 -7
  299. package/src/chain/errors/blockError.ts +8 -2
  300. package/src/chain/errors/proposerPreferences.ts +7 -0
  301. package/src/chain/forkChoice/index.ts +4 -0
  302. package/src/chain/interface.ts +8 -3
  303. package/src/chain/opPools/aggregatedAttestationPool.ts +1 -1
  304. package/src/chain/opPools/attestationPool.ts +1 -1
  305. package/src/chain/opPools/deferredVoluntaryExitPool.ts +65 -0
  306. package/src/chain/opPools/executionPayloadBidPool.ts +13 -7
  307. package/src/chain/opPools/index.ts +2 -1
  308. package/src/chain/opPools/payloadAttestationPool.ts +3 -3
  309. package/src/chain/opPools/syncCommitteeMessagePool.ts +1 -1
  310. package/src/chain/opPools/syncContributionAndProofPool.ts +1 -1
  311. package/src/chain/opPools/utils.ts +1 -1
  312. package/src/chain/prepareNextSlot.ts +24 -6
  313. package/src/chain/produceBlock/computeNewStateRoot.ts +3 -38
  314. package/src/chain/produceBlock/produceBlockBody.ts +1 -1
  315. package/src/chain/regen/interface.ts +5 -2
  316. package/src/chain/regen/queued.ts +5 -5
  317. package/src/chain/seenCache/seenAttesters.ts +31 -5
  318. package/src/chain/seenCache/seenPayloadEnvelopeInput.ts +143 -14
  319. package/src/chain/stateCache/fifoBlockStateCache.ts +8 -1
  320. package/src/chain/stateCache/persistentCheckpointsCache.ts +133 -8
  321. package/src/chain/stateCache/types.ts +3 -3
  322. package/src/chain/validation/attestation.ts +1 -7
  323. package/src/chain/validation/attesterSlashing.ts +1 -8
  324. package/src/chain/validation/block.ts +43 -10
  325. package/src/chain/validation/executionPayloadBid.ts +168 -14
  326. package/src/chain/validation/executionPayloadEnvelope.ts +0 -1
  327. package/src/chain/validation/payloadAttestationMessage.ts +6 -17
  328. package/src/chain/validation/proposerPreferences.ts +15 -5
  329. package/src/chain/validation/proposerSlashing.ts +1 -1
  330. package/src/chain/validation/voluntaryExit.ts +59 -2
  331. package/src/execution/builder/apiClient.ts +244 -0
  332. package/src/execution/builder/validateBid.ts +166 -0
  333. package/src/metrics/metrics/lodestar.ts +187 -61
  334. package/src/network/gossip/topic.ts +38 -0
  335. package/src/network/libp2p/index.ts +11 -2
  336. package/src/network/network.ts +29 -54
  337. package/src/network/processor/constants.ts +6 -0
  338. package/src/network/processor/gossipHandlers.ts +15 -2
  339. package/src/network/processor/gossipQueues/indexed.ts +0 -1
  340. package/src/network/processor/index.ts +67 -30
  341. package/src/network/reqresp/score.ts +5 -11
  342. package/src/network/util.ts +0 -5
  343. package/src/node/deferredVoluntaryExitPublisher.ts +54 -0
  344. package/src/node/nodejs.ts +10 -1
  345. package/src/sync/range/batch.ts +83 -28
  346. package/src/sync/range/chain.ts +35 -13
  347. package/src/sync/range/range.ts +1 -1
  348. package/src/sync/types.ts +36 -1
  349. package/src/sync/unknownBlock.ts +258 -68
  350. package/src/sync/utils/downloadByRange.ts +21 -12
  351. package/src/sync/utils/downloadByRoot.ts +3 -1
  352. package/lib/chain/bls/maybeBatch.d.ts +0 -12
  353. package/lib/chain/bls/maybeBatch.d.ts.map +0 -1
  354. package/lib/chain/bls/maybeBatch.js +0 -35
  355. package/lib/chain/bls/maybeBatch.js.map +0 -1
  356. package/src/chain/bls/maybeBatch.ts +0 -45
@@ -1,6 +1,5 @@
1
1
  import {
2
- computeEpochAtSlot,
3
- createSingleSignatureSetFromComponents,
2
+ createIndexedSignatureSetFromComponents,
4
3
  getPayloadAttestationDataSigningRoot,
5
4
  isStatePostGloas,
6
5
  } from "@lodestar/state-transition";
@@ -36,7 +35,6 @@ async function validatePayloadAttestationMessage(
36
35
  prioritizeBls = false
37
36
  ): Promise<PayloadAttestationValidationResult> {
38
37
  const {data, validatorIndex} = payloadAttestationMessage;
39
- const epoch = computeEpochAtSlot(data.slot);
40
38
 
41
39
  // [IGNORE] The message's slot is for the current slot (with a `MAXIMUM_GOSSIP_CLOCK_DISPARITY` allowance), i.e. `data.slot == current_slot`.
42
40
  if (!chain.clock.isCurrentSlotGivenGossipDisparity(data.slot)) {
@@ -48,9 +46,8 @@ async function validatePayloadAttestationMessage(
48
46
  }
49
47
 
50
48
  // [IGNORE] The `payload_attestation_message` is the first valid message received
51
- // from the validator with index `payload_attestation_message.validator_index`.
52
- // A single validator can participate PTC at most once per epoch
53
- if (chain.seenPayloadAttesters.isKnown(epoch, validatorIndex)) {
49
+ // for the slot from the validator with index `payload_attestation_message.validator_index`.
50
+ if (chain.seenPayloadAttesters.isKnown(data.slot, validatorIndex)) {
54
51
  throw new PayloadAttestationError(GossipAction.IGNORE, {
55
52
  code: PayloadAttestationErrorCode.PAYLOAD_ATTESTATION_ALREADY_KNOWN,
56
53
  validatorIndex,
@@ -114,16 +111,8 @@ async function validatePayloadAttestationMessage(
114
111
  }
115
112
 
116
113
  // [REJECT] `payload_attestation_message.signature` is valid with respect to the validator's public key.
117
- const validatorPubkey = chain.pubkeyCache.get(validatorIndex);
118
- if (!validatorPubkey) {
119
- throw new PayloadAttestationError(GossipAction.REJECT, {
120
- code: PayloadAttestationErrorCode.INVALID_ATTESTER,
121
- attesterIndex: validatorIndex,
122
- });
123
- }
124
-
125
- const signatureSet = createSingleSignatureSetFromComponents(
126
- validatorPubkey,
114
+ const signatureSet = createIndexedSignatureSetFromComponents(
115
+ validatorIndex,
127
116
  getPayloadAttestationDataSigningRoot(chain.config, data),
128
117
  payloadAttestationMessage.signature
129
118
  );
@@ -135,7 +124,7 @@ async function validatePayloadAttestationMessage(
135
124
  }
136
125
 
137
126
  // Valid
138
- chain.seenPayloadAttesters.add(epoch, validatorIndex);
127
+ chain.seenPayloadAttesters.add(data.slot, validatorIndex);
139
128
 
140
129
  return {
141
130
  attDataRootHex: toRootHex(ssz.gloas.PayloadAttestationData.hashTreeRoot(data)),
@@ -1,9 +1,9 @@
1
1
  import {IForkChoice, ProtoBlock} from "@lodestar/fork-choice";
2
- import {GENESIS_EPOCH, GENESIS_SLOT, MIN_SEED_LOOKAHEAD, SLOTS_PER_EPOCH} from "@lodestar/params";
2
+ import {GENESIS_EPOCH, GENESIS_SLOT, MIN_SEED_LOOKAHEAD, SLOTS_PER_EPOCH, isForkPostGloas} from "@lodestar/params";
3
3
  import {
4
4
  computeEpochAtSlot,
5
5
  computeStartSlotAtEpoch,
6
- createSingleSignatureSetFromComponents,
6
+ createIndexedSignatureSetFromComponents,
7
7
  getProposerPreferencesSigningRoot,
8
8
  } from "@lodestar/state-transition";
9
9
  import {Epoch, Slot, ValidatorIndex, gloas} from "@lodestar/types";
@@ -13,7 +13,7 @@ import {IBeaconChain} from "../index.js";
13
13
 
14
14
  /**
15
15
  * Validates a gossiped `SignedProposerPreferences` per
16
- * https://github.com/ethereum/consensus-specs/blob/v1.7.0-alpha.13/specs/gloas/p2p-interface.md#new-proposer_preferences
16
+ * https://github.com/ethereum/consensus-specs/blob/v1.7.0-alpha.14/specs/gloas/p2p-interface.md#new-proposer_preferences
17
17
  */
18
18
  export async function validateGossipProposerPreferences(
19
19
  chain: IBeaconChain,
@@ -24,6 +24,16 @@ export async function validateGossipProposerPreferences(
24
24
  const dependentRootHex = toRootHex(dependentRoot);
25
25
  const proposalEpoch = computeEpochAtSlot(proposalSlot);
26
26
 
27
+ // [IGNORE] The proposal epoch is after the Gloas upgrade
28
+ const proposalFork = chain.config.getForkName(proposalSlot);
29
+ if (!isForkPostGloas(proposalFork)) {
30
+ throw new ProposerPreferencesError(GossipAction.IGNORE, {
31
+ code: ProposerPreferencesErrorCode.PRE_GLOAS_PROPOSAL_SLOT,
32
+ proposalSlot,
33
+ proposalFork,
34
+ });
35
+ }
36
+
27
37
  // [IGNORE] `preferences.proposal_slot` is within the proposer lookahead,
28
38
  // allowing for `MAXIMUM_GOSSIP_CLOCK_DISPARITY`.
29
39
  const currentEpoch = computeEpochAtSlot(chain.clock.currentSlotWithGossipDisparity);
@@ -129,8 +139,8 @@ export async function validateGossipProposerPreferences(
129
139
  }
130
140
 
131
141
  // [REJECT] `signed_proposer_preferences.signature` is valid with respect to the validator's public key.
132
- const signatureSet = createSingleSignatureSetFromComponents(
133
- chain.pubkeyCache.getOrThrow(validatorIndex),
142
+ const signatureSet = createIndexedSignatureSetFromComponents(
143
+ validatorIndex,
134
144
  getProposerPreferencesSigningRoot(chain.config, preferences),
135
145
  signedProposerPreferences.signature
136
146
  );
@@ -37,7 +37,7 @@ async function validateProposerSlashing(
37
37
  try {
38
38
  const proposer = state.getValidator(proposerSlashing.signedHeader1.message.proposerIndex);
39
39
  // verifySignature = false, verified in batch below
40
- assertValidProposerSlashing(chain.config, chain.pubkeyCache, state.slot, proposerSlashing, proposer, false);
40
+ assertValidProposerSlashing(chain.config, state.slot, proposerSlashing, proposer, false);
41
41
  } catch (e) {
42
42
  throw new ProposerSlashingError(GossipAction.REJECT, {
43
43
  code: ProposerSlashingErrorCode.INVALID,
@@ -9,12 +9,69 @@ import {
9
9
  import {IBeaconChain} from "../index.js";
10
10
  import {RegenCaller} from "../regen/index.js";
11
11
 
12
+ export type ApiVoluntaryExitResult = {status: "published"} | {status: "deferred"; validity: VoluntaryExitValidity};
13
+
14
+ // Variants that can become valid in a future epoch without user action.
15
+ // - earlyEpoch: exit.message.epoch is in the future; valid once current epoch catches up
16
+ // - shortTimeActive: validator active < SHARD_COMMITTEE_PERIOD; valid once enough time passes
17
+ // - pendingWithdrawals: Electra; valid once pending partial withdrawals drain
18
+ // Note: VoluntaryExitValidity.inactive is intentionally excluded. It conflates
19
+ // "validator does not exist" (permanent) with "validator not yet activated"
20
+ // (transient), and cleanly classifying it requires splitting the enum variant
21
+ // upstream. Left for a future follow-up.
22
+
23
+ export function isTransientExitValidity(v: VoluntaryExitValidity): boolean {
24
+ switch (v) {
25
+ case VoluntaryExitValidity.earlyEpoch:
26
+ case VoluntaryExitValidity.shortTimeActive:
27
+ case VoluntaryExitValidity.pendingWithdrawals:
28
+ return true;
29
+ case VoluntaryExitValidity.valid:
30
+ case VoluntaryExitValidity.inactive:
31
+ case VoluntaryExitValidity.alreadyExited:
32
+ case VoluntaryExitValidity.invalidSignature:
33
+ return false;
34
+ }
35
+ }
36
+
37
+ // Comments for each call are present inside `validateVoluntaryExit`.
12
38
  export async function validateApiVoluntaryExit(
13
39
  chain: IBeaconChain,
14
40
  voluntaryExit: phase0.SignedVoluntaryExit
15
- ): Promise<void> {
41
+ ): Promise<ApiVoluntaryExitResult> {
16
42
  const prioritizeBls = true;
17
- return validateVoluntaryExit(chain, voluntaryExit, prioritizeBls);
43
+
44
+ if (
45
+ chain.opPool.hasSeenVoluntaryExit(voluntaryExit.message.validatorIndex) ||
46
+ chain.deferredVoluntaryExitPool.has(voluntaryExit.message.validatorIndex)
47
+ ) {
48
+ throw new VoluntaryExitError(GossipAction.IGNORE, {
49
+ code: VoluntaryExitErrorCode.ALREADY_EXISTS,
50
+ });
51
+ }
52
+
53
+ const state = await chain.getHeadStateAtCurrentEpoch(RegenCaller.validateApiVoluntaryExit);
54
+ const validity = state.getVoluntaryExitValidity(voluntaryExit, false);
55
+
56
+ if (validity !== VoluntaryExitValidity.valid && !isTransientExitValidity(validity)) {
57
+ throw new VoluntaryExitError(GossipAction.REJECT, {
58
+ code: voluntaryExitValidityToErrorCode(validity),
59
+ });
60
+ }
61
+
62
+ const signatureSet = getVoluntaryExitSignatureSet(chain.config, state, voluntaryExit);
63
+ if (!(await chain.bls.verifySignatureSets([signatureSet], {batchable: true, priority: prioritizeBls}))) {
64
+ throw new VoluntaryExitError(GossipAction.REJECT, {
65
+ code: VoluntaryExitErrorCode.INVALID_SIGNATURE,
66
+ });
67
+ }
68
+
69
+ if (validity !== VoluntaryExitValidity.valid) {
70
+ // Transient failure — signature is good, defer
71
+ return {status: "deferred", validity};
72
+ }
73
+
74
+ return {status: "published"};
18
75
  }
19
76
 
20
77
  export async function validateGossipVoluntaryExit(
@@ -0,0 +1,244 @@
1
+ import {routes} from "@lodestar/api";
2
+ import {ApiClient as BuilderApi, getClient} from "@lodestar/api/builder";
3
+ import {ChainForkConfig} from "@lodestar/config";
4
+ import {Logger} from "@lodestar/logger";
5
+ import {DOMAIN_BUILDER_REQUEST_AUTH, ForkPostGloas} from "@lodestar/params";
6
+ import {
7
+ ZERO_HASH,
8
+ computeDomain,
9
+ computeSigningRoot,
10
+ createSingleSignatureSetFromComponents,
11
+ } from "@lodestar/state-transition";
12
+ import {BLSPubkey, Root, SignedBeaconBlock, Slot, WithOptionalBytes, gloas, ssz} from "@lodestar/types";
13
+ import {isValidAsciiHttpUrl, toHex, toPrintableUrl} from "@lodestar/utils";
14
+ import type {IBlsVerifier} from "../../chain/bls/index.js";
15
+ import {Metrics} from "../../metrics/metrics.js";
16
+ import {IClock} from "../../util/clock.js";
17
+
18
+ /**
19
+ * Additional duration to account for potential event loop lag which causes
20
+ * builder bids to be rejected even though the response was sent in time.
21
+ */
22
+ const EVENT_LOOP_LAG_BUFFER = 250;
23
+
24
+ /**
25
+ * Duration given to a builder to provide a `SignedExecutionPayloadBid` before the deadline
26
+ * is reached, advertised on each bid request via the `X-Timeout-Ms` header. The p2p bid is
27
+ * selected after the same duration, only considering bids received up to that point.
28
+ */
29
+ export const BUILDER_BID_DEADLINE_MS = 500;
30
+
31
+ /** Local timeout for bid requests, event loop lag must not discard bids that arrived in time */
32
+ export const BUILDER_BID_REQUEST_TIMEOUT_MS = BUILDER_BID_DEADLINE_MS + EVENT_LOOP_LAG_BUFFER;
33
+
34
+ export type BuilderApiClientOpts = {
35
+ /** Timeout for builder api requests, bid requests always use `BUILDER_BID_REQUEST_TIMEOUT_MS` */
36
+ timeout?: number;
37
+ // Add User-Agent header to all requests
38
+ userAgent?: string;
39
+ };
40
+
41
+ type BuilderUrl = string;
42
+
43
+ /** Decode the SSZ URL bytes without allowing replacement characters or unsafe header values. */
44
+ export function decodeBuilderUrl(value: Uint8Array): BuilderUrl {
45
+ let url: string;
46
+ try {
47
+ url = new TextDecoder("utf8", {fatal: true}).decode(value);
48
+ } catch {
49
+ throw Error("Builder url must be valid UTF-8");
50
+ }
51
+ if (!isValidAsciiHttpUrl(url)) {
52
+ throw Error("Invalid builder url");
53
+ }
54
+ return url;
55
+ }
56
+
57
+ export type BuilderApiBid = {
58
+ url: BuilderUrl;
59
+ entry: routes.validator.BuilderEntry;
60
+ signedBid: gloas.SignedExecutionPayloadBid;
61
+ /** Time in milliseconds from the slot start when the bid was received */
62
+ receivedMs: number;
63
+ };
64
+
65
+ /**
66
+ * External builder integration post-gloas
67
+ *
68
+ * The builder set is driven by the resolved `BuilderConfig` the validator client supplies on
69
+ * each block production request, clients are dialed on demand based on the entry `url`.
70
+ */
71
+ export class BuilderApiClient {
72
+ private readonly clients = new Map<BuilderUrl, BuilderApi>();
73
+
74
+ constructor(
75
+ private readonly opts: BuilderApiClientOpts,
76
+ private readonly config: ChainForkConfig,
77
+ private readonly clock: IClock,
78
+ private readonly bls: IBlsVerifier,
79
+ private readonly metrics: Metrics | null = null,
80
+ private readonly logger?: Logger
81
+ ) {}
82
+
83
+ /**
84
+ * Fan out bid requests to the builders named by the entries, one request per unique
85
+ * `(url, auth.message.data)` pair. Errors and empty responses (204) are logged and filtered
86
+ * out so a single unresponsive builder never fails block production.
87
+ */
88
+ async getExecutionPayloadBids(
89
+ entries: routes.validator.BuilderEntry[],
90
+ slot: Slot,
91
+ parentHash: Root,
92
+ parentRoot: Root,
93
+ proposerPubkey: BLSPubkey
94
+ ): Promise<BuilderApiBid[]> {
95
+ const seenRequests = new Set<string>();
96
+ const requests: {url: BuilderUrl; entry: routes.validator.BuilderEntry}[] = [];
97
+
98
+ for (const entry of entries) {
99
+ const urlForLog = Buffer.from(entry.url).toString("utf8");
100
+ let url: BuilderUrl;
101
+ try {
102
+ url = decodeBuilderUrl(entry.url);
103
+ } catch {
104
+ this.logger?.warn("Ignoring builder entry with invalid url", {slot, url: urlForLog});
105
+ continue;
106
+ }
107
+
108
+ const requestKey = `${url}-${toHex(entry.auth.message.data)}`;
109
+ if (seenRequests.has(requestKey)) {
110
+ continue;
111
+ }
112
+ seenRequests.add(requestKey);
113
+
114
+ // The builder rejects a mismatch, an entry naming a different slot is not used for a bid request
115
+ if (entry.auth.message.slot !== slot) {
116
+ this.logger?.warn("Ignoring builder entry with auth for different slot", {
117
+ slot,
118
+ authSlot: entry.auth.message.slot,
119
+ builder: toPrintableUrl(url),
120
+ });
121
+ continue;
122
+ }
123
+
124
+ requests.push({url, entry});
125
+ }
126
+
127
+ // Collected in arrival order so an earlier received bid wins ties during candidate ranking
128
+ const bids: BuilderApiBid[] = [];
129
+ await Promise.all(
130
+ requests.map(async ({url, entry}) => {
131
+ this.metrics?.builderApi.bidRequests.inc();
132
+ try {
133
+ const client = await this.getOrCreateClient(url, proposerPubkey, entry.auth);
134
+ const res = await client.getExecutionPayloadBid(
135
+ {
136
+ slot,
137
+ parentHash,
138
+ parentRoot,
139
+ proposerPubkey,
140
+ requestAuth: entry.auth,
141
+ dateMilliseconds: Date.now(),
142
+ timeoutMs: BUILDER_BID_DEADLINE_MS,
143
+ },
144
+ {timeoutMs: BUILDER_BID_REQUEST_TIMEOUT_MS}
145
+ );
146
+ const signedBid = res.value();
147
+ if (signedBid === undefined) {
148
+ this.logger?.debug("No bid received from builder", {slot, builder: toPrintableUrl(url)});
149
+ return;
150
+ }
151
+ this.metrics?.builderApi.bidsReceived.inc();
152
+ bids.push({url, entry, signedBid, receivedMs: this.clock.msFromSlot(slot)});
153
+ } catch (e) {
154
+ this.metrics?.builderApi.bidRequestErrors.inc();
155
+ this.logger?.warn("Failed to get bid from builder", {slot, builder: toPrintableUrl(url)}, e as Error);
156
+ }
157
+ })
158
+ );
159
+
160
+ return bids;
161
+ }
162
+
163
+ /** Forward a proposer's builder preferences to the builder at the given url */
164
+ async submitBuilderPreferences(
165
+ url: BuilderUrl,
166
+ proposerPubkey: BLSPubkey,
167
+ request: gloas.BuilderPreferencesRequest
168
+ ): Promise<void> {
169
+ try {
170
+ const client = await this.getOrCreateClient(url, proposerPubkey, request.auth);
171
+ (await client.submitBuilderPreferences({proposerPubkey, request})).assertOk();
172
+ this.metrics?.builderApi.preferencesForwarded.inc({status: "success"});
173
+ } catch (e) {
174
+ this.metrics?.builderApi.preferencesForwarded.inc({status: "error"});
175
+ throw e;
176
+ }
177
+ }
178
+
179
+ /**
180
+ * Submit the signed beacon block to the builder whose bid was included. The builder is
181
+ * then responsible for constructing and broadcasting the corresponding
182
+ * `SignedExecutionPayloadEnvelope`, no further action is required by the proposer.
183
+ */
184
+ async submitSignedBeaconBlock(
185
+ url: BuilderUrl,
186
+ signedBlock: WithOptionalBytes<SignedBeaconBlock<ForkPostGloas>>
187
+ ): Promise<void> {
188
+ const client = this.clients.get(url);
189
+ if (client === undefined) {
190
+ this.metrics?.builderApi.blockSubmissions.inc({status: "error"});
191
+ this.logger?.warn("Ignoring signed block submission to unauthenticated builder", {url});
192
+ return;
193
+ }
194
+
195
+ try {
196
+ (await client.submitSignedBeaconBlock({signedBlock}, {redirect: "manual"})).assertOk();
197
+ this.metrics?.builderApi.blockSubmissions.inc({status: "success"});
198
+ } catch (e) {
199
+ this.metrics?.builderApi.blockSubmissions.inc({status: "error"});
200
+ throw e;
201
+ }
202
+ }
203
+
204
+ private async getOrCreateClient(
205
+ url: BuilderUrl,
206
+ proposerPubkey: BLSPubkey,
207
+ auth: gloas.SignedBuilderRequestAuth
208
+ ): Promise<BuilderApi> {
209
+ if (auth.message.data.length === 0) {
210
+ throw Error("Builder request auth data must not be empty");
211
+ }
212
+
213
+ let client = this.clients.get(url);
214
+ if (client === undefined) {
215
+ const domain = computeDomain(DOMAIN_BUILDER_REQUEST_AUTH, this.config.GENESIS_FORK_VERSION, ZERO_HASH);
216
+ const signingRoot = computeSigningRoot(ssz.gloas.BuilderRequestAuth, auth.message, domain);
217
+ const signatureSet = createSingleSignatureSetFromComponents(proposerPubkey, signingRoot, auth.signature);
218
+
219
+ let isValid = false;
220
+ try {
221
+ isValid = await this.bls.verifySignatureSets([signatureSet]);
222
+ } catch {
223
+ // Malformed signatures are invalid request authentication.
224
+ }
225
+ if (!isValid) {
226
+ throw Error("Invalid builder request auth");
227
+ }
228
+
229
+ client = getClient(
230
+ {
231
+ baseUrl: url,
232
+ globalInit: {
233
+ timeoutMs: this.opts.timeout,
234
+ headers: this.opts.userAgent ? {"User-Agent": this.opts.userAgent} : undefined,
235
+ },
236
+ },
237
+ {config: this.config, metrics: this.metrics?.builderHttpClient, logger: this.logger}
238
+ );
239
+ this.clients.set(url, client);
240
+ this.logger?.debug("External builder registered", {url: toPrintableUrl(url)});
241
+ }
242
+ return client;
243
+ }
244
+ }
@@ -0,0 +1,166 @@
1
+ import {routes} from "@lodestar/api";
2
+ import {ProtoBlock} from "@lodestar/fork-choice";
3
+ import {MAX_EXECUTION_PAYMENT, PAYLOAD_BUILDER_VERSION} from "@lodestar/params";
4
+ import {
5
+ computeEpochAtSlot,
6
+ createSingleSignatureSetFromComponents,
7
+ getExecutionPayloadBidSigningRoot,
8
+ isActiveBuilder,
9
+ isGasLimitTargetCompatible,
10
+ isStatePostGloas,
11
+ } from "@lodestar/state-transition";
12
+ import {RootHex, Slot, gloas} from "@lodestar/types";
13
+ import {bigIntMin, byteArrayEquals, prettyGweiToEth, toHex, toRootHex} from "@lodestar/utils";
14
+ import {IBeaconChain} from "../../chain/index.js";
15
+ import {RegenCaller} from "../../chain/regen/index.js";
16
+ import {getShufflingDependentRoot} from "../../util/dependentRoot.js";
17
+
18
+ /** Return the counted bid payment in Gwei, saturated at uint64 max. */
19
+ export function getBuilderBidTotalGwei(bid: gloas.ExecutionPayloadBid, maxExecutionPayment: bigint): bigint {
20
+ return bigIntMin(MAX_EXECUTION_PAYMENT, BigInt(bid.value) + bigIntMin(bid.executionPayment, maxExecutionPayment));
21
+ }
22
+
23
+ /**
24
+ * Validate a bid received from a builder over the builder API in response to a bid request
25
+ * made during block production. Unlike gossip validation, the bid must match the requested
26
+ * slot and parent exactly, may carry a non-zero `executionPayment` which is counted at most at
27
+ * the entry's `maxExecutionPayment`, and is not subject to gossip anti-spam rules.
28
+ *
29
+ * Throws with a description of the failure, the caller drops the bid.
30
+ */
31
+ export async function validateBuilderApiExecutionPayloadBid(
32
+ chain: IBeaconChain,
33
+ signedExecutionPayloadBid: gloas.SignedExecutionPayloadBid,
34
+ request: {
35
+ slot: Slot;
36
+ parentBlock: ProtoBlock;
37
+ parentBlockHash: RootHex;
38
+ parentBlockRoot: RootHex;
39
+ entry: routes.validator.BuilderEntry;
40
+ }
41
+ ): Promise<void> {
42
+ const bid = signedExecutionPayloadBid.message;
43
+ const {slot, parentBlock, parentBlockHash, parentBlockRoot, entry} = request;
44
+
45
+ if (bid.slot !== slot) {
46
+ throw Error(`Bid slot=${bid.slot} does not match requested slot=${slot}`);
47
+ }
48
+
49
+ const bidParentBlockHash = toRootHex(bid.parentBlockHash);
50
+ const bidParentBlockRoot = toRootHex(bid.parentBlockRoot);
51
+ if (bidParentBlockHash !== parentBlockHash || bidParentBlockRoot !== parentBlockRoot) {
52
+ throw Error(
53
+ `Bid parent parentBlockHash=${bidParentBlockHash} parentBlockRoot=${bidParentBlockRoot} does not match ` +
54
+ `requested parentBlockHash=${parentBlockHash} parentBlockRoot=${parentBlockRoot}`
55
+ );
56
+ }
57
+
58
+ const totalPayment = getBuilderBidTotalGwei(bid, entry.maxExecutionPayment);
59
+ if (totalPayment < entry.minBid) {
60
+ throw Error(
61
+ `Bid total payment=${prettyGweiToEth(totalPayment)} ` +
62
+ `(value=${prettyGweiToEth(bid.value)} ` +
63
+ `executionPayment=${prettyGweiToEth(bid.executionPayment)}) ` +
64
+ `is below minBid=${prettyGweiToEth(entry.minBid)}`
65
+ );
66
+ }
67
+
68
+ const state = await chain.regen
69
+ .getBlockSlotState(parentBlock, slot, {dontTransferCache: true}, RegenCaller.validateGossipExecutionPayloadBid)
70
+ .catch((e: Error) => {
71
+ throw Error(`Unable to regenerate state to validate bid: ${e.message}`);
72
+ });
73
+
74
+ if (!isStatePostGloas(state)) {
75
+ throw Error(`Expected gloas+ state for execution payload bid validation, got fork=${state.forkName}`);
76
+ }
77
+
78
+ if (bid.builderIndex >= state.getBuildersLength()) {
79
+ throw Error(`Bid builderIndex=${bid.builderIndex} is out of bounds`);
80
+ }
81
+
82
+ const builder = state.getBuilder(bid.builderIndex);
83
+ if (!isActiveBuilder(builder, state.finalizedCheckpoint.epoch)) {
84
+ throw Error(`Bid builderIndex=${bid.builderIndex} is not an active builder`);
85
+ }
86
+
87
+ if (builder.version !== PAYLOAD_BUILDER_VERSION) {
88
+ throw Error(`Invalid builder version=${builder.version} expected=${PAYLOAD_BUILDER_VERSION}`);
89
+ }
90
+
91
+ // A bid not signed by one of the builder pubkeys the entry accepts bids from must not be accepted
92
+ if (
93
+ entry.builderPubkeys.length > 0 &&
94
+ !entry.builderPubkeys.some((pubkey) => byteArrayEquals(pubkey, builder.pubkey))
95
+ ) {
96
+ throw Error(
97
+ `Bid builder pubkey=${toHex(builder.pubkey)} is not in the entry's ` +
98
+ `builderPubkeys=${entry.builderPubkeys.map(toHex).join(",")}`
99
+ );
100
+ }
101
+
102
+ const blobKzgCommitmentsLen = bid.blobKzgCommitments.length;
103
+ const maxBlobsPerBlock = chain.config.getMaxBlobsPerBlock(computeEpochAtSlot(bid.slot));
104
+ if (blobKzgCommitmentsLen > maxBlobsPerBlock) {
105
+ throw Error(`Bid has too many KZG commitments len=${blobKzgCommitmentsLen} limit=${maxBlobsPerBlock}`);
106
+ }
107
+
108
+ // The coverage check only applies to the staked collateral payment, a pure execution
109
+ // layer payment bid has nothing to cover on-chain
110
+ if (bid.value > 0 && !state.canBuilderCoverBid(bid.builderIndex, bid.value)) {
111
+ throw Error(
112
+ `Builder cannot cover bid value=${prettyGweiToEth(bid.value)} ` + `balance=${prettyGweiToEth(builder.balance)}`
113
+ );
114
+ }
115
+
116
+ const randaoMix = state.getRandaoMix(computeEpochAtSlot(state.slot));
117
+ if (!byteArrayEquals(bid.prevRandao, randaoMix)) {
118
+ throw Error(`Invalid bid prevRandao=${toHex(bid.prevRandao)} expected=${toHex(randaoMix)}`);
119
+ }
120
+
121
+ // The builder must honor the proposer preferences it learned over gossip
122
+ const bidEpoch = computeEpochAtSlot(bid.slot);
123
+ const dependentRootHex = (() => {
124
+ try {
125
+ return getShufflingDependentRoot(chain.forkChoice, bidEpoch, computeEpochAtSlot(parentBlock.slot), parentBlock);
126
+ } catch {
127
+ return null;
128
+ }
129
+ })();
130
+ if (dependentRootHex === null) {
131
+ throw Error(`Unable to resolve proposer preferences dependent root for bid slot=${bid.slot}`);
132
+ }
133
+ const proposerPreferences = chain.proposerPreferencesPool.get(bid.slot, dependentRootHex);
134
+ if (proposerPreferences === null) {
135
+ throw Error(`No proposer preferences found for bid slot=${bid.slot} dependentRoot=${dependentRootHex}`);
136
+ }
137
+ if (!byteArrayEquals(bid.feeRecipient, proposerPreferences.message.feeRecipient)) {
138
+ throw Error(
139
+ `Bid feeRecipient=${toHex(bid.feeRecipient)} does not match ` +
140
+ `proposer preferences feeRecipient=${toHex(proposerPreferences.message.feeRecipient)}`
141
+ );
142
+ }
143
+
144
+ const parentPayloadVariant = chain.forkChoice.getBlockHexAndBlockHash(bidParentBlockRoot, bidParentBlockHash);
145
+ if (parentPayloadVariant === null || parentPayloadVariant.executionPayloadBlockHash === null) {
146
+ throw Error(`Unable to resolve parent payload gas limit for bid parentBlockHash=${bidParentBlockHash}`);
147
+ }
148
+ const parentGasLimit = BigInt(parentPayloadVariant.executionPayloadGasLimit);
149
+ const targetGasLimit = proposerPreferences.message.targetGasLimit;
150
+ if (!isGasLimitTargetCompatible(parentGasLimit, bid.gasLimit, targetGasLimit)) {
151
+ throw Error(
152
+ `Bid gasLimit=${bid.gasLimit} is not compatible with ` +
153
+ `parentGasLimit=${parentGasLimit} targetGasLimit=${targetGasLimit}`
154
+ );
155
+ }
156
+
157
+ const signatureSet = createSingleSignatureSetFromComponents(
158
+ builder.pubkey,
159
+ getExecutionPayloadBidSigningRoot(chain.config, bid),
160
+ signedExecutionPayloadBid.signature
161
+ );
162
+
163
+ if (!(await chain.bls.verifySignatureSets([signatureSet]))) {
164
+ throw Error(`Invalid bid signature builderIndex=${bid.builderIndex}`);
165
+ }
166
+ }