@lodestar/beacon-node 1.40.0-dev.3715a82f3f → 1.40.0-dev.45b04262dc

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 (440) 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/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 +29 -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/api/rest/base.d.ts.map +1 -1
  15. package/lib/api/rest/base.js +12 -10
  16. package/lib/api/rest/base.js.map +1 -1
  17. package/lib/chain/ColumnReconstructionTracker.d.ts +2 -0
  18. package/lib/chain/ColumnReconstructionTracker.d.ts.map +1 -1
  19. package/lib/chain/ColumnReconstructionTracker.js +7 -3
  20. package/lib/chain/ColumnReconstructionTracker.js.map +1 -1
  21. package/lib/chain/archiveStore/historicalState/getHistoricalState.d.ts.map +1 -1
  22. package/lib/chain/archiveStore/historicalState/getHistoricalState.js +2 -1
  23. package/lib/chain/archiveStore/historicalState/getHistoricalState.js.map +1 -1
  24. package/lib/chain/archiveStore/utils/archiveBlocks.d.ts.map +1 -1
  25. package/lib/chain/archiveStore/utils/archiveBlocks.js +4 -0
  26. package/lib/chain/archiveStore/utils/archiveBlocks.js.map +1 -1
  27. package/lib/chain/blocks/blockInput/blockInput.d.ts +30 -0
  28. package/lib/chain/blocks/blockInput/blockInput.d.ts.map +1 -1
  29. package/lib/chain/blocks/blockInput/blockInput.js +44 -3
  30. package/lib/chain/blocks/blockInput/blockInput.js.map +1 -1
  31. package/lib/chain/blocks/importBlock.d.ts.map +1 -1
  32. package/lib/chain/blocks/importBlock.js +3 -7
  33. package/lib/chain/blocks/importBlock.js.map +1 -1
  34. package/lib/chain/blocks/index.d.ts.map +1 -1
  35. package/lib/chain/blocks/index.js +0 -14
  36. package/lib/chain/blocks/index.js.map +1 -1
  37. package/lib/chain/blocks/types.d.ts +0 -2
  38. package/lib/chain/blocks/types.d.ts.map +1 -1
  39. package/lib/chain/blocks/verifyBlock.d.ts.map +1 -1
  40. package/lib/chain/blocks/verifyBlock.js +1 -8
  41. package/lib/chain/blocks/verifyBlock.js.map +1 -1
  42. package/lib/chain/blocks/verifyBlocksSignatures.d.ts +2 -2
  43. package/lib/chain/blocks/verifyBlocksSignatures.d.ts.map +1 -1
  44. package/lib/chain/blocks/verifyBlocksSignatures.js +2 -2
  45. package/lib/chain/blocks/verifyBlocksSignatures.js.map +1 -1
  46. package/lib/chain/blocks/verifyBlocksStateTransitionOnly.d.ts.map +1 -1
  47. package/lib/chain/blocks/verifyBlocksStateTransitionOnly.js +1 -2
  48. package/lib/chain/blocks/verifyBlocksStateTransitionOnly.js.map +1 -1
  49. package/lib/chain/blocks/writeBlockInputToDb.d.ts +1 -4
  50. package/lib/chain/blocks/writeBlockInputToDb.d.ts.map +1 -1
  51. package/lib/chain/blocks/writeBlockInputToDb.js +28 -28
  52. package/lib/chain/blocks/writeBlockInputToDb.js.map +1 -1
  53. package/lib/chain/bls/multithread/index.d.ts +3 -1
  54. package/lib/chain/bls/multithread/index.d.ts.map +1 -1
  55. package/lib/chain/bls/multithread/index.js +5 -3
  56. package/lib/chain/bls/multithread/index.js.map +1 -1
  57. package/lib/chain/bls/multithread/jobItem.d.ts +2 -2
  58. package/lib/chain/bls/multithread/jobItem.d.ts.map +1 -1
  59. package/lib/chain/bls/multithread/jobItem.js +2 -2
  60. package/lib/chain/bls/multithread/jobItem.js.map +1 -1
  61. package/lib/chain/bls/singleThread.d.ts +4 -2
  62. package/lib/chain/bls/singleThread.d.ts.map +1 -1
  63. package/lib/chain/bls/singleThread.js +4 -2
  64. package/lib/chain/bls/singleThread.js.map +1 -1
  65. package/lib/chain/bls/utils.d.ts +2 -2
  66. package/lib/chain/bls/utils.d.ts.map +1 -1
  67. package/lib/chain/bls/utils.js +9 -6
  68. package/lib/chain/bls/utils.js.map +1 -1
  69. package/lib/chain/chain.d.ts +22 -5
  70. package/lib/chain/chain.d.ts.map +1 -1
  71. package/lib/chain/chain.js +197 -44
  72. package/lib/chain/chain.js.map +1 -1
  73. package/lib/chain/errors/attestationError.d.ts +14 -1
  74. package/lib/chain/errors/attestationError.d.ts.map +1 -1
  75. package/lib/chain/errors/attestationError.js +8 -0
  76. package/lib/chain/errors/attestationError.js.map +1 -1
  77. package/lib/chain/errors/executionPayloadBid.d.ts +48 -0
  78. package/lib/chain/errors/executionPayloadBid.d.ts.map +1 -0
  79. package/lib/chain/errors/executionPayloadBid.js +15 -0
  80. package/lib/chain/errors/executionPayloadBid.js.map +1 -0
  81. package/lib/chain/errors/executionPayloadEnvelope.d.ts +48 -0
  82. package/lib/chain/errors/executionPayloadEnvelope.d.ts.map +1 -0
  83. package/lib/chain/errors/executionPayloadEnvelope.js +16 -0
  84. package/lib/chain/errors/executionPayloadEnvelope.js.map +1 -0
  85. package/lib/chain/errors/index.d.ts +3 -0
  86. package/lib/chain/errors/index.d.ts.map +1 -1
  87. package/lib/chain/errors/index.js +3 -0
  88. package/lib/chain/errors/index.js.map +1 -1
  89. package/lib/chain/errors/payloadAttestation.d.ts +34 -0
  90. package/lib/chain/errors/payloadAttestation.d.ts.map +1 -0
  91. package/lib/chain/errors/payloadAttestation.js +13 -0
  92. package/lib/chain/errors/payloadAttestation.js.map +1 -0
  93. package/lib/chain/forkChoice/index.d.ts.map +1 -1
  94. package/lib/chain/forkChoice/index.js +18 -0
  95. package/lib/chain/forkChoice/index.js.map +1 -1
  96. package/lib/chain/initState.d.ts.map +1 -1
  97. package/lib/chain/initState.js +2 -2
  98. package/lib/chain/initState.js.map +1 -1
  99. package/lib/chain/interface.d.ts +21 -3
  100. package/lib/chain/interface.d.ts.map +1 -1
  101. package/lib/chain/interface.js.map +1 -1
  102. package/lib/chain/lightClient/index.d.ts.map +1 -1
  103. package/lib/chain/lightClient/index.js +1 -2
  104. package/lib/chain/lightClient/index.js.map +1 -1
  105. package/lib/chain/opPools/executionPayloadBidPool.d.ts +21 -0
  106. package/lib/chain/opPools/executionPayloadBidPool.d.ts.map +1 -0
  107. package/lib/chain/opPools/executionPayloadBidPool.js +57 -0
  108. package/lib/chain/opPools/executionPayloadBidPool.js.map +1 -0
  109. package/lib/chain/opPools/index.d.ts +2 -0
  110. package/lib/chain/opPools/index.d.ts.map +1 -1
  111. package/lib/chain/opPools/index.js +2 -0
  112. package/lib/chain/opPools/index.js.map +1 -1
  113. package/lib/chain/opPools/payloadAttestationPool.d.ts +24 -0
  114. package/lib/chain/opPools/payloadAttestationPool.d.ts.map +1 -0
  115. package/lib/chain/opPools/payloadAttestationPool.js +109 -0
  116. package/lib/chain/opPools/payloadAttestationPool.js.map +1 -0
  117. package/lib/chain/options.d.ts +0 -1
  118. package/lib/chain/options.d.ts.map +1 -1
  119. package/lib/chain/options.js +0 -1
  120. package/lib/chain/options.js.map +1 -1
  121. package/lib/chain/prepareNextSlot.js +6 -4
  122. package/lib/chain/prepareNextSlot.js.map +1 -1
  123. package/lib/chain/produceBlock/produceBlockBody.d.ts +3 -2
  124. package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
  125. package/lib/chain/produceBlock/produceBlockBody.js +5 -3
  126. package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
  127. package/lib/chain/regen/interface.d.ts +4 -9
  128. package/lib/chain/regen/interface.d.ts.map +1 -1
  129. package/lib/chain/regen/interface.js +1 -1
  130. package/lib/chain/regen/interface.js.map +1 -1
  131. package/lib/chain/regen/queued.d.ts +2 -3
  132. package/lib/chain/regen/queued.d.ts.map +1 -1
  133. package/lib/chain/regen/queued.js +2 -16
  134. package/lib/chain/regen/queued.js.map +1 -1
  135. package/lib/chain/regen/regen.d.ts +5 -7
  136. package/lib/chain/regen/regen.d.ts.map +1 -1
  137. package/lib/chain/regen/regen.js +7 -17
  138. package/lib/chain/regen/regen.js.map +1 -1
  139. package/lib/chain/seenCache/index.d.ts +3 -1
  140. package/lib/chain/seenCache/index.d.ts.map +1 -1
  141. package/lib/chain/seenCache/index.js +3 -1
  142. package/lib/chain/seenCache/index.js.map +1 -1
  143. package/lib/chain/seenCache/seenAttesters.d.ts +5 -0
  144. package/lib/chain/seenCache/seenAttesters.d.ts.map +1 -1
  145. package/lib/chain/seenCache/seenAttesters.js +5 -0
  146. package/lib/chain/seenCache/seenAttesters.js.map +1 -1
  147. package/lib/chain/seenCache/seenExecutionPayloadBids.d.ts +12 -0
  148. package/lib/chain/seenCache/seenExecutionPayloadBids.d.ts.map +1 -0
  149. package/lib/chain/seenCache/seenExecutionPayloadBids.js +30 -0
  150. package/lib/chain/seenCache/seenExecutionPayloadBids.js.map +1 -0
  151. package/lib/chain/seenCache/seenExecutionPayloadEnvelope.d.ts +15 -0
  152. package/lib/chain/seenCache/seenExecutionPayloadEnvelope.d.ts.map +1 -0
  153. package/lib/chain/seenCache/seenExecutionPayloadEnvelope.js +28 -0
  154. package/lib/chain/seenCache/seenExecutionPayloadEnvelope.js.map +1 -0
  155. package/lib/chain/seenCache/seenGossipBlockInput.d.ts.map +1 -1
  156. package/lib/chain/seenCache/seenGossipBlockInput.js +3 -3
  157. package/lib/chain/seenCache/seenGossipBlockInput.js.map +1 -1
  158. package/lib/chain/serializeState.d.ts.map +1 -1
  159. package/lib/chain/serializeState.js +2 -1
  160. package/lib/chain/serializeState.js.map +1 -1
  161. package/lib/chain/stateCache/index.d.ts +0 -2
  162. package/lib/chain/stateCache/index.d.ts.map +1 -1
  163. package/lib/chain/stateCache/index.js +0 -2
  164. package/lib/chain/stateCache/index.js.map +1 -1
  165. package/lib/chain/stateCache/persistentCheckpointsCache.d.ts +2 -1
  166. package/lib/chain/stateCache/persistentCheckpointsCache.d.ts.map +1 -1
  167. package/lib/chain/stateCache/persistentCheckpointsCache.js +3 -0
  168. package/lib/chain/stateCache/persistentCheckpointsCache.js.map +1 -1
  169. package/lib/chain/validation/aggregateAndProof.js +35 -14
  170. package/lib/chain/validation/aggregateAndProof.js.map +1 -1
  171. package/lib/chain/validation/attestation.d.ts +2 -2
  172. package/lib/chain/validation/attestation.d.ts.map +1 -1
  173. package/lib/chain/validation/attestation.js +27 -8
  174. package/lib/chain/validation/attestation.js.map +1 -1
  175. package/lib/chain/validation/attesterSlashing.d.ts.map +1 -1
  176. package/lib/chain/validation/attesterSlashing.js +1 -1
  177. package/lib/chain/validation/attesterSlashing.js.map +1 -1
  178. package/lib/chain/validation/blobSidecar.d.ts.map +1 -1
  179. package/lib/chain/validation/blobSidecar.js +5 -5
  180. package/lib/chain/validation/blobSidecar.js.map +1 -1
  181. package/lib/chain/validation/block.d.ts.map +1 -1
  182. package/lib/chain/validation/block.js +6 -6
  183. package/lib/chain/validation/block.js.map +1 -1
  184. package/lib/chain/validation/dataColumnSidecar.d.ts.map +1 -1
  185. package/lib/chain/validation/dataColumnSidecar.js +5 -5
  186. package/lib/chain/validation/dataColumnSidecar.js.map +1 -1
  187. package/lib/chain/validation/executionPayloadBid.d.ts +5 -0
  188. package/lib/chain/validation/executionPayloadBid.d.ts.map +1 -0
  189. package/lib/chain/validation/executionPayloadBid.js +104 -0
  190. package/lib/chain/validation/executionPayloadBid.js.map +1 -0
  191. package/lib/chain/validation/executionPayloadEnvelope.d.ts +5 -0
  192. package/lib/chain/validation/executionPayloadEnvelope.d.ts.map +1 -0
  193. package/lib/chain/validation/executionPayloadEnvelope.js +89 -0
  194. package/lib/chain/validation/executionPayloadEnvelope.js.map +1 -0
  195. package/lib/chain/validation/payloadAttestationMessage.d.ts +9 -0
  196. package/lib/chain/validation/payloadAttestationMessage.d.ts.map +1 -0
  197. package/lib/chain/validation/payloadAttestationMessage.js +72 -0
  198. package/lib/chain/validation/payloadAttestationMessage.js.map +1 -0
  199. package/lib/chain/validation/proposerSlashing.js +1 -1
  200. package/lib/chain/validation/proposerSlashing.js.map +1 -1
  201. package/lib/chain/validation/signatureSets/aggregateAndProof.d.ts +2 -3
  202. package/lib/chain/validation/signatureSets/aggregateAndProof.d.ts.map +1 -1
  203. package/lib/chain/validation/signatureSets/aggregateAndProof.js +8 -3
  204. package/lib/chain/validation/signatureSets/aggregateAndProof.js.map +1 -1
  205. package/lib/chain/validation/signatureSets/contributionAndProof.d.ts +2 -2
  206. package/lib/chain/validation/signatureSets/contributionAndProof.d.ts.map +1 -1
  207. package/lib/chain/validation/signatureSets/contributionAndProof.js +3 -3
  208. package/lib/chain/validation/signatureSets/contributionAndProof.js.map +1 -1
  209. package/lib/chain/validation/signatureSets/selectionProof.d.ts +2 -3
  210. package/lib/chain/validation/signatureSets/selectionProof.d.ts.map +1 -1
  211. package/lib/chain/validation/signatureSets/selectionProof.js +8 -3
  212. package/lib/chain/validation/signatureSets/selectionProof.js.map +1 -1
  213. package/lib/chain/validation/signatureSets/syncCommittee.d.ts +2 -2
  214. package/lib/chain/validation/signatureSets/syncCommittee.d.ts.map +1 -1
  215. package/lib/chain/validation/signatureSets/syncCommittee.js +3 -3
  216. package/lib/chain/validation/signatureSets/syncCommittee.js.map +1 -1
  217. package/lib/chain/validation/signatureSets/syncCommitteeContribution.d.ts +1 -2
  218. package/lib/chain/validation/signatureSets/syncCommitteeContribution.d.ts.map +1 -1
  219. package/lib/chain/validation/signatureSets/syncCommitteeContribution.js +2 -2
  220. package/lib/chain/validation/signatureSets/syncCommitteeContribution.js.map +1 -1
  221. package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.d.ts +2 -2
  222. package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.d.ts.map +1 -1
  223. package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.js +3 -3
  224. package/lib/chain/validation/signatureSets/syncCommitteeSelectionProof.js.map +1 -1
  225. package/lib/chain/validation/syncCommittee.js +1 -1
  226. package/lib/chain/validation/syncCommittee.js.map +1 -1
  227. package/lib/chain/validation/syncCommitteeContributionAndProof.d.ts.map +1 -1
  228. package/lib/chain/validation/syncCommitteeContributionAndProof.js +3 -5
  229. package/lib/chain/validation/syncCommitteeContributionAndProof.js.map +1 -1
  230. package/lib/chain/validation/voluntaryExit.js +1 -1
  231. package/lib/chain/validation/voluntaryExit.js.map +1 -1
  232. package/lib/chain/validatorMonitor.d.ts +2 -0
  233. package/lib/chain/validatorMonitor.d.ts.map +1 -1
  234. package/lib/chain/validatorMonitor.js +49 -7
  235. package/lib/chain/validatorMonitor.js.map +1 -1
  236. package/lib/db/repositories/checkpointState.js +0 -1
  237. package/lib/db/repositories/checkpointState.js.map +1 -1
  238. package/lib/metrics/metrics/lodestar.d.ts +27 -0
  239. package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
  240. package/lib/metrics/metrics/lodestar.js +64 -0
  241. package/lib/metrics/metrics/lodestar.js.map +1 -1
  242. package/lib/network/core/networkCore.d.ts +3 -0
  243. package/lib/network/core/networkCore.d.ts.map +1 -1
  244. package/lib/network/core/networkCore.js +9 -0
  245. package/lib/network/core/networkCore.js.map +1 -1
  246. package/lib/network/core/networkCoreWorker.js +3 -0
  247. package/lib/network/core/networkCoreWorker.js.map +1 -1
  248. package/lib/network/core/networkCoreWorkerHandler.d.ts +3 -0
  249. package/lib/network/core/networkCoreWorkerHandler.d.ts.map +1 -1
  250. package/lib/network/core/networkCoreWorkerHandler.js +9 -0
  251. package/lib/network/core/networkCoreWorkerHandler.js.map +1 -1
  252. package/lib/network/core/types.d.ts +3 -0
  253. package/lib/network/core/types.d.ts.map +1 -1
  254. package/lib/network/gossip/gossipsub.d.ts +34 -0
  255. package/lib/network/gossip/gossipsub.d.ts.map +1 -1
  256. package/lib/network/gossip/gossipsub.js +123 -0
  257. package/lib/network/gossip/gossipsub.js.map +1 -1
  258. package/lib/network/gossip/interface.d.ts +20 -2
  259. package/lib/network/gossip/interface.d.ts.map +1 -1
  260. package/lib/network/gossip/interface.js +3 -0
  261. package/lib/network/gossip/interface.js.map +1 -1
  262. package/lib/network/gossip/scoringParameters.d.ts.map +1 -1
  263. package/lib/network/gossip/scoringParameters.js +38 -2
  264. package/lib/network/gossip/scoringParameters.js.map +1 -1
  265. package/lib/network/gossip/topic.d.ts +77 -1
  266. package/lib/network/gossip/topic.d.ts.map +1 -1
  267. package/lib/network/gossip/topic.js +20 -0
  268. package/lib/network/gossip/topic.js.map +1 -1
  269. package/lib/network/network.d.ts +3 -0
  270. package/lib/network/network.d.ts.map +1 -1
  271. package/lib/network/network.js +9 -0
  272. package/lib/network/network.js.map +1 -1
  273. package/lib/network/options.d.ts +6 -0
  274. package/lib/network/options.d.ts.map +1 -1
  275. package/lib/network/options.js.map +1 -1
  276. package/lib/network/peers/peerManager.d.ts.map +1 -1
  277. package/lib/network/peers/peerManager.js +9 -0
  278. package/lib/network/peers/peerManager.js.map +1 -1
  279. package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
  280. package/lib/network/processor/gossipHandlers.js +35 -4
  281. package/lib/network/processor/gossipHandlers.js.map +1 -1
  282. package/lib/network/processor/gossipQueues/index.d.ts.map +1 -1
  283. package/lib/network/processor/gossipQueues/index.js +16 -0
  284. package/lib/network/processor/gossipQueues/index.js.map +1 -1
  285. package/lib/network/processor/index.d.ts.map +1 -1
  286. package/lib/network/processor/index.js +3 -0
  287. package/lib/network/processor/index.js.map +1 -1
  288. package/lib/network/reqresp/handlers/beaconBlocksByRange.d.ts.map +1 -1
  289. package/lib/network/reqresp/handlers/beaconBlocksByRange.js +2 -4
  290. package/lib/network/reqresp/handlers/beaconBlocksByRange.js.map +1 -1
  291. package/lib/network/reqresp/handlers/beaconBlocksByRoot.d.ts +1 -2
  292. package/lib/network/reqresp/handlers/beaconBlocksByRoot.d.ts.map +1 -1
  293. package/lib/network/reqresp/handlers/beaconBlocksByRoot.js +5 -26
  294. package/lib/network/reqresp/handlers/beaconBlocksByRoot.js.map +1 -1
  295. package/lib/network/reqresp/handlers/blobSidecarsByRoot.d.ts +1 -2
  296. package/lib/network/reqresp/handlers/blobSidecarsByRoot.d.ts.map +1 -1
  297. package/lib/network/reqresp/handlers/blobSidecarsByRoot.js +5 -7
  298. package/lib/network/reqresp/handlers/blobSidecarsByRoot.js.map +1 -1
  299. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.d.ts.map +1 -1
  300. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js +1 -2
  301. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js.map +1 -1
  302. package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.d.ts.map +1 -1
  303. package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.js +1 -5
  304. package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.js.map +1 -1
  305. package/lib/network/reqresp/handlers/index.js +2 -2
  306. package/lib/network/reqresp/handlers/index.js.map +1 -1
  307. package/lib/sync/backfill/backfill.d.ts.map +1 -1
  308. package/lib/sync/backfill/backfill.js +3 -4
  309. package/lib/sync/backfill/backfill.js.map +1 -1
  310. package/lib/sync/backfill/verify.d.ts +1 -2
  311. package/lib/sync/backfill/verify.d.ts.map +1 -1
  312. package/lib/sync/backfill/verify.js +2 -2
  313. package/lib/sync/backfill/verify.js.map +1 -1
  314. package/lib/sync/range/chain.d.ts.map +1 -1
  315. package/lib/sync/range/chain.js +0 -1
  316. package/lib/sync/range/chain.js.map +1 -1
  317. package/lib/sync/range/range.d.ts.map +1 -1
  318. package/lib/sync/range/range.js +0 -3
  319. package/lib/sync/range/range.js.map +1 -1
  320. package/lib/sync/unknownBlock.d.ts.map +1 -1
  321. package/lib/sync/unknownBlock.js +0 -3
  322. package/lib/sync/unknownBlock.js.map +1 -1
  323. package/lib/sync/utils/downloadByRange.d.ts.map +1 -1
  324. package/lib/sync/utils/downloadByRange.js +2 -2
  325. package/lib/sync/utils/downloadByRange.js.map +1 -1
  326. package/lib/sync/utils/downloadByRoot.d.ts.map +1 -1
  327. package/lib/sync/utils/downloadByRoot.js +1 -2
  328. package/lib/sync/utils/downloadByRoot.js.map +1 -1
  329. package/package.json +16 -16
  330. package/src/api/impl/beacon/blocks/index.ts +39 -37
  331. package/src/api/impl/debug/index.ts +2 -6
  332. package/src/api/impl/lodestar/index.ts +35 -3
  333. package/src/api/impl/validator/index.ts +14 -12
  334. package/src/api/rest/base.ts +15 -13
  335. package/src/chain/ColumnReconstructionTracker.ts +8 -4
  336. package/src/chain/archiveStore/historicalState/getHistoricalState.ts +2 -1
  337. package/src/chain/archiveStore/utils/archiveBlocks.ts +4 -0
  338. package/src/chain/blocks/blockInput/blockInput.ts +55 -4
  339. package/src/chain/blocks/importBlock.ts +3 -7
  340. package/src/chain/blocks/index.ts +0 -19
  341. package/src/chain/blocks/types.ts +0 -2
  342. package/src/chain/blocks/verifyBlock.ts +0 -9
  343. package/src/chain/blocks/verifyBlocksSignatures.ts +4 -12
  344. package/src/chain/blocks/verifyBlocksStateTransitionOnly.ts +1 -2
  345. package/src/chain/blocks/writeBlockInputToDb.ts +33 -30
  346. package/src/chain/bls/multithread/index.ts +7 -4
  347. package/src/chain/bls/multithread/jobItem.ts +7 -3
  348. package/src/chain/bls/singleThread.ts +5 -3
  349. package/src/chain/bls/utils.ts +15 -7
  350. package/src/chain/chain.ts +227 -56
  351. package/src/chain/errors/attestationError.ts +11 -1
  352. package/src/chain/errors/executionPayloadBid.ts +35 -0
  353. package/src/chain/errors/executionPayloadEnvelope.ts +34 -0
  354. package/src/chain/errors/index.ts +3 -0
  355. package/src/chain/errors/payloadAttestation.ts +25 -0
  356. package/src/chain/forkChoice/index.ts +19 -0
  357. package/src/chain/initState.ts +2 -2
  358. package/src/chain/interface.ts +32 -1
  359. package/src/chain/lightClient/index.ts +1 -2
  360. package/src/chain/opPools/executionPayloadBidPool.ts +77 -0
  361. package/src/chain/opPools/index.ts +2 -0
  362. package/src/chain/opPools/payloadAttestationPool.ts +157 -0
  363. package/src/chain/options.ts +0 -2
  364. package/src/chain/prepareNextSlot.ts +6 -6
  365. package/src/chain/produceBlock/produceBlockBody.ts +7 -5
  366. package/src/chain/regen/interface.ts +3 -13
  367. package/src/chain/regen/queued.ts +3 -24
  368. package/src/chain/regen/regen.ts +10 -25
  369. package/src/chain/seenCache/index.ts +3 -1
  370. package/src/chain/seenCache/seenAttesters.ts +5 -0
  371. package/src/chain/seenCache/seenExecutionPayloadBids.ts +35 -0
  372. package/src/chain/seenCache/seenExecutionPayloadEnvelope.ts +34 -0
  373. package/src/chain/seenCache/seenGossipBlockInput.ts +3 -3
  374. package/src/chain/serializeState.ts +2 -1
  375. package/src/chain/stateCache/index.ts +0 -2
  376. package/src/chain/stateCache/persistentCheckpointsCache.ts +6 -2
  377. package/src/chain/validation/aggregateAndProof.ts +36 -14
  378. package/src/chain/validation/attestation.ts +33 -16
  379. package/src/chain/validation/attesterSlashing.ts +1 -6
  380. package/src/chain/validation/blobSidecar.ts +4 -9
  381. package/src/chain/validation/block.ts +6 -6
  382. package/src/chain/validation/dataColumnSidecar.ts +4 -9
  383. package/src/chain/validation/executionPayloadBid.ts +141 -0
  384. package/src/chain/validation/executionPayloadEnvelope.ts +122 -0
  385. package/src/chain/validation/payloadAttestationMessage.ts +109 -0
  386. package/src/chain/validation/proposerSlashing.ts +1 -6
  387. package/src/chain/validation/signatureSets/aggregateAndProof.ts +9 -14
  388. package/src/chain/validation/signatureSets/contributionAndProof.ts +2 -4
  389. package/src/chain/validation/signatureSets/selectionProof.ts +9 -9
  390. package/src/chain/validation/signatureSets/syncCommittee.ts +2 -4
  391. package/src/chain/validation/signatureSets/syncCommitteeContribution.ts +2 -3
  392. package/src/chain/validation/signatureSets/syncCommitteeSelectionProof.ts +2 -4
  393. package/src/chain/validation/syncCommittee.ts +1 -1
  394. package/src/chain/validation/syncCommitteeContributionAndProof.ts +3 -5
  395. package/src/chain/validation/voluntaryExit.ts +1 -1
  396. package/src/chain/validatorMonitor.ts +62 -8
  397. package/src/db/repositories/checkpointState.ts +1 -1
  398. package/src/metrics/metrics/lodestar.ts +65 -0
  399. package/src/network/core/networkCore.ts +12 -0
  400. package/src/network/core/networkCoreWorker.ts +3 -0
  401. package/src/network/core/networkCoreWorkerHandler.ts +9 -0
  402. package/src/network/core/types.ts +6 -0
  403. package/src/network/gossip/gossipsub.ts +147 -1
  404. package/src/network/gossip/interface.ts +17 -0
  405. package/src/network/gossip/scoringParameters.ts +44 -2
  406. package/src/network/gossip/topic.ts +21 -0
  407. package/src/network/network.ts +12 -0
  408. package/src/network/options.ts +6 -0
  409. package/src/network/peers/peerManager.ts +11 -0
  410. package/src/network/processor/gossipHandlers.ts +49 -4
  411. package/src/network/processor/gossipQueues/index.ts +16 -0
  412. package/src/network/processor/index.ts +3 -0
  413. package/src/network/reqresp/handlers/beaconBlocksByRange.ts +2 -4
  414. package/src/network/reqresp/handlers/beaconBlocksByRoot.ts +5 -32
  415. package/src/network/reqresp/handlers/blobSidecarsByRoot.ts +5 -9
  416. package/src/network/reqresp/handlers/dataColumnSidecarsByRange.ts +5 -2
  417. package/src/network/reqresp/handlers/dataColumnSidecarsByRoot.ts +1 -5
  418. package/src/network/reqresp/handlers/index.ts +2 -2
  419. package/src/sync/backfill/backfill.ts +3 -4
  420. package/src/sync/backfill/verify.ts +2 -3
  421. package/src/sync/range/chain.ts +0 -1
  422. package/src/sync/range/range.ts +0 -3
  423. package/src/sync/unknownBlock.ts +0 -3
  424. package/src/sync/utils/downloadByRange.ts +2 -2
  425. package/src/sync/utils/downloadByRoot.ts +1 -2
  426. package/lib/chain/stateCache/blockStateCacheImpl.d.ts +0 -54
  427. package/lib/chain/stateCache/blockStateCacheImpl.d.ts.map +0 -1
  428. package/lib/chain/stateCache/blockStateCacheImpl.js +0 -130
  429. package/lib/chain/stateCache/blockStateCacheImpl.js.map +0 -1
  430. package/lib/chain/stateCache/inMemoryCheckpointsCache.d.ts +0 -60
  431. package/lib/chain/stateCache/inMemoryCheckpointsCache.d.ts.map +0 -1
  432. package/lib/chain/stateCache/inMemoryCheckpointsCache.js +0 -156
  433. package/lib/chain/stateCache/inMemoryCheckpointsCache.js.map +0 -1
  434. package/lib/util/bytes.d.ts +0 -3
  435. package/lib/util/bytes.d.ts.map +0 -1
  436. package/lib/util/bytes.js +0 -11
  437. package/lib/util/bytes.js.map +0 -1
  438. package/src/chain/stateCache/blockStateCacheImpl.ts +0 -149
  439. package/src/chain/stateCache/inMemoryCheckpointsCache.ts +0 -192
  440. package/src/util/bytes.ts +0 -11
