@lodestar/beacon-node 1.41.0-dev.f2caa915ab → 1.41.0-dev.f9a3a81538

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 (118) 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/types.d.ts +11 -0
  16. package/lib/chain/blocks/blockInput/types.d.ts.map +1 -1
  17. package/lib/chain/blocks/importBlock.d.ts.map +1 -1
  18. package/lib/chain/blocks/importBlock.js +27 -4
  19. package/lib/chain/blocks/importBlock.js.map +1 -1
  20. package/lib/chain/blocks/verifyBlocksSanityChecks.d.ts.map +1 -1
  21. package/lib/chain/blocks/verifyBlocksSanityChecks.js +4 -1
  22. package/lib/chain/blocks/verifyBlocksSanityChecks.js.map +1 -1
  23. package/lib/chain/blocks/writeBlockInputToDb.d.ts +12 -3
  24. package/lib/chain/blocks/writeBlockInputToDb.d.ts.map +1 -1
  25. package/lib/chain/blocks/writeBlockInputToDb.js +101 -96
  26. package/lib/chain/blocks/writeBlockInputToDb.js.map +1 -1
  27. package/lib/chain/chain.d.ts +1 -1
  28. package/lib/chain/chain.d.ts.map +1 -1
  29. package/lib/chain/chain.js +11 -11
  30. package/lib/chain/chain.js.map +1 -1
  31. package/lib/chain/emitter.d.ts +3 -3
  32. package/lib/chain/emitter.d.ts.map +1 -1
  33. package/lib/chain/errors/executionPayloadEnvelope.d.ts +2 -2
  34. package/lib/chain/errors/executionPayloadEnvelope.d.ts.map +1 -1
  35. package/lib/chain/errors/executionPayloadEnvelope.js.map +1 -1
  36. package/lib/chain/forkChoice/index.d.ts.map +1 -1
  37. package/lib/chain/forkChoice/index.js +30 -24
  38. package/lib/chain/forkChoice/index.js.map +1 -1
  39. package/lib/chain/opPools/aggregatedAttestationPool.js +1 -1
  40. package/lib/chain/opPools/aggregatedAttestationPool.js.map +1 -1
  41. package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
  42. package/lib/chain/produceBlock/produceBlockBody.js +1 -2
  43. package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
  44. package/lib/chain/regen/queued.d.ts.map +1 -1
  45. package/lib/chain/regen/queued.js +4 -1
  46. package/lib/chain/regen/queued.js.map +1 -1
  47. package/lib/chain/regen/regen.d.ts.map +1 -1
  48. package/lib/chain/regen/regen.js +6 -2
  49. package/lib/chain/regen/regen.js.map +1 -1
  50. package/lib/chain/validation/aggregateAndProof.js +1 -1
  51. package/lib/chain/validation/aggregateAndProof.js.map +1 -1
  52. package/lib/chain/validation/attestation.js +3 -3
  53. package/lib/chain/validation/attestation.js.map +1 -1
  54. package/lib/chain/validation/attesterSlashing.d.ts.map +1 -1
  55. package/lib/chain/validation/attesterSlashing.js +8 -1
  56. package/lib/chain/validation/attesterSlashing.js.map +1 -1
  57. package/lib/chain/validation/blobSidecar.js +2 -2
  58. package/lib/chain/validation/blobSidecar.js.map +1 -1
  59. package/lib/chain/validation/block.d.ts.map +1 -1
  60. package/lib/chain/validation/block.js +6 -3
  61. package/lib/chain/validation/block.js.map +1 -1
  62. package/lib/chain/validation/dataColumnSidecar.js +1 -1
  63. package/lib/chain/validation/dataColumnSidecar.js.map +1 -1
  64. package/lib/chain/validation/executionPayloadBid.js +1 -2
  65. package/lib/chain/validation/executionPayloadBid.js.map +1 -1
  66. package/lib/chain/validation/executionPayloadEnvelope.js +4 -4
  67. package/lib/chain/validation/executionPayloadEnvelope.js.map +1 -1
  68. package/lib/chain/validation/payloadAttestationMessage.js +1 -2
  69. package/lib/chain/validation/payloadAttestationMessage.js.map +1 -1
  70. package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
  71. package/lib/network/processor/gossipHandlers.js +1 -0
  72. package/lib/network/processor/gossipHandlers.js.map +1 -1
  73. package/lib/network/reqresp/handlers/beaconBlocksByRange.d.ts.map +1 -1
  74. package/lib/network/reqresp/handlers/beaconBlocksByRange.js +3 -2
  75. package/lib/network/reqresp/handlers/beaconBlocksByRange.js.map +1 -1
  76. package/lib/network/reqresp/handlers/blobSidecarsByRange.d.ts.map +1 -1
  77. package/lib/network/reqresp/handlers/blobSidecarsByRange.js +3 -2
  78. package/lib/network/reqresp/handlers/blobSidecarsByRange.js.map +1 -1
  79. package/lib/network/reqresp/handlers/blobSidecarsByRoot.js +1 -1
  80. package/lib/network/reqresp/handlers/blobSidecarsByRoot.js.map +1 -1
  81. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.d.ts.map +1 -1
  82. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js +3 -2
  83. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js.map +1 -1
  84. package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.js +1 -1
  85. package/lib/network/reqresp/handlers/dataColumnSidecarsByRoot.js.map +1 -1
  86. package/package.json +26 -26
  87. package/src/api/impl/beacon/blocks/index.ts +3 -2
  88. package/src/api/impl/validator/index.ts +26 -12
  89. package/src/chain/archiveStore/archiveStore.ts +5 -5
  90. package/src/chain/archiveStore/utils/archiveBlocks.ts +4 -5
  91. package/src/chain/archiveStore/utils/updateBackfillRange.ts +1 -1
  92. package/src/chain/blocks/blockInput/types.ts +12 -0
  93. package/src/chain/blocks/importBlock.ts +35 -4
  94. package/src/chain/blocks/verifyBlocksSanityChecks.ts +7 -2
  95. package/src/chain/blocks/writeBlockInputToDb.ts +119 -101
  96. package/src/chain/chain.ts +26 -14
  97. package/src/chain/emitter.ts +3 -3
  98. package/src/chain/errors/executionPayloadEnvelope.ts +6 -2
  99. package/src/chain/forkChoice/index.ts +39 -21
  100. package/src/chain/opPools/aggregatedAttestationPool.ts +1 -1
  101. package/src/chain/produceBlock/produceBlockBody.ts +1 -2
  102. package/src/chain/regen/queued.ts +7 -2
  103. package/src/chain/regen/regen.ts +9 -3
  104. package/src/chain/validation/aggregateAndProof.ts +1 -1
  105. package/src/chain/validation/attestation.ts +3 -3
  106. package/src/chain/validation/attesterSlashing.ts +9 -0
  107. package/src/chain/validation/blobSidecar.ts +2 -2
  108. package/src/chain/validation/block.ts +9 -4
  109. package/src/chain/validation/dataColumnSidecar.ts +1 -1
  110. package/src/chain/validation/executionPayloadBid.ts +1 -2
  111. package/src/chain/validation/executionPayloadEnvelope.ts +4 -4
  112. package/src/chain/validation/payloadAttestationMessage.ts +1 -2
  113. package/src/network/processor/gossipHandlers.ts +5 -0
  114. package/src/network/reqresp/handlers/beaconBlocksByRange.ts +3 -2
  115. package/src/network/reqresp/handlers/blobSidecarsByRange.ts +3 -2
  116. package/src/network/reqresp/handlers/blobSidecarsByRoot.ts +1 -1
  117. package/src/network/reqresp/handlers/dataColumnSidecarsByRange.ts +3 -2
  118. package/src/network/reqresp/handlers/dataColumnSidecarsByRoot.ts +1 -1
