@lodestar/beacon-node 1.39.0-dev.3bf4734ba9 → 1.39.0-dev.4263377242

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 (475) hide show
  1. package/README.md +1 -1
  2. package/lib/api/impl/beacon/blocks/utils.js +1 -1
  3. package/lib/api/impl/beacon/blocks/utils.js.map +1 -1
  4. package/lib/api/impl/beacon/state/utils.d.ts +2 -7
  5. package/lib/api/impl/beacon/state/utils.d.ts.map +1 -1
  6. package/lib/api/impl/beacon/state/utils.js +0 -12
  7. package/lib/api/impl/beacon/state/utils.js.map +1 -1
  8. package/lib/api/impl/lodestar/index.js +1 -1
  9. package/lib/api/impl/lodestar/index.js.map +1 -1
  10. package/lib/api/impl/proof/index.d.ts.map +1 -1
  11. package/lib/api/impl/proof/index.js +1 -2
  12. package/lib/api/impl/proof/index.js.map +1 -1
  13. package/lib/api/impl/validator/index.d.ts.map +1 -1
  14. package/lib/api/impl/validator/index.js +1 -3
  15. package/lib/api/impl/validator/index.js.map +1 -1
  16. package/lib/chain/archiveStore/historicalState/getHistoricalState.d.ts.map +1 -1
  17. package/lib/chain/archiveStore/historicalState/getHistoricalState.js +5 -3
  18. package/lib/chain/archiveStore/historicalState/getHistoricalState.js.map +1 -1
  19. package/lib/chain/blocks/importBlock.d.ts.map +1 -1
  20. package/lib/chain/blocks/importBlock.js +12 -3
  21. package/lib/chain/blocks/importBlock.js.map +1 -1
  22. package/lib/chain/blocks/verifyBlock.d.ts.map +1 -1
  23. package/lib/chain/blocks/verifyBlock.js +9 -2
  24. package/lib/chain/blocks/verifyBlock.js.map +1 -1
  25. package/lib/chain/blocks/verifyBlocksExecutionPayloads.d.ts.map +1 -1
  26. package/lib/chain/blocks/verifyBlocksExecutionPayloads.js +4 -2
  27. package/lib/chain/blocks/verifyBlocksExecutionPayloads.js.map +1 -1
  28. package/lib/chain/blocks/verifyBlocksSignatures.d.ts +2 -1
  29. package/lib/chain/blocks/verifyBlocksSignatures.d.ts.map +1 -1
  30. package/lib/chain/blocks/verifyBlocksSignatures.js +3 -2
  31. package/lib/chain/blocks/verifyBlocksSignatures.js.map +1 -1
  32. package/lib/chain/blocks/verifyBlocksStateTransitionOnly.d.ts.map +1 -1
  33. package/lib/chain/blocks/verifyBlocksStateTransitionOnly.js +1 -0
  34. package/lib/chain/blocks/verifyBlocksStateTransitionOnly.js.map +1 -1
  35. package/lib/chain/chain.d.ts +11 -14
  36. package/lib/chain/chain.d.ts.map +1 -1
  37. package/lib/chain/chain.js +36 -50
  38. package/lib/chain/chain.js.map +1 -1
  39. package/lib/chain/forkChoice/index.d.ts.map +1 -1
  40. package/lib/chain/forkChoice/index.js +3 -3
  41. package/lib/chain/forkChoice/index.js.map +1 -1
  42. package/lib/chain/initState.d.ts +2 -15
  43. package/lib/chain/initState.d.ts.map +1 -1
  44. package/lib/chain/initState.js +6 -65
  45. package/lib/chain/initState.js.map +1 -1
  46. package/lib/chain/interface.d.ts +6 -11
  47. package/lib/chain/interface.d.ts.map +1 -1
  48. package/lib/chain/interface.js.map +1 -1
  49. package/lib/chain/lightClient/proofs.d.ts.map +1 -1
  50. package/lib/chain/lightClient/proofs.js +0 -2
  51. package/lib/chain/lightClient/proofs.js.map +1 -1
  52. package/lib/chain/opPools/aggregatedAttestationPool.d.ts +8 -12
  53. package/lib/chain/opPools/aggregatedAttestationPool.d.ts.map +1 -1
  54. package/lib/chain/opPools/aggregatedAttestationPool.js +13 -142
  55. package/lib/chain/opPools/aggregatedAttestationPool.js.map +1 -1
  56. package/lib/chain/opPools/opPool.d.ts +3 -0
  57. package/lib/chain/opPools/opPool.d.ts.map +1 -1
  58. package/lib/chain/opPools/opPool.js +14 -16
  59. package/lib/chain/opPools/opPool.js.map +1 -1
  60. package/lib/chain/prepareNextSlot.d.ts +0 -4
  61. package/lib/chain/prepareNextSlot.d.ts.map +1 -1
  62. package/lib/chain/prepareNextSlot.js +5 -28
  63. package/lib/chain/prepareNextSlot.js.map +1 -1
  64. package/lib/chain/produceBlock/produceBlockBody.d.ts +0 -1
  65. package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
  66. package/lib/chain/produceBlock/produceBlockBody.js +10 -13
  67. package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
  68. package/lib/chain/regen/interface.d.ts +1 -5
  69. package/lib/chain/regen/interface.d.ts.map +1 -1
  70. package/lib/chain/regen/queued.d.ts +4 -7
  71. package/lib/chain/regen/queued.d.ts.map +1 -1
  72. package/lib/chain/regen/queued.js +15 -25
  73. package/lib/chain/regen/queued.js.map +1 -1
  74. package/lib/chain/regen/regen.d.ts +1 -1
  75. package/lib/chain/regen/regen.d.ts.map +1 -1
  76. package/lib/chain/regen/regen.js +13 -17
  77. package/lib/chain/regen/regen.js.map +1 -1
  78. package/lib/chain/shufflingCache.d.ts +16 -11
  79. package/lib/chain/shufflingCache.d.ts.map +1 -1
  80. package/lib/chain/shufflingCache.js +47 -41
  81. package/lib/chain/shufflingCache.js.map +1 -1
  82. package/lib/chain/stateCache/blockStateCacheImpl.d.ts +1 -2
  83. package/lib/chain/stateCache/blockStateCacheImpl.d.ts.map +1 -1
  84. package/lib/chain/stateCache/blockStateCacheImpl.js +2 -2
  85. package/lib/chain/stateCache/blockStateCacheImpl.js.map +1 -1
  86. package/lib/chain/stateCache/fifoBlockStateCache.d.ts +1 -2
  87. package/lib/chain/stateCache/fifoBlockStateCache.d.ts.map +1 -1
  88. package/lib/chain/stateCache/fifoBlockStateCache.js +4 -4
  89. package/lib/chain/stateCache/fifoBlockStateCache.js.map +1 -1
  90. package/lib/chain/stateCache/inMemoryCheckpointsCache.d.ts +4 -5
  91. package/lib/chain/stateCache/inMemoryCheckpointsCache.d.ts.map +1 -1
  92. package/lib/chain/stateCache/inMemoryCheckpointsCache.js +9 -10
  93. package/lib/chain/stateCache/inMemoryCheckpointsCache.js.map +1 -1
  94. package/lib/chain/stateCache/persistentCheckpointsCache.d.ts +9 -7
  95. package/lib/chain/stateCache/persistentCheckpointsCache.d.ts.map +1 -1
  96. package/lib/chain/stateCache/persistentCheckpointsCache.js +21 -19
  97. package/lib/chain/stateCache/persistentCheckpointsCache.js.map +1 -1
  98. package/lib/chain/stateCache/types.d.ts +5 -6
  99. package/lib/chain/stateCache/types.d.ts.map +1 -1
  100. package/lib/chain/stateCache/types.js.map +1 -1
  101. package/lib/chain/validation/aggregateAndProof.js +9 -0
  102. package/lib/chain/validation/aggregateAndProof.js.map +1 -1
  103. package/lib/chain/validation/attestation.d.ts.map +1 -1
  104. package/lib/chain/validation/attestation.js +2 -2
  105. package/lib/chain/validation/attestation.js.map +1 -1
  106. package/lib/chain/validation/attesterSlashing.d.ts.map +1 -1
  107. package/lib/chain/validation/attesterSlashing.js +2 -2
  108. package/lib/chain/validation/attesterSlashing.js.map +1 -1
  109. package/lib/chain/validation/blobSidecar.d.ts.map +1 -1
  110. package/lib/chain/validation/blobSidecar.js +2 -3
  111. package/lib/chain/validation/blobSidecar.js.map +1 -1
  112. package/lib/chain/validation/block.d.ts.map +1 -1
  113. package/lib/chain/validation/block.js +5 -3
  114. package/lib/chain/validation/block.js.map +1 -1
  115. package/lib/chain/validation/blsToExecutionChange.d.ts.map +1 -1
  116. package/lib/chain/validation/blsToExecutionChange.js +10 -3
  117. package/lib/chain/validation/blsToExecutionChange.js.map +1 -1
  118. package/lib/chain/validation/dataColumnSidecar.d.ts.map +1 -1
  119. package/lib/chain/validation/dataColumnSidecar.js +2 -3
  120. package/lib/chain/validation/dataColumnSidecar.js.map +1 -1
  121. package/lib/chain/validation/proposerSlashing.js +3 -2
  122. package/lib/chain/validation/proposerSlashing.js.map +1 -1
  123. package/lib/chain/validation/signatureSets/aggregateAndProof.js +1 -1
  124. package/lib/chain/validation/signatureSets/aggregateAndProof.js.map +1 -1
  125. package/lib/chain/validation/signatureSets/contributionAndProof.d.ts +2 -1
  126. package/lib/chain/validation/signatureSets/contributionAndProof.d.ts.map +1 -1
  127. package/lib/chain/validation/signatureSets/contributionAndProof.js +2 -2
  128. package/lib/chain/validation/signatureSets/contributionAndProof.js.map +1 -1
  129. package/lib/chain/validation/signatureSets/syncCommittee.d.ts +2 -1
  130. package/lib/chain/validation/signatureSets/syncCommittee.d.ts.map +1 -1
  131. package/lib/chain/validation/signatureSets/syncCommittee.js +2 -2
  132. package/lib/chain/validation/signatureSets/syncCommittee.js.map +1 -1
  133. package/lib/chain/validation/signatureSets/syncCommitteeContribution.d.ts +2 -1
  134. package/lib/chain/validation/signatureSets/syncCommitteeContribution.d.ts.map +1 -1
  135. package/lib/chain/validation/signatureSets/syncCommitteeContribution.js +2 -2
  136. package/lib/chain/validation/signatureSets/syncCommitteeContribution.js.map +1 -1
  137. package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.d.ts +2 -1
  138. package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.d.ts.map +1 -1
  139. package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.js +1 -2
  140. package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.js.map +1 -1
  141. package/lib/chain/validation/syncCommittee.js +1 -1
  142. package/lib/chain/validation/syncCommittee.js.map +1 -1
  143. package/lib/chain/validation/syncCommitteeContributionAndProof.d.ts.map +1 -1
  144. package/lib/chain/validation/syncCommitteeContributionAndProof.js +3 -3
  145. package/lib/chain/validation/syncCommitteeContributionAndProof.js.map +1 -1
  146. package/lib/chain/validation/voluntaryExit.js +1 -1
  147. package/lib/chain/validation/voluntaryExit.js.map +1 -1
  148. package/lib/db/beacon.d.ts +3 -7
  149. package/lib/db/beacon.d.ts.map +1 -1
  150. package/lib/db/beacon.js +33 -12
  151. package/lib/db/beacon.js.map +1 -1
  152. package/lib/db/buckets.d.ts +12 -6
  153. package/lib/db/buckets.d.ts.map +1 -1
  154. package/lib/db/buckets.js +6 -1
  155. package/lib/db/buckets.js.map +1 -1
  156. package/lib/db/interface.d.ts +2 -7
  157. package/lib/db/interface.d.ts.map +1 -1
  158. package/lib/db/repositories/checkpointState.d.ts +2 -6
  159. package/lib/db/repositories/checkpointState.d.ts.map +1 -1
  160. package/lib/db/repositories/checkpointState.js +3 -15
  161. package/lib/db/repositories/checkpointState.js.map +1 -1
  162. package/lib/db/repositories/index.d.ts +0 -3
  163. package/lib/db/repositories/index.d.ts.map +1 -1
  164. package/lib/db/repositories/index.js +0 -3
  165. package/lib/db/repositories/index.js.map +1 -1
  166. package/lib/db/repositories/stateArchive.d.ts +9 -9
  167. package/lib/db/repositories/stateArchive.d.ts.map +1 -1
  168. package/lib/db/repositories/stateArchive.js +6 -21
  169. package/lib/db/repositories/stateArchive.js.map +1 -1
  170. package/lib/execution/engine/http.d.ts +1 -1
  171. package/lib/execution/engine/http.d.ts.map +1 -1
  172. package/lib/execution/engine/http.js +2 -3
  173. package/lib/execution/engine/http.js.map +1 -1
  174. package/lib/execution/engine/index.d.ts.map +1 -1
  175. package/lib/execution/engine/index.js +1 -1
  176. package/lib/execution/engine/index.js.map +1 -1
  177. package/lib/execution/engine/interface.d.ts +1 -1
  178. package/lib/execution/engine/interface.d.ts.map +1 -1
  179. package/lib/execution/engine/interface.js.map +1 -1
  180. package/lib/{eth1/provider → execution/engine}/jsonRpcHttpClient.d.ts +1 -1
  181. package/lib/execution/engine/jsonRpcHttpClient.d.ts.map +1 -0
  182. package/lib/execution/engine/jsonRpcHttpClient.js.map +1 -0
  183. package/lib/execution/engine/jwt.d.ts.map +1 -0
  184. package/lib/execution/engine/jwt.js.map +1 -0
  185. package/lib/execution/engine/mock.d.ts +9 -6
  186. package/lib/execution/engine/mock.d.ts.map +1 -1
  187. package/lib/execution/engine/mock.js +35 -8
  188. package/lib/execution/engine/mock.js.map +1 -1
  189. package/lib/execution/engine/payloadIdCache.d.ts +1 -1
  190. package/lib/execution/engine/payloadIdCache.d.ts.map +1 -1
  191. package/lib/execution/engine/types.d.ts +1 -1
  192. package/lib/execution/engine/types.d.ts.map +1 -1
  193. package/lib/execution/engine/types.js +1 -1
  194. package/lib/execution/engine/types.js.map +1 -1
  195. package/lib/execution/engine/utils.d.ts +64 -2
  196. package/lib/execution/engine/utils.d.ts.map +1 -1
  197. package/lib/execution/engine/utils.js +91 -2
  198. package/lib/execution/engine/utils.js.map +1 -1
  199. package/lib/index.d.ts +1 -2
  200. package/lib/index.d.ts.map +1 -1
  201. package/lib/index.js +1 -2
  202. package/lib/index.js.map +1 -1
  203. package/lib/metrics/metrics/lodestar.d.ts +1 -41
  204. package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
  205. package/lib/metrics/metrics/lodestar.js +3 -107
  206. package/lib/metrics/metrics/lodestar.js.map +1 -1
  207. package/lib/network/core/events.d.ts +1 -1
  208. package/lib/network/core/events.d.ts.map +1 -1
  209. package/lib/network/core/events.js +1 -1
  210. package/lib/network/core/events.js.map +1 -1
  211. package/lib/network/events.d.ts +6 -1
  212. package/lib/network/events.d.ts.map +1 -1
  213. package/lib/network/events.js +7 -1
  214. package/lib/network/events.js.map +1 -1
  215. package/lib/network/peers/discover.d.ts.map +1 -1
  216. package/lib/network/peers/discover.js.map +1 -1
  217. package/lib/network/reqresp/utils/dataColumnResponseValidation.js +1 -1
  218. package/lib/network/reqresp/utils/dataColumnResponseValidation.js.map +1 -1
  219. package/lib/node/nodejs.d.ts +6 -3
  220. package/lib/node/nodejs.d.ts.map +1 -1
  221. package/lib/node/nodejs.js +30 -12
  222. package/lib/node/nodejs.js.map +1 -1
  223. package/lib/node/notifier.d.ts.map +1 -1
  224. package/lib/node/notifier.js +9 -6
  225. package/lib/node/notifier.js.map +1 -1
  226. package/lib/node/options.d.ts +0 -2
  227. package/lib/node/options.d.ts.map +1 -1
  228. package/lib/node/options.js +0 -2
  229. package/lib/node/options.js.map +1 -1
  230. package/lib/node/utils/interop/deposits.d.ts +2 -1
  231. package/lib/node/utils/interop/deposits.d.ts.map +1 -1
  232. package/lib/node/utils/interop/deposits.js.map +1 -1
  233. package/lib/node/utils/interop/state.d.ts +1 -1
  234. package/lib/node/utils/interop/state.d.ts.map +1 -1
  235. package/lib/node/utils/state.d.ts +1 -7
  236. package/lib/node/utils/state.d.ts.map +1 -1
  237. package/lib/node/utils/state.js +1 -14
  238. package/lib/node/utils/state.js.map +1 -1
  239. package/lib/sync/backfill/backfill.d.ts.map +1 -1
  240. package/lib/sync/backfill/backfill.js +2 -4
  241. package/lib/sync/backfill/backfill.js.map +1 -1
  242. package/lib/sync/backfill/verify.d.ts +2 -2
  243. package/lib/sync/backfill/verify.d.ts.map +1 -1
  244. package/lib/sync/backfill/verify.js +3 -3
  245. package/lib/sync/backfill/verify.js.map +1 -1
  246. package/lib/util/sszBytes.js +1 -1
  247. package/lib/util/sszBytes.js.map +1 -1
  248. package/lib/util/workerEvents.d.ts +1 -6
  249. package/lib/util/workerEvents.d.ts.map +1 -1
  250. package/lib/util/workerEvents.js +8 -8
  251. package/lib/util/workerEvents.js.map +1 -1
  252. package/package.json +28 -26
  253. package/src/api/impl/beacon/blocks/utils.ts +1 -1
  254. package/src/api/impl/beacon/state/utils.ts +2 -22
  255. package/src/api/impl/lodestar/index.ts +1 -1
  256. package/src/api/impl/proof/index.ts +1 -2
  257. package/src/api/impl/validator/index.ts +1 -3
  258. package/src/chain/archiveStore/historicalState/getHistoricalState.ts +5 -3
  259. package/src/chain/blocks/importBlock.ts +13 -3
  260. package/src/chain/blocks/verifyBlock.ts +10 -3
  261. package/src/chain/blocks/verifyBlocksExecutionPayloads.ts +9 -2
  262. package/src/chain/blocks/verifyBlocksSignatures.ts +13 -3
  263. package/src/chain/blocks/verifyBlocksStateTransitionOnly.ts +1 -0
  264. package/src/chain/chain.ts +50 -62
  265. package/src/chain/forkChoice/index.ts +3 -2
  266. package/src/chain/initState.ts +6 -100
  267. package/src/chain/interface.ts +6 -10
  268. package/src/chain/lightClient/proofs.ts +0 -2
  269. package/src/chain/opPools/aggregatedAttestationPool.ts +23 -195
  270. package/src/chain/opPools/opPool.ts +13 -15
  271. package/src/chain/prepareNextSlot.ts +3 -34
  272. package/src/chain/produceBlock/produceBlockBody.ts +15 -14
  273. package/src/chain/regen/interface.ts +1 -5
  274. package/src/chain/regen/queued.ts +15 -34
  275. package/src/chain/regen/regen.ts +12 -18
  276. package/src/chain/shufflingCache.ts +67 -50
  277. package/src/chain/stateCache/blockStateCacheImpl.ts +2 -3
  278. package/src/chain/stateCache/fifoBlockStateCache.ts +4 -5
  279. package/src/chain/stateCache/inMemoryCheckpointsCache.ts +9 -15
  280. package/src/chain/stateCache/persistentCheckpointsCache.ts +32 -27
  281. package/src/chain/stateCache/types.ts +5 -10
  282. package/src/chain/validation/aggregateAndProof.ts +12 -0
  283. package/src/chain/validation/attestation.ts +3 -3
  284. package/src/chain/validation/attesterSlashing.ts +14 -2
  285. package/src/chain/validation/blobSidecar.ts +3 -3
  286. package/src/chain/validation/block.ts +6 -2
  287. package/src/chain/validation/blsToExecutionChange.ts +10 -8
  288. package/src/chain/validation/dataColumnSidecar.ts +3 -3
  289. package/src/chain/validation/proposerSlashing.ts +8 -2
  290. package/src/chain/validation/signatureSets/aggregateAndProof.ts +1 -1
  291. package/src/chain/validation/signatureSets/contributionAndProof.ts +3 -1
  292. package/src/chain/validation/signatureSets/syncCommittee.ts +3 -1
  293. package/src/chain/validation/signatureSets/syncCommitteeContribution.ts +3 -1
  294. package/src/chain/validation/signatureSets/syncCommitteeSelectionProof.ts +2 -1
  295. package/src/chain/validation/syncCommittee.ts +1 -1
  296. package/src/chain/validation/syncCommitteeContributionAndProof.ts +8 -3
  297. package/src/chain/validation/voluntaryExit.ts +1 -1
  298. package/src/db/beacon.ts +38 -16
  299. package/src/db/buckets.ts +12 -7
  300. package/src/db/interface.ts +2 -13
  301. package/src/db/repositories/checkpointState.ts +3 -19
  302. package/src/db/repositories/index.ts +0 -3
  303. package/src/db/repositories/stateArchive.ts +13 -27
  304. package/src/execution/engine/http.ts +8 -9
  305. package/src/execution/engine/index.ts +1 -1
  306. package/src/execution/engine/interface.ts +1 -1
  307. package/src/{eth1/provider → execution/engine}/jsonRpcHttpClient.ts +1 -1
  308. package/src/execution/engine/mock.ts +41 -15
  309. package/src/execution/engine/payloadIdCache.ts +1 -1
  310. package/src/execution/engine/types.ts +9 -9
  311. package/src/execution/engine/utils.ts +111 -5
  312. package/src/index.ts +1 -2
  313. package/src/metrics/metrics/lodestar.ts +3 -109
  314. package/src/network/core/events.ts +1 -1
  315. package/src/network/events.ts +7 -1
  316. package/src/network/peers/discover.ts +3 -3
  317. package/src/network/reqresp/utils/dataColumnResponseValidation.ts +1 -1
  318. package/src/node/nodejs.ts +37 -13
  319. package/src/node/notifier.ts +13 -7
  320. package/src/node/options.ts +0 -3
  321. package/src/node/utils/interop/deposits.ts +3 -1
  322. package/src/node/utils/interop/state.ts +1 -1
  323. package/src/node/utils/state.ts +3 -18
  324. package/src/sync/backfill/backfill.ts +2 -9
  325. package/src/sync/backfill/verify.ts +3 -8
  326. package/src/util/sszBytes.ts +1 -1
  327. package/src/util/workerEvents.ts +9 -8
  328. package/lib/chain/genesis/genesis.d.ts +0 -51
  329. package/lib/chain/genesis/genesis.d.ts.map +0 -1
  330. package/lib/chain/genesis/genesis.js +0 -123
  331. package/lib/chain/genesis/genesis.js.map +0 -1
  332. package/lib/chain/genesis/interface.d.ts +0 -13
  333. package/lib/chain/genesis/interface.d.ts.map +0 -1
  334. package/lib/chain/genesis/interface.js +0 -2
  335. package/lib/chain/genesis/interface.js.map +0 -1
  336. package/lib/chain/rewards/attestationsRewards.d.ts +0 -7
  337. package/lib/chain/rewards/attestationsRewards.d.ts.map +0 -1
  338. package/lib/chain/rewards/attestationsRewards.js +0 -112
  339. package/lib/chain/rewards/attestationsRewards.js.map +0 -1
  340. package/lib/chain/rewards/blockRewards.d.ts +0 -14
  341. package/lib/chain/rewards/blockRewards.d.ts.map +0 -1
  342. package/lib/chain/rewards/blockRewards.js +0 -94
  343. package/lib/chain/rewards/blockRewards.js.map +0 -1
  344. package/lib/chain/rewards/syncCommitteeRewards.d.ts +0 -6
  345. package/lib/chain/rewards/syncCommitteeRewards.d.ts.map +0 -1
  346. package/lib/chain/rewards/syncCommitteeRewards.js +0 -36
  347. package/lib/chain/rewards/syncCommitteeRewards.js.map +0 -1
  348. package/lib/db/repositories/depositDataRoot.d.ts +0 -22
  349. package/lib/db/repositories/depositDataRoot.d.ts.map +0 -1
  350. package/lib/db/repositories/depositDataRoot.js +0 -62
  351. package/lib/db/repositories/depositDataRoot.js.map +0 -1
  352. package/lib/db/repositories/depositEvent.d.ts +0 -13
  353. package/lib/db/repositories/depositEvent.d.ts.map +0 -1
  354. package/lib/db/repositories/depositEvent.js +0 -27
  355. package/lib/db/repositories/depositEvent.js.map +0 -1
  356. package/lib/db/repositories/eth1Data.d.ts +0 -13
  357. package/lib/db/repositories/eth1Data.d.ts.map +0 -1
  358. package/lib/db/repositories/eth1Data.js +0 -26
  359. package/lib/db/repositories/eth1Data.js.map +0 -1
  360. package/lib/db/single/index.d.ts +0 -3
  361. package/lib/db/single/index.d.ts.map +0 -1
  362. package/lib/db/single/index.js +0 -3
  363. package/lib/db/single/index.js.map +0 -1
  364. package/lib/db/single/preGenesisState.d.ts +0 -16
  365. package/lib/db/single/preGenesisState.d.ts.map +0 -1
  366. package/lib/db/single/preGenesisState.js +0 -29
  367. package/lib/db/single/preGenesisState.js.map +0 -1
  368. package/lib/db/single/preGenesisStateLastProcessedBlock.d.ts +0 -14
  369. package/lib/db/single/preGenesisStateLastProcessedBlock.d.ts.map +0 -1
  370. package/lib/db/single/preGenesisStateLastProcessedBlock.js +0 -27
  371. package/lib/db/single/preGenesisStateLastProcessedBlock.js.map +0 -1
  372. package/lib/eth1/errors.d.ts +0 -66
  373. package/lib/eth1/errors.d.ts.map +0 -1
  374. package/lib/eth1/errors.js +0 -27
  375. package/lib/eth1/errors.js.map +0 -1
  376. package/lib/eth1/eth1DataCache.d.ts +0 -19
  377. package/lib/eth1/eth1DataCache.d.ts.map +0 -1
  378. package/lib/eth1/eth1DataCache.js +0 -19
  379. package/lib/eth1/eth1DataCache.js.map +0 -1
  380. package/lib/eth1/eth1DepositDataTracker.d.ts +0 -80
  381. package/lib/eth1/eth1DepositDataTracker.d.ts.map +0 -1
  382. package/lib/eth1/eth1DepositDataTracker.js +0 -317
  383. package/lib/eth1/eth1DepositDataTracker.js.map +0 -1
  384. package/lib/eth1/eth1DepositsCache.d.ts +0 -42
  385. package/lib/eth1/eth1DepositsCache.d.ts.map +0 -1
  386. package/lib/eth1/eth1DepositsCache.js +0 -119
  387. package/lib/eth1/eth1DepositsCache.js.map +0 -1
  388. package/lib/eth1/index.d.ts +0 -31
  389. package/lib/eth1/index.d.ts.map +0 -1
  390. package/lib/eth1/index.js +0 -71
  391. package/lib/eth1/index.js.map +0 -1
  392. package/lib/eth1/interface.d.ts +0 -74
  393. package/lib/eth1/interface.d.ts.map +0 -1
  394. package/lib/eth1/interface.js +0 -8
  395. package/lib/eth1/interface.js.map +0 -1
  396. package/lib/eth1/options.d.ts +0 -22
  397. package/lib/eth1/options.d.ts.map +0 -1
  398. package/lib/eth1/options.js +0 -8
  399. package/lib/eth1/options.js.map +0 -1
  400. package/lib/eth1/provider/eth1Provider.d.ts +0 -39
  401. package/lib/eth1/provider/eth1Provider.d.ts.map +0 -1
  402. package/lib/eth1/provider/eth1Provider.js +0 -147
  403. package/lib/eth1/provider/eth1Provider.js.map +0 -1
  404. package/lib/eth1/provider/jsonRpcHttpClient.d.ts.map +0 -1
  405. package/lib/eth1/provider/jsonRpcHttpClient.js.map +0 -1
  406. package/lib/eth1/provider/jwt.d.ts.map +0 -1
  407. package/lib/eth1/provider/jwt.js.map +0 -1
  408. package/lib/eth1/provider/utils.d.ts +0 -65
  409. package/lib/eth1/provider/utils.d.ts.map +0 -1
  410. package/lib/eth1/provider/utils.js +0 -120
  411. package/lib/eth1/provider/utils.js.map +0 -1
  412. package/lib/eth1/stream.d.ts +0 -15
  413. package/lib/eth1/stream.d.ts.map +0 -1
  414. package/lib/eth1/stream.js +0 -54
  415. package/lib/eth1/stream.js.map +0 -1
  416. package/lib/eth1/utils/depositContract.d.ts +0 -14
  417. package/lib/eth1/utils/depositContract.d.ts.map +0 -1
  418. package/lib/eth1/utils/depositContract.js +0 -33
  419. package/lib/eth1/utils/depositContract.js.map +0 -1
  420. package/lib/eth1/utils/deposits.d.ts +0 -8
  421. package/lib/eth1/utils/deposits.d.ts.map +0 -1
  422. package/lib/eth1/utils/deposits.js +0 -47
  423. package/lib/eth1/utils/deposits.js.map +0 -1
  424. package/lib/eth1/utils/eth1Data.d.ts +0 -22
  425. package/lib/eth1/utils/eth1Data.d.ts.map +0 -1
  426. package/lib/eth1/utils/eth1Data.js +0 -77
  427. package/lib/eth1/utils/eth1Data.js.map +0 -1
  428. package/lib/eth1/utils/eth1DepositEvent.d.ts +0 -7
  429. package/lib/eth1/utils/eth1DepositEvent.d.ts.map +0 -1
  430. package/lib/eth1/utils/eth1DepositEvent.js +0 -13
  431. package/lib/eth1/utils/eth1DepositEvent.js.map +0 -1
  432. package/lib/eth1/utils/eth1Vote.d.ts +0 -17
  433. package/lib/eth1/utils/eth1Vote.d.ts.map +0 -1
  434. package/lib/eth1/utils/eth1Vote.js +0 -111
  435. package/lib/eth1/utils/eth1Vote.js.map +0 -1
  436. package/lib/eth1/utils/groupDepositEventsByBlock.d.ts +0 -9
  437. package/lib/eth1/utils/groupDepositEventsByBlock.d.ts.map +0 -1
  438. package/lib/eth1/utils/groupDepositEventsByBlock.js +0 -17
  439. package/lib/eth1/utils/groupDepositEventsByBlock.js.map +0 -1
  440. package/lib/eth1/utils/optimizeNextBlockDiffForGenesis.d.ts +0 -10
  441. package/lib/eth1/utils/optimizeNextBlockDiffForGenesis.d.ts.map +0 -1
  442. package/lib/eth1/utils/optimizeNextBlockDiffForGenesis.js +0 -14
  443. package/lib/eth1/utils/optimizeNextBlockDiffForGenesis.js.map +0 -1
  444. package/src/chain/genesis/genesis.ts +0 -190
  445. package/src/chain/genesis/interface.ts +0 -14
  446. package/src/chain/rewards/attestationsRewards.ts +0 -197
  447. package/src/chain/rewards/blockRewards.ts +0 -150
  448. package/src/chain/rewards/syncCommitteeRewards.ts +0 -58
  449. package/src/db/repositories/depositDataRoot.ts +0 -80
  450. package/src/db/repositories/depositEvent.ts +0 -32
  451. package/src/db/repositories/eth1Data.ts +0 -33
  452. package/src/db/single/index.ts +0 -2
  453. package/src/db/single/preGenesisState.ts +0 -37
  454. package/src/db/single/preGenesisStateLastProcessedBlock.ts +0 -34
  455. package/src/eth1/errors.ts +0 -40
  456. package/src/eth1/eth1DataCache.ts +0 -26
  457. package/src/eth1/eth1DepositDataTracker.ts +0 -410
  458. package/src/eth1/eth1DepositsCache.ts +0 -141
  459. package/src/eth1/index.ts +0 -94
  460. package/src/eth1/interface.ts +0 -87
  461. package/src/eth1/options.ts +0 -28
  462. package/src/eth1/provider/eth1Provider.ts +0 -229
  463. package/src/eth1/provider/utils.ts +0 -136
  464. package/src/eth1/stream.ts +0 -75
  465. package/src/eth1/utils/depositContract.ts +0 -37
  466. package/src/eth1/utils/deposits.ts +0 -70
  467. package/src/eth1/utils/eth1Data.ts +0 -100
  468. package/src/eth1/utils/eth1DepositEvent.ts +0 -12
  469. package/src/eth1/utils/eth1Vote.ts +0 -142
  470. package/src/eth1/utils/groupDepositEventsByBlock.ts +0 -19
  471. package/src/eth1/utils/optimizeNextBlockDiffForGenesis.ts +0 -18
  472. /package/lib/{eth1/provider → execution/engine}/jsonRpcHttpClient.js +0 -0
  473. /package/lib/{eth1/provider → execution/engine}/jwt.d.ts +0 -0
  474. /package/lib/{eth1/provider → execution/engine}/jwt.js +0 -0
  475. /package/src/{eth1/provider → execution/engine}/jwt.ts +0 -0
