@lodestar/beacon-node 1.40.0-dev.c975f70481 → 1.40.0-dev.cd347a28d7

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 (379) hide show
  1. package/lib/api/impl/beacon/blocks/index.d.ts.map +1 -1
  2. package/lib/api/impl/beacon/blocks/index.js +15 -25
  3. package/lib/api/impl/beacon/blocks/index.js.map +1 -1
  4. package/lib/api/impl/debug/index.d.ts +1 -1
  5. package/lib/api/impl/debug/index.d.ts.map +1 -1
  6. package/lib/api/impl/debug/index.js +3 -6
  7. package/lib/api/impl/debug/index.js.map +1 -1
  8. package/lib/api/impl/lodestar/index.d.ts.map +1 -1
  9. package/lib/api/impl/lodestar/index.js +15 -2
  10. package/lib/api/impl/lodestar/index.js.map +1 -1
  11. package/lib/api/impl/validator/index.d.ts.map +1 -1
  12. package/lib/api/impl/validator/index.js +9 -8
  13. package/lib/api/impl/validator/index.js.map +1 -1
  14. package/lib/chain/ColumnReconstructionTracker.d.ts +2 -0
  15. package/lib/chain/ColumnReconstructionTracker.d.ts.map +1 -1
  16. package/lib/chain/ColumnReconstructionTracker.js +7 -3
  17. package/lib/chain/ColumnReconstructionTracker.js.map +1 -1
  18. package/lib/chain/archiveStore/utils/archiveBlocks.d.ts.map +1 -1
  19. package/lib/chain/archiveStore/utils/archiveBlocks.js +4 -0
  20. package/lib/chain/archiveStore/utils/archiveBlocks.js.map +1 -1
  21. package/lib/chain/blocks/blockInput/blockInput.d.ts +30 -0
  22. package/lib/chain/blocks/blockInput/blockInput.d.ts.map +1 -1
  23. package/lib/chain/blocks/blockInput/blockInput.js +42 -1
  24. package/lib/chain/blocks/blockInput/blockInput.js.map +1 -1
  25. package/lib/chain/blocks/importBlock.d.ts.map +1 -1
  26. package/lib/chain/blocks/importBlock.js +3 -7
  27. package/lib/chain/blocks/importBlock.js.map +1 -1
  28. package/lib/chain/blocks/index.d.ts.map +1 -1
  29. package/lib/chain/blocks/index.js +0 -14
  30. package/lib/chain/blocks/index.js.map +1 -1
  31. package/lib/chain/blocks/types.d.ts +0 -2
  32. package/lib/chain/blocks/types.d.ts.map +1 -1
  33. package/lib/chain/blocks/verifyBlock.d.ts.map +1 -1
  34. package/lib/chain/blocks/verifyBlock.js +1 -8
  35. package/lib/chain/blocks/verifyBlock.js.map +1 -1
  36. package/lib/chain/blocks/verifyBlocksSignatures.d.ts +2 -2
  37. package/lib/chain/blocks/verifyBlocksSignatures.d.ts.map +1 -1
  38. package/lib/chain/blocks/verifyBlocksSignatures.js +2 -2
  39. package/lib/chain/blocks/verifyBlocksSignatures.js.map +1 -1
  40. package/lib/chain/blocks/writeBlockInputToDb.d.ts +1 -4
  41. package/lib/chain/blocks/writeBlockInputToDb.d.ts.map +1 -1
  42. package/lib/chain/blocks/writeBlockInputToDb.js +28 -28
  43. package/lib/chain/blocks/writeBlockInputToDb.js.map +1 -1
  44. package/lib/chain/bls/multithread/index.d.ts +3 -1
  45. package/lib/chain/bls/multithread/index.d.ts.map +1 -1
  46. package/lib/chain/bls/multithread/index.js +5 -3
  47. package/lib/chain/bls/multithread/index.js.map +1 -1
  48. package/lib/chain/bls/multithread/jobItem.d.ts +2 -2
  49. package/lib/chain/bls/multithread/jobItem.d.ts.map +1 -1
  50. package/lib/chain/bls/multithread/jobItem.js +2 -2
  51. package/lib/chain/bls/multithread/jobItem.js.map +1 -1
  52. package/lib/chain/bls/singleThread.d.ts +4 -2
  53. package/lib/chain/bls/singleThread.d.ts.map +1 -1
  54. package/lib/chain/bls/singleThread.js +4 -2
  55. package/lib/chain/bls/singleThread.js.map +1 -1
  56. package/lib/chain/bls/utils.d.ts +2 -2
  57. package/lib/chain/bls/utils.d.ts.map +1 -1
  58. package/lib/chain/bls/utils.js +9 -6
  59. package/lib/chain/bls/utils.js.map +1 -1
  60. package/lib/chain/chain.d.ts +22 -5
  61. package/lib/chain/chain.d.ts.map +1 -1
  62. package/lib/chain/chain.js +197 -44
  63. package/lib/chain/chain.js.map +1 -1
  64. package/lib/chain/errors/attestationError.d.ts +14 -1
  65. package/lib/chain/errors/attestationError.d.ts.map +1 -1
  66. package/lib/chain/errors/attestationError.js +8 -0
  67. package/lib/chain/errors/attestationError.js.map +1 -1
  68. package/lib/chain/errors/executionPayloadBid.d.ts +48 -0
  69. package/lib/chain/errors/executionPayloadBid.d.ts.map +1 -0
  70. package/lib/chain/errors/executionPayloadBid.js +15 -0
  71. package/lib/chain/errors/executionPayloadBid.js.map +1 -0
  72. package/lib/chain/errors/executionPayloadEnvelope.d.ts +48 -0
  73. package/lib/chain/errors/executionPayloadEnvelope.d.ts.map +1 -0
  74. package/lib/chain/errors/executionPayloadEnvelope.js +16 -0
  75. package/lib/chain/errors/executionPayloadEnvelope.js.map +1 -0
  76. package/lib/chain/errors/index.d.ts +3 -0
  77. package/lib/chain/errors/index.d.ts.map +1 -1
  78. package/lib/chain/errors/index.js +3 -0
  79. package/lib/chain/errors/index.js.map +1 -1
  80. package/lib/chain/errors/payloadAttestation.d.ts +34 -0
  81. package/lib/chain/errors/payloadAttestation.d.ts.map +1 -0
  82. package/lib/chain/errors/payloadAttestation.js +13 -0
  83. package/lib/chain/errors/payloadAttestation.js.map +1 -0
  84. package/lib/chain/forkChoice/index.d.ts.map +1 -1
  85. package/lib/chain/forkChoice/index.js +18 -0
  86. package/lib/chain/forkChoice/index.js.map +1 -1
  87. package/lib/chain/interface.d.ts +21 -3
  88. package/lib/chain/interface.d.ts.map +1 -1
  89. package/lib/chain/interface.js.map +1 -1
  90. package/lib/chain/opPools/executionPayloadBidPool.d.ts +21 -0
  91. package/lib/chain/opPools/executionPayloadBidPool.d.ts.map +1 -0
  92. package/lib/chain/opPools/executionPayloadBidPool.js +57 -0
  93. package/lib/chain/opPools/executionPayloadBidPool.js.map +1 -0
  94. package/lib/chain/opPools/index.d.ts +2 -0
  95. package/lib/chain/opPools/index.d.ts.map +1 -1
  96. package/lib/chain/opPools/index.js +2 -0
  97. package/lib/chain/opPools/index.js.map +1 -1
  98. package/lib/chain/opPools/payloadAttestationPool.d.ts +24 -0
  99. package/lib/chain/opPools/payloadAttestationPool.d.ts.map +1 -0
  100. package/lib/chain/opPools/payloadAttestationPool.js +109 -0
  101. package/lib/chain/opPools/payloadAttestationPool.js.map +1 -0
  102. package/lib/chain/options.d.ts +0 -1
  103. package/lib/chain/options.d.ts.map +1 -1
  104. package/lib/chain/options.js +0 -1
  105. package/lib/chain/options.js.map +1 -1
  106. package/lib/chain/prepareNextSlot.js +6 -4
  107. package/lib/chain/prepareNextSlot.js.map +1 -1
  108. package/lib/chain/produceBlock/produceBlockBody.d.ts +3 -2
  109. package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
  110. package/lib/chain/produceBlock/produceBlockBody.js +5 -3
  111. package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
  112. package/lib/chain/regen/interface.d.ts +4 -9
  113. package/lib/chain/regen/interface.d.ts.map +1 -1
  114. package/lib/chain/regen/interface.js +1 -1
  115. package/lib/chain/regen/interface.js.map +1 -1
  116. package/lib/chain/regen/queued.d.ts +2 -3
  117. package/lib/chain/regen/queued.d.ts.map +1 -1
  118. package/lib/chain/regen/queued.js +2 -16
  119. package/lib/chain/regen/queued.js.map +1 -1
  120. package/lib/chain/regen/regen.d.ts +5 -7
  121. package/lib/chain/regen/regen.d.ts.map +1 -1
  122. package/lib/chain/regen/regen.js +7 -17
  123. package/lib/chain/regen/regen.js.map +1 -1
  124. package/lib/chain/seenCache/index.d.ts +3 -1
  125. package/lib/chain/seenCache/index.d.ts.map +1 -1
  126. package/lib/chain/seenCache/index.js +3 -1
  127. package/lib/chain/seenCache/index.js.map +1 -1
  128. package/lib/chain/seenCache/seenAttesters.d.ts +5 -0
  129. package/lib/chain/seenCache/seenAttesters.d.ts.map +1 -1
  130. package/lib/chain/seenCache/seenAttesters.js +5 -0
  131. package/lib/chain/seenCache/seenAttesters.js.map +1 -1
  132. package/lib/chain/seenCache/seenExecutionPayloadBids.d.ts +12 -0
  133. package/lib/chain/seenCache/seenExecutionPayloadBids.d.ts.map +1 -0
  134. package/lib/chain/seenCache/seenExecutionPayloadBids.js +30 -0
  135. package/lib/chain/seenCache/seenExecutionPayloadBids.js.map +1 -0
  136. package/lib/chain/seenCache/seenExecutionPayloadEnvelope.d.ts +15 -0
  137. package/lib/chain/seenCache/seenExecutionPayloadEnvelope.d.ts.map +1 -0
  138. package/lib/chain/seenCache/seenExecutionPayloadEnvelope.js +28 -0
  139. package/lib/chain/seenCache/seenExecutionPayloadEnvelope.js.map +1 -0
  140. package/lib/chain/seenCache/seenGossipBlockInput.js +1 -1
  141. package/lib/chain/stateCache/index.d.ts +0 -2
  142. package/lib/chain/stateCache/index.d.ts.map +1 -1
  143. package/lib/chain/stateCache/index.js +0 -2
  144. package/lib/chain/stateCache/index.js.map +1 -1
  145. package/lib/chain/stateCache/persistentCheckpointsCache.d.ts +2 -1
  146. package/lib/chain/stateCache/persistentCheckpointsCache.d.ts.map +1 -1
  147. package/lib/chain/stateCache/persistentCheckpointsCache.js +3 -0
  148. package/lib/chain/stateCache/persistentCheckpointsCache.js.map +1 -1
  149. package/lib/chain/validation/aggregateAndProof.js +35 -14
  150. package/lib/chain/validation/aggregateAndProof.js.map +1 -1
  151. package/lib/chain/validation/attestation.d.ts +2 -2
  152. package/lib/chain/validation/attestation.d.ts.map +1 -1
  153. package/lib/chain/validation/attestation.js +27 -8
  154. package/lib/chain/validation/attestation.js.map +1 -1
  155. package/lib/chain/validation/attesterSlashing.d.ts.map +1 -1
  156. package/lib/chain/validation/attesterSlashing.js +1 -1
  157. package/lib/chain/validation/attesterSlashing.js.map +1 -1
  158. package/lib/chain/validation/blobSidecar.d.ts.map +1 -1
  159. package/lib/chain/validation/blobSidecar.js +3 -3
  160. package/lib/chain/validation/blobSidecar.js.map +1 -1
  161. package/lib/chain/validation/block.d.ts.map +1 -1
  162. package/lib/chain/validation/block.js +6 -6
  163. package/lib/chain/validation/block.js.map +1 -1
  164. package/lib/chain/validation/dataColumnSidecar.d.ts.map +1 -1
  165. package/lib/chain/validation/dataColumnSidecar.js +3 -3
  166. package/lib/chain/validation/dataColumnSidecar.js.map +1 -1
  167. package/lib/chain/validation/executionPayloadBid.d.ts +5 -0
  168. package/lib/chain/validation/executionPayloadBid.d.ts.map +1 -0
  169. package/lib/chain/validation/executionPayloadBid.js +104 -0
  170. package/lib/chain/validation/executionPayloadBid.js.map +1 -0
  171. package/lib/chain/validation/executionPayloadEnvelope.d.ts +5 -0
  172. package/lib/chain/validation/executionPayloadEnvelope.d.ts.map +1 -0
  173. package/lib/chain/validation/executionPayloadEnvelope.js +89 -0
  174. package/lib/chain/validation/executionPayloadEnvelope.js.map +1 -0
  175. package/lib/chain/validation/payloadAttestationMessage.d.ts +9 -0
  176. package/lib/chain/validation/payloadAttestationMessage.d.ts.map +1 -0
  177. package/lib/chain/validation/payloadAttestationMessage.js +72 -0
  178. package/lib/chain/validation/payloadAttestationMessage.js.map +1 -0
  179. package/lib/chain/validation/proposerSlashing.js +1 -1
  180. package/lib/chain/validation/proposerSlashing.js.map +1 -1
  181. package/lib/chain/validation/signatureSets/aggregateAndProof.d.ts +2 -3
  182. package/lib/chain/validation/signatureSets/aggregateAndProof.d.ts.map +1 -1
  183. package/lib/chain/validation/signatureSets/aggregateAndProof.js +8 -3
  184. package/lib/chain/validation/signatureSets/aggregateAndProof.js.map +1 -1
  185. package/lib/chain/validation/signatureSets/contributionAndProof.d.ts +2 -2
  186. package/lib/chain/validation/signatureSets/contributionAndProof.d.ts.map +1 -1
  187. package/lib/chain/validation/signatureSets/contributionAndProof.js +3 -3
  188. package/lib/chain/validation/signatureSets/contributionAndProof.js.map +1 -1
  189. package/lib/chain/validation/signatureSets/selectionProof.d.ts +2 -3
  190. package/lib/chain/validation/signatureSets/selectionProof.d.ts.map +1 -1
  191. package/lib/chain/validation/signatureSets/selectionProof.js +8 -3
  192. package/lib/chain/validation/signatureSets/selectionProof.js.map +1 -1
  193. package/lib/chain/validation/signatureSets/syncCommittee.d.ts +2 -2
  194. package/lib/chain/validation/signatureSets/syncCommittee.d.ts.map +1 -1
  195. package/lib/chain/validation/signatureSets/syncCommittee.js +3 -3
  196. package/lib/chain/validation/signatureSets/syncCommittee.js.map +1 -1
  197. package/lib/chain/validation/signatureSets/syncCommitteeContribution.d.ts +1 -2
  198. package/lib/chain/validation/signatureSets/syncCommitteeContribution.d.ts.map +1 -1
  199. package/lib/chain/validation/signatureSets/syncCommitteeContribution.js +2 -2
  200. package/lib/chain/validation/signatureSets/syncCommitteeContribution.js.map +1 -1
  201. package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.d.ts +2 -2
  202. package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.d.ts.map +1 -1
  203. package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.js +3 -3
  204. package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.js.map +1 -1
  205. package/lib/chain/validation/syncCommittee.js +1 -1
  206. package/lib/chain/validation/syncCommittee.js.map +1 -1
  207. package/lib/chain/validation/syncCommitteeContributionAndProof.d.ts.map +1 -1
  208. package/lib/chain/validation/syncCommitteeContributionAndProof.js +3 -5
  209. package/lib/chain/validation/syncCommitteeContributionAndProof.js.map +1 -1
  210. package/lib/chain/validation/voluntaryExit.js +1 -1
  211. package/lib/chain/validation/voluntaryExit.js.map +1 -1
  212. package/lib/chain/validatorMonitor.d.ts +2 -0
  213. package/lib/chain/validatorMonitor.d.ts.map +1 -1
  214. package/lib/chain/validatorMonitor.js +49 -7
  215. package/lib/chain/validatorMonitor.js.map +1 -1
  216. package/lib/db/repositories/checkpointState.js +0 -1
  217. package/lib/db/repositories/checkpointState.js.map +1 -1
  218. package/lib/metrics/metrics/lodestar.d.ts +27 -0
  219. package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
  220. package/lib/metrics/metrics/lodestar.js +64 -0
  221. package/lib/metrics/metrics/lodestar.js.map +1 -1
  222. package/lib/network/gossip/gossipsub.d.ts +19 -0
  223. package/lib/network/gossip/gossipsub.d.ts.map +1 -1
  224. package/lib/network/gossip/gossipsub.js +71 -0
  225. package/lib/network/gossip/gossipsub.js.map +1 -1
  226. package/lib/network/gossip/interface.d.ts +20 -2
  227. package/lib/network/gossip/interface.d.ts.map +1 -1
  228. package/lib/network/gossip/interface.js +3 -0
  229. package/lib/network/gossip/interface.js.map +1 -1
  230. package/lib/network/gossip/scoringParameters.d.ts.map +1 -1
  231. package/lib/network/gossip/scoringParameters.js +38 -2
  232. package/lib/network/gossip/scoringParameters.js.map +1 -1
  233. package/lib/network/gossip/topic.d.ts +77 -1
  234. package/lib/network/gossip/topic.d.ts.map +1 -1
  235. package/lib/network/gossip/topic.js +20 -0
  236. package/lib/network/gossip/topic.js.map +1 -1
  237. package/lib/network/options.d.ts +6 -0
  238. package/lib/network/options.d.ts.map +1 -1
  239. package/lib/network/options.js.map +1 -1
  240. package/lib/network/peers/peerManager.d.ts.map +1 -1
  241. package/lib/network/peers/peerManager.js +9 -0
  242. package/lib/network/peers/peerManager.js.map +1 -1
  243. package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
  244. package/lib/network/processor/gossipHandlers.js +35 -4
  245. package/lib/network/processor/gossipHandlers.js.map +1 -1
  246. package/lib/network/processor/gossipQueues/index.d.ts.map +1 -1
  247. package/lib/network/processor/gossipQueues/index.js +16 -0
  248. package/lib/network/processor/gossipQueues/index.js.map +1 -1
  249. package/lib/network/processor/index.d.ts.map +1 -1
  250. package/lib/network/processor/index.js +3 -0
  251. package/lib/network/processor/index.js.map +1 -1
  252. package/lib/network/reqresp/handlers/beaconBlocksByRange.d.ts.map +1 -1
  253. package/lib/network/reqresp/handlers/beaconBlocksByRange.js +2 -4
  254. package/lib/network/reqresp/handlers/beaconBlocksByRange.js.map +1 -1
  255. package/lib/network/reqresp/handlers/beaconBlocksByRoot.d.ts +1 -2
  256. package/lib/network/reqresp/handlers/beaconBlocksByRoot.d.ts.map +1 -1
  257. package/lib/network/reqresp/handlers/beaconBlocksByRoot.js +5 -26
  258. package/lib/network/reqresp/handlers/beaconBlocksByRoot.js.map +1 -1
  259. package/lib/network/reqresp/handlers/blobSidecarsByRoot.d.ts +1 -2
  260. package/lib/network/reqresp/handlers/blobSidecarsByRoot.d.ts.map +1 -1
  261. package/lib/network/reqresp/handlers/blobSidecarsByRoot.js +5 -7
  262. package/lib/network/reqresp/handlers/blobSidecarsByRoot.js.map +1 -1
  263. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.d.ts.map +1 -1
  264. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js +1 -2
  265. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js.map +1 -1
  266. package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.d.ts.map +1 -1
  267. package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.js +1 -5
  268. package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.js.map +1 -1
  269. package/lib/network/reqresp/handlers/index.js +2 -2
  270. package/lib/network/reqresp/handlers/index.js.map +1 -1
  271. package/lib/sync/backfill/backfill.js +2 -2
  272. package/lib/sync/backfill/backfill.js.map +1 -1
  273. package/lib/sync/backfill/verify.d.ts +1 -2
  274. package/lib/sync/backfill/verify.d.ts.map +1 -1
  275. package/lib/sync/backfill/verify.js +2 -2
  276. package/lib/sync/backfill/verify.js.map +1 -1
  277. package/lib/sync/range/chain.d.ts.map +1 -1
  278. package/lib/sync/range/chain.js +0 -1
  279. package/lib/sync/range/chain.js.map +1 -1
  280. package/lib/sync/range/range.d.ts.map +1 -1
  281. package/lib/sync/range/range.js +0 -3
  282. package/lib/sync/range/range.js.map +1 -1
  283. package/lib/sync/unknownBlock.d.ts.map +1 -1
  284. package/lib/sync/unknownBlock.js +0 -3
  285. package/lib/sync/unknownBlock.js.map +1 -1
  286. package/package.json +15 -15
  287. package/src/api/impl/beacon/blocks/index.ts +17 -25
  288. package/src/api/impl/debug/index.ts +2 -6
  289. package/src/api/impl/lodestar/index.ts +18 -3
  290. package/src/api/impl/validator/index.ts +14 -12
  291. package/src/chain/ColumnReconstructionTracker.ts +8 -4
  292. package/src/chain/archiveStore/utils/archiveBlocks.ts +4 -0
  293. package/src/chain/blocks/blockInput/blockInput.ts +53 -2
  294. package/src/chain/blocks/importBlock.ts +3 -7
  295. package/src/chain/blocks/index.ts +0 -19
  296. package/src/chain/blocks/types.ts +0 -2
  297. package/src/chain/blocks/verifyBlock.ts +0 -9
  298. package/src/chain/blocks/verifyBlocksSignatures.ts +4 -12
  299. package/src/chain/blocks/writeBlockInputToDb.ts +33 -30
  300. package/src/chain/bls/multithread/index.ts +7 -4
  301. package/src/chain/bls/multithread/jobItem.ts +7 -3
  302. package/src/chain/bls/singleThread.ts +5 -3
  303. package/src/chain/bls/utils.ts +15 -7
  304. package/src/chain/chain.ts +227 -56
  305. package/src/chain/errors/attestationError.ts +11 -1
  306. package/src/chain/errors/executionPayloadBid.ts +35 -0
  307. package/src/chain/errors/executionPayloadEnvelope.ts +34 -0
  308. package/src/chain/errors/index.ts +3 -0
  309. package/src/chain/errors/payloadAttestation.ts +25 -0
  310. package/src/chain/forkChoice/index.ts +19 -0
  311. package/src/chain/interface.ts +32 -1
  312. package/src/chain/opPools/executionPayloadBidPool.ts +77 -0
  313. package/src/chain/opPools/index.ts +2 -0
  314. package/src/chain/opPools/payloadAttestationPool.ts +157 -0
  315. package/src/chain/options.ts +0 -2
  316. package/src/chain/prepareNextSlot.ts +6 -6
  317. package/src/chain/produceBlock/produceBlockBody.ts +7 -5
  318. package/src/chain/regen/interface.ts +3 -13
  319. package/src/chain/regen/queued.ts +3 -24
  320. package/src/chain/regen/regen.ts +10 -25
  321. package/src/chain/seenCache/index.ts +3 -1
  322. package/src/chain/seenCache/seenAttesters.ts +5 -0
  323. package/src/chain/seenCache/seenExecutionPayloadBids.ts +35 -0
  324. package/src/chain/seenCache/seenExecutionPayloadEnvelope.ts +34 -0
  325. package/src/chain/seenCache/seenGossipBlockInput.ts +1 -1
  326. package/src/chain/stateCache/index.ts +0 -2
  327. package/src/chain/stateCache/persistentCheckpointsCache.ts +6 -2
  328. package/src/chain/validation/aggregateAndProof.ts +36 -14
  329. package/src/chain/validation/attestation.ts +33 -16
  330. package/src/chain/validation/attesterSlashing.ts +1 -6
  331. package/src/chain/validation/blobSidecar.ts +2 -7
  332. package/src/chain/validation/block.ts +6 -6
  333. package/src/chain/validation/dataColumnSidecar.ts +2 -7
  334. package/src/chain/validation/executionPayloadBid.ts +141 -0
  335. package/src/chain/validation/executionPayloadEnvelope.ts +122 -0
  336. package/src/chain/validation/payloadAttestationMessage.ts +109 -0
  337. package/src/chain/validation/proposerSlashing.ts +1 -6
  338. package/src/chain/validation/signatureSets/aggregateAndProof.ts +9 -14
  339. package/src/chain/validation/signatureSets/contributionAndProof.ts +2 -4
  340. package/src/chain/validation/signatureSets/selectionProof.ts +9 -9
  341. package/src/chain/validation/signatureSets/syncCommittee.ts +2 -4
  342. package/src/chain/validation/signatureSets/syncCommitteeContribution.ts +2 -3
  343. package/src/chain/validation/signatureSets/syncCommitteeSelectionProof.ts +2 -4
  344. package/src/chain/validation/syncCommittee.ts +1 -1
  345. package/src/chain/validation/syncCommitteeContributionAndProof.ts +3 -5
  346. package/src/chain/validation/voluntaryExit.ts +1 -1
  347. package/src/chain/validatorMonitor.ts +62 -8
  348. package/src/db/repositories/checkpointState.ts +1 -1
  349. package/src/metrics/metrics/lodestar.ts +65 -0
  350. package/src/network/gossip/gossipsub.ts +86 -1
  351. package/src/network/gossip/interface.ts +17 -0
  352. package/src/network/gossip/scoringParameters.ts +44 -2
  353. package/src/network/gossip/topic.ts +21 -0
  354. package/src/network/options.ts +6 -0
  355. package/src/network/peers/peerManager.ts +11 -0
  356. package/src/network/processor/gossipHandlers.ts +49 -4
  357. package/src/network/processor/gossipQueues/index.ts +16 -0
  358. package/src/network/processor/index.ts +3 -0
  359. package/src/network/reqresp/handlers/beaconBlocksByRange.ts +2 -4
  360. package/src/network/reqresp/handlers/beaconBlocksByRoot.ts +5 -32
  361. package/src/network/reqresp/handlers/blobSidecarsByRoot.ts +5 -9
  362. package/src/network/reqresp/handlers/dataColumnSidecarsByRange.ts +5 -2
  363. package/src/network/reqresp/handlers/dataColumnSidecarsByRoot.ts +1 -5
  364. package/src/network/reqresp/handlers/index.ts +2 -2
  365. package/src/sync/backfill/backfill.ts +2 -2
  366. package/src/sync/backfill/verify.ts +2 -3
  367. package/src/sync/range/chain.ts +0 -1
  368. package/src/sync/range/range.ts +0 -3
  369. package/src/sync/unknownBlock.ts +0 -3
  370. package/lib/chain/stateCache/blockStateCacheImpl.d.ts +0 -54
  371. package/lib/chain/stateCache/blockStateCacheImpl.d.ts.map +0 -1
  372. package/lib/chain/stateCache/blockStateCacheImpl.js +0 -130
  373. package/lib/chain/stateCache/blockStateCacheImpl.js.map +0 -1
  374. package/lib/chain/stateCache/inMemoryCheckpointsCache.d.ts +0 -60
  375. package/lib/chain/stateCache/inMemoryCheckpointsCache.d.ts.map +0 -1
  376. package/lib/chain/stateCache/inMemoryCheckpointsCache.js +0 -156
  377. package/lib/chain/stateCache/inMemoryCheckpointsCache.js.map +0 -1
  378. package/src/chain/stateCache/blockStateCacheImpl.ts +0 -149
  379. package/src/chain/stateCache/inMemoryCheckpointsCache.ts +0 -192
