@lodestar/beacon-node 1.39.1 → 1.40.0-dev.059f489b0f

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 (509) hide show
  1. package/lib/api/impl/beacon/blocks/index.d.ts.map +1 -1
  2. package/lib/api/impl/beacon/blocks/index.js +23 -27
  3. package/lib/api/impl/beacon/blocks/index.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/config/constants.d.ts +3 -0
  9. package/lib/api/impl/config/constants.d.ts.map +1 -1
  10. package/lib/api/impl/config/constants.js +5 -1
  11. package/lib/api/impl/config/constants.js.map +1 -1
  12. package/lib/api/impl/debug/index.d.ts +1 -1
  13. package/lib/api/impl/debug/index.d.ts.map +1 -1
  14. package/lib/api/impl/debug/index.js +3 -6
  15. package/lib/api/impl/debug/index.js.map +1 -1
  16. package/lib/api/impl/lodestar/index.d.ts.map +1 -1
  17. package/lib/api/impl/lodestar/index.js +30 -3
  18. package/lib/api/impl/lodestar/index.js.map +1 -1
  19. package/lib/api/impl/proof/index.d.ts.map +1 -1
  20. package/lib/api/impl/proof/index.js +1 -2
  21. package/lib/api/impl/proof/index.js.map +1 -1
  22. package/lib/api/impl/validator/index.d.ts.map +1 -1
  23. package/lib/api/impl/validator/index.js +10 -11
  24. package/lib/api/impl/validator/index.js.map +1 -1
  25. package/lib/api/rest/base.d.ts.map +1 -1
  26. package/lib/api/rest/base.js +2 -2
  27. package/lib/api/rest/base.js.map +1 -1
  28. package/lib/chain/ColumnReconstructionTracker.d.ts +2 -0
  29. package/lib/chain/ColumnReconstructionTracker.d.ts.map +1 -1
  30. package/lib/chain/ColumnReconstructionTracker.js +7 -3
  31. package/lib/chain/ColumnReconstructionTracker.js.map +1 -1
  32. package/lib/chain/archiveStore/historicalState/getHistoricalState.d.ts.map +1 -1
  33. package/lib/chain/archiveStore/historicalState/getHistoricalState.js +7 -4
  34. package/lib/chain/archiveStore/historicalState/getHistoricalState.js.map +1 -1
  35. package/lib/chain/archiveStore/utils/archiveBlocks.d.ts.map +1 -1
  36. package/lib/chain/archiveStore/utils/archiveBlocks.js +23 -14
  37. package/lib/chain/archiveStore/utils/archiveBlocks.js.map +1 -1
  38. package/lib/chain/blocks/blockInput/blockInput.d.ts +30 -0
  39. package/lib/chain/blocks/blockInput/blockInput.d.ts.map +1 -1
  40. package/lib/chain/blocks/blockInput/blockInput.js +44 -3
  41. package/lib/chain/blocks/blockInput/blockInput.js.map +1 -1
  42. package/lib/chain/blocks/importBlock.d.ts.map +1 -1
  43. package/lib/chain/blocks/importBlock.js +15 -10
  44. package/lib/chain/blocks/importBlock.js.map +1 -1
  45. package/lib/chain/blocks/index.d.ts.map +1 -1
  46. package/lib/chain/blocks/index.js +0 -14
  47. package/lib/chain/blocks/index.js.map +1 -1
  48. package/lib/chain/blocks/types.d.ts +0 -2
  49. package/lib/chain/blocks/types.d.ts.map +1 -1
  50. package/lib/chain/blocks/verifyBlock.d.ts.map +1 -1
  51. package/lib/chain/blocks/verifyBlock.js +9 -9
  52. package/lib/chain/blocks/verifyBlock.js.map +1 -1
  53. package/lib/chain/blocks/verifyBlocksSignatures.d.ts +2 -2
  54. package/lib/chain/blocks/verifyBlocksSignatures.d.ts.map +1 -1
  55. package/lib/chain/blocks/verifyBlocksSignatures.js +2 -2
  56. package/lib/chain/blocks/verifyBlocksSignatures.js.map +1 -1
  57. package/lib/chain/blocks/verifyBlocksStateTransitionOnly.d.ts.map +1 -1
  58. package/lib/chain/blocks/verifyBlocksStateTransitionOnly.js +2 -2
  59. package/lib/chain/blocks/verifyBlocksStateTransitionOnly.js.map +1 -1
  60. package/lib/chain/blocks/writeBlockInputToDb.d.ts +1 -4
  61. package/lib/chain/blocks/writeBlockInputToDb.d.ts.map +1 -1
  62. package/lib/chain/blocks/writeBlockInputToDb.js +28 -28
  63. package/lib/chain/blocks/writeBlockInputToDb.js.map +1 -1
  64. package/lib/chain/bls/multithread/index.d.ts +3 -1
  65. package/lib/chain/bls/multithread/index.d.ts.map +1 -1
  66. package/lib/chain/bls/multithread/index.js +5 -3
  67. package/lib/chain/bls/multithread/index.js.map +1 -1
  68. package/lib/chain/bls/multithread/jobItem.d.ts +2 -2
  69. package/lib/chain/bls/multithread/jobItem.d.ts.map +1 -1
  70. package/lib/chain/bls/multithread/jobItem.js +2 -2
  71. package/lib/chain/bls/multithread/jobItem.js.map +1 -1
  72. package/lib/chain/bls/singleThread.d.ts +4 -2
  73. package/lib/chain/bls/singleThread.d.ts.map +1 -1
  74. package/lib/chain/bls/singleThread.js +4 -2
  75. package/lib/chain/bls/singleThread.js.map +1 -1
  76. package/lib/chain/bls/utils.d.ts +2 -2
  77. package/lib/chain/bls/utils.d.ts.map +1 -1
  78. package/lib/chain/bls/utils.js +9 -6
  79. package/lib/chain/bls/utils.js.map +1 -1
  80. package/lib/chain/chain.d.ts +25 -7
  81. package/lib/chain/chain.d.ts.map +1 -1
  82. package/lib/chain/chain.js +213 -50
  83. package/lib/chain/chain.js.map +1 -1
  84. package/lib/chain/errors/attestationError.d.ts +14 -1
  85. package/lib/chain/errors/attestationError.d.ts.map +1 -1
  86. package/lib/chain/errors/attestationError.js +8 -0
  87. package/lib/chain/errors/attestationError.js.map +1 -1
  88. package/lib/chain/errors/executionPayloadBid.d.ts +48 -0
  89. package/lib/chain/errors/executionPayloadBid.d.ts.map +1 -0
  90. package/lib/chain/errors/executionPayloadBid.js +15 -0
  91. package/lib/chain/errors/executionPayloadBid.js.map +1 -0
  92. package/lib/chain/errors/executionPayloadEnvelope.d.ts +48 -0
  93. package/lib/chain/errors/executionPayloadEnvelope.d.ts.map +1 -0
  94. package/lib/chain/errors/executionPayloadEnvelope.js +16 -0
  95. package/lib/chain/errors/executionPayloadEnvelope.js.map +1 -0
  96. package/lib/chain/errors/index.d.ts +3 -0
  97. package/lib/chain/errors/index.d.ts.map +1 -1
  98. package/lib/chain/errors/index.js +3 -0
  99. package/lib/chain/errors/index.js.map +1 -1
  100. package/lib/chain/errors/payloadAttestation.d.ts +34 -0
  101. package/lib/chain/errors/payloadAttestation.d.ts.map +1 -0
  102. package/lib/chain/errors/payloadAttestation.js +13 -0
  103. package/lib/chain/errors/payloadAttestation.js.map +1 -0
  104. package/lib/chain/forkChoice/index.d.ts.map +1 -1
  105. package/lib/chain/forkChoice/index.js +18 -0
  106. package/lib/chain/forkChoice/index.js.map +1 -1
  107. package/lib/chain/initState.d.ts +1 -1
  108. package/lib/chain/initState.d.ts.map +1 -1
  109. package/lib/chain/initState.js +7 -5
  110. package/lib/chain/initState.js.map +1 -1
  111. package/lib/chain/interface.d.ts +23 -5
  112. package/lib/chain/interface.d.ts.map +1 -1
  113. package/lib/chain/interface.js.map +1 -1
  114. package/lib/chain/lightClient/index.d.ts.map +1 -1
  115. package/lib/chain/lightClient/index.js +1 -2
  116. package/lib/chain/lightClient/index.js.map +1 -1
  117. package/lib/chain/lightClient/proofs.d.ts.map +1 -1
  118. package/lib/chain/lightClient/proofs.js +0 -2
  119. package/lib/chain/lightClient/proofs.js.map +1 -1
  120. package/lib/chain/opPools/aggregatedAttestationPool.d.ts +5 -9
  121. package/lib/chain/opPools/aggregatedAttestationPool.d.ts.map +1 -1
  122. package/lib/chain/opPools/aggregatedAttestationPool.js +12 -141
  123. package/lib/chain/opPools/aggregatedAttestationPool.js.map +1 -1
  124. package/lib/chain/opPools/executionPayloadBidPool.d.ts +21 -0
  125. package/lib/chain/opPools/executionPayloadBidPool.d.ts.map +1 -0
  126. package/lib/chain/opPools/executionPayloadBidPool.js +57 -0
  127. package/lib/chain/opPools/executionPayloadBidPool.js.map +1 -0
  128. package/lib/chain/opPools/index.d.ts +2 -0
  129. package/lib/chain/opPools/index.d.ts.map +1 -1
  130. package/lib/chain/opPools/index.js +2 -0
  131. package/lib/chain/opPools/index.js.map +1 -1
  132. package/lib/chain/opPools/opPool.js +5 -8
  133. package/lib/chain/opPools/opPool.js.map +1 -1
  134. package/lib/chain/opPools/payloadAttestationPool.d.ts +24 -0
  135. package/lib/chain/opPools/payloadAttestationPool.d.ts.map +1 -0
  136. package/lib/chain/opPools/payloadAttestationPool.js +109 -0
  137. package/lib/chain/opPools/payloadAttestationPool.js.map +1 -0
  138. package/lib/chain/options.d.ts +0 -1
  139. package/lib/chain/options.d.ts.map +1 -1
  140. package/lib/chain/options.js +0 -1
  141. package/lib/chain/options.js.map +1 -1
  142. package/lib/chain/prepareNextSlot.d.ts.map +1 -1
  143. package/lib/chain/prepareNextSlot.js +9 -10
  144. package/lib/chain/prepareNextSlot.js.map +1 -1
  145. package/lib/chain/produceBlock/produceBlockBody.d.ts +3 -2
  146. package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
  147. package/lib/chain/produceBlock/produceBlockBody.js +6 -4
  148. package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
  149. package/lib/chain/regen/interface.d.ts +5 -14
  150. package/lib/chain/regen/interface.d.ts.map +1 -1
  151. package/lib/chain/regen/interface.js +1 -1
  152. package/lib/chain/regen/interface.js.map +1 -1
  153. package/lib/chain/regen/queued.d.ts +6 -10
  154. package/lib/chain/regen/queued.d.ts.map +1 -1
  155. package/lib/chain/regen/queued.js +16 -40
  156. package/lib/chain/regen/queued.js.map +1 -1
  157. package/lib/chain/regen/regen.d.ts +6 -8
  158. package/lib/chain/regen/regen.d.ts.map +1 -1
  159. package/lib/chain/regen/regen.js +20 -34
  160. package/lib/chain/regen/regen.js.map +1 -1
  161. package/lib/chain/seenCache/index.d.ts +3 -1
  162. package/lib/chain/seenCache/index.d.ts.map +1 -1
  163. package/lib/chain/seenCache/index.js +3 -1
  164. package/lib/chain/seenCache/index.js.map +1 -1
  165. package/lib/chain/seenCache/seenAttesters.d.ts +5 -0
  166. package/lib/chain/seenCache/seenAttesters.d.ts.map +1 -1
  167. package/lib/chain/seenCache/seenAttesters.js +5 -0
  168. package/lib/chain/seenCache/seenAttesters.js.map +1 -1
  169. package/lib/chain/seenCache/seenExecutionPayloadBids.d.ts +12 -0
  170. package/lib/chain/seenCache/seenExecutionPayloadBids.d.ts.map +1 -0
  171. package/lib/chain/seenCache/seenExecutionPayloadBids.js +30 -0
  172. package/lib/chain/seenCache/seenExecutionPayloadBids.js.map +1 -0
  173. package/lib/chain/seenCache/seenExecutionPayloadEnvelope.d.ts +15 -0
  174. package/lib/chain/seenCache/seenExecutionPayloadEnvelope.d.ts.map +1 -0
  175. package/lib/chain/seenCache/seenExecutionPayloadEnvelope.js +28 -0
  176. package/lib/chain/seenCache/seenExecutionPayloadEnvelope.js.map +1 -0
  177. package/lib/chain/seenCache/seenGossipBlockInput.d.ts.map +1 -1
  178. package/lib/chain/seenCache/seenGossipBlockInput.js +3 -3
  179. package/lib/chain/seenCache/seenGossipBlockInput.js.map +1 -1
  180. package/lib/chain/shufflingCache.d.ts +16 -11
  181. package/lib/chain/shufflingCache.d.ts.map +1 -1
  182. package/lib/chain/shufflingCache.js +47 -41
  183. package/lib/chain/shufflingCache.js.map +1 -1
  184. package/lib/chain/stateCache/fifoBlockStateCache.d.ts +1 -2
  185. package/lib/chain/stateCache/fifoBlockStateCache.d.ts.map +1 -1
  186. package/lib/chain/stateCache/fifoBlockStateCache.js +4 -4
  187. package/lib/chain/stateCache/fifoBlockStateCache.js.map +1 -1
  188. package/lib/chain/stateCache/index.d.ts +0 -2
  189. package/lib/chain/stateCache/index.d.ts.map +1 -1
  190. package/lib/chain/stateCache/index.js +0 -2
  191. package/lib/chain/stateCache/index.js.map +1 -1
  192. package/lib/chain/stateCache/persistentCheckpointsCache.d.ts +7 -7
  193. package/lib/chain/stateCache/persistentCheckpointsCache.d.ts.map +1 -1
  194. package/lib/chain/stateCache/persistentCheckpointsCache.js +20 -17
  195. package/lib/chain/stateCache/persistentCheckpointsCache.js.map +1 -1
  196. package/lib/chain/stateCache/types.d.ts +5 -6
  197. package/lib/chain/stateCache/types.d.ts.map +1 -1
  198. package/lib/chain/stateCache/types.js.map +1 -1
  199. package/lib/chain/validation/aggregateAndProof.js +35 -14
  200. package/lib/chain/validation/aggregateAndProof.js.map +1 -1
  201. package/lib/chain/validation/attestation.d.ts +2 -2
  202. package/lib/chain/validation/attestation.d.ts.map +1 -1
  203. package/lib/chain/validation/attestation.js +28 -9
  204. package/lib/chain/validation/attestation.js.map +1 -1
  205. package/lib/chain/validation/attesterSlashing.d.ts.map +1 -1
  206. package/lib/chain/validation/attesterSlashing.js +2 -2
  207. package/lib/chain/validation/attesterSlashing.js.map +1 -1
  208. package/lib/chain/validation/blobSidecar.d.ts.map +1 -1
  209. package/lib/chain/validation/blobSidecar.js +5 -5
  210. package/lib/chain/validation/blobSidecar.js.map +1 -1
  211. package/lib/chain/validation/block.d.ts.map +1 -1
  212. package/lib/chain/validation/block.js +8 -6
  213. package/lib/chain/validation/block.js.map +1 -1
  214. package/lib/chain/validation/blsToExecutionChange.d.ts.map +1 -1
  215. package/lib/chain/validation/blsToExecutionChange.js +9 -2
  216. package/lib/chain/validation/blsToExecutionChange.js.map +1 -1
  217. package/lib/chain/validation/dataColumnSidecar.d.ts.map +1 -1
  218. package/lib/chain/validation/dataColumnSidecar.js +5 -5
  219. package/lib/chain/validation/dataColumnSidecar.js.map +1 -1
  220. package/lib/chain/validation/executionPayloadBid.d.ts +5 -0
  221. package/lib/chain/validation/executionPayloadBid.d.ts.map +1 -0
  222. package/lib/chain/validation/executionPayloadBid.js +104 -0
  223. package/lib/chain/validation/executionPayloadBid.js.map +1 -0
  224. package/lib/chain/validation/executionPayloadEnvelope.d.ts +5 -0
  225. package/lib/chain/validation/executionPayloadEnvelope.d.ts.map +1 -0
  226. package/lib/chain/validation/executionPayloadEnvelope.js +89 -0
  227. package/lib/chain/validation/executionPayloadEnvelope.js.map +1 -0
  228. package/lib/chain/validation/payloadAttestationMessage.d.ts +9 -0
  229. package/lib/chain/validation/payloadAttestationMessage.d.ts.map +1 -0
  230. package/lib/chain/validation/payloadAttestationMessage.js +72 -0
  231. package/lib/chain/validation/payloadAttestationMessage.js.map +1 -0
  232. package/lib/chain/validation/proposerSlashing.js +3 -2
  233. package/lib/chain/validation/proposerSlashing.js.map +1 -1
  234. package/lib/chain/validation/signatureSets/aggregateAndProof.d.ts +2 -3
  235. package/lib/chain/validation/signatureSets/aggregateAndProof.d.ts.map +1 -1
  236. package/lib/chain/validation/signatureSets/aggregateAndProof.js +8 -3
  237. package/lib/chain/validation/signatureSets/aggregateAndProof.js.map +1 -1
  238. package/lib/chain/validation/signatureSets/contributionAndProof.d.ts +2 -2
  239. package/lib/chain/validation/signatureSets/contributionAndProof.d.ts.map +1 -1
  240. package/lib/chain/validation/signatureSets/contributionAndProof.js +3 -3
  241. package/lib/chain/validation/signatureSets/contributionAndProof.js.map +1 -1
  242. package/lib/chain/validation/signatureSets/selectionProof.d.ts +2 -3
  243. package/lib/chain/validation/signatureSets/selectionProof.d.ts.map +1 -1
  244. package/lib/chain/validation/signatureSets/selectionProof.js +8 -3
  245. package/lib/chain/validation/signatureSets/selectionProof.js.map +1 -1
  246. package/lib/chain/validation/signatureSets/syncCommittee.d.ts +2 -2
  247. package/lib/chain/validation/signatureSets/syncCommittee.d.ts.map +1 -1
  248. package/lib/chain/validation/signatureSets/syncCommittee.js +3 -3
  249. package/lib/chain/validation/signatureSets/syncCommittee.js.map +1 -1
  250. package/lib/chain/validation/signatureSets/syncCommitteeContribution.d.ts +1 -2
  251. package/lib/chain/validation/signatureSets/syncCommitteeContribution.d.ts.map +1 -1
  252. package/lib/chain/validation/signatureSets/syncCommitteeContribution.js +2 -2
  253. package/lib/chain/validation/signatureSets/syncCommitteeContribution.js.map +1 -1
  254. package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.d.ts +2 -2
  255. package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.d.ts.map +1 -1
  256. package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.js +3 -3
  257. package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.js.map +1 -1
  258. package/lib/chain/validation/syncCommittee.js +1 -1
  259. package/lib/chain/validation/syncCommittee.js.map +1 -1
  260. package/lib/chain/validation/syncCommitteeContributionAndProof.d.ts.map +1 -1
  261. package/lib/chain/validation/syncCommitteeContributionAndProof.js +3 -5
  262. package/lib/chain/validation/syncCommitteeContributionAndProof.js.map +1 -1
  263. package/lib/chain/validation/voluntaryExit.js +1 -1
  264. package/lib/chain/validation/voluntaryExit.js.map +1 -1
  265. package/lib/chain/validatorMonitor.d.ts +2 -0
  266. package/lib/chain/validatorMonitor.d.ts.map +1 -1
  267. package/lib/chain/validatorMonitor.js +49 -7
  268. package/lib/chain/validatorMonitor.js.map +1 -1
  269. package/lib/db/repositories/checkpointState.d.ts +2 -6
  270. package/lib/db/repositories/checkpointState.d.ts.map +1 -1
  271. package/lib/db/repositories/checkpointState.js +3 -16
  272. package/lib/db/repositories/checkpointState.js.map +1 -1
  273. package/lib/db/repositories/stateArchive.d.ts +9 -9
  274. package/lib/db/repositories/stateArchive.d.ts.map +1 -1
  275. package/lib/db/repositories/stateArchive.js +6 -21
  276. package/lib/db/repositories/stateArchive.js.map +1 -1
  277. package/lib/execution/engine/mock.d.ts +9 -6
  278. package/lib/execution/engine/mock.d.ts.map +1 -1
  279. package/lib/execution/engine/mock.js +34 -7
  280. package/lib/execution/engine/mock.js.map +1 -1
  281. package/lib/index.d.ts +1 -1
  282. package/lib/index.d.ts.map +1 -1
  283. package/lib/index.js +1 -1
  284. package/lib/index.js.map +1 -1
  285. package/lib/metrics/metrics/lodestar.d.ts +28 -6
  286. package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
  287. package/lib/metrics/metrics/lodestar.js +67 -17
  288. package/lib/metrics/metrics/lodestar.js.map +1 -1
  289. package/lib/network/core/networkCore.d.ts +3 -0
  290. package/lib/network/core/networkCore.d.ts.map +1 -1
  291. package/lib/network/core/networkCore.js +9 -0
  292. package/lib/network/core/networkCore.js.map +1 -1
  293. package/lib/network/core/networkCoreWorker.js +3 -0
  294. package/lib/network/core/networkCoreWorker.js.map +1 -1
  295. package/lib/network/core/networkCoreWorkerHandler.d.ts +3 -0
  296. package/lib/network/core/networkCoreWorkerHandler.d.ts.map +1 -1
  297. package/lib/network/core/networkCoreWorkerHandler.js +9 -0
  298. package/lib/network/core/networkCoreWorkerHandler.js.map +1 -1
  299. package/lib/network/core/types.d.ts +3 -0
  300. package/lib/network/core/types.d.ts.map +1 -1
  301. package/lib/network/gossip/gossipsub.d.ts +34 -0
  302. package/lib/network/gossip/gossipsub.d.ts.map +1 -1
  303. package/lib/network/gossip/gossipsub.js +123 -0
  304. package/lib/network/gossip/gossipsub.js.map +1 -1
  305. package/lib/network/gossip/interface.d.ts +20 -2
  306. package/lib/network/gossip/interface.d.ts.map +1 -1
  307. package/lib/network/gossip/interface.js +3 -0
  308. package/lib/network/gossip/interface.js.map +1 -1
  309. package/lib/network/gossip/scoringParameters.d.ts.map +1 -1
  310. package/lib/network/gossip/scoringParameters.js +38 -2
  311. package/lib/network/gossip/scoringParameters.js.map +1 -1
  312. package/lib/network/gossip/topic.d.ts +77 -1
  313. package/lib/network/gossip/topic.d.ts.map +1 -1
  314. package/lib/network/gossip/topic.js +20 -0
  315. package/lib/network/gossip/topic.js.map +1 -1
  316. package/lib/network/network.d.ts +3 -0
  317. package/lib/network/network.d.ts.map +1 -1
  318. package/lib/network/network.js +9 -0
  319. package/lib/network/network.js.map +1 -1
  320. package/lib/network/options.d.ts +6 -0
  321. package/lib/network/options.d.ts.map +1 -1
  322. package/lib/network/options.js.map +1 -1
  323. package/lib/network/peers/peerManager.d.ts.map +1 -1
  324. package/lib/network/peers/peerManager.js +9 -0
  325. package/lib/network/peers/peerManager.js.map +1 -1
  326. package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
  327. package/lib/network/processor/gossipHandlers.js +35 -4
  328. package/lib/network/processor/gossipHandlers.js.map +1 -1
  329. package/lib/network/processor/gossipQueues/index.d.ts.map +1 -1
  330. package/lib/network/processor/gossipQueues/index.js +16 -0
  331. package/lib/network/processor/gossipQueues/index.js.map +1 -1
  332. package/lib/network/processor/index.d.ts.map +1 -1
  333. package/lib/network/processor/index.js +3 -0
  334. package/lib/network/processor/index.js.map +1 -1
  335. package/lib/network/reqresp/handlers/beaconBlocksByRange.d.ts.map +1 -1
  336. package/lib/network/reqresp/handlers/beaconBlocksByRange.js +2 -4
  337. package/lib/network/reqresp/handlers/beaconBlocksByRange.js.map +1 -1
  338. package/lib/network/reqresp/handlers/beaconBlocksByRoot.d.ts +1 -2
  339. package/lib/network/reqresp/handlers/beaconBlocksByRoot.d.ts.map +1 -1
  340. package/lib/network/reqresp/handlers/beaconBlocksByRoot.js +5 -26
  341. package/lib/network/reqresp/handlers/beaconBlocksByRoot.js.map +1 -1
  342. package/lib/network/reqresp/handlers/blobSidecarsByRoot.d.ts +1 -2
  343. package/lib/network/reqresp/handlers/blobSidecarsByRoot.d.ts.map +1 -1
  344. package/lib/network/reqresp/handlers/blobSidecarsByRoot.js +5 -7
  345. package/lib/network/reqresp/handlers/blobSidecarsByRoot.js.map +1 -1
  346. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.d.ts.map +1 -1
  347. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js +1 -2
  348. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js.map +1 -1
  349. package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.d.ts.map +1 -1
  350. package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.js +1 -5
  351. package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.js.map +1 -1
  352. package/lib/network/reqresp/handlers/index.js +2 -2
  353. package/lib/network/reqresp/handlers/index.js.map +1 -1
  354. package/lib/network/reqresp/utils/dataColumnResponseValidation.js +1 -1
  355. package/lib/network/reqresp/utils/dataColumnResponseValidation.js.map +1 -1
  356. package/lib/node/nodejs.d.ts.map +1 -1
  357. package/lib/node/nodejs.js +17 -2
  358. package/lib/node/nodejs.js.map +1 -1
  359. package/lib/sync/backfill/backfill.d.ts.map +1 -1
  360. package/lib/sync/backfill/backfill.js +3 -4
  361. package/lib/sync/backfill/backfill.js.map +1 -1
  362. package/lib/sync/backfill/verify.d.ts +1 -2
  363. package/lib/sync/backfill/verify.d.ts.map +1 -1
  364. package/lib/sync/backfill/verify.js +2 -2
  365. package/lib/sync/backfill/verify.js.map +1 -1
  366. package/lib/sync/range/chain.d.ts.map +1 -1
  367. package/lib/sync/range/chain.js +0 -1
  368. package/lib/sync/range/chain.js.map +1 -1
  369. package/lib/sync/range/range.d.ts.map +1 -1
  370. package/lib/sync/range/range.js +0 -3
  371. package/lib/sync/range/range.js.map +1 -1
  372. package/lib/sync/unknownBlock.d.ts.map +1 -1
  373. package/lib/sync/unknownBlock.js +0 -3
  374. package/lib/sync/unknownBlock.js.map +1 -1
  375. package/lib/sync/utils/downloadByRange.d.ts.map +1 -1
  376. package/lib/sync/utils/downloadByRange.js +2 -2
  377. package/lib/sync/utils/downloadByRange.js.map +1 -1
  378. package/lib/sync/utils/downloadByRoot.d.ts.map +1 -1
  379. package/lib/sync/utils/downloadByRoot.js +1 -2
  380. package/lib/sync/utils/downloadByRoot.js.map +1 -1
  381. package/lib/util/sszBytes.js +1 -1
  382. package/lib/util/sszBytes.js.map +1 -1
  383. package/package.json +16 -16
  384. package/src/api/impl/beacon/blocks/index.ts +39 -37
  385. package/src/api/impl/beacon/state/utils.ts +2 -22
  386. package/src/api/impl/config/constants.ts +8 -0
  387. package/src/api/impl/debug/index.ts +2 -6
  388. package/src/api/impl/lodestar/index.ts +36 -4
  389. package/src/api/impl/proof/index.ts +1 -2
  390. package/src/api/impl/validator/index.ts +15 -15
  391. package/src/api/rest/base.ts +4 -4
  392. package/src/chain/ColumnReconstructionTracker.ts +8 -4
  393. package/src/chain/archiveStore/historicalState/getHistoricalState.ts +7 -4
  394. package/src/chain/archiveStore/utils/archiveBlocks.ts +25 -14
  395. package/src/chain/blocks/blockInput/blockInput.ts +55 -4
  396. package/src/chain/blocks/importBlock.ts +16 -10
  397. package/src/chain/blocks/index.ts +0 -19
  398. package/src/chain/blocks/types.ts +0 -2
  399. package/src/chain/blocks/verifyBlock.ts +9 -12
  400. package/src/chain/blocks/verifyBlocksSignatures.ts +4 -12
  401. package/src/chain/blocks/verifyBlocksStateTransitionOnly.ts +2 -2
  402. package/src/chain/blocks/writeBlockInputToDb.ts +33 -30
  403. package/src/chain/bls/multithread/index.ts +7 -4
  404. package/src/chain/bls/multithread/jobItem.ts +7 -3
  405. package/src/chain/bls/singleThread.ts +5 -3
  406. package/src/chain/bls/utils.ts +15 -7
  407. package/src/chain/chain.ts +247 -65
  408. package/src/chain/errors/attestationError.ts +11 -1
  409. package/src/chain/errors/executionPayloadBid.ts +35 -0
  410. package/src/chain/errors/executionPayloadEnvelope.ts +34 -0
  411. package/src/chain/errors/index.ts +3 -0
  412. package/src/chain/errors/payloadAttestation.ts +25 -0
  413. package/src/chain/forkChoice/index.ts +19 -0
  414. package/src/chain/initState.ts +7 -5
  415. package/src/chain/interface.ts +34 -3
  416. package/src/chain/lightClient/index.ts +1 -2
  417. package/src/chain/lightClient/proofs.ts +0 -2
  418. package/src/chain/opPools/aggregatedAttestationPool.ts +19 -191
  419. package/src/chain/opPools/executionPayloadBidPool.ts +77 -0
  420. package/src/chain/opPools/index.ts +2 -0
  421. package/src/chain/opPools/opPool.ts +5 -7
  422. package/src/chain/opPools/payloadAttestationPool.ts +157 -0
  423. package/src/chain/options.ts +0 -2
  424. package/src/chain/prepareNextSlot.ts +8 -12
  425. package/src/chain/produceBlock/produceBlockBody.ts +13 -6
  426. package/src/chain/regen/interface.ts +4 -18
  427. package/src/chain/regen/queued.ts +17 -57
  428. package/src/chain/regen/regen.ts +22 -43
  429. package/src/chain/seenCache/index.ts +3 -1
  430. package/src/chain/seenCache/seenAttesters.ts +5 -0
  431. package/src/chain/seenCache/seenExecutionPayloadBids.ts +35 -0
  432. package/src/chain/seenCache/seenExecutionPayloadEnvelope.ts +34 -0
  433. package/src/chain/seenCache/seenGossipBlockInput.ts +3 -3
  434. package/src/chain/shufflingCache.ts +67 -50
  435. package/src/chain/stateCache/fifoBlockStateCache.ts +4 -5
  436. package/src/chain/stateCache/index.ts +0 -2
  437. package/src/chain/stateCache/persistentCheckpointsCache.ts +23 -27
  438. package/src/chain/stateCache/types.ts +5 -10
  439. package/src/chain/validation/aggregateAndProof.ts +36 -14
  440. package/src/chain/validation/attestation.ts +36 -19
  441. package/src/chain/validation/attesterSlashing.ts +9 -7
  442. package/src/chain/validation/blobSidecar.ts +4 -9
  443. package/src/chain/validation/block.ts +9 -6
  444. package/src/chain/validation/blsToExecutionChange.ts +9 -7
  445. package/src/chain/validation/dataColumnSidecar.ts +4 -9
  446. package/src/chain/validation/executionPayloadBid.ts +141 -0
  447. package/src/chain/validation/executionPayloadEnvelope.ts +122 -0
  448. package/src/chain/validation/payloadAttestationMessage.ts +109 -0
  449. package/src/chain/validation/proposerSlashing.ts +3 -7
  450. package/src/chain/validation/signatureSets/aggregateAndProof.ts +9 -14
  451. package/src/chain/validation/signatureSets/contributionAndProof.ts +2 -4
  452. package/src/chain/validation/signatureSets/selectionProof.ts +9 -9
  453. package/src/chain/validation/signatureSets/syncCommittee.ts +2 -4
  454. package/src/chain/validation/signatureSets/syncCommitteeContribution.ts +2 -3
  455. package/src/chain/validation/signatureSets/syncCommitteeSelectionProof.ts +2 -4
  456. package/src/chain/validation/syncCommittee.ts +1 -1
  457. package/src/chain/validation/syncCommitteeContributionAndProof.ts +3 -5
  458. package/src/chain/validation/voluntaryExit.ts +1 -1
  459. package/src/chain/validatorMonitor.ts +62 -8
  460. package/src/db/repositories/checkpointState.ts +3 -19
  461. package/src/db/repositories/stateArchive.ts +13 -27
  462. package/src/execution/engine/mock.ts +40 -13
  463. package/src/index.ts +1 -1
  464. package/src/metrics/metrics/lodestar.ts +68 -17
  465. package/src/network/core/networkCore.ts +12 -0
  466. package/src/network/core/networkCoreWorker.ts +3 -0
  467. package/src/network/core/networkCoreWorkerHandler.ts +9 -0
  468. package/src/network/core/types.ts +6 -0
  469. package/src/network/gossip/gossipsub.ts +147 -1
  470. package/src/network/gossip/interface.ts +17 -0
  471. package/src/network/gossip/scoringParameters.ts +44 -2
  472. package/src/network/gossip/topic.ts +21 -0
  473. package/src/network/network.ts +12 -0
  474. package/src/network/options.ts +6 -0
  475. package/src/network/peers/peerManager.ts +11 -0
  476. package/src/network/processor/gossipHandlers.ts +49 -4
  477. package/src/network/processor/gossipQueues/index.ts +16 -0
  478. package/src/network/processor/index.ts +3 -0
  479. package/src/network/reqresp/handlers/beaconBlocksByRange.ts +2 -4
  480. package/src/network/reqresp/handlers/beaconBlocksByRoot.ts +5 -32
  481. package/src/network/reqresp/handlers/blobSidecarsByRoot.ts +5 -9
  482. package/src/network/reqresp/handlers/dataColumnSidecarsByRange.ts +5 -2
  483. package/src/network/reqresp/handlers/dataColumnSidecarsByRoot.ts +1 -5
  484. package/src/network/reqresp/handlers/index.ts +2 -2
  485. package/src/network/reqresp/utils/dataColumnResponseValidation.ts +1 -1
  486. package/src/node/nodejs.ts +18 -3
  487. package/src/sync/backfill/backfill.ts +3 -4
  488. package/src/sync/backfill/verify.ts +2 -3
  489. package/src/sync/range/chain.ts +0 -1
  490. package/src/sync/range/range.ts +0 -3
  491. package/src/sync/unknownBlock.ts +0 -3
  492. package/src/sync/utils/downloadByRange.ts +2 -2
  493. package/src/sync/utils/downloadByRoot.ts +1 -2
  494. package/src/util/sszBytes.ts +1 -1
  495. package/lib/chain/stateCache/blockStateCacheImpl.d.ts +0 -55
  496. package/lib/chain/stateCache/blockStateCacheImpl.d.ts.map +0 -1
  497. package/lib/chain/stateCache/blockStateCacheImpl.js +0 -130
  498. package/lib/chain/stateCache/blockStateCacheImpl.js.map +0 -1
  499. package/lib/chain/stateCache/inMemoryCheckpointsCache.d.ts +0 -61
  500. package/lib/chain/stateCache/inMemoryCheckpointsCache.d.ts.map +0 -1
  501. package/lib/chain/stateCache/inMemoryCheckpointsCache.js +0 -157
  502. package/lib/chain/stateCache/inMemoryCheckpointsCache.js.map +0 -1
  503. package/lib/util/bytes.d.ts +0 -3
  504. package/lib/util/bytes.d.ts.map +0 -1
  505. package/lib/util/bytes.js +0 -11
  506. package/lib/util/bytes.js.map +0 -1
  507. package/src/chain/stateCache/blockStateCacheImpl.ts +0 -150
  508. package/src/chain/stateCache/inMemoryCheckpointsCache.ts +0 -198
  509. package/src/util/bytes.ts +0 -11
