@lodestar/beacon-node 1.47.0-dev.f591cb177e → 1.48.0-dev.67344272c0

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 (342) hide show
  1. package/lib/api/impl/beacon/blocks/index.d.ts.map +1 -1
  2. package/lib/api/impl/beacon/blocks/index.js +44 -12
  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 +21 -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.map +1 -1
  11. package/lib/api/impl/events/index.js +2 -0
  12. package/lib/api/impl/events/index.js.map +1 -1
  13. package/lib/api/impl/lodestar/index.js +1 -1
  14. package/lib/api/impl/lodestar/index.js.map +1 -1
  15. package/lib/api/impl/validator/index.d.ts.map +1 -1
  16. package/lib/api/impl/validator/index.js +237 -49
  17. package/lib/api/impl/validator/index.js.map +1 -1
  18. package/lib/api/impl/validator/utils.js +1 -1
  19. package/lib/api/impl/validator/utils.js.map +1 -1
  20. package/lib/api/rest/base.d.ts.map +1 -1
  21. package/lib/api/rest/base.js +7 -0
  22. package/lib/api/rest/base.js.map +1 -1
  23. package/lib/chain/archiveStore/archiveStore.js +1 -1
  24. package/lib/chain/archiveStore/archiveStore.js.map +1 -1
  25. package/lib/chain/blocks/importExecutionPayload.d.ts +3 -2
  26. package/lib/chain/blocks/importExecutionPayload.d.ts.map +1 -1
  27. package/lib/chain/blocks/importExecutionPayload.js +11 -9
  28. package/lib/chain/blocks/importExecutionPayload.js.map +1 -1
  29. package/lib/chain/blocks/index.d.ts.map +1 -1
  30. package/lib/chain/blocks/index.js +21 -13
  31. package/lib/chain/blocks/index.js.map +1 -1
  32. package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.d.ts +2 -1
  33. package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.d.ts.map +1 -1
  34. package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.js +6 -2
  35. package/lib/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.js.map +1 -1
  36. package/lib/chain/blocks/payloadEnvelopeInput/types.d.ts +14 -5
  37. package/lib/chain/blocks/payloadEnvelopeInput/types.d.ts.map +1 -1
  38. package/lib/chain/blocks/payloadEnvelopeInput/types.js +5 -0
  39. package/lib/chain/blocks/payloadEnvelopeInput/types.js.map +1 -1
  40. package/lib/chain/blocks/verifyBlock.d.ts.map +1 -1
  41. package/lib/chain/blocks/verifyBlock.js +5 -2
  42. package/lib/chain/blocks/verifyBlock.js.map +1 -1
  43. package/lib/chain/blocks/verifyBlocksStateTransitionOnly.d.ts.map +1 -1
  44. package/lib/chain/blocks/verifyBlocksStateTransitionOnly.js +22 -12
  45. package/lib/chain/blocks/verifyBlocksStateTransitionOnly.js.map +1 -1
  46. package/lib/chain/blocks/verifyExecutionPayloadEnvelope.d.ts +2 -2
  47. package/lib/chain/blocks/verifyExecutionPayloadEnvelope.d.ts.map +1 -1
  48. package/lib/chain/blocks/verifyExecutionPayloadEnvelope.js +2 -2
  49. package/lib/chain/blocks/verifyExecutionPayloadEnvelope.js.map +1 -1
  50. package/lib/chain/bls/index.d.ts +1 -1
  51. package/lib/chain/bls/index.d.ts.map +1 -1
  52. package/lib/chain/bls/interface.d.ts +5 -5
  53. package/lib/chain/bls/interface.d.ts.map +1 -1
  54. package/lib/chain/bls/multithread/index.d.ts +5 -11
  55. package/lib/chain/bls/multithread/index.d.ts.map +1 -1
  56. package/lib/chain/bls/multithread/index.js +116 -101
  57. package/lib/chain/bls/multithread/index.js.map +1 -1
  58. package/lib/chain/bls/multithread/jobItem.d.ts +5 -19
  59. package/lib/chain/bls/multithread/jobItem.d.ts.map +1 -1
  60. package/lib/chain/bls/multithread/jobItem.js +10 -65
  61. package/lib/chain/bls/multithread/jobItem.js.map +1 -1
  62. package/lib/chain/bls/multithread/types.d.ts +29 -8
  63. package/lib/chain/bls/multithread/types.d.ts.map +1 -1
  64. package/lib/chain/bls/multithread/types.js +12 -0
  65. package/lib/chain/bls/multithread/types.js.map +1 -1
  66. package/lib/chain/bls/multithread/utils.d.ts +4 -0
  67. package/lib/chain/bls/multithread/utils.d.ts.map +1 -1
  68. package/lib/chain/bls/multithread/utils.js +10 -0
  69. package/lib/chain/bls/multithread/utils.js.map +1 -1
  70. package/lib/chain/bls/multithread/worker.js +49 -23
  71. package/lib/chain/bls/multithread/worker.js.map +1 -1
  72. package/lib/chain/bls/singleThread.d.ts +4 -10
  73. package/lib/chain/bls/singleThread.d.ts.map +1 -1
  74. package/lib/chain/bls/singleThread.js +8 -45
  75. package/lib/chain/bls/singleThread.js.map +1 -1
  76. package/lib/chain/bls/utils.d.ts +4 -4
  77. package/lib/chain/bls/utils.d.ts.map +1 -1
  78. package/lib/chain/bls/utils.js +18 -19
  79. package/lib/chain/bls/utils.js.map +1 -1
  80. package/lib/chain/chain.d.ts +9 -4
  81. package/lib/chain/chain.d.ts.map +1 -1
  82. package/lib/chain/chain.js +22 -8
  83. package/lib/chain/chain.js.map +1 -1
  84. package/lib/chain/errors/blockError.d.ts +1 -0
  85. package/lib/chain/errors/blockError.d.ts.map +1 -1
  86. package/lib/chain/errors/blockError.js +6 -1
  87. package/lib/chain/errors/blockError.js.map +1 -1
  88. package/lib/chain/errors/executionPayloadBid.d.ts +5 -0
  89. package/lib/chain/errors/executionPayloadBid.d.ts.map +1 -1
  90. package/lib/chain/errors/executionPayloadBid.js +1 -0
  91. package/lib/chain/errors/executionPayloadBid.js.map +1 -1
  92. package/lib/chain/forkChoice/index.d.ts.map +1 -1
  93. package/lib/chain/forkChoice/index.js +4 -0
  94. package/lib/chain/forkChoice/index.js.map +1 -1
  95. package/lib/chain/interface.d.ts +8 -4
  96. package/lib/chain/interface.d.ts.map +1 -1
  97. package/lib/chain/interface.js.map +1 -1
  98. package/lib/chain/opPools/aggregatedAttestationPool.js +1 -1
  99. package/lib/chain/opPools/aggregatedAttestationPool.js.map +1 -1
  100. package/lib/chain/opPools/attestationPool.d.ts +1 -1
  101. package/lib/chain/opPools/attestationPool.d.ts.map +1 -1
  102. package/lib/chain/opPools/attestationPool.js +1 -1
  103. package/lib/chain/opPools/attestationPool.js.map +1 -1
  104. package/lib/chain/opPools/deferredVoluntaryExitPool.d.ts +16 -0
  105. package/lib/chain/opPools/deferredVoluntaryExitPool.d.ts.map +1 -0
  106. package/lib/chain/opPools/deferredVoluntaryExitPool.js +57 -0
  107. package/lib/chain/opPools/deferredVoluntaryExitPool.js.map +1 -0
  108. package/lib/chain/opPools/executionPayloadBidPool.d.ts +7 -2
  109. package/lib/chain/opPools/executionPayloadBidPool.d.ts.map +1 -1
  110. package/lib/chain/opPools/executionPayloadBidPool.js +4 -4
  111. package/lib/chain/opPools/executionPayloadBidPool.js.map +1 -1
  112. package/lib/chain/opPools/index.d.ts +2 -1
  113. package/lib/chain/opPools/index.d.ts.map +1 -1
  114. package/lib/chain/opPools/index.js +1 -0
  115. package/lib/chain/opPools/index.js.map +1 -1
  116. package/lib/chain/opPools/payloadAttestationPool.js +3 -3
  117. package/lib/chain/opPools/payloadAttestationPool.js.map +1 -1
  118. package/lib/chain/opPools/syncCommitteeMessagePool.js +1 -1
  119. package/lib/chain/opPools/syncCommitteeMessagePool.js.map +1 -1
  120. package/lib/chain/opPools/syncContributionAndProofPool.js +1 -1
  121. package/lib/chain/opPools/syncContributionAndProofPool.js.map +1 -1
  122. package/lib/chain/opPools/utils.d.ts +1 -1
  123. package/lib/chain/opPools/utils.d.ts.map +1 -1
  124. package/lib/chain/opPools/utils.js +1 -1
  125. package/lib/chain/opPools/utils.js.map +1 -1
  126. package/lib/chain/prepareNextSlot.d.ts +5 -0
  127. package/lib/chain/prepareNextSlot.d.ts.map +1 -1
  128. package/lib/chain/prepareNextSlot.js +47 -6
  129. package/lib/chain/prepareNextSlot.js.map +1 -1
  130. package/lib/chain/produceBlock/computeNewStateRoot.d.ts.map +1 -1
  131. package/lib/chain/produceBlock/computeNewStateRoot.js +3 -25
  132. package/lib/chain/produceBlock/computeNewStateRoot.js.map +1 -1
  133. package/lib/chain/produceBlock/produceBlockBody.js +1 -1
  134. package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
  135. package/lib/chain/regen/interface.d.ts +5 -2
  136. package/lib/chain/regen/interface.d.ts.map +1 -1
  137. package/lib/chain/regen/interface.js +3 -0
  138. package/lib/chain/regen/interface.js.map +1 -1
  139. package/lib/chain/regen/queued.d.ts +2 -2
  140. package/lib/chain/regen/queued.d.ts.map +1 -1
  141. package/lib/chain/regen/queued.js +5 -5
  142. package/lib/chain/regen/queued.js.map +1 -1
  143. package/lib/chain/seenCache/seenAttesters.d.ts +9 -5
  144. package/lib/chain/seenCache/seenAttesters.d.ts.map +1 -1
  145. package/lib/chain/seenCache/seenAttesters.js +25 -4
  146. package/lib/chain/seenCache/seenAttesters.js.map +1 -1
  147. package/lib/chain/seenCache/seenPayloadEnvelopeInput.d.ts +28 -1
  148. package/lib/chain/seenCache/seenPayloadEnvelopeInput.d.ts.map +1 -1
  149. package/lib/chain/seenCache/seenPayloadEnvelopeInput.js +121 -13
  150. package/lib/chain/seenCache/seenPayloadEnvelopeInput.js.map +1 -1
  151. package/lib/chain/stateCache/fifoBlockStateCache.d.ts +5 -1
  152. package/lib/chain/stateCache/fifoBlockStateCache.d.ts.map +1 -1
  153. package/lib/chain/stateCache/fifoBlockStateCache.js +6 -0
  154. package/lib/chain/stateCache/fifoBlockStateCache.js.map +1 -1
  155. package/lib/chain/stateCache/persistentCheckpointsCache.d.ts +47 -5
  156. package/lib/chain/stateCache/persistentCheckpointsCache.d.ts.map +1 -1
  157. package/lib/chain/stateCache/persistentCheckpointsCache.js +117 -7
  158. package/lib/chain/stateCache/persistentCheckpointsCache.js.map +1 -1
  159. package/lib/chain/stateCache/types.d.ts +3 -3
  160. package/lib/chain/stateCache/types.d.ts.map +1 -1
  161. package/lib/chain/validation/attestation.d.ts.map +1 -1
  162. package/lib/chain/validation/attestation.js +1 -4
  163. package/lib/chain/validation/attestation.js.map +1 -1
  164. package/lib/chain/validation/attesterSlashing.d.ts.map +1 -1
  165. package/lib/chain/validation/attesterSlashing.js +1 -1
  166. package/lib/chain/validation/attesterSlashing.js.map +1 -1
  167. package/lib/chain/validation/block.d.ts.map +1 -1
  168. package/lib/chain/validation/block.js +40 -10
  169. package/lib/chain/validation/block.js.map +1 -1
  170. package/lib/chain/validation/executionPayloadBid.d.ts +15 -3
  171. package/lib/chain/validation/executionPayloadBid.d.ts.map +1 -1
  172. package/lib/chain/validation/executionPayloadBid.js +166 -12
  173. package/lib/chain/validation/executionPayloadBid.js.map +1 -1
  174. package/lib/chain/validation/executionPayloadEnvelope.js +1 -1
  175. package/lib/chain/validation/executionPayloadEnvelope.js.map +1 -1
  176. package/lib/chain/validation/payloadAttestationMessage.d.ts.map +1 -1
  177. package/lib/chain/validation/payloadAttestationMessage.js +5 -14
  178. package/lib/chain/validation/payloadAttestationMessage.js.map +1 -1
  179. package/lib/chain/validation/proposerPreferences.js +2 -2
  180. package/lib/chain/validation/proposerPreferences.js.map +1 -1
  181. package/lib/chain/validation/proposerSlashing.js +1 -1
  182. package/lib/chain/validation/proposerSlashing.js.map +1 -1
  183. package/lib/chain/validation/voluntaryExit.d.ts +9 -1
  184. package/lib/chain/validation/voluntaryExit.d.ts.map +1 -1
  185. package/lib/chain/validation/voluntaryExit.js +46 -1
  186. package/lib/chain/validation/voluntaryExit.js.map +1 -1
  187. package/lib/execution/builder/apiClient.d.ts +70 -0
  188. package/lib/execution/builder/apiClient.d.ts.map +1 -0
  189. package/lib/execution/builder/apiClient.js +202 -0
  190. package/lib/execution/builder/apiClient.js.map +1 -0
  191. package/lib/execution/builder/validateBid.d.ts +23 -0
  192. package/lib/execution/builder/validateBid.d.ts.map +1 -0
  193. package/lib/execution/builder/validateBid.js +119 -0
  194. package/lib/execution/builder/validateBid.js.map +1 -0
  195. package/lib/metrics/metrics/lodestar.d.ts +84 -23
  196. package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
  197. package/lib/metrics/metrics/lodestar.js +161 -55
  198. package/lib/metrics/metrics/lodestar.js.map +1 -1
  199. package/lib/network/gossip/topic.d.ts +13 -0
  200. package/lib/network/gossip/topic.d.ts.map +1 -1
  201. package/lib/network/gossip/topic.js +37 -0
  202. package/lib/network/gossip/topic.js.map +1 -1
  203. package/lib/network/network.d.ts.map +1 -1
  204. package/lib/network/network.js +23 -43
  205. package/lib/network/network.js.map +1 -1
  206. package/lib/network/processor/constants.d.ts +7 -0
  207. package/lib/network/processor/constants.d.ts.map +1 -0
  208. package/lib/network/processor/constants.js +7 -0
  209. package/lib/network/processor/constants.js.map +1 -0
  210. package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
  211. package/lib/network/processor/gossipHandlers.js +6 -2
  212. package/lib/network/processor/gossipHandlers.js.map +1 -1
  213. package/lib/network/processor/gossipQueues/indexed.d.ts.map +1 -1
  214. package/lib/network/processor/gossipQueues/indexed.js +0 -1
  215. package/lib/network/processor/gossipQueues/indexed.js.map +1 -1
  216. package/lib/network/processor/index.d.ts +3 -0
  217. package/lib/network/processor/index.d.ts.map +1 -1
  218. package/lib/network/processor/index.js +52 -23
  219. package/lib/network/processor/index.js.map +1 -1
  220. package/lib/network/reqresp/score.d.ts.map +1 -1
  221. package/lib/network/reqresp/score.js +5 -11
  222. package/lib/network/reqresp/score.js.map +1 -1
  223. package/lib/network/util.d.ts +0 -1
  224. package/lib/network/util.d.ts.map +1 -1
  225. package/lib/network/util.js +0 -4
  226. package/lib/network/util.js.map +1 -1
  227. package/lib/node/deferredVoluntaryExitPublisher.d.ts +15 -0
  228. package/lib/node/deferredVoluntaryExitPublisher.d.ts.map +1 -0
  229. package/lib/node/deferredVoluntaryExitPublisher.js +38 -0
  230. package/lib/node/deferredVoluntaryExitPublisher.js.map +1 -0
  231. package/lib/node/nodejs.d.ts +2 -1
  232. package/lib/node/nodejs.d.ts.map +1 -1
  233. package/lib/node/nodejs.js +7 -0
  234. package/lib/node/nodejs.js.map +1 -1
  235. package/lib/sync/range/batch.d.ts +23 -5
  236. package/lib/sync/range/batch.d.ts.map +1 -1
  237. package/lib/sync/range/batch.js +61 -22
  238. package/lib/sync/range/batch.js.map +1 -1
  239. package/lib/sync/range/chain.d.ts +2 -1
  240. package/lib/sync/range/chain.d.ts.map +1 -1
  241. package/lib/sync/range/chain.js +32 -12
  242. package/lib/sync/range/chain.js.map +1 -1
  243. package/lib/sync/range/range.js +1 -1
  244. package/lib/sync/range/range.js.map +1 -1
  245. package/lib/sync/types.d.ts +32 -0
  246. package/lib/sync/types.d.ts.map +1 -1
  247. package/lib/sync/types.js +33 -0
  248. package/lib/sync/types.js.map +1 -1
  249. package/lib/sync/unknownBlock.d.ts +6 -2
  250. package/lib/sync/unknownBlock.d.ts.map +1 -1
  251. package/lib/sync/unknownBlock.js +143 -68
  252. package/lib/sync/unknownBlock.js.map +1 -1
  253. package/lib/sync/utils/downloadByRange.d.ts.map +1 -1
  254. package/lib/sync/utils/downloadByRange.js +16 -11
  255. package/lib/sync/utils/downloadByRange.js.map +1 -1
  256. package/lib/sync/utils/downloadByRoot.d.ts.map +1 -1
  257. package/lib/sync/utils/downloadByRoot.js +3 -1
  258. package/lib/sync/utils/downloadByRoot.js.map +1 -1
  259. package/package.json +35 -35
  260. package/src/api/impl/beacon/blocks/index.ts +51 -15
  261. package/src/api/impl/beacon/pool/index.ts +22 -2
  262. package/src/api/impl/beacon/state/utils.ts +2 -1
  263. package/src/api/impl/events/index.ts +3 -1
  264. package/src/api/impl/lodestar/index.ts +1 -1
  265. package/src/api/impl/validator/index.ts +290 -49
  266. package/src/api/impl/validator/utils.ts +1 -1
  267. package/src/api/rest/base.ts +7 -0
  268. package/src/chain/archiveStore/archiveStore.ts +1 -1
  269. package/src/chain/blocks/importExecutionPayload.ts +12 -11
  270. package/src/chain/blocks/index.ts +25 -13
  271. package/src/chain/blocks/payloadEnvelopeInput/payloadEnvelopeInput.ts +8 -2
  272. package/src/chain/blocks/payloadEnvelopeInput/types.ts +17 -4
  273. package/src/chain/blocks/verifyBlock.ts +5 -2
  274. package/src/chain/blocks/verifyBlocksStateTransitionOnly.ts +25 -16
  275. package/src/chain/blocks/verifyExecutionPayloadEnvelope.ts +1 -9
  276. package/src/chain/bls/index.ts +1 -1
  277. package/src/chain/bls/interface.ts +7 -3
  278. package/src/chain/bls/multithread/index.ts +148 -120
  279. package/src/chain/bls/multithread/jobItem.ts +12 -82
  280. package/src/chain/bls/multithread/types.ts +33 -8
  281. package/src/chain/bls/multithread/utils.ts +11 -0
  282. package/src/chain/bls/multithread/worker.ts +85 -27
  283. package/src/chain/bls/singleThread.ts +11 -55
  284. package/src/chain/bls/utils.ts +23 -24
  285. package/src/chain/chain.ts +25 -7
  286. package/src/chain/errors/blockError.ts +8 -2
  287. package/src/chain/errors/executionPayloadBid.ts +6 -0
  288. package/src/chain/forkChoice/index.ts +4 -0
  289. package/src/chain/interface.ts +8 -3
  290. package/src/chain/opPools/aggregatedAttestationPool.ts +1 -1
  291. package/src/chain/opPools/attestationPool.ts +1 -1
  292. package/src/chain/opPools/deferredVoluntaryExitPool.ts +65 -0
  293. package/src/chain/opPools/executionPayloadBidPool.ts +13 -7
  294. package/src/chain/opPools/index.ts +2 -1
  295. package/src/chain/opPools/payloadAttestationPool.ts +3 -3
  296. package/src/chain/opPools/syncCommitteeMessagePool.ts +1 -1
  297. package/src/chain/opPools/syncContributionAndProofPool.ts +1 -1
  298. package/src/chain/opPools/utils.ts +1 -1
  299. package/src/chain/prepareNextSlot.ts +49 -6
  300. package/src/chain/produceBlock/computeNewStateRoot.ts +3 -38
  301. package/src/chain/produceBlock/produceBlockBody.ts +1 -1
  302. package/src/chain/regen/interface.ts +5 -2
  303. package/src/chain/regen/queued.ts +5 -5
  304. package/src/chain/seenCache/seenAttesters.ts +31 -5
  305. package/src/chain/seenCache/seenPayloadEnvelopeInput.ts +143 -14
  306. package/src/chain/stateCache/fifoBlockStateCache.ts +8 -1
  307. package/src/chain/stateCache/persistentCheckpointsCache.ts +133 -8
  308. package/src/chain/stateCache/types.ts +3 -3
  309. package/src/chain/validation/attestation.ts +1 -7
  310. package/src/chain/validation/attesterSlashing.ts +1 -8
  311. package/src/chain/validation/block.ts +43 -10
  312. package/src/chain/validation/executionPayloadBid.ts +193 -14
  313. package/src/chain/validation/executionPayloadEnvelope.ts +0 -1
  314. package/src/chain/validation/payloadAttestationMessage.ts +6 -17
  315. package/src/chain/validation/proposerPreferences.ts +3 -3
  316. package/src/chain/validation/proposerSlashing.ts +1 -1
  317. package/src/chain/validation/voluntaryExit.ts +59 -2
  318. package/src/execution/builder/apiClient.ts +264 -0
  319. package/src/execution/builder/validateBid.ts +181 -0
  320. package/src/metrics/metrics/lodestar.ts +176 -61
  321. package/src/network/gossip/topic.ts +38 -0
  322. package/src/network/network.ts +29 -54
  323. package/src/network/processor/constants.ts +6 -0
  324. package/src/network/processor/gossipHandlers.ts +6 -2
  325. package/src/network/processor/gossipQueues/indexed.ts +0 -1
  326. package/src/network/processor/index.ts +67 -30
  327. package/src/network/reqresp/score.ts +5 -11
  328. package/src/network/util.ts +0 -5
  329. package/src/node/deferredVoluntaryExitPublisher.ts +54 -0
  330. package/src/node/nodejs.ts +10 -1
  331. package/src/sync/range/batch.ts +83 -28
  332. package/src/sync/range/chain.ts +35 -13
  333. package/src/sync/range/range.ts +1 -1
  334. package/src/sync/types.ts +33 -0
  335. package/src/sync/unknownBlock.ts +167 -73
  336. package/src/sync/utils/downloadByRange.ts +21 -12
  337. package/src/sync/utils/downloadByRoot.ts +3 -1
  338. package/lib/chain/bls/maybeBatch.d.ts +0 -12
  339. package/lib/chain/bls/maybeBatch.d.ts.map +0 -1
  340. package/lib/chain/bls/maybeBatch.js +0 -35
  341. package/lib/chain/bls/maybeBatch.js.map +0 -1
  342. package/src/chain/bls/maybeBatch.ts +0 -45