@@ -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};
@@ -8,6 +8,7 @@ import {
8
8
  createCachedBeaconState,
9
9
  stateTransition,
10
10
  } from "@lodestar/state-transition";
11
+ import {byteArrayEquals} from "@lodestar/utils";
11
12
  import {IBeaconDb} from "../../../db/index.js";
12
13
  import {getStateTypeFromBytes} from "../../../util/multifork.js";
13
14
  import {HistoricalStateRegenMetrics} from "./metrics.js";
@@ -98,7 +99,7 @@ export async function getHistoricalState(
98
99
  throw e;
99
100
  }
100
101
  blockCount++;
101
- if (Buffer.compare(state.hashTreeRoot(), block.message.stateRoot) !== 0) {
102
+ if (!byteArrayEquals(state.hashTreeRoot(), block.message.stateRoot)) {
102
103
  metrics?.regenErrorCount.inc({reason: RegenErrorType.invalidStateRoot});
103
104
  }
104
105
  }
@@ -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,6 +1,6 @@
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
- import {fromHex, prettyBytes, toRootHex, withTimeout} from "@lodestar/utils";
3
+ import {byteArrayEquals, fromHex, prettyBytes, toRootHex, withTimeout} from "@lodestar/utils";
4
4
  import {VersionedHashes} from "../../../execution/index.js";
