@lodestar/beacon-node 1.42.0 → 1.43.0-dev.6641fd750e

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 (158) hide show
  1. package/lib/api/impl/beacon/blocks/index.d.ts.map +1 -1
  2. package/lib/api/impl/beacon/blocks/index.js +20 -0
  3. package/lib/api/impl/beacon/blocks/index.js.map +1 -1
  4. package/lib/api/impl/beacon/pool/index.d.ts.map +1 -1
  5. package/lib/api/impl/beacon/pool/index.js +4 -0
  6. package/lib/api/impl/beacon/pool/index.js.map +1 -1
  7. package/lib/api/impl/beacon/state/index.d.ts.map +1 -1
  8. package/lib/api/impl/beacon/state/index.js +13 -10
  9. package/lib/api/impl/beacon/state/index.js.map +1 -1
  10. package/lib/api/impl/lodestar/index.d.ts.map +1 -1
  11. package/lib/api/impl/lodestar/index.js +4 -0
  12. package/lib/api/impl/lodestar/index.js.map +1 -1
  13. package/lib/api/impl/validator/index.d.ts.map +1 -1
  14. package/lib/api/impl/validator/index.js +9 -3
  15. package/lib/api/impl/validator/index.js.map +1 -1
  16. package/lib/chain/blocks/importBlock.d.ts.map +1 -1
  17. package/lib/chain/blocks/importBlock.js +6 -4
  18. package/lib/chain/blocks/importBlock.js.map +1 -1
  19. package/lib/chain/blocks/importExecutionPayload.d.ts.map +1 -1
  20. package/lib/chain/blocks/importExecutionPayload.js +14 -5
  21. package/lib/chain/blocks/importExecutionPayload.js.map +1 -1
  22. package/lib/chain/blocks/index.js +1 -1
  23. package/lib/chain/blocks/index.js.map +1 -1
  24. package/lib/chain/blocks/types.d.ts +3 -3
  25. package/lib/chain/blocks/types.d.ts.map +1 -1
  26. package/lib/chain/blocks/verifyBlocksExecutionPayloads.d.ts.map +1 -1
  27. package/lib/chain/blocks/verifyBlocksExecutionPayloads.js +3 -2
  28. package/lib/chain/blocks/verifyBlocksExecutionPayloads.js.map +1 -1
  29. package/lib/chain/blocks/verifyBlocksSignatures.d.ts.map +1 -1
  30. package/lib/chain/blocks/verifyBlocksSignatures.js +4 -2
  31. package/lib/chain/blocks/verifyBlocksSignatures.js.map +1 -1
  32. package/lib/chain/chain.d.ts +2 -1
  33. package/lib/chain/chain.d.ts.map +1 -1
  34. package/lib/chain/chain.js +22 -8
  35. package/lib/chain/chain.js.map +1 -1
  36. package/lib/chain/errors/blockError.d.ts +11 -1
  37. package/lib/chain/errors/blockError.d.ts.map +1 -1
  38. package/lib/chain/errors/blockError.js +4 -0
  39. package/lib/chain/errors/blockError.js.map +1 -1
  40. package/lib/chain/forkChoice/index.d.ts.map +1 -1
  41. package/lib/chain/forkChoice/index.js +10 -8
  42. package/lib/chain/forkChoice/index.js.map +1 -1
  43. package/lib/chain/interface.d.ts +2 -1
  44. package/lib/chain/interface.d.ts.map +1 -1
  45. package/lib/chain/interface.js.map +1 -1
  46. package/lib/chain/lightClient/index.d.ts +2 -2
  47. package/lib/chain/lightClient/index.d.ts.map +1 -1
  48. package/lib/chain/lightClient/index.js +7 -0
  49. package/lib/chain/lightClient/index.js.map +1 -1
  50. package/lib/chain/opPools/aggregatedAttestationPool.d.ts.map +1 -1
  51. package/lib/chain/opPools/aggregatedAttestationPool.js +5 -2
  52. package/lib/chain/opPools/aggregatedAttestationPool.js.map +1 -1
  53. package/lib/chain/opPools/executionPayloadBidPool.d.ts +2 -2
  54. package/lib/chain/opPools/executionPayloadBidPool.d.ts.map +1 -1
  55. package/lib/chain/opPools/executionPayloadBidPool.js +2 -2
  56. package/lib/chain/opPools/executionPayloadBidPool.js.map +1 -1
  57. package/lib/chain/prepareNextSlot.d.ts.map +1 -1
  58. package/lib/chain/prepareNextSlot.js +7 -1
  59. package/lib/chain/prepareNextSlot.js.map +1 -1
  60. package/lib/chain/produceBlock/computeNewStateRoot.d.ts +3 -3
  61. package/lib/chain/produceBlock/computeNewStateRoot.d.ts.map +1 -1
  62. package/lib/chain/produceBlock/computeNewStateRoot.js +8 -8
  63. package/lib/chain/produceBlock/computeNewStateRoot.js.map +1 -1
  64. package/lib/chain/produceBlock/produceBlockBody.d.ts +5 -5
  65. package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
  66. package/lib/chain/produceBlock/produceBlockBody.js +23 -4
  67. package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
  68. package/lib/chain/validation/block.d.ts.map +1 -1
  69. package/lib/chain/validation/block.js +27 -5
  70. package/lib/chain/validation/block.js.map +1 -1
  71. package/lib/chain/validation/executionPayloadBid.d.ts.map +1 -1
  72. package/lib/chain/validation/executionPayloadBid.js +7 -4
  73. package/lib/chain/validation/executionPayloadBid.js.map +1 -1
  74. package/lib/chain/validation/executionPayloadEnvelope.d.ts.map +1 -1
  75. package/lib/chain/validation/executionPayloadEnvelope.js +6 -1
  76. package/lib/chain/validation/executionPayloadEnvelope.js.map +1 -1
  77. package/lib/chain/validation/payloadAttestationMessage.d.ts.map +1 -1
  78. package/lib/chain/validation/payloadAttestationMessage.js +4 -1
  79. package/lib/chain/validation/payloadAttestationMessage.js.map +1 -1
  80. package/lib/chain/validation/syncCommittee.d.ts.map +1 -1
  81. package/lib/chain/validation/syncCommittee.js +4 -0
  82. package/lib/chain/validation/syncCommittee.js.map +1 -1
  83. package/lib/chain/validation/syncCommitteeContributionAndProof.js +4 -1
  84. package/lib/chain/validation/syncCommitteeContributionAndProof.js.map +1 -1
  85. package/lib/chain/validatorMonitor.d.ts.map +1 -1
  86. package/lib/chain/validatorMonitor.js +3 -3
  87. package/lib/chain/validatorMonitor.js.map +1 -1
  88. package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
  89. package/lib/network/processor/gossipHandlers.js +4 -0
  90. package/lib/network/processor/gossipHandlers.js.map +1 -1
  91. package/lib/network/reqresp/handlers/beaconBlocksByRange.d.ts.map +1 -1
  92. package/lib/network/reqresp/handlers/beaconBlocksByRange.js +2 -1
  93. package/lib/network/reqresp/handlers/beaconBlocksByRange.js.map +1 -1
  94. package/lib/network/reqresp/handlers/beaconBlocksByRoot.d.ts.map +1 -1
  95. package/lib/network/reqresp/handlers/beaconBlocksByRoot.js +2 -0
  96. package/lib/network/reqresp/handlers/beaconBlocksByRoot.js.map +1 -1
  97. package/lib/network/reqresp/handlers/blobSidecarsByRange.d.ts +2 -2
  98. package/lib/network/reqresp/handlers/blobSidecarsByRange.d.ts.map +1 -1
  99. package/lib/network/reqresp/handlers/blobSidecarsByRange.js +7 -3
  100. package/lib/network/reqresp/handlers/blobSidecarsByRange.js.map +1 -1
  101. package/lib/network/reqresp/handlers/blobSidecarsByRoot.d.ts.map +1 -1
  102. package/lib/network/reqresp/handlers/blobSidecarsByRoot.js +6 -0
  103. package/lib/network/reqresp/handlers/blobSidecarsByRoot.js.map +1 -1
  104. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.d.ts +2 -2
  105. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.d.ts.map +1 -1
  106. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js +7 -3
  107. package/lib/network/reqresp/handlers/dataColumnSidecarsByRange.js.map +1 -1
  108. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.d.ts.map +1 -1
  109. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.js +2 -1
  110. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRange.js.map +1 -1
  111. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRoot.d.ts.map +1 -1
  112. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRoot.js +3 -8
  113. package/lib/network/reqresp/handlers/executionPayloadEnvelopesByRoot.js.map +1 -1
  114. package/lib/node/nodejs.d.ts.map +1 -1
  115. package/lib/node/nodejs.js +4 -1
  116. package/lib/node/nodejs.js.map +1 -1
  117. package/lib/node/notifier.d.ts.map +1 -1
  118. package/lib/node/notifier.js +2 -2
  119. package/lib/node/notifier.js.map +1 -1
  120. package/package.json +15 -15
  121. package/src/api/impl/beacon/blocks/index.ts +29 -0
  122. package/src/api/impl/beacon/pool/index.ts +4 -0
  123. package/src/api/impl/beacon/state/index.ts +15 -15
  124. package/src/api/impl/lodestar/index.ts +4 -0
  125. package/src/api/impl/validator/index.ts +9 -2
  126. package/src/chain/blocks/importBlock.ts +11 -7
  127. package/src/chain/blocks/importExecutionPayload.ts +15 -5
  128. package/src/chain/blocks/index.ts +1 -1
  129. package/src/chain/blocks/types.ts +3 -3
  130. package/src/chain/blocks/verifyBlocksExecutionPayloads.ts +2 -1
  131. package/src/chain/blocks/verifyBlocksSignatures.ts +9 -2
  132. package/src/chain/chain.ts +30 -8
  133. package/src/chain/errors/blockError.ts +7 -1
  134. package/src/chain/forkChoice/index.ts +11 -8
  135. package/src/chain/interface.ts +5 -0
  136. package/src/chain/lightClient/index.ts +15 -3
  137. package/src/chain/opPools/aggregatedAttestationPool.ts +6 -1
  138. package/src/chain/opPools/executionPayloadBidPool.ts +3 -3
  139. package/src/chain/prepareNextSlot.ts +8 -0
  140. package/src/chain/produceBlock/computeNewStateRoot.ts +11 -10
  141. package/src/chain/produceBlock/produceBlockBody.ts +40 -10
  142. package/src/chain/validation/block.ts +30 -7
  143. package/src/chain/validation/executionPayloadBid.ts +7 -3
  144. package/src/chain/validation/executionPayloadEnvelope.ts +10 -1
  145. package/src/chain/validation/payloadAttestationMessage.ts +4 -0
  146. package/src/chain/validation/syncCommittee.ts +5 -1
  147. package/src/chain/validation/syncCommitteeContributionAndProof.ts +5 -1
  148. package/src/chain/validatorMonitor.ts +3 -2
  149. package/src/network/processor/gossipHandlers.ts +5 -0
  150. package/src/network/reqresp/handlers/beaconBlocksByRange.ts +3 -1
  151. package/src/network/reqresp/handlers/beaconBlocksByRoot.ts +3 -0
  152. package/src/network/reqresp/handlers/blobSidecarsByRange.ts +15 -3
  153. package/src/network/reqresp/handlers/blobSidecarsByRoot.ts +11 -0
  154. package/src/network/reqresp/handlers/dataColumnSidecarsByRange.ts +19 -3
  155. package/src/network/reqresp/handlers/executionPayloadEnvelopesByRange.ts +3 -1
  156. package/src/network/reqresp/handlers/executionPayloadEnvelopesByRoot.ts +3 -12
  157. package/src/node/nodejs.ts +5 -2
  158. package/src/node/notifier.ts +7 -2