@@ -2,21 +2,27 @@ import path from "node:path";
2
2
  import { UpdateHeadOpt } from "@lodestar/fork-choice";
3
3
  import { EFFECTIVE_BALANCE_INCREMENT, GENESIS_SLOT, SLOTS_PER_EPOCH, isForkPostElectra } from "@lodestar/params";
4
4
  import { computeAnchorCheckpoint, computeAttestationsRewards, computeBlockRewards, computeEndSlotAtEpoch, computeEpochAtSlot, computeStartSlotAtEpoch, computeSyncCommitteeRewards, getEffectiveBalanceIncrementsZeroInactive, getEffectiveBalancesFromStateBytes, processSlots, } from "@lodestar/state-transition";
5
- import { isBlindedBeaconBlock, } from "@lodestar/types";
5
+ import { isBlindedBeaconBlock, ssz, sszTypesFor, } from "@lodestar/types";
6
6
  import { fromHex, gweiToWei, isErrorAborted, pruneSetToMax, sleep, toRootHex } from "@lodestar/utils";
7
7
  import { GENESIS_EPOCH, ZERO_HASH } from "../constants/index.js";
8
+ import { BLOB_SIDECARS_IN_WRAPPER_INDEX } from "../db/repositories/blobSidecars.js";
8
9
  import { BuilderStatus } from "../execution/builder/http.js";
