@lodestar/beacon-node 1.41.0-dev.bb33751bfd → 1.41.0-dev.be5acbb8f7

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 (166) hide show
  1. package/lib/api/impl/beacon/blocks/index.d.ts.map +1 -1
  2. package/lib/api/impl/beacon/blocks/index.js +3 -2
  3. package/lib/api/impl/beacon/blocks/index.js.map +1 -1
  4. package/lib/api/impl/validator/index.d.ts.map +1 -1
  5. package/lib/api/impl/validator/index.js +26 -10
  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.map +1 -1
  9. package/lib/chain/archiveStore/utils/archiveBlocks.d.ts +3 -8
  10. package/lib/chain/archiveStore/utils/archiveBlocks.d.ts.map +1 -1
  11. package/lib/chain/archiveStore/utils/archiveBlocks.js +1 -1
  12. package/lib/chain/archiveStore/utils/archiveBlocks.js.map +1 -1
  13. package/lib/chain/archiveStore/utils/updateBackfillRange.js +1 -1
  14. package/lib/chain/archiveStore/utils/updateBackfillRange.js.map +1 -1
  15. package/lib/chain/blocks/blockInput/blockInput.d.ts +5 -0
  16. package/lib/chain/blocks/blockInput/blockInput.d.ts.map +1 -1
  17. package/lib/chain/blocks/blockInput/blockInput.js +24 -0
  18. package/lib/chain/blocks/blockInput/blockInput.js.map +1 -1
  19. package/lib/chain/blocks/blockInput/types.d.ts +16 -0
  20. package/lib/chain/blocks/blockInput/types.d.ts.map +1 -1
  21. package/lib/chain/blocks/importBlock.d.ts.map +1 -1
  22. package/lib/chain/blocks/importBlock.js +27 -4
  23. package/lib/chain/blocks/importBlock.js.map +1 -1
  24. package/lib/chain/blocks/verifyBlocksSanityChecks.d.ts.map +1 -1
  25. package/lib/chain/blocks/verifyBlocksSanityChecks.js +4 -1
  26. package/lib/chain/blocks/verifyBlocksSanityChecks.js.map +1 -1
  27. package/lib/chain/blocks/writeBlockInputToDb.d.ts +12 -3
  28. package/lib/chain/blocks/writeBlockInputToDb.d.ts.map +1 -1
  29. package/lib/chain/blocks/writeBlockInputToDb.js +92 -98
  30. package/lib/chain/blocks/writeBlockInputToDb.js.map +1 -1
  31. package/lib/chain/chain.d.ts +2 -2
  32. package/lib/chain/chain.d.ts.map +1 -1
  33. package/lib/chain/chain.js +13 -12
  34. package/lib/chain/chain.js.map +1 -1
  35. package/lib/chain/emitter.d.ts +3 -3
  36. package/lib/chain/emitter.d.ts.map +1 -1
  37. package/lib/chain/errors/executionPayloadBid.d.ts +1 -1
  38. package/lib/chain/errors/executionPayloadEnvelope.d.ts +2 -2
  39. package/lib/chain/errors/executionPayloadEnvelope.d.ts.map +1 -1
  40. package/lib/chain/errors/executionPayloadEnvelope.js.map +1 -1
  41. package/lib/chain/errors/payloadAttestation.d.ts +1 -1
  42. package/lib/chain/forkChoice/index.d.ts.map +1 -1
  43. package/lib/chain/forkChoice/index.js +30 -24
  44. package/lib/chain/forkChoice/index.js.map +1 -1
  45. package/lib/chain/opPools/aggregatedAttestationPool.js +1 -1
  46. package/lib/chain/opPools/aggregatedAttestationPool.js.map +1 -1
  47. package/lib/chain/produceBlock/computeNewStateRoot.d.ts +0 -1
  48. package/lib/chain/produceBlock/computeNewStateRoot.d.ts.map +1 -1
  49. package/lib/chain/produceBlock/computeNewStateRoot.js +4 -3
  50. package/lib/chain/produceBlock/computeNewStateRoot.js.map +1 -1
  51. package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
  52. package/lib/chain/produceBlock/produceBlockBody.js +1 -2
  53. package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
  54. package/lib/chain/regen/queued.d.ts.map +1 -1
  55. package/lib/chain/regen/queued.js +4 -1
  56. package/lib/chain/regen/queued.js.map +1 -1
  57. package/lib/chain/regen/regen.d.ts.map +1 -1
  58. package/lib/chain/regen/regen.js +6 -2
  59. package/lib/chain/regen/regen.js.map +1 -1
  60. package/lib/chain/seenCache/seenGossipBlockInput.d.ts +5 -1
  61. package/lib/chain/seenCache/seenGossipBlockInput.d.ts.map +1 -1
  62. package/lib/chain/seenCache/seenGossipBlockInput.js +21 -8
  63. package/lib/chain/seenCache/seenGossipBlockInput.js.map +1 -1
  64. package/lib/chain/validation/aggregateAndProof.js +1 -1
  65. package/lib/chain/validation/aggregateAndProof.js.map +1 -1
  66. package/lib/chain/validation/attestation.js +3 -3
  67. package/lib/chain/validation/attestation.js.map +1 -1
  68. package/lib/chain/validation/attesterSlashing.d.ts.map +1 -1
  69. package/lib/chain/validation/attesterSlashing.js +8 -1
  70. package/lib/chain/validation/attesterSlashing.js.map +1 -1
  71. package/lib/chain/validation/blobSidecar.js +2 -2
  72. package/lib/chain/validation/blobSidecar.js.map +1 -1
  73. package/lib/chain/validation/block.d.ts.map +1 -1
  74. package/lib/chain/validation/block.js +6 -3
  75. package/lib/chain/validation/block.js.map +1 -1
  76. package/lib/chain/validation/dataColumnSidecar.js +1 -1
  77. package/lib/chain/validation/dataColumnSidecar.js.map +1 -1
  78. package/lib/chain/validation/executionPayloadBid.js +1 -2
  79. package/lib/chain/validation/executionPayloadBid.js.map +1 -1
  80. package/lib/chain/validation/executionPayloadEnvelope.js +4 -4
  81. package/lib/chain/validation/executionPayloadEnvelope.js.map +1 -1
  82. package/lib/chain/validation/payloadAttestationMessage.js +1 -2
  83. package/lib/chain/validation/payloadAttestationMessage.js.map +1 -1
  84. package/lib/db/index.d.ts +1 -0
  85. package/lib/db/index.d.ts.map +1 -1
  86. package/lib/db/index.js +1 -0
  87. package/lib/db/index.js.map +1 -1
  88. package/lib/metrics/metrics/lodestar.d.ts +1 -0
  89. package/lib/metrics/metrics/lodestar.d.ts.map +1 -1
  90. package/lib/metrics/metrics/lodestar.js +4 -0
  91. package/lib/metrics/metrics/lodestar.js.map +1 -1
  92. package/lib/network/network.d.ts.map +1 -1
  93. package/lib/network/network.js +1 -1
  94. package/lib/network/network.js.map +1 -1
  95. package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
  96. package/lib/network/processor/gossipHandlers.js +1 -0
  97. package/lib/network/processor/gossipHandlers.js.map +1 -1
  98. package/lib/network/reqresp/handlers/beaconBlocksByRange.d.ts.map +1 -1
  99. package/lib/network/reqresp/handlers/beaconBlocksByRange.js +3 -2
  100. package/lib/network/reqresp/handlers/beaconBlocksByRange.js.map +1 -1
  101. package/lib/network/reqresp/handlers/blobSidecarsByRange.d.ts.map +1 -1
  102. package/lib/network/reqresp/handlers/blobSidecarsByRange.js +3 -2
  103. package/lib/network/reqresp/handlers/blobSidecarsByRange.js.map +1 -1
  104. package/lib/network/reqresp/handlers/blobSidecarsByRoot.js +1 -1
  105. package/lib/network/reqresp/handlers/blobSidecarsByRoot.js.map +1 -1
  106. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.d.ts.map +1 -1
  107. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js +3 -2
  108. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js.map +1 -1
  109. package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.js +1 -1
  110. package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.js.map +1 -1
  111. package/lib/network/reqresp/utils/collect.d.ts +1 -1
  112. package/lib/network/reqresp/utils/collectSequentialBlocksInRange.d.ts +1 -1
  113. package/lib/sync/utils/downloadByRoot.d.ts +1 -1
  114. package/lib/sync/utils/remoteSyncType.d.ts +1 -1
  115. package/lib/util/serializedCache.d.ts +4 -4
  116. package/lib/util/serializedCache.d.ts.map +1 -1
  117. package/lib/util/serializedCache.js +6 -4
  118. package/lib/util/serializedCache.js.map +1 -1
  119. package/package.json +26 -26
  120. package/src/api/impl/beacon/blocks/index.ts +3 -2
  121. package/src/api/impl/validator/index.ts +26 -12
  122. package/src/chain/archiveStore/archiveStore.ts +5 -5
  123. package/src/chain/archiveStore/utils/archiveBlocks.ts +4 -5
  124. package/src/chain/archiveStore/utils/updateBackfillRange.ts +1 -1
  125. package/src/chain/blocks/blockInput/blockInput.ts +35 -0
  126. package/src/chain/blocks/blockInput/types.ts +17 -0
  127. package/src/chain/blocks/importBlock.ts +35 -4
  128. package/src/chain/blocks/verifyBlocksSanityChecks.ts +7 -2
  129. package/src/chain/blocks/writeBlockInputToDb.ts +105 -104
  130. package/src/chain/chain.ts +31 -19
  131. package/src/chain/emitter.ts +3 -3
  132. package/src/chain/errors/executionPayloadBid.ts +1 -1
  133. package/src/chain/errors/executionPayloadEnvelope.ts +6 -2
  134. package/src/chain/errors/payloadAttestation.ts +1 -1
  135. package/src/chain/forkChoice/index.ts +39 -21
  136. package/src/chain/opPools/aggregatedAttestationPool.ts +1 -1
  137. package/src/chain/produceBlock/computeNewStateRoot.ts +4 -3
  138. package/src/chain/produceBlock/produceBlockBody.ts +1 -2
  139. package/src/chain/regen/queued.ts +7 -2
  140. package/src/chain/regen/regen.ts +9 -3
  141. package/src/chain/seenCache/seenGossipBlockInput.ts +38 -10
  142. package/src/chain/validation/aggregateAndProof.ts +1 -1
  143. package/src/chain/validation/attestation.ts +3 -3
  144. package/src/chain/validation/attesterSlashing.ts +9 -0
  145. package/src/chain/validation/blobSidecar.ts +2 -2
  146. package/src/chain/validation/block.ts +9 -4
  147. package/src/chain/validation/dataColumnSidecar.ts +1 -1
  148. package/src/chain/validation/executionPayloadBid.ts +1 -2
  149. package/src/chain/validation/executionPayloadEnvelope.ts +4 -4
  150. package/src/chain/validation/payloadAttestationMessage.ts +1 -2
  151. package/src/db/index.ts +1 -0
  152. package/src/metrics/metrics/lodestar.ts +4 -0
  153. package/src/network/network.ts +2 -1
  154. package/src/network/processor/gossipHandlers.ts +6 -1
  155. package/src/network/processor/gossipValidatorFn.ts +1 -1
  156. package/src/network/reqresp/ReqRespBeaconNode.ts +1 -1
  157. package/src/network/reqresp/handlers/beaconBlocksByRange.ts +4 -3
  158. package/src/network/reqresp/handlers/blobSidecarsByRange.ts +3 -2
  159. package/src/network/reqresp/handlers/blobSidecarsByRoot.ts +1 -1
  160. package/src/network/reqresp/handlers/dataColumnSidecarsByRange.ts +4 -3
  161. package/src/network/reqresp/handlers/dataColumnSidecarsByRoot.ts +2 -2
  162. package/src/network/reqresp/utils/collect.ts +1 -1
  163. package/src/network/reqresp/utils/collectSequentialBlocksInRange.ts +1 -1
  164. package/src/sync/utils/downloadByRoot.ts +1 -1
  165. package/src/sync/utils/remoteSyncType.ts +1 -1
  166. package/src/util/serializedCache.ts +7 -5