@@ -3,6 +3,7 @@ import {
3
3
  createSingleSignatureSetFromComponents,
4
4
  getExecutionPayloadBidSigningRoot,
5
5
  isActiveBuilder,
6
+ isStatePostGloas,
6
7
  } from "@lodestar/state-transition";
7
8
  import {gloas} from "@lodestar/types";
8
9
  import {toRootHex} from "@lodestar/utils";
@@ -32,6 +33,9 @@ async function validateExecutionPayloadBid(
32
33
  const parentBlockRootHex = toRootHex(bid.parentBlockRoot);
33
34
  const parentBlockHashHex = toRootHex(bid.parentBlockHash);
34
35
  const state = await chain.getHeadStateAtCurrentEpoch(RegenCaller.validateGossipExecutionPayloadBid);
36
+ if (!isStatePostGloas(state)) {
37
+ throw new Error(`Expected gloas+ state for execution payload bid validation, got fork=${state.forkName}`);
38
+ }
35
39
 
36
40
  // [IGNORE] `bid.slot` is the current slot or the next slot.
37
41
  const currentSlot = chain.clock.currentSlot;
@@ -83,9 +87,9 @@ async function validateExecutionPayloadBid(
83
87
  });
84
88
  }
85
89
 
86
- // [IGNORE] this bid is the highest value bid seen for the corresponding slot
87
- // and the given parent block hash.
88
- const bestBid = chain.executionPayloadBidPool.getBestBid(parentBlockRootHex, parentBlockHashHex, bid.slot);
90
+ // [IGNORE] this bid is the highest value bid seen for the tuple
91
+ // `(bid.slot, bid.parent_block_hash, bid.parent_block_root)`.
92
+ const bestBid = chain.executionPayloadBidPool.getBestBid(bid.slot, parentBlockHashHex, parentBlockRootHex);
89
93
  if (bestBid !== null && bestBid.value >= bid.value) {
90
94
  throw new ExecutionPayloadBidError(GossipAction.IGNORE, {
91
95
  code: ExecutionPayloadBidErrorCode.BID_TOO_LOW,
@@ -1,5 +1,9 @@
1
1
  import {PayloadStatus} from "@lodestar/fork-choice";
2
- import {computeStartSlotAtEpoch, getExecutionPayloadEnvelopeSignatureSet} from "@lodestar/state-transition";
2
+ import {
3
+ computeStartSlotAtEpoch,
4
+ getExecutionPayloadEnvelopeSignatureSet,
5
+ isStatePostGloas,
6
+ } from "@lodestar/state-transition";
3
7
  import {gloas} from "@lodestar/types";
4
8
  import {toRootHex} from "@lodestar/utils";
5
9
  import {ExecutionPayloadEnvelopeError, ExecutionPayloadEnvelopeErrorCode, GossipAction} from "../errors/index.js";
@@ -113,7 +117,12 @@ async function validateExecutionPayloadEnvelope(
113
117
  slot: envelope.slot,
114
118
  });
115
119
  });