@@ -30,7 +30,7 @@ import {
30
30
  isDenebBlockContents,
31
31
  sszTypesFor,
32
32
  } from "@lodestar/types";
33
- import {fromAsync, fromHex, sleep, toHex, toRootHex} from "@lodestar/utils";
33
+ import {fromHex, sleep, toHex, toRootHex} from "@lodestar/utils";
34
34
  import {BlockInputSource, isBlockInputBlobs, isBlockInputColumns} from "../../../../chain/blocks/blockInput/index.js";
35
35
  import {ImportBlockOpts} from "../../../../chain/blocks/types.js";
36
36
  import {verifyBlocksInEpoch} from "../../../../chain/blocks/verifyBlock.js";
@@ -285,7 +285,7 @@ export function getBeaconBlockApi({
285
285
  () =>
286
286
  // there is no rush to persist block since we published it to gossip anyway
287
287
  chain
288
- .processBlock(blockForImport, {...opts, eagerPersistBlock: false})
288
+ .processBlock(blockForImport, opts)
289
289
  .catch((e) => {
290
290
  if (e instanceof BlockError && e.type.code === BlockErrorCode.PARENT_UNKNOWN) {
291
291
  chain.emitter.emit(ChainEvent.unknownParent, {
@@ -434,11 +434,13 @@ export function getBeaconBlockApi({
434
434
  const nonFinalizedBlocks = chain.forkChoice.getBlockSummariesByParentRoot(parentRoot);
435
435
  await Promise.all(
436
436
  nonFinalizedBlocks.map(async (summary) => {
437
- const block = await db.block.get(fromHex(summary.blockRoot));
438
- if (block) {
439
- const canonical = chain.forkChoice.getCanonicalBlockAtSlot(block.message.slot);
437
+ const blockResult = await chain.getBlockByRoot(summary.blockRoot);
438
+ if (blockResult) {
439
+ const canonical = chain.forkChoice.getCanonicalBlockAtSlot(blockResult.block.message.slot);
440
440
  if (canonical) {
441
- result.push(toBeaconHeaderResponse(config, block, canonical.blockRoot === summary.blockRoot));
441
+ result.push(
442
+ toBeaconHeaderResponse(config, blockResult.block, canonical.blockRoot === summary.blockRoot)
443
+ );
442
444
  if (isOptimisticBlock(canonical)) {
443
445
  executionOptimistic = true;
444
446
  }
@@ -492,9 +494,9 @@ export function getBeaconBlockApi({
492
494
  finalized = false;
493
495
 
494
496
  if (summary.blockRoot !== toRootHex(canonicalRoot)) {
495
- const block = await db.block.get(fromHex(summary.blockRoot));
496
- if (block) {
497
- result.push(toBeaconHeaderResponse(config, block));
497
+ const blockResult = await chain.getBlockByRoot(summary.blockRoot);
498
+ if (blockResult) {
499
+ result.push(toBeaconHeaderResponse(config, blockResult.block));
498
500
  }
499
501
  }
500
502
  })
@@ -626,6 +628,7 @@ export function getBeaconBlockApi({
626
628
  const {block, executionOptimistic, finalized} = await getBlockResponse(chain, blockId);
627
629
  const fork = config.getForkName(block.message.slot);
628
630
  const blockRoot = sszTypesFor(fork).BeaconBlock.hashTreeRoot(block.message);
631
+ const blockRootHex = toRootHex(blockRoot);
629
632
 
630
633
  let data: deneb.BlobSidecars;
631
634
 
@@ -642,10 +645,7 @@ export function getBeaconBlockApi({
642
645
  const blobCount = blobKzgCommitments.length;
643
646
 
644
647
  if (blobCount > 0) {
645
- let dataColumnSidecars = await fromAsync(db.dataColumnSidecar.valuesStream(blockRoot));
646
- if (dataColumnSidecars.length === 0) {
647
- dataColumnSidecars = await fromAsync(db.dataColumnSidecarArchive.valuesStream(block.message.slot));
648
- }
648
+ const dataColumnSidecars = await chain.getDataColumnSidecars(block.message.slot, blockRootHex);
649
649
 
650
650
  if (dataColumnSidecars.length === 0) {
651
651
  throw new ApiError(
@@ -682,10 +682,7 @@ export function getBeaconBlockApi({
682
682
  data = [];
683
683
  }
684
684
  } else if (isForkPostDeneb(fork)) {
685
- let {blobSidecars} = (await db.blobSidecars.get(blockRoot)) ?? {};
686
- if (!blobSidecars) {
687
- ({blobSidecars} = (await db.blobSidecarsArchive.get(block.message.slot)) ?? {});
688
- }
685
+ const blobSidecars = await chain.getBlobSidecars(block.message.slot, blockRootHex);
689
686
 
690
687
  if (!blobSidecars) {
691
688
  throw new ApiError(
@@ -715,6 +712,7 @@ export function getBeaconBlockApi({
715
712
  const {block, executionOptimistic, finalized} = await getBlockResponse(chain, blockId);
716
713
  const fork = config.getForkName(block.message.slot);
717
714
  const blockRoot = sszTypesFor(fork).BeaconBlock.hashTreeRoot(block.message);
715
+ const blockRootHex = toRootHex(blockRoot);
718
716
 
719
717
  let blobs: deneb.Blobs;
720
718
 
@@ -731,10 +729,7 @@ export function getBeaconBlockApi({
731
729
  const blobCount = blobKzgCommitments.length;
732
730
 
733
731
  if (blobCount > 0) {
734
- let dataColumnSidecars = await fromAsync(db.dataColumnSidecar.valuesStream(blockRoot));
735
- if (dataColumnSidecars.length === 0) {
736
- dataColumnSidecars = await fromAsync(db.dataColumnSidecarArchive.valuesStream(block.message.slot));
737
- }
732
+ const dataColumnSidecars = await chain.getDataColumnSidecars(block.message.slot, blockRootHex);
738
733
 
739
734
  if (dataColumnSidecars.length === 0) {
740
735
  throw new ApiError(
@@ -766,10 +761,7 @@ export function getBeaconBlockApi({
766
761
  blobs = [];
767
762
  }
768
763
  } else if (isForkPostDeneb(fork)) {
769
- let {blobSidecars} = (await db.blobSidecars.get(blockRoot)) ?? {};
770
- if (!blobSidecars) {
771
- ({blobSidecars} = (await db.blobSidecarsArchive.get(block.message.slot)) ?? {});
772
- }
764
+ const blobSidecars = await chain.getBlobSidecars(block.message.slot, blockRootHex);
773
765
 
774
766
  if (!blobSidecars) {
775
767
  throw new ApiError(
@@ -3,7 +3,7 @@ import {ApplicationMethods} from "@lodestar/api/server";
3
3
  import {ExecutionStatus} from "@lodestar/fork-choice";
4
4
  import {ZERO_HASH_HEX, isForkPostDeneb, isForkPostFulu} from "@lodestar/params";
5
5
  import {BeaconState, deneb, fulu, sszTypesFor} from "@lodestar/types";
6
- import {fromAsync, toRootHex} from "@lodestar/utils";
6
+ import {toRootHex} from "@lodestar/utils";
7
7
  import {isOptimisticBlock} from "../../../util/forkChoice.js";
8
8
  import {getStateSlotFromBytes} from "../../../util/multifork.js";
9
9
  import {getBlockResponse} from "../beacon/blocks/utils.js";
@@ -14,7 +14,6 @@ import {assertUniqueItems} from "../utils.js";
14
14
  export function getDebugApi({
15
15
  chain,
16
16
  config,
17
- db,
18
17
  }: Pick<ApiModules, "chain" | "config" | "db">): ApplicationMethods<routes.debug.Endpoints> {
19
18
  return {
20
19
  async getDebugChainHeadsV2() {
@@ -104,10 +103,7 @@ export function getDebugApi({
104
103
  : 0;
105
104
 
106
105
  if (isForkPostFulu(fork) && blobCount > 0) {
107
- dataColumnSidecars = await fromAsync(db.dataColumnSidecar.valuesStream(blockRoot));
108
- if (dataColumnSidecars.length === 0) {
109
- dataColumnSidecars = await fromAsync(db.dataColumnSidecarArchive.valuesStream(block.message.slot));
110
- }
106
+ dataColumnSidecars = await chain.getDataColumnSidecars(block.message.slot, toRootHex(blockRoot));
111
107
 
112
108
  if (dataColumnSidecars.length === 0) {
113
109
  throw Error(
@@ -238,6 +238,24 @@ export function getLodestarApi({
238
238
  },
239
239
  };
240
240
  },
241
+
242
+ async getMonitoredValidatorIndices() {
243
+ return {
244
+ data: chain.validatorMonitor?.getMonitoredValidatorIndices() ?? [],
245
+ };
246
+ },
247
+
248
+ async getCustodyInfo() {
249
+ const {custodyColumns, targetCustodyGroupCount} = chain.custodyConfig;
250
+
251
+ return {
252
+ data: {
253
+ earliestCustodiedSlot: chain.earliestAvailableSlot,
254
+ custodyGroupCount: targetCustodyGroupCount,
255
+ custodyColumns,
256
+ },
257
+ };
258
+ },
241
259
  };
242
260
  }
243
261
 
@@ -249,9 +267,6 @@ function regenRequestToJson(config: ChainForkConfig, regenRequest: RegenRequest)
249
267
  slot: regenRequest.args[1],
250
268
  };
251
269
 
252
- case "getCheckpointState":
253
- return ssz.phase0.Checkpoint.toJson(regenRequest.args[0]);
254
-
255
270
  case "getPreState": {
256
271
  const slot = regenRequest.args[0].slot;
257
272
  return {
@@ -1,7 +1,7 @@
1
1
  import {PubkeyIndexMap} from "@chainsafe/pubkey-index-map";
2
2
  import {routes} from "@lodestar/api";
3
3
  import {ApplicationMethods} from "@lodestar/api/server";
4
- import {ExecutionStatus} from "@lodestar/fork-choice";
4
+ import {ExecutionStatus, ProtoBlock} from "@lodestar/fork-choice";
5
5
  import {
6
6
  ForkName,
7
7
  ForkPostBellatrix,
@@ -67,10 +67,11 @@ import {
67
67
  SyncCommitteeError,
68
68
  SyncCommitteeErrorCode,
69
69
  } from "../../../chain/errors/index.js";
70
- import {ChainEvent, CheckpointHex, CommonBlockBody} from "../../../chain/index.js";
70
+ import {ChainEvent, CommonBlockBody} from "../../../chain/index.js";
71
71
  import {PREPARE_NEXT_SLOT_BPS} from "../../../chain/prepareNextSlot.js";
72
72
  import {BlockType, ProduceFullDeneb} from "../../../chain/produceBlock/index.js";
73
73
  import {RegenCaller} from "../../../chain/regen/index.js";
74
+ import {CheckpointHex} from "../../../chain/stateCache/types.js";
74
75
  import {validateApiAggregateAndProof} from "../../../chain/validation/index.js";
75
76
  import {validateSyncCommitteeGossipContributionAndProof} from "../../../chain/validation/syncCommitteeContributionAndProof.js";
76
77
  import {ZERO_HASH} from "../../../constants/index.js";
@@ -413,10 +414,10 @@ export function getValidatorApi(
413
414
  // as of now fee recipient checks can not be performed because builder does not return bid recipient
414
415
  {
415
416
  commonBlockBodyPromise,
416
- parentBlockRoot,
417
+ parentBlock,
417
418
  }: Omit<routes.validator.ExtraProduceBlockOpts, "builderSelection"> & {
418
419
  commonBlockBodyPromise: Promise<CommonBlockBody>;
419
- parentBlockRoot: Root;
420
+ parentBlock: ProtoBlock;
420
421
  }
421
422
  ): Promise<ProduceBlindedBlockRes> {
422
423
  const version = config.getForkName(slot);
@@ -447,7 +448,7 @@ export function getValidatorApi(
447
448
  timer = metrics?.blockProductionTime.startTimer();
448
449
  const {block, executionPayloadValue, consensusBlockValue} = await chain.produceBlindedBlock({
449
450
  slot,
450
- parentBlockRoot,
451
+ parentBlock,
451
452
  randaoReveal,
452
453
  graffiti,
453
454
  commonBlockBodyPromise,
@@ -482,10 +483,10 @@ export function getValidatorApi(
482
483
  feeRecipient,
483
484
  strictFeeRecipientCheck,
484
485
  commonBlockBodyPromise,
485
- parentBlockRoot,
486
+ parentBlock,
486
487
  }: Omit<routes.validator.ExtraProduceBlockOpts, "builderSelection"> & {
487
488
  commonBlockBodyPromise: Promise<CommonBlockBody>;
488
- parentBlockRoot: Root;
489
+ parentBlock: ProtoBlock;
489
490
  }
490
491
  ): Promise<ProduceBlockContentsRes & {shouldOverrideBuilder?: boolean}> {
491
492
  const source = ProducedBlockSource.engine;
@@ -496,7 +497,7 @@ export function getValidatorApi(
496
497
  timer = metrics?.blockProductionTime.startTimer();
497
498
  const {block, executionPayloadValue, consensusBlockValue, shouldOverrideBuilder} = await chain.produceBlock({
498
499
  slot,
499
- parentBlockRoot,
500
+ parentBlock,
500
501
  randaoReveal,
501
502
  graffiti,
502
503
  feeRecipient,
@@ -569,7 +570,8 @@ export function getValidatorApi(
569
570
  notWhileSyncing();
570
571
  await waitForSlot(slot); // Must never request for a future slot > currentSlot
571
572
 
572
- const {blockRoot: parentBlockRootHex, slot: parentSlot} = chain.getProposerHead(slot);
573
+ const parentBlock = chain.getProposerHead(slot);
574
+ const {blockRoot: parentBlockRootHex, slot: parentSlot} = parentBlock;
573
575
  const parentBlockRoot = fromHex(parentBlockRootHex);
574
576
  notOnOutOfRangeData(parentBlockRoot);
575
577
  metrics?.blockProductionSlotDelta.set(slot - parentSlot);
@@ -638,7 +640,7 @@ export function getValidatorApi(
638
640
  // can't do fee recipient checks as builder bid doesn't return feeRecipient as of now
639
641
  strictFeeRecipientCheck: false,
640
642
  commonBlockBodyPromise,
641
- parentBlockRoot,
643
+ parentBlock,
642
644
  })
643
645
  : Promise.reject(new Error("Builder disabled"));
644
646
 
@@ -647,7 +649,7 @@ export function getValidatorApi(
647
649
  feeRecipient,
648
650
  strictFeeRecipientCheck,
649
651
  commonBlockBodyPromise,
650
- parentBlockRoot,
652
+ parentBlock,
651
653
  }).then((engineBlock) => {
652
654
  // Once the engine returns a block, in the event of either:
653
655
  // - suspected builder censorship
@@ -689,7 +691,7 @@ export function getValidatorApi(
689
691
  chain
690
692
  .produceCommonBlockBody({
691
693
  slot,
692
- parentBlockRoot,
694
+ parentBlock,
693
695
  randaoReveal,
694
696
  graffiti: graffitiBytes,
695
697
  })
@@ -8,12 +8,12 @@ import {ChainEventEmitter} from "./emitter.js";
8
8
  /**
9
9
  * Minimum time to wait before attempting reconstruction
10
10
  */
11
- const RECONSTRUCTION_DELAY_MIN_MS = 800;
11
+ const RECONSTRUCTION_DELAY_MIN_BPS = 667;
12
12
 
13
13
  /**
14
14
  * Maximum time to wait before attempting reconstruction
15
15
  */
16
- const RECONSTRUCTION_DELAY_MAX_MS = 1200;
16
+ const RECONSTRUCTION_DELAY_MAX_BPS = 1000;
17
17
 
18
18
  export type ColumnReconstructionTrackerInit = {
19
19
  logger: Logger;
@@ -41,11 +41,16 @@ export class ColumnReconstructionTracker {
41
41
  /** Track if a reconstruction attempt is in-flight */
42
42
  running = false;
43
43
 
44
+ private readonly minDelayMs: number;
45
+ private readonly maxDelayMs: number;
46
+
44
47
  constructor(init: ColumnReconstructionTrackerInit) {
45
48
  this.logger = init.logger;
46
49
  this.emitter = init.emitter;
47
50
  this.metrics = init.metrics;
48
51
  this.config = init.config;
52
+ this.minDelayMs = this.config.getSlotComponentDurationMs(RECONSTRUCTION_DELAY_MIN_BPS);
53
+ this.maxDelayMs = this.config.getSlotComponentDurationMs(RECONSTRUCTION_DELAY_MAX_BPS);
49
54
  }
50
55
 
51
56
  triggerColumnReconstruction(blockInput: BlockInputColumns): void {
@@ -61,8 +66,7 @@ export class ColumnReconstructionTracker {
61
66
  // just that it has been triggered for this block root.
62
67
  this.running = true;
63
68
  this.lastBlockRootHex = blockInput.blockRootHex;
64
- const delay =
65
- RECONSTRUCTION_DELAY_MIN_MS + Math.random() * (RECONSTRUCTION_DELAY_MAX_MS - RECONSTRUCTION_DELAY_MIN_MS);
69
+ const delay = this.minDelayMs + Math.random() * (this.maxDelayMs - this.minDelayMs);
66
70
  sleep(delay)
67
71
  .then(() => {
68
72
  const logCtx = {slot: blockInput.slot, root: blockInput.blockRootHex};
@@ -238,6 +238,7 @@ async function migrateBlocksFromHotToColdDb(db: IBeaconDb, blocks: BlockRootSlot
238
238
  // load Buffer instead of SignedBeaconBlock to improve performance
239
239
  const canonicalBlockEntries: BlockArchiveBatchPutBinaryItem[] = await Promise.all(
240
240
  canonicalBlocks.map(async (block) => {
241
+ // Here we assume the blocks are already in the hot db
241
242
  const blockBuffer = await db.block.getBinary(block.root);
242
243
  if (!blockBuffer) {
243
244
  throw Error(`Block not found for slot ${block.slot} root ${toRootHex(block.root)}`);
@@ -294,6 +295,8 @@ async function migrateBlobSidecarsFromHotToColdDb(
294
295
  );
295
296
  })
296
297
  .map(async (block) => {
298
+ // Here we assume the blob sidecars are already in the hot db
299
+ // instead of checking first the block input cache
297
300
  const bytes = await db.blobSidecars.getBinary(block.root);
298
301
  if (!bytes) {
299
302
  throw Error(`No blobSidecars found for slot ${block.slot} root ${toRootHex(block.root)}`);
@@ -343,6 +346,7 @@ async function migrateDataColumnSidecarsFromHotToColdDb(
343
346
  continue;
344
347
  }
345
348
 
349
+ // Here we assume the data column sidecars are already in the hot db
346
350
  const dataColumnSidecarBytes = await fromAsync(db.dataColumnSidecar.valuesStreamBinary(block.root));
347
351
  // there could be 0 dataColumnSidecarBytes if block has no blob
348
352
  logger.verbose("migrateDataColumnSidecarsFromHotToColdDb", {
@@ -1,4 +1,4 @@
1
- import {ForkName, ForkPostFulu, ForkPreDeneb, ForkPreGloas} from "@lodestar/params";
1
+ import {ForkName, ForkPostFulu, ForkPreDeneb, ForkPreGloas, NUMBER_OF_COLUMNS} from "@lodestar/params";
2
2
  import {BeaconBlockBody, BlobIndex, ColumnIndex, SignedBeaconBlock, Slot, deneb, fulu} from "@lodestar/types";
3
3
  import {fromHex, prettyBytes, toRootHex, withTimeout} from "@lodestar/utils";
4
4
  import {VersionedHashes} from "../../../execution/index.js";
@@ -412,6 +412,10 @@ export class BlockInputBlobs extends AbstractBlockInput<ForkBlobsDA, deneb.BlobS
412
412
  return this.blobsCache.has(blobIndex);
413
413
  }
414
414
 
415
+ getBlob(blobIndex: BlobIndex): deneb.BlobSidecar | undefined {
416
+ return this.blobsCache.get(blobIndex)?.blobSidecar;
417
+ }
418
+
415
419
  addBlob(
416
420
  {blockRootHex, blobSidecar, source, peerIdStr, seenTimestampSec}: AddBlob,
417
421
  opts = {throwOnDuplicateAdd: true}
@@ -557,6 +561,7 @@ type BlockInputColumnsState =
557
561
  | {
558
562
  hasBlock: true;
559
563
  hasAllData: true;
564
+ hasComputedAllData: boolean;
560
565
  versionedHashes: VersionedHashes;
561
566
  block: SignedBeaconBlock<ForkColumnsDA>;
562
567
  source: SourceMeta;
@@ -565,6 +570,7 @@ type BlockInputColumnsState =
565
570
  | {
566
571
  hasBlock: true;
567
572
  hasAllData: false;
573
+ hasComputedAllData: false;
568
574
  versionedHashes: VersionedHashes;
569
575
  block: SignedBeaconBlock<ForkColumnsDA>;
570
576
  source: SourceMeta;
@@ -572,11 +578,13 @@ type BlockInputColumnsState =
572
578
  | {
573
579
  hasBlock: false;
574
580
  hasAllData: true;
581
+ hasComputedAllData: boolean;
575
582
  versionedHashes: VersionedHashes;
576
583
  }
577
584
  | {
578
585
  hasBlock: false;
579
586
  hasAllData: false;
587
+ hasComputedAllData: false;
580
588
  versionedHashes: VersionedHashes;
581
589
  };
582
590
  /**
@@ -594,6 +602,12 @@ export class BlockInputColumns extends AbstractBlockInput<ForkColumnsDA, fulu.Da
594
602
  private columnsCache = new Map<ColumnIndex, ColumnWithSource>();
595
603
  private readonly sampledColumns: ColumnIndex[];
596
604
  private readonly custodyColumns: ColumnIndex[];
605
+ /**
606
+ * This promise resolves when all sampled columns are available
607
+ *
608
+ * This is different from `dataPromise` which resolves when all data is available or could become available (e.g. through reconstruction)
609
+ */
610
+ protected computedDataPromise = createPromise<fulu.DataColumnSidecars>();
597
611
 
598
612
  private constructor(
599
613
  init: BlockInputInit,
@@ -622,6 +636,7 @@ export class BlockInputColumns extends AbstractBlockInput<ForkColumnsDA, fulu.Da
622
636
  const state = {
623
637
  hasBlock: true,
624
638
  hasAllData,
639
+ hasComputedAllData: hasAllData,
625
640
  versionedHashes: props.block.message.body.blobKzgCommitments.map(kzgCommitmentToVersionedHash),
626
641
  block: props.block,
627
642
  source: {
@@ -645,6 +660,7 @@ export class BlockInputColumns extends AbstractBlockInput<ForkColumnsDA, fulu.Da
645
660
  blockInput.blockPromise.resolve(props.block);
646
661
  if (hasAllData) {
647
662
  blockInput.dataPromise.resolve([]);
663
+ blockInput.computedDataPromise.resolve([]);
648
664
  }
649
665
  return blockInput;
650
666
  }
@@ -657,6 +673,7 @@ export class BlockInputColumns extends AbstractBlockInput<ForkColumnsDA, fulu.Da
657
673
  const state: BlockInputColumnsState = {
658
674
  hasBlock: false,
659
675
  hasAllData,
676
+ hasComputedAllData: hasAllData as false,
660
677
  versionedHashes: props.columnSidecar.kzgCommitments.map(kzgCommitmentToVersionedHash),
661
678
  };
662
679
  const init: BlockInputInit = {
@@ -670,6 +687,7 @@ export class BlockInputColumns extends AbstractBlockInput<ForkColumnsDA, fulu.Da
670
687
  const blockInput = new BlockInputColumns(init, state, props.sampledColumns, props.custodyColumns);
671
688
  if (hasAllData) {
672
689
  blockInput.dataPromise.resolve([]);
690
+ blockInput.computedDataPromise.resolve([]);
673
691
  }
674
692
  return blockInput;
675
693
  }
@@ -718,11 +736,14 @@ export class BlockInputColumns extends AbstractBlockInput<ForkColumnsDA, fulu.Da
718
736
  const hasAllData =
719
737
  (props.block.message.body as BeaconBlockBody<ForkPostFulu & ForkPreGloas>).blobKzgCommitments.length === 0 ||
720
738
  this.state.hasAllData;
739
+ const hasComputedAllData =
740
+ props.block.message.body.blobKzgCommitments.length === 0 || this.state.hasComputedAllData;
721
741
 
722
742
  this.state = {
723
743
  ...this.state,
724
744
  hasBlock: true,
725
745
  hasAllData,
746
+ hasComputedAllData,
726
747
  block: props.block,
727
748
  source: {
728
749
  source: props.source,
@@ -770,23 +791,42 @@ export class BlockInputColumns extends AbstractBlockInput<ForkColumnsDA, fulu.Da
770
791
  this.columnsCache.set(columnSidecar.index, {columnSidecar, source, seenTimestampSec, peerIdStr});
771
792
 
772
793
  const sampledColumns = this.getSampledColumns();
773
- const hasAllData = this.state.hasAllData || sampledColumns.length === this.sampledColumns.length;
794
+ const hasAllData =
795
+ // already hasAllData
796
+ this.state.hasAllData ||
797
+ // has all sampled columns
798
+ sampledColumns.length === this.sampledColumns.length ||
799
+ // has enough columns to reconstruct the rest
800
+ this.columnsCache.size >= NUMBER_OF_COLUMNS / 2;
801
+
802
+ const hasComputedAllData =
803
+ // has all sampled columns
804
+ sampledColumns.length === this.sampledColumns.length;
774
805
 
775
806
  this.state = {
776
807
  ...this.state,
777
808
  hasAllData: hasAllData || this.state.hasAllData,
809
+ hasComputedAllData: hasComputedAllData || this.state.hasComputedAllData,
778
810
  timeCompleteSec: hasAllData ? seenTimestampSec : undefined,
779
811
  } as BlockInputColumnsState;
780
812
 
781
813
  if (hasAllData && sampledColumns !== null) {
782
814
  this.dataPromise.resolve(sampledColumns);
783
815
  }
816
+
817
+ if (hasComputedAllData && sampledColumns !== null) {
818
+ this.computedDataPromise.resolve(sampledColumns);
819
+ }
784
820
  }
785
821
 
786
822
  hasColumn(columnIndex: number): boolean {
787
823
  return this.columnsCache.has(columnIndex);
788
824
  }
789
825
 
826
+ getColumn(columnIndex: number): fulu.DataColumnSidecar | undefined {
827
+ return this.columnsCache.get(columnIndex)?.columnSidecar;
828
+ }
829
+
790
830
  getVersionedHashes(): VersionedHashes {
791
831
  return this.state.versionedHashes;
792
832
  }
@@ -851,4 +891,15 @@ export class BlockInputColumns extends AbstractBlockInput<ForkColumnsDA, fulu.Da
851
891
  versionedHashes: this.state.versionedHashes,
852
892
  };
853
893
  }
894
+
895
+ hasComputedAllData(): boolean {
896
+ return this.state.hasComputedAllData;
897
+ }
898
+
899
+ waitForComputedAllData(timeout: number, signal?: AbortSignal): Promise<fulu.DataColumnSidecars> {
900
+ if (!this.state.hasComputedAllData) {
901
+ return withTimeout(() => this.computedDataPromise.promise, timeout, signal);
902
+ }
903
+ return Promise.resolve(this.getSampledColumns());
904
+ }
854
905
  }
@@ -30,11 +30,10 @@ import type {BeaconChain} from "../chain.js";
30
30
  import {ChainEvent, ReorgEventData} from "../emitter.js";
31
31
  import {ForkchoiceCaller} from "../forkChoice/index.js";
32
32
  import {REPROCESS_MIN_TIME_TO_NEXT_SLOT_SEC} from "../reprocess.js";
33
- import {toCheckpointHex} from "../stateCache/index.js";
33
+ import {toCheckpointHex} from "../stateCache/persistentCheckpointsCache.js";
34
34
  import {isBlockInputBlobs, isBlockInputColumns} from "./blockInput/blockInput.js";
35
35
  import {AttestationImportOpt, FullyVerifiedBlock, ImportBlockOpts} from "./types.js";
36
36
  import {getCheckpointFromState} from "./utils/checkpoint.js";
37
- import {writeBlockInputToDb} from "./writeBlockInputToDb.js";
38
37
 
39
38
  /**
40
39
  * Fork-choice allows to import attestations from current (0) or past (1) epoch.
@@ -91,11 +90,8 @@ export async function importBlock(
91
90
  throw Error("Unavailable block can not be imported in forkchoice");
92
91
  }
93
92
 
94
- // 1. Persist block to hot DB (pre-emptively)
95
- // If eagerPersistBlock = true we do that in verifyBlocksInEpoch to batch all I/O operations to save block time to head
96
- if (!opts.eagerPersistBlock) {
97
- await writeBlockInputToDb.call(this, [blockInput]);
98
- }
93
+ // 1. Persist block to hot DB (performed asynchronously to avoid blocking head selection)
94
+ void this.unfinalizedBlockWrites.push([blockInput]);
99
95
 
100
96
  // Without forcefully clearing this cache, we would rely on WeakMap to evict memory which is not reliable
101
97
  this.serializedCache.clear();
@@ -11,7 +11,6 @@ import {FullyVerifiedBlock, ImportBlockOpts} from "./types.js";
11
11
  import {assertLinearChainSegment} from "./utils/chainSegment.js";
12
12
  import {verifyBlocksInEpoch} from "./verifyBlock.js";
13
13
  import {verifyBlocksSanityChecks} from "./verifyBlocksSanityChecks.js";
14
- import {removeEagerlyPersistedBlockInputs} from "./writeBlockInputToDb.js";
15
14
 
16
15
  export {AttestationImportOpt, type ImportBlockOpts} from "./types.js";
17
16
 
@@ -143,24 +142,6 @@ export async function processBlocks(
143
142
  }
144
143
  }
145
144
 
146
- // Clean db if we don't have blocks in forkchoice but already persisted them to db
147
- //
148
- // NOTE: this function is awaited to ensure that DB size remains constant, otherwise an attacker may bloat the
149
- // disk with big malicious payloads. Our sequential block importer will wait for this promise before importing
150
- // another block. The removal call error is not propagated since that would halt the chain.
151
- //
152
- // LOG: Because the error is not propagated and there's a risk of db bloat, the error is logged at warn level
153
- // to alert the user of potential db bloat. This error _should_ never happen user must act and report to us
154
- if (opts.eagerPersistBlock) {
155
- await removeEagerlyPersistedBlockInputs.call(this, blocks).catch((e) => {
156
- this.logger.warn(
157
- "Error pruning eagerly imported block inputs, DB may grow in size if this error happens frequently",
158
- {slot: blocks.map((block) => block.getBlock().message.slot).join(",")},
159
- e
160
- );
161
- });
162
- }
163
-
164
145
  throw err;
165
146
  }
166
147
  }
@@ -78,8 +78,6 @@ export type ImportBlockOpts = {
78
78
  validBlobSidecars?: BlobSidecarValidation;
79
79
  /** Seen timestamp seconds */
80
80
  seenTimestampSec?: number;
81
- /** Set to true if persist block right at verification time */
82
- eagerPersistBlock?: boolean;
83
81
  };
84
82
 
85
83
  /**
@@ -21,7 +21,6 @@ import {verifyBlocksDataAvailability} from "./verifyBlocksDataAvailability.js";
21
21
  import {SegmentExecStatus, verifyBlocksExecutionPayload} from "./verifyBlocksExecutionPayloads.js";
22
22
  import {verifyBlocksSignatures} from "./verifyBlocksSignatures.js";
23
23
  import {verifyBlocksStateTransitionOnly} from "./verifyBlocksStateTransitionOnly.js";
24
- import {writeBlockInputToDb} from "./writeBlockInputToDb.js";
25
24
 
26
25
  /**
27
26
  * Verifies 1 or more blocks are fully valid; from a linear sequence of blocks.
@@ -146,7 +145,6 @@ export async function verifyBlocksInEpoch(
146
145
  opts.skipVerifyBlockSignatures !== true
147
146
  ? verifyBlocksSignatures(
148
147
  this.config,
149
- this.index2pubkey,
150
148
  this.bls,
151
149
  this.logger,
152
150
  this.metrics,
@@ -156,13 +154,6 @@ export async function verifyBlocksInEpoch(
156
154
  opts
157
155
  )
158
156
  : Promise.resolve({verifySignaturesTime: Date.now()}),
159
-
160
- // ideally we want to only persist blocks after verifying them however the reality is there are
161
- // rarely invalid blocks we'll batch all I/O operation here to reduce the overhead if there's
162
- // an error, we'll remove blocks not in forkchoice
163
- opts.verifyOnly !== true && opts.eagerPersistBlock
164
- ? writeBlockInputToDb.call(this, blockInputs)
165
- : Promise.resolve(),
166
157
  ]);
167
158
 
168
159
  if (opts.verifyOnly !== true) {
@@ -1,5 +1,5 @@
1
1
  import {BeaconConfig} from "@lodestar/config";
2
- import {CachedBeaconStateAllForks, Index2PubkeyCache, getBlockSignatureSets} from "@lodestar/state-transition";
2
+ import {CachedBeaconStateAllForks, getBlockSignatureSets} from "@lodestar/state-transition";
3
3
  import {IndexedAttestation, SignedBeaconBlock} from "@lodestar/types";
4
4
  import {Logger} from "@lodestar/utils";
5
5
  import {Metrics} from "../../metrics/metrics.js";
@@ -17,7 +17,6 @@ import {ImportBlockOpts} from "./types.js";
17
17
  */
18
18
  export async function verifyBlocksSignatures(
19
19
  config: BeaconConfig,
20
- index2pubkey: Index2PubkeyCache,
21
20
  bls: IBlsVerifier,
22
21
  logger: Logger,
23
22
  metrics: Metrics | null,
@@ -42,16 +41,9 @@ export async function verifyBlocksSignatures(
42
41
  : //
43
42
  // Verify signatures per block to track which block is invalid
44
43
  bls.verifySignatureSets(
45
- getBlockSignatureSets(
46
- config,
47
- index2pubkey,
48
- currentSyncCommitteeIndexed,
49
- block,
50
- indexedAttestationsByBlock[i],
51
- {
52
- skipProposerSignature: opts.validProposerSignature,
53
- }
54
- )
44
+ getBlockSignatureSets(config, currentSyncCommitteeIndexed, block, indexedAttestationsByBlock[i], {
45
+ skipProposerSignature: opts.validProposerSignature,
46
+ })
55
47
  );
56
48
 
57
49
  // getBlockSignatureSets() takes 45ms in benchmarks for 2022Q2 mainnet blocks (100 sigs). When syncing a 32 blocks