@lodestar/beacon-node 1.47.0-dev.0bcaaaebb5 → 1.47.0-dev.101e2c290d

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 (332) 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.js +1 -1
  15. package/lib/api/impl/lodestar/index.js.map +1 -1
  16. package/lib/api/impl/validator/index.js +1 -1
  17. package/lib/api/impl/validator/index.js.map +1 -1
  18. package/lib/api/rest/base.d.ts.map +1 -1
  19. package/lib/api/rest/base.js +7 -0
  20. package/lib/api/rest/base.js.map +1 -1
  21. package/lib/chain/archiveStore/archiveStore.js +1 -1
  22. package/lib/chain/archiveStore/archiveStore.js.map +1 -1
  23. package/lib/chain/archiveStore/historicalState/metrics.d.ts.map +1 -1
  24. package/lib/chain/archiveStore/historicalState/metrics.js +21 -0
  25. package/lib/chain/archiveStore/historicalState/metrics.js.map +1 -1
  26. package/lib/chain/blocks/importBlock.d.ts.map +1 -1
  27. package/lib/chain/blocks/importBlock.js +2 -7
  28. package/lib/chain/blocks/importBlock.js.map +1 -1
  29. package/lib/chain/blocks/importExecutionPayload.d.ts +3 -2
  30. package/lib/chain/blocks/importExecutionPayload.d.ts.map +1 -1
  31. package/lib/chain/blocks/importExecutionPayload.js +11 -9
  32. package/lib/chain/blocks/importExecutionPayload.js.map +1 -1
  33. package/lib/chain/blocks/index.d.ts.map +1 -1
  34. package/lib/chain/blocks/index.js +14 -6
  35. package/lib/chain/blocks/index.js.map +1 -1
  36. package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.d.ts +2 -1
  37. package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.d.ts.map +1 -1
  38. package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.js +6 -2
  39. package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.js.map +1 -1
  40. package/lib/chain/blocks/payloadEnvelopeInput/types.d.ts +14 -5
  41. package/lib/chain/blocks/payloadEnvelopeInput/types.d.ts.map +1 -1
  42. package/lib/chain/blocks/payloadEnvelopeInput/types.js +5 -0
  43. package/lib/chain/blocks/payloadEnvelopeInput/types.js.map +1 -1
  44. package/lib/chain/blocks/verifyBlocksStateTransitionOnly.d.ts.map +1 -1
  45. package/lib/chain/blocks/verifyBlocksStateTransitionOnly.js +22 -12
  46. package/lib/chain/blocks/verifyBlocksStateTransitionOnly.js.map +1 -1
  47. package/lib/chain/blocks/verifyExecutionPayloadEnvelope.d.ts +2 -2
  48. package/lib/chain/blocks/verifyExecutionPayloadEnvelope.d.ts.map +1 -1
  49. package/lib/chain/blocks/verifyExecutionPayloadEnvelope.js +2 -2
  50. package/lib/chain/blocks/verifyExecutionPayloadEnvelope.js.map +1 -1
  51. package/lib/chain/bls/index.d.ts +1 -1
  52. package/lib/chain/bls/index.d.ts.map +1 -1
  53. package/lib/chain/bls/interface.d.ts +5 -5
  54. package/lib/chain/bls/interface.d.ts.map +1 -1
  55. package/lib/chain/bls/multithread/index.d.ts +5 -11
  56. package/lib/chain/bls/multithread/index.d.ts.map +1 -1
  57. package/lib/chain/bls/multithread/index.js +116 -101
  58. package/lib/chain/bls/multithread/index.js.map +1 -1
  59. package/lib/chain/bls/multithread/jobItem.d.ts +5 -19
  60. package/lib/chain/bls/multithread/jobItem.d.ts.map +1 -1
  61. package/lib/chain/bls/multithread/jobItem.js +10 -65
  62. package/lib/chain/bls/multithread/jobItem.js.map +1 -1
  63. package/lib/chain/bls/multithread/types.d.ts +29 -8
  64. package/lib/chain/bls/multithread/types.d.ts.map +1 -1
  65. package/lib/chain/bls/multithread/types.js +12 -0
  66. package/lib/chain/bls/multithread/types.js.map +1 -1
  67. package/lib/chain/bls/multithread/utils.d.ts +4 -0
  68. package/lib/chain/bls/multithread/utils.d.ts.map +1 -1
  69. package/lib/chain/bls/multithread/utils.js +10 -0
  70. package/lib/chain/bls/multithread/utils.js.map +1 -1
  71. package/lib/chain/bls/multithread/worker.js +49 -23
  72. package/lib/chain/bls/multithread/worker.js.map +1 -1
  73. package/lib/chain/bls/singleThread.d.ts +4 -10
  74. package/lib/chain/bls/singleThread.d.ts.map +1 -1
  75. package/lib/chain/bls/singleThread.js +8 -45
  76. package/lib/chain/bls/singleThread.js.map +1 -1
  77. package/lib/chain/bls/utils.d.ts +4 -4
  78. package/lib/chain/bls/utils.d.ts.map +1 -1
  79. package/lib/chain/bls/utils.js +18 -19
  80. package/lib/chain/bls/utils.js.map +1 -1
  81. package/lib/chain/builderCircuitBreaker.d.ts +6 -5
  82. package/lib/chain/builderCircuitBreaker.d.ts.map +1 -1
  83. package/lib/chain/builderCircuitBreaker.js +28 -15
  84. package/lib/chain/builderCircuitBreaker.js.map +1 -1
  85. package/lib/chain/chain.d.ts +4 -2
  86. package/lib/chain/chain.d.ts.map +1 -1
  87. package/lib/chain/chain.js +16 -6
  88. package/lib/chain/chain.js.map +1 -1
  89. package/lib/chain/errors/blockError.d.ts +1 -0
  90. package/lib/chain/errors/blockError.d.ts.map +1 -1
  91. package/lib/chain/errors/blockError.js +6 -1
  92. package/lib/chain/errors/blockError.js.map +1 -1
  93. package/lib/chain/errors/proposerPreferences.d.ts +6 -0
  94. package/lib/chain/errors/proposerPreferences.d.ts.map +1 -1
  95. package/lib/chain/errors/proposerPreferences.js +1 -0
  96. package/lib/chain/errors/proposerPreferences.js.map +1 -1
  97. package/lib/chain/forkChoice/index.d.ts.map +1 -1
  98. package/lib/chain/forkChoice/index.js +4 -0
  99. package/lib/chain/forkChoice/index.js.map +1 -1
  100. package/lib/chain/interface.d.ts +4 -2
  101. package/lib/chain/interface.d.ts.map +1 -1
  102. package/lib/chain/interface.js.map +1 -1
  103. package/lib/chain/opPools/aggregatedAttestationPool.js +1 -1
  104. package/lib/chain/opPools/aggregatedAttestationPool.js.map +1 -1
  105. package/lib/chain/opPools/attestationPool.d.ts +1 -1
  106. package/lib/chain/opPools/attestationPool.d.ts.map +1 -1
  107. package/lib/chain/opPools/attestationPool.js +1 -1
  108. package/lib/chain/opPools/attestationPool.js.map +1 -1
  109. package/lib/chain/opPools/deferredVoluntaryExitPool.d.ts +16 -0
  110. package/lib/chain/opPools/deferredVoluntaryExitPool.d.ts.map +1 -0
  111. package/lib/chain/opPools/deferredVoluntaryExitPool.js +57 -0
  112. package/lib/chain/opPools/deferredVoluntaryExitPool.js.map +1 -0
  113. package/lib/chain/opPools/index.d.ts +1 -0
  114. package/lib/chain/opPools/index.d.ts.map +1 -1
  115. package/lib/chain/opPools/index.js +1 -0
  116. package/lib/chain/opPools/index.js.map +1 -1
  117. package/lib/chain/opPools/payloadAttestationPool.js +3 -3
  118. package/lib/chain/opPools/payloadAttestationPool.js.map +1 -1
  119. package/lib/chain/opPools/syncCommitteeMessagePool.js +1 -1
  120. package/lib/chain/opPools/syncCommitteeMessagePool.js.map +1 -1
  121. package/lib/chain/opPools/syncContributionAndProofPool.js +1 -1
  122. package/lib/chain/opPools/syncContributionAndProofPool.js.map +1 -1
  123. package/lib/chain/opPools/utils.d.ts +1 -1
  124. package/lib/chain/opPools/utils.d.ts.map +1 -1
  125. package/lib/chain/opPools/utils.js +1 -1
  126. package/lib/chain/opPools/utils.js.map +1 -1
  127. package/lib/chain/options.d.ts +1 -1
  128. package/lib/chain/options.d.ts.map +1 -1
  129. package/lib/chain/prepareNextSlot.d.ts.map +1 -1
  130. package/lib/chain/prepareNextSlot.js +24 -6
  131. package/lib/chain/prepareNextSlot.js.map +1 -1
  132. package/lib/chain/regen/interface.d.ts +4 -2
  133. package/lib/chain/regen/interface.d.ts.map +1 -1
  134. package/lib/chain/regen/interface.js +2 -0
  135. package/lib/chain/regen/interface.js.map +1 -1
  136. package/lib/chain/regen/queued.d.ts +2 -2
  137. package/lib/chain/regen/queued.d.ts.map +1 -1
  138. package/lib/chain/regen/queued.js +5 -5
  139. package/lib/chain/regen/queued.js.map +1 -1
  140. package/lib/chain/seenCache/seenAttesters.d.ts +9 -5
  141. package/lib/chain/seenCache/seenAttesters.d.ts.map +1 -1
  142. package/lib/chain/seenCache/seenAttesters.js +25 -4
  143. package/lib/chain/seenCache/seenAttesters.js.map +1 -1
  144. package/lib/chain/seenCache/seenPayloadEnvelopeInput.d.ts +28 -1
  145. package/lib/chain/seenCache/seenPayloadEnvelopeInput.d.ts.map +1 -1
  146. package/lib/chain/seenCache/seenPayloadEnvelopeInput.js +121 -13
  147. package/lib/chain/seenCache/seenPayloadEnvelopeInput.js.map +1 -1
  148. package/lib/chain/stateCache/fifoBlockStateCache.d.ts +5 -1
  149. package/lib/chain/stateCache/fifoBlockStateCache.d.ts.map +1 -1
  150. package/lib/chain/stateCache/fifoBlockStateCache.js +6 -0
  151. package/lib/chain/stateCache/fifoBlockStateCache.js.map +1 -1
  152. package/lib/chain/stateCache/persistentCheckpointsCache.d.ts +47 -5
  153. package/lib/chain/stateCache/persistentCheckpointsCache.d.ts.map +1 -1
  154. package/lib/chain/stateCache/persistentCheckpointsCache.js +117 -7
  155. package/lib/chain/stateCache/persistentCheckpointsCache.js.map +1 -1
  156. package/lib/chain/stateCache/types.d.ts +3 -3
  157. package/lib/chain/stateCache/types.d.ts.map +1 -1
  158. package/lib/chain/validation/attestation.d.ts.map +1 -1
  159. package/lib/chain/validation/attestation.js +1 -4
  160. package/lib/chain/validation/attestation.js.map +1 -1
  161. package/lib/chain/validation/attesterSlashing.d.ts.map +1 -1
  162. package/lib/chain/validation/attesterSlashing.js +1 -1
  163. package/lib/chain/validation/attesterSlashing.js.map +1 -1
  164. package/lib/chain/validation/executionPayloadBid.d.ts.map +1 -1
  165. package/lib/chain/validation/executionPayloadBid.js +1 -2
  166. package/lib/chain/validation/executionPayloadBid.js.map +1 -1
  167. package/lib/chain/validation/executionPayloadEnvelope.js +1 -1
  168. package/lib/chain/validation/executionPayloadEnvelope.js.map +1 -1
  169. package/lib/chain/validation/payloadAttestationMessage.d.ts.map +1 -1
  170. package/lib/chain/validation/payloadAttestationMessage.js +5 -14
  171. package/lib/chain/validation/payloadAttestationMessage.js.map +1 -1
  172. package/lib/chain/validation/proposerPreferences.d.ts +1 -1
  173. package/lib/chain/validation/proposerPreferences.d.ts.map +1 -1
  174. package/lib/chain/validation/proposerPreferences.js +13 -4
  175. package/lib/chain/validation/proposerPreferences.js.map +1 -1
  176. package/lib/chain/validation/proposerSlashing.js +1 -1
  177. package/lib/chain/validation/proposerSlashing.js.map +1 -1
  178. package/lib/chain/validation/voluntaryExit.d.ts +9 -1
  179. package/lib/chain/validation/voluntaryExit.d.ts.map +1 -1
  180. package/lib/chain/validation/voluntaryExit.js +46 -1
  181. package/lib/chain/validation/voluntaryExit.js.map +1 -1
  182. package/lib/execution/builder/http.d.ts +10 -7
  183. package/lib/execution/builder/http.d.ts.map +1 -1
  184. package/lib/execution/builder/http.js +11 -8
  185. package/lib/execution/builder/http.js.map +1 -1
  186. package/lib/metrics/metrics/beacon.d.ts +3 -3
  187. package/lib/metrics/metrics/beacon.d.ts.map +1 -1
  188. package/lib/metrics/metrics/beacon.js +9 -9
  189. package/lib/metrics/metrics/beacon.js.map +1 -1
  190. package/lib/metrics/metrics/lodestar.d.ts +72 -22
  191. package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
  192. package/lib/metrics/metrics/lodestar.js +130 -52
  193. package/lib/metrics/metrics/lodestar.js.map +1 -1
  194. package/lib/network/gossip/topic.d.ts +13 -0
  195. package/lib/network/gossip/topic.d.ts.map +1 -1
  196. package/lib/network/gossip/topic.js +37 -0
  197. package/lib/network/gossip/topic.js.map +1 -1
  198. package/lib/network/libp2p/index.d.ts.map +1 -1
  199. package/lib/network/libp2p/index.js +10 -2
  200. package/lib/network/libp2p/index.js.map +1 -1
  201. package/lib/network/network.d.ts.map +1 -1
  202. package/lib/network/network.js +22 -43
  203. package/lib/network/network.js.map +1 -1
  204. package/lib/network/processor/constants.d.ts +7 -0
  205. package/lib/network/processor/constants.d.ts.map +1 -0
  206. package/lib/network/processor/constants.js +7 -0
  207. package/lib/network/processor/constants.js.map +1 -0
  208. package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
  209. package/lib/network/processor/gossipHandlers.js +12 -3
  210. package/lib/network/processor/gossipHandlers.js.map +1 -1
  211. package/lib/network/processor/index.d.ts +3 -0
  212. package/lib/network/processor/index.d.ts.map +1 -1
  213. package/lib/network/processor/index.js +36 -15
  214. package/lib/network/processor/index.js.map +1 -1
  215. package/lib/network/reqresp/score.d.ts.map +1 -1
  216. package/lib/network/reqresp/score.js +5 -11
  217. package/lib/network/reqresp/score.js.map +1 -1
  218. package/lib/network/util.d.ts +0 -1
  219. package/lib/network/util.d.ts.map +1 -1
  220. package/lib/network/util.js +0 -4
  221. package/lib/network/util.js.map +1 -1
  222. package/lib/node/deferredVoluntaryExitPublisher.d.ts +15 -0
  223. package/lib/node/deferredVoluntaryExitPublisher.d.ts.map +1 -0
  224. package/lib/node/deferredVoluntaryExitPublisher.js +38 -0
  225. package/lib/node/deferredVoluntaryExitPublisher.js.map +1 -0
  226. package/lib/node/nodejs.d.ts +2 -1
  227. package/lib/node/nodejs.d.ts.map +1 -1
  228. package/lib/node/nodejs.js +2 -0
  229. package/lib/node/nodejs.js.map +1 -1
  230. package/lib/sync/range/batch.d.ts +23 -5
  231. package/lib/sync/range/batch.d.ts.map +1 -1
  232. package/lib/sync/range/batch.js +61 -22
  233. package/lib/sync/range/batch.js.map +1 -1
  234. package/lib/sync/range/chain.d.ts +2 -1
  235. package/lib/sync/range/chain.d.ts.map +1 -1
  236. package/lib/sync/range/chain.js +23 -10
  237. package/lib/sync/range/chain.js.map +1 -1
  238. package/lib/sync/types.d.ts +32 -0
  239. package/lib/sync/types.d.ts.map +1 -1
  240. package/lib/sync/types.js +33 -0
  241. package/lib/sync/types.js.map +1 -1
  242. package/lib/sync/unknownBlock.d.ts +13 -2
  243. package/lib/sync/unknownBlock.d.ts.map +1 -1
  244. package/lib/sync/unknownBlock.js +218 -63
  245. package/lib/sync/unknownBlock.js.map +1 -1
  246. package/lib/sync/utils/downloadByRange.d.ts.map +1 -1
  247. package/lib/sync/utils/downloadByRange.js +16 -11
  248. package/lib/sync/utils/downloadByRange.js.map +1 -1
  249. package/lib/sync/utils/downloadByRoot.d.ts.map +1 -1
  250. package/lib/sync/utils/downloadByRoot.js +3 -1
  251. package/lib/sync/utils/downloadByRoot.js.map +1 -1
  252. package/package.json +35 -35
  253. package/src/api/impl/beacon/blocks/index.ts +7 -8
  254. package/src/api/impl/beacon/pool/index.ts +27 -2
  255. package/src/api/impl/beacon/state/utils.ts +2 -1
  256. package/src/api/impl/events/index.ts +12 -4
  257. package/src/api/impl/lodestar/index.ts +1 -1
  258. package/src/api/impl/validator/index.ts +1 -1
  259. package/src/api/rest/base.ts +7 -0
  260. package/src/chain/archiveStore/archiveStore.ts +1 -1
  261. package/src/chain/archiveStore/historicalState/metrics.ts +22 -0
  262. package/src/chain/blocks/importBlock.ts +1 -6
  263. package/src/chain/blocks/importExecutionPayload.ts +12 -11
  264. package/src/chain/blocks/index.ts +18 -6
  265. package/src/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.ts +8 -2
  266. package/src/chain/blocks/payloadEnvelopeInput/types.ts +17 -4
  267. package/src/chain/blocks/verifyBlocksStateTransitionOnly.ts +25 -16
  268. package/src/chain/blocks/verifyExecutionPayloadEnvelope.ts +1 -9
  269. package/src/chain/bls/index.ts +1 -1
  270. package/src/chain/bls/interface.ts +7 -3
  271. package/src/chain/bls/multithread/index.ts +148 -120
  272. package/src/chain/bls/multithread/jobItem.ts +12 -82
  273. package/src/chain/bls/multithread/types.ts +33 -8
  274. package/src/chain/bls/multithread/utils.ts +11 -0
  275. package/src/chain/bls/multithread/worker.ts +85 -27
  276. package/src/chain/bls/singleThread.ts +11 -55
  277. package/src/chain/bls/utils.ts +23 -24
  278. package/src/chain/builderCircuitBreaker.ts +31 -17
  279. package/src/chain/chain.ts +17 -6
  280. package/src/chain/errors/blockError.ts +8 -2
  281. package/src/chain/errors/proposerPreferences.ts +7 -0
  282. package/src/chain/forkChoice/index.ts +4 -0
  283. package/src/chain/interface.ts +4 -1
  284. package/src/chain/opPools/aggregatedAttestationPool.ts +1 -1
  285. package/src/chain/opPools/attestationPool.ts +1 -1
  286. package/src/chain/opPools/deferredVoluntaryExitPool.ts +65 -0
  287. package/src/chain/opPools/index.ts +1 -0
  288. package/src/chain/opPools/payloadAttestationPool.ts +3 -3
  289. package/src/chain/opPools/syncCommitteeMessagePool.ts +1 -1
  290. package/src/chain/opPools/syncContributionAndProofPool.ts +1 -1
  291. package/src/chain/opPools/utils.ts +1 -1
  292. package/src/chain/options.ts +1 -1
  293. package/src/chain/prepareNextSlot.ts +24 -6
  294. package/src/chain/regen/interface.ts +4 -2
  295. package/src/chain/regen/queued.ts +5 -5
  296. package/src/chain/seenCache/seenAttesters.ts +31 -5
  297. package/src/chain/seenCache/seenPayloadEnvelopeInput.ts +143 -14
  298. package/src/chain/stateCache/fifoBlockStateCache.ts +8 -1
  299. package/src/chain/stateCache/persistentCheckpointsCache.ts +133 -8
  300. package/src/chain/stateCache/types.ts +3 -3
  301. package/src/chain/validation/attestation.ts +1 -7
  302. package/src/chain/validation/attesterSlashing.ts +1 -8
  303. package/src/chain/validation/executionPayloadBid.ts +1 -2
  304. package/src/chain/validation/executionPayloadEnvelope.ts +0 -1
  305. package/src/chain/validation/payloadAttestationMessage.ts +6 -17
  306. package/src/chain/validation/proposerPreferences.ts +15 -5
  307. package/src/chain/validation/proposerSlashing.ts +1 -1
  308. package/src/chain/validation/voluntaryExit.ts +59 -2
  309. package/src/execution/builder/http.ts +11 -11
  310. package/src/metrics/metrics/beacon.ts +9 -9
  311. package/src/metrics/metrics/lodestar.ts +142 -57
  312. package/src/network/gossip/topic.ts +38 -0
  313. package/src/network/libp2p/index.ts +11 -2
  314. package/src/network/network.ts +27 -55
  315. package/src/network/processor/constants.ts +6 -0
  316. package/src/network/processor/gossipHandlers.ts +14 -1
  317. package/src/network/processor/index.ts +42 -19
  318. package/src/network/reqresp/score.ts +5 -11
  319. package/src/network/util.ts +0 -5
  320. package/src/node/deferredVoluntaryExitPublisher.ts +54 -0
  321. package/src/node/nodejs.ts +5 -1
  322. package/src/sync/range/batch.ts +83 -28
  323. package/src/sync/range/chain.ts +26 -11
  324. package/src/sync/types.ts +36 -1
  325. package/src/sync/unknownBlock.ts +255 -70
  326. package/src/sync/utils/downloadByRange.ts +21 -12
  327. package/src/sync/utils/downloadByRoot.ts +3 -1
  328. package/lib/chain/bls/maybeBatch.d.ts +0 -12
  329. package/lib/chain/bls/maybeBatch.d.ts.map +0 -1
  330. package/lib/chain/bls/maybeBatch.js +0 -35
  331. package/lib/chain/bls/maybeBatch.js.map +0 -1
  332. package/src/chain/bls/maybeBatch.ts +0 -45
