@lodestar/beacon-node 1.46.0 → 1.47.0-dev.02d2dbea03

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 (348) hide show
  1. package/lib/api/impl/beacon/blocks/index.d.ts.map +1 -1
  2. package/lib/api/impl/beacon/blocks/index.js +6 -8
  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.d.ts.map +1 -1
  15. package/lib/api/impl/lodestar/index.js +12 -13
  16. package/lib/api/impl/lodestar/index.js.map +1 -1
  17. package/lib/api/impl/validator/index.d.ts.map +1 -1
  18. package/lib/api/impl/validator/index.js +12 -22
  19. package/lib/api/impl/validator/index.js.map +1 -1
  20. package/lib/api/impl/validator/utils.d.ts +5 -0
  21. package/lib/api/impl/validator/utils.d.ts.map +1 -1
  22. package/lib/api/impl/validator/utils.js +18 -12
  23. package/lib/api/impl/validator/utils.js.map +1 -1
  24. package/lib/api/rest/base.d.ts.map +1 -1
  25. package/lib/api/rest/base.js +7 -0
  26. package/lib/api/rest/base.js.map +1 -1
  27. package/lib/chain/archiveStore/archiveStore.js +1 -1
  28. package/lib/chain/archiveStore/archiveStore.js.map +1 -1
  29. package/lib/chain/archiveStore/historicalState/metrics.d.ts.map +1 -1
  30. package/lib/chain/archiveStore/historicalState/metrics.js +21 -0
  31. package/lib/chain/archiveStore/historicalState/metrics.js.map +1 -1
  32. package/lib/chain/blocks/importBlock.d.ts.map +1 -1
  33. package/lib/chain/blocks/importBlock.js +3 -8
  34. package/lib/chain/blocks/importBlock.js.map +1 -1
  35. package/lib/chain/blocks/importExecutionPayload.d.ts +3 -2
  36. package/lib/chain/blocks/importExecutionPayload.d.ts.map +1 -1
  37. package/lib/chain/blocks/importExecutionPayload.js +12 -10
  38. package/lib/chain/blocks/importExecutionPayload.js.map +1 -1
  39. package/lib/chain/blocks/index.d.ts.map +1 -1
  40. package/lib/chain/blocks/index.js +17 -11
  41. package/lib/chain/blocks/index.js.map +1 -1
  42. package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.d.ts +2 -1
  43. package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.d.ts.map +1 -1
  44. package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.js +6 -2
  45. package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.js.map +1 -1
  46. package/lib/chain/blocks/payloadEnvelopeInput/types.d.ts +14 -5
  47. package/lib/chain/blocks/payloadEnvelopeInput/types.d.ts.map +1 -1
  48. package/lib/chain/blocks/payloadEnvelopeInput/types.js +5 -0
  49. package/lib/chain/blocks/payloadEnvelopeInput/types.js.map +1 -1
  50. package/lib/chain/blocks/verifyBlock.d.ts.map +1 -1
  51. package/lib/chain/blocks/verifyBlock.js +11 -16
  52. package/lib/chain/blocks/verifyBlock.js.map +1 -1
  53. package/lib/chain/blocks/verifyBlocksStateTransitionOnly.d.ts.map +1 -1
  54. package/lib/chain/blocks/verifyBlocksStateTransitionOnly.js +22 -12
  55. package/lib/chain/blocks/verifyBlocksStateTransitionOnly.js.map +1 -1
  56. package/lib/chain/blocks/verifyExecutionPayloadEnvelope.d.ts +2 -2
  57. package/lib/chain/blocks/verifyExecutionPayloadEnvelope.d.ts.map +1 -1
  58. package/lib/chain/blocks/verifyExecutionPayloadEnvelope.js +2 -2
  59. package/lib/chain/blocks/verifyExecutionPayloadEnvelope.js.map +1 -1
  60. package/lib/chain/bls/index.d.ts +1 -1
  61. package/lib/chain/bls/index.d.ts.map +1 -1
  62. package/lib/chain/bls/interface.d.ts +5 -5
  63. package/lib/chain/bls/interface.d.ts.map +1 -1
  64. package/lib/chain/bls/multithread/index.d.ts +5 -11
  65. package/lib/chain/bls/multithread/index.d.ts.map +1 -1
  66. package/lib/chain/bls/multithread/index.js +116 -101
  67. package/lib/chain/bls/multithread/index.js.map +1 -1
  68. package/lib/chain/bls/multithread/jobItem.d.ts +5 -19
  69. package/lib/chain/bls/multithread/jobItem.d.ts.map +1 -1
  70. package/lib/chain/bls/multithread/jobItem.js +10 -65
  71. package/lib/chain/bls/multithread/jobItem.js.map +1 -1
  72. package/lib/chain/bls/multithread/types.d.ts +29 -8
  73. package/lib/chain/bls/multithread/types.d.ts.map +1 -1
  74. package/lib/chain/bls/multithread/types.js +12 -0
  75. package/lib/chain/bls/multithread/types.js.map +1 -1
  76. package/lib/chain/bls/multithread/utils.d.ts +4 -0
  77. package/lib/chain/bls/multithread/utils.d.ts.map +1 -1
  78. package/lib/chain/bls/multithread/utils.js +10 -0
  79. package/lib/chain/bls/multithread/utils.js.map +1 -1
  80. package/lib/chain/bls/multithread/worker.js +49 -23
  81. package/lib/chain/bls/multithread/worker.js.map +1 -1
  82. package/lib/chain/bls/singleThread.d.ts +4 -10
  83. package/lib/chain/bls/singleThread.d.ts.map +1 -1
  84. package/lib/chain/bls/singleThread.js +8 -45
  85. package/lib/chain/bls/singleThread.js.map +1 -1
  86. package/lib/chain/bls/utils.d.ts +4 -4
  87. package/lib/chain/bls/utils.d.ts.map +1 -1
  88. package/lib/chain/bls/utils.js +18 -19
  89. package/lib/chain/bls/utils.js.map +1 -1
  90. package/lib/chain/builderCircuitBreaker.d.ts +6 -5
  91. package/lib/chain/builderCircuitBreaker.d.ts.map +1 -1
  92. package/lib/chain/builderCircuitBreaker.js +28 -15
  93. package/lib/chain/builderCircuitBreaker.js.map +1 -1
  94. package/lib/chain/chain.d.ts +5 -3
  95. package/lib/chain/chain.d.ts.map +1 -1
  96. package/lib/chain/chain.js +24 -8
  97. package/lib/chain/chain.js.map +1 -1
  98. package/lib/chain/errors/blockError.d.ts +2 -0
  99. package/lib/chain/errors/blockError.d.ts.map +1 -1
  100. package/lib/chain/errors/blockError.js +6 -1
  101. package/lib/chain/errors/blockError.js.map +1 -1
  102. package/lib/chain/errors/proposerPreferences.d.ts +6 -0
  103. package/lib/chain/errors/proposerPreferences.d.ts.map +1 -1
  104. package/lib/chain/errors/proposerPreferences.js +1 -0
  105. package/lib/chain/errors/proposerPreferences.js.map +1 -1
  106. package/lib/chain/interface.d.ts +4 -2
  107. package/lib/chain/interface.d.ts.map +1 -1
  108. package/lib/chain/interface.js.map +1 -1
  109. package/lib/chain/opPools/aggregatedAttestationPool.js +1 -1
  110. package/lib/chain/opPools/aggregatedAttestationPool.js.map +1 -1
  111. package/lib/chain/opPools/attestationPool.d.ts +1 -1
  112. package/lib/chain/opPools/attestationPool.d.ts.map +1 -1
  113. package/lib/chain/opPools/attestationPool.js +1 -1
  114. package/lib/chain/opPools/attestationPool.js.map +1 -1
  115. package/lib/chain/opPools/deferredVoluntaryExitPool.d.ts +16 -0
  116. package/lib/chain/opPools/deferredVoluntaryExitPool.d.ts.map +1 -0
  117. package/lib/chain/opPools/deferredVoluntaryExitPool.js +57 -0
  118. package/lib/chain/opPools/deferredVoluntaryExitPool.js.map +1 -0
  119. package/lib/chain/opPools/index.d.ts +1 -0
  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/options.d.ts +1 -3
  134. package/lib/chain/options.d.ts.map +1 -1
  135. package/lib/chain/options.js.map +1 -1
  136. package/lib/chain/prepareNextSlot.js +2 -2
  137. package/lib/chain/prepareNextSlot.js.map +1 -1
  138. package/lib/chain/produceBlock/produceBlockBody.d.ts +2 -0
  139. package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
  140. package/lib/chain/produceBlock/produceBlockBody.js +8 -3
  141. package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
  142. package/lib/chain/regen/interface.d.ts +4 -2
  143. package/lib/chain/regen/interface.d.ts.map +1 -1
  144. package/lib/chain/regen/interface.js +2 -0
  145. package/lib/chain/regen/interface.js.map +1 -1
  146. package/lib/chain/regen/queued.d.ts +2 -2
  147. package/lib/chain/regen/queued.d.ts.map +1 -1
  148. package/lib/chain/regen/queued.js +5 -5
  149. package/lib/chain/regen/queued.js.map +1 -1
  150. package/lib/chain/seenCache/seenAttesters.d.ts +9 -5
  151. package/lib/chain/seenCache/seenAttesters.d.ts.map +1 -1
  152. package/lib/chain/seenCache/seenAttesters.js +25 -4
  153. package/lib/chain/seenCache/seenAttesters.js.map +1 -1
  154. package/lib/chain/seenCache/seenBlockProposers.d.ts +5 -1
  155. package/lib/chain/seenCache/seenBlockProposers.d.ts.map +1 -1
  156. package/lib/chain/seenCache/seenBlockProposers.js +17 -7
  157. package/lib/chain/seenCache/seenBlockProposers.js.map +1 -1
  158. package/lib/chain/seenCache/seenPayloadEnvelopeInput.d.ts +28 -1
  159. package/lib/chain/seenCache/seenPayloadEnvelopeInput.d.ts.map +1 -1
  160. package/lib/chain/seenCache/seenPayloadEnvelopeInput.js +121 -13
  161. package/lib/chain/seenCache/seenPayloadEnvelopeInput.js.map +1 -1
  162. package/lib/chain/stateCache/fifoBlockStateCache.d.ts +5 -1
  163. package/lib/chain/stateCache/fifoBlockStateCache.d.ts.map +1 -1
  164. package/lib/chain/stateCache/fifoBlockStateCache.js +6 -0
  165. package/lib/chain/stateCache/fifoBlockStateCache.js.map +1 -1
  166. package/lib/chain/stateCache/persistentCheckpointsCache.d.ts +47 -5
  167. package/lib/chain/stateCache/persistentCheckpointsCache.d.ts.map +1 -1
  168. package/lib/chain/stateCache/persistentCheckpointsCache.js +117 -7
  169. package/lib/chain/stateCache/persistentCheckpointsCache.js.map +1 -1
  170. package/lib/chain/stateCache/types.d.ts +3 -3
  171. package/lib/chain/stateCache/types.d.ts.map +1 -1
  172. package/lib/chain/validation/attestation.d.ts.map +1 -1
  173. package/lib/chain/validation/attestation.js +1 -4
  174. package/lib/chain/validation/attestation.js.map +1 -1
  175. package/lib/chain/validation/attesterSlashing.d.ts.map +1 -1
  176. package/lib/chain/validation/attesterSlashing.js +1 -1
  177. package/lib/chain/validation/attesterSlashing.js.map +1 -1
  178. package/lib/chain/validation/block.d.ts.map +1 -1
  179. package/lib/chain/validation/block.js +21 -7
  180. package/lib/chain/validation/block.js.map +1 -1
  181. package/lib/chain/validation/executionPayloadBid.d.ts.map +1 -1
  182. package/lib/chain/validation/executionPayloadBid.js +1 -2
  183. package/lib/chain/validation/executionPayloadBid.js.map +1 -1
  184. package/lib/chain/validation/executionPayloadEnvelope.js +1 -1
  185. package/lib/chain/validation/executionPayloadEnvelope.js.map +1 -1
  186. package/lib/chain/validation/payloadAttestationMessage.d.ts.map +1 -1
  187. package/lib/chain/validation/payloadAttestationMessage.js +5 -14
  188. package/lib/chain/validation/payloadAttestationMessage.js.map +1 -1
  189. package/lib/chain/validation/proposerPreferences.d.ts +1 -1
  190. package/lib/chain/validation/proposerPreferences.d.ts.map +1 -1
  191. package/lib/chain/validation/proposerPreferences.js +13 -4
  192. package/lib/chain/validation/proposerPreferences.js.map +1 -1
  193. package/lib/chain/validation/proposerSlashing.js +1 -1
  194. package/lib/chain/validation/proposerSlashing.js.map +1 -1
  195. package/lib/chain/validation/voluntaryExit.d.ts +9 -1
  196. package/lib/chain/validation/voluntaryExit.d.ts.map +1 -1
  197. package/lib/chain/validation/voluntaryExit.js +46 -1
  198. package/lib/chain/validation/voluntaryExit.js.map +1 -1
  199. package/lib/execution/builder/http.d.ts +10 -7
  200. package/lib/execution/builder/http.d.ts.map +1 -1
  201. package/lib/execution/builder/http.js +11 -8
  202. package/lib/execution/builder/http.js.map +1 -1
  203. package/lib/metrics/metrics/beacon.d.ts +3 -3
  204. package/lib/metrics/metrics/beacon.d.ts.map +1 -1
  205. package/lib/metrics/metrics/beacon.js +9 -9
  206. package/lib/metrics/metrics/beacon.js.map +1 -1
  207. package/lib/metrics/metrics/lodestar.d.ts +71 -22
  208. package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
  209. package/lib/metrics/metrics/lodestar.js +126 -52
  210. package/lib/metrics/metrics/lodestar.js.map +1 -1
  211. package/lib/network/gossip/topic.d.ts +13 -0
  212. package/lib/network/gossip/topic.d.ts.map +1 -1
  213. package/lib/network/gossip/topic.js +37 -0
  214. package/lib/network/gossip/topic.js.map +1 -1
  215. package/lib/network/libp2p/index.d.ts.map +1 -1
  216. package/lib/network/libp2p/index.js +10 -2
  217. package/lib/network/libp2p/index.js.map +1 -1
  218. package/lib/network/network.d.ts.map +1 -1
  219. package/lib/network/network.js +22 -43
  220. package/lib/network/network.js.map +1 -1
  221. package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
  222. package/lib/network/processor/gossipHandlers.js +37 -6
  223. package/lib/network/processor/gossipHandlers.js.map +1 -1
  224. package/lib/network/reqresp/score.d.ts.map +1 -1
  225. package/lib/network/reqresp/score.js +5 -11
  226. package/lib/network/reqresp/score.js.map +1 -1
  227. package/lib/network/util.d.ts +0 -1
  228. package/lib/network/util.d.ts.map +1 -1
  229. package/lib/network/util.js +0 -4
  230. package/lib/network/util.js.map +1 -1
  231. package/lib/node/deferredVoluntaryExitPublisher.d.ts +15 -0
  232. package/lib/node/deferredVoluntaryExitPublisher.d.ts.map +1 -0
  233. package/lib/node/deferredVoluntaryExitPublisher.js +38 -0
  234. package/lib/node/deferredVoluntaryExitPublisher.js.map +1 -0
  235. package/lib/node/nodejs.d.ts +2 -1
  236. package/lib/node/nodejs.d.ts.map +1 -1
  237. package/lib/node/nodejs.js +2 -0
  238. package/lib/node/nodejs.js.map +1 -1
  239. package/lib/sync/range/batch.d.ts +23 -5
  240. package/lib/sync/range/batch.d.ts.map +1 -1
  241. package/lib/sync/range/batch.js +62 -23
  242. package/lib/sync/range/batch.js.map +1 -1
  243. package/lib/sync/range/chain.d.ts +2 -1
  244. package/lib/sync/range/chain.d.ts.map +1 -1
  245. package/lib/sync/range/chain.js +23 -10
  246. package/lib/sync/range/chain.js.map +1 -1
  247. package/lib/sync/range/utils/hashBlocks.d.ts +16 -4
  248. package/lib/sync/range/utils/hashBlocks.d.ts.map +1 -1
  249. package/lib/sync/range/utils/hashBlocks.js +49 -18
  250. package/lib/sync/range/utils/hashBlocks.js.map +1 -1
  251. package/lib/sync/types.d.ts +32 -0
  252. package/lib/sync/types.d.ts.map +1 -1
  253. package/lib/sync/types.js +33 -0
  254. package/lib/sync/types.js.map +1 -1
  255. package/lib/sync/unknownBlock.d.ts +9 -0
  256. package/lib/sync/unknownBlock.d.ts.map +1 -1
  257. package/lib/sync/unknownBlock.js +187 -47
  258. package/lib/sync/unknownBlock.js.map +1 -1
  259. package/lib/sync/utils/downloadByRange.d.ts.map +1 -1
  260. package/lib/sync/utils/downloadByRange.js +16 -11
  261. package/lib/sync/utils/downloadByRange.js.map +1 -1
  262. package/lib/sync/utils/downloadByRoot.d.ts.map +1 -1
  263. package/lib/sync/utils/downloadByRoot.js +3 -1
  264. package/lib/sync/utils/downloadByRoot.js.map +1 -1
  265. package/package.json +37 -37
  266. package/src/api/impl/beacon/blocks/index.ts +7 -8
  267. package/src/api/impl/beacon/pool/index.ts +27 -2
  268. package/src/api/impl/beacon/state/utils.ts +2 -1
  269. package/src/api/impl/events/index.ts +12 -4
  270. package/src/api/impl/lodestar/index.ts +12 -13
  271. package/src/api/impl/validator/index.ts +22 -27
  272. package/src/api/impl/validator/utils.ts +30 -15
  273. package/src/api/rest/base.ts +7 -0
  274. package/src/chain/archiveStore/archiveStore.ts +1 -1
  275. package/src/chain/archiveStore/historicalState/metrics.ts +22 -0
  276. package/src/chain/blocks/importBlock.ts +2 -7
  277. package/src/chain/blocks/importExecutionPayload.ts +13 -12
  278. package/src/chain/blocks/index.ts +21 -11
  279. package/src/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.ts +8 -2
  280. package/src/chain/blocks/payloadEnvelopeInput/types.ts +17 -4
  281. package/src/chain/blocks/verifyBlock.ts +21 -25
  282. package/src/chain/blocks/verifyBlocksStateTransitionOnly.ts +25 -16
  283. package/src/chain/blocks/verifyExecutionPayloadEnvelope.ts +1 -9
  284. package/src/chain/bls/index.ts +1 -1
  285. package/src/chain/bls/interface.ts +7 -3
  286. package/src/chain/bls/multithread/index.ts +148 -120
  287. package/src/chain/bls/multithread/jobItem.ts +12 -82
  288. package/src/chain/bls/multithread/types.ts +33 -8
  289. package/src/chain/bls/multithread/utils.ts +11 -0
  290. package/src/chain/bls/multithread/worker.ts +85 -27
  291. package/src/chain/bls/singleThread.ts +11 -55
  292. package/src/chain/bls/utils.ts +23 -24
  293. package/src/chain/builderCircuitBreaker.ts +31 -17
  294. package/src/chain/chain.ts +25 -7
  295. package/src/chain/errors/blockError.ts +9 -3
  296. package/src/chain/errors/proposerPreferences.ts +7 -0
  297. package/src/chain/interface.ts +4 -1
  298. package/src/chain/opPools/aggregatedAttestationPool.ts +1 -1
  299. package/src/chain/opPools/attestationPool.ts +1 -1
  300. package/src/chain/opPools/deferredVoluntaryExitPool.ts +65 -0
  301. package/src/chain/opPools/index.ts +1 -0
  302. package/src/chain/opPools/payloadAttestationPool.ts +3 -3
  303. package/src/chain/opPools/syncCommitteeMessagePool.ts +1 -1
  304. package/src/chain/opPools/syncContributionAndProofPool.ts +1 -1
  305. package/src/chain/opPools/utils.ts +1 -1
  306. package/src/chain/options.ts +1 -3
  307. package/src/chain/prepareNextSlot.ts +2 -2
  308. package/src/chain/produceBlock/produceBlockBody.ts +15 -2
  309. package/src/chain/regen/interface.ts +4 -2
  310. package/src/chain/regen/queued.ts +5 -5
  311. package/src/chain/seenCache/seenAttesters.ts +31 -5
  312. package/src/chain/seenCache/seenBlockProposers.ts +24 -7
  313. package/src/chain/seenCache/seenPayloadEnvelopeInput.ts +143 -14
  314. package/src/chain/stateCache/fifoBlockStateCache.ts +8 -1
  315. package/src/chain/stateCache/persistentCheckpointsCache.ts +133 -8
  316. package/src/chain/stateCache/types.ts +3 -3
  317. package/src/chain/validation/attestation.ts +1 -7
  318. package/src/chain/validation/attesterSlashing.ts +1 -8
  319. package/src/chain/validation/block.ts +21 -7
  320. package/src/chain/validation/executionPayloadBid.ts +1 -2
  321. package/src/chain/validation/executionPayloadEnvelope.ts +0 -1
  322. package/src/chain/validation/payloadAttestationMessage.ts +6 -17
  323. package/src/chain/validation/proposerPreferences.ts +15 -5
  324. package/src/chain/validation/proposerSlashing.ts +1 -1
  325. package/src/chain/validation/voluntaryExit.ts +59 -2
  326. package/src/execution/builder/http.ts +11 -11
  327. package/src/metrics/metrics/beacon.ts +9 -9
  328. package/src/metrics/metrics/lodestar.ts +138 -57
  329. package/src/network/gossip/topic.ts +38 -0
  330. package/src/network/libp2p/index.ts +11 -2
  331. package/src/network/network.ts +27 -55
  332. package/src/network/processor/gossipHandlers.ts +40 -4
  333. package/src/network/reqresp/score.ts +5 -11
  334. package/src/network/util.ts +0 -5
  335. package/src/node/deferredVoluntaryExitPublisher.ts +54 -0
  336. package/src/node/nodejs.ts +5 -1
  337. package/src/sync/range/batch.ts +84 -29
  338. package/src/sync/range/chain.ts +26 -11
  339. package/src/sync/range/utils/hashBlocks.ts +56 -21
  340. package/src/sync/types.ts +36 -1
  341. package/src/sync/unknownBlock.ts +212 -53
  342. package/src/sync/utils/downloadByRange.ts +21 -12
  343. package/src/sync/utils/downloadByRoot.ts +3 -1
  344. package/lib/chain/bls/maybeBatch.d.ts +0 -12
  345. package/lib/chain/bls/maybeBatch.d.ts.map +0 -1
  346. package/lib/chain/bls/maybeBatch.js +0 -35
  347. package/lib/chain/bls/maybeBatch.js.map +0 -1
  348. package/src/chain/bls/maybeBatch.ts +0 -45