120
+ if (!isStatePostGloas(blockState)) {
121
+ throw new Error(`Expected gloas+ state for execution payload envelope validation, got fork=${blockState.forkName}`);
122
+ }
116
123
 
124
+ // [REJECT] `signed_execution_payload_envelope.signature` is valid as verified
125
+ // by `verify_execution_payload_envelope_signature`.
117
126
  const signatureSet = getExecutionPayloadEnvelopeSignatureSet(
118
127
  chain.config,
119
128
  chain.pubkeyCache,
@@ -2,6 +2,7 @@ import {
2
2
  computeEpochAtSlot,
3
3
  createSingleSignatureSetFromComponents,
4
4
  getPayloadAttestationDataSigningRoot,
5
+ isStatePostGloas,
5
6
  } from "@lodestar/state-transition";
6
7
  import {RootHex, gloas, ssz} from "@lodestar/types";
7
8
  import {toRootHex} from "@lodestar/utils";
@@ -66,6 +67,9 @@ async function validatePayloadAttestationMessage(
66
67
  }
67
68
 
68
69
  const state = chain.getHeadState();
70
+ if (!isStatePostGloas(state)) {
71
+ throw new Error(`Expected gloas+ state for payload attestation validation, got fork=${state.forkName}`);
72
+ }
69
73
 
70
74
  // [REJECT] The message's block `data.beacon_block_root` passes validation.
71
75
  // TODO GLOAS: implement this. Technically if we cannot get proto block from fork choice,
@@ -1,5 +1,5 @@
1
1
  import {SYNC_COMMITTEE_SUBNET_COUNT, SYNC_COMMITTEE_SUBNET_SIZE} from "@lodestar/params";
2
- import {IBeaconStateView} from "@lodestar/state-transition";
2
+ import {IBeaconStateView, isStatePostAltair} from "@lodestar/state-transition";
3
3
  import {SubnetID, altair} from "@lodestar/types";
4
4
  import {toRootHex} from "@lodestar/utils";
5
5
  import {GossipAction, SyncCommitteeError, SyncCommitteeErrorCode} from "../errors/index.js";
@@ -148,6 +148,10 @@ function getIndicesInSubcommittee(
148
148
  subnet: SubnetID,
149
149
  data: Pick<altair.SyncCommitteeMessage, "slot" | "validatorIndex">
150
150
  ): IndexInSubcommittee[] | null {
151
+ if (!isStatePostAltair(headState)) {
152
+ return null;
153
+ }
154
+
151
155
  const syncCommittee = headState.getIndexedSyncCommittee(data.slot);
152
156
  const indexesInCommittee = syncCommittee.validatorIndexMap.get(data.validatorIndex);
153
157
  if (indexesInCommittee === undefined) {
@@ -1,5 +1,5 @@
1
1
  import {SYNC_COMMITTEE_SUBNET_SIZE} from "@lodestar/params";
2
- import {IBeaconStateView, isSyncCommitteeAggregator} from "@lodestar/state-transition";
2
+ import {IBeaconStateView, isStatePostAltair, isSyncCommitteeAggregator} from "@lodestar/state-transition";
3
3
  import {ValidatorIndex, altair} from "@lodestar/types";
4
4
  import {GossipAction, SyncCommitteeError, SyncCommitteeErrorCode} from "../errors/index.js";
5
5
  import {IBeaconChain} from "../interface.js";
@@ -107,6 +107,10 @@ function getContributionIndices(
107
107
  state: IBeaconStateView,
108
108
  contribution: altair.SyncCommitteeContribution
109
109
  ): ValidatorIndex[] {
110
+ if (!isStatePostAltair(state)) {
111
+ throw new Error("Expected Altair state for sync committee contribution");
112
+ }
113
+
110
114
  const startIndex = contribution.subcommitteeIndex * SYNC_COMMITTEE_SUBNET_SIZE;
111
115
 
112
116
  const syncCommittee = state.getIndexedSyncCommittee(contribution.slot);
@@ -1,5 +1,5 @@
1
1
  import {ChainForkConfig} from "@lodestar/config";
2
- import {ForkSeq, MIN_ATTESTATION_INCLUSION_DELAY, SLOTS_PER_EPOCH} from "@lodestar/params";
2
+ import {MIN_ATTESTATION_INCLUSION_DELAY, SLOTS_PER_EPOCH} from "@lodestar/params";
3
3
  import {
4
4
  IBeaconStateView,
5
5
  ParticipationFlags,
@@ -7,6 +7,7 @@ import {
7
7
  computeStartSlotAtEpoch,
8
8
  computeTimeAtSlot,
9
9
  getCurrentSlot,
10
+ isStatePostAltair,
10
11
  parseAttesterFlags,
11
12
  parseParticipationFlags,
12
13
  } from "@lodestar/state-transition";
@@ -740,7 +741,7 @@ export function createValidatorMonitor(
740
741
 
741
742
  const rootCache = new RootHexCache(headState);
742
743
 
743
- if (config.getForkSeq(headState.slot) >= ForkSeq.altair) {
744
+ if (isStatePostAltair(headState)) {
744
745
  const prevEpochStartSlot = computeStartSlotAtEpoch(prevEpoch);
745
746
  const prevEpochTargetRoot = toRootHex(headState.getBlockRootAtSlot(prevEpochStartSlot));
746
747
 
@@ -1148,6 +1148,11 @@ function getSequentialHandlers(modules: ValidatorFnsModules, options: GossipHand
1148
1148
  } catch (e) {
1149
1149
  logger.error("Error adding to executionPayloadBid pool", {}, e as Error);
1150
1150
  }
1151
+
1152
+ chain.emitter.emit(routes.events.EventType.executionPayloadBid, {
1153
+ version: config.getForkName(executionPayloadBid.message.slot),
1154
+ data: executionPayloadBid,
1155
+ });
1151
1156
  },
1152
1157
  };
1153
1158
  }
@@ -96,11 +96,13 @@ export function validateBeaconBlocksByRangeRequest(
96
96
  if (count < 1) {
97
97
  throw new ResponseError(RespStatus.INVALID_REQUEST, "count < 1");
98
98
  }
99
- // TODO: validate against MIN_EPOCHS_FOR_BLOCK_REQUESTS
100
99
  if (startSlot < GENESIS_SLOT) {
101
100
  throw new ResponseError(RespStatus.INVALID_REQUEST, "startSlot < genesis");
102
101
  }
103
102
 
103
+ // The phase0 req/resp spec uses MIN_EPOCHS_FOR_BLOCK_REQUESTS to define the minimum range peers MUST serve.
104
+ // Archival nodes may still serve older retained blocks to allow genesis sync.
105
+
104
106
  // step > 1 is deprecated, see https://github.com/ethereum/consensus-specs/pull/2856
105
107
 
106
108
  const maxRequestBlocks = isForkPostDeneb(config.getForkName(startSlot))
@@ -8,6 +8,9 @@ export async function* onBeaconBlocksByRoot(
8
8
  requestBody: BeaconBlocksByRootRequest,
9
9
  chain: IBeaconChain
10
10
  ): AsyncIterable<ResponseOutgoing> {
11
+ // The phase0 req/resp spec uses MIN_EPOCHS_FOR_BLOCK_REQUESTS to define the minimum range peers MUST serve.
12
+ // Archival nodes may still serve older retained blocks to allow genesis sync.
13
+
11
14
  for (const blockRoot of requestBody) {
12
15
  const root = blockRoot;
13
16
  const block = await chain.getSerializedBlockByRoot(toRootHex(root));
@@ -2,7 +2,7 @@ import {ChainConfig} from "@lodestar/config";
2
2
  import {BLOB_SIDECAR_FIXED_SIZE, GENESIS_SLOT} from "@lodestar/params";
3
3
  import {RespStatus, ResponseError, ResponseOutgoing} from "@lodestar/reqresp";
4
4
  import {computeEpochAtSlot} from "@lodestar/state-transition";
5
- import {Slot, deneb} from "@lodestar/types";
5
+ import {Epoch, Slot, deneb} from "@lodestar/types";
6
6
  import {fromHex} from "@lodestar/utils";
7
7
  import {IBeaconChain} from "../../../chain/index.js";
8
8
  import {IBeaconDb} from "../../../db/index.js";
@@ -14,7 +14,7 @@ export async function* onBlobSidecarsByRange(
14
14
  db: IBeaconDb
15
15
  ): AsyncIterable<ResponseOutgoing> {
16
16
  // Non-finalized range of blobs
17
- const {startSlot, count} = validateBlobSidecarsByRangeRequest(chain.config, request);
17
+ const {startSlot, count} = validateBlobSidecarsByRangeRequest(chain.config, chain.clock.currentEpoch, request);
18
18
  const endSlot = startSlot + count;
19
19
 
20
20
  const finalized = db.blobSidecarsArchive;
@@ -94,6 +94,7 @@ export function* iterateBlobBytesFromWrapper(
94
94
 
95
95
  export function validateBlobSidecarsByRangeRequest(
96
96
  config: ChainConfig,
97
+ currentEpoch: Epoch,
97
98
  request: deneb.BlobSidecarsByRangeRequest
98
99
  ): deneb.BlobSidecarsByRangeRequest {
99
100
  const {startSlot} = request;
@@ -102,11 +103,22 @@ export function validateBlobSidecarsByRangeRequest(
102
103
  if (count < 1) {
103
104
  throw new ResponseError(RespStatus.INVALID_REQUEST, "count < 1");
104
105
  }
105
- // TODO: validate against MIN_EPOCHS_FOR_BLOCK_REQUESTS
106
106
  if (startSlot < GENESIS_SLOT) {
107
107
  throw new ResponseError(RespStatus.INVALID_REQUEST, "startSlot < genesis");
108
108
  }
109
109
 
110
+ // Spec: [max(current_epoch - MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS, DENEB_FORK_EPOCH), current_epoch]
111
+ const minimumRequestEpoch = Math.max(
112
+ currentEpoch - config.MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS,
113
+ config.DENEB_FORK_EPOCH
114
+ );
115
+ if (computeEpochAtSlot(startSlot) < minimumRequestEpoch) {
116
+ throw new ResponseError(
117
+ RespStatus.RESOURCE_UNAVAILABLE,
118
+ "startSlot is before MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS"
119
+ );
120
+ }
121
+
110
122
  if (count > config.MAX_REQUEST_BLOCKS_DENEB) {
111
123
  count = config.MAX_REQUEST_BLOCKS_DENEB;
112
124
  }
@@ -12,6 +12,13 @@ export async function* onBlobSidecarsByRoot(
12
12
  ): AsyncIterable<ResponseOutgoing> {
13
13
  const finalizedSlot = chain.forkChoice.getFinalizedBlock().slot;
14
14
 
15
+ // Spec: [max(current_epoch - MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS, DENEB_FORK_EPOCH), current_epoch]
16
+ const currentEpoch = chain.clock.currentEpoch;
17
+ const minimumRequestEpoch = Math.max(
18
+ currentEpoch - chain.config.MIN_EPOCHS_FOR_BLOB_SIDECARS_REQUESTS,
19
+ chain.config.DENEB_FORK_EPOCH
20
+ );
21
+
15
22
  // In sidecars by root request, it can be expected that sidecar requests will be come
16
23
  // clustured by blockroots, and this helps us save db lookups once we load sidecars
17
24
  // for a root
@@ -29,6 +36,10 @@ export async function* onBlobSidecarsByRoot(
29
36
  continue;
30
37
  }
31
38
 
39
+ if (computeEpochAtSlot(block.slot) < minimumRequestEpoch) {
40
+ continue;
41
+ }
42
+
32
43
  // Check if we need to load sidecars for a new block root
33
44
  if (lastFetchedSideCars === null || lastFetchedSideCars.blockRoot !== blockRootHex) {
34
45
  const blobSidecarsBytes = await chain.getSerializedBlobSidecars(block.slot, blockRootHex);
@@ -3,7 +3,7 @@ import {ChainConfig} from "@lodestar/config";
3
3
  import {GENESIS_SLOT} from "@lodestar/params";
4
4
  import {RespStatus, ResponseError, ResponseOutgoing} from "@lodestar/reqresp";
5
5
  import {computeEpochAtSlot} from "@lodestar/state-transition";
6
- import {ColumnIndex, fulu} from "@lodestar/types";
6
+ import {ColumnIndex, Epoch, fulu} from "@lodestar/types";
7
7
  import {fromHex} from "@lodestar/utils";
8
8
  import {IBeaconChain} from "../../../chain/index.js";
9
9
  import {IBeaconDb} from "../../../db/index.js";
@@ -21,7 +21,11 @@ export async function* onDataColumnSidecarsByRange(
21
21
  peerClient: string
22
22
  ): AsyncIterable<ResponseOutgoing> {
23
23
  // Non-finalized range of columns
24
- const {startSlot, count, columns: requestedColumns} = validateDataColumnSidecarsByRangeRequest(chain.config, request);
24
+ const {
25
+ startSlot,
26
+ count,
27
+ columns: requestedColumns,
28
+ } = validateDataColumnSidecarsByRangeRequest(chain.config, chain.clock.currentEpoch, request);
25
29
  const availableColumns = validateRequestedDataColumns(chain, requestedColumns);
26
30
  const endSlot = startSlot + count;
27
31
 
@@ -139,6 +143,7 @@ export async function* onDataColumnSidecarsByRange(
139
143
 
140
144
  export function validateDataColumnSidecarsByRangeRequest(
141
145
  config: ChainConfig,
146
+ currentEpoch: Epoch,
142
147
  request: fulu.DataColumnSidecarsByRangeRequest
143
148
  ): fulu.DataColumnSidecarsByRangeRequest {
144
149
  const {startSlot, columns} = request;
@@ -147,11 +152,22 @@ export function validateDataColumnSidecarsByRangeRequest(
147
152
  if (count < 1) {
148
153
  throw new ResponseError(RespStatus.INVALID_REQUEST, "count < 1");
149
154
  }
150
- // TODO: validate against MIN_EPOCHS_FOR_BLOCK_REQUESTS
151
155
  if (startSlot < GENESIS_SLOT) {
152
156
  throw new ResponseError(RespStatus.INVALID_REQUEST, "startSlot < genesis");
153
157
  }
154
158
 
159
+ // Spec: [max(current_epoch - MIN_EPOCHS_FOR_DATA_COLUMN_SIDECARS_REQUESTS, FULU_FORK_EPOCH), current_epoch]
160
+ const minimumRequestEpoch = Math.max(
161
+ currentEpoch - config.MIN_EPOCHS_FOR_DATA_COLUMN_SIDECARS_REQUESTS,
162
+ config.FULU_FORK_EPOCH
163
+ );
164
+ if (computeEpochAtSlot(startSlot) < minimumRequestEpoch) {
165
+ throw new ResponseError(
166
+ RespStatus.RESOURCE_UNAVAILABLE,
167
+ "startSlot is before MIN_EPOCHS_FOR_DATA_COLUMN_SIDECARS_REQUESTS"
168
+ );
169
+ }
170
+
155
171
  if (count > config.MAX_REQUEST_BLOCKS_DENEB) {
156
172
  count = config.MAX_REQUEST_BLOCKS_DENEB;
157
173
  }
@@ -81,11 +81,13 @@ export function validateExecutionPayloadEnvelopesByRangeRequest(
81
81
  if (count < 1) {
82
82
  throw new ResponseError(RespStatus.INVALID_REQUEST, "count < 1");
83
83
  }
84
- // TODO: validate against MIN_EPOCHS_FOR_BLOCK_REQUESTS
85
84
  if (startSlot < GENESIS_SLOT) {
86
85
  throw new ResponseError(RespStatus.INVALID_REQUEST, "startSlot < genesis");
87
86
  }
88
87
 
88
+ // The gloas req/resp spec uses MIN_EPOCHS_FOR_BLOCK_REQUESTS to define the minimum range peers MUST serve.
89
+ // Archival nodes may still serve older retained payloads to allow genesis sync.
90
+
89
91
  if (count > config.MAX_REQUEST_BLOCKS_DENEB) {
90
92
  count = config.MAX_REQUEST_BLOCKS_DENEB;
91
93
  }
@@ -10,12 +10,8 @@ export async function* onExecutionPayloadEnvelopesByRoot(
10
10
  chain: IBeaconChain,
11
11
  db: IBeaconDb
12
12
  ): AsyncIterable<ResponseOutgoing> {
13
- // Spec: [max(GLOAS_FORK_EPOCH, current_epoch - MIN_EPOCHS_FOR_BLOCK_REQUESTS), current_epoch]
14
- const currentEpoch = chain.clock.currentEpoch;
15
- const minimumRequestEpoch = Math.max(
16
- currentEpoch - chain.config.MIN_EPOCHS_FOR_BLOCK_REQUESTS,
17
- chain.config.GLOAS_FORK_EPOCH
18
- );
13
+ // The gloas req/resp spec uses MIN_EPOCHS_FOR_BLOCK_REQUESTS to define the minimum range peers MUST serve.
14
+ // Archival nodes may still serve older retained payloads to allow genesis sync.
19
15
 
20
16
  for (const root of requestBody) {
21
17
  const rootHex = toRootHex(root);
@@ -27,16 +23,11 @@ export async function* onExecutionPayloadEnvelopesByRoot(
27
23
  continue;
28
24
  }
29
25
 
30
- const requestedEpoch = computeEpochAtSlot(slot);
31
- if (requestedEpoch < minimumRequestEpoch) {
32
- continue;
33
- }
34
-
35
26
  const envelopeBytes = await chain.getSerializedExecutionPayloadEnvelope(slot, rootHex);
36
27
  if (envelopeBytes) {
37
28
  yield {
38
29
  data: envelopeBytes,
39
- boundary: chain.config.getForkBoundaryAtEpoch(requestedEpoch),
30
+ boundary: chain.config.getForkBoundaryAtEpoch(computeEpochAtSlot(slot)),
40
31
  };
41
32
  }
42
33
  }
@@ -6,7 +6,7 @@ import {BeaconApiMethods} from "@lodestar/api/beacon/server";
6
6
  import {BeaconConfig} from "@lodestar/config";
7
7
  import type {LoggerNode} from "@lodestar/logger/node";
8
8
  import {ZERO_HASH_HEX} from "@lodestar/params";
9
- import {IBeaconStateView, PubkeyCache} from "@lodestar/state-transition";
9
+ import {IBeaconStateView, PubkeyCache, isStatePostBellatrix} from "@lodestar/state-transition";
10
10
  import {phase0} from "@lodestar/types";
11
11
  import {sleep, toRootHex} from "@lodestar/utils";
12
12
  import {ProcessShutdownCallback} from "@lodestar/validator";
@@ -221,7 +221,10 @@ export class BeaconNode {
221
221
 
222
222
  let executionEngineOpts = opts.executionEngine;
223
223
  if (opts.executionEngine.mode === "mock") {
224
- const eth1BlockHash = anchorState.isExecutionStateType ? toRootHex(anchorState.latestBlockHash) : undefined;
224
+ const eth1BlockHash =
225
+ isStatePostBellatrix(anchorState) && anchorState.isExecutionStateType
226
+ ? toRootHex(anchorState.latestBlockHash)
227
+ : undefined;
225
228
  executionEngineOpts = {
226
229
  ...opts.executionEngine,
227
230
  genesisBlockHash: ZERO_HASH_HEX,
@@ -1,7 +1,12 @@
1
1
  import {BeaconConfig} from "@lodestar/config";
2
2
  import {ExecutionStatus, ProtoBlock} from "@lodestar/fork-choice";
3
3
  import {EPOCHS_PER_SYNC_COMMITTEE_PERIOD, SLOTS_PER_EPOCH} from "@lodestar/params";
4
- import {IBeaconStateView, computeEpochAtSlot, computeStartSlotAtEpoch} from "@lodestar/state-transition";
4
+ import {
5
+ IBeaconStateView,
6
+ computeEpochAtSlot,
7
+ computeStartSlotAtEpoch,
8
+ isStatePostBellatrix,
9
+ } from "@lodestar/state-transition";
5
10
  import {Epoch} from "@lodestar/types";
6
11
  import {ErrorAborted, Logger, prettyBytes, prettyBytesShort, sleep} from "@lodestar/utils";
7
12
  import {IBeaconChain} from "../chain/index.js";
@@ -165,7 +170,7 @@ function getHeadExecutionInfo(
165
170
  const executionStatusStr = headInfo.executionStatus.toLowerCase();
166
171
 
167
172
  // Add execution status to notifier only if head is on/post bellatrix
168
- if (headState.isExecutionStateType) {
173
+ if (isStatePostBellatrix(headState) && headState.isExecutionStateType) {
169
174
  if (headState.isMergeTransitionComplete) {
170
175
  const executionPayloadHashInfo =
171
176
  headInfo.executionStatus !== ExecutionStatus.PreMerge ? headInfo.executionPayloadBlockHash : "empty";