@lodestar/beacon-node 1.38.0 → 1.39.0-dev.39dac0f03d

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 (388) hide show
  1. package/lib/api/impl/beacon/blocks/utils.js +1 -1
  2. package/lib/api/impl/beacon/blocks/utils.js.map +1 -1
  3. package/lib/api/impl/beacon/state/index.d.ts.map +1 -1
  4. package/lib/api/impl/beacon/state/index.js +4 -5
  5. package/lib/api/impl/beacon/state/index.js.map +1 -1
  6. package/lib/api/impl/validator/index.js +1 -1
  7. package/lib/api/impl/validator/index.js.map +1 -1
  8. package/lib/chain/blocks/verifyBlock.d.ts.map +1 -1
  9. package/lib/chain/blocks/verifyBlock.js +1 -21
  10. package/lib/chain/blocks/verifyBlock.js.map +1 -1
  11. package/lib/chain/blocks/verifyBlocksExecutionPayloads.d.ts +1 -6
  12. package/lib/chain/blocks/verifyBlocksExecutionPayloads.d.ts.map +1 -1
  13. package/lib/chain/blocks/verifyBlocksExecutionPayloads.js +9 -128
  14. package/lib/chain/blocks/verifyBlocksExecutionPayloads.js.map +1 -1
  15. package/lib/chain/blocks/verifyBlocksSignatures.d.ts +3 -2
  16. package/lib/chain/blocks/verifyBlocksSignatures.d.ts.map +1 -1
  17. package/lib/chain/blocks/verifyBlocksSignatures.js +2 -2
  18. package/lib/chain/blocks/verifyBlocksSignatures.js.map +1 -1
  19. package/lib/chain/chain.d.ts +1 -4
  20. package/lib/chain/chain.d.ts.map +1 -1
  21. package/lib/chain/chain.js +10 -28
  22. package/lib/chain/chain.js.map +1 -1
  23. package/lib/chain/initState.d.ts +1 -14
  24. package/lib/chain/initState.d.ts.map +1 -1
  25. package/lib/chain/initState.js +1 -62
  26. package/lib/chain/initState.js.map +1 -1
  27. package/lib/chain/interface.d.ts +0 -2
  28. package/lib/chain/interface.d.ts.map +1 -1
  29. package/lib/chain/interface.js.map +1 -1
  30. package/lib/chain/opPools/aggregatedAttestationPool.d.ts +4 -4
  31. package/lib/chain/opPools/aggregatedAttestationPool.d.ts.map +1 -1
  32. package/lib/chain/opPools/aggregatedAttestationPool.js +4 -4
  33. package/lib/chain/opPools/aggregatedAttestationPool.js.map +1 -1
  34. package/lib/chain/opPools/opPool.d.ts +3 -0
  35. package/lib/chain/opPools/opPool.d.ts.map +1 -1
  36. package/lib/chain/opPools/opPool.js +9 -8
  37. package/lib/chain/opPools/opPool.js.map +1 -1
  38. package/lib/chain/options.d.ts +0 -4
  39. package/lib/chain/options.d.ts.map +1 -1
  40. package/lib/chain/options.js +0 -2
  41. package/lib/chain/options.js.map +1 -1
  42. package/lib/chain/prepareNextSlot.d.ts +0 -4
  43. package/lib/chain/prepareNextSlot.d.ts.map +1 -1
  44. package/lib/chain/prepareNextSlot.js +2 -22
  45. package/lib/chain/prepareNextSlot.js.map +1 -1
  46. package/lib/chain/produceBlock/produceBlockBody.d.ts +2 -22
  47. package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
  48. package/lib/chain/produceBlock/produceBlockBody.js +32 -98
  49. package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
  50. package/lib/chain/rewards/attestationsRewards.d.ts +3 -2
  51. package/lib/chain/rewards/attestationsRewards.d.ts.map +1 -1
  52. package/lib/chain/rewards/attestationsRewards.js +9 -9
  53. package/lib/chain/rewards/attestationsRewards.js.map +1 -1
  54. package/lib/chain/rewards/blockRewards.d.ts +2 -1
  55. package/lib/chain/rewards/blockRewards.d.ts.map +1 -1
  56. package/lib/chain/rewards/blockRewards.js +5 -5
  57. package/lib/chain/rewards/blockRewards.js.map +1 -1
  58. package/lib/chain/rewards/syncCommitteeRewards.d.ts +3 -2
  59. package/lib/chain/rewards/syncCommitteeRewards.d.ts.map +1 -1
  60. package/lib/chain/rewards/syncCommitteeRewards.js +2 -3
  61. package/lib/chain/rewards/syncCommitteeRewards.js.map +1 -1
  62. package/lib/chain/stateCache/persistentCheckpointsCache.d.ts +4 -1
  63. package/lib/chain/stateCache/persistentCheckpointsCache.d.ts.map +1 -1
  64. package/lib/chain/stateCache/persistentCheckpointsCache.js +4 -2
  65. package/lib/chain/stateCache/persistentCheckpointsCache.js.map +1 -1
  66. package/lib/chain/validation/attesterSlashing.js +2 -2
  67. package/lib/chain/validation/attesterSlashing.js.map +1 -1
  68. package/lib/chain/validation/blobSidecar.d.ts.map +1 -1
  69. package/lib/chain/validation/blobSidecar.js +2 -2
  70. package/lib/chain/validation/blobSidecar.js.map +1 -1
  71. package/lib/chain/validation/block.js +1 -1
  72. package/lib/chain/validation/block.js.map +1 -1
  73. package/lib/chain/validation/blsToExecutionChange.js +1 -1
  74. package/lib/chain/validation/dataColumnSidecar.d.ts.map +1 -1
  75. package/lib/chain/validation/dataColumnSidecar.js +2 -2
  76. package/lib/chain/validation/dataColumnSidecar.js.map +1 -1
  77. package/lib/chain/validation/proposerSlashing.js +1 -1
  78. package/lib/chain/validation/proposerSlashing.js.map +1 -1
  79. package/lib/chain/validation/signatureSets/aggregateAndProof.js +1 -1
  80. package/lib/chain/validation/signatureSets/aggregateAndProof.js.map +1 -1
  81. package/lib/chain/validation/signatureSets/contributionAndProof.d.ts +3 -2
  82. package/lib/chain/validation/signatureSets/contributionAndProof.d.ts.map +1 -1
  83. package/lib/chain/validation/signatureSets/contributionAndProof.js +3 -4
  84. package/lib/chain/validation/signatureSets/contributionAndProof.js.map +1 -1
  85. package/lib/chain/validation/signatureSets/syncCommittee.d.ts +3 -2
  86. package/lib/chain/validation/signatureSets/syncCommittee.d.ts.map +1 -1
  87. package/lib/chain/validation/signatureSets/syncCommittee.js +3 -3
  88. package/lib/chain/validation/signatureSets/syncCommittee.js.map +1 -1
  89. package/lib/chain/validation/signatureSets/syncCommitteeContribution.d.ts +2 -1
  90. package/lib/chain/validation/signatureSets/syncCommitteeContribution.d.ts.map +1 -1
  91. package/lib/chain/validation/signatureSets/syncCommitteeContribution.js +2 -2
  92. package/lib/chain/validation/signatureSets/syncCommitteeContribution.js.map +1 -1
  93. package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.d.ts +3 -2
  94. package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.d.ts.map +1 -1
  95. package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.js +2 -3
  96. package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.js.map +1 -1
  97. package/lib/chain/validation/syncCommittee.js +1 -1
  98. package/lib/chain/validation/syncCommittee.js.map +1 -1
  99. package/lib/chain/validation/syncCommitteeContributionAndProof.d.ts.map +1 -1
  100. package/lib/chain/validation/syncCommitteeContributionAndProof.js +5 -4
  101. package/lib/chain/validation/syncCommitteeContributionAndProof.js.map +1 -1
  102. package/lib/chain/validation/voluntaryExit.js +1 -1
  103. package/lib/chain/validation/voluntaryExit.js.map +1 -1
  104. package/lib/db/beacon.d.ts +3 -7
  105. package/lib/db/beacon.d.ts.map +1 -1
  106. package/lib/db/beacon.js +33 -12
  107. package/lib/db/beacon.js.map +1 -1
  108. package/lib/db/buckets.d.ts +12 -6
  109. package/lib/db/buckets.d.ts.map +1 -1
  110. package/lib/db/buckets.js +6 -1
  111. package/lib/db/buckets.js.map +1 -1
  112. package/lib/db/interface.d.ts +2 -7
  113. package/lib/db/interface.d.ts.map +1 -1
  114. package/lib/db/repositories/index.d.ts +0 -3
  115. package/lib/db/repositories/index.d.ts.map +1 -1
  116. package/lib/db/repositories/index.js +0 -3
  117. package/lib/db/repositories/index.js.map +1 -1
  118. package/lib/execution/engine/http.d.ts +5 -13
  119. package/lib/execution/engine/http.d.ts.map +1 -1
  120. package/lib/execution/engine/http.js +6 -15
  121. package/lib/execution/engine/http.js.map +1 -1
  122. package/lib/execution/engine/index.d.ts.map +1 -1
  123. package/lib/execution/engine/index.js +1 -1
  124. package/lib/execution/engine/index.js.map +1 -1
  125. package/lib/execution/engine/interface.d.ts +1 -1
  126. package/lib/execution/engine/interface.d.ts.map +1 -1
  127. package/lib/execution/engine/interface.js.map +1 -1
  128. package/lib/{eth1/provider → execution/engine}/jsonRpcHttpClient.d.ts +1 -1
  129. package/lib/execution/engine/jsonRpcHttpClient.d.ts.map +1 -0
  130. package/lib/execution/engine/jsonRpcHttpClient.js.map +1 -0
  131. package/lib/execution/engine/jwt.d.ts.map +1 -0
  132. package/lib/execution/engine/jwt.js.map +1 -0
  133. package/lib/execution/engine/mock.d.ts +2 -6
  134. package/lib/execution/engine/mock.d.ts.map +1 -1
  135. package/lib/execution/engine/mock.js +4 -15
  136. package/lib/execution/engine/mock.js.map +1 -1
  137. package/lib/execution/engine/payloadIdCache.d.ts +1 -1
  138. package/lib/execution/engine/payloadIdCache.d.ts.map +1 -1
  139. package/lib/execution/engine/types.d.ts +1 -1
  140. package/lib/execution/engine/types.d.ts.map +1 -1
  141. package/lib/execution/engine/types.js +1 -1
  142. package/lib/execution/engine/types.js.map +1 -1
  143. package/lib/execution/engine/utils.d.ts +64 -2
  144. package/lib/execution/engine/utils.d.ts.map +1 -1
  145. package/lib/execution/engine/utils.js +91 -2
  146. package/lib/execution/engine/utils.js.map +1 -1
  147. package/lib/index.d.ts +1 -2
  148. package/lib/index.d.ts.map +1 -1
  149. package/lib/index.js +1 -2
  150. package/lib/index.js.map +1 -1
  151. package/lib/metrics/metrics/lodestar.d.ts +0 -49
  152. package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
  153. package/lib/metrics/metrics/lodestar.js +0 -134
  154. package/lib/metrics/metrics/lodestar.js.map +1 -1
  155. package/lib/network/core/events.d.ts +1 -1
  156. package/lib/network/core/events.d.ts.map +1 -1
  157. package/lib/network/core/events.js +1 -1
  158. package/lib/network/core/events.js.map +1 -1
  159. package/lib/network/events.d.ts +6 -1
  160. package/lib/network/events.d.ts.map +1 -1
  161. package/lib/network/events.js +7 -1
  162. package/lib/network/events.js.map +1 -1
  163. package/lib/node/nodejs.d.ts.map +1 -1
  164. package/lib/node/nodejs.js +10 -9
  165. package/lib/node/nodejs.js.map +1 -1
  166. package/lib/node/notifier.d.ts.map +1 -1
  167. package/lib/node/notifier.js +0 -13
  168. package/lib/node/notifier.js.map +1 -1
  169. package/lib/node/options.d.ts +0 -2
  170. package/lib/node/options.d.ts.map +1 -1
  171. package/lib/node/options.js +0 -2
  172. package/lib/node/options.js.map +1 -1
  173. package/lib/node/utils/interop/deposits.d.ts +2 -1
  174. package/lib/node/utils/interop/deposits.d.ts.map +1 -1
  175. package/lib/node/utils/interop/deposits.js.map +1 -1
  176. package/lib/node/utils/interop/state.d.ts +1 -1
  177. package/lib/node/utils/interop/state.d.ts.map +1 -1
  178. package/lib/node/utils/state.d.ts +1 -7
  179. package/lib/node/utils/state.d.ts.map +1 -1
  180. package/lib/node/utils/state.js +1 -14
  181. package/lib/node/utils/state.js.map +1 -1
  182. package/lib/sync/backfill/backfill.d.ts.map +1 -1
  183. package/lib/sync/backfill/backfill.js +2 -2
  184. package/lib/sync/backfill/backfill.js.map +1 -1
  185. package/lib/sync/backfill/verify.d.ts +2 -2
  186. package/lib/sync/backfill/verify.d.ts.map +1 -1
  187. package/lib/sync/backfill/verify.js +3 -3
  188. package/lib/sync/backfill/verify.js.map +1 -1
  189. package/lib/util/workerEvents.d.ts +1 -6
  190. package/lib/util/workerEvents.d.ts.map +1 -1
  191. package/lib/util/workerEvents.js +8 -8
  192. package/lib/util/workerEvents.js.map +1 -1
  193. package/package.json +14 -21
  194. package/src/api/impl/beacon/blocks/utils.ts +1 -1
  195. package/src/api/impl/beacon/state/index.ts +4 -5
  196. package/src/api/impl/validator/index.ts +1 -1
  197. package/src/chain/blocks/verifyBlock.ts +3 -24
  198. package/src/chain/blocks/verifyBlocksExecutionPayloads.ts +9 -161
  199. package/src/chain/blocks/verifyBlocksSignatures.ts +5 -2
  200. package/src/chain/chain.ts +9 -32
  201. package/src/chain/initState.ts +1 -97
  202. package/src/chain/interface.ts +0 -2
  203. package/src/chain/opPools/aggregatedAttestationPool.ts +7 -7
  204. package/src/chain/opPools/opPool.ts +8 -8
  205. package/src/chain/options.ts +0 -6
  206. package/src/chain/prepareNextSlot.ts +2 -29
  207. package/src/chain/produceBlock/produceBlockBody.ts +33 -132
  208. package/src/chain/rewards/attestationsRewards.ts +18 -8
  209. package/src/chain/rewards/blockRewards.ts +6 -3
  210. package/src/chain/rewards/syncCommitteeRewards.ts +5 -3
  211. package/src/chain/stateCache/persistentCheckpointsCache.ts +15 -2
  212. package/src/chain/validation/attesterSlashing.ts +2 -2
  213. package/src/chain/validation/blobSidecar.ts +10 -2
  214. package/src/chain/validation/block.ts +1 -1
  215. package/src/chain/validation/blsToExecutionChange.ts +1 -1
  216. package/src/chain/validation/dataColumnSidecar.ts +6 -1
  217. package/src/chain/validation/proposerSlashing.ts +1 -1
  218. package/src/chain/validation/signatureSets/aggregateAndProof.ts +1 -1
  219. package/src/chain/validation/signatureSets/contributionAndProof.ts +6 -3
  220. package/src/chain/validation/signatureSets/syncCommittee.ts +6 -2
  221. package/src/chain/validation/signatureSets/syncCommitteeContribution.ts +3 -1
  222. package/src/chain/validation/signatureSets/syncCommitteeSelectionProof.ts +5 -2
  223. package/src/chain/validation/syncCommittee.ts +1 -1
  224. package/src/chain/validation/syncCommitteeContributionAndProof.ts +10 -6
  225. package/src/chain/validation/voluntaryExit.ts +1 -1
  226. package/src/db/beacon.ts +38 -16
  227. package/src/db/buckets.ts +12 -7
  228. package/src/db/interface.ts +2 -13
  229. package/src/db/repositories/index.ts +0 -3
  230. package/src/execution/engine/http.ts +12 -21
  231. package/src/execution/engine/index.ts +1 -1
  232. package/src/execution/engine/interface.ts +1 -1
  233. package/src/{eth1/provider → execution/engine}/jsonRpcHttpClient.ts +1 -1
  234. package/src/execution/engine/mock.ts +4 -17
  235. package/src/execution/engine/payloadIdCache.ts +1 -1
  236. package/src/execution/engine/types.ts +9 -9
  237. package/src/execution/engine/utils.ts +111 -5
  238. package/src/index.ts +1 -2
  239. package/src/metrics/metrics/lodestar.ts +0 -144
  240. package/src/network/core/events.ts +1 -1
  241. package/src/network/events.ts +7 -1
  242. package/src/node/nodejs.ts +11 -9
  243. package/src/node/notifier.ts +0 -16
  244. package/src/node/options.ts +0 -3
  245. package/src/node/utils/interop/deposits.ts +3 -1
  246. package/src/node/utils/interop/state.ts +1 -1
  247. package/src/node/utils/state.ts +3 -18
  248. package/src/sync/backfill/backfill.ts +14 -2
  249. package/src/sync/backfill/verify.ts +10 -2
  250. package/src/util/workerEvents.ts +9 -8
  251. package/lib/chain/genesis/genesis.d.ts +0 -51
  252. package/lib/chain/genesis/genesis.d.ts.map +0 -1
  253. package/lib/chain/genesis/genesis.js +0 -123
  254. package/lib/chain/genesis/genesis.js.map +0 -1
  255. package/lib/chain/genesis/interface.d.ts +0 -13
  256. package/lib/chain/genesis/interface.d.ts.map +0 -1
  257. package/lib/chain/genesis/interface.js +0 -2
  258. package/lib/chain/genesis/interface.js.map +0 -1
  259. package/lib/db/repositories/depositDataRoot.d.ts +0 -22
  260. package/lib/db/repositories/depositDataRoot.d.ts.map +0 -1
  261. package/lib/db/repositories/depositDataRoot.js +0 -62
  262. package/lib/db/repositories/depositDataRoot.js.map +0 -1
  263. package/lib/db/repositories/depositEvent.d.ts +0 -13
  264. package/lib/db/repositories/depositEvent.d.ts.map +0 -1
  265. package/lib/db/repositories/depositEvent.js +0 -27
  266. package/lib/db/repositories/depositEvent.js.map +0 -1
  267. package/lib/db/repositories/eth1Data.d.ts +0 -13
  268. package/lib/db/repositories/eth1Data.d.ts.map +0 -1
  269. package/lib/db/repositories/eth1Data.js +0 -26
  270. package/lib/db/repositories/eth1Data.js.map +0 -1
  271. package/lib/db/single/index.d.ts +0 -3
  272. package/lib/db/single/index.d.ts.map +0 -1
  273. package/lib/db/single/index.js +0 -3
  274. package/lib/db/single/index.js.map +0 -1
  275. package/lib/db/single/preGenesisState.d.ts +0 -16
  276. package/lib/db/single/preGenesisState.d.ts.map +0 -1
  277. package/lib/db/single/preGenesisState.js +0 -29
  278. package/lib/db/single/preGenesisState.js.map +0 -1
  279. package/lib/db/single/preGenesisStateLastProcessedBlock.d.ts +0 -14
  280. package/lib/db/single/preGenesisStateLastProcessedBlock.d.ts.map +0 -1
  281. package/lib/db/single/preGenesisStateLastProcessedBlock.js +0 -27
  282. package/lib/db/single/preGenesisStateLastProcessedBlock.js.map +0 -1
  283. package/lib/eth1/errors.d.ts +0 -66
  284. package/lib/eth1/errors.d.ts.map +0 -1
  285. package/lib/eth1/errors.js +0 -27
  286. package/lib/eth1/errors.js.map +0 -1
  287. package/lib/eth1/eth1DataCache.d.ts +0 -19
  288. package/lib/eth1/eth1DataCache.d.ts.map +0 -1
  289. package/lib/eth1/eth1DataCache.js +0 -19
  290. package/lib/eth1/eth1DataCache.js.map +0 -1
  291. package/lib/eth1/eth1DepositDataTracker.d.ts +0 -80
  292. package/lib/eth1/eth1DepositDataTracker.d.ts.map +0 -1
  293. package/lib/eth1/eth1DepositDataTracker.js +0 -317
  294. package/lib/eth1/eth1DepositDataTracker.js.map +0 -1
  295. package/lib/eth1/eth1DepositsCache.d.ts +0 -42
  296. package/lib/eth1/eth1DepositsCache.d.ts.map +0 -1
  297. package/lib/eth1/eth1DepositsCache.js +0 -119
  298. package/lib/eth1/eth1DepositsCache.js.map +0 -1
  299. package/lib/eth1/eth1MergeBlockTracker.d.ts +0 -65
  300. package/lib/eth1/eth1MergeBlockTracker.d.ts.map +0 -1
  301. package/lib/eth1/eth1MergeBlockTracker.js +0 -262
  302. package/lib/eth1/eth1MergeBlockTracker.js.map +0 -1
  303. package/lib/eth1/index.d.ts +0 -46
  304. package/lib/eth1/index.d.ts.map +0 -1
  305. package/lib/eth1/index.js +0 -121
  306. package/lib/eth1/index.js.map +0 -1
  307. package/lib/eth1/interface.d.ts +0 -112
  308. package/lib/eth1/interface.d.ts.map +0 -1
  309. package/lib/eth1/interface.js +0 -8
  310. package/lib/eth1/interface.js.map +0 -1
  311. package/lib/eth1/options.d.ts +0 -22
  312. package/lib/eth1/options.d.ts.map +0 -1
  313. package/lib/eth1/options.js +0 -8
  314. package/lib/eth1/options.js.map +0 -1
  315. package/lib/eth1/provider/eth1Provider.d.ts +0 -39
  316. package/lib/eth1/provider/eth1Provider.d.ts.map +0 -1
  317. package/lib/eth1/provider/eth1Provider.js +0 -147
  318. package/lib/eth1/provider/eth1Provider.js.map +0 -1
  319. package/lib/eth1/provider/jsonRpcHttpClient.d.ts.map +0 -1
  320. package/lib/eth1/provider/jsonRpcHttpClient.js.map +0 -1
  321. package/lib/eth1/provider/jwt.d.ts.map +0 -1
  322. package/lib/eth1/provider/jwt.js.map +0 -1
  323. package/lib/eth1/provider/utils.d.ts +0 -65
  324. package/lib/eth1/provider/utils.d.ts.map +0 -1
  325. package/lib/eth1/provider/utils.js +0 -120
  326. package/lib/eth1/provider/utils.js.map +0 -1
  327. package/lib/eth1/stream.d.ts +0 -15
  328. package/lib/eth1/stream.d.ts.map +0 -1
  329. package/lib/eth1/stream.js +0 -54
  330. package/lib/eth1/stream.js.map +0 -1
  331. package/lib/eth1/utils/depositContract.d.ts +0 -14
  332. package/lib/eth1/utils/depositContract.d.ts.map +0 -1
  333. package/lib/eth1/utils/depositContract.js +0 -33
  334. package/lib/eth1/utils/depositContract.js.map +0 -1
  335. package/lib/eth1/utils/deposits.d.ts +0 -8
  336. package/lib/eth1/utils/deposits.d.ts.map +0 -1
  337. package/lib/eth1/utils/deposits.js +0 -47
  338. package/lib/eth1/utils/deposits.js.map +0 -1
  339. package/lib/eth1/utils/eth1Data.d.ts +0 -22
  340. package/lib/eth1/utils/eth1Data.d.ts.map +0 -1
  341. package/lib/eth1/utils/eth1Data.js +0 -77
  342. package/lib/eth1/utils/eth1Data.js.map +0 -1
  343. package/lib/eth1/utils/eth1DepositEvent.d.ts +0 -7
  344. package/lib/eth1/utils/eth1DepositEvent.d.ts.map +0 -1
  345. package/lib/eth1/utils/eth1DepositEvent.js +0 -13
  346. package/lib/eth1/utils/eth1DepositEvent.js.map +0 -1
  347. package/lib/eth1/utils/eth1Vote.d.ts +0 -17
  348. package/lib/eth1/utils/eth1Vote.d.ts.map +0 -1
  349. package/lib/eth1/utils/eth1Vote.js +0 -111
  350. package/lib/eth1/utils/eth1Vote.js.map +0 -1
  351. package/lib/eth1/utils/groupDepositEventsByBlock.d.ts +0 -9
  352. package/lib/eth1/utils/groupDepositEventsByBlock.d.ts.map +0 -1
  353. package/lib/eth1/utils/groupDepositEventsByBlock.js +0 -17
  354. package/lib/eth1/utils/groupDepositEventsByBlock.js.map +0 -1
  355. package/lib/eth1/utils/optimizeNextBlockDiffForGenesis.d.ts +0 -10
  356. package/lib/eth1/utils/optimizeNextBlockDiffForGenesis.d.ts.map +0 -1
  357. package/lib/eth1/utils/optimizeNextBlockDiffForGenesis.js +0 -14
  358. package/lib/eth1/utils/optimizeNextBlockDiffForGenesis.js.map +0 -1
  359. package/src/chain/genesis/genesis.ts +0 -190
  360. package/src/chain/genesis/interface.ts +0 -14
  361. package/src/db/repositories/depositDataRoot.ts +0 -80
  362. package/src/db/repositories/depositEvent.ts +0 -32
  363. package/src/db/repositories/eth1Data.ts +0 -33
  364. package/src/db/single/index.ts +0 -2
  365. package/src/db/single/preGenesisState.ts +0 -37
  366. package/src/db/single/preGenesisStateLastProcessedBlock.ts +0 -34
  367. package/src/eth1/errors.ts +0 -40
  368. package/src/eth1/eth1DataCache.ts +0 -26
  369. package/src/eth1/eth1DepositDataTracker.ts +0 -410
  370. package/src/eth1/eth1DepositsCache.ts +0 -141
  371. package/src/eth1/eth1MergeBlockTracker.ts +0 -328
  372. package/src/eth1/index.ts +0 -157
  373. package/src/eth1/interface.ts +0 -131
  374. package/src/eth1/options.ts +0 -28
  375. package/src/eth1/provider/eth1Provider.ts +0 -229
  376. package/src/eth1/provider/utils.ts +0 -136
  377. package/src/eth1/stream.ts +0 -75
  378. package/src/eth1/utils/depositContract.ts +0 -37
  379. package/src/eth1/utils/deposits.ts +0 -70
  380. package/src/eth1/utils/eth1Data.ts +0 -100
  381. package/src/eth1/utils/eth1DepositEvent.ts +0 -12
  382. package/src/eth1/utils/eth1Vote.ts +0 -142
  383. package/src/eth1/utils/groupDepositEventsByBlock.ts +0 -19
  384. package/src/eth1/utils/optimizeNextBlockDiffForGenesis.ts +0 -18
  385. /package/lib/{eth1/provider → execution/engine}/jsonRpcHttpClient.js +0 -0
  386. /package/lib/{eth1/provider → execution/engine}/jwt.d.ts +0 -0
  387. /package/lib/{eth1/provider → execution/engine}/jwt.js +0 -0
  388. /package/src/{eth1/provider → execution/engine}/jwt.ts +0 -0
