@lodestar/beacon-node 1.35.0-dev.f80d2d52da → 1.35.0-dev.fd1dac853d

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 (1374) hide show
  1. package/lib/api/impl/api.d.ts.map +1 -0
  2. package/lib/api/impl/beacon/blocks/index.d.ts.map +1 -0
  3. package/lib/api/impl/beacon/blocks/index.js +58 -46
  4. package/lib/api/impl/beacon/blocks/index.js.map +1 -1
  5. package/lib/api/impl/beacon/blocks/utils.d.ts.map +1 -0
  6. package/lib/api/impl/beacon/index.d.ts.map +1 -0
  7. package/lib/api/impl/beacon/pool/index.d.ts.map +1 -0
  8. package/lib/api/impl/beacon/pool/index.js +3 -3
  9. package/lib/api/impl/beacon/pool/index.js.map +1 -1
  10. package/lib/api/impl/beacon/rewards/index.d.ts.map +1 -0
  11. package/lib/api/impl/beacon/state/index.d.ts.map +1 -0
  12. package/lib/api/impl/beacon/state/utils.d.ts.map +1 -0
  13. package/lib/api/impl/config/constants.d.ts +5 -0
  14. package/lib/api/impl/config/constants.d.ts.map +1 -0
  15. package/lib/api/impl/config/constants.js +6 -1
  16. package/lib/api/impl/config/constants.js.map +1 -1
  17. package/lib/api/impl/config/index.d.ts.map +1 -0
  18. package/lib/api/impl/debug/index.d.ts.map +1 -0
  19. package/lib/api/impl/debug/index.js +1 -1
  20. package/lib/api/impl/debug/index.js.map +1 -1
  21. package/lib/api/impl/errors.d.ts.map +1 -0
  22. package/lib/api/impl/errors.js +2 -0
  23. package/lib/api/impl/errors.js.map +1 -1
  24. package/lib/api/impl/events/index.d.ts.map +1 -0
  25. package/lib/api/impl/index.d.ts +3 -3
  26. package/lib/api/impl/index.d.ts.map +1 -0
  27. package/lib/api/impl/index.js +3 -3
  28. package/lib/api/impl/index.js.map +1 -1
  29. package/lib/api/impl/lightclient/index.d.ts.map +1 -0
  30. package/lib/api/impl/lodestar/index.d.ts.map +1 -0
  31. package/lib/api/impl/lodestar/index.js +2 -2
  32. package/lib/api/impl/lodestar/index.js.map +1 -1
  33. package/lib/api/impl/node/index.d.ts.map +1 -0
  34. package/lib/api/impl/node/utils.d.ts.map +1 -0
  35. package/lib/api/impl/proof/index.d.ts.map +1 -0
  36. package/lib/api/impl/types.d.ts.map +1 -0
  37. package/lib/api/impl/utils.d.ts.map +1 -0
  38. package/lib/api/impl/validator/index.d.ts.map +1 -0
  39. package/lib/api/impl/validator/index.js +22 -26
  40. package/lib/api/impl/validator/index.js.map +1 -1
  41. package/lib/api/impl/validator/utils.d.ts.map +1 -0
  42. package/lib/api/index.d.ts.map +1 -0
  43. package/lib/api/options.d.ts.map +1 -0
  44. package/lib/api/rest/activeSockets.d.ts.map +1 -0
  45. package/lib/api/rest/activeSockets.js +3 -2
  46. package/lib/api/rest/activeSockets.js.map +1 -1
  47. package/lib/api/rest/base.d.ts +1 -1
  48. package/lib/api/rest/base.d.ts.map +1 -0
  49. package/lib/api/rest/base.js +6 -2
  50. package/lib/api/rest/base.js.map +1 -1
  51. package/lib/api/rest/index.d.ts.map +1 -0
  52. package/lib/api/rest/index.js +2 -0
  53. package/lib/api/rest/index.js.map +1 -1
  54. package/lib/api/rest/swaggerUI.d.ts.map +1 -0
  55. package/lib/api/rest/swaggerUI.js +4 -2
  56. package/lib/api/rest/swaggerUI.js.map +1 -1
  57. package/lib/bun-wrappers/prometheus-gc-stats.d.ts +2 -0
  58. package/lib/bun-wrappers/prometheus-gc-stats.d.ts.map +1 -0
  59. package/lib/bun-wrappers/prometheus-gc-stats.js +8 -0
  60. package/lib/bun-wrappers/prometheus-gc-stats.js.map +1 -0
  61. package/lib/chain/ColumnReconstructionTracker.d.ts +32 -0
  62. package/lib/chain/ColumnReconstructionTracker.d.ts.map +1 -0
  63. package/lib/chain/ColumnReconstructionTracker.js +71 -0
  64. package/lib/chain/ColumnReconstructionTracker.js.map +1 -0
  65. package/lib/chain/GetBlobsTracker.d.ts +31 -0
  66. package/lib/chain/GetBlobsTracker.d.ts.map +1 -0
  67. package/lib/chain/GetBlobsTracker.js +82 -0
  68. package/lib/chain/GetBlobsTracker.js.map +1 -0
  69. package/lib/chain/archiveStore/archiveStore.d.ts.map +1 -0
  70. package/lib/chain/archiveStore/archiveStore.js +49 -38
  71. package/lib/chain/archiveStore/archiveStore.js.map +1 -1
  72. package/lib/chain/archiveStore/constants.d.ts.map +1 -0
  73. package/lib/chain/archiveStore/historicalState/getHistoricalState.d.ts.map +1 -0
  74. package/lib/chain/archiveStore/historicalState/historicalStateRegen.d.ts.map +1 -0
  75. package/lib/chain/archiveStore/historicalState/historicalStateRegen.js +3 -0
  76. package/lib/chain/archiveStore/historicalState/historicalStateRegen.js.map +1 -1
  77. package/lib/chain/archiveStore/historicalState/metrics.d.ts.map +1 -0
  78. package/lib/chain/archiveStore/historicalState/types.d.ts.map +1 -0
  79. package/lib/chain/archiveStore/historicalState/worker.d.ts.map +1 -0
  80. package/lib/chain/archiveStore/historicalState/worker.js +1 -1
  81. package/lib/chain/archiveStore/historicalState/worker.js.map +1 -1
  82. package/lib/chain/archiveStore/index.d.ts +1 -1
  83. package/lib/chain/archiveStore/index.d.ts.map +1 -0
  84. package/lib/chain/archiveStore/index.js +1 -1
  85. package/lib/chain/archiveStore/interface.d.ts.map +1 -0
  86. package/lib/chain/archiveStore/strategies/frequencyStateArchiveStrategy.d.ts.map +1 -0
  87. package/lib/chain/archiveStore/strategies/frequencyStateArchiveStrategy.js +5 -0
  88. package/lib/chain/archiveStore/strategies/frequencyStateArchiveStrategy.js.map +1 -1
  89. package/lib/chain/archiveStore/utils/archiveBlocks.d.ts.map +1 -0
  90. package/lib/chain/archiveStore/utils/archiveBlocks.js +5 -1
  91. package/lib/chain/archiveStore/utils/archiveBlocks.js.map +1 -1
  92. package/lib/chain/archiveStore/utils/pruneHistory.d.ts.map +1 -0
  93. package/lib/chain/archiveStore/utils/updateBackfillRange.d.ts.map +1 -0
  94. package/lib/chain/balancesCache.d.ts.map +1 -0
  95. package/lib/chain/balancesCache.js +1 -3
  96. package/lib/chain/balancesCache.js.map +1 -1
  97. package/lib/chain/beaconProposerCache.d.ts.map +1 -0
  98. package/lib/chain/beaconProposerCache.js +1 -0
  99. package/lib/chain/beaconProposerCache.js.map +1 -1
  100. package/lib/chain/blocks/blockInput/blockInput.d.ts +19 -7
  101. package/lib/chain/blocks/blockInput/blockInput.d.ts.map +1 -0
  102. package/lib/chain/blocks/blockInput/blockInput.js +133 -89
  103. package/lib/chain/blocks/blockInput/blockInput.js.map +1 -1
  104. package/lib/chain/blocks/blockInput/errors.d.ts.map +1 -0
  105. package/lib/chain/blocks/blockInput/index.d.ts +1 -1
  106. package/lib/chain/blocks/blockInput/index.d.ts.map +1 -0
  107. package/lib/chain/blocks/blockInput/index.js +1 -1
  108. package/lib/chain/blocks/blockInput/types.d.ts +19 -10
  109. package/lib/chain/blocks/blockInput/types.d.ts.map +1 -0
  110. package/lib/chain/blocks/blockInput/types.js +1 -0
  111. package/lib/chain/blocks/blockInput/types.js.map +1 -1
  112. package/lib/chain/blocks/blockInput/utils.d.ts +0 -4
  113. package/lib/chain/blocks/blockInput/utils.d.ts.map +1 -0
  114. package/lib/chain/blocks/blockInput/utils.js +6 -29
  115. package/lib/chain/blocks/blockInput/utils.js.map +1 -1
  116. package/lib/chain/blocks/importBlock.d.ts.map +1 -0
  117. package/lib/chain/blocks/importBlock.js +42 -37
  118. package/lib/chain/blocks/importBlock.js.map +1 -1
  119. package/lib/chain/blocks/index.d.ts +6 -5
  120. package/lib/chain/blocks/index.d.ts.map +1 -0
  121. package/lib/chain/blocks/index.js +5 -4
  122. package/lib/chain/blocks/index.js.map +1 -1
  123. package/lib/chain/blocks/types.d.ts +3 -108
  124. package/lib/chain/blocks/types.d.ts.map +1 -0
  125. package/lib/chain/blocks/types.js +0 -119
  126. package/lib/chain/blocks/types.js.map +1 -1
  127. package/lib/chain/blocks/utils/blowfishBanner.d.ts.map +1 -0
  128. package/lib/chain/blocks/utils/chainSegment.d.ts +2 -2
  129. package/lib/chain/blocks/utils/chainSegment.d.ts.map +1 -0
  130. package/lib/chain/blocks/utils/chainSegment.js +2 -2
  131. package/lib/chain/blocks/utils/chainSegment.js.map +1 -1
  132. package/lib/chain/blocks/utils/checkpoint.d.ts.map +1 -0
  133. package/lib/chain/blocks/utils/giraffeBanner.d.ts.map +1 -0
  134. package/lib/chain/blocks/utils/ownBanner.d.ts.map +1 -0
  135. package/lib/chain/blocks/utils/pandaMergeTransitionBanner.d.ts.map +1 -0
  136. package/lib/chain/blocks/utils/zebraBanner.d.ts.map +1 -0
  137. package/lib/chain/blocks/verifyBlock.d.ts +3 -3
  138. package/lib/chain/blocks/verifyBlock.d.ts.map +1 -0
  139. package/lib/chain/blocks/verifyBlock.js +15 -14
  140. package/lib/chain/blocks/verifyBlock.js.map +1 -1
  141. package/lib/chain/blocks/verifyBlocksDataAvailability.d.ts +7 -22
  142. package/lib/chain/blocks/verifyBlocksDataAvailability.d.ts.map +1 -0
  143. package/lib/chain/blocks/verifyBlocksDataAvailability.js +23 -108
  144. package/lib/chain/blocks/verifyBlocksDataAvailability.js.map +1 -1
  145. package/lib/chain/blocks/verifyBlocksExecutionPayloads.d.ts +4 -3
  146. package/lib/chain/blocks/verifyBlocksExecutionPayloads.d.ts.map +1 -0
  147. package/lib/chain/blocks/verifyBlocksExecutionPayloads.js +24 -22
  148. package/lib/chain/blocks/verifyBlocksExecutionPayloads.js.map +1 -1
  149. package/lib/chain/blocks/verifyBlocksSanityChecks.d.ts +4 -3
  150. package/lib/chain/blocks/verifyBlocksSanityChecks.d.ts.map +1 -0
  151. package/lib/chain/blocks/verifyBlocksSanityChecks.js +2 -2
  152. package/lib/chain/blocks/verifyBlocksSanityChecks.js.map +1 -1
  153. package/lib/chain/blocks/verifyBlocksSignatures.d.ts.map +1 -0
  154. package/lib/chain/blocks/verifyBlocksStateTransitionOnly.d.ts +3 -2
  155. package/lib/chain/blocks/verifyBlocksStateTransitionOnly.d.ts.map +1 -0
  156. package/lib/chain/blocks/verifyBlocksStateTransitionOnly.js +2 -2
  157. package/lib/chain/blocks/verifyBlocksStateTransitionOnly.js.map +1 -1
  158. package/lib/chain/blocks/writeBlockInputToDb.d.ts +3 -3
  159. package/lib/chain/blocks/writeBlockInputToDb.d.ts.map +1 -0
  160. package/lib/chain/blocks/writeBlockInputToDb.js +56 -67
  161. package/lib/chain/blocks/writeBlockInputToDb.js.map +1 -1
  162. package/lib/chain/bls/index.d.ts.map +1 -0
  163. package/lib/chain/bls/interface.d.ts.map +1 -0
  164. package/lib/chain/bls/maybeBatch.d.ts.map +1 -0
  165. package/lib/chain/bls/multithread/index.d.ts.map +1 -0
  166. package/lib/chain/bls/multithread/index.js +168 -163
  167. package/lib/chain/bls/multithread/index.js.map +1 -1
  168. package/lib/chain/bls/multithread/jobItem.d.ts.map +1 -0
  169. package/lib/chain/bls/multithread/poolSize.d.ts.map +1 -0
  170. package/lib/chain/bls/multithread/types.d.ts.map +1 -0
  171. package/lib/chain/bls/multithread/utils.d.ts.map +1 -0
  172. package/lib/chain/bls/multithread/worker.d.ts.map +1 -0
  173. package/lib/chain/bls/singleThread.d.ts.map +1 -0
  174. package/lib/chain/bls/singleThread.js +1 -0
  175. package/lib/chain/bls/singleThread.js.map +1 -1
  176. package/lib/chain/bls/utils.d.ts.map +1 -0
  177. package/lib/chain/chain.d.ts +13 -11
  178. package/lib/chain/chain.d.ts.map +1 -0
  179. package/lib/chain/chain.js +82 -24
  180. package/lib/chain/chain.js.map +1 -1
  181. package/lib/chain/emitter.d.ts +43 -2
  182. package/lib/chain/emitter.d.ts.map +1 -0
  183. package/lib/chain/emitter.js +18 -0
  184. package/lib/chain/emitter.js.map +1 -1
  185. package/lib/chain/errors/attestationError.d.ts.map +1 -0
  186. package/lib/chain/errors/attesterSlashingError.d.ts.map +1 -0
  187. package/lib/chain/errors/blobSidecarError.d.ts +24 -0
  188. package/lib/chain/errors/blobSidecarError.d.ts.map +1 -0
  189. package/lib/chain/errors/blobSidecarError.js +10 -0
  190. package/lib/chain/errors/blobSidecarError.js.map +1 -1
  191. package/lib/chain/errors/blockError.d.ts.map +1 -0
  192. package/lib/chain/errors/blockError.js +1 -0
  193. package/lib/chain/errors/blockError.js.map +1 -1
  194. package/lib/chain/errors/blsToExecutionChangeError.d.ts.map +1 -0
  195. package/lib/chain/errors/dataColumnSidecarError.d.ts +42 -0
  196. package/lib/chain/errors/dataColumnSidecarError.d.ts.map +1 -0
  197. package/lib/chain/errors/dataColumnSidecarError.js +14 -0
  198. package/lib/chain/errors/dataColumnSidecarError.js.map +1 -1
  199. package/lib/chain/errors/gossipValidation.d.ts.map +1 -0
  200. package/lib/chain/errors/gossipValidation.js +1 -0
  201. package/lib/chain/errors/gossipValidation.js.map +1 -1
  202. package/lib/chain/errors/index.d.ts +2 -2
  203. package/lib/chain/errors/index.d.ts.map +1 -0
  204. package/lib/chain/errors/index.js +2 -2
  205. package/lib/chain/errors/index.js.map +1 -1
  206. package/lib/chain/errors/lightClientError.d.ts.map +1 -0
  207. package/lib/chain/errors/proposerSlashingError.d.ts.map +1 -0
  208. package/lib/chain/errors/syncCommitteeError.d.ts.map +1 -0
  209. package/lib/chain/errors/voluntaryExitError.d.ts.map +1 -0
  210. package/lib/chain/forkChoice/index.d.ts.map +1 -0
  211. package/lib/chain/forkChoice/index.js.map +1 -1
  212. package/lib/chain/genesis/genesis.d.ts.map +1 -0
  213. package/lib/chain/genesis/genesis.js +16 -5
  214. package/lib/chain/genesis/genesis.js.map +1 -1
  215. package/lib/chain/genesis/interface.d.ts.map +1 -0
  216. package/lib/chain/index.d.ts +2 -2
  217. package/lib/chain/index.d.ts.map +1 -0
  218. package/lib/chain/index.js +2 -2
  219. package/lib/chain/index.js.map +1 -1
  220. package/lib/chain/initState.d.ts.map +1 -0
  221. package/lib/chain/interface.d.ts +12 -9
  222. package/lib/chain/interface.d.ts.map +1 -0
  223. package/lib/chain/interface.js.map +1 -1
  224. package/lib/chain/lightClient/index.d.ts.map +1 -0
  225. package/lib/chain/lightClient/index.js +16 -9
  226. package/lib/chain/lightClient/index.js.map +1 -1
  227. package/lib/chain/lightClient/proofs.d.ts.map +1 -0
  228. package/lib/chain/lightClient/proofs.js.map +1 -1
  229. package/lib/chain/lightClient/types.d.ts.map +1 -0
  230. package/lib/chain/opPools/aggregatedAttestationPool.d.ts.map +1 -0
  231. package/lib/chain/opPools/aggregatedAttestationPool.js +14 -9
  232. package/lib/chain/opPools/aggregatedAttestationPool.js.map +1 -1
  233. package/lib/chain/opPools/attestationPool.d.ts +2 -3
  234. package/lib/chain/opPools/attestationPool.d.ts.map +1 -0
  235. package/lib/chain/opPools/attestationPool.js +10 -7
  236. package/lib/chain/opPools/attestationPool.js.map +1 -1
  237. package/lib/chain/opPools/index.d.ts +1 -1
  238. package/lib/chain/opPools/index.d.ts.map +1 -0
  239. package/lib/chain/opPools/index.js +1 -1
  240. package/lib/chain/opPools/index.js.map +1 -1
  241. package/lib/chain/opPools/opPool.d.ts.map +1 -0
  242. package/lib/chain/opPools/opPool.js +10 -12
  243. package/lib/chain/opPools/opPool.js.map +1 -1
  244. package/lib/chain/opPools/syncCommitteeMessagePool.d.ts +3 -2
  245. package/lib/chain/opPools/syncCommitteeMessagePool.d.ts.map +1 -0
  246. package/lib/chain/opPools/syncCommitteeMessagePool.js +14 -10
  247. package/lib/chain/opPools/syncCommitteeMessagePool.js.map +1 -1
  248. package/lib/chain/opPools/syncContributionAndProofPool.d.ts.map +1 -0
  249. package/lib/chain/opPools/syncContributionAndProofPool.js +5 -2
  250. package/lib/chain/opPools/syncContributionAndProofPool.js.map +1 -1
  251. package/lib/chain/opPools/types.d.ts +1 -1
  252. package/lib/chain/opPools/types.d.ts.map +1 -0
  253. package/lib/chain/opPools/types.js +1 -1
  254. package/lib/chain/opPools/types.js.map +1 -1
  255. package/lib/chain/opPools/utils.d.ts.map +1 -0
  256. package/lib/chain/options.d.ts.map +1 -0
  257. package/lib/chain/options.js +1 -1
  258. package/lib/chain/options.js.map +1 -1
  259. package/lib/chain/prepareNextSlot.d.ts +3 -3
  260. package/lib/chain/prepareNextSlot.d.ts.map +1 -0
  261. package/lib/chain/prepareNextSlot.js +145 -140
  262. package/lib/chain/prepareNextSlot.js.map +1 -1
  263. package/lib/chain/produceBlock/computeNewStateRoot.d.ts.map +1 -0
  264. package/lib/chain/produceBlock/index.d.ts.map +1 -0
  265. package/lib/chain/produceBlock/produceBlockBody.d.ts +1 -1
  266. package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -0
  267. package/lib/chain/produceBlock/produceBlockBody.js +3 -10
  268. package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
  269. package/lib/chain/produceBlock/validateBlobsAndKzgCommitments.d.ts.map +1 -0
  270. package/lib/chain/regen/errors.d.ts.map +1 -0
  271. package/lib/chain/regen/errors.js +1 -0
  272. package/lib/chain/regen/errors.js.map +1 -1
  273. package/lib/chain/regen/index.d.ts +1 -1
  274. package/lib/chain/regen/index.d.ts.map +1 -0
  275. package/lib/chain/regen/index.js +1 -1
  276. package/lib/chain/regen/index.js.map +1 -1
  277. package/lib/chain/regen/interface.d.ts.map +1 -0
  278. package/lib/chain/regen/queued.d.ts.map +1 -0
  279. package/lib/chain/regen/queued.js +35 -28
  280. package/lib/chain/regen/queued.js.map +1 -1
  281. package/lib/chain/regen/regen.d.ts.map +1 -0
  282. package/lib/chain/regen/regen.js +1 -0
  283. package/lib/chain/regen/regen.js.map +1 -1
  284. package/lib/chain/reprocess.d.ts.map +1 -0
  285. package/lib/chain/reprocess.js +3 -1
  286. package/lib/chain/reprocess.js.map +1 -1
  287. package/lib/chain/rewards/attestationsRewards.d.ts.map +1 -0
  288. package/lib/chain/rewards/blockRewards.d.ts.map +1 -0
  289. package/lib/chain/rewards/syncCommitteeRewards.d.ts.map +1 -0
  290. package/lib/chain/seenCache/index.d.ts +1 -1
  291. package/lib/chain/seenCache/index.d.ts.map +1 -0
  292. package/lib/chain/seenCache/index.js +1 -1
  293. package/lib/chain/seenCache/index.js.map +1 -1
  294. package/lib/chain/seenCache/seenAggregateAndProof.d.ts.map +1 -0
  295. package/lib/chain/seenCache/seenAggregateAndProof.js +7 -6
  296. package/lib/chain/seenCache/seenAggregateAndProof.js.map +1 -1
  297. package/lib/chain/seenCache/seenAttestationData.d.ts.map +1 -0
  298. package/lib/chain/seenCache/seenAttestationData.js +5 -2
  299. package/lib/chain/seenCache/seenAttestationData.js.map +1 -1
  300. package/lib/chain/seenCache/seenAttesters.d.ts.map +1 -0
  301. package/lib/chain/seenCache/seenAttesters.js +2 -4
  302. package/lib/chain/seenCache/seenAttesters.js.map +1 -1
  303. package/lib/chain/seenCache/seenBlockAttesters.d.ts.map +1 -0
  304. package/lib/chain/seenCache/seenBlockProposers.d.ts.map +1 -0
  305. package/lib/chain/seenCache/seenBlockProposers.js +2 -4
  306. package/lib/chain/seenCache/seenBlockProposers.js.map +1 -1
  307. package/lib/chain/seenCache/seenCommittee.d.ts.map +1 -0
  308. package/lib/chain/seenCache/seenCommittee.js +1 -3
  309. package/lib/chain/seenCache/seenCommittee.js.map +1 -1
  310. package/lib/chain/seenCache/seenCommitteeContribution.d.ts.map +1 -0
  311. package/lib/chain/seenCache/seenCommitteeContribution.js +3 -2
  312. package/lib/chain/seenCache/seenCommitteeContribution.js.map +1 -1
  313. package/lib/chain/seenCache/seenGossipBlockInput.d.ts +74 -78
  314. package/lib/chain/seenCache/seenGossipBlockInput.d.ts.map +1 -0
  315. package/lib/chain/seenCache/seenGossipBlockInput.js +235 -369
  316. package/lib/chain/seenCache/seenGossipBlockInput.js.map +1 -1
  317. package/lib/chain/serializeState.d.ts.map +1 -0
  318. package/lib/chain/shufflingCache.d.ts.map +1 -0
  319. package/lib/chain/shufflingCache.js +5 -2
  320. package/lib/chain/shufflingCache.js.map +1 -1
  321. package/lib/chain/stateCache/blockStateCacheImpl.d.ts.map +1 -0
  322. package/lib/chain/stateCache/blockStateCacheImpl.js +13 -7
  323. package/lib/chain/stateCache/blockStateCacheImpl.js.map +1 -1
  324. package/lib/chain/stateCache/datastore/db.d.ts.map +1 -0
  325. package/lib/chain/stateCache/datastore/db.js +1 -0
  326. package/lib/chain/stateCache/datastore/db.js.map +1 -1
  327. package/lib/chain/stateCache/datastore/file.d.ts.map +1 -0
  328. package/lib/chain/stateCache/datastore/file.js +1 -0
  329. package/lib/chain/stateCache/datastore/file.js.map +1 -1
  330. package/lib/chain/stateCache/datastore/index.d.ts +1 -1
  331. package/lib/chain/stateCache/datastore/index.d.ts.map +1 -0
  332. package/lib/chain/stateCache/datastore/index.js +1 -1
  333. package/lib/chain/stateCache/datastore/index.js.map +1 -1
  334. package/lib/chain/stateCache/datastore/types.d.ts.map +1 -0
  335. package/lib/chain/stateCache/fifoBlockStateCache.d.ts.map +1 -0
  336. package/lib/chain/stateCache/fifoBlockStateCache.js +10 -0
  337. package/lib/chain/stateCache/fifoBlockStateCache.js.map +1 -1
  338. package/lib/chain/stateCache/inMemoryCheckpointsCache.d.ts.map +1 -0
  339. package/lib/chain/stateCache/inMemoryCheckpointsCache.js +10 -4
  340. package/lib/chain/stateCache/inMemoryCheckpointsCache.js.map +1 -1
  341. package/lib/chain/stateCache/index.d.ts +1 -1
  342. package/lib/chain/stateCache/index.d.ts.map +1 -0
  343. package/lib/chain/stateCache/index.js +1 -1
  344. package/lib/chain/stateCache/index.js.map +1 -1
  345. package/lib/chain/stateCache/mapMetrics.d.ts.map +1 -0
  346. package/lib/chain/stateCache/mapMetrics.js +4 -4
  347. package/lib/chain/stateCache/mapMetrics.js.map +1 -1
  348. package/lib/chain/stateCache/persistentCheckpointsCache.d.ts.map +1 -0
  349. package/lib/chain/stateCache/persistentCheckpointsCache.js +23 -14
  350. package/lib/chain/stateCache/persistentCheckpointsCache.js.map +1 -1
  351. package/lib/chain/stateCache/types.d.ts.map +1 -0
  352. package/lib/chain/validation/aggregateAndProof.d.ts.map +1 -0
  353. package/lib/chain/validation/attestation.d.ts.map +1 -0
  354. package/lib/chain/validation/attesterSlashing.d.ts.map +1 -0
  355. package/lib/chain/validation/blobSidecar.d.ts +8 -3
  356. package/lib/chain/validation/blobSidecar.d.ts.map +1 -0
  357. package/lib/chain/validation/blobSidecar.js +73 -31
  358. package/lib/chain/validation/blobSidecar.js.map +1 -1
  359. package/lib/chain/validation/block.d.ts.map +1 -0
  360. package/lib/chain/validation/blsToExecutionChange.d.ts.map +1 -0
  361. package/lib/chain/validation/dataColumnSidecar.d.ts +7 -9
  362. package/lib/chain/validation/dataColumnSidecar.d.ts.map +1 -0
  363. package/lib/chain/validation/dataColumnSidecar.js +95 -57
  364. package/lib/chain/validation/dataColumnSidecar.js.map +1 -1
  365. package/lib/chain/validation/index.d.ts +1 -1
  366. package/lib/chain/validation/index.d.ts.map +1 -0
  367. package/lib/chain/validation/index.js +1 -1
  368. package/lib/chain/validation/index.js.map +1 -1
  369. package/lib/chain/validation/lightClientFinalityUpdate.d.ts.map +1 -0
  370. package/lib/chain/validation/lightClientFinalityUpdate.js +4 -3
  371. package/lib/chain/validation/lightClientFinalityUpdate.js.map +1 -1
  372. package/lib/chain/validation/lightClientOptimisticUpdate.d.ts +6 -4
  373. package/lib/chain/validation/lightClientOptimisticUpdate.d.ts.map +1 -0
  374. package/lib/chain/validation/lightClientOptimisticUpdate.js +11 -11
  375. package/lib/chain/validation/lightClientOptimisticUpdate.js.map +1 -1
  376. package/lib/chain/validation/proposerSlashing.d.ts.map +1 -0
  377. package/lib/chain/validation/signatureSets/aggregateAndProof.d.ts +1 -2
  378. package/lib/chain/validation/signatureSets/aggregateAndProof.d.ts.map +1 -0
  379. package/lib/chain/validation/signatureSets/aggregateAndProof.js.map +1 -1
  380. package/lib/chain/validation/signatureSets/contributionAndProof.d.ts.map +1 -0
  381. package/lib/chain/validation/signatureSets/index.d.ts.map +1 -0
  382. package/lib/chain/validation/signatureSets/selectionProof.d.ts.map +1 -0
  383. package/lib/chain/validation/signatureSets/syncCommittee.d.ts.map +1 -0
  384. package/lib/chain/validation/signatureSets/syncCommitteeContribution.d.ts.map +1 -0
  385. package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.d.ts.map +1 -0
  386. package/lib/chain/validation/syncCommittee.d.ts.map +1 -0
  387. package/lib/chain/validation/syncCommitteeContributionAndProof.d.ts.map +1 -0
  388. package/lib/chain/validation/voluntaryExit.d.ts.map +1 -0
  389. package/lib/chain/validatorMonitor.d.ts +1 -3
  390. package/lib/chain/validatorMonitor.d.ts.map +1 -0
  391. package/lib/chain/validatorMonitor.js +23 -16
  392. package/lib/chain/validatorMonitor.js.map +1 -1
  393. package/lib/constants/constants.d.ts.map +1 -0
  394. package/lib/constants/index.d.ts.map +1 -0
  395. package/lib/constants/network.d.ts.map +1 -0
  396. package/lib/db/beacon.d.ts.map +1 -0
  397. package/lib/db/beacon.js +24 -0
  398. package/lib/db/beacon.js.map +1 -1
  399. package/lib/db/buckets.d.ts +4 -4
  400. package/lib/db/buckets.d.ts.map +1 -0
  401. package/lib/db/buckets.js +4 -4
  402. package/lib/db/buckets.js.map +1 -1
  403. package/lib/db/index.d.ts +1 -1
  404. package/lib/db/index.d.ts.map +1 -0
  405. package/lib/db/index.js.map +1 -1
  406. package/lib/db/interface.d.ts.map +1 -0
  407. package/lib/db/options.d.ts.map +1 -0
  408. package/lib/db/repositories/attesterSlashing.d.ts.map +1 -0
  409. package/lib/db/repositories/backfilledRanges.d.ts.map +1 -0
  410. package/lib/db/repositories/blobSidecars.d.ts.map +1 -0
  411. package/lib/db/repositories/blobSidecars.js +1 -1
  412. package/lib/db/repositories/blobSidecars.js.map +1 -1
  413. package/lib/db/repositories/blobSidecarsArchive.d.ts.map +1 -0
  414. package/lib/db/repositories/blobSidecarsArchive.js +1 -1
  415. package/lib/db/repositories/blobSidecarsArchive.js.map +1 -1
  416. package/lib/db/repositories/block.d.ts.map +1 -0
  417. package/lib/db/repositories/blockArchive.d.ts.map +1 -0
  418. package/lib/db/repositories/blockArchive.js +2 -3
  419. package/lib/db/repositories/blockArchive.js.map +1 -1
  420. package/lib/db/repositories/blockArchiveIndex.d.ts +2 -2
  421. package/lib/db/repositories/blockArchiveIndex.d.ts.map +1 -0
  422. package/lib/db/repositories/blsToExecutionChange.d.ts.map +1 -0
  423. package/lib/db/repositories/checkpointState.d.ts.map +1 -0
  424. package/lib/db/repositories/dataColumnSidecar.d.ts.map +1 -0
  425. package/lib/db/repositories/dataColumnSidecar.js +2 -2
  426. package/lib/db/repositories/dataColumnSidecar.js.map +1 -1
  427. package/lib/db/repositories/dataColumnSidecarArchive.d.ts.map +1 -0
  428. package/lib/db/repositories/dataColumnSidecarArchive.js +2 -2
  429. package/lib/db/repositories/dataColumnSidecarArchive.js.map +1 -1
  430. package/lib/db/repositories/depositDataRoot.d.ts.map +1 -0
  431. package/lib/db/repositories/depositDataRoot.js +1 -0
  432. package/lib/db/repositories/depositDataRoot.js.map +1 -1
  433. package/lib/db/repositories/depositEvent.d.ts.map +1 -0
  434. package/lib/db/repositories/eth1Data.d.ts.map +1 -0
  435. package/lib/db/repositories/index.d.ts +10 -10
  436. package/lib/db/repositories/index.d.ts.map +1 -0
  437. package/lib/db/repositories/index.js +9 -9
  438. package/lib/db/repositories/index.js.map +1 -1
  439. package/lib/db/repositories/lightclientBestUpdate.d.ts.map +1 -0
  440. package/lib/db/repositories/lightclientCheckpointHeader.d.ts.map +1 -0
  441. package/lib/db/repositories/lightclientSyncCommittee.d.ts.map +1 -0
  442. package/lib/db/repositories/lightclientSyncCommitteeWitness.d.ts.map +1 -0
  443. package/lib/db/repositories/proposerSlashing.d.ts.map +1 -0
  444. package/lib/db/repositories/stateArchive.d.ts.map +1 -0
  445. package/lib/db/repositories/stateArchiveIndex.d.ts.map +1 -0
  446. package/lib/db/repositories/voluntaryExit.d.ts.map +1 -0
  447. package/lib/db/single/index.d.ts.map +1 -0
  448. package/lib/db/single/preGenesisState.d.ts.map +1 -0
  449. package/lib/db/single/preGenesisState.js +6 -0
  450. package/lib/db/single/preGenesisState.js.map +1 -1
  451. package/lib/db/single/preGenesisStateLastProcessedBlock.d.ts.map +1 -0
  452. package/lib/db/single/preGenesisStateLastProcessedBlock.js +5 -0
  453. package/lib/db/single/preGenesisStateLastProcessedBlock.js.map +1 -1
  454. package/lib/eth1/errors.d.ts.map +1 -0
  455. package/lib/eth1/eth1DataCache.d.ts.map +1 -0
  456. package/lib/eth1/eth1DataCache.js +2 -0
  457. package/lib/eth1/eth1DataCache.js.map +1 -1
  458. package/lib/eth1/eth1DepositDataTracker.d.ts.map +1 -0
  459. package/lib/eth1/eth1DepositDataTracker.js +18 -5
  460. package/lib/eth1/eth1DepositDataTracker.js.map +1 -1
  461. package/lib/eth1/eth1DepositsCache.d.ts.map +1 -0
  462. package/lib/eth1/eth1DepositsCache.js +3 -0
  463. package/lib/eth1/eth1DepositsCache.js.map +1 -1
  464. package/lib/eth1/eth1MergeBlockTracker.d.ts.map +1 -0
  465. package/lib/eth1/eth1MergeBlockTracker.js +10 -4
  466. package/lib/eth1/eth1MergeBlockTracker.js.map +1 -1
  467. package/lib/eth1/index.d.ts.map +1 -0
  468. package/lib/eth1/index.js +2 -0
  469. package/lib/eth1/index.js.map +1 -1
  470. package/lib/eth1/interface.d.ts.map +1 -0
  471. package/lib/eth1/options.d.ts.map +1 -0
  472. package/lib/eth1/provider/eth1Provider.d.ts +1 -2
  473. package/lib/eth1/provider/eth1Provider.d.ts.map +1 -0
  474. package/lib/eth1/provider/eth1Provider.js +6 -2
  475. package/lib/eth1/provider/eth1Provider.js.map +1 -1
  476. package/lib/eth1/provider/jsonRpcHttpClient.d.ts +1 -1
  477. package/lib/eth1/provider/jsonRpcHttpClient.d.ts.map +1 -0
  478. package/lib/eth1/provider/jsonRpcHttpClient.js +16 -2
  479. package/lib/eth1/provider/jsonRpcHttpClient.js.map +1 -1
  480. package/lib/eth1/provider/jwt.d.ts.map +1 -0
  481. package/lib/eth1/provider/jwt.js.map +1 -1
  482. package/lib/eth1/provider/utils.d.ts +5 -0
  483. package/lib/eth1/provider/utils.d.ts.map +1 -0
  484. package/lib/eth1/provider/utils.js +9 -1
  485. package/lib/eth1/provider/utils.js.map +1 -1
  486. package/lib/eth1/stream.d.ts.map +1 -0
  487. package/lib/eth1/utils/depositContract.d.ts.map +1 -0
  488. package/lib/eth1/utils/deposits.d.ts.map +1 -0
  489. package/lib/eth1/utils/deposits.js.map +1 -1
  490. package/lib/eth1/utils/eth1Data.d.ts.map +1 -0
  491. package/lib/eth1/utils/eth1DepositEvent.d.ts.map +1 -0
  492. package/lib/eth1/utils/eth1Vote.d.ts.map +1 -0
  493. package/lib/eth1/utils/groupDepositEventsByBlock.d.ts.map +1 -0
  494. package/lib/eth1/utils/optimizeNextBlockDiffForGenesis.d.ts.map +1 -0
  495. package/lib/execution/builder/cache.d.ts.map +1 -0
  496. package/lib/execution/builder/cache.js +6 -0
  497. package/lib/execution/builder/cache.js.map +1 -1
  498. package/lib/execution/builder/http.d.ts.map +1 -0
  499. package/lib/execution/builder/http.js +14 -8
  500. package/lib/execution/builder/http.js.map +1 -1
  501. package/lib/execution/builder/index.d.ts.map +1 -0
  502. package/lib/execution/builder/index.js.map +1 -1
  503. package/lib/execution/builder/interface.d.ts.map +1 -0
  504. package/lib/execution/builder/utils.d.ts.map +1 -0
  505. package/lib/execution/engine/disabled.d.ts.map +1 -0
  506. package/lib/execution/engine/disabled.js +2 -4
  507. package/lib/execution/engine/disabled.js.map +1 -1
  508. package/lib/execution/engine/http.d.ts +2 -2
  509. package/lib/execution/engine/http.d.ts.map +1 -0
  510. package/lib/execution/engine/http.js +43 -11
  511. package/lib/execution/engine/http.js.map +1 -1
  512. package/lib/execution/engine/index.d.ts.map +1 -0
  513. package/lib/execution/engine/interface.d.ts +2 -2
  514. package/lib/execution/engine/interface.d.ts.map +1 -0
  515. package/lib/execution/engine/interface.js.map +1 -1
  516. package/lib/execution/engine/mock.d.ts +1 -0
  517. package/lib/execution/engine/mock.d.ts.map +1 -0
  518. package/lib/execution/engine/mock.js +16 -12
  519. package/lib/execution/engine/mock.js.map +1 -1
  520. package/lib/execution/engine/payloadIdCache.d.ts.map +1 -0
  521. package/lib/execution/engine/payloadIdCache.js +1 -3
  522. package/lib/execution/engine/payloadIdCache.js.map +1 -1
  523. package/lib/execution/engine/types.d.ts +5 -1
  524. package/lib/execution/engine/types.d.ts.map +1 -0
  525. package/lib/execution/engine/types.js +37 -8
  526. package/lib/execution/engine/types.js.map +1 -1
  527. package/lib/execution/engine/utils.d.ts.map +1 -0
  528. package/lib/execution/engine/utils.js +3 -3
  529. package/lib/execution/engine/utils.js.map +1 -1
  530. package/lib/execution/index.d.ts +2 -2
  531. package/lib/execution/index.d.ts.map +1 -0
  532. package/lib/execution/index.js +2 -2
  533. package/lib/execution/index.js.map +1 -1
  534. package/lib/index.d.ts +6 -6
  535. package/lib/index.d.ts.map +1 -0
  536. package/lib/index.js +5 -5
  537. package/lib/index.js.map +1 -1
  538. package/lib/metrics/index.d.ts +1 -1
  539. package/lib/metrics/index.d.ts.map +1 -0
  540. package/lib/metrics/index.js +1 -1
  541. package/lib/metrics/index.js.map +1 -1
  542. package/lib/metrics/metrics/beacon.d.ts +11 -5
  543. package/lib/metrics/metrics/beacon.d.ts.map +1 -0
  544. package/lib/metrics/metrics/beacon.js +40 -20
  545. package/lib/metrics/metrics/beacon.js.map +1 -1
  546. package/lib/metrics/metrics/lodestar.d.ts +56 -14
  547. package/lib/metrics/metrics/lodestar.d.ts.map +1 -0
  548. package/lib/metrics/metrics/lodestar.js +87 -10
  549. package/lib/metrics/metrics/lodestar.js.map +1 -1
  550. package/lib/metrics/metrics.d.ts +1 -1
  551. package/lib/metrics/metrics.d.ts.map +1 -0
  552. package/lib/metrics/metrics.js.map +1 -1
  553. package/lib/metrics/nodeJsMetrics.d.ts.map +1 -0
  554. package/lib/metrics/nodeJsMetrics.js +1 -1
  555. package/lib/metrics/nodeJsMetrics.js.map +1 -1
  556. package/lib/metrics/options.d.ts.map +1 -0
  557. package/lib/metrics/server/http.d.ts +1 -1
  558. package/lib/metrics/server/http.d.ts.map +1 -0
  559. package/lib/metrics/server/index.d.ts.map +1 -0
  560. package/lib/metrics/utils/avgMinMax.d.ts +1 -1
  561. package/lib/metrics/utils/avgMinMax.d.ts.map +1 -0
  562. package/lib/metrics/utils/avgMinMax.js +10 -6
  563. package/lib/metrics/utils/avgMinMax.js.map +1 -1
  564. package/lib/metrics/utils/gauge.d.ts +1 -1
  565. package/lib/metrics/utils/gauge.d.ts.map +1 -0
  566. package/lib/metrics/utils/gauge.js +1 -4
  567. package/lib/metrics/utils/gauge.js.map +1 -1
  568. package/lib/metrics/utils/registryMetricCreator.d.ts +1 -1
  569. package/lib/metrics/utils/registryMetricCreator.d.ts.map +1 -0
  570. package/lib/metrics/utils/registryMetricCreator.js.map +1 -1
  571. package/lib/monitoring/clientStats.d.ts.map +1 -0
  572. package/lib/monitoring/index.d.ts.map +1 -0
  573. package/lib/monitoring/options.d.ts.map +1 -0
  574. package/lib/monitoring/properties.d.ts.map +1 -0
  575. package/lib/monitoring/properties.js +4 -0
  576. package/lib/monitoring/properties.js.map +1 -1
  577. package/lib/monitoring/service.d.ts.map +1 -0
  578. package/lib/monitoring/service.js +13 -1
  579. package/lib/monitoring/service.js.map +1 -1
  580. package/lib/monitoring/system.d.ts.map +1 -0
  581. package/lib/monitoring/system.js +25 -27
  582. package/lib/monitoring/system.js.map +1 -1
  583. package/lib/monitoring/types.d.ts.map +1 -0
  584. package/lib/network/core/events.d.ts.map +1 -0
  585. package/lib/network/core/index.d.ts.map +1 -0
  586. package/lib/network/core/metrics.d.ts.map +1 -0
  587. package/lib/network/core/networkCore.d.ts +2 -2
  588. package/lib/network/core/networkCore.d.ts.map +1 -0
  589. package/lib/network/core/networkCore.js +67 -50
  590. package/lib/network/core/networkCore.js.map +1 -1
  591. package/lib/network/core/networkCoreWorker.d.ts.map +1 -0
  592. package/lib/network/core/networkCoreWorker.js +1 -1
  593. package/lib/network/core/networkCoreWorker.js.map +1 -1
  594. package/lib/network/core/networkCoreWorkerHandler.d.ts +2 -2
  595. package/lib/network/core/networkCoreWorkerHandler.d.ts.map +1 -0
  596. package/lib/network/core/networkCoreWorkerHandler.js +14 -5
  597. package/lib/network/core/networkCoreWorkerHandler.js.map +1 -1
  598. package/lib/network/core/types.d.ts.map +1 -0
  599. package/lib/network/discv5/index.d.ts +2 -2
  600. package/lib/network/discv5/index.d.ts.map +1 -0
  601. package/lib/network/discv5/index.js +9 -3
  602. package/lib/network/discv5/index.js.map +1 -1
  603. package/lib/network/discv5/types.d.ts.map +1 -0
  604. package/lib/network/discv5/utils.d.ts.map +1 -0
  605. package/lib/network/discv5/worker.d.ts.map +1 -0
  606. package/lib/network/discv5/worker.js +3 -3
  607. package/lib/network/discv5/worker.js.map +1 -1
  608. package/lib/network/events.d.ts +2 -18
  609. package/lib/network/events.d.ts.map +1 -0
  610. package/lib/network/events.js +0 -7
  611. package/lib/network/events.js.map +1 -1
  612. package/lib/network/forks.d.ts.map +1 -0
  613. package/lib/network/gossip/constants.d.ts.map +1 -0
  614. package/lib/network/gossip/encoding.d.ts +1 -1
  615. package/lib/network/gossip/encoding.d.ts.map +1 -0
  616. package/lib/network/gossip/encoding.js +4 -2
  617. package/lib/network/gossip/encoding.js.map +1 -1
  618. package/lib/network/gossip/errors.d.ts.map +1 -0
  619. package/lib/network/gossip/errors.js +1 -0
  620. package/lib/network/gossip/errors.js.map +1 -1
  621. package/lib/network/gossip/gossipsub.d.ts +2 -1
  622. package/lib/network/gossip/gossipsub.d.ts.map +1 -0
  623. package/lib/network/gossip/gossipsub.js +44 -18
  624. package/lib/network/gossip/gossipsub.js.map +1 -1
  625. package/lib/network/gossip/index.d.ts +2 -2
  626. package/lib/network/gossip/index.d.ts.map +1 -0
  627. package/lib/network/gossip/index.js +2 -2
  628. package/lib/network/gossip/index.js.map +1 -1
  629. package/lib/network/gossip/interface.d.ts +2 -2
  630. package/lib/network/gossip/interface.d.ts.map +1 -0
  631. package/lib/network/gossip/metrics.d.ts +15 -7
  632. package/lib/network/gossip/metrics.d.ts.map +1 -0
  633. package/lib/network/gossip/metrics.js +16 -6
  634. package/lib/network/gossip/metrics.js.map +1 -1
  635. package/lib/network/gossip/scoringParameters.d.ts.map +1 -0
  636. package/lib/network/gossip/scoringParameters.js +4 -4
  637. package/lib/network/gossip/scoringParameters.js.map +1 -1
  638. package/lib/network/gossip/topic.d.ts +125 -105
  639. package/lib/network/gossip/topic.d.ts.map +1 -0
  640. package/lib/network/gossip/topic.js +2 -1
  641. package/lib/network/gossip/topic.js.map +1 -1
  642. package/lib/network/index.d.ts +3 -3
  643. package/lib/network/index.d.ts.map +1 -0
  644. package/lib/network/index.js +3 -3
  645. package/lib/network/index.js.map +1 -1
  646. package/lib/network/interface.d.ts +3 -2
  647. package/lib/network/interface.d.ts.map +1 -0
  648. package/lib/network/libp2p/error.d.ts.map +1 -0
  649. package/lib/network/libp2p/index.d.ts.map +1 -0
  650. package/lib/network/libp2p/index.js +11 -3
  651. package/lib/network/libp2p/index.js.map +1 -1
  652. package/lib/network/metadata.d.ts.map +1 -0
  653. package/lib/network/metadata.js +6 -1
  654. package/lib/network/metadata.js.map +1 -1
  655. package/lib/network/network.d.ts +5 -3
  656. package/lib/network/network.d.ts.map +1 -0
  657. package/lib/network/network.js +92 -76
  658. package/lib/network/network.js.map +1 -1
  659. package/lib/network/networkConfig.d.ts.map +1 -0
  660. package/lib/network/options.d.ts.map +1 -0
  661. package/lib/network/options.js +1 -1
  662. package/lib/network/options.js.map +1 -1
  663. package/lib/network/peers/client.d.ts.map +1 -0
  664. package/lib/network/peers/datastore.d.ts +2 -2
  665. package/lib/network/peers/datastore.d.ts.map +1 -0
  666. package/lib/network/peers/datastore.js +10 -4
  667. package/lib/network/peers/datastore.js.map +1 -1
  668. package/lib/network/peers/discover.d.ts.map +1 -0
  669. package/lib/network/peers/discover.js +75 -66
  670. package/lib/network/peers/discover.js.map +1 -1
  671. package/lib/network/peers/index.d.ts.map +1 -0
  672. package/lib/network/peers/peerManager.d.ts.map +1 -0
  673. package/lib/network/peers/peerManager.js +156 -131
  674. package/lib/network/peers/peerManager.js.map +1 -1
  675. package/lib/network/peers/peersData.d.ts +1 -1
  676. package/lib/network/peers/peersData.d.ts.map +1 -0
  677. package/lib/network/peers/peersData.js +1 -3
  678. package/lib/network/peers/peersData.js.map +1 -1
  679. package/lib/network/peers/score/constants.d.ts.map +1 -0
  680. package/lib/network/peers/score/index.d.ts +1 -1
  681. package/lib/network/peers/score/index.d.ts.map +1 -0
  682. package/lib/network/peers/score/index.js +1 -1
  683. package/lib/network/peers/score/index.js.map +1 -1
  684. package/lib/network/peers/score/interface.d.ts.map +1 -0
  685. package/lib/network/peers/score/score.d.ts.map +1 -0
  686. package/lib/network/peers/score/score.js +6 -0
  687. package/lib/network/peers/score/score.js.map +1 -1
  688. package/lib/network/peers/score/store.d.ts.map +1 -0
  689. package/lib/network/peers/score/store.js +3 -0
  690. package/lib/network/peers/score/store.js.map +1 -1
  691. package/lib/network/peers/score/utils.d.ts.map +1 -0
  692. package/lib/network/peers/utils/assertPeerRelevance.d.ts.map +1 -0
  693. package/lib/network/peers/utils/enrSubnetsDeserialize.d.ts.map +1 -0
  694. package/lib/network/peers/utils/getConnectedPeerIds.d.ts.map +1 -0
  695. package/lib/network/peers/utils/index.d.ts.map +1 -0
  696. package/lib/network/peers/utils/prioritizePeers.d.ts.map +1 -0
  697. package/lib/network/peers/utils/prioritizePeers.js.map +1 -1
  698. package/lib/network/peers/utils/subnetMap.d.ts.map +1 -0
  699. package/lib/network/peers/utils/subnetMap.js +2 -4
  700. package/lib/network/peers/utils/subnetMap.js.map +1 -1
  701. package/lib/network/processor/aggregatorTracker.d.ts.map +1 -0
  702. package/lib/network/processor/aggregatorTracker.js +1 -3
  703. package/lib/network/processor/aggregatorTracker.js.map +1 -1
  704. package/lib/network/processor/extractSlotRootFns.d.ts.map +1 -0
  705. package/lib/network/processor/gossipHandlers.d.ts.map +1 -0
  706. package/lib/network/processor/gossipHandlers.js +145 -165
  707. package/lib/network/processor/gossipHandlers.js.map +1 -1
  708. package/lib/network/processor/gossipQueues/index.d.ts.map +1 -0
  709. package/lib/network/processor/gossipQueues/indexed.d.ts.map +1 -0
  710. package/lib/network/processor/gossipQueues/indexed.js +11 -9
  711. package/lib/network/processor/gossipQueues/indexed.js.map +1 -1
  712. package/lib/network/processor/gossipQueues/linear.d.ts.map +1 -0
  713. package/lib/network/processor/gossipQueues/linear.js +9 -8
  714. package/lib/network/processor/gossipQueues/linear.js.map +1 -1
  715. package/lib/network/processor/gossipQueues/types.d.ts.map +1 -0
  716. package/lib/network/processor/gossipValidatorFn.d.ts.map +1 -0
  717. package/lib/network/processor/index.d.ts +2 -1
  718. package/lib/network/processor/index.d.ts.map +1 -0
  719. package/lib/network/processor/index.js +21 -8
  720. package/lib/network/processor/index.js.map +1 -1
  721. package/lib/network/processor/types.d.ts.map +1 -0
  722. package/lib/network/reqresp/ReqRespBeaconNode.d.ts +1 -1
  723. package/lib/network/reqresp/ReqRespBeaconNode.d.ts.map +1 -0
  724. package/lib/network/reqresp/ReqRespBeaconNode.js +11 -2
  725. package/lib/network/reqresp/ReqRespBeaconNode.js.map +1 -1
  726. package/lib/network/reqresp/handlers/beaconBlocksByRange.d.ts.map +1 -0
  727. package/lib/network/reqresp/handlers/beaconBlocksByRoot.d.ts.map +1 -0
  728. package/lib/network/reqresp/handlers/blobSidecarsByRange.d.ts.map +1 -0
  729. package/lib/network/reqresp/handlers/blobSidecarsByRoot.d.ts.map +1 -0
  730. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.d.ts.map +1 -0
  731. package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.d.ts.map +1 -0
  732. package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.js.map +1 -1
  733. package/lib/network/reqresp/handlers/index.d.ts.map +1 -0
  734. package/lib/network/reqresp/handlers/lightClientBootstrap.d.ts.map +1 -0
  735. package/lib/network/reqresp/handlers/lightClientFinalityUpdate.d.ts.map +1 -0
  736. package/lib/network/reqresp/handlers/lightClientOptimisticUpdate.d.ts.map +1 -0
  737. package/lib/network/reqresp/handlers/lightClientUpdatesByRange.d.ts.map +1 -0
  738. package/lib/network/reqresp/index.d.ts +1 -3
  739. package/lib/network/reqresp/index.d.ts.map +1 -0
  740. package/lib/network/reqresp/index.js +1 -3
  741. package/lib/network/reqresp/index.js.map +1 -1
  742. package/lib/network/reqresp/interface.d.ts.map +1 -0
  743. package/lib/network/reqresp/protocols.d.ts.map +1 -0
  744. package/lib/network/reqresp/rateLimit.d.ts.map +1 -0
  745. package/lib/network/reqresp/rateLimit.js +11 -5
  746. package/lib/network/reqresp/rateLimit.js.map +1 -1
  747. package/lib/network/reqresp/score.d.ts.map +1 -0
  748. package/lib/network/reqresp/types.d.ts.map +1 -0
  749. package/lib/network/reqresp/utils/collect.d.ts.map +1 -0
  750. package/lib/network/reqresp/utils/collectSequentialBlocksInRange.d.ts.map +1 -0
  751. package/lib/network/reqresp/utils/dataColumnResponseValidation.d.ts.map +1 -0
  752. package/lib/network/reqresp/utils/dataColumnResponseValidation.js.map +1 -1
  753. package/lib/network/statusCache.d.ts.map +1 -0
  754. package/lib/network/statusCache.js +1 -0
  755. package/lib/network/statusCache.js.map +1 -1
  756. package/lib/network/subnets/attnetsService.d.ts.map +1 -0
  757. package/lib/network/subnets/attnetsService.js +73 -65
  758. package/lib/network/subnets/attnetsService.js.map +1 -1
  759. package/lib/network/subnets/index.d.ts.map +1 -0
  760. package/lib/network/subnets/interface.d.ts.map +1 -0
  761. package/lib/network/subnets/interface.js +1 -1
  762. package/lib/network/subnets/interface.js.map +1 -1
  763. package/lib/network/subnets/syncnetsService.d.ts.map +1 -0
  764. package/lib/network/subnets/syncnetsService.js +29 -22
  765. package/lib/network/subnets/syncnetsService.js.map +1 -1
  766. package/lib/network/subnets/util.d.ts.map +1 -0
  767. package/lib/network/subnets/util.js +1 -2
  768. package/lib/network/subnets/util.js.map +1 -1
  769. package/lib/network/util.d.ts.map +1 -0
  770. package/lib/node/index.d.ts.map +1 -0
  771. package/lib/node/nodejs.d.ts +1 -1
  772. package/lib/node/nodejs.d.ts.map +1 -0
  773. package/lib/node/nodejs.js +15 -0
  774. package/lib/node/nodejs.js.map +1 -1
  775. package/lib/node/notifier.d.ts.map +1 -0
  776. package/lib/node/notifier.js +2 -3
  777. package/lib/node/notifier.js.map +1 -1
  778. package/lib/node/options.d.ts.map +1 -0
  779. package/lib/node/options.js.map +1 -1
  780. package/lib/node/utils/interop/deposits.d.ts.map +1 -0
  781. package/lib/node/utils/interop/state.d.ts.map +1 -0
  782. package/lib/node/utils/interop/state.js +1 -2
  783. package/lib/node/utils/interop/state.js.map +1 -1
  784. package/lib/node/utils/lightclient.d.ts.map +1 -0
  785. package/lib/node/utils/state.d.ts.map +1 -0
  786. package/lib/sync/backfill/backfill.d.ts +1 -1
  787. package/lib/sync/backfill/backfill.d.ts.map +1 -0
  788. package/lib/sync/backfill/backfill.js +58 -16
  789. package/lib/sync/backfill/backfill.js.map +1 -1
  790. package/lib/sync/backfill/errors.d.ts.map +1 -0
  791. package/lib/sync/backfill/index.d.ts.map +1 -0
  792. package/lib/sync/backfill/verify.d.ts.map +1 -0
  793. package/lib/sync/constants.d.ts +2 -1
  794. package/lib/sync/constants.d.ts.map +1 -0
  795. package/lib/sync/constants.js +2 -1
  796. package/lib/sync/constants.js.map +1 -1
  797. package/lib/sync/index.d.ts.map +1 -0
  798. package/lib/sync/interface.d.ts +1 -59
  799. package/lib/sync/interface.d.ts.map +1 -0
  800. package/lib/sync/interface.js +0 -20
  801. package/lib/sync/interface.js.map +1 -1
  802. package/lib/sync/options.d.ts +1 -1
  803. package/lib/sync/options.d.ts.map +1 -0
  804. package/lib/sync/range/batch.d.ts +48 -32
  805. package/lib/sync/range/batch.d.ts.map +1 -0
  806. package/lib/sync/range/batch.js +201 -55
  807. package/lib/sync/range/batch.js.map +1 -1
  808. package/lib/sync/range/chain.d.ts +15 -10
  809. package/lib/sync/range/chain.d.ts.map +1 -0
  810. package/lib/sync/range/chain.js +141 -70
  811. package/lib/sync/range/chain.js.map +1 -1
  812. package/lib/sync/range/range.d.ts +3 -3
  813. package/lib/sync/range/range.d.ts.map +1 -0
  814. package/lib/sync/range/range.js +86 -54
  815. package/lib/sync/range/range.js.map +1 -1
  816. package/lib/sync/range/utils/batches.d.ts.map +1 -0
  817. package/lib/sync/range/utils/chainTarget.d.ts.map +1 -0
  818. package/lib/sync/range/utils/hashBlocks.d.ts +2 -2
  819. package/lib/sync/range/utils/hashBlocks.d.ts.map +1 -0
  820. package/lib/sync/range/utils/hashBlocks.js +6 -4
  821. package/lib/sync/range/utils/hashBlocks.js.map +1 -1
  822. package/lib/sync/range/utils/index.d.ts.map +1 -0
  823. package/lib/sync/range/utils/peerBalancer.d.ts.map +1 -0
  824. package/lib/sync/range/utils/peerBalancer.js +18 -13
  825. package/lib/sync/range/utils/peerBalancer.js.map +1 -1
  826. package/lib/sync/range/utils/updateChains.d.ts.map +1 -0
  827. package/lib/sync/sync.d.ts +1 -2
  828. package/lib/sync/sync.d.ts.map +1 -0
  829. package/lib/sync/sync.js +95 -87
  830. package/lib/sync/sync.js.map +1 -1
  831. package/lib/sync/types.d.ts +43 -0
  832. package/lib/sync/types.d.ts.map +1 -0
  833. package/lib/sync/types.js +34 -0
  834. package/lib/sync/types.js.map +1 -0
  835. package/lib/sync/unknownBlock.d.ts +42 -29
  836. package/lib/sync/unknownBlock.d.ts.map +1 -0
  837. package/lib/sync/unknownBlock.js +407 -462
  838. package/lib/sync/unknownBlock.js.map +1 -1
  839. package/lib/sync/utils/downloadByRange.d.ts +186 -0
  840. package/lib/sync/utils/downloadByRange.d.ts.map +1 -0
  841. package/lib/sync/utils/downloadByRange.js +457 -0
  842. package/lib/sync/utils/downloadByRange.js.map +1 -0
  843. package/lib/sync/utils/downloadByRoot.d.ts +121 -0
  844. package/lib/sync/utils/downloadByRoot.d.ts.map +1 -0
  845. package/lib/sync/utils/downloadByRoot.js +346 -0
  846. package/lib/sync/utils/downloadByRoot.js.map +1 -0
  847. package/lib/sync/utils/pendingBlocksTree.d.ts +14 -6
  848. package/lib/sync/utils/pendingBlocksTree.d.ts.map +1 -0
  849. package/lib/sync/utils/pendingBlocksTree.js +24 -18
  850. package/lib/sync/utils/pendingBlocksTree.js.map +1 -1
  851. package/lib/sync/utils/remoteSyncType.d.ts.map +1 -0
  852. package/lib/util/address.d.ts.map +1 -0
  853. package/lib/util/array.d.ts.map +1 -0
  854. package/lib/util/array.js +7 -3
  855. package/lib/util/array.js.map +1 -1
  856. package/lib/util/asyncIterableToEvents.d.ts.map +1 -0
  857. package/lib/util/asyncIterableToEvents.js +6 -3
  858. package/lib/util/asyncIterableToEvents.js.map +1 -1
  859. package/lib/util/binarySearch.d.ts.map +1 -0
  860. package/lib/util/binarySearch.js +2 -0
  861. package/lib/util/binarySearch.js.map +1 -1
  862. package/lib/util/bitArray.d.ts.map +1 -0
  863. package/lib/util/blobs.d.ts +2 -2
  864. package/lib/util/blobs.d.ts.map +1 -0
  865. package/lib/util/blobs.js +9 -7
  866. package/lib/util/blobs.js.map +1 -1
  867. package/lib/util/bufferPool.d.ts.map +1 -0
  868. package/lib/util/bufferPool.js +7 -2
  869. package/lib/util/bufferPool.js.map +1 -1
  870. package/lib/util/bytes.d.ts.map +1 -0
  871. package/lib/util/chunkify.d.ts.map +1 -0
  872. package/lib/util/clock.d.ts +9 -4
  873. package/lib/util/clock.d.ts.map +1 -0
  874. package/lib/util/clock.js +30 -22
  875. package/lib/util/clock.js.map +1 -1
  876. package/lib/util/dataColumns.d.ts +13 -10
  877. package/lib/util/dataColumns.d.ts.map +1 -0
  878. package/lib/util/dataColumns.js +92 -134
  879. package/lib/util/dataColumns.js.map +1 -1
  880. package/lib/util/dependentRoot.d.ts.map +1 -0
  881. package/lib/util/enum.d.ts.map +1 -0
  882. package/lib/util/error.d.ts.map +1 -0
  883. package/lib/util/eventLoop.d.ts.map +1 -0
  884. package/lib/util/execution.d.ts +20 -0
  885. package/lib/util/execution.d.ts.map +1 -0
  886. package/lib/util/execution.js +165 -0
  887. package/lib/util/execution.js.map +1 -0
  888. package/lib/util/file.d.ts.map +1 -0
  889. package/lib/util/forkChoice.d.ts.map +1 -0
  890. package/lib/util/forkName.d.ts.map +1 -0
  891. package/lib/util/graffiti.d.ts.map +1 -0
  892. package/lib/util/hex.d.ts.map +1 -0
  893. package/lib/util/index.d.ts.map +1 -0
  894. package/lib/util/ip.d.ts.map +1 -0
  895. package/lib/util/itTrigger.d.ts.map +1 -0
  896. package/lib/util/itTrigger.js +4 -4
  897. package/lib/util/itTrigger.js.map +1 -1
  898. package/lib/util/kzg.d.ts.map +1 -0
  899. package/lib/util/map.d.ts.map +1 -0
  900. package/lib/util/map.js +2 -0
  901. package/lib/util/map.js.map +1 -1
  902. package/lib/util/metadata.d.ts.map +1 -0
  903. package/lib/util/multifork.d.ts.map +1 -0
  904. package/lib/util/numpy.d.ts.map +1 -0
  905. package/lib/util/peerId.d.ts.map +1 -0
  906. package/lib/util/profile.d.ts.map +1 -0
  907. package/lib/util/promises.d.ts.map +1 -0
  908. package/lib/util/queue/errors.d.ts.map +1 -0
  909. package/lib/util/queue/fnQueue.d.ts.map +1 -0
  910. package/lib/util/queue/index.d.ts +1 -1
  911. package/lib/util/queue/index.d.ts.map +1 -0
  912. package/lib/util/queue/index.js +1 -1
  913. package/lib/util/queue/index.js.map +1 -1
  914. package/lib/util/queue/itemQueue.d.ts.map +1 -0
  915. package/lib/util/queue/itemQueue.js +52 -49
  916. package/lib/util/queue/itemQueue.js.map +1 -1
  917. package/lib/util/queue/options.d.ts.map +1 -0
  918. package/lib/util/serializedCache.d.ts.map +1 -0
  919. package/lib/util/serializedCache.js +1 -3
  920. package/lib/util/serializedCache.js.map +1 -1
  921. package/lib/util/set.d.ts.map +1 -0
  922. package/lib/util/set.js +2 -0
  923. package/lib/util/set.js.map +1 -1
  924. package/lib/util/shuffle.d.ts.map +1 -0
  925. package/lib/util/sortBy.d.ts.map +1 -0
  926. package/lib/util/sszBytes.d.ts +1 -0
  927. package/lib/util/sszBytes.d.ts.map +1 -0
  928. package/lib/util/sszBytes.js +1 -1
  929. package/lib/util/sszBytes.js.map +1 -1
  930. package/lib/util/strictEvents.d.ts.map +1 -0
  931. package/lib/util/time.d.ts.map +1 -0
  932. package/lib/util/timeSeries.d.ts.map +1 -0
  933. package/lib/util/timeSeries.js +3 -1
  934. package/lib/util/timeSeries.js.map +1 -1
  935. package/lib/util/types.d.ts +1 -1
  936. package/lib/util/types.d.ts.map +1 -0
  937. package/lib/util/types.js +2 -2
  938. package/lib/util/types.js.map +1 -1
  939. package/lib/util/workerEvents.d.ts.map +1 -0
  940. package/lib/util/wrapError.d.ts +7 -0
  941. package/lib/util/wrapError.d.ts.map +1 -0
  942. package/package.json +40 -24
  943. package/src/api/impl/api.ts +26 -0
  944. package/src/api/impl/beacon/blocks/index.ts +744 -0
  945. package/src/api/impl/beacon/blocks/utils.ts +75 -0
  946. package/src/api/impl/beacon/index.ts +35 -0
  947. package/src/api/impl/beacon/pool/index.ts +314 -0
  948. package/src/api/impl/beacon/rewards/index.ts +30 -0
  949. package/src/api/impl/beacon/state/index.ts +406 -0
  950. package/src/api/impl/beacon/state/utils.ts +189 -0
  951. package/src/api/impl/config/constants.ts +127 -0
  952. package/src/api/impl/config/index.ts +59 -0
  953. package/src/api/impl/debug/index.ts +131 -0
  954. package/src/api/impl/errors.ts +50 -0
  955. package/src/api/impl/events/index.ts +33 -0
  956. package/src/api/impl/index.ts +6 -0
  957. package/src/api/impl/lightclient/index.ts +64 -0
  958. package/src/api/impl/lodestar/index.ts +257 -0
  959. package/src/api/impl/node/index.ts +88 -0
  960. package/src/api/impl/node/utils.ts +51 -0
  961. package/src/api/impl/proof/index.ts +60 -0
  962. package/src/api/impl/types.ts +17 -0
  963. package/src/api/impl/utils.ts +25 -0
  964. package/src/api/impl/validator/index.ts +1533 -0
  965. package/src/api/impl/validator/utils.ts +85 -0
  966. package/src/api/index.ts +2 -0
  967. package/src/api/options.ts +16 -0
  968. package/src/api/rest/activeSockets.ts +109 -0
  969. package/src/api/rest/base.ts +216 -0
  970. package/src/api/rest/index.ts +63 -0
  971. package/src/api/rest/swaggerUI.ts +80 -0
  972. package/src/bun-wrappers/prometheus-gc-stats.ts +7 -0
  973. package/src/chain/ColumnReconstructionTracker.ts +90 -0
  974. package/src/chain/GetBlobsTracker.ts +115 -0
  975. package/src/chain/archiveStore/archiveStore.ts +222 -0
  976. package/src/chain/archiveStore/constants.ts +5 -0
  977. package/src/chain/archiveStore/historicalState/getHistoricalState.ts +116 -0
  978. package/src/chain/archiveStore/historicalState/historicalStateRegen.ts +68 -0
  979. package/src/chain/archiveStore/historicalState/metrics.ts +214 -0
  980. package/src/chain/archiveStore/historicalState/types.ts +41 -0
  981. package/src/chain/archiveStore/historicalState/worker.ts +77 -0
  982. package/src/chain/archiveStore/index.ts +3 -0
  983. package/src/chain/archiveStore/interface.ts +75 -0
  984. package/src/chain/archiveStore/strategies/frequencyStateArchiveStrategy.ts +138 -0
  985. package/src/chain/archiveStore/utils/archiveBlocks.ts +437 -0
  986. package/src/chain/archiveStore/utils/pruneHistory.ts +56 -0
  987. package/src/chain/archiveStore/utils/updateBackfillRange.ts +50 -0
  988. package/src/chain/balancesCache.ts +52 -0
  989. package/src/chain/beaconProposerCache.ts +43 -0
  990. package/src/chain/blocks/blockInput/blockInput.ts +852 -0
  991. package/src/chain/blocks/blockInput/errors.ts +48 -0
  992. package/src/chain/blocks/blockInput/index.ts +4 -0
  993. package/src/chain/blocks/blockInput/types.ts +145 -0
  994. package/src/chain/blocks/blockInput/utils.ts +21 -0
  995. package/src/chain/blocks/importBlock.ts +599 -0
  996. package/src/chain/blocks/index.ts +179 -0
  997. package/src/chain/blocks/types.ts +101 -0
  998. package/src/chain/blocks/utils/blowfishBanner.ts +28 -0
  999. package/src/chain/blocks/utils/chainSegment.ts +29 -0
  1000. package/src/chain/blocks/utils/checkpoint.ts +25 -0
  1001. package/src/chain/blocks/utils/giraffeBanner.ts +30 -0
  1002. package/src/chain/blocks/utils/ownBanner.ts +20 -0
  1003. package/src/chain/blocks/utils/pandaMergeTransitionBanner.ts +43 -0
  1004. package/src/chain/blocks/utils/zebraBanner.ts +45 -0
  1005. package/src/chain/blocks/verifyBlock.ts +242 -0
  1006. package/src/chain/blocks/verifyBlocksDataAvailability.ts +42 -0
  1007. package/src/chain/blocks/verifyBlocksExecutionPayloads.ts +438 -0
  1008. package/src/chain/blocks/verifyBlocksSanityChecks.ts +129 -0
  1009. package/src/chain/blocks/verifyBlocksSignatures.ts +105 -0
  1010. package/src/chain/blocks/verifyBlocksStateTransitionOnly.ts +114 -0
  1011. package/src/chain/blocks/writeBlockInputToDb.ts +120 -0
  1012. package/src/chain/bls/index.ts +4 -0
  1013. package/src/chain/bls/interface.ts +68 -0
  1014. package/src/chain/bls/maybeBatch.ts +45 -0
  1015. package/src/chain/bls/multithread/index.ts +582 -0
  1016. package/src/chain/bls/multithread/jobItem.ts +119 -0
  1017. package/src/chain/bls/multithread/poolSize.ts +16 -0
  1018. package/src/chain/bls/multithread/types.ts +38 -0
  1019. package/src/chain/bls/multithread/utils.ts +19 -0
  1020. package/src/chain/bls/multithread/worker.ts +114 -0
  1021. package/src/chain/bls/singleThread.ts +87 -0
  1022. package/src/chain/bls/utils.ts +30 -0
  1023. package/src/chain/chain.ts +1354 -0
  1024. package/src/chain/emitter.ts +113 -0
  1025. package/src/chain/errors/attestationError.ts +194 -0
  1026. package/src/chain/errors/attesterSlashingError.ts +11 -0
  1027. package/src/chain/errors/blobSidecarError.ts +60 -0
  1028. package/src/chain/errors/blockError.ts +166 -0
  1029. package/src/chain/errors/blsToExecutionChangeError.ts +13 -0
  1030. package/src/chain/errors/dataColumnSidecarError.ts +80 -0
  1031. package/src/chain/errors/gossipValidation.ts +20 -0
  1032. package/src/chain/errors/index.ts +10 -0
  1033. package/src/chain/errors/lightClientError.ts +30 -0
  1034. package/src/chain/errors/proposerSlashingError.ts +11 -0
  1035. package/src/chain/errors/syncCommitteeError.ts +36 -0
  1036. package/src/chain/errors/voluntaryExitError.ts +13 -0
  1037. package/src/chain/forkChoice/index.ts +112 -0
  1038. package/src/chain/genesis/genesis.ts +190 -0
  1039. package/src/chain/genesis/interface.ts +14 -0
  1040. package/src/chain/index.ts +6 -0
  1041. package/src/chain/initState.ts +221 -0
  1042. package/src/chain/interface.ts +280 -0
  1043. package/src/chain/lightClient/index.ts +764 -0
  1044. package/src/chain/lightClient/proofs.ts +85 -0
  1045. package/src/chain/lightClient/types.ts +33 -0
  1046. package/src/chain/opPools/aggregatedAttestationPool.ts +1063 -0
  1047. package/src/chain/opPools/attestationPool.ts +282 -0
  1048. package/src/chain/opPools/index.ts +5 -0
  1049. package/src/chain/opPools/opPool.ts +462 -0
  1050. package/src/chain/opPools/syncCommitteeMessagePool.ts +169 -0
  1051. package/src/chain/opPools/syncContributionAndProofPool.ts +240 -0
  1052. package/src/chain/opPools/types.ts +35 -0
  1053. package/src/chain/opPools/utils.ts +65 -0
  1054. package/src/chain/options.ts +138 -0
  1055. package/src/chain/prepareNextSlot.ts +277 -0
  1056. package/src/chain/produceBlock/computeNewStateRoot.ts +55 -0
  1057. package/src/chain/produceBlock/index.ts +2 -0
  1058. package/src/chain/produceBlock/produceBlockBody.ts +797 -0
  1059. package/src/chain/produceBlock/validateBlobsAndKzgCommitments.ts +54 -0
  1060. package/src/chain/regen/errors.ts +30 -0
  1061. package/src/chain/regen/index.ts +4 -0
  1062. package/src/chain/regen/interface.ts +93 -0
  1063. package/src/chain/regen/queued.ts +317 -0
  1064. package/src/chain/regen/regen.ts +424 -0
  1065. package/src/chain/reprocess.ts +161 -0
  1066. package/src/chain/rewards/attestationsRewards.ts +196 -0
  1067. package/src/chain/rewards/blockRewards.ts +150 -0
  1068. package/src/chain/rewards/syncCommitteeRewards.ts +58 -0
  1069. package/src/chain/seenCache/index.ts +5 -0
  1070. package/src/chain/seenCache/seenAggregateAndProof.ts +120 -0
  1071. package/src/chain/seenCache/seenAttestationData.ts +145 -0
  1072. package/src/chain/seenCache/seenAttesters.ts +58 -0
  1073. package/src/chain/seenCache/seenBlockAttesters.ts +18 -0
  1074. package/src/chain/seenCache/seenBlockProposers.ts +48 -0
  1075. package/src/chain/seenCache/seenCommittee.ts +43 -0
  1076. package/src/chain/seenCache/seenCommitteeContribution.ts +104 -0
  1077. package/src/chain/seenCache/seenGossipBlockInput.ts +373 -0
  1078. package/src/chain/serializeState.ts +32 -0
  1079. package/src/chain/shufflingCache.ts +238 -0
  1080. package/src/chain/stateCache/blockStateCacheImpl.ts +150 -0
  1081. package/src/chain/stateCache/datastore/db.ts +36 -0
  1082. package/src/chain/stateCache/datastore/file.ts +53 -0
  1083. package/src/chain/stateCache/datastore/index.ts +2 -0
  1084. package/src/chain/stateCache/datastore/types.ts +13 -0
  1085. package/src/chain/stateCache/fifoBlockStateCache.ts +208 -0
  1086. package/src/chain/stateCache/inMemoryCheckpointsCache.ts +198 -0
  1087. package/src/chain/stateCache/index.ts +3 -0
  1088. package/src/chain/stateCache/mapMetrics.ts +52 -0
  1089. package/src/chain/stateCache/persistentCheckpointsCache.ts +837 -0
  1090. package/src/chain/stateCache/types.ts +86 -0
  1091. package/src/chain/validation/aggregateAndProof.ts +258 -0
  1092. package/src/chain/validation/attestation.ts +885 -0
  1093. package/src/chain/validation/attesterSlashing.ts +61 -0
  1094. package/src/chain/validation/blobSidecar.ts +301 -0
  1095. package/src/chain/validation/block.ts +188 -0
  1096. package/src/chain/validation/blsToExecutionChange.ts +61 -0
  1097. package/src/chain/validation/dataColumnSidecar.ts +381 -0
  1098. package/src/chain/validation/index.ts +9 -0
  1099. package/src/chain/validation/lightClientFinalityUpdate.ts +46 -0
  1100. package/src/chain/validation/lightClientOptimisticUpdate.ts +68 -0
  1101. package/src/chain/validation/proposerSlashing.ts +54 -0
  1102. package/src/chain/validation/signatureSets/aggregateAndProof.ts +38 -0
  1103. package/src/chain/validation/signatureSets/contributionAndProof.ts +27 -0
  1104. package/src/chain/validation/signatureSets/index.ts +6 -0
  1105. package/src/chain/validation/signatureSets/selectionProof.ts +27 -0
  1106. package/src/chain/validation/signatureSets/syncCommittee.ts +22 -0
  1107. package/src/chain/validation/signatureSets/syncCommitteeContribution.ts +18 -0
  1108. package/src/chain/validation/signatureSets/syncCommitteeSelectionProof.ts +27 -0
  1109. package/src/chain/validation/syncCommittee.ts +165 -0
  1110. package/src/chain/validation/syncCommitteeContributionAndProof.ts +122 -0
  1111. package/src/chain/validation/voluntaryExit.ts +58 -0
  1112. package/src/chain/validatorMonitor.ts +1310 -0
  1113. package/src/constants/constants.ts +15 -0
  1114. package/src/constants/index.ts +2 -0
  1115. package/src/constants/network.ts +52 -0
  1116. package/src/db/beacon.ts +113 -0
  1117. package/src/db/buckets.ts +80 -0
  1118. package/src/db/index.ts +2 -0
  1119. package/src/db/interface.ts +76 -0
  1120. package/src/db/options.ts +7 -0
  1121. package/src/db/repositories/attesterSlashing.ts +38 -0
  1122. package/src/db/repositories/backfilledRanges.ts +29 -0
  1123. package/src/db/repositories/blobSidecars.ts +37 -0
  1124. package/src/db/repositories/blobSidecarsArchive.ts +28 -0
  1125. package/src/db/repositories/block.ts +33 -0
  1126. package/src/db/repositories/blockArchive.ts +170 -0
  1127. package/src/db/repositories/blockArchiveIndex.ts +45 -0
  1128. package/src/db/repositories/blsToExecutionChange.ts +16 -0
  1129. package/src/db/repositories/checkpointState.ts +31 -0
  1130. package/src/db/repositories/dataColumnSidecar.ts +49 -0
  1131. package/src/db/repositories/dataColumnSidecarArchive.ts +56 -0
  1132. package/src/db/repositories/depositDataRoot.ts +80 -0
  1133. package/src/db/repositories/depositEvent.ts +32 -0
  1134. package/src/db/repositories/eth1Data.ts +33 -0
  1135. package/src/db/repositories/index.ts +20 -0
  1136. package/src/db/repositories/lightclientBestUpdate.ts +41 -0
  1137. package/src/db/repositories/lightclientCheckpointHeader.ts +32 -0
  1138. package/src/db/repositories/lightclientSyncCommittee.ts +16 -0
  1139. package/src/db/repositories/lightclientSyncCommitteeWitness.ts +77 -0
  1140. package/src/db/repositories/proposerSlashing.ts +15 -0
  1141. package/src/db/repositories/stateArchive.ts +69 -0
  1142. package/src/db/repositories/stateArchiveIndex.ts +18 -0
  1143. package/src/db/repositories/voluntaryExit.ts +15 -0
  1144. package/src/db/single/index.ts +2 -0
  1145. package/src/db/single/preGenesisState.ts +37 -0
  1146. package/src/db/single/preGenesisStateLastProcessedBlock.ts +34 -0
  1147. package/src/eth1/errors.ts +40 -0
  1148. package/src/eth1/eth1DataCache.ts +26 -0
  1149. package/src/eth1/eth1DepositDataTracker.ts +410 -0
  1150. package/src/eth1/eth1DepositsCache.ts +141 -0
  1151. package/src/eth1/eth1MergeBlockTracker.ts +328 -0
  1152. package/src/eth1/index.ts +157 -0
  1153. package/src/eth1/interface.ts +131 -0
  1154. package/src/eth1/options.ts +28 -0
  1155. package/src/eth1/provider/eth1Provider.ts +229 -0
  1156. package/src/eth1/provider/jsonRpcHttpClient.ts +390 -0
  1157. package/src/eth1/provider/jwt.ts +36 -0
  1158. package/src/eth1/provider/utils.ts +136 -0
  1159. package/src/eth1/stream.ts +75 -0
  1160. package/src/eth1/utils/depositContract.ts +37 -0
  1161. package/src/eth1/utils/deposits.ts +70 -0
  1162. package/src/eth1/utils/eth1Data.ts +100 -0
  1163. package/src/eth1/utils/eth1DepositEvent.ts +12 -0
  1164. package/src/eth1/utils/eth1Vote.ts +142 -0
  1165. package/src/eth1/utils/groupDepositEventsByBlock.ts +19 -0
  1166. package/src/eth1/utils/optimizeNextBlockDiffForGenesis.ts +18 -0
  1167. package/src/execution/builder/cache.ts +39 -0
  1168. package/src/execution/builder/http.ts +229 -0
  1169. package/src/execution/builder/index.ts +27 -0
  1170. package/src/execution/builder/interface.ts +49 -0
  1171. package/src/execution/builder/utils.ts +19 -0
  1172. package/src/execution/engine/disabled.ts +35 -0
  1173. package/src/execution/engine/http.ts +644 -0
  1174. package/src/execution/engine/index.ts +63 -0
  1175. package/src/execution/engine/interface.ts +199 -0
  1176. package/src/execution/engine/mock.ts +493 -0
  1177. package/src/execution/engine/payloadIdCache.ts +54 -0
  1178. package/src/execution/engine/types.ts +640 -0
  1179. package/src/execution/engine/utils.ts +136 -0
  1180. package/src/execution/index.ts +4 -0
  1181. package/src/index.ts +20 -0
  1182. package/src/metrics/index.ts +4 -0
  1183. package/src/metrics/metrics/beacon.ts +390 -0
  1184. package/src/metrics/metrics/lodestar.ts +1870 -0
  1185. package/src/metrics/metrics.ts +43 -0
  1186. package/src/metrics/nodeJsMetrics.ts +19 -0
  1187. package/src/metrics/options.ts +22 -0
  1188. package/src/metrics/server/http.ts +114 -0
  1189. package/src/metrics/server/index.ts +1 -0
  1190. package/src/metrics/utils/avgMinMax.ts +87 -0
  1191. package/src/metrics/utils/gauge.ts +22 -0
  1192. package/src/metrics/utils/registryMetricCreator.ts +41 -0
  1193. package/src/monitoring/clientStats.ts +297 -0
  1194. package/src/monitoring/index.ts +2 -0
  1195. package/src/monitoring/options.ts +19 -0
  1196. package/src/monitoring/properties.ts +152 -0
  1197. package/src/monitoring/service.ts +235 -0
  1198. package/src/monitoring/system.ts +146 -0
  1199. package/src/monitoring/types.ts +21 -0
  1200. package/src/network/core/events.ts +59 -0
  1201. package/src/network/core/index.ts +3 -0
  1202. package/src/network/core/metrics.ts +304 -0
  1203. package/src/network/core/networkCore.ts +599 -0
  1204. package/src/network/core/networkCoreWorker.ts +176 -0
  1205. package/src/network/core/networkCoreWorkerHandler.ts +284 -0
  1206. package/src/network/core/types.ts +119 -0
  1207. package/src/network/discv5/index.ts +132 -0
  1208. package/src/network/discv5/types.ts +74 -0
  1209. package/src/network/discv5/utils.ts +50 -0
  1210. package/src/network/discv5/worker.ts +137 -0
  1211. package/src/network/events.ts +51 -0
  1212. package/src/network/forks.ts +94 -0
  1213. package/src/network/gossip/constants.ts +15 -0
  1214. package/src/network/gossip/encoding.ts +111 -0
  1215. package/src/network/gossip/errors.ts +7 -0
  1216. package/src/network/gossip/gossipsub.ts +384 -0
  1217. package/src/network/gossip/index.ts +4 -0
  1218. package/src/network/gossip/interface.ts +215 -0
  1219. package/src/network/gossip/metrics.ts +71 -0
  1220. package/src/network/gossip/scoringParameters.ts +333 -0
  1221. package/src/network/gossip/topic.ts +332 -0
  1222. package/src/network/index.ts +8 -0
  1223. package/src/network/interface.ts +134 -0
  1224. package/src/network/libp2p/error.ts +55 -0
  1225. package/src/network/libp2p/index.ts +153 -0
  1226. package/src/network/metadata.ts +162 -0
  1227. package/src/network/network.ts +767 -0
  1228. package/src/network/networkConfig.ts +12 -0
  1229. package/src/network/options.ts +70 -0
  1230. package/src/network/peers/client.ts +29 -0
  1231. package/src/network/peers/datastore.ts +188 -0
  1232. package/src/network/peers/discover.ts +647 -0
  1233. package/src/network/peers/index.ts +2 -0
  1234. package/src/network/peers/peerManager.ts +900 -0
  1235. package/src/network/peers/peersData.ts +65 -0
  1236. package/src/network/peers/score/constants.ts +34 -0
  1237. package/src/network/peers/score/index.ts +4 -0
  1238. package/src/network/peers/score/interface.ts +74 -0
  1239. package/src/network/peers/score/score.ts +200 -0
  1240. package/src/network/peers/score/store.ts +95 -0
  1241. package/src/network/peers/score/utils.ts +37 -0
  1242. package/src/network/peers/utils/assertPeerRelevance.ts +99 -0
  1243. package/src/network/peers/utils/enrSubnetsDeserialize.ts +27 -0
  1244. package/src/network/peers/utils/getConnectedPeerIds.ts +33 -0
  1245. package/src/network/peers/utils/index.ts +4 -0
  1246. package/src/network/peers/utils/prioritizePeers.ts +627 -0
  1247. package/src/network/peers/utils/subnetMap.ts +88 -0
  1248. package/src/network/processor/aggregatorTracker.ts +38 -0
  1249. package/src/network/processor/extractSlotRootFns.ts +64 -0
  1250. package/src/network/processor/gossipHandlers.ts +951 -0
  1251. package/src/network/processor/gossipQueues/index.ts +114 -0
  1252. package/src/network/processor/gossipQueues/indexed.ts +219 -0
  1253. package/src/network/processor/gossipQueues/linear.ts +162 -0
  1254. package/src/network/processor/gossipQueues/types.ts +57 -0
  1255. package/src/network/processor/gossipValidatorFn.ts +142 -0
  1256. package/src/network/processor/index.ts +496 -0
  1257. package/src/network/processor/types.ts +27 -0
  1258. package/src/network/reqresp/ReqRespBeaconNode.ts +373 -0
  1259. package/src/network/reqresp/handlers/beaconBlocksByRange.ts +101 -0
  1260. package/src/network/reqresp/handlers/beaconBlocksByRoot.ts +49 -0
  1261. package/src/network/reqresp/handlers/blobSidecarsByRange.ts +114 -0
  1262. package/src/network/reqresp/handlers/blobSidecarsByRoot.ts +62 -0
  1263. package/src/network/reqresp/handlers/dataColumnSidecarsByRange.ts +144 -0
  1264. package/src/network/reqresp/handlers/dataColumnSidecarsByRoot.ts +88 -0
  1265. package/src/network/reqresp/handlers/index.ts +78 -0
  1266. package/src/network/reqresp/handlers/lightClientBootstrap.ts +31 -0
  1267. package/src/network/reqresp/handlers/lightClientFinalityUpdate.ts +21 -0
  1268. package/src/network/reqresp/handlers/lightClientOptimisticUpdate.ts +21 -0
  1269. package/src/network/reqresp/handlers/lightClientUpdatesByRange.ts +39 -0
  1270. package/src/network/reqresp/index.ts +2 -0
  1271. package/src/network/reqresp/interface.ts +45 -0
  1272. package/src/network/reqresp/protocols.ts +146 -0
  1273. package/src/network/reqresp/rateLimit.ts +112 -0
  1274. package/src/network/reqresp/score.ts +70 -0
  1275. package/src/network/reqresp/types.ts +174 -0
  1276. package/src/network/reqresp/utils/collect.ts +84 -0
  1277. package/src/network/reqresp/utils/collectSequentialBlocksInRange.ts +57 -0
  1278. package/src/network/reqresp/utils/dataColumnResponseValidation.ts +99 -0
  1279. package/src/network/statusCache.ts +17 -0
  1280. package/src/network/subnets/attnetsService.ts +382 -0
  1281. package/src/network/subnets/index.ts +2 -0
  1282. package/src/network/subnets/interface.ts +66 -0
  1283. package/src/network/subnets/syncnetsService.ts +147 -0
  1284. package/src/network/subnets/util.ts +63 -0
  1285. package/src/network/util.ts +29 -0
  1286. package/src/node/index.ts +2 -0
  1287. package/src/node/nodejs.ts +349 -0
  1288. package/src/node/notifier.ts +206 -0
  1289. package/src/node/options.ts +51 -0
  1290. package/src/node/utils/interop/deposits.ts +53 -0
  1291. package/src/node/utils/interop/state.ts +59 -0
  1292. package/src/node/utils/lightclient.ts +7 -0
  1293. package/src/node/utils/state.ts +37 -0
  1294. package/src/sync/backfill/backfill.ts +893 -0
  1295. package/src/sync/backfill/errors.ts +23 -0
  1296. package/src/sync/backfill/index.ts +1 -0
  1297. package/src/sync/backfill/verify.ts +58 -0
  1298. package/src/sync/constants.ts +71 -0
  1299. package/src/sync/index.ts +2 -0
  1300. package/src/sync/interface.ts +55 -0
  1301. package/src/sync/options.ts +45 -0
  1302. package/src/sync/range/batch.ts +455 -0
  1303. package/src/sync/range/chain.ts +715 -0
  1304. package/src/sync/range/range.ts +354 -0
  1305. package/src/sync/range/utils/batches.ts +119 -0
  1306. package/src/sync/range/utils/chainTarget.ts +62 -0
  1307. package/src/sync/range/utils/hashBlocks.ts +27 -0
  1308. package/src/sync/range/utils/index.ts +5 -0
  1309. package/src/sync/range/utils/peerBalancer.ts +184 -0
  1310. package/src/sync/range/utils/updateChains.ts +66 -0
  1311. package/src/sync/sync.ts +290 -0
  1312. package/src/sync/types.ts +57 -0
  1313. package/src/sync/unknownBlock.ts +860 -0
  1314. package/src/sync/utils/downloadByRange.ts +808 -0
  1315. package/src/sync/utils/downloadByRoot.ts +560 -0
  1316. package/src/sync/utils/pendingBlocksTree.ts +97 -0
  1317. package/src/sync/utils/remoteSyncType.ts +144 -0
  1318. package/src/util/address.ts +3 -0
  1319. package/src/util/array.ts +311 -0
  1320. package/src/util/asyncIterableToEvents.ts +164 -0
  1321. package/src/util/binarySearch.ts +48 -0
  1322. package/src/util/bitArray.ts +84 -0
  1323. package/src/util/blobs.ts +210 -0
  1324. package/src/util/bufferPool.ts +95 -0
  1325. package/src/util/bytes.ts +11 -0
  1326. package/src/util/chunkify.ts +27 -0
  1327. package/src/util/clock.ts +212 -0
  1328. package/src/util/dataColumns.ts +415 -0
  1329. package/src/util/dependentRoot.ts +47 -0
  1330. package/src/util/enum.ts +17 -0
  1331. package/src/util/error.ts +56 -0
  1332. package/src/util/eventLoop.ts +22 -0
  1333. package/src/util/execution.ts +223 -0
  1334. package/src/util/file.ts +52 -0
  1335. package/src/util/forkChoice.ts +5 -0
  1336. package/src/util/forkName.ts +20 -0
  1337. package/src/util/graffiti.ts +39 -0
  1338. package/src/util/hex.ts +9 -0
  1339. package/src/util/index.ts +2 -0
  1340. package/src/util/ip.ts +6 -0
  1341. package/src/util/itTrigger.ts +49 -0
  1342. package/src/util/kzg.ts +3 -0
  1343. package/src/util/map.ts +77 -0
  1344. package/src/util/metadata.ts +22 -0
  1345. package/src/util/multifork.ts +69 -0
  1346. package/src/util/numpy.ts +8 -0
  1347. package/src/util/peerId.ts +16 -0
  1348. package/src/util/profile.ts +54 -0
  1349. package/src/util/promises.ts +14 -0
  1350. package/src/util/queue/errors.ts +14 -0
  1351. package/src/util/queue/fnQueue.ts +16 -0
  1352. package/src/util/queue/index.ts +4 -0
  1353. package/src/util/queue/itemQueue.ts +128 -0
  1354. package/src/util/queue/options.ts +37 -0
  1355. package/src/util/serializedCache.ts +20 -0
  1356. package/src/util/set.ts +62 -0
  1357. package/src/util/shuffle.ts +21 -0
  1358. package/src/util/sortBy.ts +19 -0
  1359. package/src/util/sszBytes.ts +481 -0
  1360. package/src/util/strictEvents.ts +8 -0
  1361. package/src/util/time.ts +13 -0
  1362. package/src/util/timeSeries.ts +118 -0
  1363. package/src/util/types.ts +31 -0
  1364. package/src/util/workerEvents.ts +142 -0
  1365. package/src/util/wrapError.ts +27 -0
  1366. package/lib/chain/seenCache/seenBlockInput.d.ts +0 -84
  1367. package/lib/chain/seenCache/seenBlockInput.js +0 -225
  1368. package/lib/chain/seenCache/seenBlockInput.js.map +0 -1
  1369. package/lib/network/reqresp/beaconBlocksMaybeBlobsByRange.d.ts +0 -28
  1370. package/lib/network/reqresp/beaconBlocksMaybeBlobsByRange.js +0 -328
  1371. package/lib/network/reqresp/beaconBlocksMaybeBlobsByRange.js.map +0 -1
  1372. package/lib/network/reqresp/beaconBlocksMaybeBlobsByRoot.d.ts +0 -49
  1373. package/lib/network/reqresp/beaconBlocksMaybeBlobsByRoot.js +0 -499
  1374. package/lib/network/reqresp/beaconBlocksMaybeBlobsByRoot.js.map +0 -1