@@ -418,13 +418,20 @@ export async function importBlock(
418
418
  this.logger.verbose("After importBlock caching postState without SSZ cache", {slot: postState.slot});
419
419
  }
420
420
 
421
+ // Cache shufflings when crossing an epoch boundary
422
+ const parentEpoch = computeEpochAtSlot(parentBlockSlot);
423
+ if (parentEpoch < blockEpoch) {
424
+ this.shufflingCache.processState(postState);
425
+ this.logger.verbose("Processed shuffling for next epoch", {parentEpoch, blockEpoch, slot: blockSlot});
426
+ }
427
+
421
428
  if (blockSlot % SLOTS_PER_EPOCH === 0) {
422
429
  // Cache state to preserve epoch transition work
423
430
  const checkpointState = postState;
424
431
  const cp = getCheckpointFromState(checkpointState);
425
432
  this.regen.addCheckpointState(cp, checkpointState);
426
- // consumers should not mutate or get the transfered cache
427
- this.emitter.emit(ChainEvent.checkpoint, cp, checkpointState.clone(true));
433
+ // consumers should not mutate state ever
434
+ this.emitter.emit(ChainEvent.checkpoint, cp, checkpointState);
428
435
 
429
436
  // Note: in-lined code from previos handler of ChainEvent.checkpoint
430
437
  this.logger.verbose("Checkpoint processed", toCheckpointHex(cp));
@@ -584,7 +591,10 @@ export function addAttestationPostElectra(
584
591
  true
585
592
  );
586
593
  } else {
587
- const committees = epochCtx.getBeaconCommittees(attestation.data.slot, committeeIndices);
594
+ const attSlot = attestation.data.slot;
595
+ const attEpoch = computeEpochAtSlot(attSlot);
596
+ const decisionRoot = epochCtx.getShufflingDecisionRoot(attEpoch);
597
+ const committees = this.shufflingCache.getBeaconCommittees(attEpoch, decisionRoot, attSlot, committeeIndices);
588
598
  const aggregationBools = attestation.aggregationBits.toBoolArray();
589
599
  let offset = 0;
590
600
  for (let i = 0; i < committees.length; i++) {
@@ -75,6 +75,10 @@ export async function verifyBlocksInEpoch(
75
75
  throw new BlockError(block0, {code: BlockErrorCode.PRESTATE_MISSING, error: e as Error});
76
76
  });
77
77
 
78
+ // in forky condition, make sure to populate ShufflingCache with regened state
79
+ // otherwise it may fail to get indexed attestations from shuffling cache later
80
+ this.shufflingCache.processState(preState0);
81
+
78
82
  if (!isStateValidatorsNodesPopulated(preState0)) {
79
83
  this.logger.verbose("verifyBlocksInEpoch preState0 SSZ cache stats", {
80
84
  slot: preState0.slot,
@@ -105,9 +109,11 @@ export async function verifyBlocksInEpoch(
105
109
  // Store indexed attestations for each block to avoid recomputing them during import
106
110
  const indexedAttestationsByBlock: IndexedAttestation[][] = [];
107
111
  for (const [i, block] of blocks.entries()) {
108
- indexedAttestationsByBlock[i] = block.message.body.attestations.map((attestation) =>
109
- preState0.epochCtx.getIndexedAttestation(fork, attestation)
110
- );
112
+ indexedAttestationsByBlock[i] = block.message.body.attestations.map((attestation) => {
113
+ const attEpoch = computeEpochAtSlot(attestation.data.slot);
114
+ const decisionRoot = preState0.epochCtx.getShufflingDecisionRoot(attEpoch);
115
+ return this.shufflingCache.getIndexedAttestation(attEpoch, decisionRoot, fork, attestation);
116
+ });
111
117
  }
112
118
 
113
119
  // batch all I/O operations to reduce overhead
@@ -139,6 +145,7 @@ export async function verifyBlocksInEpoch(
139
145
  // All signatures at once
140
146
  opts.skipVerifyBlockSignatures !== true
141
147
  ? verifyBlocksSignatures(
148
+ this.config,
142
149
  this.index2pubkey,
143
150
  this.bls,
144
151
  this.logger,
@@ -8,7 +8,12 @@ import {
8
8
  ProtoBlock,
9
9
  } from "@lodestar/fork-choice";
10
10
  import {ForkSeq} from "@lodestar/params";
11
- import {CachedBeaconStateAllForks, isExecutionBlockBodyType, isExecutionStateType} from "@lodestar/state-transition";
11
+ import {
12
+ CachedBeaconStateAllForks,
13
+ isExecutionBlockBodyType,
14
+ isExecutionEnabled,
15
+ isExecutionStateType,
16
+ } from "@lodestar/state-transition";
12
17
  import {bellatrix, electra} from "@lodestar/types";
13
18
  import {ErrorAborted, Logger, toRootHex} from "@lodestar/utils";
14
19
  import {ExecutionPayloadStatus, IExecutionEngine} from "../../execution/engine/interface.js";
@@ -145,7 +150,9 @@ export async function verifyBlockExecutionPayload(
145
150
  const block = blockInput.getBlock();
146
151
  /** Not null if execution is enabled */
147
152
  const executionPayloadEnabled =
148
- isExecutionStateType(preState0) && isExecutionBlockBodyType(block.message.body)
153
+ isExecutionStateType(preState0) &&
154
+ isExecutionBlockBodyType(block.message.body) &&
155
+ isExecutionEnabled(preState0, block.message)
149
156
  ? block.message.body.executionPayload
150
157
  : null;
151
158
 
@@ -1,3 +1,4 @@
1
+ import {BeaconConfig} from "@lodestar/config";
1
2
  import {CachedBeaconStateAllForks, Index2PubkeyCache, getBlockSignatureSets} from "@lodestar/state-transition";
2
3
  import {IndexedAttestation, SignedBeaconBlock} from "@lodestar/types";
3
4
  import {Logger} from "@lodestar/utils";
@@ -15,6 +16,7 @@ import {ImportBlockOpts} from "./types.js";
15
16
  * Since all data is known in advance all signatures are verified at once in parallel.
16
17
  */
17
18
  export async function verifyBlocksSignatures(
19
+ config: BeaconConfig,
18
20
  index2pubkey: Index2PubkeyCache,
19
21
  bls: IBlsVerifier,
20
22
  logger: Logger,
@@ -26,6 +28,7 @@ export async function verifyBlocksSignatures(
26
28
  ): Promise<{verifySignaturesTime: number}> {
27
29
  const isValidPromises: Promise<boolean>[] = [];
28
30
  const recvToValLatency = Date.now() / 1000 - (opts.seenTimestampSec ?? Date.now() / 1000);
31
+ const currentSyncCommitteeIndexed = preState0.epochCtx.currentSyncCommitteeIndexed;
29
32
 
30
33
  // Verifies signatures after running state transition, so all SyncCommittee signed roots are known at this point.
31
34
  // We must ensure block.slot <= state.slot before running getAllBlockSignatureSets().
@@ -39,9 +42,16 @@ export async function verifyBlocksSignatures(
39
42
  : //
40
43
  // Verify signatures per block to track which block is invalid
41
44
  bls.verifySignatureSets(
42
- getBlockSignatureSets(index2pubkey, preState0, block, indexedAttestationsByBlock[i], {
43
- skipProposerSignature: opts.validProposerSignature,
44
- })
45
+ getBlockSignatureSets(
46
+ config,
47
+ index2pubkey,
48
+ currentSyncCommitteeIndexed,
49
+ block,
50
+ indexedAttestationsByBlock[i],
51
+ {
52
+ skipProposerSignature: opts.validProposerSignature,
53
+ }
54
+ )
45
55
  );
46
56
 
47
57
  // getBlockSignatureSets() takes 45ms in benchmarks for 2022Q2 mainnet blocks (100 sigs). When syncing a 32 blocks
@@ -59,6 +59,7 @@ export async function verifyBlocksStateTransitionOnly(
59
59
  // if block is trusted don't verify proposer or op signature
60
60
  verifyProposer: !useBlsBatchVerify && !validSignatures && !validProposerSignature,
61
61
  verifySignatures: !useBlsBatchVerify && !validSignatures,
62
+ dontTransferCache: false,
62
63
  },
63
64
  {metrics, validatorMonitor}
64
65
  );
@@ -14,13 +14,14 @@ import {
14
14
  EpochShuffling,
15
15
  Index2PubkeyCache,
16
16
  computeAnchorCheckpoint,
17
+ computeAttestationsRewards,
18
+ computeBlockRewards,
17
19
  computeEndSlotAtEpoch,
18
20
  computeEpochAtSlot,
19
21
  computeStartSlotAtEpoch,
20
- createCachedBeaconState,
22
+ computeSyncCommitteeRewards,
21
23
  getEffectiveBalanceIncrementsZeroInactive,
22
24
  getEffectiveBalancesFromStateBytes,
23
- isCachedBeaconState,
24
25
  processSlots,
25
26
  } from "@lodestar/state-transition";
26
27
  import {
@@ -38,12 +39,12 @@ import {
38
39
  Wei,
39
40
  isBlindedBeaconBlock,
40
41
  phase0,
42
+ rewards,
41
43
  } from "@lodestar/types";
42
44
  import {Logger, fromHex, gweiToWei, isErrorAborted, pruneSetToMax, sleep, toRootHex} from "@lodestar/utils";
43
45
  import {ProcessShutdownCallback} from "@lodestar/validator";
44
46
  import {GENESIS_EPOCH, ZERO_HASH} from "../constants/index.js";
45
47
  import {IBeaconDb} from "../db/index.js";
46
- import {IEth1ForBlockProduction} from "../eth1/index.js";
47
48
  import {BuilderStatus} from "../execution/builder/http.js";
48
49
  import {IExecutionBuilder, IExecutionEngine} from "../execution/index.js";
49
50
  import {Metrics} from "../metrics/index.js";
@@ -51,6 +52,7 @@ import {computeNodeIdFromPrivateKey} from "../network/subnets/interface.js";
51
52
  import {BufferPool} from "../util/bufferPool.js";
52
53
  import {Clock, ClockEvent, IClock} from "../util/clock.js";
53
54
  import {CustodyConfig, getValidatorsCustodyRequirement} from "../util/dataColumns.js";
55
+ import {callInNextEventLoop} from "../util/eventLoop.js";
54
56
  import {ensureDir, writeIfNotExist} from "../util/file.js";
55
57
  import {isOptimisticBlock} from "../util/forkChoice.js";
56
58
  import {SerializedCache} from "../util/serializedCache.js";
@@ -80,9 +82,6 @@ import {AssembledBlockType, BlockType, ProduceResult} from "./produceBlock/index
80
82
  import {BlockAttributes, produceBlockBody, produceCommonBlockBody} from "./produceBlock/produceBlockBody.js";
81
83
  import {QueuedStateRegenerator, RegenCaller} from "./regen/index.js";
82
84
  import {ReprocessController} from "./reprocess.js";
83
- import {AttestationsRewards, computeAttestationsRewards} from "./rewards/attestationsRewards.js";
84
- import {BlockRewards, computeBlockRewards} from "./rewards/blockRewards.js";
85
- import {SyncCommitteeRewards, computeSyncCommitteeRewards} from "./rewards/syncCommitteeRewards.js";
86
85
  import {
87
86
  SeenAggregators,
88
87
  SeenAttesters,
@@ -117,7 +116,6 @@ const DEFAULT_MAX_CACHED_PRODUCED_RESULTS = 4;
117
116
  export class BeaconChain implements IBeaconChain {
118
117
  readonly genesisTime: UintNum64;
119
118
  readonly genesisValidatorsRoot: Root;
120
- readonly eth1: IEth1ForBlockProduction;
121
119
  readonly executionEngine: IExecutionEngine;
122
120
  readonly executionBuilder?: IExecutionBuilder;
123
121
  // Expose config for convenience in modularized functions
@@ -144,7 +142,7 @@ export class BeaconChain implements IBeaconChain {
144
142
  readonly aggregatedAttestationPool: AggregatedAttestationPool;
145
143
  readonly syncCommitteeMessagePool: SyncCommitteeMessagePool;
146
144
  readonly syncContributionAndProofPool;
147
- readonly opPool = new OpPool();
145
+ readonly opPool: OpPool;
148
146
 
149
147
  // Gossip seen cache
150
148
  readonly seenAttesters = new SeenAttesters();
@@ -206,6 +204,8 @@ export class BeaconChain implements IBeaconChain {
206
204
  {
207
205
  privateKey,
208
206
  config,
207
+ pubkey2index,
208
+ index2pubkey,
209
209
  db,
210
210
  dbName,
211
211
  dataDir,
@@ -216,12 +216,13 @@ export class BeaconChain implements IBeaconChain {
216
216
  validatorMonitor,
217
217
  anchorState,
218
218
  isAnchorStateFinalized,
219
- eth1,
220
219
  executionEngine,
221
220
  executionBuilder,
222
221
  }: {
223
222
  privateKey: PrivateKey;
224
223
  config: BeaconConfig;
224
+ pubkey2index: PubkeyIndexMap;
225
+ index2pubkey: Index2PubkeyCache;
225
226
  db: IBeaconDb;
226
227
  dbName: string;
227
228
  dataDir: string;
@@ -231,9 +232,8 @@ export class BeaconChain implements IBeaconChain {
231
232
  clock?: IClock;
232
233
  metrics: Metrics | null;
233
234
  validatorMonitor: ValidatorMonitor | null;
234
- anchorState: BeaconStateAllForks;
235
+ anchorState: CachedBeaconStateAllForks;
235
236
  isAnchorStateFinalized: boolean;
236
- eth1: IEth1ForBlockProduction;
237
237
  executionEngine: IExecutionEngine;
238
238
  executionBuilder?: IExecutionBuilder;
239
239
  }
@@ -248,7 +248,6 @@ export class BeaconChain implements IBeaconChain {
248
248
  this.genesisTime = anchorState.genesisTime;
249
249
  this.anchorStateLatestBlockSlot = anchorState.latestBlockHeader.slot;
250
250
  this.genesisValidatorsRoot = anchorState.genesisValidatorsRoot;
251
- this.eth1 = eth1;
252
251
  this.executionEngine = executionEngine;
253
252
  this.executionBuilder = executionBuilder;
254
253
  const signal = this.abortController.signal;
@@ -265,6 +264,7 @@ export class BeaconChain implements IBeaconChain {
265
264
  this.aggregatedAttestationPool = new AggregatedAttestationPool(this.config, metrics);
266
265
  this.syncCommitteeMessagePool = new SyncCommitteeMessagePool(config, clock, this.opts?.preaggregateSlotDistance);
267
266
  this.syncContributionAndProofPool = new SyncContributionAndProofPool(config, clock, metrics, logger);
267
+ this.opPool = new OpPool(config);
268
268
 
269
269
  this.seenAggregatedAttestations = new SeenAggregatedAttestations(metrics);
270
270
  this.seenContributionAndProof = new SeenContributionAndProof(metrics);
@@ -291,39 +291,26 @@ export class BeaconChain implements IBeaconChain {
291
291
  logger,
292
292
  });
293
293
 
294
- // Restore state caches
295
- // anchorState may already by a CachedBeaconState. If so, don't create the cache again, since deserializing all
296
- // pubkeys takes ~30 seconds for 350k keys (mainnet 2022Q2).
297
- // When the BeaconStateCache is created in eth1 genesis builder it may be incorrect. Until we can ensure that
298
- // it's safe to re-use _ANY_ BeaconStateCache, this option is disabled by default and only used in tests.
299
- const cachedState =
300
- isCachedBeaconState(anchorState) && opts.skipCreateStateCacheIfAvailable
301
- ? anchorState
302
- : createCachedBeaconState(anchorState, {
303
- config,
304
- pubkey2index: new PubkeyIndexMap(),
305
- index2pubkey: [],
306
- });
307
- this._earliestAvailableSlot = cachedState.slot;
308
-
309
- this.shufflingCache = cachedState.epochCtx.shufflingCache = new ShufflingCache(metrics, logger, this.opts, [
294
+ this._earliestAvailableSlot = anchorState.slot;
295
+
296
+ this.shufflingCache = new ShufflingCache(metrics, logger, this.opts, [
310
297
  {
311
- shuffling: cachedState.epochCtx.previousShuffling,
312
- decisionRoot: cachedState.epochCtx.previousDecisionRoot,
298
+ shuffling: anchorState.epochCtx.previousShuffling,
299
+ decisionRoot: anchorState.epochCtx.previousDecisionRoot,
313
300
  },
314
301
  {
315
- shuffling: cachedState.epochCtx.currentShuffling,
316
- decisionRoot: cachedState.epochCtx.currentDecisionRoot,
302
+ shuffling: anchorState.epochCtx.currentShuffling,
303
+ decisionRoot: anchorState.epochCtx.currentDecisionRoot,
317
304
  },
318
305
  {
319
- shuffling: cachedState.epochCtx.nextShuffling,
320
- decisionRoot: cachedState.epochCtx.nextDecisionRoot,
306
+ shuffling: anchorState.epochCtx.nextShuffling,
307
+ decisionRoot: anchorState.epochCtx.nextDecisionRoot,
321
308
  },
322
309
  ]);
323
310
 
324
- // Persist single global instance of state caches
325
- this.pubkey2index = cachedState.epochCtx.pubkey2index;
326
- this.index2pubkey = cachedState.epochCtx.index2pubkey;
311
+ // Global cache of validators pubkey/index mapping
312
+ this.pubkey2index = pubkey2index;
313
+ this.index2pubkey = index2pubkey;
327
314
 
328
315
  const fileDataStore = opts.nHistoricalStatesFileDataStore ?? true;
329
316
  const blockStateCache = this.opts.nHistoricalStates
@@ -339,6 +326,7 @@ export class BeaconChain implements IBeaconChain {
339
326
  this.cpStateDatastore = fileDataStore ? new FileCPStateDatastore(dataDir) : new DbCPStateDatastore(this.db);
340
327
  checkpointStateCache = new PersistentCheckpointStateCache(
341
328
  {
329
+ config,
342
330
  metrics,
343
331
  logger,
344
332
  clock,
@@ -353,15 +341,15 @@ export class BeaconChain implements IBeaconChain {
353
341
  }
354
342
 
355
343
  const {checkpoint} = computeAnchorCheckpoint(config, anchorState);
356
- blockStateCache.add(cachedState);
357
- blockStateCache.setHeadState(cachedState);
358
- checkpointStateCache.add(checkpoint, cachedState);
344
+ blockStateCache.add(anchorState);
345
+ blockStateCache.setHeadState(anchorState);
346
+ checkpointStateCache.add(checkpoint, anchorState);
359
347
 
360
348
  const forkChoice = initializeForkChoice(
361
349
  config,
362
350
  emitter,
363
351
  clock.currentSlot,
364
- cachedState,
352
+ anchorState,
365
353
  isAnchorStateFinalized,
366
354
  opts,
367
355
  this.justifiedBalancesGetter.bind(this),
@@ -417,15 +405,6 @@ export class BeaconChain implements IBeaconChain {
417
405
  signal
418
406
  );
419
407
 
420
- // Stop polling eth1 data if anchor state is in Electra AND deposit_requests_start_index is reached
421
- const anchorStateFork = this.config.getForkName(anchorState.slot);
422
- if (isForkPostElectra(anchorStateFork)) {
423
- const {eth1DepositIndex, depositRequestsStartIndex} = anchorState as BeaconStateElectra;
424
- if (eth1DepositIndex === Number(depositRequestsStartIndex)) {
425
- this.eth1.stopPollingEth1Data();
426
- }
427
- }
428
-
429
408
  // always run PrepareNextSlotScheduler except for fork_choice spec tests
430
409
  if (!opts?.disablePrepareNextSlot) {
431
410
  new PrepareNextSlotScheduler(this, this.config, metrics, this.logger, signal);
@@ -440,6 +419,7 @@ export class BeaconChain implements IBeaconChain {
440
419
  clock.addListener(ClockEvent.epoch, this.onClockEpoch.bind(this));
441
420
  emitter.addListener(ChainEvent.forkChoiceFinalized, this.onForkChoiceFinalized.bind(this));
442
421
  emitter.addListener(ChainEvent.forkChoiceJustified, this.onForkChoiceJustified.bind(this));
422
+ emitter.addListener(ChainEvent.checkpoint, this.onCheckpoint.bind(this));
443
423
  }
444
424
 
445
425
  async init(): Promise<void> {
@@ -527,7 +507,7 @@ export class BeaconChain implements IBeaconChain {
527
507
  async getStateBySlot(
528
508
  slot: Slot,
529
509
  opts?: StateGetOpts
530
- ): Promise<{state: BeaconStateAllForks; executionOptimistic: boolean; finalized: boolean} | null> {
510
+ ): Promise<{state: CachedBeaconStateAllForks; executionOptimistic: boolean; finalized: boolean} | null> {
531
511
  const finalizedBlock = this.forkChoice.getFinalizedBlock();
532
512
 
533
513
  if (slot < finalizedBlock.slot) {
@@ -582,7 +562,7 @@ export class BeaconChain implements IBeaconChain {
582
562
  async getStateByStateRoot(
583
563
  stateRoot: RootHex,
584
564
  opts?: StateGetOpts
585
- ): Promise<{state: BeaconStateAllForks; executionOptimistic: boolean; finalized: boolean} | null> {
565
+ ): Promise<{state: CachedBeaconStateAllForks | Uint8Array; executionOptimistic: boolean; finalized: boolean} | null> {
586
566
  if (opts?.allowRegen) {
587
567
  const state = await this.regen.getState(stateRoot, RegenCaller.restApi);
588
568
  const block = this.forkChoice.getBlock(state.latestBlockHeader.hashTreeRoot());
@@ -610,7 +590,8 @@ export class BeaconChain implements IBeaconChain {
610
590
  };
611
591
  }
612
592
 
613
- const data = await this.db.stateArchive.getByRoot(fromHex(stateRoot));
593
+ // this is mostly useful for a node with `--chain.archiveStateEpochFrequency 1`
594
+ const data = await this.db.stateArchive.getBinaryByRoot(fromHex(stateRoot));
614
595
  return data && {state: data, executionOptimistic: false, finalized: true};
615
596
  }
616
597
 
@@ -1003,8 +984,8 @@ export class BeaconChain implements IBeaconChain {
1003
984
  this.metrics?.gossipAttestation.useHeadBlockState.inc({caller: regenCaller});
1004
985
  state = await this.regen.getState(attHeadBlock.stateRoot, regenCaller);
1005
986
  }
1006
-
1007
- // should always be the current epoch of the active context so no need to await a result from the ShufflingCache
987
+ // resolve the promise to unblock other calls of the same epoch and dependent root
988
+ this.shufflingCache.processState(state);
1008
989
  return state.epochCtx.getShufflingAtEpoch(attEpoch);
1009
990
  }
1010
991
 
@@ -1188,6 +1169,13 @@ export class BeaconChain implements IBeaconChain {
1188
1169
  this.logger.verbose("Fork choice justified", {epoch: cp.epoch, root: cp.rootHex});
1189
1170
  }
1190
1171
 
1172
+ private onCheckpoint(this: BeaconChain, _checkpoint: phase0.Checkpoint, state: CachedBeaconStateAllForks): void {
1173
+ // Defer to not block other checkpoint event handlers, which can cause lightclient update delays
1174
+ callInNextEventLoop(() => {
1175
+ this.shufflingCache.processState(state);
1176
+ });
1177
+ }
1178
+
1191
1179
  private async onForkChoiceFinalized(this: BeaconChain, cp: CheckpointWithHex): Promise<void> {
1192
1180
  this.logger.verbose("Fork choice finalized", {epoch: cp.epoch, root: cp.rootHex});
1193
1181
  this.seenBlockProposers.prune(computeStartSlotAtEpoch(cp.epoch));
@@ -1309,7 +1297,7 @@ export class BeaconChain implements IBeaconChain {
1309
1297
  }
1310
1298
  }
1311
1299
 
1312
- async getBlockRewards(block: BeaconBlock | BlindedBeaconBlock): Promise<BlockRewards> {
1300
+ async getBlockRewards(block: BeaconBlock | BlindedBeaconBlock): Promise<rewards.BlockRewards> {
1313
1301
  let preState = this.regen.getPreStateSync(block);
1314
1302
 
1315
1303
  if (preState === null) {
@@ -1318,15 +1306,15 @@ export class BeaconChain implements IBeaconChain {
1318
1306
 
1319
1307
  preState = processSlots(preState, block.slot); // Dial preState's slot to block.slot
1320
1308
 
1321
- const postState = this.regen.getStateSync(toRootHex(block.stateRoot)) ?? undefined;
1309
+ const proposerRewards = this.regen.getStateSync(toRootHex(block.stateRoot))?.proposerRewards ?? undefined;
1322
1310
 
1323
- return computeBlockRewards(block, preState.clone(), postState?.clone());
1311
+ return computeBlockRewards(this.config, block, preState, proposerRewards);
1324
1312
  }
1325
1313
 
1326
1314
  async getAttestationsRewards(
1327
1315
  epoch: Epoch,
1328
1316
  validatorIds?: (ValidatorIndex | string)[]
1329
- ): Promise<{rewards: AttestationsRewards; executionOptimistic: boolean; finalized: boolean}> {
1317
+ ): Promise<{rewards: rewards.AttestationsRewards; executionOptimistic: boolean; finalized: boolean}> {
1330
1318
  // We use end slot of (epoch + 1) to ensure we have seen all attestations. On-time or late. Any late attestation beyond this slot is not considered
1331
1319
  const slot = computeEndSlotAtEpoch(epoch + 1);
1332
1320
  const stateResult = await this.getStateBySlot(slot, {allowRegen: false}); // No regen if state not in cache
@@ -1344,7 +1332,7 @@ export class BeaconChain implements IBeaconChain {
1344
1332
  throw Error(`State is not in cache for slot ${slot}`);
1345
1333
  }
1346
1334
 
1347
- const rewards = await computeAttestationsRewards(this.pubkey2index, cachedState, validatorIds);
1335
+ const rewards = await computeAttestationsRewards(this.config, this.pubkey2index, cachedState, validatorIds);
1348
1336
 
1349
1337
  return {rewards, executionOptimistic, finalized};
1350
1338
  }
@@ -1352,7 +1340,7 @@ export class BeaconChain implements IBeaconChain {
1352
1340
  async getSyncCommitteeRewards(
1353
1341
  block: BeaconBlock | BlindedBeaconBlock,
1354
1342
  validatorIds?: (ValidatorIndex | string)[]
1355
- ): Promise<SyncCommitteeRewards> {
1343
+ ): Promise<rewards.SyncCommitteeRewards> {
1356
1344
  let preState = this.regen.getPreStateSync(block);
1357
1345
 
1358
1346
  if (preState === null) {
@@ -1361,6 +1349,6 @@ export class BeaconChain implements IBeaconChain {
1361
1349
 
1362
1350
  preState = processSlots(preState, block.slot); // Dial preState's slot to block.slot
1363
1351
 
1364
- return computeSyncCommitteeRewards(this.index2pubkey, block, preState.clone(), validatorIds);
1352
+ return computeSyncCommitteeRewards(this.config, this.index2pubkey, block, preState, validatorIds);
1365
1353
  }
1366
1354
  }
@@ -18,6 +18,7 @@ import {
18
18
  getBlockRootAtSlot,
19
19
  getEffectiveBalanceIncrementsZeroInactive,
20
20
  isExecutionStateType,
21
+ isMergeTransitionComplete,
21
22
  } from "@lodestar/state-transition";
22
23
  import {Slot, ssz} from "@lodestar/types";
23
24
  import {Logger, toRootHex} from "@lodestar/utils";
@@ -134,7 +135,7 @@ export function initializeForkChoiceFromFinalizedState(
134
135
  unrealizedFinalizedEpoch: finalizedCheckpoint.epoch,
135
136
  unrealizedFinalizedRoot: toRootHex(finalizedCheckpoint.root),
136
137
 
137
- ...(isExecutionStateType(state)
138
+ ...(isExecutionStateType(state) && isMergeTransitionComplete(state)
138
139
  ? {
139
140
  executionPayloadBlockHash: toRootHex(state.latestExecutionPayloadHeader.blockHash),
140
141
  executionPayloadNumber: state.latestExecutionPayloadHeader.blockNumber,
@@ -215,7 +216,7 @@ export function initializeForkChoiceFromUnfinalizedState(
215
216
  unrealizedFinalizedEpoch: finalizedCheckpoint.epoch,
216
217
  unrealizedFinalizedRoot: toRootHex(finalizedCheckpoint.root),
217
218
 
218
- ...(isExecutionStateType(unfinalizedState)
219
+ ...(isExecutionStateType(unfinalizedState) && isMergeTransitionComplete(unfinalizedState)
219
220
  ? {
220
221
  executionPayloadBlockHash: toRootHex(unfinalizedState.latestExecutionPayloadHeader.blockHash),
221
222
  executionPayloadNumber: unfinalizedState.latestExecutionPayloadHeader.blockNumber,
@@ -1,37 +1,12 @@
1
1
  import {ChainForkConfig} from "@lodestar/config";
2
2
  import {ZERO_HASH} from "@lodestar/params";
3
- import {
4
- BeaconStateAllForks,
5
- CachedBeaconStateAllForks,
6
- computeEpochAtSlot,
7
- computeStartSlotAtEpoch,
8
- } from "@lodestar/state-transition";
3
+ import {BeaconStateAllForks, computeEpochAtSlot, computeStartSlotAtEpoch} from "@lodestar/state-transition";
9
4
  import {SignedBeaconBlock, ssz} from "@lodestar/types";
10
5
  import {Logger, toHex, toRootHex} from "@lodestar/utils";
11
6
  import {GENESIS_SLOT} from "../constants/index.js";
12
7
  import {IBeaconDb} from "../db/index.js";
13
- import {Eth1Provider} from "../eth1/index.js";
14
- import {Eth1Options} from "../eth1/options.js";
15
8
  import {Metrics} from "../metrics/index.js";
16
- import {GenesisBuilder} from "./genesis/genesis.js";
17
- import {GenesisResult} from "./genesis/interface.js";
18
-
19
- export async function persistGenesisResult(
20
- db: IBeaconDb,
21
- genesisResult: GenesisResult,
22
- genesisBlock: SignedBeaconBlock
23
- ): Promise<void> {
24
- await Promise.all([
25
- db.stateArchive.add(genesisResult.state),
26
- db.blockArchive.add(genesisBlock),
27
- db.depositDataRoot.putList(genesisResult.depositTree.getAllReadonlyValues()),
28
- db.eth1Data.put(genesisResult.block.timestamp, {
29
- ...genesisResult.block,
30
- depositCount: genesisResult.depositTree.length,
31
- depositRoot: genesisResult.depositTree.hashTreeRoot(),
32
- }),
33
- ]);
34
- }
9
+ import {getStateTypeFromBytes} from "../util/multifork.js";
35
10
 
36
11
  export async function persistAnchorState(
37
12
  config: ChainForkConfig,
@@ -75,88 +50,19 @@ export function createGenesisBlock(config: ChainForkConfig, genesisState: Beacon
75
50
  return genesisBlock;
76
51
  }
77
52
 
78
- /**
79
- * Initialize and persist a genesis state and related data
80
- */
81
- export async function initStateFromEth1({
82
- config,
83
- db,
84
- logger,
85
- opts,
86
- signal,
87
- }: {
88
- config: ChainForkConfig;
89
- db: IBeaconDb;
90
- logger: Logger;
91
- opts: Eth1Options;
92
- signal: AbortSignal;
93
- }): Promise<CachedBeaconStateAllForks> {
94
- logger.info("Listening to eth1 for genesis state");
95
-
96
- const statePreGenesis = await db.preGenesisState.get();
97
- const depositTree = await db.depositDataRoot.getDepositRootTree();
98
- const lastProcessedBlockNumber = await db.preGenesisStateLastProcessedBlock.get();
99
-
100
- const builder = new GenesisBuilder({
101
- config,
102
- eth1Provider: new Eth1Provider(config, {...opts, logger}, signal),
103
- logger,
104
- signal,
105
- pendingStatus:
106
- statePreGenesis && depositTree !== undefined && lastProcessedBlockNumber != null
107
- ? {state: statePreGenesis, depositTree, lastProcessedBlockNumber}
108
- : undefined,
109
- });
110
-
111
- try {
112
- const genesisResult = await builder.waitForGenesis();
113
-
114
- // Note: .hashTreeRoot() automatically commits()
115
- const genesisBlock = createGenesisBlock(config, genesisResult.state);
116
- const types = config.getForkTypes(GENESIS_SLOT);
117
- const stateRoot = genesisResult.state.hashTreeRoot();
118
- const blockRoot = types.BeaconBlock.hashTreeRoot(genesisBlock.message);
119
-
120
- logger.info("Initializing genesis state", {
121
- stateRoot: toRootHex(stateRoot),
122
- blockRoot: toRootHex(blockRoot),
123
- validatorCount: genesisResult.state.validators.length,
124
- });
125
-
126
- await persistGenesisResult(db, genesisResult, genesisBlock);
127
-
128
- logger.verbose("Clearing pending genesis state if any");
129
- await db.preGenesisState.delete();
130
- await db.preGenesisStateLastProcessedBlock.delete();
131
-
132
- return genesisResult.state;
133
- } catch (e) {
134
- if (builder.lastProcessedBlockNumber != null) {
135
- logger.info("Persisting genesis state", {block: builder.lastProcessedBlockNumber});
136
-
137
- // Commit changed before serializing
138
- builder.state.commit();
139
-
140
- await db.preGenesisState.put(builder.state);
141
- await db.depositDataRoot.putList(builder.depositTree.getAllReadonlyValues());
142
- await db.preGenesisStateLastProcessedBlock.put(builder.lastProcessedBlockNumber);
143
- }
144
- throw e;
145
- }
146
- }
147
-
148
53
  /**
149
54
  * Restore the latest beacon state from db
150
55
  */
151
56
  export async function initStateFromDb(
152
- _config: ChainForkConfig,
57
+ config: ChainForkConfig,
153
58
  db: IBeaconDb,
154
59
  logger: Logger
155
60
  ): Promise<BeaconStateAllForks> {
156
- const state = await db.stateArchive.lastValue();
157
- if (!state) {
61
+ const stateBytes = await db.stateArchive.lastBinary();
62
+ if (stateBytes == null) {
158
63
  throw new Error("No state exists in database");
159
64
  }
65
+ const state = getStateTypeFromBytes(config, stateBytes).deserializeToViewDU(stateBytes);
160
66
 
161
67
  logger.info("Initializing beacon state from db", {
162
68
  slot: state.slot,