@@ -4,9 +4,11 @@ import {
4
4
  ForkChoice,
5
5
  ForkChoiceStore,
6
6
  JustifiedBalancesGetter,
7
+ PayloadStatus,
7
8
  ProtoArray,
8
9
  ProtoBlock,
9
10
  ForkChoiceOpts as RawForkChoiceOpts,
11
+ getCheckpointPayloadStatus,
10
12
  } from "@lodestar/fork-choice";
11
13
  import {ZERO_HASH_HEX} from "@lodestar/params";
12
14
  import {
@@ -104,6 +106,14 @@ export function initializeForkChoiceFromFinalizedState(
104
106
  // production code use ForkChoice constructor directly
105
107
  const forkchoiceConstructor = opts.forkchoiceConstructor ?? ForkChoice;
106
108
 
109
+ const isForkPostGloas = (state as CachedBeaconStateGloas).latestBlockHash !== undefined;
110
+
111
+ // Determine justified checkpoint payload status
112
+ const justifiedPayloadStatus = getCheckpointPayloadStatus(state, justifiedCheckpoint.epoch);
113
+
114
+ // Determine finalized checkpoint payload status
115
+ const finalizedPayloadStatus = getCheckpointPayloadStatus(state, finalizedCheckpoint.epoch);
116
+
107
117
  return new forkchoiceConstructor(
108
118
  config,
109
119
 
@@ -113,6 +123,8 @@ export function initializeForkChoiceFromFinalizedState(
113
123
  finalizedCheckpoint,
114
124
  justifiedBalances,
115
125
  justifiedBalancesGetter,
126
+ justifiedPayloadStatus,
127
+ finalizedPayloadStatus,
116
128
  {
117
129
  onJustified: (cp) => emitter.emit(ChainEvent.forkChoiceJustified, cp),
118
130
  onFinalized: (cp) => emitter.emit(ChainEvent.forkChoiceFinalized, cp),
@@ -145,15 +157,12 @@ export function initializeForkChoiceFromFinalizedState(
145
157
  : {executionPayloadBlockHash: null, executionStatus: ExecutionStatus.PreMerge}),
146
158
 
147
159
  dataAvailabilityStatus: DataAvailabilityStatus.PreData,
148
- ...(computeEpochAtSlot(blockHeader.slot) < state.config.GLOAS_FORK_EPOCH
149
- ? {
150
- builderIndex: undefined,
151
- blockHashHex: undefined,
152
- }
153
- : {
154
- builderIndex: (state as CachedBeaconStateGloas).latestExecutionPayloadBid.builderIndex,
155
- blockHashHex: toRootHex((state as CachedBeaconStateGloas).latestExecutionPayloadBid.blockHash),
156
- }),
160
+ payloadStatus: isForkPostGloas ? PayloadStatus.PENDING : PayloadStatus.FULL, // TODO GLOAS: Post-gloas how do we know if the checkpoint payload is FULL or EMPTY?
161
+ builderIndex: isForkPostGloas ? (state as CachedBeaconStateGloas).latestExecutionPayloadBid.builderIndex : null,
162
+ blockHashFromBid: isForkPostGloas
163
+ ? toRootHex((state as CachedBeaconStateGloas).latestExecutionPayloadBid.blockHash)
164
+ : null,
165
+ parentBlockHash: isForkPostGloas ? toRootHex((state as CachedBeaconStateGloas).latestBlockHash) : null,
157
166
  },
158
167
  currentSlot
159
168
  ),
@@ -196,12 +205,22 @@ export function initializeForkChoiceFromUnfinalizedState(
196
205
 
197
206
  // this is not the justified state, but there is no other ways to get justified balances
198
207
  const justifiedBalances = getEffectiveBalanceIncrementsZeroInactive(unfinalizedState);
208
+
209
+ const isForkPostGloas = (unfinalizedState as CachedBeaconStateGloas).latestBlockHash !== undefined;
210
+
211
+ // For unfinalized state, use getCheckpointPayloadStatus to determine the correct status.
212
+ // It checks state.execution_payload_availability to determine EMPTY vs FULL.
213
+ const justifiedPayloadStatus = getCheckpointPayloadStatus(unfinalizedState, justifiedCheckpoint.epoch);
214
+ const finalizedPayloadStatus = getCheckpointPayloadStatus(unfinalizedState, finalizedCheckpoint.epoch);
215
+
199
216
  const store = new ForkChoiceStore(
200
217
  currentSlot,
201
218
  justifiedCheckpoint,
202
219
  finalizedCheckpoint,
203
220
  justifiedBalances,
204
221
  justifiedBalancesGetter,
222
+ justifiedPayloadStatus,
223
+ finalizedPayloadStatus,
205
224
  {
206
225
  onJustified: (cp) => emitter.emit(ChainEvent.forkChoiceJustified, cp),
207
226
  onFinalized: (cp) => emitter.emit(ChainEvent.forkChoiceFinalized, cp),
@@ -235,15 +254,14 @@ export function initializeForkChoiceFromUnfinalizedState(
235
254
  : {executionPayloadBlockHash: null, executionStatus: ExecutionStatus.PreMerge}),
236
255
 
237
256
  dataAvailabilityStatus: DataAvailabilityStatus.PreData,
238
- ...(computeEpochAtSlot(blockHeader.slot) < unfinalizedState.config.GLOAS_FORK_EPOCH
239
- ? {
240
- builderIndex: undefined,
241
- blockHashHex: undefined,
242
- }
243
- : {
244
- builderIndex: (unfinalizedState as CachedBeaconStateGloas).latestExecutionPayloadBid.builderIndex,
245
- blockHashHex: toRootHex((unfinalizedState as CachedBeaconStateGloas).latestExecutionPayloadBid.blockHash),
246
- }),
257
+ payloadStatus: isForkPostGloas ? PayloadStatus.PENDING : PayloadStatus.FULL, // TODO GLOAS: Post-gloas how do we know if the checkpoint payload is FULL or EMPTY?
258
+ builderIndex: isForkPostGloas
259
+ ? (unfinalizedState as CachedBeaconStateGloas).latestExecutionPayloadBid.builderIndex
260
+ : null,
261
+ blockHashFromBid: isForkPostGloas
262
+ ? toRootHex((unfinalizedState as CachedBeaconStateGloas).latestExecutionPayloadBid.blockHash)
263
+ : null,
264
+ parentBlockHash: isForkPostGloas ? toRootHex((unfinalizedState as CachedBeaconStateGloas).latestBlockHash) : null,
247
265
  };
248
266
 
249
267
  const parentSlot = blockHeader.slot - 1;
@@ -285,9 +303,9 @@ export function initializeForkChoiceFromUnfinalizedState(
285
303
  };
286
304
 
287
305
  const protoArray = ProtoArray.initialize(finalizedBlock, currentSlot);
288
- protoArray.onBlock(justifiedBlock, currentSlot);
289
- protoArray.onBlock(parentBlock, currentSlot);
290
- protoArray.onBlock(headBlock, currentSlot);
306
+ protoArray.onBlock(justifiedBlock, currentSlot, null);
307
+ protoArray.onBlock(parentBlock, currentSlot, null);
308
+ protoArray.onBlock(headBlock, currentSlot, null);
291
309
 
292
310
  logger?.verbose("Initialized protoArray successfully", {...logCtx, length: protoArray.length()});
293
311
 
@@ -864,7 +864,7 @@ function isValidShuffling(
864
864
  // attestation's shuffling is the same as the current state's.
865
865
  // To account for skipped slots, find the first block at *or before* the pivot slot.
866
866
  const beaconBlockRootHex = blockRootHex;
867
- const beaconBlock = forkChoice.getBlockHex(beaconBlockRootHex);
867
+ const beaconBlock = forkChoice.getBlockHexDefaultStatus(beaconBlockRootHex);
868
868
  if (!beaconBlock) {
869
869
  return InvalidAttestationData.BlockNotInForkChoice;
870
870
  }
@@ -61,7 +61,6 @@ export function computeNewStateRoot(
61
61
  * Compute the state root after processing an execution payload envelope.
62
62
  * Similar to `computeNewStateRoot` but for payload envelope processing.
63
63
  *
64
- * The `postBlockState` is mutated in place, callers must ensure it is not needed afterward.
65
64
  */
66
65
  export function computeEnvelopeStateRoot(
67
66
  metrics: Metrics | null,
@@ -74,13 +73,15 @@ export function computeEnvelopeStateRoot(
74
73
  };
75
74
 
76
75
  const processEnvelopeTimer = metrics?.blockPayload.executionPayloadEnvelopeProcessingTime.startTimer();
77
- processExecutionPayloadEnvelope(postBlockState, signedEnvelope, false);
76
+ const postEnvelopeState = processExecutionPayloadEnvelope(postBlockState, signedEnvelope, false, {
77
+ dontTransferCache: true,
78
+ });
78
79
  processEnvelopeTimer?.();
79
80
 
80
81
  const hashTreeRootTimer = metrics?.stateHashTreeRootTime.startTimer({
81
82
  source: StateHashTreeRootSource.computeEnvelopeStateRoot,
82
83
  });
83
- const stateRoot = postBlockState.hashTreeRoot();
84
+ const stateRoot = postEnvelopeState.hashTreeRoot();
84
85
  hashTreeRootTimer?.();
85
86
 
86
87
  return stateRoot;
@@ -723,8 +723,7 @@ export function getPayloadAttributesForSSE(
723
723
 
724
724
  let parentBlockNumber: number;
725
725
  if (isForkPostGloas(fork)) {
726
- // TODO GLOAS: revisit this after fork choice changes are merged
727
- const parentBlock = chain.forkChoice.getBlock(parentBlockRoot);
726
+ const parentBlock = chain.forkChoice.getBlockHexAndBlockHash(toRootHex(parentBlockRoot), toRootHex(parentHash));
728
727
  if (parentBlock?.executionPayloadBlockHash == null) {
729
728
  throw Error(`Parent block not found in fork choice root=${toRootHex(parentBlockRoot)}`);
730
729
  }
@@ -1,7 +1,7 @@
1
1
  import {routes} from "@lodestar/api";
2
2
  import {IForkChoice, ProtoBlock} from "@lodestar/fork-choice";
3
3
  import {CachedBeaconStateAllForks, computeEpochAtSlot} from "@lodestar/state-transition";
4
- import {BeaconBlock, Epoch, RootHex, Slot, phase0} from "@lodestar/types";
4
+ import {BeaconBlock, Epoch, RootHex, Slot, isGloasBeaconBlock, phase0} from "@lodestar/types";
5
5
  import {Logger, toRootHex} from "@lodestar/utils";
6
6
  import {Metrics} from "../../metrics/index.js";
7
7
  import {JobItemQueue} from "../../util/queue/index.js";
@@ -88,7 +88,12 @@ export class QueuedStateRegenerator implements IStateRegenerator {
88
88
  */
89
89
  getPreStateSync(block: BeaconBlock): CachedBeaconStateAllForks | null {
90
90
  const parentRoot = toRootHex(block.parentRoot);
91
- const parentBlock = this.forkChoice.getBlockHex(parentRoot);
91
+ const parentBlock = isGloasBeaconBlock(block)
92
+ ? this.forkChoice.getBlockHexAndBlockHash(
93
+ parentRoot,
94
+ toRootHex(block.body.signedExecutionPayloadBid.message.parentBlockHash)
95
+ )
96
+ : this.forkChoice.getBlockHexDefaultStatus(parentRoot);
92
97
  if (!parentBlock) {
93
98
  throw new RegenError({
94
99
  code: RegenErrorCode.BLOCK_NOT_IN_FORKCHOICE,
@@ -11,7 +11,7 @@ import {
11
11
  processSlots,
12
12
  stateTransition,
13
13
  } from "@lodestar/state-transition";
14
- import {BeaconBlock, RootHex, SignedBeaconBlock, Slot} from "@lodestar/types";
14
+ import {BeaconBlock, RootHex, SignedBeaconBlock, Slot, isGloasBeaconBlock} from "@lodestar/types";
15
15
  import {Logger, fromHex, toRootHex} from "@lodestar/utils";
16
16
  import {IBeaconDb} from "../../db/index.js";
17
17
  import {Metrics} from "../../metrics/index.js";
@@ -58,7 +58,13 @@ export class StateRegenerator implements IStateRegeneratorInternal {
58
58
  opts: StateRegenerationOpts,
59
59
  regenCaller: RegenCaller
60
60
  ): Promise<CachedBeaconStateAllForks> {
61
- const parentBlock = this.modules.forkChoice.getBlock(block.parentRoot);
61
+ const parentRoot = toRootHex(block.parentRoot);
62
+ const parentBlock = isGloasBeaconBlock(block)
63
+ ? this.modules.forkChoice.getBlockHexAndBlockHash(
64
+ parentRoot,
65
+ toRootHex(block.body.signedExecutionPayloadBid.message.parentBlockHash)
66
+ )
67
+ : this.modules.forkChoice.getBlockHexDefaultStatus(parentRoot);
62
68
  if (!parentBlock) {
63
69
  throw new RegenError({
64
70
  code: RegenErrorCode.BLOCK_NOT_IN_FORKCHOICE,
@@ -152,7 +158,7 @@ export class StateRegenerator implements IStateRegeneratorInternal {
152
158
 
153
159
  const getSeedStateTimer = this.modules.metrics?.regenGetState.getSeedState.startTimer({caller});
154
160
  // iterateAncestorBlocks only returns ancestor blocks, not the block itself
155
- for (const b of this.modules.forkChoice.iterateAncestorBlocks(block.blockRoot)) {
161
+ for (const b of this.modules.forkChoice.iterateAncestorBlocks(block.blockRoot, block.payloadStatus)) {
156
162
  state = this.modules.blockStateCache.get(b.stateRoot);
157
163
  if (state) {
158
164
  break;
@@ -17,6 +17,7 @@ import {Metrics} from "../../metrics/metrics.js";
17
17
  import {MAX_LOOK_AHEAD_EPOCHS} from "../../sync/constants.js";
18
18
  import {IClock} from "../../util/clock.js";
19
19
  import {CustodyConfig} from "../../util/dataColumns.js";
20
+ import {SerializedCache} from "../../util/serializedCache.js";
20
21
  import {
21
22
  BlockInput,
22
23
  BlockInputBlobs,
@@ -55,6 +56,7 @@ export type SeenBlockInputCacheModules = {
55
56
  chainEvents: ChainEventEmitter;
56
57
  signal: AbortSignal;
57
58
  custodyConfig: CustodyConfig;
59
+ serializedCache: SerializedCache;
58
60
  metrics: Metrics | null;
59
61
  logger?: Logger;
60
62
  };
@@ -101,6 +103,7 @@ export class SeenBlockInput {
101
103
  private readonly clock: IClock;
102
104
  private readonly chainEvents: ChainEventEmitter;
103
105
  private readonly signal: AbortSignal;
106
+ private readonly serializedCache: SerializedCache;
104
107
  private readonly metrics: Metrics | null;
105
108
  private readonly logger?: Logger;
106
109
  private blockInputs = new Map<RootHex, IBlockInput>();
@@ -109,19 +112,35 @@ export class SeenBlockInput {
109
112
  // and the signature to ensure we only skip verification if both match
110
113
  private verifiedProposerSignatures = new Map<Slot, Map<RootHex, BLSSignature>>();
111
114
 
112
- constructor({config, custodyConfig, clock, chainEvents, signal, metrics, logger}: SeenBlockInputCacheModules) {
115
+ constructor({
116
+ config,
117
+ custodyConfig,
118
+ clock,
119
+ chainEvents,
120
+ signal,
121
+ serializedCache,
122
+ metrics,
123
+ logger,
124
+ }: SeenBlockInputCacheModules) {
113
125
  this.config = config;
114
126
  this.custodyConfig = custodyConfig;
115
127
  this.clock = clock;
116
128
  this.chainEvents = chainEvents;
117
129
  this.signal = signal;
130
+ this.serializedCache = serializedCache;
118
131
  this.metrics = metrics;
119
132
  this.logger = logger;
120
133
 
121
134
  if (metrics) {
122
- metrics.seenCache.blockInput.blockInputCount.addCollect(() =>
123
- metrics.seenCache.blockInput.blockInputCount.set(this.blockInputs.size)
124
- );
135
+ metrics.seenCache.blockInput.blockInputCount.addCollect(() => {
136
+ metrics.seenCache.blockInput.blockInputCount.set(this.blockInputs.size);
137
+ metrics.seenCache.blockInput.serializedObjectCount.set(
138
+ Array.from(this.blockInputs.values()).reduce(
139
+ (count, blockInput) => count + blockInput.getSerializedCacheKeys().length,
140
+ 0
141
+ )
142
+ );
143
+ });
125
144
  }
126
145
 
127
146
  this.chainEvents.on(ChainEvent.forkChoiceFinalized, this.onFinalized);
@@ -142,7 +161,10 @@ export class SeenBlockInput {
142
161
  * Removes the single BlockInput from the cache
143
162
  */
144
163
  remove(rootHex: RootHex): void {
145
- this.blockInputs.delete(rootHex);
164
+ const blockInput = this.blockInputs.get(rootHex);
165
+ if (blockInput) {
166
+ this.evictBlockInput(blockInput);
167
+ }
146
168
  }
147
169
 
148
170
  /**
@@ -154,7 +176,7 @@ export class SeenBlockInput {
154
176
  let deletedCount = 0;
155
177
  while (blockInput) {
156
178
  deletedCount++;
157
- this.blockInputs.delete(blockInput.blockRootHex);
179
+ this.evictBlockInput(blockInput);
158
180
  blockInput = this.blockInputs.get(parentRootHex ?? "");
159
181
  parentRootHex = blockInput?.parentRootHex;
160
182
  }
@@ -165,10 +187,10 @@ export class SeenBlockInput {
165
187
  onFinalized = (checkpoint: CheckpointWithHex) => {
166
188
  let deletedCount = 0;
167
189
  const cutoffSlot = computeStartSlotAtEpoch(checkpoint.epoch);
168
- for (const [rootHex, blockInput] of this.blockInputs) {
190
+ for (const [, blockInput] of this.blockInputs) {
169
191
  if (blockInput.slot < cutoffSlot) {
170
192
  deletedCount++;
171
- this.blockInputs.delete(rootHex);
193
+ this.evictBlockInput(blockInput);
172
194
  }
173
195
  }
174
196
  this.logger?.debug(`BlockInputCache.onFinalized deleted ${deletedCount} cached BlockInputs`);
@@ -408,14 +430,20 @@ export class SeenBlockInput {
408
430
 
409
431
  if (itemsToDelete > 0) {
410
432
  const sorted = [...this.blockInputs.entries()].sort((a, b) => a[1].slot - b[1].slot);
411
- for (const [rootHex] of sorted) {
412
- this.blockInputs.delete(rootHex);
433
+ for (const [, blockInput] of sorted) {
434
+ this.evictBlockInput(blockInput);
413
435
  itemsToDelete--;
414
436
  if (itemsToDelete <= 0) return;
415
437
  }
416
438
  }
417
439
  pruneSetToMax(this.verifiedProposerSignatures, MAX_BLOCK_INPUT_CACHE_SIZE);
418
440
  }
441
+
442
+ private evictBlockInput(blockInput: IBlockInput): void {
443
+ // Without forcefully clearing this cache, we would rely on WeakMap to evict memory which is not reliable
444
+ this.serializedCache.delete(blockInput.getSerializedCacheKeys());
445
+ this.blockInputs.delete(blockInput.blockRootHex);
446
+ }
419
447
  }
420
448
 
421
449
  enum SeenBlockInputCacheErrorCode {
@@ -81,7 +81,7 @@ async function validateAggregateAndProof(
81
81
  });
82
82
  }
83
83
  // [REJECT] `aggregate.data.index == 0` if `block.slot == aggregate.data.slot`.
84
- const block = chain.forkChoice.getBlock(attData.beaconBlockRoot);
84
+ const block = chain.forkChoice.getBlockDefaultStatus(attData.beaconBlockRoot);
85
85
 
86
86
  // If block is unknown, we don't handle it here. It will throw error later on at `verifyHeadBlockAndTargetRoot()`
87
87
  if (block !== null && block.slot === attData.slot && attData.index !== 0) {
@@ -186,7 +186,7 @@ export async function validateGossipAttestationsSameAttData(
186
186
  chain.seenAttesters.add(targetEpoch, validatorIndex);
187
187
  } else {
188
188
  step0ResultOrErrors[oldIndex] = {
189
- err: new AttestationError(GossipAction.IGNORE, {
189
+ err: new AttestationError(GossipAction.REJECT, {
190
190
  code: AttestationErrorCode.INVALID_SIGNATURE,
191
191
  }),
192
192
  };
@@ -307,7 +307,7 @@ async function validateAttestationNoSignatureCheck(
307
307
  }
308
308
 
309
309
  // [REJECT] `attestation.data.index == 0` if `block.slot == attestation.data.slot`.
310
- const block = chain.forkChoice.getBlock(attData.beaconBlockRoot);
310
+ const block = chain.forkChoice.getBlockDefaultStatus(attData.beaconBlockRoot);
311
311
 
312
312
  // block being null will be handled by `verifyHeadBlockAndTargetRoot`
313
313
  if (block !== null && block.slot === attSlot && attData.index !== 0) {
@@ -756,7 +756,7 @@ export function getAttestationDataSigningRoot(config: BeaconConfig, data: phase0
756
756
  function verifyHeadBlockIsKnown(chain: IBeaconChain, beaconBlockRoot: Root): ProtoBlock {
757
757
  // TODO (LH): Enforce a maximum skip distance for unaggregated attestations.
758
758
 
759
- const headBlock = chain.forkChoice.getBlock(beaconBlockRoot);
759
+ const headBlock = chain.forkChoice.getBlockDefaultStatus(beaconBlockRoot);
760
760
  if (headBlock === null) {
761
761
  throw new AttestationError(GossipAction.IGNORE, {
762
762
  code: AttestationErrorCode.UNKNOWN_OR_PREFINALIZED_BEACON_BLOCK_ROOT,
@@ -2,6 +2,7 @@ import {
2
2
  assertValidAttesterSlashing,
3
3
  getAttesterSlashableIndices,
4
4
  getAttesterSlashingSignatureSets,
5
+ isSlashableValidator,
5
6
  } from "@lodestar/state-transition";
6
7
  import {AttesterSlashing} from "@lodestar/types";
7
8
  import {AttesterSlashingError, AttesterSlashingErrorCode, GossipAction} from "../errors/index.js";
@@ -58,6 +59,14 @@ export async function validateAttesterSlashing(
58
59
  });
59
60
  }
60
61
 
62
+ const currentEpoch = state.epochCtx.epoch;
63
+ if (!intersectingIndices.some((index) => isSlashableValidator(state.validators.getReadonly(index), currentEpoch))) {
64
+ throw new AttesterSlashingError(GossipAction.REJECT, {
65
+ code: AttesterSlashingErrorCode.INVALID,
66
+ error: Error("AttesterSlashing has no slashable validators"),
67
+ });
68
+ }
69
+
61
70
  const signatureSets = getAttesterSlashingSignatureSets(chain.config, state.slot, attesterSlashing);
62
71
  if (!(await chain.bls.verifySignatureSets(signatureSets, {batchable: true, priority: prioritizeBls}))) {
63
72
  throw new AttesterSlashingError(GossipAction.REJECT, {
@@ -78,7 +78,7 @@ export async function validateGossipBlobSidecar(
78
78
  // already know this block.
79
79
  const blockRoot = ssz.phase0.BeaconBlockHeader.hashTreeRoot(blobSidecar.signedBlockHeader.message);
80
80
  const blockHex = toRootHex(blockRoot);
81
- if (chain.forkChoice.getBlockHex(blockHex) !== null) {
81
+ if (chain.forkChoice.getBlockHexDefaultStatus(blockHex) !== null) {
82
82
  throw new BlobSidecarGossipError(GossipAction.IGNORE, {code: BlobSidecarErrorCode.ALREADY_KNOWN, root: blockHex});
83
83
  }
84
84
 
@@ -89,7 +89,7 @@ export async function validateGossipBlobSidecar(
89
89
  // gossip and non-gossip sources) (a client MAY queue blocks for processing once the parent block is
90
90
  // retrieved).
91
91
  const parentRoot = toRootHex(blobSidecar.signedBlockHeader.message.parentRoot);
92
- const parentBlock = chain.forkChoice.getBlockHex(parentRoot);
92
+ const parentBlock = chain.forkChoice.getBlockHexDefaultStatus(parentRoot);
93
93
  if (parentBlock === null) {
94
94
  // If fork choice does *not* consider the parent to be a descendant of the finalized block,
95
95
  // then there are two more cases:
@@ -9,7 +9,7 @@ import {
9
9
  isExecutionEnabled,
10
10
  isExecutionStateType,
11
11
  } from "@lodestar/state-transition";
12
- import {SignedBeaconBlock, deneb, gloas} from "@lodestar/types";
12
+ import {SignedBeaconBlock, deneb, gloas, isGloasBeaconBlock} from "@lodestar/types";
13
13
  import {byteArrayEquals, sleep, toRootHex} from "@lodestar/utils";
14
14
  import {BlockErrorCode, BlockGossipError, GossipAction} from "../errors/index.js";
15
15
  import {IBeaconChain} from "../interface.js";
@@ -56,7 +56,7 @@ export async function validateGossipBlock(
56
56
  // check, we will load the parent and state from disk only to find out later that we
57
57
  // already know this block.
58
58
  const blockRoot = toRootHex(config.getForkTypes(blockSlot).BeaconBlock.hashTreeRoot(block));
59
- if (chain.forkChoice.getBlockHex(blockRoot) !== null) {
59
+ if (chain.forkChoice.getBlockHexDefaultStatus(blockRoot) !== null) {
60
60
  throw new BlockGossipError(GossipAction.IGNORE, {code: BlockErrorCode.ALREADY_KNOWN, root: blockRoot});
61
61
  }
62
62
 
@@ -72,7 +72,12 @@ export async function validateGossipBlock(
72
72
  // [REJECT] The current finalized_checkpoint is an ancestor of block -- i.e.
73
73
  // get_ancestor(store, block.parent_root, compute_start_slot_at_epoch(store.finalized_checkpoint.epoch)) == store.finalized_checkpoint.root
74
74
  const parentRoot = toRootHex(block.parentRoot);
75
- const parentBlock = chain.forkChoice.getBlockHex(parentRoot);
75
+ const parentBlock = isGloasBeaconBlock(block)
76
+ ? chain.forkChoice.getBlockHexAndBlockHash(
77
+ parentRoot,
78
+ toRootHex(block.body.signedExecutionPayloadBid.message.parentBlockHash)
79
+ )
80
+ : chain.forkChoice.getBlockHexDefaultStatus(parentRoot);
76
81
  if (parentBlock === null) {
77
82
  // If fork choice does *not* consider the parent to be a descendant of the finalized block,
78
83
  // then there are two more cases:
@@ -104,7 +109,7 @@ export async function validateGossipBlock(
104
109
 
105
110
  // [REJECT] The block is from a higher slot than its parent.
106
111
  if (parentBlock.slot >= blockSlot) {
107
- throw new BlockGossipError(GossipAction.IGNORE, {
112
+ throw new BlockGossipError(GossipAction.REJECT, {
108
113
  code: BlockErrorCode.NOT_LATER_THAN_PARENT,
109
114
  parentSlot: parentBlock.slot,
110
115
  slot: blockSlot,
@@ -73,7 +73,7 @@ export async function validateGossipDataColumnSidecar(
73
73
  // 6) [IGNORE] The sidecar's block's parent (defined by block_header.parent_root) has been seen (via gossip
74
74
  // or non-gossip sources)
75
75
  const parentRoot = toRootHex(blockHeader.parentRoot);
76
- const parentBlock = chain.forkChoice.getBlockHex(parentRoot);
76
+ const parentBlock = chain.forkChoice.getBlockHexDefaultStatus(parentRoot);
77
77
  if (parentBlock === null) {
78
78
  // If fork choice does *not* consider the parent to be a descendant of the finalized block,
79
79
  // then there are two more cases:
@@ -113,8 +113,7 @@ async function validateExecutionPayloadBid(
113
113
 
114
114
  // [IGNORE] `bid.parent_block_root` is the hash tree root of a known beacon
115
115
  // block in fork choice.
116
- const block = chain.forkChoice.getBlock(bid.parentBlockRoot);
117
- if (block === null) {
116
+ if (!chain.forkChoice.hasBlock(bid.parentBlockRoot)) {
118
117
  throw new ExecutionPayloadBidError(GossipAction.IGNORE, {
119
118
  code: ExecutionPayloadBidErrorCode.UNKNOWN_BLOCK_ROOT,
120
119
  parentBlockRoot: parentBlockRootHex,
@@ -37,7 +37,7 @@ async function validateExecutionPayloadEnvelope(
37
37
  // the block is retrieved).
38
38
  // TODO GLOAS: Need to review this, we should queue the envelope for later
39
39
  // processing if the block is not yet known, otherwise we would ignore it here
40
- const block = chain.forkChoice.getBlock(envelope.beaconBlockRoot);
40
+ const block = chain.forkChoice.getBlockDefaultStatus(envelope.beaconBlockRoot);
41
41
  if (block === null) {
42
42
  throw new ExecutionPayloadEnvelopeError(GossipAction.IGNORE, {
43
43
  code: ExecutionPayloadEnvelopeErrorCode.BLOCK_ROOT_UNKNOWN,
@@ -79,7 +79,7 @@ async function validateExecutionPayloadEnvelope(
79
79
  });
80
80
  }
81
81
 
82
- if (block.builderIndex === undefined || block.blockHashHex === undefined) {
82
+ if (block.builderIndex == null || block.blockHashFromBid == null) {
83
83
  // This indicates this block is a pre-gloas block which is wrong
84
84
  throw new ExecutionPayloadEnvelopeError(GossipAction.IGNORE, {
85
85
  code: ExecutionPayloadEnvelopeErrorCode.CACHE_FAIL,
@@ -97,11 +97,11 @@ async function validateExecutionPayloadEnvelope(
97
97
  }
98
98
 
99
99
  // [REJECT] `payload.block_hash == bid.block_hash`
100
- if (toRootHex(payload.blockHash) !== block.blockHashHex) {
100
+ if (toRootHex(payload.blockHash) !== block.blockHashFromBid) {
101
101
  throw new ExecutionPayloadEnvelopeError(GossipAction.REJECT, {
102
102
  code: ExecutionPayloadEnvelopeErrorCode.BLOCK_HASH_MISMATCH,
103
103
  envelopeBlockHash: toRootHex(payload.blockHash),
104
- bidBlockHash: block.blockHashHex,
104
+ bidBlockHash: block.blockHashFromBid,
105
105
  });
106
106
  }
107
107
 
@@ -59,8 +59,7 @@ async function validatePayloadAttestationMessage(
59
59
  // [IGNORE] The message's block `data.beacon_block_root` has been seen (via
60
60
  // gossip or non-gossip sources) (a client MAY queue attestation for processing
61
61
  // once the block is retrieved. Note a client might want to request payload after).
62
- const block = chain.forkChoice.getBlock(data.beaconBlockRoot);
63
- if (block === null) {
62
+ if (!chain.forkChoice.hasBlock(data.beaconBlockRoot)) {
64
63
  throw new PayloadAttestationError(GossipAction.IGNORE, {
65
64
  code: PayloadAttestationErrorCode.UNKNOWN_BLOCK_ROOT,
66
65
  blockRoot: toRootHex(data.beaconBlockRoot),
package/src/db/index.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export {BeaconDb} from "./beacon.js";
2
+ export {Bucket} from "./buckets.js";
2
3
  export type {IBeaconDb} from "./interface.js";
@@ -1461,6 +1461,10 @@ export function createLodestarMetrics(
1461
1461
  name: "lodestar_seen_block_input_cache_size",
1462
1462
  help: "Number of cached BlockInputs",
1463
1463
  }),
1464
+ serializedObjectCount: register.gauge({
1465
+ name: "lodestar_seen_block_input_cache_serialized_object_count",
1466
+ help: "Number of serialized objects retained by cached BlockInputs",
1467
+ }),
1464
1468
  duplicateBlockCount: register.gauge<{source: BlockInputSource}>({
1465
1469
  name: "lodestar_seen_block_input_cache_duplicate_block_count",
1466
1470
  help: "Total number of duplicate blocks that pass validation and attempt to be cached but are known",
@@ -539,7 +539,8 @@ export class Network implements INetwork {
539
539
  this.config.getForkSeq(this.clock.currentSlot) >= ForkSeq.altair ? [Version.V2] : [Version.V2, Version.V1],
540
540
  request
541
541
  ),
542
- request
542
+ request,
543
+ this.chain.serializedCache
543
544
  );
544
545
  }
545
546
 
@@ -71,7 +71,7 @@ import {validateGossipPayloadAttestationMessage} from "../../chain/validation/pa
71
71
  import {OpSource} from "../../chain/validatorMonitor.js";
72
72
  import {Metrics} from "../../metrics/index.js";
73
73
  import {kzgCommitmentToVersionedHash} from "../../util/blobs.js";
74
- import {getBlobKzgCommitments} from "../../util/dataColumns.ts";
74
+ import {getBlobKzgCommitments} from "../../util/dataColumns.js";
75
75
  import {INetworkCore} from "../core/index.js";
76
76
  import {NetworkEventBus} from "../events.js";
77
77
  import {
@@ -856,6 +856,11 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
856
856
  } catch (e) {
857
857
  logger.error("Error adding to payloadAttestation pool", {}, e as Error);
858
858
  }
859
+ chain.forkChoice.notifyPtcMessages(
860
+ toRootHex(payloadAttestationMessage.data.beaconBlockRoot),
861
+ [validationResult.validatorCommitteeIndex],
862
+ payloadAttestationMessage.data.payloadPresent
863
+ );
859
864
  },
860
865
  [GossipType.execution_payload_bid]: async ({
861
866
  gossipData,
@@ -11,7 +11,7 @@ import {
11
11
  GossipValidatorBatchFn,
12
12
  GossipValidatorFn,
13
13
  } from "../gossip/interface.js";
14
- import {prettyPrintPeerIdStr} from "../util.ts";
14
+ import {prettyPrintPeerIdStr} from "../util.js";
15
15
 
16
16
  export type ValidatorFnModules = {
17
17
  config: ChainForkConfig;
@@ -19,7 +19,7 @@ import {callInNextEventLoop} from "../../util/eventLoop.js";
19
19
  import {NetworkCoreMetrics} from "../core/metrics.js";
20
20
  import {INetworkEventBus, NetworkEvent} from "../events.js";
21
21
  import {MetadataController} from "../metadata.js";
22
- import {ClientKind} from "../peers/client.ts";
22
+ import {ClientKind} from "../peers/client.js";
23
23
  import {PeersData} from "../peers/peersData.js";
24
24
  import {IPeerRpcScoreStore, PeerAction} from "../peers/score/index.js";
25
25
  import {StatusCache} from "../statusCache.js";
@@ -6,7 +6,7 @@ import {computeEpochAtSlot} from "@lodestar/state-transition";
6
6
  import {deneb, phase0} from "@lodestar/types";
7
7
  import {IBeaconChain} from "../../../chain/index.js";
8
8
  import {IBeaconDb} from "../../../db/index.js";
9
- import {prettyPrintPeerId} from "../../util.ts";
9
+ import {prettyPrintPeerId} from "../../util.js";
10
10
 
11
11
  // TODO: Unit test
12
12
 
@@ -47,9 +47,10 @@ export async function* onBeaconBlocksByRange(
47
47
 
48
48
  // Non-finalized range of blocks
49
49
  if (endSlot > finalizedSlot) {
50
- const headRoot = chain.forkChoice.getHeadRoot();
50
+ const headBlock = chain.forkChoice.getHead();
51
+ const headRoot = headBlock.blockRoot;
51
52
  // TODO DENEB: forkChoice should mantain an array of canonical blocks, and change only on reorg
52
- const headChain = chain.forkChoice.getAllAncestorBlocks(headRoot);
53
+ const headChain = chain.forkChoice.getAllAncestorBlocks(headRoot, headBlock.payloadStatus);
53
54
  // getAllAncestorBlocks response includes the head node, so it's the full chain.
54
55
 
55
56
  // Iterate head chain with ascending block numbers
@@ -34,9 +34,10 @@ export async function* onBlobSidecarsByRange(
34
34
 
35
35
  // Non-finalized range of blobs
36
36
  if (endSlot > finalizedSlot) {
37
- const headRoot = chain.forkChoice.getHeadRoot();
37
+ const headBlock = chain.forkChoice.getHead();
38
+ const headRoot = headBlock.blockRoot;
38
39
  // TODO DENEB: forkChoice should mantain an array of canonical blocks, and change only on reorg
39
- const headChain = chain.forkChoice.getAllAncestorBlocks(headRoot);
40
+ const headChain = chain.forkChoice.getAllAncestorBlocks(headRoot, headBlock.payloadStatus);
40
41
 
41
42
  // Iterate head chain with ascending block numbers
42
43
  for (let i = headChain.length - 1; i >= 0; i--) {
@@ -20,7 +20,7 @@ export async function* onBlobSidecarsByRoot(
20
20
  for (const blobIdentifier of requestBody) {
21
21
  const {blockRoot, index} = blobIdentifier;
22
22
  const blockRootHex = toRootHex(blockRoot);
23
- const block = chain.forkChoice.getBlockHex(blockRootHex);
23
+ const block = chain.forkChoice.getBlockHexDefaultStatus(blockRootHex);
24
24
 
25
25
  // NOTE: Only support non-finalized blocks.
26
26
  // SPEC: Clients MUST support requesting blocks and sidecars since the latest finalized epoch.