5
5
  import {kzgCommitmentToVersionedHash} from "../../../util/blobs.js";
6
6
  import {BlockInputError, BlockInputErrorCode} from "./errors.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}
@@ -525,7 +529,7 @@ function blockAndBlobArePaired(block: SignedBeaconBlock<ForkBlobsDA>, blobSideca
525
529
  if (!blockCommitment || !blobSidecar.kzgCommitment) {
526
530
  return false;
527
531
  }
528
- return Buffer.compare(blockCommitment, blobSidecar.kzgCommitment) === 0;
532
+ return byteArrayEquals(blockCommitment, blobSidecar.kzgCommitment);
529
533
  }
530
534
 
531
535
  function assertBlockAndBlobArePaired(
@@ -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
@@ -5,9 +5,8 @@ import {
5
5
  StateHashTreeRootSource,
6
6
  stateTransition,
7
7
  } from "@lodestar/state-transition";
8
- import {ErrorAborted, Logger} from "@lodestar/utils";
8
+ import {ErrorAborted, Logger, byteArrayEquals} from "@lodestar/utils";
9
9
  import {Metrics} from "../../metrics/index.js";
10
- import {byteArrayEquals} from "../../util/bytes.js";
11
10
  import {nextEventLoop} from "../../util/eventLoop.js";
12
11
  import {BlockError, BlockErrorCode} from "../errors/index.js";
13
12
  import {BlockProcessOpts} from "../options.js";
@@ -44,6 +44,15 @@ export async function writeBlockInputToDb(this: BeaconChain, blocksInputs: IBloc
44
44
 
45
45
  // NOTE: Old data is pruned on archive
46
46
  if (isBlockInputColumns(blockInput)) {
47
+ if (!blockInput.hasComputedAllData()) {
48
+ // Supernodes may only have a subset of the data columns by the time the block begins to be imported
49
+ // because full data availability can be assumed after NUMBER_OF_COLUMNS / 2 columns are available.
50
+ // Here, however, all data columns must be fully available/reconstructed before persisting to the DB.
51
+ await blockInput.waitForComputedAllData(BLOB_AVAILABILITY_TIMEOUT).catch(() => {
52
+ this.logger.debug("Failed to wait for computed all data", {slot, blockRoot: blockRootHex});
53
+ });
54
+ }
55
+
47
56
  const {custodyColumns} = this.custodyConfig;
48
57
  const blobsLen = (block.message as fulu.BeaconBlock).body.blobKzgCommitments.length;
49
58
  let dataColumnsLen: number;
@@ -98,35 +107,29 @@ export async function writeBlockInputToDb(this: BeaconChain, blocksInputs: IBloc
98
107
  }
99
108
  }
100
109
 
101
- /**
102
- * Prunes eagerly persisted block inputs only if not known to the fork-choice
103
- */
104
- export async function removeEagerlyPersistedBlockInputs(this: BeaconChain, blockInputs: IBlockInput[]): Promise<void> {
105
- const blockToRemove = [];
106
- const blobsToRemove = [];
107
- const dataColumnsToRemove = [];
108
-
109
- for (const blockInput of blockInputs) {
110
- const block = blockInput.getBlock();
111
- const slot = block.message.slot;
112
- const blockRoot = this.config.getForkTypes(slot).BeaconBlock.hashTreeRoot(block.message);
113
- const blockRootHex = toRootHex(blockRoot);
114
- if (!this.forkChoice.hasBlockHex(blockRootHex)) {
115
- blockToRemove.push(block);
116
-
117
- if (isBlockInputColumns(blockInput) && blockInput.getCustodyColumns().length > 0) {
118
- dataColumnsToRemove.push(blockRoot);
119
- } else if (isBlockInputBlobs(blockInput)) {
120
- const blobSidecars = blockInput.getBlobs();
121
- blobsToRemove.push({blockRoot, slot, blobSidecars});
110
+ export async function persistBlockInputs(this: BeaconChain, blockInputs: IBlockInput[]): Promise<void> {
111
+ await writeBlockInputToDb
112
+ .call(this, blockInputs)
113
+ .catch((e) => {
114
+ this.logger.debug(
115
+ "Error persisting block input in hot db",
116
+ {
117
+ count: blockInputs.length,
118
+ slot: blockInputs[0].slot,
119
+ root: blockInputs[0].blockRootHex,
120
+ },
121
+ e
122
+ );
123
+ })
124
+ .finally(() => {
125
+ for (const blockInput of blockInputs) {
126
+ this.seenBlockInputCache.prune(blockInput.blockRootHex);
122
127
  }
123
- }
124
- }
125
-
126
- await Promise.all([
127
- // TODO: Batch DB operations not with Promise.all but with level db ops
128
- this.db.block.batchRemove(blockToRemove),
129
- this.db.blobSidecars.batchRemove(blobsToRemove),
130
- this.db.dataColumnSidecar.deleteMany(dataColumnsToRemove),
131
- ]);
128
+ if (blockInputs.length === 1) {
129
+ this.logger.debug("Pruned block input", {
130
+ slot: blockInputs[0].slot,
131
+ root: blockInputs[0].blockRootHex,
132
+ });
133
+ }
134
+ });
132
135
  }
@@ -7,7 +7,7 @@ import {Worker, spawn} from "@chainsafe/threads";
7
7
  self = undefined;
8
8
 
9
9
  import {PublicKey} from "@chainsafe/blst";
10
- import {ISignatureSet} from "@lodestar/state-transition";
10
+ import {ISignatureSet, Index2PubkeyCache} from "@lodestar/state-transition";
11
11
  import {Logger} from "@lodestar/utils";
12
12
  import {Metrics} from "../../../metrics/index.js";
13
13
  import {LinkedList} from "../../../util/array.js";
@@ -34,6 +34,7 @@ const workerDir = process.env.NODE_ENV === "test" ? "../../../../lib/chain/bls/m
34
34
  export type BlsMultiThreadWorkerPoolModules = {
35
35
  logger: Logger;
36
36
  metrics: Metrics | null;
37
+ index2pubkey: Index2PubkeyCache;
37
38
  };
38
39
 
39
40
  export type BlsMultiThreadWorkerPoolOptions = {
@@ -113,6 +114,7 @@ type WorkerDescriptor = {
113
114
  export class BlsMultiThreadWorkerPool implements IBlsVerifier {
114
115
  private readonly logger: Logger;
115
116
  private readonly metrics: Metrics | null;
117
+ private readonly index2pubkey: Index2PubkeyCache;
116
118
 
117
119
  private readonly workers: WorkerDescriptor[];
118
120
  private readonly jobs = new LinkedList<JobQueueItem>();
@@ -128,9 +130,10 @@ export class BlsMultiThreadWorkerPool implements IBlsVerifier {
128
130
  private workersBusy = 0;
129
131
 
130
132
  constructor(options: BlsMultiThreadWorkerPoolOptions, modules: BlsMultiThreadWorkerPoolModules) {
131
- const {logger, metrics} = modules;
133
+ const {logger, metrics, index2pubkey} = modules;
132
134
  this.logger = logger;
133
135
  this.metrics = metrics;
136
+ this.index2pubkey = index2pubkey;
134
137
  this.blsVerifyAllMultiThread = options.blsVerifyAllMultiThread ?? false;
135
138
 
136
139
  // Use compressed for herumi for now.
@@ -170,7 +173,7 @@ export class BlsMultiThreadWorkerPool implements IBlsVerifier {
170
173
  try {
171
174
  return verifySignatureSetsMaybeBatch(
172
175
  sets.map((set) => ({
173
- publicKey: getAggregatedPubkey(set),
176
+ publicKey: getAggregatedPubkey(set, this.index2pubkey),
174
177
  message: set.signingRoot.valueOf(),
175
178
  signature: set.signature,
176
179
  }))
@@ -395,7 +398,7 @@ export class BlsMultiThreadWorkerPool implements IBlsVerifier {
395
398
  try {
396
399
  // Note: This can throw, must be handled per-job.
397
400
  // Pubkey and signature aggregation is defered here
398
- workReq = await jobItemWorkReq(job, this.metrics);
401
+ workReq = await jobItemWorkReq(job, this.index2pubkey, this.metrics);
399
402
  } catch (e) {
400
403
  this.metrics?.blsThreadPool.errorAggregateSignatureSetsCount.inc({type: job.type});
401
404
 
@@ -1,5 +1,5 @@
1
1
  import {PublicKey, asyncAggregateWithRandomness} from "@chainsafe/blst";
2
- import {ISignatureSet, SignatureSetType} from "@lodestar/state-transition";
2
+ import {ISignatureSet, Index2PubkeyCache, SignatureSetType} from "@lodestar/state-transition";
3
3
  import {Metrics} from "../../../metrics/metrics.js";
4
4
  import {LinkedList} from "../../../util/array.js";
5
5
  import {VerifySignatureOpts} from "../interface.js";
@@ -48,14 +48,18 @@ export function jobItemSigSets(job: JobQueueItem): number {
48
48
  * Prepare BlsWorkReq from JobQueueItem
49
49
  * WARNING: May throw with untrusted user input
50
50
  */
51
- export async function jobItemWorkReq(job: JobQueueItem, metrics: Metrics | null): Promise<BlsWorkReq> {
51
+ export async function jobItemWorkReq(
52
+ job: JobQueueItem,
53
+ index2pubkey: Index2PubkeyCache,
54
+ metrics: Metrics | null
55
+ ): Promise<BlsWorkReq> {
52
56
  switch (job.type) {
53
57
  case JobQueueItemType.default:
54
58
  return {
55
59
  opts: job.opts,
56
60
  sets: job.sets.map((set) => ({
57
61
  // this can throw, handled in the consumer code
58
- publicKey: getAggregatedPubkey(set, metrics).toBytes(),
62
+ publicKey: getAggregatedPubkey(set, index2pubkey, metrics).toBytes(),
59
63
  signature: set.signature,
60
64
  message: set.signingRoot,
61
65
  })),
@@ -1,5 +1,5 @@
1
1
  import {PublicKey, Signature, aggregatePublicKeys, aggregateSignatures, verify} from "@chainsafe/blst";
2
- import {ISignatureSet} from "@lodestar/state-transition";
2
+ import {ISignatureSet, Index2PubkeyCache} from "@lodestar/state-transition";
3
3
  import {Metrics} from "../../metrics/index.js";
4
4
  import {IBlsVerifier} from "./interface.js";
5
5
  import {verifySignatureSetsMaybeBatch} from "./maybeBatch.js";
@@ -7,16 +7,18 @@ import {getAggregatedPubkey, getAggregatedPubkeysCount} from "./utils.js";
7
7
 
8
8
  export class BlsSingleThreadVerifier implements IBlsVerifier {
9
9
  private readonly metrics: Metrics | null;
10
+ private readonly index2pubkey: Index2PubkeyCache;
10
11
 
11
- constructor({metrics = null}: {metrics: Metrics | null}) {
12
+ constructor({metrics = null, index2pubkey}: {metrics: Metrics | null; index2pubkey: Index2PubkeyCache}) {
12
13
  this.metrics = metrics;
14
+ this.index2pubkey = index2pubkey;
13
15
  }
14
16
 
15
17
  async verifySignatureSets(sets: ISignatureSet[]): Promise<boolean> {
16
18
  this.metrics?.bls.aggregatedPubkeys.inc(getAggregatedPubkeysCount(sets));
17
19
 
18
20
  const setsAggregated = sets.map((set) => ({
19
- publicKey: getAggregatedPubkey(set),
21
+ publicKey: getAggregatedPubkey(set, this.index2pubkey, this.metrics),
20
22
  message: set.signingRoot,
21
23
  signature: set.signature,
22
24
  }));
@@ -1,17 +1,25 @@
1
1
  import {PublicKey, aggregatePublicKeys} from "@chainsafe/blst";
2
- import {ISignatureSet, SignatureSetType} from "@lodestar/state-transition";
2
+ import {ISignatureSet, Index2PubkeyCache, SignatureSetType} from "@lodestar/state-transition";
3
3
  import {Metrics} from "../../metrics/metrics.js";
4
4
 
5
- export function getAggregatedPubkey(signatureSet: ISignatureSet, metrics: Metrics | null = null): PublicKey {
5
+ export function getAggregatedPubkey(
6
+ signatureSet: ISignatureSet,
7
+ index2pubkey: Index2PubkeyCache,
8
+ metrics: Metrics | null = null
9
+ ): PublicKey {
6
10
  switch (signatureSet.type) {
7
11
  case SignatureSetType.single:
8
12
  return signatureSet.pubkey;
9
13
 
14
+ case SignatureSetType.indexed:
15
+ return index2pubkey[signatureSet.index];
16
+
10
17
  case SignatureSetType.aggregate: {
11
18
  const timer = metrics?.blsThreadPool.pubkeysAggregationMainThreadDuration.startTimer();
12
- const pubkeys = aggregatePublicKeys(signatureSet.pubkeys);
19
+ const pubkeys = signatureSet.indices.map((i) => index2pubkey[i]);
20
+ const aggregated = aggregatePublicKeys(pubkeys);
13
21
  timer?.();
14
- return pubkeys;
22
+ return aggregated;
15
23
  }
16
24
 
17
25
  default:
@@ -20,11 +28,11 @@ export function getAggregatedPubkey(signatureSet: ISignatureSet, metrics: Metric
20
28
  }
21
29
 
22
30
  export function getAggregatedPubkeysCount(signatureSets: ISignatureSet[]): number {
23
- let pubkeysConut = 0;
31
+ let pubkeysCount = 0;
24
32
  for (const set of signatureSets) {
25
33
  if (set.type === SignatureSetType.aggregate) {
26
- pubkeysConut += set.pubkeys.length;
34
+ pubkeysCount += set.indices.length;
27
35
  }
28
36
  }
29
- return pubkeysConut;
37
+ return pubkeysCount;
30
38
  }