@@ -14,7 +14,11 @@ import {BlockStateCache, CacheItemType, CheckpointHex, CheckpointStateCache} fro
14
14
  export type PersistentCheckpointStateCacheOpts = {
15
15
  /** Keep max n state epochs in memory, persist the rest to disk */
16
16
  maxCPStateEpochsInMemory?: number;
17
- /** Keep max n state epochs on disk */
17
+ /**
18
+ * On-disk retention of persisted checkpoint states. Selects one of two modes:
19
+ * - `Infinity` (default) -> tiered retention mode
20
+ * - any finite `n` (>= 0) -> legacy flat retention (keep the last n dense epochs)
21
+ */
18
22
  maxCPStateEpochsOnDisk?: number;
19
23
  };
20
24
 
@@ -64,6 +68,18 @@ export const DEFAULT_MAX_CP_STATE_EPOCHS_IN_MEMORY = 3;
64
68
  */
65
69
  export const DEFAULT_MAX_CP_STATE_ON_DISK = Infinity;
66
70
 
71
+ // CP_STATE_TIER_BASE = spacing multiplier per tier AND per-tier capacity. Deciding capacity == base
72
+ // so that a full tier[n] always holds exactly ONE epoch aligned to tier[n+1]
73
+ // given tier[n] has span = 16 ^ n and tier[n+1] has span = 16 ^ (n+1)
74
+ // why 16?
75
+ // - tier 0 is the dense hot-regen window; it must exceed regen's MAX_EPOCH_TO_PROCESS (=5).
76
+ // - with a full 4 tiers = 64 epochs, we can cover ~ a year of continuous non-finality, and it'll grow very slowly after that
77
+ // - tier0 spans 16 epochs ≈ 1.7h, this is more than enough to handle reorg
78
+ // - tier1 spans 256 epochs ≈ 1.1d, ie we store 16 epochs of the previous day
79
+ // - tier2 spans 4096 epochs ≈ 18d, ie we store 16 epochs of the last ~2.5 weeks
80
+ // - tier3 spans 65536ep ≈ 291d, ie we store 16 epochs of the last 0.8 year
81
+ export const CP_STATE_TIER_BASE = 16;
82
+
67
83
  // TODO GLOAS: re-evaluate this timing
