@lodestar/beacon-node 1.38.0 → 1.39.0-dev.100ab480bb

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 (393) 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 +3 -2
  18. package/lib/chain/blocks/verifyBlocksSignatures.js.map +1 -1
  19. package/lib/chain/chain.d.ts +8 -12
  20. package/lib/chain/chain.d.ts.map +1 -1
  21. package/lib/chain/chain.js +25 -59
  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 +4 -9
  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/stateCache/persistentCheckpointsCache.d.ts +4 -1
  51. package/lib/chain/stateCache/persistentCheckpointsCache.d.ts.map +1 -1
  52. package/lib/chain/stateCache/persistentCheckpointsCache.js +4 -2
  53. package/lib/chain/stateCache/persistentCheckpointsCache.js.map +1 -1
  54. package/lib/chain/validation/aggregateAndProof.js +9 -0
  55. package/lib/chain/validation/aggregateAndProof.js.map +1 -1
  56. package/lib/chain/validation/attesterSlashing.d.ts.map +1 -1
  57. package/lib/chain/validation/attesterSlashing.js +2 -2
  58. package/lib/chain/validation/attesterSlashing.js.map +1 -1
  59. package/lib/chain/validation/blobSidecar.d.ts.map +1 -1
  60. package/lib/chain/validation/blobSidecar.js +2 -2
  61. package/lib/chain/validation/blobSidecar.js.map +1 -1
  62. package/lib/chain/validation/block.js +1 -1
  63. package/lib/chain/validation/block.js.map +1 -1
  64. package/lib/chain/validation/blsToExecutionChange.js +1 -1
  65. package/lib/chain/validation/dataColumnSidecar.d.ts.map +1 -1
  66. package/lib/chain/validation/dataColumnSidecar.js +2 -2
  67. package/lib/chain/validation/dataColumnSidecar.js.map +1 -1
  68. package/lib/chain/validation/proposerSlashing.js +1 -1
  69. package/lib/chain/validation/proposerSlashing.js.map +1 -1
  70. package/lib/chain/validation/signatureSets/aggregateAndProof.js +1 -1
  71. package/lib/chain/validation/signatureSets/aggregateAndProof.js.map +1 -1
  72. package/lib/chain/validation/signatureSets/contributionAndProof.d.ts +3 -2
  73. package/lib/chain/validation/signatureSets/contributionAndProof.d.ts.map +1 -1
  74. package/lib/chain/validation/signatureSets/contributionAndProof.js +3 -4
  75. package/lib/chain/validation/signatureSets/contributionAndProof.js.map +1 -1
  76. package/lib/chain/validation/signatureSets/syncCommittee.d.ts +3 -2
  77. package/lib/chain/validation/signatureSets/syncCommittee.d.ts.map +1 -1
  78. package/lib/chain/validation/signatureSets/syncCommittee.js +3 -3
  79. package/lib/chain/validation/signatureSets/syncCommittee.js.map +1 -1
  80. package/lib/chain/validation/signatureSets/syncCommitteeContribution.d.ts +2 -1
  81. package/lib/chain/validation/signatureSets/syncCommitteeContribution.d.ts.map +1 -1
  82. package/lib/chain/validation/signatureSets/syncCommitteeContribution.js +2 -2
  83. package/lib/chain/validation/signatureSets/syncCommitteeContribution.js.map +1 -1
  84. package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.d.ts +3 -2
  85. package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.d.ts.map +1 -1
  86. package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.js +2 -3
  87. package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.js.map +1 -1
  88. package/lib/chain/validation/syncCommittee.js +1 -1
  89. package/lib/chain/validation/syncCommittee.js.map +1 -1
  90. package/lib/chain/validation/syncCommitteeContributionAndProof.d.ts.map +1 -1
  91. package/lib/chain/validation/syncCommitteeContributionAndProof.js +5 -4
  92. package/lib/chain/validation/syncCommitteeContributionAndProof.js.map +1 -1
  93. package/lib/chain/validation/voluntaryExit.js +1 -1
  94. package/lib/chain/validation/voluntaryExit.js.map +1 -1
  95. package/lib/db/beacon.d.ts +3 -7
  96. package/lib/db/beacon.d.ts.map +1 -1
  97. package/lib/db/beacon.js +33 -12
  98. package/lib/db/beacon.js.map +1 -1
  99. package/lib/db/buckets.d.ts +12 -6
  100. package/lib/db/buckets.d.ts.map +1 -1
  101. package/lib/db/buckets.js +6 -1
  102. package/lib/db/buckets.js.map +1 -1
  103. package/lib/db/interface.d.ts +2 -7
  104. package/lib/db/interface.d.ts.map +1 -1
  105. package/lib/db/repositories/index.d.ts +0 -3
  106. package/lib/db/repositories/index.d.ts.map +1 -1
  107. package/lib/db/repositories/index.js +0 -3
  108. package/lib/db/repositories/index.js.map +1 -1
  109. package/lib/execution/engine/http.d.ts +5 -13
  110. package/lib/execution/engine/http.d.ts.map +1 -1
  111. package/lib/execution/engine/http.js +6 -15
  112. package/lib/execution/engine/http.js.map +1 -1
  113. package/lib/execution/engine/index.d.ts.map +1 -1
  114. package/lib/execution/engine/index.js +1 -1
  115. package/lib/execution/engine/index.js.map +1 -1
  116. package/lib/execution/engine/interface.d.ts +1 -1
  117. package/lib/execution/engine/interface.d.ts.map +1 -1
  118. package/lib/execution/engine/interface.js.map +1 -1
  119. package/lib/{eth1/provider → execution/engine}/jsonRpcHttpClient.d.ts +1 -1
  120. package/lib/execution/engine/jsonRpcHttpClient.d.ts.map +1 -0
  121. package/lib/execution/engine/jsonRpcHttpClient.js.map +1 -0
  122. package/lib/execution/engine/jwt.d.ts.map +1 -0
  123. package/lib/execution/engine/jwt.js.map +1 -0
  124. package/lib/execution/engine/mock.d.ts +2 -6
  125. package/lib/execution/engine/mock.d.ts.map +1 -1
  126. package/lib/execution/engine/mock.js +4 -15
  127. package/lib/execution/engine/mock.js.map +1 -1
  128. package/lib/execution/engine/payloadIdCache.d.ts +1 -1
  129. package/lib/execution/engine/payloadIdCache.d.ts.map +1 -1
  130. package/lib/execution/engine/types.d.ts +1 -1
  131. package/lib/execution/engine/types.d.ts.map +1 -1
  132. package/lib/execution/engine/types.js +1 -1
  133. package/lib/execution/engine/types.js.map +1 -1
  134. package/lib/execution/engine/utils.d.ts +64 -2
  135. package/lib/execution/engine/utils.d.ts.map +1 -1
  136. package/lib/execution/engine/utils.js +91 -2
  137. package/lib/execution/engine/utils.js.map +1 -1
  138. package/lib/index.d.ts +1 -2
  139. package/lib/index.d.ts.map +1 -1
  140. package/lib/index.js +1 -2
  141. package/lib/index.js.map +1 -1
  142. package/lib/metrics/metrics/lodestar.d.ts +0 -49
  143. package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
  144. package/lib/metrics/metrics/lodestar.js +0 -134
  145. package/lib/metrics/metrics/lodestar.js.map +1 -1
  146. package/lib/network/core/events.d.ts +1 -1
  147. package/lib/network/core/events.d.ts.map +1 -1
  148. package/lib/network/core/events.js +1 -1
  149. package/lib/network/core/events.js.map +1 -1
  150. package/lib/network/events.d.ts +6 -1
  151. package/lib/network/events.d.ts.map +1 -1
  152. package/lib/network/events.js +7 -1
  153. package/lib/network/events.js.map +1 -1
  154. package/lib/node/nodejs.d.ts +6 -3
  155. package/lib/node/nodejs.d.ts.map +1 -1
  156. package/lib/node/nodejs.js +13 -10
  157. package/lib/node/nodejs.js.map +1 -1
  158. package/lib/node/notifier.d.ts.map +1 -1
  159. package/lib/node/notifier.js +0 -13
  160. package/lib/node/notifier.js.map +1 -1
  161. package/lib/node/options.d.ts +0 -2
  162. package/lib/node/options.d.ts.map +1 -1
  163. package/lib/node/options.js +0 -2
  164. package/lib/node/options.js.map +1 -1
  165. package/lib/node/utils/interop/deposits.d.ts +2 -1
  166. package/lib/node/utils/interop/deposits.d.ts.map +1 -1
  167. package/lib/node/utils/interop/deposits.js.map +1 -1
  168. package/lib/node/utils/interop/state.d.ts +1 -1
  169. package/lib/node/utils/interop/state.d.ts.map +1 -1
  170. package/lib/node/utils/state.d.ts +1 -7
  171. package/lib/node/utils/state.d.ts.map +1 -1
  172. package/lib/node/utils/state.js +1 -14
  173. package/lib/node/utils/state.js.map +1 -1
  174. package/lib/sync/backfill/backfill.d.ts.map +1 -1
  175. package/lib/sync/backfill/backfill.js +2 -2
  176. package/lib/sync/backfill/backfill.js.map +1 -1
  177. package/lib/sync/backfill/verify.d.ts +2 -2
  178. package/lib/sync/backfill/verify.d.ts.map +1 -1
  179. package/lib/sync/backfill/verify.js +3 -3
  180. package/lib/sync/backfill/verify.js.map +1 -1
  181. package/lib/util/workerEvents.d.ts +1 -6
  182. package/lib/util/workerEvents.d.ts.map +1 -1
  183. package/lib/util/workerEvents.js +8 -8
  184. package/lib/util/workerEvents.js.map +1 -1
  185. package/package.json +14 -21
  186. package/src/api/impl/beacon/blocks/utils.ts +1 -1
  187. package/src/api/impl/beacon/state/index.ts +4 -5
  188. package/src/api/impl/validator/index.ts +1 -1
  189. package/src/chain/blocks/verifyBlock.ts +3 -24
  190. package/src/chain/blocks/verifyBlocksExecutionPayloads.ts +9 -161
  191. package/src/chain/blocks/verifyBlocksSignatures.ts +15 -4
  192. package/src/chain/chain.ts +35 -69
  193. package/src/chain/initState.ts +1 -97
  194. package/src/chain/interface.ts +4 -8
  195. package/src/chain/opPools/aggregatedAttestationPool.ts +7 -7
  196. package/src/chain/opPools/opPool.ts +8 -8
  197. package/src/chain/options.ts +0 -6
  198. package/src/chain/prepareNextSlot.ts +2 -29
  199. package/src/chain/produceBlock/produceBlockBody.ts +33 -132
  200. package/src/chain/stateCache/persistentCheckpointsCache.ts +15 -2
  201. package/src/chain/validation/aggregateAndProof.ts +12 -0
  202. package/src/chain/validation/attesterSlashing.ts +7 -2
  203. package/src/chain/validation/blobSidecar.ts +10 -2
  204. package/src/chain/validation/block.ts +1 -1
  205. package/src/chain/validation/blsToExecutionChange.ts +1 -1
  206. package/src/chain/validation/dataColumnSidecar.ts +6 -1
  207. package/src/chain/validation/proposerSlashing.ts +6 -1
  208. package/src/chain/validation/signatureSets/aggregateAndProof.ts +1 -1
  209. package/src/chain/validation/signatureSets/contributionAndProof.ts +6 -3
  210. package/src/chain/validation/signatureSets/syncCommittee.ts +6 -2
  211. package/src/chain/validation/signatureSets/syncCommitteeContribution.ts +3 -1
  212. package/src/chain/validation/signatureSets/syncCommitteeSelectionProof.ts +5 -2
  213. package/src/chain/validation/syncCommittee.ts +1 -1
  214. package/src/chain/validation/syncCommitteeContributionAndProof.ts +10 -6
  215. package/src/chain/validation/voluntaryExit.ts +1 -1
  216. package/src/db/beacon.ts +38 -16
  217. package/src/db/buckets.ts +12 -7
  218. package/src/db/interface.ts +2 -13
  219. package/src/db/repositories/index.ts +0 -3
  220. package/src/execution/engine/http.ts +12 -21
  221. package/src/execution/engine/index.ts +1 -1
  222. package/src/execution/engine/interface.ts +1 -1
  223. package/src/{eth1/provider → execution/engine}/jsonRpcHttpClient.ts +1 -1
  224. package/src/execution/engine/mock.ts +4 -17
  225. package/src/execution/engine/payloadIdCache.ts +1 -1
  226. package/src/execution/engine/types.ts +9 -9
  227. package/src/execution/engine/utils.ts +111 -5
  228. package/src/index.ts +1 -2
  229. package/src/metrics/metrics/lodestar.ts +0 -144
  230. package/src/network/core/events.ts +1 -1
  231. package/src/network/events.ts +7 -1
  232. package/src/node/nodejs.ts +20 -11
  233. package/src/node/notifier.ts +0 -16
  234. package/src/node/options.ts +0 -3
  235. package/src/node/utils/interop/deposits.ts +3 -1
  236. package/src/node/utils/interop/state.ts +1 -1
  237. package/src/node/utils/state.ts +3 -18
  238. package/src/sync/backfill/backfill.ts +14 -2
  239. package/src/sync/backfill/verify.ts +9 -2
  240. package/src/util/workerEvents.ts +9 -8
  241. package/lib/chain/genesis/genesis.d.ts +0 -51
  242. package/lib/chain/genesis/genesis.d.ts.map +0 -1
  243. package/lib/chain/genesis/genesis.js +0 -123
  244. package/lib/chain/genesis/genesis.js.map +0 -1
  245. package/lib/chain/genesis/interface.d.ts +0 -13
  246. package/lib/chain/genesis/interface.d.ts.map +0 -1
  247. package/lib/chain/genesis/interface.js +0 -2
  248. package/lib/chain/genesis/interface.js.map +0 -1
  249. package/lib/chain/rewards/attestationsRewards.d.ts +0 -7
  250. package/lib/chain/rewards/attestationsRewards.d.ts.map +0 -1
  251. package/lib/chain/rewards/attestationsRewards.js +0 -112
  252. package/lib/chain/rewards/attestationsRewards.js.map +0 -1
  253. package/lib/chain/rewards/blockRewards.d.ts +0 -14
  254. package/lib/chain/rewards/blockRewards.d.ts.map +0 -1
  255. package/lib/chain/rewards/blockRewards.js +0 -94
  256. package/lib/chain/rewards/blockRewards.js.map +0 -1
  257. package/lib/chain/rewards/syncCommitteeRewards.d.ts +0 -6
  258. package/lib/chain/rewards/syncCommitteeRewards.d.ts.map +0 -1
  259. package/lib/chain/rewards/syncCommitteeRewards.js +0 -37
  260. package/lib/chain/rewards/syncCommitteeRewards.js.map +0 -1
  261. package/lib/db/repositories/depositDataRoot.d.ts +0 -22
  262. package/lib/db/repositories/depositDataRoot.d.ts.map +0 -1
  263. package/lib/db/repositories/depositDataRoot.js +0 -62
  264. package/lib/db/repositories/depositDataRoot.js.map +0 -1
  265. package/lib/db/repositories/depositEvent.d.ts +0 -13
  266. package/lib/db/repositories/depositEvent.d.ts.map +0 -1
  267. package/lib/db/repositories/depositEvent.js +0 -27
  268. package/lib/db/repositories/depositEvent.js.map +0 -1
  269. package/lib/db/repositories/eth1Data.d.ts +0 -13
  270. package/lib/db/repositories/eth1Data.d.ts.map +0 -1
  271. package/lib/db/repositories/eth1Data.js +0 -26
  272. package/lib/db/repositories/eth1Data.js.map +0 -1
  273. package/lib/db/single/index.d.ts +0 -3
  274. package/lib/db/single/index.d.ts.map +0 -1
  275. package/lib/db/single/index.js +0 -3
  276. package/lib/db/single/index.js.map +0 -1
  277. package/lib/db/single/preGenesisState.d.ts +0 -16
  278. package/lib/db/single/preGenesisState.d.ts.map +0 -1
  279. package/lib/db/single/preGenesisState.js +0 -29
  280. package/lib/db/single/preGenesisState.js.map +0 -1
  281. package/lib/db/single/preGenesisStateLastProcessedBlock.d.ts +0 -14
  282. package/lib/db/single/preGenesisStateLastProcessedBlock.d.ts.map +0 -1
  283. package/lib/db/single/preGenesisStateLastProcessedBlock.js +0 -27
  284. package/lib/db/single/preGenesisStateLastProcessedBlock.js.map +0 -1
  285. package/lib/eth1/errors.d.ts +0 -66
  286. package/lib/eth1/errors.d.ts.map +0 -1
  287. package/lib/eth1/errors.js +0 -27
  288. package/lib/eth1/errors.js.map +0 -1
  289. package/lib/eth1/eth1DataCache.d.ts +0 -19
  290. package/lib/eth1/eth1DataCache.d.ts.map +0 -1
  291. package/lib/eth1/eth1DataCache.js +0 -19
  292. package/lib/eth1/eth1DataCache.js.map +0 -1
  293. package/lib/eth1/eth1DepositDataTracker.d.ts +0 -80
  294. package/lib/eth1/eth1DepositDataTracker.d.ts.map +0 -1
  295. package/lib/eth1/eth1DepositDataTracker.js +0 -317
  296. package/lib/eth1/eth1DepositDataTracker.js.map +0 -1
  297. package/lib/eth1/eth1DepositsCache.d.ts +0 -42
  298. package/lib/eth1/eth1DepositsCache.d.ts.map +0 -1
  299. package/lib/eth1/eth1DepositsCache.js +0 -119
  300. package/lib/eth1/eth1DepositsCache.js.map +0 -1
  301. package/lib/eth1/eth1MergeBlockTracker.d.ts +0 -65
  302. package/lib/eth1/eth1MergeBlockTracker.d.ts.map +0 -1
  303. package/lib/eth1/eth1MergeBlockTracker.js +0 -262
  304. package/lib/eth1/eth1MergeBlockTracker.js.map +0 -1
  305. package/lib/eth1/index.d.ts +0 -46
  306. package/lib/eth1/index.d.ts.map +0 -1
  307. package/lib/eth1/index.js +0 -121
  308. package/lib/eth1/index.js.map +0 -1
  309. package/lib/eth1/interface.d.ts +0 -112
  310. package/lib/eth1/interface.d.ts.map +0 -1
  311. package/lib/eth1/interface.js +0 -8
  312. package/lib/eth1/interface.js.map +0 -1
  313. package/lib/eth1/options.d.ts +0 -22
  314. package/lib/eth1/options.d.ts.map +0 -1
  315. package/lib/eth1/options.js +0 -8
  316. package/lib/eth1/options.js.map +0 -1
  317. package/lib/eth1/provider/eth1Provider.d.ts +0 -39
  318. package/lib/eth1/provider/eth1Provider.d.ts.map +0 -1
  319. package/lib/eth1/provider/eth1Provider.js +0 -147
  320. package/lib/eth1/provider/eth1Provider.js.map +0 -1
  321. package/lib/eth1/provider/jsonRpcHttpClient.d.ts.map +0 -1
  322. package/lib/eth1/provider/jsonRpcHttpClient.js.map +0 -1
  323. package/lib/eth1/provider/jwt.d.ts.map +0 -1
  324. package/lib/eth1/provider/jwt.js.map +0 -1
  325. package/lib/eth1/provider/utils.d.ts +0 -65
  326. package/lib/eth1/provider/utils.d.ts.map +0 -1
  327. package/lib/eth1/provider/utils.js +0 -120
  328. package/lib/eth1/provider/utils.js.map +0 -1
  329. package/lib/eth1/stream.d.ts +0 -15
  330. package/lib/eth1/stream.d.ts.map +0 -1
  331. package/lib/eth1/stream.js +0 -54
  332. package/lib/eth1/stream.js.map +0 -1
  333. package/lib/eth1/utils/depositContract.d.ts +0 -14
  334. package/lib/eth1/utils/depositContract.d.ts.map +0 -1
  335. package/lib/eth1/utils/depositContract.js +0 -33
  336. package/lib/eth1/utils/depositContract.js.map +0 -1
  337. package/lib/eth1/utils/deposits.d.ts +0 -8
  338. package/lib/eth1/utils/deposits.d.ts.map +0 -1
  339. package/lib/eth1/utils/deposits.js +0 -47
  340. package/lib/eth1/utils/deposits.js.map +0 -1
  341. package/lib/eth1/utils/eth1Data.d.ts +0 -22
  342. package/lib/eth1/utils/eth1Data.d.ts.map +0 -1
  343. package/lib/eth1/utils/eth1Data.js +0 -77
  344. package/lib/eth1/utils/eth1Data.js.map +0 -1
  345. package/lib/eth1/utils/eth1DepositEvent.d.ts +0 -7
  346. package/lib/eth1/utils/eth1DepositEvent.d.ts.map +0 -1
  347. package/lib/eth1/utils/eth1DepositEvent.js +0 -13
  348. package/lib/eth1/utils/eth1DepositEvent.js.map +0 -1
  349. package/lib/eth1/utils/eth1Vote.d.ts +0 -17
  350. package/lib/eth1/utils/eth1Vote.d.ts.map +0 -1
  351. package/lib/eth1/utils/eth1Vote.js +0 -111
  352. package/lib/eth1/utils/eth1Vote.js.map +0 -1
  353. package/lib/eth1/utils/groupDepositEventsByBlock.d.ts +0 -9
  354. package/lib/eth1/utils/groupDepositEventsByBlock.d.ts.map +0 -1
  355. package/lib/eth1/utils/groupDepositEventsByBlock.js +0 -17
  356. package/lib/eth1/utils/groupDepositEventsByBlock.js.map +0 -1
  357. package/lib/eth1/utils/optimizeNextBlockDiffForGenesis.d.ts +0 -10
  358. package/lib/eth1/utils/optimizeNextBlockDiffForGenesis.d.ts.map +0 -1
  359. package/lib/eth1/utils/optimizeNextBlockDiffForGenesis.js +0 -14
  360. package/lib/eth1/utils/optimizeNextBlockDiffForGenesis.js.map +0 -1
  361. package/src/chain/genesis/genesis.ts +0 -190
  362. package/src/chain/genesis/interface.ts +0 -14
  363. package/src/chain/rewards/attestationsRewards.ts +0 -196
  364. package/src/chain/rewards/blockRewards.ts +0 -150
  365. package/src/chain/rewards/syncCommitteeRewards.ts +0 -58
  366. package/src/db/repositories/depositDataRoot.ts +0 -80
  367. package/src/db/repositories/depositEvent.ts +0 -32
  368. package/src/db/repositories/eth1Data.ts +0 -33
  369. package/src/db/single/index.ts +0 -2
  370. package/src/db/single/preGenesisState.ts +0 -37
  371. package/src/db/single/preGenesisStateLastProcessedBlock.ts +0 -34
  372. package/src/eth1/errors.ts +0 -40
  373. package/src/eth1/eth1DataCache.ts +0 -26
  374. package/src/eth1/eth1DepositDataTracker.ts +0 -410
  375. package/src/eth1/eth1DepositsCache.ts +0 -141
  376. package/src/eth1/eth1MergeBlockTracker.ts +0 -328
  377. package/src/eth1/index.ts +0 -157
  378. package/src/eth1/interface.ts +0 -131
  379. package/src/eth1/options.ts +0 -28
  380. package/src/eth1/provider/eth1Provider.ts +0 -229
  381. package/src/eth1/provider/utils.ts +0 -136
  382. package/src/eth1/stream.ts +0 -75
  383. package/src/eth1/utils/depositContract.ts +0 -37
  384. package/src/eth1/utils/deposits.ts +0 -70
  385. package/src/eth1/utils/eth1Data.ts +0 -100
  386. package/src/eth1/utils/eth1DepositEvent.ts +0 -12
  387. package/src/eth1/utils/eth1Vote.ts +0 -142
  388. package/src/eth1/utils/groupDepositEventsByBlock.ts +0 -19
  389. package/src/eth1/utils/optimizeNextBlockDiffForGenesis.ts +0 -18
  390. /package/lib/{eth1/provider → execution/engine}/jsonRpcHttpClient.js +0 -0
  391. /package/lib/{eth1/provider → execution/engine}/jwt.d.ts +0 -0
  392. /package/lib/{eth1/provider → execution/engine}/jwt.js +0 -0
  393. /package/src/{eth1/provider → execution/engine}/jwt.ts +0 -0