@@ -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;
@@ -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),
@@ -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,
@@ -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.
@@ -78,8 +78,9 @@ export async function* onDataColumnSidecarsByRange(
78
78
 
79
79
  // Non-finalized range of columns
80
80
  if (endSlot > finalizedSlot) {
81
- const headRoot = chain.forkChoice.getHeadRoot();
82
- const headChain = chain.forkChoice.getAllAncestorBlocks(headRoot);
81
+ const headBlock = chain.forkChoice.getHead();
82
+ const headRoot = headBlock.blockRoot;
83
+ const headChain = chain.forkChoice.getAllAncestorBlocks(headRoot, headBlock.payloadStatus);
83
84
 
84
85
  // Iterate head chain with ascending block numbers
85
86
  for (let i = headChain.length - 1; i >= 0; i--) {
@@ -34,7 +34,7 @@ export async function* onDataColumnSidecarsByRoot(
34
34
  }
35
35
 
36
36
  const blockRootHex = toRootHex(blockRoot);
37
- const block = chain.forkChoice.getBlockHex(blockRootHex);
37
+ const block = chain.forkChoice.getBlockHexDefaultStatus(blockRootHex);
38
38
  // If the block is not in fork choice, it may be finalized. Attempt to find its slot in block archive
39
39
  const slot = block ? block.slot : await db.blockArchive.getSlotByRoot(blockRoot);
40
40