68
84
  const PROCESS_CHECKPOINT_STATES_BPS = 6667;
69
85
 
@@ -112,6 +128,19 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
112
128
  private preComputedCheckpointHits: number | null = null;
113
129
  private readonly maxEpochsInMemory: number;
114
130
  private readonly maxEpochsOnDisk: number;
131
+ /**
132
+ * Persist checkpoint states (epoch + root) by tiers
133
+ *
134
+ * ╔═════════ tier 2 ══════════╦═══════ tier 1 ═══════╦═══ tier 0 (dense) ══╗
135
+ * finalizedEpoch -> ║ keep 1 epoch per 256 ║ keep 1 epoch per 16 ║ keep every epoch ║ -> head
136
+ * ║ x·······x·······x······ ║ x···x···x···x··· ║ xxxxxxxxxxxxxxxxx ║
137
+ * ╚═══════════════════════════╩══════════════════════╩═════════════════════╝
138
+ *
139
+ * starting from tier 1, all epochs must be aligned to the finalized epoch
140
+ */
141
+ private persistentTiers: Map<Epoch, Set<RootHex>>[] = [new Map()];
142
+ private finalizedEpoch: Epoch = 0;
143
+ private justifiedEpoch: Epoch = 0;
115
144
  private readonly datastore: CPStateDatastore;