@@ -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
+ }
@@ -11,14 +11,20 @@ const SLOTS_RETAINED = 2;
11
11
  type BlockRootHex = string;
12
12
  type BlockHashHex = string;
13
13
 
14
+ export type PooledExecutionPayloadBid = {
15
+ signedBid: gloas.SignedExecutionPayloadBid;
16
+ /** Time in milliseconds from the slot start when the bid was received */
17
+ receivedMs: number;
18
+ };
19
+
14
20
  /**
15
21
  * Store the best signed execution payload bid per slot / (parent block root, parent block hash).
16
22
  */
17
23
  export class ExecutionPayloadBidPool {
18
24
  private readonly bidByParentHashByParentRootBySlot = new MapDef<
19
25
  Slot,
20
- MapDef<BlockRootHex, Map<BlockHashHex, gloas.SignedExecutionPayloadBid>>
21
- >(() => new MapDef<BlockRootHex, Map<BlockHashHex, gloas.SignedExecutionPayloadBid>>(() => new Map()));
26
+ MapDef<BlockRootHex, Map<BlockHashHex, PooledExecutionPayloadBid>>
27
+ >(() => new MapDef<BlockRootHex, Map<BlockHashHex, PooledExecutionPayloadBid>>(() => new Map()));
22
28
  private lowestPermissibleSlot = 0;
23
29
 
24
30
  get size(): number {
@@ -31,7 +37,7 @@ export class ExecutionPayloadBidPool {
31
37
  return count;
32
38
  }
33
39
 
34
- add(bid: gloas.SignedExecutionPayloadBid): InsertOutcome {
40
+ add(bid: gloas.SignedExecutionPayloadBid, receivedMs: number): InsertOutcome {
35
41
  const {slot, parentBlockRoot, parentBlockHash, value} = bid.message;
36
42
  const lowestPermissibleSlot = this.lowestPermissibleSlot;
37
43
 
@@ -45,16 +51,16 @@ export class ExecutionPayloadBidPool {
45
51
  const existing = bidByParentHash.get(parentHashHex);
46
52
 
47
53
  if (existing) {
48
- const existingValue = existing.message.value;
54
+ const existingValue = existing.signedBid.message.value;
49
55
  const newValue = value;
50
56
  if (newValue > existingValue) {
51
- bidByParentHash.set(parentHashHex, bid);
57
+ bidByParentHash.set(parentHashHex, {signedBid: bid, receivedMs});
52
58
  return InsertOutcome.NewData;
53
59
  }
54
60
  return newValue === existingValue ? InsertOutcome.AlreadyKnown : InsertOutcome.NotBetterThan;
55
61
  }
56
62
 
57
- bidByParentHash.set(parentHashHex, bid);
63
+ bidByParentHash.set(parentHashHex, {signedBid: bid, receivedMs});
58
64
  return InsertOutcome.NewData;
59
65
  }
60
66
 
@@ -66,7 +72,7 @@ export class ExecutionPayloadBidPool {
66
72
  slot: Slot,
67
73
  parentBlockHash: BlockHashHex | null,
68
74
  parentBlockRoot: BlockRootHex
69
- ): gloas.SignedExecutionPayloadBid | null {
75
+ ): PooledExecutionPayloadBid | null {
70
76
  if (parentBlockHash === null) return null;
71
77
  const bidByParentHash = this.bidByParentHashByParentRootBySlot.get(slot)?.get(parentBlockRoot);
72
78
  return bidByParentHash?.get(parentBlockHash) ?? null;
@@ -1,6 +1,7 @@
1
1
  export {AggregatedAttestationPool} from "./aggregatedAttestationPool.js";
2
2
  export {AttestationPool} from "./attestationPool.js";
3
- export {ExecutionPayloadBidPool} from "./executionPayloadBidPool.js";
3
+ export {DeferredVoluntaryExitPool} from "./deferredVoluntaryExitPool.js";
4
+ export {ExecutionPayloadBidPool, type PooledExecutionPayloadBid} from "./executionPayloadBidPool.js";
4
5
  export {OpPool} from "./opPool.js";
5
6
  export {PayloadAttestationPool} from "./payloadAttestationPool.js";
6
7
  export {ProposerPreferencesPool} from "./proposerPreferencesPool.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";
@@ -45,6 +45,14 @@ const PREPARE_EPOCH_LIMIT = 1;
45
45
  * Expressed in bps so it scales with slot duration (mainnet vs minimal/devnet). */
46
46
  const BUILDER_PREVERIFY_LIMIT_BPS = 2000;
47
47
 
48
+ /**
49
+ * How far before the next slot builder connections are pre-established, see `checkBuilderStatusBeforeSlot`.
50
+ *
51
+ * 1667 = 16.67% of slot (2s on mainnet). Must stay under the few seconds an idle connection survives,
52
+ * while leaving room for a round trip to a distant builder to complete before the slot begins.
53
+ */
54
+ const BUILDER_STATUS_CHECK_BEFORE_SLOT_BPS = 1667;
55
+
48
56
  /**
49
57
  * At Bellatrix, if we are responsible for proposing in next slot, we want to prepare payload
50
58
  * 4s before the start of next slot at PREPARE_NEXT_SLOT_BPS of the current slot.
@@ -151,25 +159,41 @@ export class PrepareNextSlotScheduler {
151
159
  const proposerIndex = await getProposerIndex();
152
160
  feeRecipient = this.chain.beaconProposerCache.get(proposerIndex);
153
161
 
154
- if (feeRecipient) {
155
- // If we are proposing next slot, we need to predict if we can proposer-boost-reorg or not
156
- const proposerHead = this.chain.predictProposerHead(clockSlot);
162
+ // Predict the proposer head of the next slot when either:
163
+ // - we are proposing the next slot (single-slot proposer-boost-reorg), or
164
+ // - this is an epoch transition: post-Fulu the next proposer may reorg a weak
165
+ // last-block-of-epoch and build slot 0 on the strong parent (epoch-boundary reorg),
166
+ // so we should dial the strong parent through the boundary instead of the weak head.
167
+ if (feeRecipient || isEpochTransition) {
168
+ const proposerHead = this.chain.predictProposerHead();
157
169
  const {slot: proposerHeadSlot, blockRoot: proposerHeadRoot} = proposerHead;
158
170
 
159
- // If we predict we can reorg, we build on the proposer head (parent) block instead
171
+ // If we predict a reorg, we build the epoch transition on the proposer head (parent) instead
160
172
  if (proposerHeadRoot !== headRoot || proposerHeadSlot !== headSlot) {
161
- this.logger.verbose("Weak head detected. May build on parent block instead", {
173
+ // feeRecipient set => WE propose the next slot and may reorg it out ourselves;
174
+ // otherwise it's a predicted reorg by another proposer (epoch-boundary reorg).
175
+ const logMessage = feeRecipient
176
+ ? "Weak head detected. We may build on parent block instead"
177
+ : "Weak head detected. Another proposer may build on parent block instead";
178
+ this.logger.verbose(logMessage, {
162
179
  proposerHeadSlot,
163
180
  proposerHeadRoot,
164
181
  headSlot,
165
182
  headRoot,
183
+ isEpochTransition,
166
184
  });
167
185
  this.metrics?.weakHeadDetected.inc();
186
+ if (isEpochTransition) {
187
+ this.metrics?.precomputeNextEpochTransition.predictedReorg.inc();
188
+ }
168
189
  updatedHead = proposerHead;
169
190
  }
191
+ }
170
192
 
193
+ if (feeRecipient) {
171
194
  if (isForkPostGloas(fork)) {
172
195
  this.chain.builderCircuitBreaker.update(clockSlot, updatedHead);
196
+ this.checkBuilderStatusBeforeSlot(prepareSlot);
173
197
  } else {
174
198
  // Update the builder status, if enabled shoot an api call to check status
175
199
  this.chain.updateBuilderStatus(clockSlot);
@@ -182,6 +206,7 @@ export class PrepareNextSlotScheduler {
182
206
  }
183
207
 
184
208
  // post-fulu we'll always reach here because preparedState is undefined
209
+ // we may run epoch transition not with headBlock if it's weak
185
210
  if (preparedState === undefined || updatedHead !== headBlock) {
186
211
  preparedState = await this.chain.regen.getBlockSlotState(
187
212
  updatedHead,
@@ -280,7 +305,7 @@ export class PrepareNextSlotScheduler {
280
305
  // + if next slot is a skipped slot, it'd help getting target checkpoint state faster to validate attestations
281
306
  if (isEpochTransition) {
282
307
  this.metrics?.precomputeNextEpochTransition.count.inc({result: "success"}, 1);
283
- const previousHits = this.chain.regen.updatePreComputedCheckpoint(headRoot, nextEpoch);
308
+ const previousHits = this.chain.regen.updatePreComputedCheckpoint(updatedHead.blockRoot, nextEpoch);
284
309
  if (previousHits === 0) {
285
310
  this.metrics?.precomputeNextEpochTransition.waste.inc();
286
311
  }
@@ -289,6 +314,8 @@ export class PrepareNextSlotScheduler {
289
314
  this.logger.verbose("Completed PrepareNextSlotScheduler epoch transition", {
290
315
  nextEpoch,
291
316
  headSlot,
317
+ headRoot,
318
+ updatedHeadRoot: updatedHead.blockRoot,
292
319
  prepareSlot,
293
320
  previousHits,
294
321
  durationMs: Date.now() - start,
@@ -372,6 +399,22 @@ export class PrepareNextSlotScheduler {
372
399
  }
373
400
  };
374
401
 
402
+ /**
403
+ * Pre-establish the builder connections so the handshake lands outside the bid deadline. Scheduled
404
+ * later in the slot, connecting at PREPARE_NEXT_SLOT_BPS would go cold before bids are requested.
405
+ */
406
+ private checkBuilderStatusBeforeSlot(prepareSlot: Slot): void {
407
+ const msBeforeSlot = this.config.getSlotComponentDurationMs(BUILDER_STATUS_CHECK_BEFORE_SLOT_BPS);
408
+ const msUntilCheck = -this.chain.clock.msFromSlot(prepareSlot) - msBeforeSlot;
409
+ sleep(Math.max(0, msUntilCheck), this.signal)
410
+ .then(() => this.chain.builderApiClient.checkStatus())
411
+ .catch((e) => {
412
+ if (!isErrorAborted(e)) {
413
+ this.logger.debug("Failed to check builder status", {prepareSlot}, e as Error);
414
+ }
415
+ });
416
+ }
417
+
375
418
  computeStateHashTreeRoot(state: IBeaconStateView, isEpochTransition: boolean): void {
376
419
  // cache HashObjects for faster hashTreeRoot() later, especially for computeNewStateRoot() if we need to produce a block at slot 0 of epoch
377
420
  // see https://github.com/ChainSafe/lodestar/issues/6194
@@ -1,11 +1,5 @@
1
- import {
2
- DataAvailabilityStatus,
3
- ExecutionPayloadStatus,
4
- IBeaconStateView,
5
- StateHashTreeRootSource,
6
- } from "@lodestar/state-transition";
1
+ import {EMPTY_SIGNATURE, IBeaconStateView} from "@lodestar/state-transition";
7
2
  import {BeaconBlock, BlindedBeaconBlock, Gwei, Root} from "@lodestar/types";
8
- import {ZERO_HASH} from "../../constants/index.js";
9
3
  import {Metrics} from "../../metrics/index.js";
10
4
 
11
5
  /**
@@ -19,35 +13,6 @@ export function computeNewStateRoot(
19
13
  block: BeaconBlock | BlindedBeaconBlock
20
14
  ): {newStateRoot: Root; proposerReward: Gwei; postState: IBeaconStateView} {
21
15
  // Set signature to zero to re-use stateTransition() function which requires the SignedBeaconBlock type
22
- const blockEmptySig = {message: block, signature: ZERO_HASH};
23
-
24
- const postState = state.stateTransition(
25
- blockEmptySig,
26
- {
27
- // ExecutionPayloadStatus.valid: Assume payload valid, it has been produced by a trusted EL
28
- executionPayloadStatus: ExecutionPayloadStatus.valid,
29
- // DataAvailabilityStatus.available: Assume the blobs to be available, have just been produced by trusted EL
30
- dataAvailabilityStatus: DataAvailabilityStatus.Available,
31
- // verifyStateRoot: false | the root in the block is zero-ed, it's being computed here
32
- verifyStateRoot: false,
33
- // verifyProposer: false | as the block signature is zero-ed
34
- verifyProposer: false,
35
- // verifySignatures: false | since the data to assemble the block is trusted
36
- verifySignatures: false,
37
- // Preserve cache in source state, since the resulting state is not added to the state cache
38
- dontTransferCache: true,
39
- },
40
- {metrics}
41
- );
42
-
43
- const {attestations, syncAggregate, slashing} = postState.proposerRewards;
44
- const proposerReward = BigInt(attestations + syncAggregate + slashing);
45
-
46
- const hashTreeRootTimer = metrics?.stateHashTreeRootTime.startTimer({
47
- source: StateHashTreeRootSource.computeNewStateRoot,
48
- });
49
- const newStateRoot = postState.hashTreeRoot();
50
- hashTreeRootTimer?.();
51
-
52
- return {newStateRoot, proposerReward, postState};
16
+ const signedBlock = {message: block, signature: EMPTY_SIGNATURE};
17
+ return state.computeNewStateRoot({block: signedBlock}, {metrics});
53
18
  }
@@ -241,7 +241,7 @@ export async function produceBlockBody<T extends BlockType>(
241
241
  const parentExecutionRequests = isExtendingPayload
242
242
  ? await this.getParentExecutionRequests(parentBlock.slot, parentBlock.blockRoot)
243
243
  : ssz.gloas.ExecutionRequests.defaultValue();
244
- executionPayloadValue = BigInt(builderBid.message.value) * GWEI_TO_WEI;
244
+ executionPayloadValue = (BigInt(builderBid.message.value) + builderBid.message.executionPayment) * GWEI_TO_WEI;
245
245
 
246
246
  const commonBlockBody = await commonBlockBodyPromise;
247
247
  const gloasBody = Object.assign({}, commonBlockBody) as gloas.BeaconBlockBody;
@@ -21,7 +21,10 @@ 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",
27
+ validateApiExecutionPayloadBid = "validateApiExecutionPayloadBid",
25
28
  validateGossipPayloadAttestationMessage = "validateGossipPayloadAttestationMessage",
26
29
  validateGossipProposerPreferences = "validateGossipProposerPreferences",
27
30
  onForkChoiceFinalized = "onForkChoiceFinalized",
@@ -39,14 +42,14 @@ export type StateRegenerationOpts = {
39
42
  };
40
43
 
41
44
  export interface IStateRegenerator extends IStateRegeneratorInternal {
42
- dropCache(): void;
45
+ dropCache(): Promise<void>;
43
46
  dumpCacheSummary(): routes.lodestar.StateCacheItem[];
44
47
  getStateSync(stateRoot: RootHex): IBeaconStateView | null;
45
48
  getPreStateSync(block: BeaconBlock): IBeaconStateView | null;
46
49
  getCheckpointStateOrBytes(cp: CheckpointHex): Promise<IBeaconStateView | Uint8Array | null>;
47
50
  getCheckpointStateSync(cp: CheckpointHex): IBeaconStateView | null;
48
51
  getClosestHeadState(head: ProtoBlock): IBeaconStateView | null;
49
- pruneOnCheckpoint(finalizedEpoch: Epoch, justifiedEpoch: Epoch, headStateRoot: RootHex): void;
52
+ onCheckpoint(finalizedEpoch: Epoch, justifiedEpoch: Epoch, headStateRoot: RootHex): void;
50
53
  processState(blockRootHex: RootHex, postState: IBeaconStateView): void;
51
54
  addCheckpointState(cp: phase0.Checkpoint, item: IBeaconStateView): void;
52
55
  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
+ }