@lodestar/beacon-node 1.45.0 → 1.46.0-dev.18a1510f34

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 (268) hide show
  1. package/lib/api/impl/beacon/blocks/index.d.ts.map +1 -1
  2. package/lib/api/impl/beacon/blocks/index.js +186 -57
  3. package/lib/api/impl/beacon/blocks/index.js.map +1 -1
  4. package/lib/api/impl/config/constants.d.ts +1 -0
  5. package/lib/api/impl/config/constants.d.ts.map +1 -1
  6. package/lib/api/impl/config/constants.js +2 -1
  7. package/lib/api/impl/config/constants.js.map +1 -1
  8. package/lib/api/impl/lodestar/index.d.ts.map +1 -1
  9. package/lib/api/impl/lodestar/index.js +2 -3
  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 +173 -89
  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 +6 -3
  16. package/lib/api/rest/base.js.map +1 -1
  17. package/lib/chain/archiveStore/archiveStore.d.ts.map +1 -1
  18. package/lib/chain/archiveStore/archiveStore.js +17 -3
  19. package/lib/chain/archiveStore/archiveStore.js.map +1 -1
  20. package/lib/chain/archiveStore/historicalState/historicalStateRegen.d.ts.map +1 -1
  21. package/lib/chain/archiveStore/historicalState/historicalStateRegen.js +0 -1
  22. package/lib/chain/archiveStore/historicalState/historicalStateRegen.js.map +1 -1
  23. package/lib/chain/blocks/importBlock.d.ts.map +1 -1
  24. package/lib/chain/blocks/importBlock.js +2 -17
  25. package/lib/chain/blocks/importBlock.js.map +1 -1
  26. package/lib/chain/blocks/utils/chainSegment.d.ts.map +1 -1
  27. package/lib/chain/blocks/utils/chainSegment.js +13 -5
  28. package/lib/chain/blocks/utils/chainSegment.js.map +1 -1
  29. package/lib/chain/blocks/verifyBlocksExecutionPayloads.js +1 -1
  30. package/lib/chain/blocks/verifyBlocksExecutionPayloads.js.map +1 -1
  31. package/lib/chain/blocks/verifyBlocksSanityChecks.js +1 -1
  32. package/lib/chain/blocks/verifyBlocksSanityChecks.js.map +1 -1
  33. package/lib/chain/blocks/verifyExecutionPayloadEnvelope.js +3 -3
  34. package/lib/chain/blocks/verifyExecutionPayloadEnvelope.js.map +1 -1
  35. package/lib/chain/bls/multithread/index.d.ts.map +1 -1
  36. package/lib/chain/bls/multithread/index.js +0 -1
  37. package/lib/chain/bls/multithread/index.js.map +1 -1
  38. package/lib/chain/chain.d.ts.map +1 -1
  39. package/lib/chain/chain.js +44 -2
  40. package/lib/chain/chain.js.map +1 -1
  41. package/lib/chain/errors/blockError.d.ts +48 -6
  42. package/lib/chain/errors/blockError.d.ts.map +1 -1
  43. package/lib/chain/errors/blockError.js +25 -4
  44. package/lib/chain/errors/blockError.js.map +1 -1
  45. package/lib/chain/errors/executionPayloadBid.d.ts +11 -4
  46. package/lib/chain/errors/executionPayloadBid.d.ts.map +1 -1
  47. package/lib/chain/errors/executionPayloadBid.js +1 -0
  48. package/lib/chain/errors/executionPayloadBid.js.map +1 -1
  49. package/lib/chain/errors/executionPayloadEnvelope.d.ts +11 -0
  50. package/lib/chain/errors/executionPayloadEnvelope.d.ts.map +1 -1
  51. package/lib/chain/errors/executionPayloadEnvelope.js +2 -0
  52. package/lib/chain/errors/executionPayloadEnvelope.js.map +1 -1
  53. package/lib/chain/errors/proposerPreferences.d.ts +14 -1
  54. package/lib/chain/errors/proposerPreferences.d.ts.map +1 -1
  55. package/lib/chain/errors/proposerPreferences.js +2 -0
  56. package/lib/chain/errors/proposerPreferences.js.map +1 -1
  57. package/lib/chain/lightClient/index.d.ts.map +1 -1
  58. package/lib/chain/lightClient/index.js +11 -6
  59. package/lib/chain/lightClient/index.js.map +1 -1
  60. package/lib/chain/lightClient/proofs.d.ts.map +1 -1
  61. package/lib/chain/lightClient/proofs.js +28 -2
  62. package/lib/chain/lightClient/proofs.js.map +1 -1
  63. package/lib/chain/lightClient/types.d.ts +3 -1
  64. package/lib/chain/lightClient/types.d.ts.map +1 -1
  65. package/lib/chain/opPools/aggregatedAttestationPool.d.ts.map +1 -1
  66. package/lib/chain/opPools/aggregatedAttestationPool.js +2 -1
  67. package/lib/chain/opPools/aggregatedAttestationPool.js.map +1 -1
  68. package/lib/chain/opPools/proposerPreferencesPool.d.ts +1 -1
  69. package/lib/chain/opPools/proposerPreferencesPool.d.ts.map +1 -1
  70. package/lib/chain/opPools/proposerPreferencesPool.js +1 -1
  71. package/lib/chain/opPools/proposerPreferencesPool.js.map +1 -1
  72. package/lib/chain/prepareNextSlot.js +1 -1
  73. package/lib/chain/prepareNextSlot.js.map +1 -1
  74. package/lib/chain/produceBlock/produceBlockBody.js +4 -4
  75. package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
  76. package/lib/chain/seenCache/seenExecutionPayloadBids.d.ts +6 -5
  77. package/lib/chain/seenCache/seenExecutionPayloadBids.d.ts.map +1 -1
  78. package/lib/chain/seenCache/seenExecutionPayloadBids.js +16 -8
  79. package/lib/chain/seenCache/seenExecutionPayloadBids.js.map +1 -1
  80. package/lib/chain/validation/aggregateAndProof.js +10 -6
  81. package/lib/chain/validation/aggregateAndProof.js.map +1 -1
  82. package/lib/chain/validation/attestation.d.ts.map +1 -1
  83. package/lib/chain/validation/attestation.js +10 -6
  84. package/lib/chain/validation/attestation.js.map +1 -1
  85. package/lib/chain/validation/blobSidecar.js +1 -1
  86. package/lib/chain/validation/block.d.ts.map +1 -1
  87. package/lib/chain/validation/block.js +53 -4
  88. package/lib/chain/validation/block.js.map +1 -1
  89. package/lib/chain/validation/executionPayloadBid.d.ts.map +1 -1
  90. package/lib/chain/validation/executionPayloadBid.js +100 -26
  91. package/lib/chain/validation/executionPayloadBid.js.map +1 -1
  92. package/lib/chain/validation/executionPayloadEnvelope.d.ts.map +1 -1
  93. package/lib/chain/validation/executionPayloadEnvelope.js +29 -0
  94. package/lib/chain/validation/executionPayloadEnvelope.js.map +1 -1
  95. package/lib/chain/validation/proposerPreferences.d.ts +9 -2
  96. package/lib/chain/validation/proposerPreferences.d.ts.map +1 -1
  97. package/lib/chain/validation/proposerPreferences.js +65 -13
  98. package/lib/chain/validation/proposerPreferences.js.map +1 -1
  99. package/lib/chain/validation/signatureSets/aggregateAndProof.d.ts.map +1 -1
  100. package/lib/chain/validation/signatureSets/aggregateAndProof.js +2 -3
  101. package/lib/chain/validation/signatureSets/aggregateAndProof.js.map +1 -1
  102. package/lib/chain/validatorMonitor.js +1 -1
  103. package/lib/chain/validatorMonitor.js.map +1 -1
  104. package/lib/db/repositories/lightclientSyncCommitteeWitness.d.ts.map +1 -1
  105. package/lib/db/repositories/lightclientSyncCommitteeWitness.js +42 -7
  106. package/lib/db/repositories/lightclientSyncCommitteeWitness.js.map +1 -1
  107. package/lib/execution/engine/interface.d.ts +1 -1
  108. package/lib/execution/engine/types.js +1 -1
  109. package/lib/execution/engine/types.js.map +1 -1
  110. package/lib/metrics/nodeJsMetrics.js +1 -1
  111. package/lib/metrics/nodeJsMetrics.js.map +1 -1
  112. package/lib/network/core/networkCoreWorkerHandler.d.ts.map +1 -1
  113. package/lib/network/core/networkCoreWorkerHandler.js +2 -7
  114. package/lib/network/core/networkCoreWorkerHandler.js.map +1 -1
  115. package/lib/network/discv5/index.d.ts.map +1 -1
  116. package/lib/network/discv5/index.js +1 -4
  117. package/lib/network/discv5/index.js.map +1 -1
  118. package/lib/network/gossip/encoding.d.ts +2 -2
  119. package/lib/network/gossip/encoding.d.ts.map +1 -1
  120. package/lib/network/gossip/encoding.js +15 -9
  121. package/lib/network/gossip/encoding.js.map +1 -1
  122. package/lib/network/gossip/gossipsub.d.ts.map +1 -1
  123. package/lib/network/gossip/gossipsub.js +2 -2
  124. package/lib/network/gossip/gossipsub.js.map +1 -1
  125. package/lib/network/gossip/topic.d.ts +79 -236
  126. package/lib/network/gossip/topic.d.ts.map +1 -1
  127. package/lib/network/gossip/topic.js +24 -1
  128. package/lib/network/gossip/topic.js.map +1 -1
  129. package/lib/network/interface.d.ts +4 -1
  130. package/lib/network/interface.d.ts.map +1 -1
  131. package/lib/network/libp2p/index.d.ts.map +1 -1
  132. package/lib/network/libp2p/index.js +2 -9
  133. package/lib/network/libp2p/index.js.map +1 -1
  134. package/lib/network/network.d.ts +4 -1
  135. package/lib/network/network.d.ts.map +1 -1
  136. package/lib/network/network.js +19 -11
  137. package/lib/network/network.js.map +1 -1
  138. package/lib/network/peers/datastore.d.ts +1 -1
  139. package/lib/network/peers/datastore.d.ts.map +1 -1
  140. package/lib/network/peers/datastore.js +1 -1
  141. package/lib/network/peers/datastore.js.map +1 -1
  142. package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
  143. package/lib/network/processor/gossipHandlers.js +12 -6
  144. package/lib/network/processor/gossipHandlers.js.map +1 -1
  145. package/lib/network/processor/index.d.ts.map +1 -1
  146. package/lib/network/processor/index.js +2 -1
  147. package/lib/network/processor/index.js.map +1 -1
  148. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.d.ts.map +1 -1
  149. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.js +4 -2
  150. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.js.map +1 -1
  151. package/lib/network/reqresp/handlers/index.d.ts.map +1 -1
  152. package/lib/network/reqresp/handlers/index.js +20 -11
  153. package/lib/network/reqresp/handlers/index.js.map +1 -1
  154. package/lib/network/reqresp/handlers/lightClientFinalityUpdate.js +1 -1
  155. package/lib/network/reqresp/handlers/lightClientFinalityUpdate.js.map +1 -1
  156. package/lib/network/reqresp/handlers/lightClientOptimisticUpdate.js +1 -1
  157. package/lib/network/reqresp/handlers/lightClientOptimisticUpdate.js.map +1 -1
  158. package/lib/network/reqresp/handlers/lightClientUpdatesByRange.d.ts.map +1 -1
  159. package/lib/network/reqresp/handlers/lightClientUpdatesByRange.js +6 -2
  160. package/lib/network/reqresp/handlers/lightClientUpdatesByRange.js.map +1 -1
  161. package/lib/network/util.d.ts +1 -0
  162. package/lib/network/util.d.ts.map +1 -1
  163. package/lib/network/util.js +4 -0
  164. package/lib/network/util.js.map +1 -1
  165. package/lib/sync/constants.d.ts +6 -5
  166. package/lib/sync/constants.d.ts.map +1 -1
  167. package/lib/sync/constants.js +6 -5
  168. package/lib/sync/constants.js.map +1 -1
  169. package/lib/sync/range/batch.d.ts +10 -1
  170. package/lib/sync/range/batch.d.ts.map +1 -1
  171. package/lib/sync/range/batch.js +28 -10
  172. package/lib/sync/range/batch.js.map +1 -1
  173. package/lib/sync/range/chain.d.ts.map +1 -1
  174. package/lib/sync/range/chain.js +30 -15
  175. package/lib/sync/range/chain.js.map +1 -1
  176. package/lib/sync/range/utils/batches.d.ts +18 -0
  177. package/lib/sync/range/utils/batches.d.ts.map +1 -1
  178. package/lib/sync/range/utils/batches.js +39 -0
  179. package/lib/sync/range/utils/batches.js.map +1 -1
  180. package/lib/sync/sync.d.ts.map +1 -1
  181. package/lib/sync/sync.js +7 -0
  182. package/lib/sync/sync.js.map +1 -1
  183. package/lib/sync/unknownBlock.d.ts.map +1 -1
  184. package/lib/sync/unknownBlock.js +7 -2
  185. package/lib/sync/unknownBlock.js.map +1 -1
  186. package/lib/util/execution.js +1 -1
  187. package/lib/util/execution.js.map +1 -1
  188. package/lib/util/profile.d.ts +3 -0
  189. package/lib/util/profile.d.ts.map +1 -1
  190. package/lib/util/profile.js +1 -27
  191. package/lib/util/profile.js.map +1 -1
  192. package/lib/util/sszBytes.js +1 -1
  193. package/package.json +29 -38
  194. package/src/api/impl/beacon/blocks/index.ts +221 -63
  195. package/src/api/impl/config/constants.ts +2 -0
  196. package/src/api/impl/lodestar/index.ts +2 -3
  197. package/src/api/impl/validator/index.ts +207 -99
  198. package/src/api/rest/base.ts +8 -3
  199. package/src/chain/archiveStore/archiveStore.ts +20 -3
  200. package/src/chain/archiveStore/historicalState/historicalStateRegen.ts +0 -1
  201. package/src/chain/blocks/importBlock.ts +0 -17
  202. package/src/chain/blocks/utils/chainSegment.ts +16 -5
  203. package/src/chain/blocks/verifyBlocksExecutionPayloads.ts +1 -1
  204. package/src/chain/blocks/verifyBlocksSanityChecks.ts +1 -1
  205. package/src/chain/blocks/verifyExecutionPayloadEnvelope.ts +3 -3
  206. package/src/chain/bls/multithread/index.ts +0 -1
  207. package/src/chain/chain.ts +61 -2
  208. package/src/chain/errors/blockError.ts +44 -7
  209. package/src/chain/errors/executionPayloadBid.ts +12 -4
  210. package/src/chain/errors/executionPayloadEnvelope.ts +9 -0
  211. package/src/chain/errors/proposerPreferences.ts +16 -1
  212. package/src/chain/lightClient/index.ts +12 -7
  213. package/src/chain/lightClient/proofs.ts +36 -1
  214. package/src/chain/lightClient/types.ts +3 -1
  215. package/src/chain/opPools/aggregatedAttestationPool.ts +4 -2
  216. package/src/chain/opPools/proposerPreferencesPool.ts +1 -1
  217. package/src/chain/prepareNextSlot.ts +1 -1
  218. package/src/chain/produceBlock/produceBlockBody.ts +5 -5
  219. package/src/chain/seenCache/seenExecutionPayloadBids.ts +22 -9
  220. package/src/chain/validation/aggregateAndProof.ts +12 -6
  221. package/src/chain/validation/attestation.ts +12 -6
  222. package/src/chain/validation/blobSidecar.ts +1 -1
  223. package/src/chain/validation/block.ts +69 -4
  224. package/src/chain/validation/executionPayloadBid.ts +119 -28
  225. package/src/chain/validation/executionPayloadEnvelope.ts +37 -0
  226. package/src/chain/validation/proposerPreferences.ts +75 -13
  227. package/src/chain/validation/signatureSets/aggregateAndProof.ts +3 -3
  228. package/src/chain/validatorMonitor.ts +1 -1
  229. package/src/db/repositories/lightclientSyncCommitteeWitness.ts +57 -9
  230. package/src/execution/engine/interface.ts +1 -1
  231. package/src/execution/engine/types.ts +1 -1
  232. package/src/metrics/nodeJsMetrics.ts +1 -1
  233. package/src/network/core/networkCoreWorkerHandler.ts +2 -6
  234. package/src/network/discv5/index.ts +1 -4
  235. package/src/network/gossip/encoding.ts +13 -7
  236. package/src/network/gossip/gossipsub.ts +7 -2
  237. package/src/network/gossip/topic.ts +30 -0
  238. package/src/network/interface.ts +3 -1
  239. package/src/network/libp2p/index.ts +2 -10
  240. package/src/network/network.ts +24 -15
  241. package/src/network/peers/datastore.ts +1 -1
  242. package/src/network/processor/gossipHandlers.ts +12 -6
  243. package/src/network/processor/index.ts +2 -1
  244. package/src/network/reqresp/handlers/executionPayloadEnvelopesByRange.ts +4 -2
  245. package/src/network/reqresp/handlers/index.ts +21 -12
  246. package/src/network/reqresp/handlers/lightClientFinalityUpdate.ts +1 -1
  247. package/src/network/reqresp/handlers/lightClientOptimisticUpdate.ts +1 -1
  248. package/src/network/reqresp/handlers/lightClientUpdatesByRange.ts +6 -2
  249. package/src/network/util.ts +5 -0
  250. package/src/sync/constants.ts +6 -5
  251. package/src/sync/range/batch.ts +31 -10
  252. package/src/sync/range/chain.ts +36 -16
  253. package/src/sync/range/utils/batches.ts +44 -0
  254. package/src/sync/sync.ts +10 -0
  255. package/src/sync/unknownBlock.ts +8 -2
  256. package/src/util/execution.ts +1 -1
  257. package/src/util/profile.ts +1 -31
  258. package/src/util/sszBytes.ts +1 -1
  259. package/lib/bun-wrappers/prometheus-gc-stats.d.ts +0 -2
  260. package/lib/bun-wrappers/prometheus-gc-stats.d.ts.map +0 -1
  261. package/lib/bun-wrappers/prometheus-gc-stats.js +0 -8
  262. package/lib/bun-wrappers/prometheus-gc-stats.js.map +0 -1
  263. package/lib/network/peers/datastore_bun.d.ts +0 -3
  264. package/lib/network/peers/datastore_bun.d.ts.map +0 -1
  265. package/lib/network/peers/datastore_bun.js +0 -3
  266. package/lib/network/peers/datastore_bun.js.map +0 -1
  267. package/src/bun-wrappers/prometheus-gc-stats.ts +0 -7
  268. package/src/network/peers/datastore_bun.ts +0 -3