116
145
  private readonly blockStateCache: BlockStateCache;
117
146
  private readonly bufferPool?: BufferPool;
@@ -152,6 +181,13 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
152
181
  metrics.cpStateCache.size.set({type: CacheItemType.inMemory}, inMemoryCount);
153
182
  metrics.cpStateCache.epochSize.set({type: CacheItemType.persisted}, persistentEpochs.size);
154
183
  metrics.cpStateCache.epochSize.set({type: CacheItemType.inMemory}, memoryEpochs.size);
184
+
185
+ for (let tier = 0; tier < this.persistentTiers.length; tier++) {
186
+ let states = 0;
187
+ for (const roots of this.persistentTiers[tier].values()) states += roots.size;
188
+ metrics.cpStateCache.persistentTierEpochs.set({tier}, this.persistentTiers[tier].size);
189
+ metrics.cpStateCache.persistentTierStates.set({tier}, states);
190
+ }
155
191
  });
156
192
  }
157
193
  this.logger = logger;
@@ -407,10 +443,77 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
407
443
  }
408
444
 
409
445
  /**
410
- * This is just to conform to the old implementation
446
+ * This is called on every checkpoint event to refresh the pinned finalized/justified epochs.
411
447
  */
412
- prune(): void {
413
- // do nothing
448
+ onCheckpoint(finalizedEpoch: Epoch, justifiedEpoch: Epoch): void {
449
+ this.finalizedEpoch = finalizedEpoch;
450
+ this.justifiedEpoch = justifiedEpoch;
451
+ }
452
+
453
+ /**
454
+ * This is called right after we persist a checkpoint state.
455
+ */
456
+ private async onPersist(epoch: Epoch, rootHex: RootHex): Promise<void> {
457
+ let roots = this.persistentTiers[0].get(epoch);
458
+ if (roots === undefined) {
459
+ roots = new Set<RootHex>();
460
+ this.persistentTiers[0].set(epoch, roots);
461
+ }
462
+ roots.add(rootHex);
463
+ await this.prunePersistentTier(0);
464
+ }
465
+
466
+ /**
467
+ * When tier `n` overflows (> CP_STATE_TIER_BASE epochs), evict its oldest epoch and either promote it to tier `n + 1` (if aligned there) or delete it.
468
+ *
469
+ * before: persistentTiers[n] = { ..., e_old }
470
+ * persistentTiers[n+1] = { ... }
471
+ *
472
+ * after, if e_old aligns to n+1: | after, if e_old does NOT align to n+1:
473
+ * persistentTiers[n] = { ... } | persistentTiers[n] = { ... }
474
+ * persistentTiers[n+1] = { ..., e_old } | e_old and all its roots deleted from disk
475
+ *
476
+ * Since pruning a tier[n] may push an item at tier[n+1], we must call the function recursively.
477
+ */
478
+ private async prunePersistentTier(tier: number): Promise<void> {
479
+ const tierMap = this.persistentTiers[tier];
480
+ while (tierMap.size > CP_STATE_TIER_BASE) {
481
+ // Evict the oldest epoch, but never the pinned justified epoch
482
+ const oldestEpoch = Math.min(...Array.from(tierMap.keys()).filter((epoch) => epoch !== this.justifiedEpoch));
483
+ const roots = tierMap.get(oldestEpoch) as Set<RootHex>;
484
+ tierMap.delete(oldestEpoch);
485
+
486
+ const rootHexes = Array.from(roots).join(",");
487
+ // `>= finalizedEpoch` guards the transient window where an epoch below the (fork-choice)
488
+ // finalized epoch has not yet been removed by pruneFinalized: its offset would be negative
489
+ // and JS `%` could spuriously report it as aligned. Such epochs are stale -> delete.
490
+ if (oldestEpoch >= this.finalizedEpoch && this.alignedForTier(oldestEpoch, tier + 1)) {
491
+ if (this.persistentTiers[tier + 1] === undefined) {
492
+ this.persistentTiers[tier + 1] = new Map<Epoch, Set<RootHex>>();
493
+ }
494
+ this.persistentTiers[tier + 1].set(oldestEpoch, roots);
495
+ this.logger.verbose("Migrated persistent checkpoint states to lower tier", {
496
+ epoch: oldestEpoch,
497
+ fromTier: tier,
498
+ toTier: tier + 1,
499
+ rootHexes,
500
+ });
501
+ await this.prunePersistentTier(tier + 1);
502
+ } else {
503
+ // the oldest epoch is not aligned to the next tier
504
+ await this.deleteAllEpochItems(oldestEpoch)
505
+ .then(() => this.logger.verbose("Pruned checkpoint states from disk", {epoch: oldestEpoch, tier, rootHexes}))
506
+ .catch((e) => this.logger.debug("Error delete all epoch items", {epoch: oldestEpoch, tier}, e as Error));
507
+ }
508
+ }
509
+ }
510
+
511
+ /**
512
+ * Starting from tier[1], it must be aligned to the finalized epoch
513
+ * ie given finalized epoch F, tier[n] only epochs of F + n*16, n = 1,2,3...
514
+ */
515
+ private alignedForTier(epoch: Epoch, tier: number): boolean {
516
+ return (epoch - this.finalizedEpoch) % CP_STATE_TIER_BASE ** tier === 0;
414
517
  }
415
518
 
416
519
  /**
@@ -598,9 +701,16 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
598
701
  return seedBlockState;
599
702
  }
600
703
 
601
- clear(): void {
602
- this.cache.clear();
603
- this.epochIndex.clear();
704
+ async clear(): Promise<void> {
705
+ // deleteAllEpochItems removes every root of an epoch from disk and clears the cache
706
+ await Promise.all(
707
+ Array.from(this.epochIndex.keys()).map((epoch) =>
708
+ this.deleteAllEpochItems(epoch).catch((e) =>
709
+ this.logger.debug("Error delete all epoch items on clear", {epoch}, e as Error)
710
+ )
711
+ )
712
+ );
713
+ this.persistentTiers = [new Map()];
604
714
  }
605
715
 
606
716
  /** ONLY FOR DEBUGGING PURPOSES. For lodestar debug API */
@@ -743,12 +853,18 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
743
853
  }