@@ -1,5 +1,6 @@
1
1
  import path from "node:path";
2
2
  import {PrivateKey} from "@libp2p/interface";
3
+ import {type PubkeyCache} from "@chainsafe/lodestar-z/pubkeys";
3
4
  import {Type} from "@chainsafe/ssz";
4
5
  import {routes} from "@lodestar/api";
5
6
  import {BeaconConfig} from "@lodestar/config";
@@ -25,7 +26,6 @@ import {
25
26
  EffectiveBalanceIncrements,
26
27
  EpochShuffling,
27
28
  IBeaconStateView,
28
- PubkeyCache,
29
29
  computeEndSlotAtEpoch,
30
30
  computeEpochAtSlot,
31
31
  computeStartSlotAtEpoch,
@@ -79,6 +79,7 @@ import {CheckpointBalancesCache} from "./balancesCache.js";
79
79
  import {BeaconProposerCache} from "./beaconProposerCache.js";
80
80
  import {IBlockInput, isBlockInputBlobs, isBlockInputColumns} from "./blocks/blockInput/index.js";
81
81
  import {BlockProcessor, ImportBlockOpts} from "./blocks/index.js";
82
+ import {PayloadEnvelopeInputSource} from "./blocks/payloadEnvelopeInput/index.js";
82
83
  import {PayloadEnvelopeProcessor} from "./blocks/payloadEnvelopeProcessor.js";
83
84
  import {ImportPayloadOpts} from "./blocks/types.js";
84
85
  import {persistBlockInput} from "./blocks/writeBlockInputToDb.js";
@@ -94,6 +95,7 @@ import {LightClientServer} from "./lightClient/index.js";
94
95
  import {
95
96
  AggregatedAttestationPool,
96
97
  AttestationPool,
98
+ DeferredVoluntaryExitPool,
97
99
  ExecutionPayloadBidPool,
98
100
  OpPool,
99
101
  PayloadAttestationPool,
@@ -193,6 +195,7 @@ export class BeaconChain implements IBeaconChain {
193
195
  readonly payloadAttestationPool: PayloadAttestationPool;
194
196
  readonly proposerPreferencesPool = new ProposerPreferencesPool();
195
197
  readonly opPool: OpPool;
198
+ readonly deferredVoluntaryExitPool: DeferredVoluntaryExitPool;
196
199
 
197
200
  // Gossip seen cache
198
201
  readonly seenAttesters = new SeenAttesters();
@@ -307,8 +310,8 @@ export class BeaconChain implements IBeaconChain {
307
310
  const emitter = new ChainEventEmitter();
308
311
  // by default, verify signatures on both main threads and worker threads
309
312
  const bls = opts.blsVerifyAllMainThread
310
- ? new BlsSingleThreadVerifier({metrics, pubkeyCache})
311
- : new BlsMultiThreadWorkerPool(opts, {logger, metrics, pubkeyCache});
313
+ ? new BlsSingleThreadVerifier({metrics})
314
+ : new BlsMultiThreadWorkerPool(opts, {logger, metrics});
312
315
 
313
316
  if (!clock) clock = new Clock({config, genesisTime: this.genesisTime, signal});
314
317
 
@@ -320,6 +323,7 @@ export class BeaconChain implements IBeaconChain {
320
323
  this.executionPayloadBidPool = new ExecutionPayloadBidPool();
321
324
  this.payloadAttestationPool = new PayloadAttestationPool(config, clock, metrics);
322
325
  this.opPool = new OpPool(config);
326
+ this.deferredVoluntaryExitPool = new DeferredVoluntaryExitPool(logger);
323
327
 
324
328
  this.seenAggregatedAttestations = new SeenAggregatedAttestations(metrics);
325
329
  this.seenContributionAndProof = new SeenContributionAndProof(metrics);
@@ -451,6 +455,9 @@ export class BeaconChain implements IBeaconChain {
451
455
  chainEvents: emitter,
452
456
  signal,
453
457
  serializedCache: this.serializedCache,
458
+ db,
459
+ seenBlockInputCache: this.seenBlockInputCache,
460
+ custodyConfig: this.custodyConfig,
454
461
  metrics,
455
462
  logger,
456
463
  });
@@ -466,7 +473,8 @@ export class BeaconChain implements IBeaconChain {
466
473
  bid: anchorBid,
467
474
  sampledColumns: this.custodyConfig.sampledColumns,
468
475
  custodyColumns: this.custodyConfig.custodyColumns,
469
- timeCreatedSec: Math.floor(Date.now() / 1000),
476
+ seenTimestampSec: Date.now() / 1000,
477
+ source: PayloadEnvelopeInputSource.anchorState,
470
478
  });
471
479
  }
472
480
 
@@ -579,7 +587,7 @@ export class BeaconChain implements IBeaconChain {
579
587
  // seenAggregators = single aggregator index, not participants of the aggregate
580
588
  this.seenAggregators.isKnown(epoch, index) ||
581
589
  // seenPayloadAttesters = single signer of payload attestation message
582
- this.seenPayloadAttesters.isKnown(epoch, index) ||
590
+ this.seenPayloadAttesters.seenAtEpoch(epoch, index) ||
583
591
  // seenBlockProposers = single block proposer
584
592
  this.seenBlockProposers.seenAtEpoch(epoch, index)
585
593
  );
@@ -1090,7 +1098,7 @@ export class BeaconChain implements IBeaconChain {
1090
1098
  RegenCaller.produceBlock
1091
1099
  );
1092
1100
  const proposerIndex = state.getBeaconProposer(slot);
1093
- const proposerPubKey = this.pubkeyCache.getOrThrow(proposerIndex).toBytes();
1101
+ const proposerPubKey = this.pubkeyCache.getPubkeyBytesOrThrow(proposerIndex);
1094
1102
 
1095
1103
  const {body, produceResult, executionPayloadValue, shouldOverrideBuilder} = await produceBlockBody.call(
1096
1104
  this,
@@ -1569,6 +1577,7 @@ export class BeaconChain implements IBeaconChain {
1569
1577
  // aggregatedAttestationPool tracks metrics on its own
1570
1578
  metrics.opPool.attestationPool.size.set(this.attestationPool.getAttestationCount());
1571
1579
  metrics.opPool.attesterSlashingPoolSize.set(this.opPool.attesterSlashingsSize);
1580
+ metrics.opPool.deferredVoluntaryExitPool.size.set(this.deferredVoluntaryExitPool.size());
1572
1581
  metrics.opPool.proposerSlashingPoolSize.set(this.opPool.proposerSlashingsSize);
1573
1582
  metrics.opPool.voluntaryExitPoolSize.set(this.opPool.voluntaryExitsSize);
1574
1583
  metrics.opPool.syncCommitteeMessagePoolSize.set(this.syncCommitteeMessagePool.size);
@@ -1577,6 +1586,8 @@ export class BeaconChain implements IBeaconChain {
1577
1586
  // syncContributionAndProofPool tracks metrics on its own
1578
1587
  metrics.opPool.blsToExecutionChangePoolSize.set(this.opPool.blsToExecutionChangeSize);
1579
1588
  metrics.chain.blacklistedBlocks.set(this.blacklistedBlocks.size);
1589
+ metrics.bls.pubkeyCacheSize.set(this.pubkeyCache.size);
1590
+ metrics.bls.pubkeyCacheCapacity.set(this.pubkeyCache.capacity);
1580
1591
 
1581
1592
  const headState = this.getHeadState();
1582
1593
  if (isStatePostElectra(headState)) {
@@ -136,7 +136,7 @@ export type BlockErrorType =
136
136
  | {code: BlockErrorCode.NON_LINEAR_PARENT_ROOTS}
137
137
  | {code: BlockErrorCode.NON_LINEAR_SLOTS}
138
138
  | {code: BlockErrorCode.ENVELOPE_BLOCK_ROOT_MISMATCH; envelopeBlockRoot: RootHex; blockRoot: RootHex}
139
- | {code: BlockErrorCode.PER_BLOCK_PROCESSING_ERROR; error: Error}
139
+ | {code: BlockErrorCode.PER_BLOCK_PROCESSING_ERROR; blockRoot: RootHex; error: Error}
140
140
  | {code: BlockErrorCode.BEACON_CHAIN_ERROR; error: Error}
141
141
  | {code: BlockErrorCode.KNOWN_BAD_BLOCK}
142
142
  | {code: BlockErrorCode.BLACKLISTED_BLOCK}
@@ -184,13 +184,19 @@ export function isBlockErrorAborted(e: unknown): e is BlockError {
184
184
  export function renderBlockErrorType(type: BlockErrorType): Record<string, string | number | null> {
185
185
  switch (type.code) {
186
186
  case BlockErrorCode.PRESTATE_MISSING:
187
- case BlockErrorCode.PER_BLOCK_PROCESSING_ERROR:
188
187
  case BlockErrorCode.BEACON_CHAIN_ERROR:
189
188
  return {
190
189
  code: type.code,
191
190
  error: type.error.message,
192
191
  };
193
192
 
193
+ case BlockErrorCode.PER_BLOCK_PROCESSING_ERROR:
194
+ return {
195
+ code: type.code,
196
+ blockRoot: type.blockRoot,
197
+ error: type.error.message,
198
+ };
199
+
194
200
  case BlockErrorCode.INVALID_SIGNATURE:
195
201
  return {
196
202
  code: type.code,
@@ -1,7 +1,9 @@
1
+ import {ForkName} from "@lodestar/params";
1
2
  import {Epoch, RootHex, Slot, ValidatorIndex} from "@lodestar/types";
2
3
  import {GossipActionError} from "./gossipValidation.js";
3
4
 
4
5
  export enum ProposerPreferencesErrorCode {
6
+ PRE_GLOAS_PROPOSAL_SLOT = "PROPOSER_PREFERENCES_ERROR_PRE_GLOAS_PROPOSAL_SLOT",
5
7
  INVALID_EPOCH = "PROPOSER_PREFERENCES_ERROR_INVALID_EPOCH",
6
8
  PROPOSAL_SLOT_PASSED = "PROPOSER_PREFERENCES_ERROR_PROPOSAL_SLOT_PASSED",
7
9
  UNKNOWN_DEPENDENT_ROOT = "PROPOSER_PREFERENCES_ERROR_UNKNOWN_DEPENDENT_ROOT",
@@ -13,6 +15,11 @@ export enum ProposerPreferencesErrorCode {
13
15
  }
14
16
 
15
17
  export type ProposerPreferencesErrorType =
18
+ | {
19
+ code: ProposerPreferencesErrorCode.PRE_GLOAS_PROPOSAL_SLOT;
20
+ proposalSlot: Slot;
21
+ proposalFork: ForkName;
22
+ }
16
23
  | {
17
24
  code: ProposerPreferencesErrorCode.INVALID_EPOCH;
18
25
  proposalSlot: Slot;
@@ -134,6 +134,8 @@ export function initializeForkChoiceFromFinalizedState(
134
134
  stateRoot: toRootHex(blockHeader.stateRoot),
135
135
  blockRoot: toRootHex(checkpoint.root),
136
136
  timeliness: true, // Optimistically assume is timely
137
+ ptcTimeliness: true, // Spec: block_timeliness for anchor = [True, True]
138
+ proposerIndex: blockHeader.proposerIndex,
137
139
 
138
140
  justifiedEpoch: justifiedCheckpoint.epoch,
139
141
  justifiedRoot: toRootHex(justifiedCheckpoint.root),
@@ -230,6 +232,8 @@ export function initializeForkChoiceFromUnfinalizedState(
230
232
  blockRoot: headRoot,
231
233
  targetRoot: headRoot,
232
234
  timeliness: true, // Optimistically assume is timely
235
+ ptcTimeliness: true, // Spec: block_timeliness for anchor = [True, True]
236
+ proposerIndex: blockHeader.proposerIndex,
233
237
 
234
238
  justifiedEpoch: justifiedCheckpoint.epoch,
235
239
  justifiedRoot: toRootHex(justifiedCheckpoint.root),
@@ -1,7 +1,8 @@
1
+ import {type PubkeyCache} from "@chainsafe/lodestar-z/pubkeys";
1
2
  import {Type} from "@chainsafe/ssz";
2
3
  import {BeaconConfig} from "@lodestar/config";
3
4
  import {CheckpointWithHex, IForkChoice, ProtoBlock} from "@lodestar/fork-choice";
4
- import {EpochShuffling, IBeaconStateView, PubkeyCache} from "@lodestar/state-transition";
5
+ import {EpochShuffling, IBeaconStateView} from "@lodestar/state-transition";
5
6
  import {
6
7
  BeaconBlock,
7
8
  BlindedBeaconBlock,
@@ -44,6 +45,7 @@ import {LightClientServer} from "./lightClient/index.js";
44
45
  import {AggregatedAttestationPool} from "./opPools/aggregatedAttestationPool.js";
45
46
  import {
46
47
  AttestationPool,
48
+ DeferredVoluntaryExitPool,
47
49
  ExecutionPayloadBidPool,
48
50
  OpPool,
49
51
  PayloadAttestationPool,
@@ -127,6 +129,7 @@ export interface IBeaconChain {
127
129
  readonly payloadAttestationPool: PayloadAttestationPool;
128
130
  readonly proposerPreferencesPool: ProposerPreferencesPool;
129
131
  readonly opPool: OpPool;
132
+ readonly deferredVoluntaryExitPool: DeferredVoluntaryExitPool;
130
133
 
131
134
  // Gossip seen cache
132
135
  readonly seenAttesters: SeenAttesters;
@@ -1,4 +1,4 @@
1
- import {Signature, aggregateSignatures} from "@chainsafe/blst";
1
+ import {Signature, aggregateSignatures} from "@chainsafe/lodestar-z/blst";
2
2
  import {BitArray} from "@chainsafe/ssz";
3
3
  import {BeaconConfig} from "@lodestar/config";
4
4
  import {IForkChoice} from "@lodestar/fork-choice";
@@ -1,4 +1,4 @@
1
- import {Signature, aggregateSignatures} from "@chainsafe/blst";
1
+ import {Signature, aggregateSignatures} from "@chainsafe/lodestar-z/blst";
2
2
  import {BitArray} from "@chainsafe/ssz";
3
3
  import {ChainForkConfig} from "@lodestar/config";
4
4
  import {MAX_COMMITTEES_PER_SLOT, isForkPostElectra} from "@lodestar/params";
@@ -0,0 +1,65 @@
1
+ import {Logger} from "@lodestar/logger";
2
+ import {IBeaconStateView, VoluntaryExitValidity} from "@lodestar/state-transition";
3
+ import {Epoch, ValidatorIndex} from "@lodestar/types";
4
+ import {SignedVoluntaryExit} from "@lodestar/types/phase0";
5
+ import {isTransientExitValidity} from "../validation/voluntaryExit.js";
6
+
7
+ type DeferredEntry = {
8
+ exit: SignedVoluntaryExit;
9
+ validity: VoluntaryExitValidity;
10
+ insertedAtEpoch: Epoch;
11
+ };
12
+
13
+ export class DeferredVoluntaryExitPool {
14
+ private pool = new Map<ValidatorIndex, DeferredEntry>();
15
+
16
+ constructor(
17
+ private readonly logger: Logger,
18
+ private readonly maxSize = 1024,
19
+ private readonly maxDeferEpochs = 4096
20
+ ) {}
21
+
22
+ insert(exit: SignedVoluntaryExit, validity: VoluntaryExitValidity, currentEpoch: Epoch): boolean {
23
+ if (!isTransientExitValidity(validity)) return false;
24
+ if (this.pool.size === this.maxSize) return false;
25
+ if (this.pool.has(exit.message.validatorIndex)) return false;
26
+
27
+ this.pool.set(exit.message.validatorIndex, {exit, validity, insertedAtEpoch: currentEpoch});
28
+
29
+ return true;
30
+ }
31
+
32
+ drainProcessableExits(state: IBeaconStateView): SignedVoluntaryExit[] {
33
+ const epoch = state.epoch;
34
+ const validExits: SignedVoluntaryExit[] = [];
35
+ for (const [validatorIndex, entry] of this.pool) {
36
+ try {
37
+ if (epoch - entry.insertedAtEpoch > this.maxDeferEpochs) {
38
+ this.pool.delete(validatorIndex);
39
+ this.logger.debug("Deferred voluntary exit expired", {validatorIndex, lastValidity: entry.validity});
40
+ continue;
41
+ }
42
+ const validity = state.getVoluntaryExitValidity(entry.exit, true);
43
+ if (validity === VoluntaryExitValidity.valid) {
44
+ validExits.push(entry.exit);
45
+ this.pool.delete(validatorIndex);
46
+ } else if (!isTransientExitValidity(validity)) {
47
+ this.logger.debug("Deferred voluntary exit became permanently invalid", {validatorIndex, validity});
48
+ this.pool.delete(validatorIndex);
49
+ }
50
+ // Else if still transient - keep
51
+ } catch (e) {
52
+ this.logger.debug("Processing deferred voluntary exit failed", {validatorIndex}, e as Error);
53
+ }
54
+ }
55
+ return validExits;
56
+ }
57
+
58
+ has(validatorIndex: ValidatorIndex): boolean {
59
+ return this.pool.has(validatorIndex);
60
+ }
61
+
62
+ size(): number {
63
+ return this.pool.size;
64
+ }
65
+ }
@@ -1,5 +1,6 @@
1
1
  export {AggregatedAttestationPool} from "./aggregatedAttestationPool.js";
2
2
  export {AttestationPool} from "./attestationPool.js";
3
+ export {DeferredVoluntaryExitPool} from "./deferredVoluntaryExitPool.js";
3
4
  export {ExecutionPayloadBidPool} from "./executionPayloadBidPool.js";
4
5
  export {OpPool} from "./opPool.js";
5
6
  export {PayloadAttestationPool} from "./payloadAttestationPool.js";
@@ -1,4 +1,4 @@
1
- import {Signature, aggregateSignatures} from "@chainsafe/blst";
1
+ import {Signature, aggregateSignatures} from "@chainsafe/lodestar-z/blst";
2
2
  import {BitArray} from "@chainsafe/ssz";
3
3
  import {ChainForkConfig} from "@lodestar/config";
4
4
  import {MAX_COMMITTEES_PER_SLOT, MAX_PAYLOAD_ATTESTATIONS, PTC_SIZE} from "@lodestar/params";
@@ -178,8 +178,8 @@ function aggregateMessageInto(
178
178
  validatorCommitteeIndices: number[],
179
179
  aggregate: AggregateFast
180
180
  ): InsertOutcome {
181
- // Gossip dedup via `seenPayloadAttesters` is keyed by (epoch, validatorIndex), so the same
182
- // validator's message is never processed twice all of its bits are set together or none.
181
+ // Gossip dedup via `seenPayloadAttesters` is keyed by (slot, validatorIndex), so the same
182
+ // validator's message is never processed twice for this aggregate's slot. All of its bits are set together or none.
183
183
  // Checking the first index is sufficient.
184
184
  if (aggregate.aggregationBits.get(validatorCommitteeIndices[0]) === true) {
185
185
  return InsertOutcome.AlreadyKnown;
@@ -1,4 +1,4 @@
1
- import {Signature, aggregateSignatures} from "@chainsafe/blst";
1
+ import {Signature, aggregateSignatures} from "@chainsafe/lodestar-z/blst";
2
2
  import {BitArray} from "@chainsafe/ssz";
3
3
  import {ChainForkConfig} from "@lodestar/config";
4
4
  import {SYNC_COMMITTEE_SIZE, SYNC_COMMITTEE_SUBNET_COUNT} from "@lodestar/params";
@@ -1,4 +1,4 @@
1
- import {Signature, aggregateSignatures} from "@chainsafe/blst";
1
+ import {Signature, aggregateSignatures} from "@chainsafe/lodestar-z/blst";
2
2
  import {BitArray} from "@chainsafe/ssz";
3
3
  import {ChainForkConfig} from "@lodestar/config";
4
4
  import {SYNC_COMMITTEE_SIZE, SYNC_COMMITTEE_SUBNET_SIZE} from "@lodestar/params";
@@ -1,4 +1,4 @@
1
- import {Signature} from "@chainsafe/blst";
1
+ import {Signature} from "@chainsafe/lodestar-z/blst";
2
2
  import {BLS_WITHDRAWAL_PREFIX} from "@lodestar/params";
3
3
  import {IBeaconStateView} from "@lodestar/state-transition";
4
4
  import {Slot, capella} from "@lodestar/types";
@@ -53,7 +53,7 @@ export type IChainOptions = BlockProcessOpts &
53
53
  nativeStateView?: boolean;
54
54
  /** Builder circuit breaker fault inspection window in slots */
55
55
  faultInspectionWindow?: number;
56
- /** Allowed unrevealed payloads within the fault inspection window */
56
+ /** Canonical EMPTY blocks allowed per `faultInspectionWindow` observed blocks */
57
57
  allowedFaults?: number;
58
58
  };
59
59
 
@@ -151,25 +151,40 @@ export class PrepareNextSlotScheduler {
151
151
  const proposerIndex = await getProposerIndex();
152
152
  feeRecipient = this.chain.beaconProposerCache.get(proposerIndex);
153
153
 
154
- if (feeRecipient) {
155
- // If we are proposing next slot, we need to predict if we can proposer-boost-reorg or not
154
+ // Predict the proposer head of the next slot when either:
155
+ // - we are proposing the next slot (single-slot proposer-boost-reorg), or
156
+ // - this is an epoch transition: post-Fulu the next proposer may reorg a weak
157
+ // last-block-of-epoch and build slot 0 on the strong parent (epoch-boundary reorg),
158
+ // so we should dial the strong parent through the boundary instead of the weak head.
159
+ if (feeRecipient || isEpochTransition) {
156
160
  const proposerHead = this.chain.predictProposerHead(clockSlot);
157
161
  const {slot: proposerHeadSlot, blockRoot: proposerHeadRoot} = proposerHead;
158
162
 
159
- // If we predict we can reorg, we build on the proposer head (parent) block instead
163
+ // If we predict a reorg, we build the epoch transition on the proposer head (parent) instead
160
164
  if (proposerHeadRoot !== headRoot || proposerHeadSlot !== headSlot) {
161
- this.logger.verbose("Weak head detected. May build on parent block instead", {
165
+ // feeRecipient set => WE propose the next slot and may reorg it out ourselves;
166
+ // otherwise it's a predicted reorg by another proposer (epoch-boundary reorg).
167
+ const logMessage = feeRecipient
168
+ ? "Weak head detected. We may build on parent block instead"
169
+ : "Weak head detected. Another proposer may build on parent block instead";
170
+ this.logger.verbose(logMessage, {
162
171
  proposerHeadSlot,
163
172
  proposerHeadRoot,
164
173
  headSlot,
165
174
  headRoot,
175
+ isEpochTransition,
166
176
  });
167
177
  this.metrics?.weakHeadDetected.inc();
178
+ if (isEpochTransition) {
179
+ this.metrics?.precomputeNextEpochTransition.predictedReorg.inc();
180
+ }
168
181
  updatedHead = proposerHead;
169
182
  }
183
+ }
170
184
 
185
+ if (feeRecipient) {
171
186
  if (isForkPostGloas(fork)) {
172
- this.chain.builderCircuitBreaker.update(clockSlot);
187
+ this.chain.builderCircuitBreaker.update(clockSlot, updatedHead);
173
188
  } else {
174
189
  // Update the builder status, if enabled shoot an api call to check status
175
190
  this.chain.updateBuilderStatus(clockSlot);
@@ -182,6 +197,7 @@ export class PrepareNextSlotScheduler {
182
197
  }
183
198
 
184
199
  // post-fulu we'll always reach here because preparedState is undefined
200
+ // we may run epoch transition not with headBlock if it's weak
185
201
  if (preparedState === undefined || updatedHead !== headBlock) {
186
202
  preparedState = await this.chain.regen.getBlockSlotState(
187
203
  updatedHead,
@@ -280,7 +296,7 @@ export class PrepareNextSlotScheduler {
280
296
  // + if next slot is a skipped slot, it'd help getting target checkpoint state faster to validate attestations
281
297
  if (isEpochTransition) {
282
298
  this.metrics?.precomputeNextEpochTransition.count.inc({result: "success"}, 1);
283
- const previousHits = this.chain.regen.updatePreComputedCheckpoint(headRoot, nextEpoch);
299
+ const previousHits = this.chain.regen.updatePreComputedCheckpoint(updatedHead.blockRoot, nextEpoch);
284
300
  if (previousHits === 0) {
285
301
  this.metrics?.precomputeNextEpochTransition.waste.inc();
286
302
  }
@@ -289,6 +305,8 @@ export class PrepareNextSlotScheduler {
289
305
  this.logger.verbose("Completed PrepareNextSlotScheduler epoch transition", {
290
306
  nextEpoch,
291
307
  headSlot,
308
+ headRoot,
309
+ updatedHeadRoot: updatedHead.blockRoot,
292
310
  prepareSlot,
293
311
  previousHits,
294
312
  durationMs: Date.now() - start,
@@ -21,6 +21,8 @@ export enum RegenCaller {
21
21
  validateGossipAggregateAndProof = "validateGossipAggregateAndProof",
22
22
  validateGossipAttestation = "validateGossipAttestation",
23
23
  validateGossipVoluntaryExit = "validateGossipVoluntaryExit",
24
+ validateApiVoluntaryExit = "validateApiVoluntaryExit",
25
+ publishDeferredVoluntaryExits = "publishDeferredVoluntaryExits",
24
26
  validateGossipExecutionPayloadBid = "validateGossipExecutionPayloadBid",
25
27
  validateGossipPayloadAttestationMessage = "validateGossipPayloadAttestationMessage",
26
28
  validateGossipProposerPreferences = "validateGossipProposerPreferences",
@@ -39,14 +41,14 @@ export type StateRegenerationOpts = {
39
41
  };
40
42
 
41
43
  export interface IStateRegenerator extends IStateRegeneratorInternal {
42
- dropCache(): void;
44
+ dropCache(): Promise<void>;
43
45
  dumpCacheSummary(): routes.lodestar.StateCacheItem[];
44
46
  getStateSync(stateRoot: RootHex): IBeaconStateView | null;
45
47
  getPreStateSync(block: BeaconBlock): IBeaconStateView | null;
46
48
  getCheckpointStateOrBytes(cp: CheckpointHex): Promise<IBeaconStateView | Uint8Array | null>;
47
49
  getCheckpointStateSync(cp: CheckpointHex): IBeaconStateView | null;
48
50
  getClosestHeadState(head: ProtoBlock): IBeaconStateView | null;
49
- pruneOnCheckpoint(finalizedEpoch: Epoch, justifiedEpoch: Epoch, headStateRoot: RootHex): void;
51
+ onCheckpoint(finalizedEpoch: Epoch, justifiedEpoch: Epoch, headStateRoot: RootHex): void;
50
52
  processState(blockRootHex: RootHex, postState: IBeaconStateView): void;
51
53
  addCheckpointState(cp: phase0.Checkpoint, item: IBeaconStateView): void;
52
54
  updateHeadState(newHead: ProtoBlock, maybeHeadState: IBeaconStateView): void;
@@ -67,9 +67,9 @@ export class QueuedStateRegenerator implements IStateRegenerator {
67
67
  return this.jobQueue.jobLen < REGEN_CAN_ACCEPT_WORK_THRESHOLD;
68
68
  }
69
69
 
70
- dropCache(): void {
70
+ async dropCache(): Promise<void> {
71
71
  this.blockStateCache.clear();
72
- this.checkpointStateCache.clear();
72
+ await this.checkpointStateCache.clear();
73
73
  }
74
74
 
75
75
  dumpCacheSummary(): routes.lodestar.StateCacheItem[] {
@@ -138,9 +138,9 @@ export class QueuedStateRegenerator implements IStateRegenerator {
138
138
  return this.checkpointStateCache.getLatest(head.blockRoot, Infinity) || this.blockStateCache.get(head.stateRoot);
139
139
  }
140
140
 
141
- pruneOnCheckpoint(finalizedEpoch: Epoch, justifiedEpoch: Epoch, headStateRoot: RootHex): void {
142
- this.checkpointStateCache.prune(finalizedEpoch, justifiedEpoch);
143
- this.blockStateCache.prune(headStateRoot);
141
+ onCheckpoint(finalizedEpoch: Epoch, justifiedEpoch: Epoch, headStateRoot: RootHex): void {
142
+ this.checkpointStateCache.onCheckpoint(finalizedEpoch, justifiedEpoch);
143
+ this.blockStateCache.onCheckpoint(headStateRoot);
144
144
  }
145
145
 
146
146
  processState(blockRootHex: RootHex, postState: IBeaconStateView): void {
@@ -1,4 +1,5 @@
1
- import {Epoch, ValidatorIndex} from "@lodestar/types";
1
+ import {computeEpochAtSlot} from "@lodestar/state-transition";
2
+ import {Epoch, Slot, ValidatorIndex} from "@lodestar/types";
2
3
  import {MapDef} from "@lodestar/utils";
3
4
 
4
5
  // How many *non future* epochs we intend to keep for SeenAttesters.
@@ -57,7 +58,32 @@ export class SeenAttesters {
57
58
  */
58
59
  export class SeenAggregators extends SeenAttesters {}
59
60
 
60
- /**
61
- * Keeps a cache to filter payload attestations from the same attesters in the same epoch
62
- */
63
- export class SeenPayloadAttesters extends SeenAttesters {}
61
+ /** Keeps a cache to filter payload attestations from the same validator in the same slot. */
62
+ export class SeenPayloadAttesters {
63
+ private readonly validatorIndexesBySlot = new MapDef<Slot, Set<ValidatorIndex>>(() => new Set<ValidatorIndex>());
64
+ private readonly validatorIndexesByEpoch = new SeenAttesters();
65
+
66
+ isKnown(slot: Slot, validatorIndex: ValidatorIndex): boolean {
67
+ return this.validatorIndexesBySlot.get(slot)?.has(validatorIndex) === true;
68
+ }
69
+
70
+ add(slot: Slot, validatorIndex: ValidatorIndex): void {
71
+ const epoch = computeEpochAtSlot(slot);
72
+ this.validatorIndexesByEpoch.add(epoch, validatorIndex);
73
+ this.validatorIndexesBySlot.getOrDefault(slot).add(validatorIndex);
74
+ }
75
+
76
+ seenAtEpoch(epoch: Epoch, validatorIndex: ValidatorIndex): boolean {
77
+ return this.validatorIndexesByEpoch.isKnown(epoch, validatorIndex);
78
+ }
79
+
80
+ prune(currentEpoch: Epoch): void {
81
+ const lowestPermissibleEpoch = Math.max(currentEpoch - EPOCH_LOOKBACK_LIMIT, 0);
82
+ for (const slot of this.validatorIndexesBySlot.keys()) {
83
+ if (computeEpochAtSlot(slot) < lowestPermissibleEpoch) {
84
+ this.validatorIndexesBySlot.delete(slot);
85
+ }
86
+ }
87
+ this.validatorIndexesByEpoch.prune(currentEpoch);
88
+ }
89
+ }