@@ -23,7 +23,9 @@ import {Batch, BatchError, BatchErrorCode, BatchMetadata, BatchStatus} from "./b
23
23
  import {
24
24
  ChainPeersBalancer,
25
25
  PeerSyncInfo,
26
+ ProcessingFaultKind,
26
27
  batchStartEpochIsAfterSlot,
28
+ classifyProcessingFault,
27
29
  computeHighestTarget,
28
30
  getBatchSlotRange,
29
31
  getNextBatchToProcess,
@@ -708,23 +710,41 @@ export class SyncChain {
708
710
  this.triggerBatchProcessor();
709
711
  } else {
710
712
  this.logger.verbose("Batch process error", logCtx, res.err);
711
- batch.processingError(res.err); // Throws after MAX_BATCH_PROCESSING_ATTEMPTS
712
-
713
- // At least one block was successfully verified and imported, so we can be sure all
714
- // previous batches are valid and we only need to download the current failed batch.
715
- // TODO: Disabled for now
716
- // if (res.err instanceof ChainSegmentError && res.err.importedBlocks > 0) {
717
- // this.advanceChain(batch.startEpoch);
718
- // }
719
-
720
- // The current batch could not be processed, so either this or previous batches are invalid.
721
- // All previous batches (AwaitingValidation) are potentially faulty and marked for retry.
722
- // Progress will be drop back to `this.startEpoch`
723
- for (const pendingBatch of this.batches.values()) {
724
- if (pendingBatch.startEpoch < batch.startEpoch) {
725
- this.logger.verbose("Batch validation error", {id: this.logId, ...pendingBatch.getMetadata()});
726
- pendingBatch.validationError(res.err); // Throws after MAX_BATCH_PROCESSING_ATTEMPTS
713
+
714
+ const invalidatePreviousBatches = (): number => {
715
+ let invalidatedCount = 0;
716
+ for (const pendingBatch of this.batches.values()) {
717
+ if (
718
+ pendingBatch.startEpoch < batch.startEpoch &&
719
+ pendingBatch.state.status === BatchStatus.AwaitingValidation
720
+ ) {
721
+ this.logger.verbose("Batch validation error", {id: this.logId, ...pendingBatch.getMetadata()});
722
+ pendingBatch.validationError(res.err);
723
+ invalidatedCount++;
724
+ }
727
725
  }
726
+ return invalidatedCount;
727
+ };
728
+
729
+ const prevBatch = this.batches.get(batch.startEpoch - EPOCHS_PER_BATCH);
730
+ switch (classifyProcessingFault(res.err, batch, prevBatch)) {
731
+ case ProcessingFaultKind.CurrentBatch:
732
+ batch.processingError(res.err);
733
+ break;
734
+
735
+ case ProcessingFaultKind.PreviousBatch:
736
+ // If no previous batch was invalidated, it means the error is on this batch
737
+ if (invalidatePreviousBatches() === 0) {
738
+ batch.processingError(res.err);
739
+ } else {
740
+ batch.retainForReprocessing();
741
+ }
742
+ break;
743
+
744
+ case ProcessingFaultKind.Ambiguous:
745
+ batch.processingError(res.err);
746
+ invalidatePreviousBatches();
747
+ break;
728
748
  }
729
749
  }
730
750
 
@@ -1,6 +1,7 @@
1
1
  import {SLOTS_PER_EPOCH} from "@lodestar/params";
2
2
  import {computeStartSlotAtEpoch} from "@lodestar/state-transition";
3
3
  import {Epoch, Slot} from "@lodestar/types";
4
+ import {BlockError, BlockErrorCode} from "../../../chain/errors/index.js";
4
5
  import {BATCH_SLOT_OFFSET, EPOCHS_PER_BATCH} from "../../constants.js";
5
6
  import {Batch, BatchStatus} from "../batch.js";
6
7
 
@@ -117,3 +118,46 @@ export function isSyncChainDone(batches: Batch[], lastEpochWithProcessBlocks: Ep
117
118
 
118
119
  return batchStartEpochIsAfterSlot(lastEpochWithProcessBlocks, targetSlot);
119
120
  }
121
+
122
+ /**
123
+ * Where a batch processing error should be attributed.
124
+ */
125
+ export enum ProcessingFaultKind {
126
+ /** This batch's own blocks are bad or incomplete, so redownload this batch. */
127
+ CurrentBatch = "CurrentBatch",
128
+ /** This batch is valid, but a previous batch did not deliver the parent. */
129
+ PreviousBatch = "PreviousBatch",
130
+ /** The fault could be in this batch or a previous batch, so hedge both ways. */
131
+ Ambiguous = "Ambiguous",
132
+ }
133
+
134
+ /**
135
+ * Classify a processChainSegment error for a batch so range sync only redownloads
136
+ * the batch or batches that could actually be at fault.
137
+ * Note that range sync is supposed to only handle linear chain, for forky condition we'll handle it via backward sync
138
+ * in BlockInputSync or the upcoming/TODO beacon_blocks_by_head req/resp.
139
+ */
140
+ export function classifyProcessingFault(err: Error, batch: Batch, prevBatch: Batch | undefined): ProcessingFaultKind {
141
+ if (!(err instanceof BlockError)) {
142
+ return ProcessingFaultKind.CurrentBatch;
143
+ }
144
+
145
+ const {code} = err.type;
146
+ if (code !== BlockErrorCode.PARENT_BLOCK_UNKNOWN && code !== BlockErrorCode.PARENT_PAYLOAD_UNKNOWN) {
147
+ return ProcessingFaultKind.CurrentBatch;
148
+ }
149
+
150
+ const firstErrorSlot = err.signedBlock.message.slot;
151
+ if (firstErrorSlot === batch.startSlot) {
152
+ // note that range sync is for linear chain, so this is clearly an issue of the previous batch
153
+ return prevBatch === undefined ? ProcessingFaultKind.CurrentBatch : ProcessingFaultKind.PreviousBatch;
154
+ }
155
+
156
+ const prevTailSlot = batch.startSlot - 1;
157
+ const prevHasFullTail =
158
+ code === BlockErrorCode.PARENT_PAYLOAD_UNKNOWN
159
+ ? (prevBatch?.getPayloadEnvelopes()?.get(prevTailSlot)?.hasPayloadEnvelope() ?? false)
160
+ : (prevBatch?.getBlocks().some((b) => b.slot === prevTailSlot) ?? false);
161
+
162
+ return prevHasFullTail ? ProcessingFaultKind.CurrentBatch : ProcessingFaultKind.Ambiguous;
163
+ }
package/src/sync/sync.ts CHANGED
@@ -75,6 +75,11 @@ export class BeaconSync implements IBeaconSync {
75
75
  if (metrics) {
76
76
  metrics.syncStatus.addCollect(() => this.scrapeMetrics(metrics));
77
77
  }
78
+
79
+ // A from-scratch or large-gap start boots not synced; updateSyncState resumes once synced
80
+ if (this.state !== SyncState.Synced) {
81
+ this.chain.forkChoice.pauseFastConfirmation();
82
+ }
78
83
  }
79
84
 
80
85
  close(): void {
@@ -228,6 +233,8 @@ export class BeaconSync implements IBeaconSync {
228
233
 
229
234
  // We have become synced, subscribe to all the gossip core topics
230
235
  if (state === SyncState.Synced && this.chain.clock.currentEpoch >= MIN_EPOCH_TO_START_GOSSIP) {
236
+ this.chain.forkChoice.resumeFastConfirmation();
237
+
231
238
  if (!this.network.isSubscribedToGossipCoreTopics()) {
232
239
  this.network
233
240
  .subscribeGossipCoreTopics()
@@ -251,6 +258,9 @@ export class BeaconSync implements IBeaconSync {
251
258
  else if (state !== SyncState.Synced) {
252
259
  const syncDiff = this.chain.clock.currentSlot - this.chain.forkChoice.getHead().slot;
253
260
  if (syncDiff > this.slotImportTolerance * 2) {
261
+ // Same debounce as gossip: transient blips keep the rule running, only a real gap pauses it
262
+ this.chain.forkChoice.pauseFastConfirmation();
263
+
254
264
  if (this.network.isSubscribedToGossipCoreTopics()) {
255
265
  this.logger.warn(`Node sync has fallen behind by ${syncDiff} slots`);
256
266
  this.network
@@ -819,7 +819,7 @@ export class BlockInputSync {
819
819
  // case BlockErrorCode.ALREADY_KNOWN:
820
820
  // case BlockErrorCode.GENESIS_BLOCK:
821
821
 
822
- case BlockErrorCode.PARENT_UNKNOWN:
822
+ case BlockErrorCode.PARENT_BLOCK_UNKNOWN:
823
823
  case BlockErrorCode.PRESTATE_MISSING:
824
824
  // Should not happen, mark as downloaded to try again latter
825
825
  this.logger.debug("Attempted to process block but its parent was still unknown", errorData, res.err);
@@ -841,10 +841,16 @@ export class BlockInputSync {
841
841
 
842
842
  case BlockErrorCode.EXECUTION_ENGINE_ERROR:
843
843
  // Removing the block(s) without penalizing the peers, hoping for EL to
844
- // recover on a latter download + verify attempt
844
+ // recover on a latter download + verify attempt.
845
845
  this.removeAllDescendants(pendingBlock);
846
846
  break;
847
847
 
848
+ case BlockErrorCode.EXECUTION_ENGINE_INVALID:
849
+ // the peer served a bad block
850
+ this.logger.debug("Execution engine rejected block from unknown parent sync", errorData, res.err);
851
+ this.removeAndDownScoreAllDescendants(pendingBlock);
852
+ break;
853
+
848
854
  default:
849
855
  // Block is not correct with respect to our chain. Log error loudly
850
856
  this.logger.debug("Error processing block from unknown parent sync", errorData, res.err);
@@ -199,7 +199,7 @@ export async function getDataColumnSidecarsFromExecution(
199
199
  const previouslyMissingColumns = input.getMissingSampledColumnMeta().missing;
200
200
  const sampledColumns = previouslyMissingColumns.map((columnIndex) => dataColumnSidecars[columnIndex]);
201
201
 
202
- // for columns that we already seen, it will be ignored through `ignoreDuplicatePublishError` gossip option
202
+ // for columns we have already seen, publishDataColumnSidecar() catches PublishError.Duplicate and marks alreadyPublished=true
203
203
  emitter.emit(ChainEvent.publishDataColumns, sampledColumns);
204
204
  // TODO: Can we record dataColumns.sentPeersPerSubnet metric here somehow
205
205
 
@@ -8,21 +8,10 @@ export enum ProfileThread {
8
8
  DISC5 = "discv5",
9
9
  }
10
10
 
11
- /**
12
- * The time to take a Bun profile.
13
- * If we increase this time it'll potentiall cause the app to crash.
14
- * If we decrease this time, profile recorded will be fragmented and hard to analyze.
15
- */
16
- const BUN_PROFILE_MS = 3 * 1000;
17
-
18
- export async function profileThread(thread: ProfileThread, durationMs: number, dirpath: string): Promise<string> {
19
- return globalThis.Bun ? profileBun(thread, durationMs) : profileNodeJS(thread, durationMs, dirpath);
20
- }
21
-
22
11
  /**
23
12
  * Take `durationMs` profile of the current thread and return the persisted file path.
24
13
  */
25
- async function profileNodeJS(thread: ProfileThread, durationMs: number, dirpath: string): Promise<string> {
14
+ export async function profileThread(thread: ProfileThread, durationMs: number, dirpath: string): Promise<string> {
26
15
  const inspector = await import("node:inspector");
27
16
 
28
17
  // due to some typing issues, not able to use promisify here
@@ -54,25 +43,6 @@ async function profileNodeJS(thread: ProfileThread, durationMs: number, dirpath:
54
43
  return filePath;
55
44
  }
56
45
 
57
- /**
58
- * Unlike NodeJS, Bun console.profile() api flush data to the inspector,
59
- * so this api returns ms taken of this profile instead of file path.
60
- */
61
- async function profileBun(thread: ProfileThread, durationMs: number): Promise<string> {
62
- const start = Date.now();
63
- let now = Date.now();
64
- while (now - start < durationMs) {
65
- // biome-ignore lint/suspicious/noConsole: need to use console api to profile in Bun
66
- console.profile(String(now));
67
- await sleep(BUN_PROFILE_MS);
68
- // biome-ignore lint/suspicious/noConsole: need to use console api to profile in Bun
69
- console.profileEnd(String(now));
70
- now = Date.now();
71
- }
72
-
73
- return `Successfully take Bun ${thread} thread profile in ${now - start}ms. Check your inspector to see the profile.`;
74
- }
75
-
76
46
  /**
77
47
  * Write heap snapshot of the current thread to the specified file.
78
48
  */
@@ -706,7 +706,7 @@ export function getBlockRootFromPayloadAttestationMessageSerialized(data: Uint8A
706
706
  * blockHash: Bytes32 (32 bytes)
707
707
  * prevRandao: Bytes32 (32 bytes)
708
708
  * feeRecipient: ExecutionAddress(20 bytes)
709
- * gasLimit: UintNum64 (8 bytes)
709
+ * gasLimit: UintBn64 (8 bytes)
710
710
  * builderIndex: BuilderIndex (8 bytes)
711
711
  * slot: Slot (8 bytes) ← absolute offset 264
712
712
  */
@@ -1,2 +0,0 @@
1
- export declare function gcStats(): () => void;
2
- //# sourceMappingURL=prometheus-gc-stats.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"prometheus-gc-stats.d.ts","sourceRoot":"","sources":["../../src/bun-wrappers/prometheus-gc-stats.ts"],"names":[],"mappings":"AAIA,wBAAgB,OAAO,eAEtB"}
@@ -1,8 +0,0 @@
1
- // Bun does not support `GCProfiler` from `node:v8`a
2
- // Which is exposed from `@chainsafe/prometheus-gc-stats` and used in `packages/beacon-node/src/metrics/nodeJsMetrics.ts`
3
- // So we expose a dummy function for Bun runtime which do nothing for now
4
- // TODO: May look get some useful data from `bun:jsc`
5
- export function gcStats() {
6
- return () => { };
7
- }
8
- //# sourceMappingURL=prometheus-gc-stats.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"prometheus-gc-stats.js","sourceRoot":"","sources":["../../src/bun-wrappers/prometheus-gc-stats.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,yHAAyH;AACzH,yEAAyE;AACzE,qDAAqD;AACrD,MAAM,UAAU,OAAO,GAAG;IACxB,OAAO,GAAG,EAAE,CAAC,EAAC,CAAC,CAAC;AAAA,CACjB"}
@@ -1,3 +0,0 @@
1
- import { FsDatastore } from "datastore-fs";
2
- export declare const LevelDatastore: typeof FsDatastore;
3
- //# sourceMappingURL=datastore_bun.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"datastore_bun.d.ts","sourceRoot":"","sources":["../../../src/network/peers/datastore_bun.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,cAAc,CAAC;AAEzC,eAAO,MAAM,cAAc,oBAAc,CAAC"}
@@ -1,3 +0,0 @@
1
- import { FsDatastore } from "datastore-fs";
2
- export const LevelDatastore = FsDatastore;
3
- //# sourceMappingURL=datastore_bun.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"datastore_bun.js","sourceRoot":"","sources":["../../../src/network/peers/datastore_bun.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,cAAc,CAAC;AAEzC,MAAM,CAAC,MAAM,cAAc,GAAG,WAAW,CAAC"}
@@ -1,7 +0,0 @@
1
- // Bun does not support `GCProfiler` from `node:v8`a
2
- // Which is exposed from `@chainsafe/prometheus-gc-stats` and used in `packages/beacon-node/src/metrics/nodeJsMetrics.ts`
3
- // So we expose a dummy function for Bun runtime which do nothing for now
4
- // TODO: May look get some useful data from `bun:jsc`
5
- export function gcStats() {
6
- return () => {};
7
- }
@@ -1,3 +0,0 @@
1
- import {FsDatastore} from "datastore-fs";
2
-
3
- export const LevelDatastore = FsDatastore;