9
10
  import { computeNodeIdFromPrivateKey } from "../network/subnets/interface.js";
10
11
  import { BufferPool } from "../util/bufferPool.js";
11
12
  import { Clock, ClockEvent } from "../util/clock.js";
12
13
  import { CustodyConfig, getValidatorsCustodyRequirement } from "../util/dataColumns.js";
14
+ import { callInNextEventLoop } from "../util/eventLoop.js";
13
15
  import { ensureDir, writeIfNotExist } from "../util/file.js";
14
16
  import { isOptimisticBlock } from "../util/forkChoice.js";
17
+ import { JobItemQueue } from "../util/queue/itemQueue.js";
15
18
  import { SerializedCache } from "../util/serializedCache.js";
19
+ import { getSlotFromSignedBeaconBlockSerialized } from "../util/sszBytes.js";
16
20
  import { ArchiveStore } from "./archiveStore/archiveStore.js";
17
21
  import { CheckpointBalancesCache } from "./balancesCache.js";
18
22
  import { BeaconProposerCache } from "./beaconProposerCache.js";
23
+ import { isBlockInputBlobs, isBlockInputColumns } from "./blocks/blockInput/index.js";
19
24
  import { BlockProcessor } from "./blocks/index.js";
25
+ import { persistBlockInputs } from "./blocks/writeBlockInputToDb.js";
20
26
  import { BlsMultiThreadWorkerPool, BlsSingleThreadVerifier } from "./bls/index.js";