@@ -0,0 +1,837 @@
1
+ import {routes} from "@lodestar/api";
2
+ import {
3
+ CachedBeaconStateAllForks,
4
+ computeStartSlotAtEpoch,
5
+ getBlockRootAtSlot,
6
+ loadCachedBeaconState,
7
+ } from "@lodestar/state-transition";
8
+ import {Epoch, RootHex, phase0} from "@lodestar/types";
9
+ import {Logger, MapDef, fromHex, sleep, toHex, toRootHex} from "@lodestar/utils";
10
+ import {Metrics} from "../../metrics/index.js";
11
+ import {AllocSource, BufferPool, BufferWithKey} from "../../util/bufferPool.js";
12
+ import {IClock} from "../../util/clock.js";
13
+ import {StateRegenerationOpts} from "../regen/interface.js";
14
+ import {serializeState} from "../serializeState.js";
15
+ import {CPStateDatastore, DatastoreKey} from "./datastore/index.js";
16
+ import {MapTracker} from "./mapMetrics.js";
17
+ import {BlockStateCache, CacheItemType, CheckpointHex, CheckpointStateCache} from "./types.js";
18
+
19
+ export type PersistentCheckpointStateCacheOpts = {
20
+ /** Keep max n states in memory, persist the rest to disk */
21
+ maxCPStateEpochsInMemory?: number;
22
+ };
23
+
24
+ type PersistentCheckpointStateCacheModules = {
25
+ metrics?: Metrics | null;
26
+ logger: Logger;
27
+ clock?: IClock | null;
28
+ signal?: AbortSignal;
29
+ datastore: CPStateDatastore;
30
+ blockStateCache: BlockStateCache;
31
+ bufferPool?: BufferPool | null;
32
+ };
33
+
34
+ /** checkpoint serialized as a string */
35
+ type CacheKey = string;
36
+
37
+ type InMemoryCacheItem = {
38
+ type: CacheItemType.inMemory;
39
+ state: CachedBeaconStateAllForks;
40
+ // if a cp state is reloaded from disk, it'll keep track of persistedKey to allow us to remove it from disk later
41
+ // it also helps not to persist it again
42
+ persistedKey?: DatastoreKey;
43
+ };
44
+
45
+ type PersistedCacheItem = {
46
+ type: CacheItemType.persisted;
47
+ value: DatastoreKey;
48
+ };
49
+
50
+ type CacheItem = InMemoryCacheItem | PersistedCacheItem;
51
+
52
+ type LoadedStateBytesData = {persistedKey: DatastoreKey; stateBytes: Uint8Array};
53
+
54
+ /**
55
+ * Before n-historical states, lodestar keeps all checkpoint states since finalized
56
+ * Since Sep 2024, lodestar stores 3 most recent checkpoint states in memory and the rest on disk. The finalized state
57
+ * may not be available in memory, and stay on disk instead.
58
+ */
59
+ export const DEFAULT_MAX_CP_STATE_EPOCHS_IN_MEMORY = 3;
60
+
61
+ // TODO GLOAS: re-evaluate this timing
62
+ const PROCESS_CHECKPOINT_STATES_BPS = 6667;
63
+
64
+ /**
65
+ * An implementation of CheckpointStateCache that keep up to n epoch checkpoint states in memory and persist the rest to disk
66
+ * - If it's more than `maxEpochsInMemory` epochs old, it will persist n last epochs to disk based on the view of the block
67
+ * - Once a chain gets finalized we'll prune all states from memory and disk for epochs < finalizedEpoch
68
+ * - In get*() apis if shouldReload is true, it will reload from disk. The reload() api is expensive and should only be called in some important flows:
69
+ * - Get state for block processing
70
+ * - updateHeadState
71
+ * - as with any cache, the state could be evicted from memory at any time, so we should always check if the state is in memory or not
72
+ * - Each time we process a state, we only persist exactly 1 checkpoint state per epoch based on the view of block and prune all others. The persisted
73
+ * checkpoint state could be finalized and used later in archive task, it's also used to regen states.
74
+ * - When we process multiple states in the same epoch, we could persist different checkpoint states of the same epoch because each block could have its
75
+ * own view. See unit test of this file `packages/beacon-node/test/unit/chain/stateCache/persistentCheckpointsCache.test.ts` for more details.
76
+ *
77
+ * The below diagram shows Previous Root Checkpoint State is persisted for epoch (n-2) and Current Root Checkpoint State is persisted for epoch (n-1)
78
+ * while at epoch (n) and (n+1) we have both of them in memory
79
+ *
80
+ * ╔════════════════════════════════════╗═══════════════╗
81
+ * ║ persisted to db or fs ║ in memory ║
82
+ * ║ reload if needed ║ ║
83
+ * ║ -----------------------------------║---------------║
84
+ * ║ epoch: (n-2) (n-1) ║ n (n+1) ║
85
+ * ║ |-------|-------|----║--|-------|----║
86
+ * ║ ^ ^ ║ ^ ^ ║
87
+ * ║ ║ ^ ^ ║
88
+ * ╚════════════════════════════════════╝═══════════════╝
89
+ *
90
+ * The "in memory" checkpoint states are similar to the old implementation: we have both Previous Root Checkpoint State and Current Root Checkpoint State per epoch.
91
+ * However in the "persisted to db or fs" part
92
+ * - if there is no reorg, we only store 1 checkpoint state per epoch, the one that could potentially be justified/finalized later based on the view of the state
93
+ * - if there is reorg, we may store >=2 checkpoint states per epoch, including any checkpoints with unknown roots to the processed state
94
+ * - the goal is to make sure we can regen any states later if needed, and we have the checkpoint state that could be justified/finalized later
95
+ */
96
+ export class PersistentCheckpointStateCache implements CheckpointStateCache {
97
+ private readonly cache: MapTracker<CacheKey, CacheItem>;
98
+ /** Epoch -> Set<blockRoot> */
99
+ private readonly epochIndex = new MapDef<Epoch, Set<RootHex>>(() => new Set<string>());
100
+ private readonly metrics: Metrics | null | undefined;
101
+ private readonly logger: Logger;
102
+ private readonly clock: IClock | null | undefined;
103
+ private readonly signal: AbortSignal | undefined;
104
+ private preComputedCheckpoint: string | null = null;
105
+ private preComputedCheckpointHits: number | null = null;
106
+ private readonly maxEpochsInMemory: number;
107
+ private readonly datastore: CPStateDatastore;
108
+ private readonly blockStateCache: BlockStateCache;
109
+ private readonly bufferPool?: BufferPool | null;
110
+
111
+ constructor(
112
+ {metrics, logger, clock, signal, datastore, blockStateCache, bufferPool}: PersistentCheckpointStateCacheModules,
113
+ opts: PersistentCheckpointStateCacheOpts
114
+ ) {
115
+ this.cache = new MapTracker(metrics?.cpStateCache);
116
+ if (metrics) {
117
+ this.metrics = metrics;
118
+ metrics.cpStateCache.size.addCollect(() => {
119
+ let persistCount = 0;
120
+ let inMemoryCount = 0;
121
+ const memoryEpochs = new Set<Epoch>();
122
+ const persistentEpochs = new Set<Epoch>();
123
+ for (const [key, cacheItem] of this.cache.entries()) {
124
+ const {epoch} = fromCacheKey(key);
125
+ if (isPersistedCacheItem(cacheItem)) {
126
+ persistCount++;
127
+ persistentEpochs.add(epoch);
128
+ } else {
129
+ inMemoryCount++;
130
+ memoryEpochs.add(epoch);
131
+ }
132
+ }
133
+ metrics.cpStateCache.size.set({type: CacheItemType.persisted}, persistCount);
134
+ metrics.cpStateCache.size.set({type: CacheItemType.inMemory}, inMemoryCount);
135
+ metrics.cpStateCache.epochSize.set({type: CacheItemType.persisted}, persistentEpochs.size);
136
+ metrics.cpStateCache.epochSize.set({type: CacheItemType.inMemory}, memoryEpochs.size);
137
+ });
138
+ }
139
+ this.logger = logger;
140
+ this.clock = clock;
141
+ this.signal = signal;
142
+ if (opts.maxCPStateEpochsInMemory !== undefined && opts.maxCPStateEpochsInMemory < 0) {
143
+ throw new Error("maxEpochsInMemory must be >= 0");
144
+ }
145
+ this.maxEpochsInMemory = opts.maxCPStateEpochsInMemory ?? DEFAULT_MAX_CP_STATE_EPOCHS_IN_MEMORY;
146
+ // Specify different datastore for testing
147
+ this.datastore = datastore;
148
+ this.blockStateCache = blockStateCache;
149
+ this.bufferPool = bufferPool;
150
+ }
151
+
152
+ /**
153
+ * Reload checkpoint state keys from the last run.
154
+ */
155
+ async init(): Promise<void> {
156
+ if (this.datastore?.init) {
157
+ await this.datastore.init();
158
+ }
159
+ const persistedKeys = await this.datastore.readKeys();
160
+ // all checkpoint states from the last run are not trusted, remove them
161
+ // otherwise if we have a bad checkpoint state from the last run, the node get stucked
162
+ // this was found during mekong devnet, see https://github.com/ChainSafe/lodestar/pull/7255
163
+ await Promise.all(persistedKeys.map((key) => this.datastore.remove(key)));
164
+ this.logger.info("Removed persisted checkpoint states from the last run", {
165
+ count: persistedKeys.length,
166
+ maxEpochsInMemory: this.maxEpochsInMemory,
167
+ });
168
+ }
169
+
170
+ /**
171
+ * Get a state from cache, it may reload from disk.
172
+ * This is an expensive api, should only be called in some important flows:
173
+ * - Validate a gossip block
174
+ * - Get block for processing
175
+ * - Regen head state
176
+ */
177
+ async getOrReload(cp: CheckpointHex, opts?: StateRegenerationOpts): Promise<CachedBeaconStateAllForks | null> {
178
+ const stateOrStateBytesData = await this.getStateOrLoadDb(cp, opts);
179
+ if (stateOrStateBytesData === null || isCachedBeaconState(stateOrStateBytesData)) {
180
+ return stateOrStateBytesData?.clone(opts?.dontTransferCache) ?? null;
181
+ }
182
+ const {persistedKey, stateBytes} = stateOrStateBytesData;
183
+ const logMeta = {persistedKey: toHex(persistedKey)};
184
+ this.logger.debug("Reload: read state successful", logMeta);
185
+ this.metrics?.cpStateCache.stateReloadSecFromSlot.observe(
186
+ this.clock?.secFromSlot(this.clock?.currentSlot ?? 0) ?? 0
187
+ );
188
+ const seedState = this.findSeedStateToReload(cp);
189
+ this.metrics?.cpStateCache.stateReloadEpochDiff.observe(Math.abs(seedState.epochCtx.epoch - cp.epoch));
190
+ this.logger.debug("Reload: found seed state", {...logMeta, seedSlot: seedState.slot});
191
+
192
+ try {
193
+ // 80% of validators serialization time comes from memory allocation, this is to avoid it
194
+ const sszTimer = this.metrics?.cpStateCache.stateReloadValidatorsSerializeDuration.startTimer();
195
+ // automatically free the buffer pool after this scope
196
+ using validatorsBytesWithKey = this.serializeStateValidators(seedState);
197
+ let validatorsBytes = validatorsBytesWithKey?.buffer;
198
+ if (validatorsBytes == null) {
199
+ // fallback logic in case we can't use the buffer pool
200
+ this.metrics?.cpStateCache.stateReloadValidatorsSerializeAllocCount.inc();
201
+ validatorsBytes = seedState.validators.serialize();
202
+ }
203
+ sszTimer?.();
204
+ const timer = this.metrics?.cpStateCache.stateReloadDuration.startTimer();
205
+ const newCachedState = loadCachedBeaconState(seedState, stateBytes, {}, validatorsBytes);
206
+ newCachedState.commit();
207
+ const stateRoot = toRootHex(newCachedState.hashTreeRoot());
208
+ timer?.();
209
+
210
+ // load all cache in order for consumers (usually regen.getState()) to process blocks faster
211
+ newCachedState.validators.getAllReadonlyValues();
212
+ newCachedState.balances.getAll();
213
+ this.logger.debug("Reload: cached state load successful", {
214
+ ...logMeta,
215
+ stateSlot: newCachedState.slot,
216
+ stateRoot,
217
+ seedSlot: seedState.slot,
218
+ });
219
+
220
+ // only remove persisted state once we reload successfully
221
+ const cpKey = toCacheKey(cp);
222
+ this.cache.set(cpKey, {type: CacheItemType.inMemory, state: newCachedState, persistedKey});
223
+ this.epochIndex.getOrDefault(cp.epoch).add(cp.rootHex);
224
+ // don't prune from memory here, call it at the last 1/3 of slot 0 of an epoch
225
+ return newCachedState.clone(opts?.dontTransferCache);
226
+ } catch (e) {
227
+ this.logger.debug("Reload: error loading cached state", logMeta, e as Error);
228
+ return null;
229
+ }
230
+ }
231
+
232
+ /**
233
+ * Return either state or state bytes loaded from db.
234
+ */
235
+ async getStateOrBytes(cp: CheckpointHex): Promise<CachedBeaconStateAllForks | Uint8Array | null> {
236
+ // don't have to transfer cache for this specific api
237
+ const stateOrLoadedState = await this.getStateOrLoadDb(cp, {dontTransferCache: true});
238
+ if (stateOrLoadedState === null || isCachedBeaconState(stateOrLoadedState)) {
239
+ return stateOrLoadedState;
240
+ }
241
+ return stateOrLoadedState.stateBytes;
242
+ }
243
+
244
+ /**
245
+ * Return either state or state bytes with persisted key loaded from db.
246
+ */
247
+ async getStateOrLoadDb(
248
+ cp: CheckpointHex,
249
+ opts?: StateRegenerationOpts
250
+ ): Promise<CachedBeaconStateAllForks | LoadedStateBytesData | null> {
251
+ const cpKey = toCacheKey(cp);
252
+ const inMemoryState = this.get(cpKey, opts);
253
+ if (inMemoryState) {
254
+ return inMemoryState;
255
+ }
256
+
257
+ const cacheItem = this.cache.get(cpKey);
258
+ if (cacheItem === undefined) {
259
+ return null;
260
+ }
261
+
262
+ if (isInMemoryCacheItem(cacheItem)) {
263
+ // should not happen, in-memory state is handled above
264
+ throw new Error("Expected persistent key");
265
+ }
266
+
267
+ const persistedKey = cacheItem.value;
268
+ const dbReadTimer = this.metrics?.cpStateCache.stateReloadDbReadTime.startTimer();
269
+ const stateBytes = await this.datastore.read(persistedKey);
270
+ dbReadTimer?.();
271
+
272
+ if (stateBytes === null) {
273
+ return null;
274
+ }
275
+ return {persistedKey, stateBytes};
276
+ }
277
+
278
+ /**
279
+ * Similar to get() api without reloading from disk
280
+ */
281
+ get(cpOrKey: CheckpointHex | string, opts?: StateRegenerationOpts): CachedBeaconStateAllForks | null {
282
+ this.metrics?.cpStateCache.lookups.inc();
283
+ const cpKey = typeof cpOrKey === "string" ? cpOrKey : toCacheKey(cpOrKey);
284
+ const cacheItem = this.cache.get(cpKey);
285
+
286
+ if (cacheItem === undefined) {
287
+ return null;
288
+ }
289
+
290
+ this.metrics?.cpStateCache.hits.inc();
291
+
292
+ if (cpKey === this.preComputedCheckpoint) {
293
+ this.preComputedCheckpointHits = (this.preComputedCheckpointHits ?? 0) + 1;
294
+ }
295
+
296
+ if (isInMemoryCacheItem(cacheItem)) {
297
+ const {state} = cacheItem;
298
+ this.metrics?.cpStateCache.stateClonedCount.observe(state.clonedCount);
299
+ return state.clone(opts?.dontTransferCache);
300
+ }
301
+
302
+ return null;
303
+ }
304
+
305
+ /**
306
+ * Add a state of a checkpoint to this cache, prune from memory if necessary.
307
+ */
308
+ add(cp: phase0.Checkpoint, state: CachedBeaconStateAllForks): void {
309
+ const cpHex = toCheckpointHex(cp);
310
+ const key = toCacheKey(cpHex);
311
+ const cacheItem = this.cache.get(key);
312
+ this.metrics?.cpStateCache.adds.inc();
313
+ if (cacheItem !== undefined && isPersistedCacheItem(cacheItem)) {
314
+ const persistedKey = cacheItem.value;
315
+ // was persisted to disk, set back to memory
316
+ this.cache.set(key, {type: CacheItemType.inMemory, state, persistedKey});
317
+ this.logger.verbose("Added checkpoint state to memory but a persisted key existed", {
318
+ epoch: cp.epoch,
319
+ rootHex: cpHex.rootHex,
320
+ persistedKey: toHex(persistedKey),
321
+ });
322
+ } else {
323
+ this.cache.set(key, {type: CacheItemType.inMemory, state});
324
+ this.logger.verbose("Added checkpoint state to memory", {epoch: cp.epoch, rootHex: cpHex.rootHex});
325
+ }
326
+ this.epochIndex.getOrDefault(cp.epoch).add(cpHex.rootHex);
327
+ }
328
+
329
+ /**
330
+ * Searches in-memory state for the latest cached state with a `root` without reload, starting with `epoch` and descending
331
+ */
332
+ getLatest(rootHex: RootHex, maxEpoch: Epoch, opts?: StateRegenerationOpts): CachedBeaconStateAllForks | null {
333
+ // sort epochs in descending order, only consider epochs lte `epoch`
334
+ const epochs = Array.from(this.epochIndex.keys())
335
+ .sort((a, b) => b - a)
336
+ .filter((e) => e <= maxEpoch);
337
+ for (const epoch of epochs) {
338
+ if (this.epochIndex.get(epoch)?.has(rootHex)) {
339
+ const inMemoryClonedState = this.get({rootHex, epoch}, opts);
340
+ if (inMemoryClonedState) {
341
+ return inMemoryClonedState;
342
+ }
343
+ }
344
+ }
345
+ return null;
346
+ }
347
+
348
+ /**
349
+ * Searches state for the latest cached state with a `root`, reload if needed, starting with `epoch` and descending
350
+ * This is expensive api, should only be called in some important flows:
351
+ * - Validate a gossip block
352
+ * - Get block for processing
353
+ * - Regen head state
354
+ */
355
+ async getOrReloadLatest(
356
+ rootHex: RootHex,
357
+ maxEpoch: Epoch,
358
+ opts?: StateRegenerationOpts
359
+ ): Promise<CachedBeaconStateAllForks | null> {
360
+ // sort epochs in descending order, only consider epochs lte `epoch`
361
+ const epochs = Array.from(this.epochIndex.keys())
362
+ .sort((a, b) => b - a)
363
+ .filter((e) => e <= maxEpoch);
364
+ for (const epoch of epochs) {
365
+ if (this.epochIndex.get(epoch)?.has(rootHex)) {
366
+ try {
367
+ const clonedState = await this.getOrReload({rootHex, epoch}, opts);
368
+ if (clonedState) {
369
+ return clonedState;
370
+ }
371
+ } catch (e) {
372
+ this.logger.debug("Error get or reload state", {epoch, rootHex}, e as Error);
373
+ }
374
+ }
375
+ }
376
+ return null;
377
+ }
378
+
379
+ /**
380
+ * Update the precomputed checkpoint and return the number of his for the
381
+ * previous one (if any).
382
+ */
383
+ updatePreComputedCheckpoint(rootHex: RootHex, epoch: Epoch): number | null {
384
+ const previousHits = this.preComputedCheckpointHits;
385
+ this.preComputedCheckpoint = toCacheKey({rootHex, epoch});
386
+ this.preComputedCheckpointHits = 0;
387
+ return previousHits;
388
+ }
389
+
390
+ /**
391
+ * This is just to conform to the old implementation
392
+ */
393
+ prune(): void {
394
+ // do nothing
395
+ }
396
+
397
+ /**
398
+ * Prune all checkpoint states before the provided finalized epoch.
399
+ */
400
+ pruneFinalized(finalizedEpoch: Epoch): void {
401
+ for (const epoch of this.epochIndex.keys()) {
402
+ if (epoch < finalizedEpoch) {
403
+ this.deleteAllEpochItems(epoch).catch((e) =>
404
+ this.logger.debug("Error delete all epoch items", {epoch, finalizedEpoch}, e as Error)
405
+ );
406
+ }
407
+ }
408
+ }
409
+
410
+ /**
411
+ * After processing a block, prune from memory based on the view of that block.
412
+ * This is likely persist 1 state per epoch, at the last 1/3 of slot 0 of an epoch although it'll be called on every last 1/3 of slot.
413
+ * Given the following block b was processed with b2, b1, b0 are ancestors in epoch (n-2), (n-1), n respectively
414
+ *
415
+ * epoch: (n-2) (n-1) n (n+1)
416
+ * |-----------|-----------|-----------|-----------|
417
+ * ^ ^ ^ ^
418
+ * | | | |
419
+ * block chain: b2---------->b1--------->b0-->b
420
+ *
421
+ * After processing block b, if maxEpochsInMemory is:
422
+ * - 2 then we'll persist {root: b2, epoch n-2} checkpoint state to disk
423
+ * - 1 then we'll persist {root: b2, epoch n-2} and {root: b1, epoch n-1} checkpoint state to disk
424
+ * - 0 then we'll persist {root: b2, epoch n-2} and {root: b1, epoch n-1} and {root: b0, epoch n} checkpoint state to disk
425
+ * - if any old epochs checkpoint states are persisted, no need to do it again
426
+ *
427
+ * Note that for each epoch there could be multiple checkpoint states, usually 2, one for Previous Root Checkpoint State and one for Current Root Checkpoint State.
428
+ * We normally only persist 1 checkpoint state per epoch, the one that could potentially be justified/finalized later based on the view of the block.
429
+ * Other checkpoint states are pruned from memory.
430
+ *
431
+ * This design also covers the reorg scenario. Given block c in the same epoch n where c.slot > b.slot, c is not descendant of b, and c is built on top of c0
432
+ * instead of b0 (epoch (n - 1))
433
+ *
434
+ * epoch: (n-2) (n-1) n (n+1)
435
+ * |-----------|-----------|-----------|-----------|
436
+ * ^ ^ ^ ^ ^ ^
437
+ * | | | | | |
438
+ * block chain: b2---------->b1----->c0->b0-->b |
439
+ * ║ |
440
+ * ╚═══════════>c (reorg)
441
+ *
442
+ * After processing block c, if maxEpochsInMemory is:
443
+ * - 0 then we'll persist {root: c0, epoch: n} checkpoint state to disk. Note that regen should populate {root: c0, epoch: n} checkpoint state before.
444
+ *
445
+ * epoch: (n-1) n (n+1)
446
+ * |-------------------------------------------------------------|-------------------------------------------------------------|
447
+ * ^ ^ ^ ^
448
+ * _______ | | | |
449
+ * | | | | | |
450
+ * | db |====== reload ======> {root: b1, epoch: n-1} cp state ======> c0 block state ======> {root: c0, epoch: n} cp state =====> c block state
451
+ * |_______|
452
+ *
453
+ *
454
+ *
455
+ * - 1 then we'll persist {root: b1, epoch n-1} checkpoint state to disk. Note that at epoch n there is both {root: b0, epoch: n} and {root: c0, epoch: n} checkpoint states in memory
456
+ * - 2 then we'll persist {root: b2, epoch n-2} checkpoint state to disk, there are also 2 checkpoint states in memory at epoch n, same to the above (maxEpochsInMemory=1)
457
+ *
458
+ * As of Mar 2024, it takes <=350ms to persist a holesky state on fast server
459
+ */
460
+ async processState(blockRootHex: RootHex, state: CachedBeaconStateAllForks): Promise<number> {
461
+ let persistCount = 0;
462
+ // it's important to sort the epochs in ascending order, in case of big reorg we always want to keep the most recent checkpoint states
463
+ const sortedEpochs = Array.from(this.epochIndex.keys()).sort((a, b) => a - b);
464
+ if (sortedEpochs.length <= this.maxEpochsInMemory) {
465
+ return 0;
466
+ }
467
+
468
+ const blockSlot = state.slot;
469
+ const processCPStatesTimeMs = state.config.getSlotComponentDurationMs(PROCESS_CHECKPOINT_STATES_BPS);
470
+ // we always have clock in production, fallback value is only for test
471
+ const msFromSlot = this.clock?.msFromSlot(blockSlot) ?? processCPStatesTimeMs;
472
+ const msToProcessCPStates = processCPStatesTimeMs - msFromSlot;
473
+ if (msToProcessCPStates > 0) {
474
+ // At ~67% of slot is the most free time of every slot, take that chance to persist checkpoint states
475
+ // normally it should only persist checkpoint states at ~67% of slot 0 of epoch
476
+ await sleep(msToProcessCPStates, this.signal);
477
+ }
478
+ // at syncing time, it's critical to persist checkpoint states as soon as possible to avoid OOM during unfinality time
479
+ // if node is synced this is not a hot time because block comes late, we'll likely miss attestation already, or the block is orphaned
480
+
481
+ const persistEpochs = sortedEpochs.slice(0, sortedEpochs.length - this.maxEpochsInMemory);
482
+ for (const lowestEpoch of persistEpochs) {
483
+ try {
484
+ // getBlockRootAtSlot() may fail, see https://github.com/ChainSafe/lodestar/issues/7495
485
+ if (state.slot < computeStartSlotAtEpoch(lowestEpoch)) {
486
+ // there is no checkpoint states of epochs newer than this state
487
+ break;
488
+ }
489
+ // usually there is only 0 or 1 epoch to persist in this loop
490
+ persistCount += await this.processPastEpoch(blockRootHex, state, lowestEpoch);
491
+ this.logger.verbose("Processed past epoch", {epoch: lowestEpoch, slot: blockSlot, root: blockRootHex});
492
+ } catch (e) {
493
+ this.logger.debug(
494
+ "Error processing past epoch",
495
+ {epoch: lowestEpoch, slot: blockSlot, root: blockRootHex},
496
+ e as Error
497
+ );
498
+ }
499
+ }
500
+
501
+ if (persistCount > 0) {
502
+ this.logger.verbose("Persisted checkpoint states", {
503
+ slot: blockSlot,
504
+ root: blockRootHex,
505
+ persistCount,
506
+ persistEpochs: persistEpochs.length,
507
+ });
508
+ }
509
+ return persistCount;
510
+ }
511
+
512
+ /**
513
+ * Find a seed state to reload the state of provided checkpoint. Based on the design of n-historical state:
514
+ *
515
+ * ╔════════════════════════════════════╗═══════════════╗
516
+ * ║ persisted to db or fs ║ in memory ║
517
+ * ║ reload if needed ║ ║
518
+ * ║ -----------------------------------║---------------║
519
+ * ║ epoch: (n-2) (n-1) ║ n (n+1) ║
520
+ * ║ |-------|-------|----║--|-------|----║
521
+ * ║ ^ ^ ║ ^ ^ ║
522
+ * ║ ║ ^ ^ ║
523
+ * ╚════════════════════════════════════╝═══════════════╝
524
+ *
525
+ * we always reload an epoch in the past. We'll start with epoch n then (n+1) prioritizing ones with the same view of `reloadedCp`.
526
+ *
527
+ * Use seed state from the block cache if cannot find any seed states within this cache.
528
+ */
529
+ findSeedStateToReload(reloadedCp: CheckpointHex): CachedBeaconStateAllForks {
530
+ const maxEpoch = Math.max(...Array.from(this.epochIndex.keys()));
531
+ const reloadedCpSlot = computeStartSlotAtEpoch(reloadedCp.epoch);
532
+ let firstState: CachedBeaconStateAllForks | null = null;
533
+ const logCtx = {reloadedCpEpoch: reloadedCp.epoch, reloadedCpRoot: reloadedCp.rootHex};
534
+
535
+ // no need to check epochs before `maxEpoch - this.maxEpochsInMemory + 1` before they are all persisted
536
+ for (let epoch = maxEpoch - this.maxEpochsInMemory + 1; epoch <= maxEpoch; epoch++) {
537
+ // if there's at least 1 state in memory in an epoch, just return the 1st one
538
+ if (firstState !== null) {
539
+ return firstState;
540
+ }
541
+
542
+ for (const rootHex of this.epochIndex.get(epoch) || []) {
543
+ const cpKey = toCacheKey({rootHex, epoch});
544
+ const cacheItem = this.cache.get(cpKey);
545
+ if (cacheItem === undefined) {
546
+ // should not happen
547
+ continue;
548
+ }
549
+ if (isInMemoryCacheItem(cacheItem)) {
550
+ const {state} = cacheItem;
551
+ if (firstState === null) {
552
+ firstState = state;
553
+ }
554
+ const cpLog = {cpEpoch: epoch, cpRoot: rootHex};
555
+
556
+ try {
557
+ // amongst states of the same epoch, choose the one with the same view of reloadedCp
558
+ if (
559
+ reloadedCpSlot < state.slot &&
560
+ toRootHex(getBlockRootAtSlot(state, reloadedCpSlot)) === reloadedCp.rootHex
561
+ ) {
562
+ this.logger.verbose("Reload: use checkpoint state as seed state", {...cpLog, ...logCtx});
563
+ return state;
564
+ }
565
+ } catch (e) {
566
+ // getBlockRootAtSlot may throw error
567
+ this.logger.debug("Error finding checkpoint state to reload", {...cpLog, ...logCtx}, e as Error);
568
+ }
569
+ }
570
+ }
571
+ }
572
+
573
+ // fallback to using the default seed state from block state cache
574
+ const seedBlockState = this.blockStateCache.getSeedState();
575
+ this.logger.verbose("Reload: use default block state as seed state", {stateSlot: seedBlockState.slot, ...logCtx});
576
+ return seedBlockState;
577
+ }
578
+
579
+ clear(): void {
580
+ this.cache.clear();
581
+ this.epochIndex.clear();
582
+ }
583
+
584
+ /** ONLY FOR DEBUGGING PURPOSES. For lodestar debug API */
585
+ dumpSummary(): routes.lodestar.StateCacheItem[] {
586
+ return Array.from(this.cache.keys()).map((key) => {
587
+ const cp = fromCacheKey(key);
588
+ // TODO: add checkpoint key and persistent key to the summary
589
+ return {
590
+ slot: computeStartSlotAtEpoch(cp.epoch),
591
+ root: cp.rootHex,
592
+ reads: this.cache.readCount.get(key) ?? 0,
593
+ lastRead: this.cache.lastRead.get(key) ?? 0,
594
+ checkpointState: true,
595
+ };
596
+ });
597
+ }
598
+
599
+ getStates(): IterableIterator<CachedBeaconStateAllForks> {
600
+ const items = Array.from(this.cache.values())
601
+ .filter(isInMemoryCacheItem)
602
+ .map((item) => item.state);
603
+
604
+ return items.values();
605
+ }
606
+
607
+ /** ONLY FOR DEBUGGING PURPOSES. For spec tests on error */
608
+ dumpCheckpointKeys(): string[] {
609
+ return Array.from(this.cache.keys());
610
+ }
611
+
612
+ /**
613
+ * Prune or persist checkpoint states in an epoch
614
+ * 1) If there is 1 checkpoint state with known root, persist it. This is when there is skipped slot at block 0 of epoch
615
+ * slot: n
616
+ * |-----------------------|-----------------------|
617
+ * PRCS root |
618
+ *
619
+ * 2) If there are 2 checkpoint states, PRCS and CRCS and both roots are known to this state, persist CRCS. If the block is reorged,
620
+ * PRCS is regen and populated to this cache again.
621
+ * slot: n
622
+ * |-----------------------|-----------------------|
623
+ * PRCS root - prune |
624
+ * CRCS root - persist |
625
+ *
626
+ * 3) If there are any roots that unknown to this state, persist their cp state. This is to handle the current block is reorged later
627
+ *
628
+ * 4) (derived from above) If there are 2 checkpoint states, PRCS and an unknown root, persist both.
629
+ * - In the example below block slot (n + 1) reorged n
630
+ * - If we process state n + 1, CRCS is unknown to it
631
+ * - we need to also store CRCS to handle the case (n+2) switches to n again
632
+ *
633
+ * PRCS - persist
634
+ * | processState()
635
+ * | |
636
+ * -------------n+1
637
+ * / |
638
+ * n-1 ------n------------n+2
639
+ * |
640
+ * CRCS - persist
641
+ *
642
+ * - PRCS is the checkpoint state that could be justified/finalized later based on the view of the state
643
+ * - unknown root checkpoint state is persisted to handle the reorg back to that branch later
644
+ *
645
+ * Performance note:
646
+ * - In normal condition, we persist 1 checkpoint state per epoch.
647
+ * - In reorged condition, we may persist multiple (most likely 2) checkpoint states per epoch.
648
+ */
649
+ private async processPastEpoch(
650
+ blockRootHex: RootHex,
651
+ state: CachedBeaconStateAllForks,
652
+ epoch: Epoch
653
+ ): Promise<number> {
654
+ let persistCount = 0;
655
+ const epochBoundarySlot = computeStartSlotAtEpoch(epoch);
656
+ const epochBoundaryRoot =
657
+ epochBoundarySlot === state.slot ? fromHex(blockRootHex) : getBlockRootAtSlot(state, epochBoundarySlot);
658
+ const epochBoundaryHex = toRootHex(epochBoundaryRoot);
659
+ const prevEpochRoot = toRootHex(getBlockRootAtSlot(state, epochBoundarySlot - 1));
660
+
661
+ // for each epoch, usually there are 2 rootHexes respective to the 2 checkpoint states: Previous Root Checkpoint State and Current Root Checkpoint State
662
+ const cpRootHexes = this.epochIndex.get(epoch) ?? [];
663
+ const persistedRootHexes = new Set<RootHex>();
664
+
665
+ // 1) if there is no CRCS, persist PRCS (block 0 of epoch is skipped). In this case prevEpochRoot === epochBoundaryHex
666
+ // 2) if there are PRCS and CRCS, persist CRCS => persist CRCS
667
+ // => this is simplified to always persist epochBoundaryHex
668
+ persistedRootHexes.add(epochBoundaryHex);
669
+
670
+ // 3) persist any states with unknown roots to this state
671
+ for (const rootHex of cpRootHexes) {
672
+ if (rootHex !== epochBoundaryHex && rootHex !== prevEpochRoot) {
673
+ persistedRootHexes.add(rootHex);
674
+ }
675
+ }
676
+
677
+ for (const rootHex of cpRootHexes) {
678
+ const cpKey = toCacheKey({epoch: epoch, rootHex});
679
+ const cacheItem = this.cache.get(cpKey);
680
+
681
+ if (cacheItem !== undefined && isInMemoryCacheItem(cacheItem)) {
682
+ let {persistedKey} = cacheItem;
683
+ const {state} = cacheItem;
684
+ const logMeta = {
685
+ stateSlot: state.slot,
686
+ rootHex,
687
+ epochBoundaryHex,
688
+ persistedKey: persistedKey ? toHex(persistedKey) : "",
689
+ };
690
+
691
+ if (persistedRootHexes.has(rootHex)) {
692
+ if (persistedKey) {
693
+ // we don't care if the checkpoint state is already persisted
694
+ this.logger.verbose("Pruned checkpoint state from memory but no need to persist", logMeta);
695
+ } else {
696
+ // persist and do not update epochIndex
697
+ this.metrics?.cpStateCache.statePersistSecFromSlot.observe(
698
+ this.clock?.secFromSlot(this.clock?.currentSlot ?? 0) ?? 0
699
+ );
700
+ const cpPersist = {epoch: epoch, root: fromHex(rootHex)};
701
+ // It's not sustainable to allocate ~240MB for each state every epoch, so we use buffer pool to reuse the memory.
702
+ // As monitored on holesky as of Jan 2024:
703
+ // - This does not increase heap allocation while gc time is the same
704
+ // - It helps stabilize persist time and save ~300ms in average (1.5s vs 1.2s)
705
+ // - It also helps the state reload to save ~500ms in average (4.3s vs 3.8s)
706
+ // - Also `serializeState.test.ts` perf test shows a lot of differences allocating ~240MB once vs per state serialization
707
+ const timer = this.metrics?.stateSerializeDuration.startTimer({
708
+ source: AllocSource.PERSISTENT_CHECKPOINTS_CACHE_STATE,
709
+ });
710
+ persistedKey = await serializeState(
711
+ state,
712
+ AllocSource.PERSISTENT_CHECKPOINTS_CACHE_STATE,
713
+ (stateBytes) => {
714
+ timer?.();
715
+ return this.datastore.write(cpPersist, stateBytes);
716
+ },
717
+ this.bufferPool
718
+ );
719
+
720
+ persistCount++;
721
+ this.logger.verbose("Pruned checkpoint state from memory and persisted to disk", {
722
+ ...logMeta,
723
+ persistedKey: toHex(persistedKey),
724
+ });
725
+ }
726
+ // overwrite cpKey, this means the state is deleted from memory
727
+ this.cache.set(cpKey, {type: CacheItemType.persisted, value: persistedKey});
728
+ } else {
729
+ if (persistedKey) {
730
+ // persisted file will be eventually deleted by the archive task
731
+ // this also means the state is deleted from memory
732
+ this.cache.set(cpKey, {type: CacheItemType.persisted, value: persistedKey});
733
+ // do not update epochIndex
734
+ } else {
735
+ // delete the state from memory
736
+ this.cache.delete(cpKey);
737
+ this.epochIndex.get(epoch)?.delete(rootHex);
738
+ }
739
+ this.metrics?.cpStateCache.statePruneFromMemoryCount.inc();
740
+ this.logger.verbose("Pruned checkpoint state from memory", logMeta);
741
+ }
742
+ }
743
+ }
744
+
745
+ return persistCount;
746
+ }
747
+
748
+ /**
749
+ * Delete all items of an epoch from disk and memory
750
+ */
751
+ private async deleteAllEpochItems(epoch: Epoch): Promise<void> {
752
+ let persistCount = 0;
753
+ const rootHexes = this.epochIndex.get(epoch) || [];
754
+ for (const rootHex of rootHexes) {
755
+ const key = toCacheKey({rootHex, epoch});
756
+ const cacheItem = this.cache.get(key);
757
+
758
+ if (cacheItem) {
759
+ const persistedKey = isPersistedCacheItem(cacheItem) ? cacheItem.value : cacheItem.persistedKey;
760
+ if (persistedKey) {
761
+ await this.datastore.remove(persistedKey);
762
+ persistCount++;
763
+ this.metrics?.cpStateCache.persistedStateRemoveCount.inc();
764
+ }
765
+ }
766
+ this.cache.delete(key);
767
+ }
768
+ this.epochIndex.delete(epoch);
769
+ this.logger.verbose("Pruned finalized checkpoints states for epoch", {
770
+ epoch,
771
+ persistCount,
772
+ rootHexes: Array.from(rootHexes).join(","),
773
+ });
774
+ }
775
+
776
+ /**
777
+ * Serialize validators to bytes leveraging the buffer pool to save memory allocation.
778
+ * - As monitored on holesky as of Jan 2024, it helps save ~500ms state reload time (4.3s vs 3.8s)
779
+ * - Also `serializeState.test.ts` perf test shows a lot of differences allocating validators bytes once vs every time,
780
+ * This is 2x - 3x faster than allocating memory every time.
781
+ */
782
+ private serializeStateValidators(state: CachedBeaconStateAllForks): BufferWithKey | null {
783
+ const type = state.type.fields.validators;
784
+ const size = type.tree_serializedSize(state.validators.node);
785
+ if (this.bufferPool) {
786
+ const bufferWithKey = this.bufferPool.alloc(size, AllocSource.PERSISTENT_CHECKPOINTS_CACHE_VALIDATORS);
787
+ if (bufferWithKey) {
788
+ const validatorsBytes = bufferWithKey.buffer;
789
+ const dataView = new DataView(validatorsBytes.buffer, validatorsBytes.byteOffset, validatorsBytes.byteLength);
790
+ state.validators.serializeToBytes({uint8Array: validatorsBytes, dataView}, 0);
791
+ return bufferWithKey;
792
+ }
793
+ }
794
+
795
+ return null;
796
+ }
797
+ }
798
+
799
+ export function toCheckpointHex(checkpoint: phase0.Checkpoint): CheckpointHex {
800
+ return {
801
+ epoch: checkpoint.epoch,
802
+ rootHex: toRootHex(checkpoint.root),
803
+ };
804
+ }
805
+
806
+ function toCacheKey(cp: CheckpointHex | phase0.Checkpoint): CacheKey {
807
+ if (isCheckpointHex(cp)) {
808
+ return `${cp.rootHex}_${cp.epoch}`;
809
+ }
810
+ return `${toRootHex(cp.root)}_${cp.epoch}`;
811
+ }
812
+
813
+ function fromCacheKey(key: CacheKey): CheckpointHex {
814
+ const [rootHex, epoch] = key.split("_");
815
+ return {
816
+ rootHex,
817
+ epoch: Number(epoch),
818
+ };
819
+ }
820
+
821
+ function isCachedBeaconState(
822
+ stateOrBytes: CachedBeaconStateAllForks | LoadedStateBytesData
823
+ ): stateOrBytes is CachedBeaconStateAllForks {
824
+ return (stateOrBytes as CachedBeaconStateAllForks).slot !== undefined;
825
+ }
826
+
827
+ function isInMemoryCacheItem(cacheItem: CacheItem): cacheItem is InMemoryCacheItem {
828
+ return cacheItem.type === CacheItemType.inMemory;
829
+ }
830
+
831
+ function isPersistedCacheItem(cacheItem: CacheItem): cacheItem is PersistedCacheItem {
832
+ return cacheItem.type === CacheItemType.persisted;
833
+ }
834
+
835
+ function isCheckpointHex(cp: CheckpointHex | phase0.Checkpoint): cp is CheckpointHex {
836
+ return (cp as CheckpointHex).rootHex !== undefined;
837
+ }