@lodestar/beacon-node 1.40.0-dev.4acd3ce568 → 1.40.0-dev.9defa5c09b

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 (251) hide show
  1. package/lib/api/impl/beacon/blocks/index.d.ts.map +1 -1
  2. package/lib/api/impl/beacon/blocks/index.js +8 -18
  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 +5 -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/archiveStore/utils/archiveBlocks.d.ts.map +1 -1
  15. package/lib/chain/archiveStore/utils/archiveBlocks.js +4 -0
  16. package/lib/chain/archiveStore/utils/archiveBlocks.js.map +1 -1
  17. package/lib/chain/blocks/blockInput/blockInput.d.ts +2 -0
  18. package/lib/chain/blocks/blockInput/blockInput.d.ts.map +1 -1
  19. package/lib/chain/blocks/blockInput/blockInput.js +6 -0
  20. package/lib/chain/blocks/blockInput/blockInput.js.map +1 -1
  21. package/lib/chain/blocks/importBlock.d.ts.map +1 -1
  22. package/lib/chain/blocks/importBlock.js +2 -6
  23. package/lib/chain/blocks/importBlock.js.map +1 -1
  24. package/lib/chain/blocks/index.d.ts.map +1 -1
  25. package/lib/chain/blocks/index.js +0 -14
  26. package/lib/chain/blocks/index.js.map +1 -1
  27. package/lib/chain/blocks/types.d.ts +0 -2
  28. package/lib/chain/blocks/types.d.ts.map +1 -1
  29. package/lib/chain/blocks/verifyBlock.d.ts.map +1 -1
  30. package/lib/chain/blocks/verifyBlock.js +0 -7
  31. package/lib/chain/blocks/verifyBlock.js.map +1 -1
  32. package/lib/chain/blocks/writeBlockInputToDb.d.ts +1 -4
  33. package/lib/chain/blocks/writeBlockInputToDb.d.ts.map +1 -1
  34. package/lib/chain/blocks/writeBlockInputToDb.js +20 -28
  35. package/lib/chain/blocks/writeBlockInputToDb.js.map +1 -1
  36. package/lib/chain/chain.d.ts +21 -4
  37. package/lib/chain/chain.d.ts.map +1 -1
  38. package/lib/chain/chain.js +178 -13
  39. package/lib/chain/chain.js.map +1 -1
  40. package/lib/chain/errors/attestationError.d.ts +14 -1
  41. package/lib/chain/errors/attestationError.d.ts.map +1 -1
  42. package/lib/chain/errors/attestationError.js +8 -0
  43. package/lib/chain/errors/attestationError.js.map +1 -1
  44. package/lib/chain/errors/executionPayloadBid.d.ts +48 -0
  45. package/lib/chain/errors/executionPayloadBid.d.ts.map +1 -0
  46. package/lib/chain/errors/executionPayloadBid.js +15 -0
  47. package/lib/chain/errors/executionPayloadBid.js.map +1 -0
  48. package/lib/chain/errors/executionPayloadEnvelope.d.ts +48 -0
  49. package/lib/chain/errors/executionPayloadEnvelope.d.ts.map +1 -0
  50. package/lib/chain/errors/executionPayloadEnvelope.js +16 -0
  51. package/lib/chain/errors/executionPayloadEnvelope.js.map +1 -0
  52. package/lib/chain/errors/index.d.ts +3 -0
  53. package/lib/chain/errors/index.d.ts.map +1 -1
  54. package/lib/chain/errors/index.js +3 -0
  55. package/lib/chain/errors/index.js.map +1 -1
  56. package/lib/chain/errors/payloadAttestation.d.ts +34 -0
  57. package/lib/chain/errors/payloadAttestation.d.ts.map +1 -0
  58. package/lib/chain/errors/payloadAttestation.js +13 -0
  59. package/lib/chain/errors/payloadAttestation.js.map +1 -0
  60. package/lib/chain/forkChoice/index.d.ts.map +1 -1
  61. package/lib/chain/forkChoice/index.js +18 -0
  62. package/lib/chain/forkChoice/index.js.map +1 -1
  63. package/lib/chain/interface.d.ts +21 -3
  64. package/lib/chain/interface.d.ts.map +1 -1
  65. package/lib/chain/interface.js.map +1 -1
  66. package/lib/chain/opPools/executionPayloadBidPool.d.ts +21 -0
  67. package/lib/chain/opPools/executionPayloadBidPool.d.ts.map +1 -0
  68. package/lib/chain/opPools/executionPayloadBidPool.js +57 -0
  69. package/lib/chain/opPools/executionPayloadBidPool.js.map +1 -0
  70. package/lib/chain/opPools/index.d.ts +2 -0
  71. package/lib/chain/opPools/index.d.ts.map +1 -1
  72. package/lib/chain/opPools/index.js +2 -0
  73. package/lib/chain/opPools/index.js.map +1 -1
  74. package/lib/chain/opPools/payloadAttestationPool.d.ts +24 -0
  75. package/lib/chain/opPools/payloadAttestationPool.d.ts.map +1 -0
  76. package/lib/chain/opPools/payloadAttestationPool.js +109 -0
  77. package/lib/chain/opPools/payloadAttestationPool.js.map +1 -0
  78. package/lib/chain/prepareNextSlot.js +6 -4
  79. package/lib/chain/prepareNextSlot.js.map +1 -1
  80. package/lib/chain/produceBlock/produceBlockBody.d.ts +3 -2
  81. package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
  82. package/lib/chain/produceBlock/produceBlockBody.js +5 -3
  83. package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
  84. package/lib/chain/regen/interface.d.ts +3 -8
  85. package/lib/chain/regen/interface.d.ts.map +1 -1
  86. package/lib/chain/regen/interface.js +1 -1
  87. package/lib/chain/regen/interface.js.map +1 -1
  88. package/lib/chain/regen/queued.d.ts +1 -2
  89. package/lib/chain/regen/queued.d.ts.map +1 -1
  90. package/lib/chain/regen/queued.js +2 -16
  91. package/lib/chain/regen/queued.js.map +1 -1
  92. package/lib/chain/regen/regen.d.ts +3 -7
  93. package/lib/chain/regen/regen.d.ts.map +1 -1
  94. package/lib/chain/regen/regen.js +3 -16
  95. package/lib/chain/regen/regen.js.map +1 -1
  96. package/lib/chain/seenCache/index.d.ts +3 -1
  97. package/lib/chain/seenCache/index.d.ts.map +1 -1
  98. package/lib/chain/seenCache/index.js +3 -1
  99. package/lib/chain/seenCache/index.js.map +1 -1
  100. package/lib/chain/seenCache/seenAttesters.d.ts +5 -0
  101. package/lib/chain/seenCache/seenAttesters.d.ts.map +1 -1
  102. package/lib/chain/seenCache/seenAttesters.js +5 -0
  103. package/lib/chain/seenCache/seenAttesters.js.map +1 -1
  104. package/lib/chain/seenCache/seenExecutionPayloadBids.d.ts +12 -0
  105. package/lib/chain/seenCache/seenExecutionPayloadBids.d.ts.map +1 -0
  106. package/lib/chain/seenCache/seenExecutionPayloadBids.js +30 -0
  107. package/lib/chain/seenCache/seenExecutionPayloadBids.js.map +1 -0
  108. package/lib/chain/seenCache/seenExecutionPayloadEnvelope.d.ts +15 -0
  109. package/lib/chain/seenCache/seenExecutionPayloadEnvelope.d.ts.map +1 -0
  110. package/lib/chain/seenCache/seenExecutionPayloadEnvelope.js +28 -0
  111. package/lib/chain/seenCache/seenExecutionPayloadEnvelope.js.map +1 -0
  112. package/lib/chain/validation/aggregateAndProof.js +32 -10
  113. package/lib/chain/validation/aggregateAndProof.js.map +1 -1
  114. package/lib/chain/validation/attestation.d.ts.map +1 -1
  115. package/lib/chain/validation/attestation.js +23 -4
  116. package/lib/chain/validation/attestation.js.map +1 -1
  117. package/lib/chain/validation/blobSidecar.js +1 -1
  118. package/lib/chain/validation/blobSidecar.js.map +1 -1
  119. package/lib/chain/validation/block.d.ts.map +1 -1
  120. package/lib/chain/validation/block.js +4 -3
  121. package/lib/chain/validation/block.js.map +1 -1
  122. package/lib/chain/validation/dataColumnSidecar.js +1 -1
  123. package/lib/chain/validation/dataColumnSidecar.js.map +1 -1
  124. package/lib/chain/validation/executionPayloadBid.d.ts +5 -0
  125. package/lib/chain/validation/executionPayloadBid.d.ts.map +1 -0
  126. package/lib/chain/validation/executionPayloadBid.js +103 -0
  127. package/lib/chain/validation/executionPayloadBid.js.map +1 -0
  128. package/lib/chain/validation/executionPayloadEnvelope.d.ts +5 -0
  129. package/lib/chain/validation/executionPayloadEnvelope.d.ts.map +1 -0
  130. package/lib/chain/validation/executionPayloadEnvelope.js +89 -0
  131. package/lib/chain/validation/executionPayloadEnvelope.js.map +1 -0
  132. package/lib/chain/validation/payloadAttestationMessage.d.ts +9 -0
  133. package/lib/chain/validation/payloadAttestationMessage.d.ts.map +1 -0
  134. package/lib/chain/validation/payloadAttestationMessage.js +72 -0
  135. package/lib/chain/validation/payloadAttestationMessage.js.map +1 -0
  136. package/lib/chain/validatorMonitor.d.ts +2 -0
  137. package/lib/chain/validatorMonitor.d.ts.map +1 -1
  138. package/lib/chain/validatorMonitor.js +42 -3
  139. package/lib/chain/validatorMonitor.js.map +1 -1
  140. package/lib/db/repositories/checkpointState.js +0 -1
  141. package/lib/db/repositories/checkpointState.js.map +1 -1
  142. package/lib/metrics/metrics/lodestar.d.ts +27 -0
  143. package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
  144. package/lib/metrics/metrics/lodestar.js +64 -0
  145. package/lib/metrics/metrics/lodestar.js.map +1 -1
  146. package/lib/network/gossip/interface.d.ts +20 -2
  147. package/lib/network/gossip/interface.d.ts.map +1 -1
  148. package/lib/network/gossip/interface.js +3 -0
  149. package/lib/network/gossip/interface.js.map +1 -1
  150. package/lib/network/gossip/scoringParameters.d.ts.map +1 -1
  151. package/lib/network/gossip/scoringParameters.js +38 -2
  152. package/lib/network/gossip/scoringParameters.js.map +1 -1
  153. package/lib/network/gossip/topic.d.ts +77 -1
  154. package/lib/network/gossip/topic.d.ts.map +1 -1
  155. package/lib/network/gossip/topic.js +20 -0
  156. package/lib/network/gossip/topic.js.map +1 -1
  157. package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
  158. package/lib/network/processor/gossipHandlers.js +34 -3
  159. package/lib/network/processor/gossipHandlers.js.map +1 -1
  160. package/lib/network/processor/gossipQueues/index.d.ts.map +1 -1
  161. package/lib/network/processor/gossipQueues/index.js +16 -0
  162. package/lib/network/processor/gossipQueues/index.js.map +1 -1
  163. package/lib/network/processor/index.d.ts.map +1 -1
  164. package/lib/network/processor/index.js +3 -0
  165. package/lib/network/processor/index.js.map +1 -1
  166. package/lib/network/reqresp/handlers/beaconBlocksByRange.d.ts.map +1 -1
  167. package/lib/network/reqresp/handlers/beaconBlocksByRange.js +2 -4
  168. package/lib/network/reqresp/handlers/beaconBlocksByRange.js.map +1 -1
  169. package/lib/network/reqresp/handlers/beaconBlocksByRoot.d.ts +1 -2
  170. package/lib/network/reqresp/handlers/beaconBlocksByRoot.d.ts.map +1 -1
  171. package/lib/network/reqresp/handlers/beaconBlocksByRoot.js +5 -26
  172. package/lib/network/reqresp/handlers/beaconBlocksByRoot.js.map +1 -1
  173. package/lib/network/reqresp/handlers/blobSidecarsByRoot.d.ts +1 -2
  174. package/lib/network/reqresp/handlers/blobSidecarsByRoot.d.ts.map +1 -1
  175. package/lib/network/reqresp/handlers/blobSidecarsByRoot.js +5 -7
  176. package/lib/network/reqresp/handlers/blobSidecarsByRoot.js.map +1 -1
  177. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.d.ts.map +1 -1
  178. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js +1 -2
  179. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js.map +1 -1
  180. package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.d.ts.map +1 -1
  181. package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.js +1 -5
  182. package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.js.map +1 -1
  183. package/lib/network/reqresp/handlers/index.js +2 -2
  184. package/lib/network/reqresp/handlers/index.js.map +1 -1
  185. package/lib/sync/range/chain.d.ts.map +1 -1
  186. package/lib/sync/range/chain.js +0 -1
  187. package/lib/sync/range/chain.js.map +1 -1
  188. package/lib/sync/range/range.d.ts.map +1 -1
  189. package/lib/sync/range/range.js +0 -3
  190. package/lib/sync/range/range.js.map +1 -1
  191. package/lib/sync/unknownBlock.d.ts.map +1 -1
  192. package/lib/sync/unknownBlock.js +0 -3
  193. package/lib/sync/unknownBlock.js.map +1 -1
  194. package/package.json +15 -15
  195. package/src/api/impl/beacon/blocks/index.ts +8 -18
  196. package/src/api/impl/debug/index.ts +2 -6
  197. package/src/api/impl/lodestar/index.ts +6 -3
  198. package/src/api/impl/validator/index.ts +12 -11
  199. package/src/chain/archiveStore/utils/archiveBlocks.ts +4 -0
  200. package/src/chain/blocks/blockInput/blockInput.ts +8 -0
  201. package/src/chain/blocks/importBlock.ts +2 -6
  202. package/src/chain/blocks/index.ts +0 -19
  203. package/src/chain/blocks/types.ts +0 -2
  204. package/src/chain/blocks/verifyBlock.ts +0 -8
  205. package/src/chain/blocks/writeBlockInputToDb.ts +24 -30
  206. package/src/chain/chain.ts +203 -21
  207. package/src/chain/errors/attestationError.ts +11 -1
  208. package/src/chain/errors/executionPayloadBid.ts +35 -0
  209. package/src/chain/errors/executionPayloadEnvelope.ts +34 -0
  210. package/src/chain/errors/index.ts +3 -0
  211. package/src/chain/errors/payloadAttestation.ts +25 -0
  212. package/src/chain/forkChoice/index.ts +19 -0
  213. package/src/chain/interface.ts +32 -1
  214. package/src/chain/opPools/executionPayloadBidPool.ts +77 -0
  215. package/src/chain/opPools/index.ts +2 -0
  216. package/src/chain/opPools/payloadAttestationPool.ts +157 -0
  217. package/src/chain/prepareNextSlot.ts +6 -6
  218. package/src/chain/produceBlock/produceBlockBody.ts +7 -5
  219. package/src/chain/regen/interface.ts +2 -12
  220. package/src/chain/regen/queued.ts +3 -23
  221. package/src/chain/regen/regen.ts +4 -24
  222. package/src/chain/seenCache/index.ts +3 -1
  223. package/src/chain/seenCache/seenAttesters.ts +5 -0
  224. package/src/chain/seenCache/seenExecutionPayloadBids.ts +35 -0
  225. package/src/chain/seenCache/seenExecutionPayloadEnvelope.ts +34 -0
  226. package/src/chain/validation/aggregateAndProof.ts +33 -10
  227. package/src/chain/validation/attestation.ts +24 -3
  228. package/src/chain/validation/blobSidecar.ts +1 -1
  229. package/src/chain/validation/block.ts +4 -3
  230. package/src/chain/validation/dataColumnSidecar.ts +1 -1
  231. package/src/chain/validation/executionPayloadBid.ts +140 -0
  232. package/src/chain/validation/executionPayloadEnvelope.ts +122 -0
  233. package/src/chain/validation/payloadAttestationMessage.ts +109 -0
  234. package/src/chain/validatorMonitor.ts +52 -3
  235. package/src/db/repositories/checkpointState.ts +1 -1
  236. package/src/metrics/metrics/lodestar.ts +65 -0
  237. package/src/network/gossip/interface.ts +17 -0
  238. package/src/network/gossip/scoringParameters.ts +44 -2
  239. package/src/network/gossip/topic.ts +21 -0
  240. package/src/network/processor/gossipHandlers.ts +48 -3
  241. package/src/network/processor/gossipQueues/index.ts +16 -0
  242. package/src/network/processor/index.ts +3 -0
  243. package/src/network/reqresp/handlers/beaconBlocksByRange.ts +2 -4
  244. package/src/network/reqresp/handlers/beaconBlocksByRoot.ts +5 -32
  245. package/src/network/reqresp/handlers/blobSidecarsByRoot.ts +5 -9
  246. package/src/network/reqresp/handlers/dataColumnSidecarsByRange.ts +5 -2
  247. package/src/network/reqresp/handlers/dataColumnSidecarsByRoot.ts +1 -5
  248. package/src/network/reqresp/handlers/index.ts +2 -2
  249. package/src/sync/range/chain.ts +0 -1
  250. package/src/sync/range/range.ts +0 -3
  251. package/src/sync/unknownBlock.ts +0 -3