21
27
  import { ColumnReconstructionTracker } from "./ColumnReconstructionTracker.js";
22
28
  import { ChainEvent, ChainEventEmitter } from "./emitter.js";
@@ -24,24 +30,22 @@ import { initializeForkChoice } from "./forkChoice/index.js";
24
30
  import { GetBlobsTracker } from "./GetBlobsTracker.js";
25
31
  import { FindHeadFnName } from "./interface.js";
26
32
  import { LightClientServer } from "./lightClient/index.js";
27
- import { AggregatedAttestationPool, AttestationPool, OpPool, SyncCommitteeMessagePool, SyncContributionAndProofPool, } from "./opPools/index.js";
33
+ import { AggregatedAttestationPool, AttestationPool, ExecutionPayloadBidPool, OpPool, PayloadAttestationPool, SyncCommitteeMessagePool, SyncContributionAndProofPool, } from "./opPools/index.js";
28
34
  import { PrepareNextSlotScheduler } from "./prepareNextSlot.js";
29
35
  import { computeNewStateRoot } from "./produceBlock/computeNewStateRoot.js";
30
36
  import { BlockType } from "./produceBlock/index.js";
31
37
  import { produceBlockBody, produceCommonBlockBody } from "./produceBlock/produceBlockBody.js";
32
38
  import { QueuedStateRegenerator, RegenCaller } from "./regen/index.js";