@@ -1,190 +0,0 @@
1
- import {Tree, toGindex} from "@chainsafe/persistent-merkle-tree";
2
- import {BeaconConfig, ChainForkConfig} from "@lodestar/config";
3
- import {GENESIS_EPOCH, GENESIS_SLOT} from "@lodestar/params";
4
- import {
5
- BeaconStateAllForks,
6
- CachedBeaconStateAllForks,
7
- applyDeposits,
8
- applyEth1BlockHash,
9
- applyTimestamp,
10
- createCachedBeaconState,
11
- createEmptyEpochCacheImmutableData,
12
- getActiveValidatorIndices,
13
- getGenesisBeaconState,
14
- getTemporaryBlockHeader,
15
- } from "@lodestar/state-transition";
16
- import {phase0, ssz} from "@lodestar/types";
17
- import {Logger} from "@lodestar/utils";
18
- import {DepositTree} from "../../db/repositories/depositDataRoot.js";
19
- import {IEth1Provider} from "../../eth1/index.js";
20
- import {IEth1StreamParams} from "../../eth1/interface.js";
21
- import {getDepositsAndBlockStreamForGenesis, getDepositsStream} from "../../eth1/stream.js";
22
- import {GenesisResult, IGenesisBuilder} from "./interface.js";
23
-
24
- export type GenesisBuilderKwargs = {
25
- config: ChainForkConfig;
26
- eth1Provider: IEth1Provider;
27
- logger: Logger;
28
-
29
- /** Use to restore pending progress */
30
- pendingStatus?: {
31
- state: BeaconStateAllForks;
32
- depositTree: DepositTree;
33
- lastProcessedBlockNumber: number;
34
- };
35
-
36
- signal?: AbortSignal;
37
- maxBlocksPerPoll?: number;
38
- };
39
-
40
- export class GenesisBuilder implements IGenesisBuilder {
41
- // Expose state to persist on error
42
- readonly state: CachedBeaconStateAllForks;
43
- readonly depositTree: DepositTree;
44
- /** Is null if no block has been processed yet */
45
- lastProcessedBlockNumber: number | null = null;
46
-
47
- private readonly config: BeaconConfig;
48
- private readonly eth1Provider: IEth1Provider;
49
- private readonly logger: Logger;
50
- private readonly signal?: AbortSignal;
51
- private readonly eth1Params: IEth1StreamParams;
52
- private readonly depositCache = new Set<number>();
53
- private readonly fromBlock: number;
54
- private readonly logEvery = 30 * 1000;
55
- private lastLog = 0;
56
- /** Current count of active validators in the state */
57
- private activatedValidatorCount: number;
58
-
59
- constructor({config, eth1Provider, logger, signal, pendingStatus, maxBlocksPerPoll}: GenesisBuilderKwargs) {
60
- // at genesis builder, there is no genesis validator so we don't have a real BeaconConfig
61
- // but we need BeaconConfig to temporarily create CachedBeaconState, the cast here is safe since we don't use any getDomain here
62
- // the use of state as CachedBeaconState is just for convenient, GenesisResult returns TreeView anyway
63
- this.eth1Provider = eth1Provider;
64
- this.logger = logger;
65
- this.signal = signal;
66
- this.eth1Params = {
67
- ...config,
68
- maxBlocksPerPoll: maxBlocksPerPoll ?? 10000,
69
- };
70
-
71
- let stateView: BeaconStateAllForks;
72
-
73
- if (pendingStatus) {
74
- this.logger.info("Restoring pending genesis state", {block: pendingStatus.lastProcessedBlockNumber});
75
- stateView = pendingStatus.state;
76
- this.depositTree = pendingStatus.depositTree;
77
- this.fromBlock = Math.max(pendingStatus.lastProcessedBlockNumber + 1, this.eth1Provider.deployBlock);
78
- } else {
79
- stateView = getGenesisBeaconState(
80
- config,
81
- ssz.phase0.Eth1Data.defaultValue(),
82
- getTemporaryBlockHeader(config, config.getForkTypes(GENESIS_SLOT).BeaconBlock.defaultValue())
83
- );
84
- this.depositTree = ssz.phase0.DepositDataRootList.defaultViewDU();
85
- this.fromBlock = this.eth1Provider.deployBlock;
86
- }
87
-
88
- // TODO - PENDING: Ensure EpochCacheImmutableData is created only once
89
- this.state = createCachedBeaconState(stateView, createEmptyEpochCacheImmutableData(config, stateView));
90
- this.config = this.state.config;
91
- this.activatedValidatorCount = getActiveValidatorIndices(stateView, GENESIS_EPOCH).length;
92
- }
93
-
94
- /**
95
- * Get eth1 deposit events and blocks and apply to this.state until we found genesis.
96
- */
97
- async waitForGenesis(): Promise<GenesisResult> {
98
- await this.eth1Provider.validateContract();
99
-
100
- // Load data from data from this.db.depositData, this.db.depositDataRoot
101
- // And start from a more recent fromBlock
102
- const blockNumberValidatorGenesis = await this.waitForGenesisValidators();
103
-
104
- const depositsAndBlocksStream = getDepositsAndBlockStreamForGenesis(
105
- blockNumberValidatorGenesis,
106
- this.eth1Provider,
107
- this.eth1Params,
108
- this.signal
109
- );
110
-
111
- for await (const [depositEvents, block] of depositsAndBlocksStream) {
112
- this.applyDeposits(depositEvents);
113
- applyTimestamp(this.config, this.state, block.timestamp);
114
- applyEth1BlockHash(this.state, block.blockHash);
115
- this.lastProcessedBlockNumber = block.blockNumber;
116
-
117
- if (
118
- this.state.genesisTime >= this.config.MIN_GENESIS_TIME &&
119
- this.activatedValidatorCount >= this.config.MIN_GENESIS_ACTIVE_VALIDATOR_COUNT
120
- ) {
121
- this.logger.info("Found genesis state", {blockNumber: block.blockNumber});
122
- return {
123
- state: this.state,
124
- depositTree: this.depositTree,
125
- block,
126
- };
127
- }
128
-
129
- this.throttledLog(`Waiting for min genesis time ${block.timestamp} / ${this.config.MIN_GENESIS_TIME}`);
130
- }
131
-
132
- throw Error("depositsStream stopped without a valid genesis state");
133
- }
134
-
135
- /**
136
- * First phase of waiting for genesis.
137
- * Stream deposits events in batches as big as possible without querying block data
138
- * @returns Block number at which there are enough active validators is state for genesis
139
- */
140
- private async waitForGenesisValidators(): Promise<number> {
141
- const depositsStream = getDepositsStream(this.fromBlock, this.eth1Provider, this.eth1Params, this.signal);
142
-
143
- for await (const {depositEvents, blockNumber} of depositsStream) {
144
- this.applyDeposits(depositEvents);
145
- this.lastProcessedBlockNumber = blockNumber;
146
-
147
- if (this.activatedValidatorCount >= this.config.MIN_GENESIS_ACTIVE_VALIDATOR_COUNT) {
148
- this.logger.info("Found enough genesis validators", {blockNumber});
149
- return blockNumber;
150
- }
151
-
152
- this.throttledLog(
153
- `Found ${this.state.validators.length} / ${this.config.MIN_GENESIS_ACTIVE_VALIDATOR_COUNT} validators to genesis`
154
- );
155
- }
156
-
157
- throw Error("depositsStream stopped without a valid genesis state");
158
- }
159
-
160
- private applyDeposits(depositEvents: phase0.DepositEvent[]): void {
161
- const newDeposits = depositEvents
162
- .filter((depositEvent) => !this.depositCache.has(depositEvent.index))
163
- .map((depositEvent) => {
164
- this.depositCache.add(depositEvent.index);
165
- this.depositTree.push(ssz.phase0.DepositData.hashTreeRoot(depositEvent.depositData));
166
- const gindex = toGindex(this.depositTree.type.depth, BigInt(depositEvent.index));
167
-
168
- // Apply changes from the push above
169
- this.depositTree.commit();
170
- const depositTreeNode = this.depositTree.node;
171
- return {
172
- proof: new Tree(depositTreeNode).getSingleProof(gindex),
173
- data: depositEvent.depositData,
174
- };
175
- });
176
-
177
- const {activatedValidatorCount} = applyDeposits(this.config, this.state, newDeposits, this.depositTree);
178
- this.activatedValidatorCount += activatedValidatorCount;
179
-
180
- // TODO: If necessary persist deposits here to this.db.depositData, this.db.depositDataRoot
181
- }
182
-
183
- /** Throttle genesis generation status log to prevent spamming */
184
- private throttledLog(message: string): void {
185
- if (Date.now() - this.lastLog > this.logEvery) {
186
- this.lastLog = Date.now();
187
- this.logger.info(message);
188
- }
189
- }
190
- }
@@ -1,14 +0,0 @@
1
- import {CompositeViewDU, VectorCompositeType} from "@chainsafe/ssz";
2
- import {CachedBeaconStateAllForks} from "@lodestar/state-transition";
3
- import {ssz} from "@lodestar/types";
4
- import {Eth1Block} from "../../eth1/interface.js";
5
-
6
- export type GenesisResult = {
7
- state: CachedBeaconStateAllForks;
8
- depositTree: CompositeViewDU<VectorCompositeType<typeof ssz.Root>>;
9
- block: Eth1Block;
10
- };
11
-
12
- export interface IGenesisBuilder {
13
- waitForGenesis: () => Promise<GenesisResult>;
14
- }
@@ -1,80 +0,0 @@
1
- import {ByteVectorType, CompositeViewDU, ListCompositeType} from "@chainsafe/ssz";
2
- import {ChainForkConfig} from "@lodestar/config";
3
- import {Db, KeyValue, Repository} from "@lodestar/db";
4
- import {Root, ssz} from "@lodestar/types";
5
- import {bytesToInt} from "@lodestar/utils";
6
- import {Bucket, getBucketNameByValue} from "../buckets.js";
7
-
8
- // TODO: Review where is best to put this type
9
- export type DepositTree = CompositeViewDU<ListCompositeType<ByteVectorType>>;
10
-
11
- export class DepositDataRootRepository extends Repository<number, Root> {
12
- private depositRootTree?: DepositTree;
13
-
14
- constructor(config: ChainForkConfig, db: Db) {
15
- const bucket = Bucket.index_depositDataRoot;
16
- super(config, db, bucket, ssz.Root, getBucketNameByValue(bucket));
17
- }
18
-
19
- decodeKey(data: Buffer): number {
20
- return bytesToInt(super.decodeKey(data) as unknown as Uint8Array, "be");
21
- }
22
-
23
- // depositDataRoots stored by depositData index
24
- getId(_value: Root): number {
25
- throw new Error("Unable to create depositIndex from root");
26
- }
27
-
28
- async put(index: number, value: Root): Promise<void> {
29
- await super.put(index, value);
30
- await this.depositRootTreeSet(index, value);
31
- }
32
-
33
- async batchPut(items: KeyValue<number, Root>[]): Promise<void> {
34
- await super.batchPut(items);
35
- for (const {key, value} of items) {
36
- await this.depositRootTreeSet(key, value);
37
- }
38
- }
39
-
40
- async putList(roots: Root[]): Promise<void> {
41
- await this.batchPut(roots.map((root, index) => ({key: index, value: root})));
42
- }
43
-
44
- async batchPutValues(values: {index: number; root: Root}[]): Promise<void> {
45
- await this.batchPut(
46
- values.map(({index, root}) => ({
47
- key: index,
48
- value: root,
49
- }))
50
- );
51
- }
52
-
53
- async getDepositRootTree(): Promise<DepositTree> {
54
- if (!this.depositRootTree) {
55
- const values = await this.values();
56
- this.depositRootTree = ssz.phase0.DepositDataRootList.toViewDU(values);
57
- }
58
- return this.depositRootTree;
59
- }
60
-
61
- async getDepositRootTreeAtIndex(depositIndex: number): Promise<DepositTree> {
62
- const depositRootTree = await this.getDepositRootTree();
63
- return depositRootTree.sliceTo(depositIndex);
64
- }
65
-
66
- private async depositRootTreeSet(index: number, value: Uint8Array): Promise<void> {
67
- const depositRootTree = await this.getDepositRootTree();
68
-
69
- // TODO: Review and fix properly
70
- if (index > depositRootTree.length) {
71
- throw Error(`Error setting depositRootTree index ${index} > length ${depositRootTree.length}`);
72
- }
73
-
74
- if (index === depositRootTree.length) {
75
- depositRootTree.push(value);
76
- } else {
77
- depositRootTree.set(index, value);
78
- }
79
- }
80
- }
@@ -1,32 +0,0 @@
1
- import {ChainForkConfig} from "@lodestar/config";
2
- import {Db, Repository} from "@lodestar/db";
3
- import {phase0, ssz} from "@lodestar/types";
4
- import {Bucket, getBucketNameByValue} from "../buckets.js";
5
-
6
- /**
7
- * DepositData indexed by deposit index
8
- * Removed when included on chain or old
9
- */
10
- export class DepositEventRepository extends Repository<number, phase0.DepositEvent> {
11
- constructor(config: ChainForkConfig, db: Db) {
12
- const bucket = Bucket.phase0_depositEvent;
13
- super(config, db, bucket, ssz.phase0.DepositEvent, getBucketNameByValue(bucket));
14
- }
15
-
16
- async deleteOld(depositCount: number): Promise<void> {
17
- const firstDepositIndex = await this.firstKey();
18
- if (firstDepositIndex === null) {
19
- return;
20
- }
21
- await this.batchDelete(Array.from({length: depositCount - firstDepositIndex}, (_, i) => i + firstDepositIndex));
22
- }
23
-
24
- async batchPutValues(depositEvents: phase0.DepositEvent[]): Promise<void> {
25
- await this.batchPut(
26
- depositEvents.map((depositEvent) => ({
27
- key: depositEvent.index,
28
- value: depositEvent,
29
- }))
30
- );
31
- }
32
- }
@@ -1,33 +0,0 @@
1
- import {ChainForkConfig} from "@lodestar/config";
2
- import {Db, Repository} from "@lodestar/db";
3
- import {phase0, ssz} from "@lodestar/types";
4
- import {bytesToInt} from "@lodestar/utils";
5
- import {Bucket, getBucketNameByValue} from "../buckets.js";
6
-
7
- export class Eth1DataRepository extends Repository<number, phase0.Eth1DataOrdered> {
8
- constructor(config: ChainForkConfig, db: Db) {
9
- const bucket = Bucket.phase0_eth1Data;
10
- super(config, db, bucket, ssz.phase0.Eth1DataOrdered, getBucketNameByValue(bucket));
11
- }
12
-
13
- decodeKey(data: Buffer): number {
14
- return bytesToInt(super.decodeKey(data) as unknown as Uint8Array, "be");
15
- }
16
-
17
- getId(_value: phase0.Eth1Data): number {
18
- throw new Error("Unable to create timestamp from block hash");
19
- }
20
-
21
- async batchPutValues(eth1Datas: (phase0.Eth1DataOrdered & {timestamp: number})[]): Promise<void> {
22
- await this.batchPut(
23
- eth1Datas.map((eth1Data) => ({
24
- key: eth1Data.timestamp,
25
- value: eth1Data,
26
- }))
27
- );
28
- }
29
-
30
- async deleteOld(timestamp: number): Promise<void> {
31
- await this.batchDelete(await this.keys({lt: timestamp}));
32
- }
33
- }
@@ -1,2 +0,0 @@
1
- export {PreGenesisState} from "./preGenesisState.js";
2
- export {PreGenesisStateLastProcessedBlock} from "./preGenesisStateLastProcessedBlock.js";
@@ -1,37 +0,0 @@
1
- import {ChainForkConfig} from "@lodestar/config";
2
- import {Db, DbReqOpts} from "@lodestar/db";
3
- import {ForkAll, GENESIS_SLOT} from "@lodestar/params";
4
- import {BeaconStateAllForks} from "@lodestar/state-transition";
5
- import {SSZTypesFor} from "@lodestar/types";
6
- import {Bucket, getBucketNameByValue} from "../buckets.js";
7
-
8
- export class PreGenesisState {
9
- private readonly config: ChainForkConfig;
10
- private readonly bucket: Bucket;
11
- private readonly db: Db;
12
- private readonly key: Uint8Array;
13
- private readonly type: SSZTypesFor<ForkAll, "BeaconState">;
14
- private readonly dbReqOpts: DbReqOpts;
15
-
16
- constructor(config: ChainForkConfig, db: Db) {
17
- this.config = config;
18
- this.db = db;
19
- this.bucket = Bucket.phase0_preGenesisState;
20
- this.key = new Uint8Array([this.bucket]);
21
- this.type = this.config.getForkTypes(GENESIS_SLOT).BeaconState;
22
- this.dbReqOpts = {bucketId: getBucketNameByValue(this.bucket)};
23
- }
24
-
25
- async put(value: BeaconStateAllForks): Promise<void> {
26
- await this.db.put(this.key, value.serialize(), this.dbReqOpts);
27
- }
28
-
29
- async get(): Promise<BeaconStateAllForks | null> {
30
- const value = await this.db.get(this.key, this.dbReqOpts);
31
- return value ? this.type.deserializeToViewDU(value) : null;
32
- }
33
-
34
- async delete(): Promise<void> {
35
- await this.db.delete(this.key, this.dbReqOpts);
36
- }
37
- }
@@ -1,34 +0,0 @@
1
- import {UintNumberType} from "@chainsafe/ssz";
2
- import {ChainForkConfig} from "@lodestar/config";
3
- import {Db, DbReqOpts} from "@lodestar/db";
4
- import {ssz} from "@lodestar/types";
5
- import {Bucket, getBucketNameByValue} from "../buckets.js";
6
-
7
- export class PreGenesisStateLastProcessedBlock {
8
- private readonly bucket: Bucket;
9
- private readonly type: UintNumberType;
10
- private readonly db: Db;
11
- private readonly key: Uint8Array;
12
- private readonly dbReqOpts: DbReqOpts;
13
-
14
- constructor(_config: ChainForkConfig, db: Db) {
15
- this.db = db;
16
- this.type = ssz.UintNum64;
17
- this.bucket = Bucket.phase0_preGenesisStateLastProcessedBlock;
18
- this.key = new Uint8Array([this.bucket]);
19
- this.dbReqOpts = {bucketId: getBucketNameByValue(this.bucket)};
20
- }
21
-
22
- async put(value: number): Promise<void> {
23
- await this.db.put(this.key, this.type.serialize(value), this.dbReqOpts);
24
- }
25
-
26
- async get(): Promise<number | null> {
27
- const value = await this.db.get(this.key, this.dbReqOpts);
28
- return value ? this.type.deserialize(value) : null;
29
- }
30
-
31
- async delete(): Promise<void> {
32
- await this.db.delete(this.key, this.dbReqOpts);
33
- }
34
- }
@@ -1,40 +0,0 @@
1
- import {LodestarError} from "@lodestar/utils";
2
-
3
- export enum Eth1ErrorCode {
4
- /** Deposit index too high */
5
- DEPOSIT_INDEX_TOO_HIGH = "ETH1_ERROR_DEPOSIT_INDEX_TOO_HIGH",
6
- /** Not enough deposits in DB */
7
- NOT_ENOUGH_DEPOSITS = "ETH1_ERROR_NOT_ENOUGH_DEPOSITS",
8
- /** Too many deposits returned by DB */
9
- TOO_MANY_DEPOSITS = "ETH1_ERROR_TOO_MANY_DEPOSITS",
10
- /** Deposit root tree does not match current eth1Data */
11
- WRONG_DEPOSIT_ROOT = "ETH1_ERROR_WRONG_DEPOSIT_ROOT",
12
-
13
- /** No deposits found for block range */
14
- NO_DEPOSITS_FOR_BLOCK_RANGE = "ETH1_ERROR_NO_DEPOSITS_FOR_BLOCK_RANGE",
15
- /** No depositRoot for depositCount */
16
- NO_DEPOSIT_ROOT = "ETH1_ERROR_NO_DEPOSIT_ROOT",
17
- /** Not enough deposit roots for index */
18
- NOT_ENOUGH_DEPOSIT_ROOTS = "ETH1_ERROR_NOT_ENOUGH_DEPOSIT_ROOTS",
19
-
20
- /** Attempted to insert a duplicate log for same index into the Eth1DepositsCache */
21
- DUPLICATE_DISTINCT_LOG = "ETH1_ERROR_DUPLICATE_DISTINCT_LOG",
22
- /** Attempted to insert a log with index != prev + 1 into the Eth1DepositsCache */
23
- NON_CONSECUTIVE_LOGS = "ETH1_ERROR_NON_CONSECUTIVE_LOGS",
24
- /** Expected a deposit log in the db for the index, missing log implies a corrupted db */
25
- MISSING_DEPOSIT_LOG = "ETH1_ERROR_MISSING_DEPOSIT_LOG",
26
- }
27
-
28
- export type Eth1ErrorType =
29
- | {code: Eth1ErrorCode.DEPOSIT_INDEX_TOO_HIGH; depositIndex: number; depositCount: number}
30
- | {code: Eth1ErrorCode.NOT_ENOUGH_DEPOSITS; len: number; expectedLen: number}
31
- | {code: Eth1ErrorCode.TOO_MANY_DEPOSITS; len: number; expectedLen: number}
32
- | {code: Eth1ErrorCode.WRONG_DEPOSIT_ROOT; root: string; expectedRoot: string}
33
- | {code: Eth1ErrorCode.NO_DEPOSITS_FOR_BLOCK_RANGE; fromBlock: number; toBlock: number}
34
- | {code: Eth1ErrorCode.NO_DEPOSIT_ROOT; depositCount: number}
35
- | {code: Eth1ErrorCode.NOT_ENOUGH_DEPOSIT_ROOTS; index: number; treeLength: number}
36
- | {code: Eth1ErrorCode.DUPLICATE_DISTINCT_LOG; newIndex: number; lastLogIndex: number}
37
- | {code: Eth1ErrorCode.NON_CONSECUTIVE_LOGS; newIndex: number; lastLogIndex: number}
38
- | {code: Eth1ErrorCode.MISSING_DEPOSIT_LOG; newIndex: number; lastLogIndex: number};
39
-
40
- export class Eth1Error extends LodestarError<Eth1ErrorType> {}
@@ -1,26 +0,0 @@
1
- import {ChainForkConfig} from "@lodestar/config";
2
- import {phase0} from "@lodestar/types";
3
- import {IBeaconDb} from "../db/index.js";
4
-
5
- export class Eth1DataCache {
6
- db: IBeaconDb;
7
- config: ChainForkConfig;
8
-
9
- constructor(config: ChainForkConfig, db: IBeaconDb) {
10
- this.config = config;
11
- this.db = db;
12
- }
13
-
14
- async get({timestampRange}: {timestampRange: {gte: number; lte: number}}): Promise<phase0.Eth1DataOrdered[]> {
15
- return this.db.eth1Data.values(timestampRange);
16
- }
17
-
18
- async add(eth1Datas: (phase0.Eth1DataOrdered & {timestamp: number})[]): Promise<void> {
19
- await this.db.eth1Data.batchPutValues(eth1Datas);
20
- }
21
-
22
- async getHighestCachedBlockNumber(): Promise<number | null> {
23
- const highestEth1Data = await this.db.eth1Data.lastValue();
24
- return highestEth1Data?.blockNumber ?? null;
25
- }
26
- }