@@ -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, {
@@ -626,6 +626,7 @@ export function getBeaconBlockApi({
626
626
  const {block, executionOptimistic, finalized} = await getBlockResponse(chain, blockId);
627
627
  const fork = config.getForkName(block.message.slot);
628
628
  const blockRoot = sszTypesFor(fork).BeaconBlock.hashTreeRoot(block.message);
629
+ const blockRootHex = toRootHex(blockRoot);
629
630
 
630
631
  let data: deneb.BlobSidecars;
631
632
 
@@ -642,10 +643,7 @@ export function getBeaconBlockApi({
642
643
  const blobCount = blobKzgCommitments.length;
643
644
 
644
645
  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
- }
646
+ const dataColumnSidecars = await chain.getDataColumnSidecars(block.message.slot, blockRootHex);
649
647
 
650
648
  if (dataColumnSidecars.length === 0) {
651
649
  throw new ApiError(
@@ -682,10 +680,7 @@ export function getBeaconBlockApi({
682
680
  data = [];
683
681
  }
684
682
  } 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
- }
683
+ const blobSidecars = await chain.getBlobSidecars(block.message.slot, blockRootHex);
689
684
 
690
685
  if (!blobSidecars) {
691
686
  throw new ApiError(
@@ -715,6 +710,7 @@ export function getBeaconBlockApi({
715
710
  const {block, executionOptimistic, finalized} = await getBlockResponse(chain, blockId);
716
711
  const fork = config.getForkName(block.message.slot);
717
712
  const blockRoot = sszTypesFor(fork).BeaconBlock.hashTreeRoot(block.message);
713
+ const blockRootHex = toRootHex(blockRoot);
718
714
 
719
715
  let blobs: deneb.Blobs;
720
716
 
@@ -731,10 +727,7 @@ export function getBeaconBlockApi({
731
727
  const blobCount = blobKzgCommitments.length;
732
728
 
733
729
  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
- }
730
+ const dataColumnSidecars = await chain.getDataColumnSidecars(block.message.slot, blockRootHex);
738
731
 
739
732
  if (dataColumnSidecars.length === 0) {
740
733
  throw new ApiError(
@@ -766,10 +759,7 @@ export function getBeaconBlockApi({
766
759
  blobs = [];
767
760
  }
768
761
  } 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
- }
762
+ const blobSidecars = await chain.getBlobSidecars(block.message.slot, blockRootHex);
773
763
 
774
764
  if (!blobSidecars) {
775
765
  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,12 @@ export function getLodestarApi({
238
238
  },
239
239
  };
240
240
  },
241
+
242
+ async getMonitoredValidatorIndices() {
243
+ return {
244
+ data: chain.validatorMonitor?.getMonitoredValidatorIndices() ?? [],
245
+ };
246
+ },
241
247
  };
242
248
  }
243
249
 
@@ -249,9 +255,6 @@ function regenRequestToJson(config: ChainForkConfig, regenRequest: RegenRequest)
249
255
  slot: regenRequest.args[1],
250
256
  };
251
257
 
252
- case "getCheckpointState":
253
- return ssz.phase0.Checkpoint.toJson(regenRequest.args[0]);
254
-
255
258
  case "getPreState": {
256
259
  const slot = regenRequest.args[0].slot;
257
260
  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,
@@ -413,10 +413,10 @@ export function getValidatorApi(
413
413
  // as of now fee recipient checks can not be performed because builder does not return bid recipient
414
414
  {
415
415
  commonBlockBodyPromise,
416
- parentBlockRoot,
416
+ parentBlock,
417
417
  }: Omit<routes.validator.ExtraProduceBlockOpts, "builderSelection"> & {
418
418
  commonBlockBodyPromise: Promise<CommonBlockBody>;
419
- parentBlockRoot: Root;
419
+ parentBlock: ProtoBlock;
420
420
  }
421
421
  ): Promise<ProduceBlindedBlockRes> {
422
422
  const version = config.getForkName(slot);
@@ -447,7 +447,7 @@ export function getValidatorApi(
447
447
  timer = metrics?.blockProductionTime.startTimer();
448
448
  const {block, executionPayloadValue, consensusBlockValue} = await chain.produceBlindedBlock({
449
449
  slot,
450
- parentBlockRoot,
450
+ parentBlock,
451
451
  randaoReveal,
452
452
  graffiti,
453
453
  commonBlockBodyPromise,
@@ -482,10 +482,10 @@ export function getValidatorApi(
482
482
  feeRecipient,
483
483
  strictFeeRecipientCheck,
484
484
  commonBlockBodyPromise,
485
- parentBlockRoot,
485
+ parentBlock,
486
486
  }: Omit<routes.validator.ExtraProduceBlockOpts, "builderSelection"> & {
487
487
  commonBlockBodyPromise: Promise<CommonBlockBody>;
488
- parentBlockRoot: Root;
488
+ parentBlock: ProtoBlock;
489
489
  }
490
490
  ): Promise<ProduceBlockContentsRes & {shouldOverrideBuilder?: boolean}> {
491
491
  const source = ProducedBlockSource.engine;
@@ -496,7 +496,7 @@ export function getValidatorApi(
496
496
  timer = metrics?.blockProductionTime.startTimer();
497
497
  const {block, executionPayloadValue, consensusBlockValue, shouldOverrideBuilder} = await chain.produceBlock({
498
498
  slot,
499
- parentBlockRoot,
499
+ parentBlock,
500
500
  randaoReveal,
501
501
  graffiti,
502
502
  feeRecipient,
@@ -569,7 +569,8 @@ export function getValidatorApi(
569
569
  notWhileSyncing();
570
570
  await waitForSlot(slot); // Must never request for a future slot > currentSlot
571
571
 
572
- const {blockRoot: parentBlockRootHex, slot: parentSlot} = chain.getProposerHead(slot);
572
+ const parentBlock = chain.getProposerHead(slot);
573
+ const {blockRoot: parentBlockRootHex, slot: parentSlot} = parentBlock;
573
574
  const parentBlockRoot = fromHex(parentBlockRootHex);
574
575
  notOnOutOfRangeData(parentBlockRoot);
575
576
  metrics?.blockProductionSlotDelta.set(slot - parentSlot);
@@ -638,7 +639,7 @@ export function getValidatorApi(
638
639
  // can't do fee recipient checks as builder bid doesn't return feeRecipient as of now
639
640
  strictFeeRecipientCheck: false,
640
641
  commonBlockBodyPromise,
641
- parentBlockRoot,
642
+ parentBlock,
642
643
  })
643
644
  : Promise.reject(new Error("Builder disabled"));
644
645
 
@@ -647,7 +648,7 @@ export function getValidatorApi(
647
648
  feeRecipient,
648
649
  strictFeeRecipientCheck,
649
650
  commonBlockBodyPromise,
650
- parentBlockRoot,
651
+ parentBlock,
651
652
  }).then((engineBlock) => {
652
653
  // Once the engine returns a block, in the event of either:
653
654
  // - suspected builder censorship
@@ -689,7 +690,7 @@ export function getValidatorApi(
689
690
  chain
690
691
  .produceCommonBlockBody({
691
692
  slot,
692
- parentBlockRoot,
693
+ parentBlock,
693
694
  randaoReveal,
694
695
  graffiti: graffitiBytes,
695
696
  })
@@ -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", {
@@ -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}
@@ -787,6 +791,10 @@ export class BlockInputColumns extends AbstractBlockInput<ForkColumnsDA, fulu.Da
787
791
  return this.columnsCache.has(columnIndex);
788
792
  }
789
793
 
794
+ getColumn(columnIndex: number): fulu.DataColumnSidecar | undefined {
795
+ return this.columnsCache.get(columnIndex)?.columnSidecar;
796
+ }
797
+
790
798
  getVersionedHashes(): VersionedHashes {
791
799
  return this.state.versionedHashes;
792
800
  }
@@ -34,7 +34,6 @@ import {toCheckpointHex} from "../stateCache/index.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.
@@ -156,13 +155,6 @@ export async function verifyBlocksInEpoch(
156
155
  opts
157
156
  )
158
157
  : 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
158
  ]);
167
159
 
168
160
  if (opts.verifyOnly !== true) {
@@ -98,35 +98,29 @@ export async function writeBlockInputToDb(this: BeaconChain, blocksInputs: IBloc
98
98
  }
99
99
  }
100
100
 
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});
101
+ export async function persistBlockInputs(this: BeaconChain, blockInputs: IBlockInput[]): Promise<void> {
102
+ await writeBlockInputToDb
103
+ .call(this, blockInputs)
104
+ .catch((e) => {
105
+ this.logger.debug(
106
+ "Error persisting block input in hot db",
107
+ {
108
+ count: blockInputs.length,
109
+ slot: blockInputs[0].slot,
110
+ root: blockInputs[0].blockRootHex,
111
+ },
112
+ e
113
+ );
114
+ })
115
+ .finally(() => {
116
+ for (const blockInput of blockInputs) {
117
+ this.seenBlockInputCache.prune(blockInput.blockRootHex);
122
118
  }
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
- ]);
119
+ if (blockInputs.length === 1) {
120
+ this.logger.debug("Pruned block input", {
121
+ slot: blockInputs[0].slot,
122
+ root: blockInputs[0].blockRootHex,
123
+ });
124
+ }
125
+ });
132
126
  }