@lodestar/beacon-node 1.46.0-dev.4c86702f24 → 1.46.0-dev.74a3175f1e

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 (81) hide show
  1. package/lib/api/impl/config/constants.d.ts +1 -0
  2. package/lib/api/impl/config/constants.d.ts.map +1 -1
  3. package/lib/api/impl/config/constants.js +2 -1
  4. package/lib/api/impl/config/constants.js.map +1 -1
  5. package/lib/api/impl/validator/index.js +1 -1
  6. package/lib/api/impl/validator/index.js.map +1 -1
  7. package/lib/chain/archiveStore/archiveStore.d.ts.map +1 -1
  8. package/lib/chain/archiveStore/archiveStore.js +17 -3
  9. package/lib/chain/archiveStore/archiveStore.js.map +1 -1
  10. package/lib/chain/blocks/verifyExecutionPayloadEnvelope.js +1 -1
  11. package/lib/chain/blocks/verifyExecutionPayloadEnvelope.js.map +1 -1
  12. package/lib/chain/errors/executionPayloadBid.d.ts +11 -4
  13. package/lib/chain/errors/executionPayloadBid.d.ts.map +1 -1
  14. package/lib/chain/errors/executionPayloadBid.js +1 -0
  15. package/lib/chain/errors/executionPayloadBid.js.map +1 -1
  16. package/lib/chain/opPools/aggregatedAttestationPool.d.ts.map +1 -1
  17. package/lib/chain/opPools/aggregatedAttestationPool.js +2 -1
  18. package/lib/chain/opPools/aggregatedAttestationPool.js.map +1 -1
  19. package/lib/chain/prepareNextSlot.js +1 -1
  20. package/lib/chain/prepareNextSlot.js.map +1 -1
  21. package/lib/chain/produceBlock/produceBlockBody.js +4 -4
  22. package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
  23. package/lib/chain/seenCache/seenExecutionPayloadBids.d.ts +6 -5
  24. package/lib/chain/seenCache/seenExecutionPayloadBids.d.ts.map +1 -1
  25. package/lib/chain/seenCache/seenExecutionPayloadBids.js +16 -8
  26. package/lib/chain/seenCache/seenExecutionPayloadBids.js.map +1 -1
  27. package/lib/chain/validation/blobSidecar.js +1 -1
  28. package/lib/chain/validation/executionPayloadBid.d.ts +0 -5
  29. package/lib/chain/validation/executionPayloadBid.d.ts.map +1 -1
  30. package/lib/chain/validation/executionPayloadBid.js +70 -24
  31. package/lib/chain/validation/executionPayloadBid.js.map +1 -1
  32. package/lib/chain/validatorMonitor.js +1 -1
  33. package/lib/chain/validatorMonitor.js.map +1 -1
  34. package/lib/execution/engine/interface.d.ts +1 -1
  35. package/lib/execution/engine/types.js +1 -1
  36. package/lib/execution/engine/types.js.map +1 -1
  37. package/lib/network/gossip/topic.d.ts +5 -5
  38. package/lib/network/processor/index.d.ts.map +1 -1
  39. package/lib/network/processor/index.js +2 -1
  40. package/lib/network/processor/index.js.map +1 -1
  41. package/lib/network/reqresp/handlers/lightClientUpdatesByRange.d.ts.map +1 -1
  42. package/lib/network/reqresp/handlers/lightClientUpdatesByRange.js +5 -1
  43. package/lib/network/reqresp/handlers/lightClientUpdatesByRange.js.map +1 -1
  44. package/lib/sync/constants.d.ts +6 -5
  45. package/lib/sync/constants.d.ts.map +1 -1
  46. package/lib/sync/constants.js +6 -5
  47. package/lib/sync/constants.js.map +1 -1
  48. package/lib/sync/range/batch.d.ts +10 -1
  49. package/lib/sync/range/batch.d.ts.map +1 -1
  50. package/lib/sync/range/batch.js +28 -10
  51. package/lib/sync/range/batch.js.map +1 -1
  52. package/lib/sync/range/chain.d.ts.map +1 -1
  53. package/lib/sync/range/chain.js +30 -15
  54. package/lib/sync/range/chain.js.map +1 -1
  55. package/lib/sync/range/utils/batches.d.ts +18 -0
  56. package/lib/sync/range/utils/batches.d.ts.map +1 -1
  57. package/lib/sync/range/utils/batches.js +39 -0
  58. package/lib/sync/range/utils/batches.js.map +1 -1
  59. package/lib/util/sszBytes.js +1 -1
  60. package/package.json +14 -14
  61. package/src/api/impl/config/constants.ts +2 -0
  62. package/src/api/impl/validator/index.ts +1 -1
  63. package/src/chain/archiveStore/archiveStore.ts +20 -3
  64. package/src/chain/blocks/verifyExecutionPayloadEnvelope.ts +1 -1
  65. package/src/chain/errors/executionPayloadBid.ts +12 -4
  66. package/src/chain/opPools/aggregatedAttestationPool.ts +3 -1
  67. package/src/chain/prepareNextSlot.ts +1 -1
  68. package/src/chain/produceBlock/produceBlockBody.ts +5 -5
  69. package/src/chain/seenCache/seenExecutionPayloadBids.ts +22 -9
  70. package/src/chain/validation/blobSidecar.ts +1 -1
  71. package/src/chain/validation/executionPayloadBid.ts +87 -26
  72. package/src/chain/validatorMonitor.ts +1 -1
  73. package/src/execution/engine/interface.ts +1 -1
  74. package/src/execution/engine/types.ts +1 -1
  75. package/src/network/processor/index.ts +2 -1
  76. package/src/network/reqresp/handlers/lightClientUpdatesByRange.ts +5 -1
  77. package/src/sync/constants.ts +6 -5
  78. package/src/sync/range/batch.ts +31 -10
  79. package/src/sync/range/chain.ts +36 -16
  80. package/src/sync/range/utils/batches.ts +44 -0
  81. package/src/util/sszBytes.ts +1 -1
@@ -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
+ }
@@ -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
  */