744
854
  // overwrite cpKey, this means the state is deleted from memory
745
855
  this.cache.set(cpKey, {type: CacheItemType.persisted, value: persistedKey});
856
+ if (this.isTieredMode) {
857
+ await this.onPersist(epoch, rootHex);
858
+ }
746
859
  } else {
747
860
  if (persistedKey) {
748
861
  // persisted file will be eventually deleted by the archive task
749
862
  // this also means the state is deleted from memory
750
863
  this.cache.set(cpKey, {type: CacheItemType.persisted, value: persistedKey});
751
864
  // do not update epochIndex
865
+ if (this.isTieredMode) {
866
+ await this.onPersist(epoch, rootHex);
867
+ }
752
868
  } else {
753
869
  // delete the state from memory
754
870
  this.cache.delete(cpKey);
@@ -790,6 +906,10 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
790
906
  this.cache.delete(key);
791
907
  }
792
908
  this.epochIndex.delete(epoch);
909
+ // keep the on-disk retention tiers in sync so they never drift from epochIndex
910
+ for (const tierMap of this.persistentTiers) {
911
+ tierMap.delete(epoch);
912
+ }
793
913
  this.logger.verbose("Pruned checkpoint states for epoch", {
794
914
  epoch,
795
915
  persistCount,
@@ -798,7 +918,7 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
798
918
  }
799
919
 
800
920
  /**
801
- * Prune persisted checkpoint states from disk.
921
+ * Legacy flat-window on-disk pruning, used only when a `maxEpochsOnDisk` is configured.
802
922
  * Note that this should handle all possible errors and not throw.
803
923
  */
804
924
  private prunePersistedStates(): void {
@@ -842,6 +962,11 @@ export class PersistentCheckpointStateCache implements CheckpointStateCache {
842
962
 
843
963
  return null;
844
964
  }
965
+
966
+ /** Tiered pruning is active with the default `Infinity` on-disk cap; a finite cap uses the flat path */
967
+ private get isTieredMode(): boolean {
968
+ return this.maxEpochsOnDisk === Infinity;
969
+ }
845
970
  }
846
971
 
847
972
  export function toCheckpointHex(checkpoint: phase0.Checkpoint): CheckpointHex {
@@ -29,7 +29,7 @@ export interface BlockStateCache {
29
29
  getSeedState(): IBeaconStateView;
30
30
  clear(): void;
31
31
  size: number;
32
- prune(headStateRootHex: RootHex): void;
32
+ onCheckpoint(headStateRootHex: RootHex): void;
33
33
  dumpSummary(): routes.lodestar.StateCacheItem[];
34
34
  /** Expose beacon states stored in cache. Use with caution */
35
35
  getStates(): IterableIterator<IBeaconStateView>;
@@ -65,9 +65,9 @@ export interface CheckpointStateCache {
65
65
  getLatest(rootHex: RootHex, maxEpoch: Epoch): IBeaconStateView | null;
66
66
  getOrReloadLatest(rootHex: RootHex, maxEpoch: Epoch): Promise<IBeaconStateView | null>;
67
67
  updatePreComputedCheckpoint(rootHex: RootHex, epoch: Epoch): number | null;
68
- prune(finalizedEpoch: Epoch, justifiedEpoch: Epoch): void;
68
+ onCheckpoint(finalizedEpoch: Epoch, justifiedEpoch: Epoch): void;
69
69
  processState(blockRootHex: RootHex, state: IBeaconStateView): Promise<number>;
70
- clear(): void;
70
+ clear(): Promise<void>;
71
71
  dumpSummary(): routes.lodestar.StateCacheItem[];
72
72
  /** Expose beacon states stored in cache. Use with caution */
73
73
  getStates(): IterableIterator<IBeaconStateView>;
@@ -142,13 +142,7 @@ export async function validateGossipAttestationsSameAttData(
142
142
  const batchableBls = signatureSets.length >= chain.opts.minSameMessageSignatureSetsToBatch;
143
143
  if (batchableBls) {
144
144
  // all signature sets should have same signing root since we filtered in network processor
145
- signatureValids = await chain.bls.verifySignatureSetsSameMessage(
146
- signatureSets.map((set) => {
147
- const publicKey = chain.pubkeyCache.getOrThrow(set.index);
148
- return {publicKey, signature: set.signature};
149
- }),
150
- signatureSets[0].signingRoot
151
- );
145
+ signatureValids = await chain.bls.verifySignatureSetsSameMessage(signatureSets, signatureSets[0].signingRoot);
152
146
  } else {
153
147
  // don't want to block the main thread if there are too few signatures
154
148
  signatureValids = await Promise.all(
@@ -44,14 +44,7 @@ export async function validateAttesterSlashing(
44
44
  // [REJECT] All of the conditions within process_attester_slashing pass validation.
45
45
  try {
46
46
  // verifySignature = false, verified in batch below
47
- assertValidAttesterSlashing(
48
- chain.config,
49
- chain.pubkeyCache,
50
- state.slot,
51
- state.validatorCount,
52
- attesterSlashing,
53
- false
54
- );
47
+ assertValidAttesterSlashing(chain.config, state.slot, state.validatorCount, attesterSlashing, false);
55
48
  } catch (e) {
56
49
  throw new AttesterSlashingError(GossipAction.REJECT, {
57
50
  code: AttesterSlashingErrorCode.INVALID,
@@ -89,13 +89,20 @@ export async function validateGossipBlock(
89
89
 
90
90
  // [IGNORE] The block is the first block with valid signature received for the proposer for the slot, signed_beacon_block.message.slot.
91
91
  const proposerIndex = block.proposerIndex;
92
- const hasBlockRoot = chain.seenBlockProposers.hasBlockRoot(blockSlot, proposerIndex, blockRoot);
93
92
  if (chain.seenBlockProposers.isKnown(blockSlot, proposerIndex)) {
94
- if (!hasBlockRoot && !chain.seenBlockProposers.isEquivocating(blockSlot, proposerIndex)) {
95
- await verifyBlockProposerSignature(chain, signedBlock, blockRoot, {verifyOnMainThread: false});
96
- chain.seenBlockProposers.observeBlockRoot(blockSlot, proposerIndex, blockRoot, signedBlockHeader);
93
+ if (chain.seenBlockProposers.isRepeatProposal(blockSlot, proposerIndex, blockRoot)) {
94
+ const hasBlockRoot = chain.seenBlockProposers.hasBlockRoot(blockSlot, proposerIndex, blockRoot);
95
+ if (!hasBlockRoot && !chain.seenBlockProposers.isEquivocating(blockSlot, proposerIndex)) {
96
+ await verifyBlockProposerSignature(chain, signedBlock, blockRoot, {verifyOnMainThread: false});
97
+ chain.seenBlockProposers.observeBlockRoot(blockSlot, proposerIndex, blockRoot, signedBlockHeader);
98
+ }
99
+ throw new BlockGossipError(GossipAction.IGNORE, {
100
+ code: BlockErrorCode.REPEAT_PROPOSAL,
101
+ proposerIndex,
102
+ root: blockRoot,
103
+ });
97
104
  }
98
- throw new BlockGossipError(GossipAction.IGNORE, {code: BlockErrorCode.REPEAT_PROPOSAL, proposerIndex});
105
+ throw new BlockGossipError(GossipAction.IGNORE, {code: BlockErrorCode.ALREADY_KNOWN, root: blockRoot});
99
106
  }
100
107
 
101
108
  // [REJECT] The current finalized_checkpoint is an ancestor of block -- i.e.
@@ -301,10 +308,17 @@ export async function validateGossipBlock(
301
308
 
302
309
  // Check again after all async validation and the early-block delay so concurrent proposals cannot both pass
303
310
  if (chain.seenBlockProposers.isKnown(blockSlot, proposerIndex)) {
304
- throw new BlockGossipError(GossipAction.IGNORE, {code: BlockErrorCode.REPEAT_PROPOSAL, proposerIndex});
311
+ if (chain.seenBlockProposers.isRepeatProposal(blockSlot, proposerIndex, blockRoot)) {
312
+ throw new BlockGossipError(GossipAction.IGNORE, {
313
+ code: BlockErrorCode.REPEAT_PROPOSAL,
314
+ proposerIndex,
315
+ root: blockRoot,
316
+ });
317
+ }
318
+ throw new BlockGossipError(GossipAction.IGNORE, {code: BlockErrorCode.ALREADY_KNOWN, root: blockRoot});
305
319
  }
306
320
 
307
- chain.seenBlockProposers.add(blockSlot, proposerIndex);
321
+ chain.seenBlockProposers.add(blockSlot, proposerIndex, blockRoot);
308
322
 
309
323
  return {skippedSlots};
310
324
  }
@@ -1,4 +1,3 @@
1
- import {PublicKey} from "@chainsafe/blst";
2
1
  import {IForkChoice, ProtoBlock} from "@lodestar/fork-choice";
3
2
  import {PAYLOAD_BUILDER_VERSION} from "@lodestar/params";
4
3
  import {
@@ -345,7 +344,7 @@ async function validateExecutionPayloadBid(
345
344
 
346
345
  // [REJECT] `signed_execution_payload_bid.signature` is valid with respect to the `bid.builder_index`.
347
346
  const signatureSet = createSingleSignatureSetFromComponents(
348
- PublicKey.fromBytes(builder.pubkey),
347
+ builder.pubkey,
349
348
  getExecutionPayloadBidSigningRoot(chain.config, bid),
350
349
  signedExecutionPayloadBid.signature
351
350
  );
@@ -170,7 +170,6 @@ async function validateExecutionPayloadEnvelope(
170
170
  // by `verify_execution_payload_envelope_signature`.
171
171
  const signatureSet = getExecutionPayloadEnvelopeSignatureSet(
172
172
  chain.config,
173
- chain.pubkeyCache,
174
173
  blockState,
175
174
  executionPayloadEnvelope,
176
175
  payloadInput.proposerIndex
@@ -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(
@@ -71,15 +71,18 @@ export class NoBidReceived extends Error {
71
71
  }
72
72
 
73
73
  /**
74
- * Beacon clients select randomized values from the following ranges when initializing
75
- * the circuit breaker (so at boot time and once for each unique boot).
74
+ * Default circuit breaker parameters:
76
75
  *
77
- * ALLOWED_FAULTS: between 1 and SLOTS_PER_EPOCH // 4
78
- * FAULT_INSPECTION_WINDOW: between SLOTS_PER_EPOCH and 2 * SLOTS_PER_EPOCH
76
+ * SLOTS_PER_EPOCH <= FAULT_INSPECTION_WINDOW < 2 * SLOTS_PER_EPOCH (randomized at initialization)
77
+ * ALLOWED_FAULTS: FAULT_INSPECTION_WINDOW // 4
79
78
  *
80
- * The values are randomized per node so builders cannot predict when a given proposer will
81
- * fall back to local blocks. With fixed thresholds a builder could withhold payloads right up
82
- * to the limit without ever tripping the breaker.
79
+ * e.g. on mainnet SLOTS_PER_EPOCH is 32, so FAULT_INSPECTION_WINDOW is between 32 and 63,
80
+ * and a window of 40 results in ALLOWED_FAULTS = 10.
81
+ *
82
+ * The randomized default window keeps the exact slots under inspection unpredictable per node,
83
+ * so a builder cannot tell when past faults age out of a given proposer's window and time
84
+ * withholding around trip or recovery points. Explicitly configured windows are clamped to at
85
+ * least SLOTS_PER_EPOCH, and configured allowedFaults is capped at the default ~25% budget.
83
86
  */
84
87
  export function getFaultInspectionParams(opts: {faultInspectionWindow?: number; allowedFaults?: number}): {
85
88
  faultInspectionWindow: number;
@@ -90,10 +93,7 @@ export function getFaultInspectionParams(opts: {faultInspectionWindow?: number;
90
93
  SLOTS_PER_EPOCH
91
94
  );
92
95
  // allowedFaults should be < faultInspectionWindow, limiting them to faultInspectionWindow/4
93
- const allowedFaults = Math.min(
94
- opts.allowedFaults ?? Math.floor(faultInspectionWindow / 4),
95
- Math.floor(faultInspectionWindow / 4)
96
- );
96
+ const allowedFaults = Math.min(opts.allowedFaults ?? Infinity, Math.floor(faultInspectionWindow / 4));
97
97
  return {faultInspectionWindow, allowedFaults};
98
98
  }
99
99
 
@@ -143,17 +143,17 @@ export function createBeaconMetrics(register: RegistryMetricCreator) {
143
143
  name: "beacon_builder_circuit_breaker_active",
144
144
  help: "Whether the builder circuit breaker is active (1) causing builder bids to be ignored",
145
145
  }),
146
- faults: register.gauge({
147
- name: "beacon_builder_circuit_breaker_faults",
148
- help: "Count of blocks with unrevealed payloads in the fault inspection window",
146
+ canonicalBlocks: register.gauge({
147
+ name: "beacon_builder_circuit_breaker_canonical_blocks",
148
+ help: "Count of canonical FULL and EMPTY blocks in the fault inspection window",
149
149
  }),
150
- blocksPresent: register.gauge({
151
- name: "beacon_builder_circuit_breaker_blocks_present",
152
- help: "Count of blocks present in the fault inspection window",
150
+ fullBlocks: register.gauge({
151
+ name: "beacon_builder_circuit_breaker_full_blocks",
152
+ help: "Count of canonical FULL blocks in the fault inspection window",
153
153
  }),
154
- payloadsRevealed: register.gauge({
155
- name: "beacon_builder_circuit_breaker_payloads_revealed",
156
- help: "Count of blocks with revealed payloads in the fault inspection window",
154
+ emptyBlocks: register.gauge({
155
+ name: "beacon_builder_circuit_breaker_empty_blocks",
156
+ help: "Count of canonical EMPTY blocks in the fault inspection window",
157
157
  }),
158
158
  },
159
159