33
39
  import { ReprocessController } from "./reprocess.js";
34
- import { SeenAggregators, SeenAttesters, SeenBlockProposers, SeenContributionAndProof, SeenSyncCommitteeMessages, } from "./seenCache/index.js";
40
+ import { SeenAggregators, SeenAttesters, SeenBlockProposers, SeenContributionAndProof, SeenExecutionPayloadBids, SeenExecutionPayloadEnvelopes, SeenPayloadAttesters, SeenSyncCommitteeMessages, } from "./seenCache/index.js";
35
41
  import { SeenAggregatedAttestations } from "./seenCache/seenAggregateAndProof.js";
36
42
  import { SeenAttestationDatas } from "./seenCache/seenAttestationData.js";
37
43
  import { SeenBlockAttesters } from "./seenCache/seenBlockAttesters.js";
38
44
  import { SeenBlockInput } from "./seenCache/seenGossipBlockInput.js";
39
45
  import { ShufflingCache } from "./shufflingCache.js";
40
- import { BlockStateCacheImpl } from "./stateCache/blockStateCacheImpl.js";
41
46
  import { DbCPStateDatastore, checkpointToDatastoreKey } from "./stateCache/datastore/db.js";
42
47
  import { FileCPStateDatastore } from "./stateCache/datastore/file.js";
43
48
  import { FIFOBlockStateCache } from "./stateCache/fifoBlockStateCache.js";
44
- import { InMemoryCheckpointStateCache } from "./stateCache/inMemoryCheckpointsCache.js";
45
49
  import { PersistentCheckpointStateCache } from "./stateCache/persistentCheckpointsCache.js";
46
50
  /**
47
51
  * The maximum number of cached produced results to keep in memory.
@@ -51,6 +55,10 @@ import { PersistentCheckpointStateCache } from "./stateCache/persistentCheckpoin
51
55
  * allow some margin if the node overloads.
52
56
  */
53
57
  const DEFAULT_MAX_CACHED_PRODUCED_RESULTS = 4;