@@ -1,196 +0,0 @@
1
- import {routes} from "@lodestar/api";
2
- import {BeaconConfig} from "@lodestar/config";
3
- import {
4
- EFFECTIVE_BALANCE_INCREMENT,
5
- ForkName,
6
- INACTIVITY_PENALTY_QUOTIENT_ALTAIR,
7
- MAX_EFFECTIVE_BALANCE,
8
- MAX_EFFECTIVE_BALANCE_ELECTRA,
9
- PARTICIPATION_FLAG_WEIGHTS,
10
- TIMELY_HEAD_FLAG_INDEX,
11
- TIMELY_SOURCE_FLAG_INDEX,
12
- TIMELY_TARGET_FLAG_INDEX,
13
- WEIGHT_DENOMINATOR,
14
- isForkPostElectra,
15
- } from "@lodestar/params";
16
- import {
17
- CachedBeaconStateAllForks,
18
- CachedBeaconStateAltair,
19
- EpochTransitionCache,
20
- FLAG_ELIGIBLE_ATTESTER,
21
- FLAG_PREV_HEAD_ATTESTER_UNSLASHED,
22
- FLAG_PREV_SOURCE_ATTESTER_UNSLASHED,
23
- FLAG_PREV_TARGET_ATTESTER_UNSLASHED,
24
- beforeProcessEpoch,
25
- hasMarkers,
26
- isInInactivityLeak,
27
- } from "@lodestar/state-transition";
28
- import {Epoch, ValidatorIndex} from "@lodestar/types";
29
- import {fromHex} from "@lodestar/utils";
30
-
31
- export type AttestationsRewards = routes.beacon.AttestationsRewards;
32
- type IdealAttestationsReward = routes.beacon.IdealAttestationsReward;
33
- type TotalAttestationsReward = routes.beacon.TotalAttestationsReward;
34
- /** Attestations penalty with respect to effective balance in Gwei */
35
- type AttestationsPenalty = {target: number; source: number; effectiveBalance: number};
36
-
37
- const defaultAttestationsReward = {head: 0, target: 0, source: 0, inclusionDelay: 0, inactivity: 0};
38
- const defaultAttestationsPenalty = {target: 0, source: 0};
39
-
40
- export async function computeAttestationsRewards(
41
- _epoch: Epoch,
42
- state: CachedBeaconStateAllForks,
43
- _config: BeaconConfig,
44
- validatorIds?: (ValidatorIndex | string)[]
45
- ): Promise<AttestationsRewards> {
46
- const fork = state.config.getForkName(state.slot);
47
- if (fork === ForkName.phase0) {
48
- throw Error("Unsupported fork. Attestations rewards calculation is not available in phase0");
49
- }
50
-
51
- const stateAltair = state as CachedBeaconStateAltair;
52
- const transitionCache = beforeProcessEpoch(stateAltair);
53
-
54
- const [idealRewards, penalties] = computeIdealAttestationsRewardsAndPenaltiesAltair(stateAltair, transitionCache);
55
- const totalRewards = computeTotalAttestationsRewardsAltair(
56
- stateAltair,
57
- transitionCache,
58
- idealRewards,
59
- penalties,
60
- validatorIds
61
- );
62
-
63
- return {idealRewards, totalRewards};
64
- }
65
-
66
- function computeIdealAttestationsRewardsAndPenaltiesAltair(
67
- state: CachedBeaconStateAllForks,
68
- transitionCache: EpochTransitionCache
69
- ): [IdealAttestationsReward[], AttestationsPenalty[]] {
70
- const baseRewardPerIncrement = transitionCache.baseRewardPerIncrement;
71
- const activeBalanceByIncrement = transitionCache.totalActiveStakeByIncrement;
72
- const fork = state.config.getForkName(state.slot);
73
- const maxEffectiveBalance = isForkPostElectra(fork) ? MAX_EFFECTIVE_BALANCE_ELECTRA : MAX_EFFECTIVE_BALANCE;
74
- const maxEffectiveBalanceByIncrement = Math.floor(maxEffectiveBalance / EFFECTIVE_BALANCE_INCREMENT);
75
-
76
- const idealRewards = Array.from({length: maxEffectiveBalanceByIncrement + 1}, (_, effectiveBalanceByIncrement) => ({
77
- ...defaultAttestationsReward,
78
- effectiveBalance: effectiveBalanceByIncrement * EFFECTIVE_BALANCE_INCREMENT,
79
- }));
80
-
81
- const attestationsPenalties: AttestationsPenalty[] = Array.from(
82
- {length: maxEffectiveBalanceByIncrement + 1},
83
- (_, effectiveBalanceByIncrement) => ({
84
- ...defaultAttestationsPenalty,
85
- effectiveBalance: effectiveBalanceByIncrement * EFFECTIVE_BALANCE_INCREMENT,
86
- })
87
- );
88
-
89
- for (let i = 0; i < PARTICIPATION_FLAG_WEIGHTS.length; i++) {
90
- const weight = PARTICIPATION_FLAG_WEIGHTS[i];
91
-
92
- let unslashedStakeByIncrement: number;
93
- let flagName: keyof IdealAttestationsReward;
94
-
95
- switch (i) {
96
- case TIMELY_SOURCE_FLAG_INDEX: {
97
- unslashedStakeByIncrement = transitionCache.prevEpochUnslashedStake.sourceStakeByIncrement;
98
- flagName = "source";
99
- break;
100
- }
101
- case TIMELY_TARGET_FLAG_INDEX: {
102
- unslashedStakeByIncrement = transitionCache.prevEpochUnslashedStake.targetStakeByIncrement;
103
- flagName = "target";
104
- break;
105
- }
106
- case TIMELY_HEAD_FLAG_INDEX: {
107
- unslashedStakeByIncrement = transitionCache.prevEpochUnslashedStake.headStakeByIncrement;
108
- flagName = "head";
109
- break;
110
- }
111
- default: {
112
- throw Error(`Unable to retrieve unslashed stake. Unknown participation flag index: ${i}`);
113
- }
114
- }
115
-
116
- for (
117
- let effectiveBalanceByIncrement = 0;
118
- effectiveBalanceByIncrement <= maxEffectiveBalanceByIncrement;
119
- effectiveBalanceByIncrement++
120
- ) {
121
- const baseReward = effectiveBalanceByIncrement * baseRewardPerIncrement;
122
- const rewardNumerator = baseReward * weight * unslashedStakeByIncrement;
123
- // Both idealReward and penalty are rounded to nearest integer. Loss of precision is minimal as unit is gwei
124
- const idealReward = Math.round(rewardNumerator / activeBalanceByIncrement / WEIGHT_DENOMINATOR);
125
- const penalty = Math.round((baseReward * weight) / WEIGHT_DENOMINATOR); // Positive number indicates penalty
126
-
127
- const idealAttestationsReward = idealRewards[effectiveBalanceByIncrement];
128
- idealAttestationsReward[flagName] = isInInactivityLeak(state) ? 0 : idealReward; // No attestations rewards during inactivity leak
129
-
130
- if (flagName !== "head") {
131
- const attestationPenalty = attestationsPenalties[effectiveBalanceByIncrement];
132
- attestationPenalty[flagName] = penalty;
133
- }
134
- }
135
- }
136
-
137
- return [idealRewards, attestationsPenalties];
138
- }
139
-
140
- // Same calculation as `getRewardsAndPenaltiesAltair` but returns the breakdown of rewards instead of aggregated
141
- function computeTotalAttestationsRewardsAltair(
142
- state: CachedBeaconStateAltair,
143
- transitionCache: EpochTransitionCache,
144
- idealRewards: IdealAttestationsReward[],
145
- penalties: AttestationsPenalty[],
146
- validatorIds: (ValidatorIndex | string)[] = []
147
- ): TotalAttestationsReward[] {
148
- const rewards = [];
149
- const {flags} = transitionCache;
150
- const {epochCtx, config} = state;
151
- const validatorIndices = validatorIds
152
- .map((id) => (typeof id === "number" ? id : epochCtx.pubkey2index.get(fromHex(id))))
153
- .filter((index) => index !== undefined); // Validator indices to include in the result
154
-
155
- const inactivityPenaltyDenominator = config.INACTIVITY_SCORE_BIAS * INACTIVITY_PENALTY_QUOTIENT_ALTAIR;
156
-
157
- for (let i = 0; i < flags.length; i++) {
158
- if (validatorIndices.length && !validatorIndices.includes(i)) {
159
- continue;
160
- }
161
-
162
- const flag = flags[i];
163
- if (!hasMarkers(flag, FLAG_ELIGIBLE_ATTESTER)) {
164
- continue;
165
- }
166
-
167
- const effectiveBalanceIncrement = epochCtx.effectiveBalanceIncrements[i];
168
-
169
- const currentRewards = {...defaultAttestationsReward, validatorIndex: i};
170
-
171
- if (hasMarkers(flag, FLAG_PREV_SOURCE_ATTESTER_UNSLASHED)) {
172
- currentRewards.source = idealRewards[effectiveBalanceIncrement].source;
173
- } else {
174
- currentRewards.source = penalties[effectiveBalanceIncrement].source * -1; // Negative reward to indicate penalty
175
- }
176
-
177
- if (hasMarkers(flag, FLAG_PREV_TARGET_ATTESTER_UNSLASHED)) {
178
- currentRewards.target = idealRewards[effectiveBalanceIncrement].target;
179
- } else {
180
- currentRewards.target = penalties[effectiveBalanceIncrement].target * -1;
181
-
182
- // Also incur inactivity penalty if not voting target correctly
183
- const inactivityPenaltyNumerator =
184
- effectiveBalanceIncrement * EFFECTIVE_BALANCE_INCREMENT * state.inactivityScores.get(i);
185
- currentRewards.inactivity = Math.floor(inactivityPenaltyNumerator / inactivityPenaltyDenominator) * -1;
186
- }
187
-
188
- if (hasMarkers(flag, FLAG_PREV_HEAD_ATTESTER_UNSLASHED)) {
189
- currentRewards.head = idealRewards[effectiveBalanceIncrement].head;
190
- }
191
-
192
- rewards.push(currentRewards);
193
- }
194
-
195
- return rewards;
196
- }
@@ -1,150 +0,0 @@
1
- import {routes} from "@lodestar/api";
2
- import {
3
- ForkName,
4
- WHISTLEBLOWER_REWARD_QUOTIENT,
5
- WHISTLEBLOWER_REWARD_QUOTIENT_ELECTRA,
6
- isForkPostElectra,
7
- } from "@lodestar/params";
8
- import {
9
- CachedBeaconStateAllForks,
10
- CachedBeaconStateAltair,
11
- CachedBeaconStatePhase0,
12
- getAttesterSlashableIndices,
13
- processAttestationsAltair,
14
- } from "@lodestar/state-transition";
15
- import {BeaconBlock, altair, phase0} from "@lodestar/types";
16
-
17
- export type BlockRewards = routes.beacon.BlockRewards;
18
- type SubRewardValue = number; // All reward values should be integer
19
-
20
- /**
21
- * Calculate total proposer block rewards given block and the beacon state of the same slot before the block is applied (preState)
22
- * postState can be passed in to read reward cache if available
23
- * Standard (Non MEV) rewards for proposing a block consists of:
24
- * 1) Including attestations from (beacon) committee
25
- * 2) Including attestations from sync committee
26
- * 3) Reporting slashable behaviours from proposer and attester
27
- */
28
- export async function computeBlockRewards(
29
- block: BeaconBlock,
30
- preState: CachedBeaconStateAllForks,
31
- postState?: CachedBeaconStateAllForks
32
- ): Promise<BlockRewards> {
33
- const fork = preState.config.getForkName(block.slot);
34
- const {attestations: cachedAttestationsReward = 0, syncAggregate: cachedSyncAggregateReward = 0} =
35
- postState?.proposerRewards ?? {};
36
- let blockAttestationReward = cachedAttestationsReward;
37
- let syncAggregateReward = cachedSyncAggregateReward;
38
-
39
- if (blockAttestationReward === 0) {
40
- blockAttestationReward =
41
- fork === ForkName.phase0
42
- ? computeBlockAttestationRewardPhase0(block as phase0.BeaconBlock, preState as CachedBeaconStatePhase0)
43
- : computeBlockAttestationRewardAltair(block as altair.BeaconBlock, preState as CachedBeaconStateAltair);
44
- }
45
-
46
- if (syncAggregateReward === 0) {
47
- syncAggregateReward = computeSyncAggregateReward(block as altair.BeaconBlock, preState as CachedBeaconStateAltair);
48
- }
49
-
50
- const blockProposerSlashingReward = computeBlockProposerSlashingReward(fork, block, preState);
51
- const blockAttesterSlashingReward = computeBlockAttesterSlashingReward(fork, block, preState);
52
-
53
- const total =
54
- blockAttestationReward + syncAggregateReward + blockProposerSlashingReward + blockAttesterSlashingReward;
55
-
56
- return {
57
- proposerIndex: block.proposerIndex,
58
- total,
59
- attestations: blockAttestationReward,
60
- syncAggregate: syncAggregateReward,
61
- proposerSlashings: blockProposerSlashingReward,
62
- attesterSlashings: blockAttesterSlashingReward,
63
- };
64
- }
65
-
66
- /**
67
- * TODO: Calculate rewards received by block proposer for including attestations.
68
- */
69
- function computeBlockAttestationRewardPhase0(
70
- _block: phase0.BeaconBlock,
71
- _preState: CachedBeaconStatePhase0
72
- ): SubRewardValue {
73
- throw new Error("Unsupported fork! Block attestation reward calculation is not available in phase0");
74
- }
75
-
76
- /**
77
- * Calculate rewards received by block proposer for including attestations since Altair.
78
- * Reuses `processAttestationsAltair()`. Has dependency on RewardCache
79
- */
80
- function computeBlockAttestationRewardAltair(
81
- block: altair.BeaconBlock,
82
- preState: CachedBeaconStateAltair
83
- ): SubRewardValue {
84
- const fork = preState.config.getForkSeq(block.slot);
85
- const {attestations} = block.body;
86
-
87
- processAttestationsAltair(fork, preState, attestations, false);
88
-
89
- return preState.proposerRewards.attestations;
90
- }
91
-
92
- function computeSyncAggregateReward(block: altair.BeaconBlock, preState: CachedBeaconStateAltair): SubRewardValue {
93
- if (block.body.syncAggregate !== undefined) {
94
- const {syncCommitteeBits} = block.body.syncAggregate;
95
- const {syncProposerReward} = preState.epochCtx;
96
-
97
- return syncCommitteeBits.getTrueBitIndexes().length * Math.floor(syncProposerReward); // syncProposerReward should already be integer
98
- }
99
-
100
- return 0; // phase0 block does not have syncAggregate
101
- }
102
-
103
- /**
104
- * Calculate rewards received by block proposer for including proposer slashings.
105
- * All proposer slashing rewards go to block proposer and none to whistleblower as of Deneb
106
- */
107
- function computeBlockProposerSlashingReward(
108
- fork: ForkName,
109
- block: BeaconBlock,
110
- state: CachedBeaconStateAllForks
111
- ): SubRewardValue {
112
- let proposerSlashingReward = 0;
113
-
114
- for (const proposerSlashing of block.body.proposerSlashings) {
115
- const offendingProposerIndex = proposerSlashing.signedHeader1.message.proposerIndex;
116
- const offendingProposerBalance = state.validators.getReadonly(offendingProposerIndex).effectiveBalance;
117
- const whistleblowerRewardQuotient = isForkPostElectra(fork)
118
- ? WHISTLEBLOWER_REWARD_QUOTIENT_ELECTRA
119
- : WHISTLEBLOWER_REWARD_QUOTIENT;
120
-
121
- proposerSlashingReward += Math.floor(offendingProposerBalance / whistleblowerRewardQuotient);
122
- }
123
-
124
- return proposerSlashingReward;
125
- }
126
-
127
- /**
128
- * Calculate rewards received by block proposer for including attester slashings.
129
- * All attester slashing rewards go to block proposer and none to whistleblower as of Deneb
130
- */
131
- function computeBlockAttesterSlashingReward(
132
- fork: ForkName,
133
- block: BeaconBlock,
134
- preState: CachedBeaconStateAllForks
135
- ): SubRewardValue {
136
- let attesterSlashingReward = 0;
137
-
138
- for (const attesterSlashing of block.body.attesterSlashings) {
139
- for (const offendingAttesterIndex of getAttesterSlashableIndices(attesterSlashing)) {
140
- const offendingAttesterBalance = preState.validators.getReadonly(offendingAttesterIndex).effectiveBalance;
141
- const whistleblowerRewardQuotient = isForkPostElectra(fork)
142
- ? WHISTLEBLOWER_REWARD_QUOTIENT_ELECTRA
143
- : WHISTLEBLOWER_REWARD_QUOTIENT;
144
-
145
- attesterSlashingReward += Math.floor(offendingAttesterBalance / whistleblowerRewardQuotient);
146
- }
147
- }
148
-
149
- return attesterSlashingReward;
150
- }
@@ -1,58 +0,0 @@
1
- import {routes} from "@lodestar/api";
2
- import {ForkName, SYNC_COMMITTEE_SIZE} from "@lodestar/params";
3
- import {CachedBeaconStateAllForks, CachedBeaconStateAltair} from "@lodestar/state-transition";
4
- import {BeaconBlock, ValidatorIndex, altair} from "@lodestar/types";
5
-
6
- export type SyncCommitteeRewards = routes.beacon.SyncCommitteeRewards;
7
- type BalanceRecord = {val: number}; // Use val for convenient way to increment/decrement balance
8
-
9
- export async function computeSyncCommitteeRewards(
10
- block: BeaconBlock,
11
- preState: CachedBeaconStateAllForks,
12
- validatorIds: (ValidatorIndex | string)[] = []
13
- ): Promise<SyncCommitteeRewards> {
14
- const fork = preState.config.getForkName(block.slot);
15
- if (fork === ForkName.phase0) {
16
- throw Error("Cannot get sync rewards as phase0 block does not have sync committee");
17
- }
18
-
19
- const altairBlock = block as altair.BeaconBlock;
20
- const preStateAltair = preState as CachedBeaconStateAltair;
21
- const {index2pubkey} = preStateAltair.epochCtx;
22
-
23
- // Bound syncCommitteeValidatorIndices in case it goes beyond SYNC_COMMITTEE_SIZE just to be safe
24
- const syncCommitteeValidatorIndices = preStateAltair.epochCtx.currentSyncCommitteeIndexed.validatorIndices.slice(
25
- 0,
26
- SYNC_COMMITTEE_SIZE
27
- );
28
- const {syncParticipantReward} = preStateAltair.epochCtx;
29
- const {syncCommitteeBits} = altairBlock.body.syncAggregate;
30
-
31
- // Use balance of each committee as starting point such that we cap the penalty to avoid balance dropping below 0
32
- const balances: Map<ValidatorIndex, BalanceRecord> = new Map();
33
- for (const i of syncCommitteeValidatorIndices) {
34
- balances.set(i, {val: preStateAltair.balances.get(i)});
35
- }
36
-
37
- for (const i of syncCommitteeValidatorIndices) {
38
- const balanceRecord = balances.get(i) as BalanceRecord;
39
- if (syncCommitteeBits.get(i)) {
40
- // Positive rewards for participants
41
- balanceRecord.val += syncParticipantReward;
42
- } else {
43
- // Negative rewards for non participants
44
- balanceRecord.val = Math.max(0, balanceRecord.val - syncParticipantReward);
45
- }
46
- }
47
-
48
- const rewards = Array.from(balances, ([validatorIndex, v]) => ({validatorIndex, reward: v.val}));
49
-
50
- if (validatorIds.length) {
51
- const filtersSet = new Set(validatorIds);
52
- return rewards.filter(
53
- (reward) => filtersSet.has(reward.validatorIndex) || filtersSet.has(index2pubkey[reward.validatorIndex].toHex())
54
- );
55
- }
56
-
57
- return rewards;
58
- }
@@ -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> {}