58
+ /**
59
+ * The maximum number of pending unfinalized block writes to the database before backpressure is applied.
60
+ */
61
+ const DEFAULT_MAX_PENDING_UNFINALIZED_BLOCK_WRITES = 32;
54
62
  export class BeaconChain {
55
63
  genesisTime;
56
64
  genesisValidatorsRoot;
@@ -72,16 +80,22 @@ export class BeaconChain {
72
80
  lightClientServer;
73
81
  reprocessController;
74
82
  archiveStore;
83
+ unfinalizedBlockWrites;
75
84
  // Ops pool
76
85
  attestationPool;
77
86
  aggregatedAttestationPool;
78
87
  syncCommitteeMessagePool;
79
88
  syncContributionAndProofPool;
89
+ executionPayloadBidPool;
90
+ payloadAttestationPool;
80
91
  opPool;
81
92
  // Gossip seen cache
82
93
  seenAttesters = new SeenAttesters();
83
94
  seenAggregators = new SeenAggregators();
95
+ seenPayloadAttesters = new SeenPayloadAttesters();
84
96
  seenAggregatedAttestations;
97
+ seenExecutionPayloadEnvelopes = new SeenExecutionPayloadEnvelopes();
98
+ seenExecutionPayloadBids = new SeenExecutionPayloadBids();
85
99
  seenBlockProposers = new SeenBlockProposers();
86
100
  seenSyncCommitteeMessages = new SeenSyncCommitteeMessages();
87
101
  seenContributionAndProof;
@@ -139,8 +153,8 @@ export class BeaconChain {
139
153
  const emitter = new ChainEventEmitter();
140
154
  // by default, verify signatures on both main threads and worker threads
141
155
  const bls = opts.blsVerifyAllMainThread
142
- ? new BlsSingleThreadVerifier({ metrics })
143
- : new BlsMultiThreadWorkerPool(opts, { logger, metrics });
156
+ ? new BlsSingleThreadVerifier({ metrics, index2pubkey })
157
+ : new BlsMultiThreadWorkerPool(opts, { logger, metrics, index2pubkey });
144
158
  if (!clock)
145
159
  clock = new Clock({ config, genesisTime: this.genesisTime, signal });
146
160
  this.blacklistedBlocks = new Map((opts.blacklistedBlocks ?? []).map((hex) => [hex, null]));
@@ -148,6 +162,8 @@ export class BeaconChain {
148
162
  this.aggregatedAttestationPool = new AggregatedAttestationPool(this.config, metrics);
149
163
  this.syncCommitteeMessagePool = new SyncCommitteeMessagePool(config, clock, this.opts?.preaggregateSlotDistance);
150
164
  this.syncContributionAndProofPool = new SyncContributionAndProofPool(config, clock, metrics, logger);
165
+ this.executionPayloadBidPool = new ExecutionPayloadBidPool();
166
+ this.payloadAttestationPool = new PayloadAttestationPool(config, clock, metrics);
151
167
  this.opPool = new OpPool(config);
152
168
  this.seenAggregatedAttestations = new SeenAggregatedAttestations(metrics);
153
169
  this.seenContributionAndProof = new SeenContributionAndProof(metrics);
@@ -172,7 +188,7 @@ export class BeaconChain {
172
188
  logger,
173
189
  });
174
190
  this._earliestAvailableSlot = anchorState.slot;
175
- this.shufflingCache = anchorState.epochCtx.shufflingCache = new ShufflingCache(metrics, logger, this.opts, [
191
+ this.shufflingCache = new ShufflingCache(metrics, logger, this.opts, [
176
192
  {
177
193
  shuffling: anchorState.epochCtx.previousShuffling,
178
194
  decisionRoot: anchorState.epochCtx.previousDecisionRoot,
@@ -190,29 +206,18 @@ export class BeaconChain {
190
206
  this.pubkey2index = pubkey2index;
191
207
  this.index2pubkey = index2pubkey;
192
208
  const fileDataStore = opts.nHistoricalStatesFileDataStore ?? true;
193
- const blockStateCache = this.opts.nHistoricalStates
194
- ? new FIFOBlockStateCache(this.opts, { metrics })
195
- : new BlockStateCacheImpl({ metrics });
196
- this.bufferPool = this.opts.nHistoricalStates
197
- ? new BufferPool(anchorState.type.tree_serializedSize(anchorState.node), metrics)
198
- : null;
199
- let checkpointStateCache;
200
- this.cpStateDatastore = undefined;
201
- if (this.opts.nHistoricalStates) {
202
- this.cpStateDatastore = fileDataStore ? new FileCPStateDatastore(dataDir) : new DbCPStateDatastore(this.db);
203
- checkpointStateCache = new PersistentCheckpointStateCache({
204
- config,
205
- metrics,
206
- logger,
207
- clock,
208
- blockStateCache,
209
- bufferPool: this.bufferPool,
210
- datastore: this.cpStateDatastore,
211
- }, this.opts);
212
- }
213
- else {
214
- checkpointStateCache = new InMemoryCheckpointStateCache({ metrics });
215
- }
209
+ const blockStateCache = new FIFOBlockStateCache(this.opts, { metrics });
210
+ this.bufferPool = new BufferPool(anchorState.type.tree_serializedSize(anchorState.node), metrics);
211
+ this.cpStateDatastore = fileDataStore ? new FileCPStateDatastore(dataDir) : new DbCPStateDatastore(this.db);
212
+ const checkpointStateCache = new PersistentCheckpointStateCache({
213
+ config,
214
+ metrics,
215
+ logger,
216
+ clock,
217
+ blockStateCache,
218
+ bufferPool: this.bufferPool,
219
+ datastore: this.cpStateDatastore,
220
+ }, this.opts);
216
221
  const { checkpoint } = computeAnchorCheckpoint(config, anchorState);
217
222
  blockStateCache.add(anchorState);
218
223
  blockStateCache.setHeadState(anchorState);
@@ -223,6 +228,7 @@ export class BeaconChain {
223
228
  forkChoice,
224
229
  blockStateCache,
225
230
  checkpointStateCache,
231
+ seenBlockInputCache: this.seenBlockInputCache,
226
232
  db,
227
233
  metrics,
228
234
  validatorMonitor,
@@ -255,6 +261,10 @@ export class BeaconChain {
255
261
  config,
256
262
  });
257
263
  this.archiveStore = new ArchiveStore({ db, chain: this, logger: logger, metrics }, { ...opts, dbName, anchorState: { finalizedCheckpoint: anchorState.finalizedCheckpoint } }, signal);
264
+ this.unfinalizedBlockWrites = new JobItemQueue(persistBlockInputs.bind(this), {
265
+ maxLength: DEFAULT_MAX_PENDING_UNFINALIZED_BLOCK_WRITES,
266
+ signal,
267
+ }, metrics?.unfinalizedBlockWritesQueue);
258
268
  // always run PrepareNextSlotScheduler except for fork_choice spec tests
259
269
  if (!opts?.disablePrepareNextSlot) {
260
270
  new PrepareNextSlotScheduler(this, this.config, metrics, this.logger, signal);
@@ -267,6 +277,7 @@ export class BeaconChain {
267
277
  clock.addListener(ClockEvent.epoch, this.onClockEpoch.bind(this));
268
278
  emitter.addListener(ChainEvent.forkChoiceFinalized, this.onForkChoiceFinalized.bind(this));
269
279
  emitter.addListener(ChainEvent.forkChoiceJustified, this.onForkChoiceJustified.bind(this));
280
+ emitter.addListener(ChainEvent.checkpoint, this.onCheckpoint.bind(this));
270
281
  }
271
282
  async init() {
272
283
  await this.archiveStore.init();
@@ -275,6 +286,10 @@ export class BeaconChain {
275
286
  async close() {
276
287
  await this.archiveStore.close();
277
288
  await this.bls.close();
289
+ // Since we don't persist unfinalized fork-choice,
290
+ // we can abort any ongoing unfinalized block writes.
291
+ // TODO: persist fork choice to disk and allow unfinalized block writes to complete.
292
+ this.unfinalizedBlockWrites.dropAllJobs();
278
293
  this.abortController.abort();
279
294
  }
280
295
  seenBlock(blockRoot) {
@@ -299,6 +314,8 @@ export class BeaconChain {
299
314
  this.seenAttesters.isKnown(epoch, index) ||
300
315
  // seenAggregators = single aggregator index, not participants of the aggregate
301
316
  this.seenAggregators.isKnown(epoch, index) ||
317
+ // seenPayloadAttesters = single signer of payload attestation message
318
+ this.seenPayloadAttesters.isKnown(epoch, index) ||
302
319
  // seenBlockProposers = single block proposer
303
320
  this.seenBlockProposers.seenAtEpoch(epoch, index));
304
321
  }
@@ -335,7 +352,7 @@ export class BeaconChain {
335
352
  // only use regen queue if necessary, it'll cache in checkpointStateCache if regen gets through epoch transition
336
353
  const head = this.forkChoice.getHead();
337
354
  const startSlot = computeStartSlotAtEpoch(epoch);
338
- return this.regen.getBlockSlotState(head.blockRoot, startSlot, { dontTransferCache: true }, regenCaller);
355
+ return this.regen.getBlockSlotState(head, startSlot, { dontTransferCache: true }, regenCaller);
339
356
  }
340
357
  async getStateBySlot(slot, opts) {
341
358
  const finalizedBlock = this.forkChoice.getFinalizedBlock();
@@ -347,7 +364,7 @@ export class BeaconChain {
347
364
  if (opts?.allowRegen) {
348
365
  // Find closest canonical block to slot, then trigger regen
349
366
  const block = this.forkChoice.getCanonicalBlockClosestLteSlot(slot) ?? finalizedBlock;
350
- const state = await this.regen.getBlockSlotState(block.blockRoot, slot, { dontTransferCache: true }, RegenCaller.restApi);
367
+ const state = await this.regen.getBlockSlotState(block, slot, { dontTransferCache: true }, RegenCaller.restApi);
351
368
  return {
352
369
  state,
353
370
  executionOptimistic: isOptimisticBlock(block),
@@ -398,7 +415,8 @@ export class BeaconChain {
398
415
  finalized: cachedStateCtx.epochCtx.epoch <= finalizedEpoch && finalizedEpoch !== GENESIS_EPOCH,
399
416
  };
400
417
  }
401
- const data = await this.db.stateArchive.getByRoot(fromHex(stateRoot));
418
+ // this is mostly useful for a node with `--chain.archiveStateEpochFrequency 1`
419
+ const data = await this.db.stateArchive.getBinaryByRoot(fromHex(stateRoot));
402
420
  return data && { state: data, executionOptimistic: false, finalized: true };
403
421
  }
404
422
  async getPersistedCheckpointState(checkpoint) {
@@ -445,6 +463,13 @@ export class BeaconChain {
445
463
  // Unfinalized slot, attempt to find in fork-choice
446
464
  const block = this.forkChoice.getCanonicalBlockAtSlot(slot);
447
465
  if (block) {
466
+ // Block found in fork-choice.
467
+ // It may be in the block input cache, awaiting full DA reconstruction, check there first
468
+ // Otherwise (most likely), check the hot db
469
+ const blockInput = this.seenBlockInputCache.get(block.blockRoot);
470
+ if (blockInput?.hasBlock()) {
471
+ return { block: blockInput.getBlock(), executionOptimistic: isOptimisticBlock(block), finalized: false };
472
+ }
448
473
  const data = await this.db.block.get(fromHex(block.blockRoot));
449
474
  if (data) {
450
475
  return { block: data, executionOptimistic: isOptimisticBlock(block), finalized: false };
@@ -460,6 +485,13 @@ export class BeaconChain {
460
485
  async getBlockByRoot(root) {
461
486
  const block = this.forkChoice.getBlockHex(root);
462
487
  if (block) {
488
+ // Block found in fork-choice.
489
+ // It may be in the block input cache, awaiting full DA reconstruction, check there first
490
+ // Otherwise (most likely), check the hot db
491
+ const blockInput = this.seenBlockInputCache.get(block.blockRoot);
492
+ if (blockInput?.hasBlock()) {
493
+ return { block: blockInput.getBlock(), executionOptimistic: isOptimisticBlock(block), finalized: false };
494
+ }
463
495
  const data = await this.db.block.get(fromHex(root));
464
496
  if (data) {
465
497
  return { block: data, executionOptimistic: isOptimisticBlock(block), finalized: false };
@@ -470,9 +502,125 @@ export class BeaconChain {
470
502
  const data = await this.db.blockArchive.getByRoot(fromHex(root));
471
503
  return data && { block: data, executionOptimistic: false, finalized: true };
472
504
  }
505
+ async getSerializedBlockByRoot(root) {
506
+ const block = this.forkChoice.getBlockHex(root);
507
+ if (block) {
508
+ // Block found in fork-choice.
509
+ // It may be in the block input cache, awaiting full DA reconstruction, check there first
510
+ // Otherwise (most likely), check the hot db
511
+ const blockInput = this.seenBlockInputCache.get(block.blockRoot);
512
+ if (blockInput?.hasBlock()) {
513
+ const signedBlock = blockInput.getBlock();
514
+ const serialized = this.serializedCache.get(signedBlock);
515
+ if (serialized) {
516
+ return {
517
+ block: serialized,
518
+ executionOptimistic: isOptimisticBlock(block),
519
+ finalized: false,
520
+ slot: blockInput.slot,
521
+ };
522
+ }
523
+ return {
524
+ block: sszTypesFor(blockInput.forkName).SignedBeaconBlock.serialize(signedBlock),
525
+ executionOptimistic: isOptimisticBlock(block),
526
+ finalized: false,
527
+ slot: blockInput.slot,
528
+ };
529
+ }
530
+ const data = await this.db.block.getBinary(fromHex(root));
531
+ if (data) {
532
+ const slot = getSlotFromSignedBeaconBlockSerialized(data);
533
+ if (slot === null)
534
+ throw new Error(`Invalid block data stored in DB for root: ${root}`);
535
+ return { block: data, executionOptimistic: isOptimisticBlock(block), finalized: false, slot };
536
+ }
537
+ // If block is not found in hot db, try cold db since there could be an archive cycle happening
538
+ // TODO: Add a lock to the archiver to have deterministic behavior on where are blocks
539
+ }
540
+ const data = await this.db.blockArchive.getBinaryEntryByRoot(fromHex(root));
541
+ return data && { block: data.value, executionOptimistic: false, finalized: true, slot: data.key };
542
+ }
543
+ async getBlobSidecars(blockSlot, blockRootHex) {
544
+ const blockInput = this.seenBlockInputCache.get(blockRootHex);
545
+ if (blockInput) {
546
+ if (!isBlockInputBlobs(blockInput)) {
547
+ throw new Error(`Expected block input to have blobs: slot=${blockSlot} root=${blockRootHex}`);
548
+ }
549
+ if (!blockInput.hasAllData()) {
550
+ return null;
551
+ }
552
+ return blockInput.getBlobs();
553
+ }
554
+ const unfinalizedBlobSidecars = (await this.db.blobSidecars.get(fromHex(blockRootHex)))?.blobSidecars ?? null;
555
+ if (unfinalizedBlobSidecars) {
556
+ return unfinalizedBlobSidecars;
557
+ }
558
+ return (await this.db.blobSidecarsArchive.get(blockSlot))?.blobSidecars ?? null;
559
+ }
560
+ async getSerializedBlobSidecars(blockSlot, blockRootHex) {
561
+ const blockInput = this.seenBlockInputCache.get(blockRootHex);
562
+ if (blockInput) {
563
+ if (!isBlockInputBlobs(blockInput)) {
564
+ throw new Error(`Expected block input to have blobs: slot=${blockSlot} root=${blockRootHex}`);
565
+ }
566
+ if (!blockInput.hasAllData()) {
567
+ return null;
568
+ }
569
+ return ssz.deneb.BlobSidecars.serialize(blockInput.getBlobs());
570
+ }
571
+ const unfinalizedBlobSidecarsWrapper = await this.db.blobSidecars.getBinary(fromHex(blockRootHex));
572
+ if (unfinalizedBlobSidecarsWrapper) {
573
+ return unfinalizedBlobSidecarsWrapper.slice(BLOB_SIDECARS_IN_WRAPPER_INDEX);
574
+ }
575
+ const finalizedBlobSidecarsWrapper = await this.db.blobSidecarsArchive.getBinary(blockSlot);
576
+ if (finalizedBlobSidecarsWrapper) {
577
+ return finalizedBlobSidecarsWrapper.slice(BLOB_SIDECARS_IN_WRAPPER_INDEX);
578
+ }
579
+ return null;
580
+ }
581
+ async getDataColumnSidecars(blockSlot, blockRootHex) {
582
+ const blockInput = this.seenBlockInputCache.get(blockRootHex);
583
+ if (blockInput) {
584
+ if (!isBlockInputColumns(blockInput)) {
585
+ throw new Error(`Expected block input to have columns: slot=${blockSlot} root=${blockRootHex}`);
586
+ }
587
+ return blockInput.getAllColumns();
588
+ }
589
+ const sidecarsUnfinalized = await this.db.dataColumnSidecar.values(fromHex(blockRootHex));
590
+ if (sidecarsUnfinalized.length > 0) {
591
+ return sidecarsUnfinalized;
592
+ }
593
+ const sidecarsFinalized = await this.db.dataColumnSidecarArchive.values(blockSlot);
594
+ return sidecarsFinalized;
595
+ }
596
+ async getSerializedDataColumnSidecars(blockSlot, blockRootHex, indices) {
597
+ const blockInput = this.seenBlockInputCache.get(blockRootHex);
598
+ if (blockInput) {
599
+ if (!isBlockInputColumns(blockInput)) {
600
+ throw new Error(`Expected block input to have columns: slot=${blockSlot} root=${blockRootHex}`);
601
+ }
602
+ return indices.map((index) => {
603
+ const sidecar = blockInput.getColumn(index);
604
+ if (!sidecar) {
605
+ return undefined;
606
+ }
607
+ const serialized = this.serializedCache.get(sidecar);
608
+ if (serialized) {
609
+ return serialized;
610
+ }
611
+ return ssz.fulu.DataColumnSidecar.serialize(sidecar);
612
+ });
613
+ }
614
+ const sidecarsUnfinalized = await this.db.dataColumnSidecar.getManyBinary(fromHex(blockRootHex), indices);
615
+ if (sidecarsUnfinalized.some((sidecar) => sidecar != null)) {
616
+ return sidecarsUnfinalized;
617
+ }
618
+ const sidecarsFinalized = await this.db.dataColumnSidecarArchive.getManyBinary(blockSlot, indices);
619
+ return sidecarsFinalized;
620
+ }
473
621
  async produceCommonBlockBody(blockAttributes) {
474
- const { slot, parentBlockRoot } = blockAttributes;
475
- const state = await this.regen.getBlockSlotState(toRootHex(parentBlockRoot), slot, { dontTransferCache: true }, RegenCaller.produceBlock);
622
+ const { slot, parentBlock } = blockAttributes;
623
+ const state = await this.regen.getBlockSlotState(parentBlock, slot, { dontTransferCache: true }, RegenCaller.produceBlock);
476
624
  // TODO: To avoid breaking changes for metric define this attribute
477
625
  const blockType = BlockType.Full;
478
626
  return produceCommonBlockBody.call(this, blockType, state, blockAttributes);
@@ -483,8 +631,8 @@ export class BeaconChain {
483
631
  produceBlindedBlock(blockAttributes) {
484
632
  return this.produceBlockWrapper(BlockType.Blinded, blockAttributes);
485
633
  }
486
- async produceBlockWrapper(blockType, { randaoReveal, graffiti, slot, feeRecipient, commonBlockBodyPromise, parentBlockRoot, }) {
487
- const state = await this.regen.getBlockSlotState(toRootHex(parentBlockRoot), slot, { dontTransferCache: true }, RegenCaller.produceBlock);
634
+ async produceBlockWrapper(blockType, { randaoReveal, graffiti, slot, feeRecipient, commonBlockBodyPromise, parentBlock, }) {
635
+ const state = await this.regen.getBlockSlotState(parentBlock, slot, { dontTransferCache: true }, RegenCaller.produceBlock);
488
636
  const proposerIndex = state.epochCtx.getBeaconProposer(slot);
489
637
  const proposerPubKey = this.index2pubkey[proposerIndex].toBytes();
490
638
  const { body, produceResult, executionPayloadValue, shouldOverrideBuilder } = await produceBlockBody.call(this, blockType, state, {
@@ -492,7 +640,7 @@ export class BeaconChain {
492
640
  graffiti,
493
641
  slot,
494
642
  feeRecipient,
495
- parentBlockRoot,
643
+ parentBlock,
496
644
  proposerIndex,
497
645
  proposerPubKey,
498
646
  commonBlockBodyPromise,
@@ -511,7 +659,7 @@ export class BeaconChain {
511
659
  const block = {
512
660
  slot,
513
661
  proposerIndex,
514
- parentRoot: parentBlockRoot,
662
+ parentRoot: fromHex(parentBlock.blockRoot),
515
663
  stateRoot: ZERO_HASH,
516
664
  body,
517
665
  };
@@ -668,7 +816,7 @@ export class BeaconChain {
668
816
  // thanks to one epoch look ahead, we don't need to dial up to attEpoch
669
817
  const targetSlot = computeStartSlotAtEpoch(attEpoch - 1);
670
818
  this.metrics?.gossipAttestation.useHeadBlockStateDialedToTargetEpoch.inc({ caller: regenCaller });
671
- state = await this.regen.getBlockSlotState(attHeadBlock.blockRoot, targetSlot, { dontTransferCache: true }, regenCaller);
819
+ state = await this.regen.getBlockSlotState(attHeadBlock, targetSlot, { dontTransferCache: true }, regenCaller);
672
820
  }
673
821
  else if (blockEpoch > attEpoch) {
674
822
  // should not happen, handled inside attestation verification code
@@ -681,7 +829,8 @@ export class BeaconChain {
681
829
  this.metrics?.gossipAttestation.useHeadBlockState.inc({ caller: regenCaller });
682
830
  state = await this.regen.getState(attHeadBlock.stateRoot, regenCaller);
683
831
  }
684
- // should always be the current epoch of the active context so no need to await a result from the ShufflingCache
832
+ // resolve the promise to unblock other calls of the same epoch and dependent root
833
+ this.shufflingCache.processState(state);
685
834
  return state.epochCtx.getShufflingAtEpoch(attEpoch);
686
835
  }
687
836
  /**
@@ -776,6 +925,8 @@ export class BeaconChain {
776
925
  metrics.opPool.proposerSlashingPoolSize.set(this.opPool.proposerSlashingsSize);
777
926
  metrics.opPool.voluntaryExitPoolSize.set(this.opPool.voluntaryExitsSize);
778
927
  metrics.opPool.syncCommitteeMessagePoolSize.set(this.syncCommitteeMessagePool.size);
928
+ metrics.opPool.payloadAttestationPool.size.set(this.payloadAttestationPool.size);
929
+ metrics.opPool.executionPayloadBidPool.size.set(this.executionPayloadBidPool.size);
779
930
  // syncContributionAndProofPool tracks metrics on its own
780
931
  metrics.opPool.blsToExecutionChangePoolSize.set(this.opPool.blsToExecutionChangeSize);
781
932
  metrics.chain.blacklistedBlocks.set(this.blacklistedBlocks.size);
@@ -800,6 +951,9 @@ export class BeaconChain {
800
951
  this.aggregatedAttestationPool.prune(slot);
801
952
  this.syncCommitteeMessagePool.prune(slot);
802
953
  this.seenSyncCommitteeMessages.prune(slot);
954
+ this.payloadAttestationPool.prune(slot);
955
+ this.executionPayloadBidPool.prune(slot);
956
+ this.seenExecutionPayloadBids.prune(slot);
803
957
  this.seenAttestationDatas.onSlot(slot);
804
958
  this.reprocessController.onSlot(slot);
805
959
  // Prune old cached block production artifacts, those are only useful on their slot
@@ -820,6 +974,7 @@ export class BeaconChain {
820
974
  this.metrics?.clockEpoch.set(epoch);
821
975
  this.seenAttesters.prune(epoch);
822
976
  this.seenAggregators.prune(epoch);
977
+ this.seenPayloadAttesters.prune(epoch);
823
978
  this.seenAggregatedAttestations.prune(epoch);
824
979
  this.seenBlockAttesters.prune(epoch);
825
980
  this.beaconProposerCache.prune(epoch);
@@ -831,20 +986,28 @@ export class BeaconChain {
831
986
  onForkChoiceJustified(cp) {
832
987
  this.logger.verbose("Fork choice justified", { epoch: cp.epoch, root: cp.rootHex });
833
988
  }
989
+ onCheckpoint(_checkpoint, state) {
990
+ // Defer to not block other checkpoint event handlers, which can cause lightclient update delays
991
+ callInNextEventLoop(() => {
992
+ this.shufflingCache.processState(state);
993
+ });
994
+ }
834
995
  async onForkChoiceFinalized(cp) {
835
996
  this.logger.verbose("Fork choice finalized", { epoch: cp.epoch, root: cp.rootHex });
836
- this.seenBlockProposers.prune(computeStartSlotAtEpoch(cp.epoch));
997
+ const finalizedSlot = computeStartSlotAtEpoch(cp.epoch);
998
+ this.seenBlockProposers.prune(finalizedSlot);
999
+ this.seenExecutionPayloadEnvelopes.prune(finalizedSlot);
837
1000
  // Update validator custody to account for effective balance changes
838
1001
  await this.updateValidatorsCustodyRequirement(cp);
839
1002
  // TODO: Improve using regen here
840
1003
  const { blockRoot, stateRoot, slot } = this.forkChoice.getHead();
841
1004
  const headState = this.regen.getStateSync(stateRoot);
842
- const headBlock = await this.db.block.get(fromHex(blockRoot));
843
- if (headBlock == null) {
844
- throw Error(`Head block ${slot} ${headBlock} is not available in database`);
1005
+ const blockResult = await this.getBlockByRoot(blockRoot);
1006
+ if (blockResult == null) {
1007
+ throw Error(`Head block for ${slot} is not available in cache or database`);
845
1008
  }
846
1009
  if (headState) {
847
- this.opPool.pruneAll(headBlock, headState);
1010
+ this.opPool.pruneAll(blockResult.block, headState);
848
1011
  }
849
1012
  if (headState === null) {
850
1013
  this.logger.verbose("Head state is null");
@@ -942,8 +1105,8 @@ export class BeaconChain {
942
1105
  throw Error(`Pre-state is unavailable given block's parent root ${toRootHex(block.parentRoot)}`);
943
1106
  }
944
1107
  preState = processSlots(preState, block.slot); // Dial preState's slot to block.slot
945
- const postState = this.regen.getStateSync(toRootHex(block.stateRoot)) ?? undefined;
946
- return computeBlockRewards(this.config, block, preState.clone(), postState?.clone());
1108
+ const proposerRewards = this.regen.getStateSync(toRootHex(block.stateRoot))?.proposerRewards ?? undefined;
1109
+ return computeBlockRewards(this.config, block, preState, proposerRewards);
947
1110
  }
948
1111
  async getAttestationsRewards(epoch, validatorIds) {
949
1112
  // 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
@@ -967,7 +1130,7 @@ export class BeaconChain {
967
1130
  throw Error(`Pre-state is unavailable given block's parent root ${toRootHex(block.parentRoot)}`);
968
1131
  }
969
1132
  preState = processSlots(preState, block.slot); // Dial preState's slot to block.slot
970
- return computeSyncCommitteeRewards(this.config, this.index2pubkey, block, preState.clone(), validatorIds);
1133
+ return computeSyncCommitteeRewards(this.config, this.index2pubkey, block, preState, validatorIds);
971
1134
  }
972
1135
  }
973
1136
  //# sourceMappingURL=chain.js.map