@lodestar/beacon-node 1.42.0-dev.ff662b331c → 1.42.0

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 (106) hide show
  1. package/lib/api/impl/beacon/pool/index.d.ts.map +1 -1
  2. package/lib/api/impl/beacon/pool/index.js +0 -4
  3. package/lib/api/impl/beacon/pool/index.js.map +1 -1
  4. package/lib/api/impl/beacon/state/index.d.ts.map +1 -1
  5. package/lib/api/impl/beacon/state/index.js +10 -13
  6. package/lib/api/impl/beacon/state/index.js.map +1 -1
  7. package/lib/api/impl/lodestar/index.d.ts.map +1 -1
  8. package/lib/api/impl/lodestar/index.js +0 -4
  9. package/lib/api/impl/lodestar/index.js.map +1 -1
  10. package/lib/api/impl/validator/index.d.ts.map +1 -1
  11. package/lib/api/impl/validator/index.js +1 -7
  12. package/lib/api/impl/validator/index.js.map +1 -1
  13. package/lib/chain/blocks/importBlock.d.ts.map +1 -1
  14. package/lib/chain/blocks/importBlock.js +4 -6
  15. package/lib/chain/blocks/importBlock.js.map +1 -1
  16. package/lib/chain/blocks/importExecutionPayload.d.ts.map +1 -1
  17. package/lib/chain/blocks/importExecutionPayload.js +1 -7
  18. package/lib/chain/blocks/importExecutionPayload.js.map +1 -1
  19. package/lib/chain/blocks/verifyBlocksExecutionPayloads.d.ts.map +1 -1
  20. package/lib/chain/blocks/verifyBlocksExecutionPayloads.js +2 -3
  21. package/lib/chain/blocks/verifyBlocksExecutionPayloads.js.map +1 -1
  22. package/lib/chain/blocks/verifyBlocksSignatures.d.ts.map +1 -1
  23. package/lib/chain/blocks/verifyBlocksSignatures.js +2 -4
  24. package/lib/chain/blocks/verifyBlocksSignatures.js.map +1 -1
  25. package/lib/chain/chain.d.ts.map +1 -1
  26. package/lib/chain/chain.js +4 -9
  27. package/lib/chain/chain.js.map +1 -1
  28. package/lib/chain/forkChoice/index.d.ts.map +1 -1
  29. package/lib/chain/forkChoice/index.js +8 -10
  30. package/lib/chain/forkChoice/index.js.map +1 -1
  31. package/lib/chain/lightClient/index.d.ts +2 -2
  32. package/lib/chain/lightClient/index.d.ts.map +1 -1
  33. package/lib/chain/lightClient/index.js.map +1 -1
  34. package/lib/chain/opPools/aggregatedAttestationPool.d.ts.map +1 -1
  35. package/lib/chain/opPools/aggregatedAttestationPool.js +2 -5
  36. package/lib/chain/opPools/aggregatedAttestationPool.js.map +1 -1
  37. package/lib/chain/opPools/executionPayloadBidPool.d.ts +2 -2
  38. package/lib/chain/opPools/executionPayloadBidPool.d.ts.map +1 -1
  39. package/lib/chain/opPools/executionPayloadBidPool.js +2 -2
  40. package/lib/chain/opPools/executionPayloadBidPool.js.map +1 -1
  41. package/lib/chain/prepareNextSlot.d.ts.map +1 -1
  42. package/lib/chain/prepareNextSlot.js +1 -7
  43. package/lib/chain/prepareNextSlot.js.map +1 -1
  44. package/lib/chain/produceBlock/computeNewStateRoot.d.ts +2 -2
  45. package/lib/chain/produceBlock/computeNewStateRoot.d.ts.map +1 -1
  46. package/lib/chain/produceBlock/computeNewStateRoot.js.map +1 -1
  47. package/lib/chain/produceBlock/produceBlockBody.d.ts +3 -3
  48. package/lib/chain/produceBlock/produceBlockBody.d.ts.map +1 -1
  49. package/lib/chain/produceBlock/produceBlockBody.js +1 -10
  50. package/lib/chain/produceBlock/produceBlockBody.js.map +1 -1
  51. package/lib/chain/validation/block.d.ts.map +1 -1
  52. package/lib/chain/validation/block.js +2 -2
  53. package/lib/chain/validation/block.js.map +1 -1
  54. package/lib/chain/validation/executionPayloadBid.d.ts.map +1 -1
  55. package/lib/chain/validation/executionPayloadBid.js +4 -7
  56. package/lib/chain/validation/executionPayloadBid.js.map +1 -1
  57. package/lib/chain/validation/executionPayloadEnvelope.d.ts.map +1 -1
  58. package/lib/chain/validation/executionPayloadEnvelope.js +1 -4
  59. package/lib/chain/validation/executionPayloadEnvelope.js.map +1 -1
  60. package/lib/chain/validation/payloadAttestationMessage.d.ts.map +1 -1
  61. package/lib/chain/validation/payloadAttestationMessage.js +1 -4
  62. package/lib/chain/validation/payloadAttestationMessage.js.map +1 -1
  63. package/lib/chain/validation/syncCommittee.d.ts.map +1 -1
  64. package/lib/chain/validation/syncCommittee.js +0 -4
  65. package/lib/chain/validation/syncCommittee.js.map +1 -1
  66. package/lib/chain/validation/syncCommitteeContributionAndProof.js +1 -4
  67. package/lib/chain/validation/syncCommitteeContributionAndProof.js.map +1 -1
  68. package/lib/chain/validatorMonitor.d.ts.map +1 -1
  69. package/lib/chain/validatorMonitor.js +3 -3
  70. package/lib/chain/validatorMonitor.js.map +1 -1
  71. package/lib/network/processor/gossipHandlers.d.ts.map +1 -1
  72. package/lib/network/processor/gossipHandlers.js +0 -4
  73. package/lib/network/processor/gossipHandlers.js.map +1 -1
  74. package/lib/node/nodejs.d.ts.map +1 -1
  75. package/lib/node/nodejs.js +1 -4
  76. package/lib/node/nodejs.js.map +1 -1
  77. package/lib/node/notifier.d.ts.map +1 -1
  78. package/lib/node/notifier.js +2 -2
  79. package/lib/node/notifier.js.map +1 -1
  80. package/package.json +15 -15
  81. package/src/api/impl/beacon/pool/index.ts +0 -4
  82. package/src/api/impl/beacon/state/index.ts +15 -15
  83. package/src/api/impl/lodestar/index.ts +0 -4
  84. package/src/api/impl/validator/index.ts +0 -7
  85. package/src/chain/blocks/importBlock.ts +7 -11
  86. package/src/chain/blocks/importExecutionPayload.ts +1 -7
  87. package/src/chain/blocks/verifyBlocksExecutionPayloads.ts +1 -2
  88. package/src/chain/blocks/verifyBlocksSignatures.ts +2 -9
  89. package/src/chain/chain.ts +4 -10
  90. package/src/chain/forkChoice/index.ts +8 -11
  91. package/src/chain/lightClient/index.ts +3 -7
  92. package/src/chain/opPools/aggregatedAttestationPool.ts +1 -6
  93. package/src/chain/opPools/executionPayloadBidPool.ts +3 -3
  94. package/src/chain/prepareNextSlot.ts +0 -8
  95. package/src/chain/produceBlock/computeNewStateRoot.ts +1 -2
  96. package/src/chain/produceBlock/produceBlockBody.ts +5 -25
  97. package/src/chain/validation/block.ts +1 -2
  98. package/src/chain/validation/executionPayloadBid.ts +3 -7
  99. package/src/chain/validation/executionPayloadEnvelope.ts +1 -8
  100. package/src/chain/validation/payloadAttestationMessage.ts +0 -4
  101. package/src/chain/validation/syncCommittee.ts +1 -5
  102. package/src/chain/validation/syncCommitteeContributionAndProof.ts +1 -5
  103. package/src/chain/validatorMonitor.ts +2 -3
  104. package/src/network/processor/gossipHandlers.ts +0 -5
  105. package/src/node/nodejs.ts +2 -5
  106. package/src/node/notifier.ts +2 -7
@@ -1,14 +1,17 @@
1
1
  import {routes} from "@lodestar/api";
2
2
  import {ApplicationMethods} from "@lodestar/api/server";
3
- import {EPOCHS_PER_HISTORICAL_VECTOR, SLOTS_PER_EPOCH, SYNC_COMMITTEE_SUBNET_SIZE} from "@lodestar/params";
3
+ import {
4
+ EPOCHS_PER_HISTORICAL_VECTOR,
5
+ SLOTS_PER_EPOCH,
6
+ SYNC_COMMITTEE_SUBNET_SIZE,
7
+ isForkPostElectra,
8
+ isForkPostFulu,
9
+ } from "@lodestar/params";
4
10
  import {
5
11
  IBeaconStateView,
6
12
  computeEpochAtSlot,
7
13
  computeStartSlotAtEpoch,
8
14
  getCurrentEpoch,
9
- isStatePostAltair,
10
- isStatePostElectra,
11
- isStatePostFulu,
12
15
  } from "@lodestar/state-transition";
13
16
  import {ValidatorIndex, getValidatorStatus, ssz} from "@lodestar/types";
14
17
  import {ApiError} from "../../errors.js";
@@ -300,9 +303,6 @@ export function getBeaconStateApi({
300
303
  if (stateEpoch < config.ALTAIR_FORK_EPOCH) {
301
304
  throw new ApiError(400, "Requested state before ALTAIR_FORK_EPOCH");
302
305
  }
303
- if (!isStatePostAltair(state)) {
304
- throw new Error("Expected Altair state for sync committee lookup");
305
- }
306
306
 
307
307
  const syncCommitteeCache = state.getIndexedSyncCommitteeAtEpoch(epoch ?? stateEpoch);
308
308
  const validatorIndices = new Array<ValidatorIndex>(...syncCommitteeCache.validatorIndices);
@@ -324,9 +324,9 @@ export function getBeaconStateApi({
324
324
 
325
325
  async getPendingDeposits({stateId}, context) {
326
326
  const {state, executionOptimistic, finalized} = await getState(stateId);
327
- const fork = state.forkName;
327
+ const fork = config.getForkName(state.slot);
328
328
 
329
- if (!isStatePostElectra(state)) {
329
+ if (!isForkPostElectra(fork)) {
330
330
  throw new ApiError(400, `Cannot retrieve pending deposits for pre-electra state fork=${fork}`);
331
331
  }
332
332
 
@@ -340,9 +340,9 @@ export function getBeaconStateApi({
340
340
 
341
341
  async getPendingPartialWithdrawals({stateId}, context) {
342
342
  const {state, executionOptimistic, finalized} = await getState(stateId);
343
- const fork = state.forkName;
343
+ const fork = config.getForkName(state.slot);
344
344
 
345
- if (!isStatePostElectra(state)) {
345
+ if (!isForkPostElectra(fork)) {
346
346
  throw new ApiError(400, `Cannot retrieve pending partial withdrawals for pre-electra state fork=${fork}`);
347
347
  }
348
348
 
@@ -358,9 +358,9 @@ export function getBeaconStateApi({
358
358
 
359
359
  async getPendingConsolidations({stateId}, context) {
360
360
  const {state, executionOptimistic, finalized} = await getState(stateId);
361
- const fork = state.forkName;
361
+ const fork = config.getForkName(state.slot);
362
362
 
363
- if (!isStatePostElectra(state)) {
363
+ if (!isForkPostElectra(fork)) {
364
364
  throw new ApiError(400, `Cannot retrieve pending consolidations for pre-electra state fork=${fork}`);
365
365
  }
366
366
 
@@ -376,9 +376,9 @@ export function getBeaconStateApi({
376
376
 
377
377
  async getProposerLookahead({stateId}, context) {
378
378
  const {state, executionOptimistic, finalized} = await getState(stateId);
379
- const fork = state.forkName;
379
+ const fork = config.getForkName(state.slot);
380
380
 
381
- if (!isStatePostFulu(state)) {
381
+ if (!isForkPostFulu(fork)) {
382
382
  throw new ApiError(400, `Cannot retrieve proposer lookahead for pre-fulu state fork=${fork}`);
383
383
  }
384
384
 
@@ -3,7 +3,6 @@ import {ApplicationMethods} from "@lodestar/api/server";
3
3
  import {ChainForkConfig} from "@lodestar/config";
4
4
  import {Repository} from "@lodestar/db";
5
5
  import {ForkSeq, SLOTS_PER_EPOCH} from "@lodestar/params";
6
- import {isStatePostCapella} from "@lodestar/state-transition";
7
6
  import {ssz} from "@lodestar/types";
8
7
  import {Checkpoint} from "@lodestar/types/phase0";
9
8
  import {fromHex, toHex, toRootHex} from "@lodestar/utils";
@@ -219,9 +218,6 @@ export function getLodestarApi({
219
218
  if (ForkSeq[fork] < ForkSeq.capella) {
220
219
  throw new Error("Historical summaries are not supported before Capella");
221
220
  }
222
- if (!isStatePostCapella(stateView)) {
223
- throw new Error("Expected Capella state for historical summaries");
224
- }
225
221
 
226
222
  const {gindex} = ssz[fork].BeaconState.getPathInfo(["historicalSummaries"]);
227
223
  const proof = stateView.getSingleProof(gindex);
@@ -25,7 +25,6 @@ import {
25
25
  computeStartSlotAtEpoch,
26
26
  computeTimeAtSlot,
27
27
  getCurrentSlot,
28
- isStatePostAltair,
29
28
  proposerShufflingDecisionRoot,
30
29
  } from "@lodestar/state-transition";
31
30
  import {
@@ -1283,9 +1282,6 @@ export function getValidatorApi(
1283
1282
  if (indices.length === 0) {
1284
1283
  throw new ApiError(400, "No validator to get attester duties");
1285
1284
  }
1286
- if (epoch < config.ALTAIR_FORK_EPOCH) {
1287
- throw new ApiError(400, "Sync committee duties are not supported before Altair");
1288
- }
1289
1285
 
1290
1286
  // May request for an epoch that's in the future
1291
1287
  await waitForNextClosestEpoch();
@@ -1295,9 +1291,6 @@ export function getValidatorApi(
1295
1291
  // Note: does not support requesting past duties
1296
1292
  const head = chain.forkChoice.getHead();
1297
1293
  const state = chain.getHeadState();
1298
- if (!isStatePostAltair(state)) {
1299
- throw new ApiError(400, "Sync committee duties are not available before Altair");
1300
- }
1301
1294
 
1302
1295
  // Check that all validatorIndex belong to the state before calling getCommitteeAssignments()
1303
1296
  const pubkeys = getPubkeysForIndices(state, indices);
@@ -25,8 +25,6 @@ import {
25
25
  computeStartSlotAtEpoch,
26
26
  computeTimeAtSlot,
27
27
  isStartSlotOfEpoch,
28
- isStatePostAltair,
29
- isStatePostBellatrix,
30
28
  } from "@lodestar/state-transition";
31
29
  import {
32
30
  Attestation,
@@ -390,13 +388,11 @@ export async function importBlock(
390
388
  // we want to import block asap so do this in the next event loop
391
389
  callInNextEventLoop(() => {
392
390
  try {
393
- if (isStatePostAltair(postBlockState)) {
394
- this.lightClientServer?.onImportBlockHead(
395
- block.message as BeaconBlock<ForkPostAltair>,
396
- postBlockState,
397
- parentBlockSlot
398
- );
399
- }
391
+ this.lightClientServer?.onImportBlockHead(
392
+ block.message as BeaconBlock<ForkPostAltair>,
393
+ postBlockState,
394
+ parentBlockSlot
395
+ );
400
396
  } catch (e) {
401
397
  this.logger.verbose("Error lightClientServer.onImportBlock", {slot: blockSlot}, e as Error);
402
398
  }
@@ -415,7 +411,7 @@ export async function importBlock(
415
411
  // and the block is weak and can potentially be reorged out.
416
412
  let shouldOverrideFcu = false;
417
413
 
418
- if (blockSlot >= currentSlot && isStatePostBellatrix(postBlockState) && postBlockState.isExecutionStateType) {
414
+ if (blockSlot >= currentSlot && postBlockState.isExecutionStateType) {
419
415
  let notOverrideFcuReason = NotReorgedReason.Unknown;
420
416
  const proposalSlot = blockSlot + 1;
421
417
  try {
@@ -602,7 +598,7 @@ export async function importBlock(
602
598
  this.metrics?.parentBlockDistance.observe(blockSlot - parentBlockSlot);
603
599
  this.metrics?.proposerBalanceDeltaAny.observe(fullyVerifiedBlock.proposerBalanceDelta);
604
600
  this.validatorMonitor?.registerImportedBlock(block.message, fullyVerifiedBlock);
605
- if (isStatePostAltair(fullyVerifiedBlock.postBlockState)) {
601
+ if (this.config.getForkSeq(blockSlot) >= ForkSeq.altair) {
606
602
  this.validatorMonitor?.registerSyncAggregateInBlock(
607
603
  blockEpoch,
608
604
  (block as altair.SignedBeaconBlock).message.body.syncAggregate,
@@ -1,7 +1,7 @@
1
1
  import {routes} from "@lodestar/api";
2
2
  import {ExecutionStatus, PayloadExecutionStatus} from "@lodestar/fork-choice";
3
3
  import {SLOTS_PER_EPOCH} from "@lodestar/params";
4
- import {getExecutionPayloadEnvelopeSignatureSet, isStatePostGloas} from "@lodestar/state-transition";
4
+ import {getExecutionPayloadEnvelopeSignatureSet} from "@lodestar/state-transition";
5
5
  import {byteArrayEquals, fromHex, toRootHex} from "@lodestar/utils";
6
6
  import {ExecutionPayloadStatus} from "../../execution/index.js";
7
7
  import {isQueueErrorAborted} from "../../util/queue/index.js";
@@ -124,12 +124,6 @@ export async function importExecutionPayload(
124
124
  {dontTransferCache: true},
125
125
  RegenCaller.processBlock
126
126
  );
127
- if (!isStatePostGloas(blockState)) {
128
- throw new PayloadError({
129
- code: PayloadErrorCode.STATE_TRANSITION_ERROR,
130
- message: `Expected gloas+ block state for payload import, got fork=${blockState.forkName}`,
131
- });
132
- }
133
127
 
134
128
  // 5. Run verification steps in parallel
135
129
  // Note: No data availability check needed here - importExecutionPayload is only
@@ -8,7 +8,7 @@ import {
8
8
  ProtoBlock,
9
9
  } from "@lodestar/fork-choice";
10
10
  import {ForkSeq} from "@lodestar/params";
11
- import {IBeaconStateView, isExecutionBlockBodyType, isStatePostBellatrix} from "@lodestar/state-transition";
11
+ import {IBeaconStateView, isExecutionBlockBodyType} from "@lodestar/state-transition";
12
12
  import {bellatrix, electra} from "@lodestar/types";
13
13
  import {ErrorAborted, Logger, toRootHex} from "@lodestar/utils";
14
14
  import {ExecutionPayloadStatus, IExecutionEngine} from "../../execution/engine/interface.js";
@@ -152,7 +152,6 @@ export async function verifyBlockExecutionPayload(
152
152
 
153
153
  /** Not null if execution is enabled */
154
154
  const executionPayloadEnabled =
155
- isStatePostBellatrix(preState0) &&
156
155
  preState0.isExecutionStateType &&
157
156
  isExecutionBlockBodyType(block.message.body) &&
158
157
  preState0.isExecutionEnabled(block.message)
@@ -1,10 +1,5 @@
1
1
  import {BeaconConfig} from "@lodestar/config";
2
- import {
3
- IBeaconStateView,
4
- SyncCommitteeCacheEmpty,
5
- getBlockSignatureSets,
6
- isStatePostAltair,
7
- } from "@lodestar/state-transition";
2
+ import {IBeaconStateView, getBlockSignatureSets} from "@lodestar/state-transition";
8
3
  import {IndexedAttestation, SignedBeaconBlock} from "@lodestar/types";
9
4
  import {Logger} from "@lodestar/utils";
10
5
  import {Metrics} from "../../metrics/metrics.js";
@@ -32,9 +27,7 @@ export async function verifyBlocksSignatures(
32
27
  ): Promise<{verifySignaturesTime: number}> {
33
28
  const isValidPromises: Promise<boolean>[] = [];
34
29
  const recvToValLatency = Date.now() / 1000 - (opts.seenTimestampSec ?? Date.now() / 1000);
35
- const currentSyncCommitteeIndexed = isStatePostAltair(preState0)
36
- ? preState0.currentSyncCommitteeIndexed
37
- : new SyncCommitteeCacheEmpty();
30
+ const currentSyncCommitteeIndexed = preState0.currentSyncCommitteeIndexed;
38
31
 
39
32
  // Verifies signatures after running state transition, so all SyncCommittee signed roots are known at this point.
40
33
  // We must ensure block.slot <= state.slot before running getAllBlockSignatureSets().
@@ -18,6 +18,7 @@ import {
18
18
  type ForkPostGloas,
19
19
  GENESIS_SLOT,
20
20
  SLOTS_PER_EPOCH,
21
+ isForkPostElectra,
21
22
  isForkPostGloas,
22
23
  } from "@lodestar/params";
23
24
  import {
@@ -29,9 +30,6 @@ import {
29
30
  computeEpochAtSlot,
30
31
  computeStartSlotAtEpoch,
31
32
  getEffectiveBalancesFromStateBytes,
32
- isStatePostAltair,
33
- isStatePostElectra,
34
- isStatePostGloas,
35
33
  } from "@lodestar/state-transition";
36
34
  import {
37
35
  BeaconBlock,
@@ -1078,9 +1076,6 @@ export class BeaconChain implements IBeaconChain {
1078
1076
  slot,
1079
1077
  stateRoot: ZERO_HASH,
1080
1078
  };
1081
- if (!isStatePostGloas(postState)) {
1082
- throw Error(`Expected gloas+ post-state for execution payload envelope, got fork=${postState.forkName}`);
1083
- }
1084
1079
  const envelopeStateRoot = computeEnvelopeStateRoot(this.metrics, postState, envelope);
1085
1080
  gloasResult.envelopeStateRoot = envelopeStateRoot;
1086
1081
  }
@@ -1409,7 +1404,9 @@ export class BeaconChain implements IBeaconChain {
1409
1404
  metrics.chain.blacklistedBlocks.set(this.blacklistedBlocks.size);
1410
1405
 
1411
1406
  const headState = this.getHeadState();
1412
- if (isStatePostElectra(headState)) {
1407
+ const fork = this.config.getForkName(headState.slot);
1408
+
1409
+ if (isForkPostElectra(fork)) {
1413
1410
  metrics.pendingDeposits.set(headState.pendingDepositsCount);
1414
1411
  metrics.pendingPartialWithdrawals.set(headState.pendingPartialWithdrawalsCount);
1415
1412
  metrics.pendingConsolidations.set(headState.pendingConsolidationsCount);
@@ -1656,9 +1653,6 @@ export class BeaconChain implements IBeaconChain {
1656
1653
  }
1657
1654
 
1658
1655
  preState = preState.processSlots(block.slot); // Dial preState's slot to block.slot
1659
- if (!isStatePostAltair(preState)) {
1660
- throw new Error("Sync committee rewards are not supported before Altair");
1661
- }
1662
1656
 
1663
1657
  return preState.computeSyncCommitteeRewards(block, validatorIds ?? []);
1664
1658
  }
@@ -10,14 +10,12 @@ import {
10
10
  ForkChoiceOpts as RawForkChoiceOpts,
11
11
  getCheckpointPayloadStatus,
12
12
  } from "@lodestar/fork-choice";
13
- import {ZERO_HASH_HEX} from "@lodestar/params";
13
+ import {ForkSeq, ZERO_HASH_HEX} from "@lodestar/params";
14
14
  import {
15
15
  DataAvailabilityStatus,
16
16
  IBeaconStateView,
17
17
  computeEpochAtSlot,
18
18
  computeStartSlotAtEpoch,
19
- isStatePostBellatrix,
20
- isStatePostGloas,
21
19
  } from "@lodestar/state-transition";
22
20
  import {Slot, ssz} from "@lodestar/types";
23
21
  import {Logger, toRootHex} from "@lodestar/utils";
@@ -144,19 +142,19 @@ export function initializeForkChoiceFromFinalizedState(
144
142
  unrealizedFinalizedEpoch: finalizedCheckpoint.epoch,
145
143
  unrealizedFinalizedRoot: toRootHex(finalizedCheckpoint.root),
146
144
 
147
- ...(isStatePostBellatrix(state) && state.isExecutionStateType && state.isMergeTransitionComplete
145
+ ...(state.isExecutionStateType && state.isMergeTransitionComplete
148
146
  ? {
149
147
  executionPayloadBlockHash: toRootHex(state.latestBlockHash),
150
148
  // TODO GLOAS: executionPayloadNumber is not tracked in BeaconState post-gloas (EIP-7732 removed
151
149
  // latestExecutionPayloadHeader). Using 0 as unavailable fallback until a solution is found.
152
- executionPayloadNumber: isStatePostGloas(state) ? 0 : state.payloadBlockNumber,
150
+ executionPayloadNumber: config.getForkSeq(state.slot) >= ForkSeq.gloas ? 0 : state.payloadBlockNumber,
153
151
  executionStatus: blockHeader.slot === GENESIS_SLOT ? ExecutionStatus.Valid : ExecutionStatus.Syncing,
154
152
  }
155
153
  : {executionPayloadBlockHash: null, executionStatus: ExecutionStatus.PreMerge}),
156
154
 
157
155
  dataAvailabilityStatus: DataAvailabilityStatus.PreData,
158
156
  payloadStatus: isForkPostGloas ? PayloadStatus.PENDING : PayloadStatus.FULL, // TODO GLOAS: Post-gloas how do we know if the checkpoint payload is FULL or EMPTY?
159
- parentBlockHash: isStatePostGloas(state) ? toRootHex(state.latestBlockHash) : null,
157
+ parentBlockHash: isForkPostGloas ? toRootHex(state.latestBlockHash) : null,
160
158
  },
161
159
  currentSlot
162
160
  ),
@@ -239,21 +237,20 @@ export function initializeForkChoiceFromUnfinalizedState(
239
237
  unrealizedFinalizedEpoch: finalizedCheckpoint.epoch,
240
238
  unrealizedFinalizedRoot: toRootHex(finalizedCheckpoint.root),
241
239
 
242
- ...(isStatePostBellatrix(unfinalizedState) &&
243
- unfinalizedState.isExecutionStateType &&
244
- unfinalizedState.isMergeTransitionComplete
240
+ ...(unfinalizedState.isExecutionStateType && unfinalizedState.isMergeTransitionComplete
245
241
  ? {
246
242
  executionPayloadBlockHash: toRootHex(unfinalizedState.latestBlockHash),
247
243
  // TODO GLOAS: executionPayloadNumber is not tracked in BeaconState post-gloas (EIP-7732 removed
248
244
  // latestExecutionPayloadHeader). Using 0 as unavailable fallback until a solution is found.
249
- executionPayloadNumber: isStatePostGloas(unfinalizedState) ? 0 : unfinalizedState.payloadBlockNumber,
245
+ executionPayloadNumber:
246
+ config.getForkSeq(unfinalizedState.slot) >= ForkSeq.gloas ? 0 : unfinalizedState.payloadBlockNumber,
250
247
  executionStatus: blockHeader.slot === GENESIS_SLOT ? ExecutionStatus.Valid : ExecutionStatus.Syncing,
251
248
  }
252
249
  : {executionPayloadBlockHash: null, executionStatus: ExecutionStatus.PreMerge}),
253
250
 
254
251
  dataAvailabilityStatus: DataAvailabilityStatus.PreData,
255
252
  payloadStatus: isForkPostGloas ? PayloadStatus.PENDING : PayloadStatus.FULL, // TODO GLOAS: Post-gloas how do we know if the checkpoint payload is FULL or EMPTY?
256
- parentBlockHash: isStatePostGloas(unfinalizedState) ? toRootHex(unfinalizedState.latestBlockHash) : null,
253
+ parentBlockHash: isForkPostGloas ? toRootHex(unfinalizedState.latestBlockHash) : null,
257
254
  };
258
255
 
259
256
  const parentSlot = blockHeader.slot - 1;
@@ -21,7 +21,7 @@ import {
21
21
  isForkPostElectra,
22
22
  } from "@lodestar/params";
23
23
  import {
24
- type IBeaconStateViewAltair,
24
+ IBeaconStateView,
25
25
  computeStartSlotAtEpoch,
26
26
  computeSyncPeriodAtEpoch,
27
27
  computeSyncPeriodAtSlot,
@@ -260,11 +260,7 @@ export class LightClientServer {
260
260
  * - Persist state witness
261
261
  * - Use block's syncAggregate
262
262
  */
263
- onImportBlockHead(
264
- block: BeaconBlock<ForkPostAltair>,
265
- postState: IBeaconStateViewAltair,
266
- parentBlockSlot: Slot
267
- ): void {
263
+ onImportBlockHead(block: BeaconBlock<ForkPostAltair>, postState: IBeaconStateView, parentBlockSlot: Slot): void {
268
264
  // TEMP: To disable this functionality for fork_choice spec tests.
269
265
  // Since the tests have deep-reorgs attested data is not available often printing lots of error logs.
270
266
  // While this function is only called for head blocks, best to disable.
@@ -400,7 +396,7 @@ export class LightClientServer {
400
396
 
401
397
  private async persistPostBlockImportData(
402
398
  block: BeaconBlock<ForkPostAltair>,
403
- postState: IBeaconStateViewAltair,
399
+ postState: IBeaconStateView,
404
400
  parentBlockSlot: Slot
405
401
  ): Promise<void> {
406
402
  const blockSlot = block.slot;
@@ -26,8 +26,6 @@ import {
26
26
  computeSlotsSinceEpochStart,
27
27
  computeStartSlotAtEpoch,
28
28
  getAttestationParticipationStatus,
29
- isStatePostAltair,
30
- isStatePostGloas,
31
29
  } from "@lodestar/state-transition";
32
30
  import {Attestation, Epoch, RootHex, Slot, electra, isElectraAttestation, phase0, ssz} from "@lodestar/types";
33
31
  import {MapDef, assert, toRootHex} from "@lodestar/utils";
@@ -361,7 +359,7 @@ export class AggregatedAttestationPool {
361
359
  inclusionDistance,
362
360
  stateEpoch,
363
361
  rootCache,
364
- isStatePostGloas(state) ? state.executionPayloadAvailability : null
362
+ ForkSeq[fork] >= ForkSeq.gloas ? state.executionPayloadAvailability : null
365
363
  );
366
364
 
367
365
  const weight =
@@ -744,9 +742,6 @@ export function getNotSeenValidatorsFn(
744
742
  if (config.getForkName(stateSlot) === ForkName.phase0) {
745
743
  throw new Error("getNotSeenValidatorsFn is not supported phase0 state");
746
744
  }
747
- if (!isStatePostAltair(state)) {
748
- throw new Error("Expected Altair state for participation tracking");
749
- }
750
745
 
751
746
  // altair and future forks
752
747
  // Get attestations to be included in an altair block.
@@ -59,13 +59,13 @@ export class ExecutionPayloadBidPool {
59
59
  }
60
60
 
61
61
  /**
62
- * Return the highest-value bid matching slot, parent block hash, and parent block root.
62
+ * Return the highest-value bid matching slot, parent block root, and parent block hash.
63
63
  * Used for gossip validation and block production.
64
64
  */
65
65
  getBestBid(
66
- slot: Slot,
66
+ parentBlockRoot: BlockRootHex,
67
67
  parentBlockHash: BlockHashHex,
68
- parentBlockRoot: BlockRootHex
68
+ slot: Slot
69
69
  ): gloas.ExecutionPayloadBid | null {
70
70
  const bidByParentHash = this.bidByParentHashByParentRootBySlot.get(slot)?.get(parentBlockRoot);
71
71
  return bidByParentHash?.get(parentBlockHash) ?? null;
@@ -7,7 +7,6 @@ import {
7
7
  StateHashTreeRootSource,
8
8
  computeEpochAtSlot,
9
9
  computeTimeAtSlot,
10
- isStatePostBellatrix,
11
10
  } from "@lodestar/state-transition";
12
11
  import {Slot} from "@lodestar/types";
13
12
  import {Logger, fromHex, isErrorAborted, sleep} from "@lodestar/utils";
@@ -160,9 +159,6 @@ export class PrepareNextSlotScheduler {
160
159
  const preparationTime =
161
160
  computeTimeAtSlot(this.config, prepareSlot, this.chain.genesisTime) - Date.now() / 1000;
162
161
  this.metrics?.blockPayload.payloadAdvancePrepTime.observe(preparationTime);
163
- if (!isStatePostBellatrix(updatedPrepareState)) {
164
- throw new Error("Expected Bellatrix state for payload preparation");
165
- }
166
162
 
167
163
  const safeBlockHash = getSafeExecutionBlockHash(this.chain.forkChoice);
168
164
  const finalizedBlockHash =
@@ -187,10 +183,6 @@ export class PrepareNextSlotScheduler {
187
183
  });
188
184
  }
189
185
 
190
- if (!isStatePostBellatrix(updatedPrepareState)) {
191
- throw new Error("Expected Bellatrix state for payload attributes");
192
- }
193
-
194
186
  this.computeStateHashTreeRoot(updatedPrepareState, isEpochTransition);
195
187
 
196
188
  // If emitPayloadAttributes is true emit a SSE payloadAttributes event
@@ -3,7 +3,6 @@ import {
3
3
  ExecutionPayloadStatus,
4
4
  G2_POINT_AT_INFINITY,
5
5
  IBeaconStateView,
6
- IBeaconStateViewGloas,
7
6
  StateHashTreeRootSource,
8
7
  } from "@lodestar/state-transition";
9
8
  import {BeaconBlock, BlindedBeaconBlock, Gwei, Root, gloas} from "@lodestar/types";
@@ -61,7 +60,7 @@ export function computeNewStateRoot(
61
60
  */
62
61
  export function computeEnvelopeStateRoot(
63
62
  metrics: Metrics | null,
64
- postBlockState: IBeaconStateViewGloas,
63
+ postBlockState: IBeaconStateView,
65
64
  envelope: gloas.ExecutionPayloadEnvelope
66
65
  ): Root {
67
66
  const signedEnvelope: gloas.SignedExecutionPayloadEnvelope = {
@@ -14,15 +14,7 @@ import {
14
14
  isForkPostBellatrix,
15
15
  isForkPostGloas,
16
16
  } from "@lodestar/params";
17
- import {
18
- G2_POINT_AT_INFINITY,
19
- IBeaconStateView,
20
- type IBeaconStateViewBellatrix,
21
- computeTimeAtSlot,
22
- isStatePostBellatrix,
23
- isStatePostCapella,
24
- isStatePostGloas,
25
- } from "@lodestar/state-transition";
17
+ import {G2_POINT_AT_INFINITY, IBeaconStateView, computeTimeAtSlot} from "@lodestar/state-transition";
26
18
  import {
27
19
  BLSPubkey,
28
20
  BLSSignature,
@@ -199,10 +191,6 @@ export async function produceBlockBody<T extends BlockType>(
199
191
  this.logger.verbose("Producing beacon block body", logMeta);
200
192
 
201
193
  if (isForkPostGloas(fork)) {
202
- if (!isStatePostGloas(currentState)) {
203
- throw new Error("Expected Gloas state for Gloas block production");
204
- }
205
-
206
194
  // TODO GLOAS: support non self-building here, the block type differentiation between
207
195
  // full and blinded no longer makes sense in gloas, it might be a good idea to move
208
196
  // this into a completely separate function and have pre/post gloas more separated
@@ -309,10 +297,6 @@ export async function produceBlockBody<T extends BlockType>(
309
297
  shouldOverrideBuilder,
310
298
  });
311
299
  } else if (isForkPostBellatrix(fork)) {
312
- if (!isStatePostBellatrix(currentState)) {
313
- throw new Error("Expected Bellatrix state for execution block production");
314
- }
315
-
316
300
  const safeBlockHash = getSafeExecutionBlockHash(this.forkChoice);
317
301
  const finalizedBlockHash = this.forkChoice.getFinalizedBlock().executionPayloadBlockHash ?? ZERO_HASH_HEX;
318
302
  const feeRecipient = requestedFeeRecipient ?? this.beaconProposerCache.getOrDefault(proposerIndex);
@@ -614,7 +598,7 @@ export async function prepareExecutionPayload(
614
598
  parentBlockRoot: Root,
615
599
  safeBlockHash: RootHex,
616
600
  finalizedBlockHash: RootHex,
617
- state: IBeaconStateViewBellatrix,
601
+ state: IBeaconStateView,
618
602
  suggestedFeeRecipient: string
619
603
  ): Promise<{prepType: PayloadPreparationType; payloadId: PayloadId}> {
620
604
  const parentHash = state.latestBlockHash;
@@ -682,7 +666,7 @@ async function prepareExecutionPayloadHeader(
682
666
  config: ChainForkConfig;
683
667
  },
684
668
  fork: ForkPostBellatrix,
685
- state: IBeaconStateViewBellatrix,
669
+ state: IBeaconStateView,
686
670
  proposerPubKey: BLSPubkey
687
671
  ): Promise<{
688
672
  header: ExecutionPayloadHeader;
@@ -709,7 +693,7 @@ export function getPayloadAttributesForSSE(
709
693
  prepareSlot,
710
694
  parentBlockRoot,
711
695
  feeRecipient,
712
- }: {prepareState: IBeaconStateViewBellatrix; prepareSlot: Slot; parentBlockRoot: Root; feeRecipient: string}
696
+ }: {prepareState: IBeaconStateView; prepareSlot: Slot; parentBlockRoot: Root; feeRecipient: string}
713
697
  ): SSEPayloadAttributes {
714
698
  const parentHash = prepareState.latestBlockHash;
715
699
  const payloadAttributes = preparePayloadAttributes(fork, chain, {
@@ -752,7 +736,7 @@ function preparePayloadAttributes(
752
736
  parentBlockRoot,
753
737
  feeRecipient,
754
738
  }: {
755
- prepareState: IBeaconStateViewBellatrix;
739
+ prepareState: IBeaconStateView;
756
740
  prepareSlot: Slot;
757
741
  parentBlockRoot: Root;
758
742
  feeRecipient: string;
@@ -767,10 +751,6 @@ function preparePayloadAttributes(
767
751
  };
768
752
 
769
753
  if (ForkSeq[fork] >= ForkSeq.capella) {
770
- if (!isStatePostCapella(prepareState)) {
771
- throw new Error("Expected Capella state for withdrawals");
772
- }
773
-
774
754
  // withdrawals logic is now fork aware as it changes on electra fork post capella
775
755
  (payloadAttributes as capella.SSEPayloadAttributes["payloadAttributes"]).withdrawals =
776
756
  prepareState.getExpectedWithdrawals().expectedWithdrawals;
@@ -6,7 +6,6 @@ import {
6
6
  computeTimeAtSlot,
7
7
  getBlockProposerSignatureSet,
8
8
  isExecutionBlockBodyType,
9
- isStatePostBellatrix,
10
9
  } from "@lodestar/state-transition";
11
10
  import {SignedBeaconBlock, deneb, gloas, isGloasBeaconBlock} from "@lodestar/types";
12
11
  import {byteArrayEquals, sleep, toRootHex} from "@lodestar/utils";
@@ -175,7 +174,7 @@ export async function validateGossipBlock(
175
174
  if (isForkPostBellatrix(fork) && !isForkPostGloas(fork)) {
176
175
  if (!isExecutionBlockBodyType(block.body)) throw Error("Not execution block body type");
177
176
  const executionPayload = block.body.executionPayload;
178
- if (isStatePostBellatrix(blockState) && blockState.isExecutionStateType && blockState.isExecutionEnabled(block)) {
177
+ if (blockState.isExecutionStateType && blockState.isExecutionEnabled(block)) {
179
178
  const expectedTimestamp = computeTimeAtSlot(config, blockSlot, chain.genesisTime);
180
179
  if (executionPayload.timestamp !== computeTimeAtSlot(config, blockSlot, chain.genesisTime)) {
181
180
  throw new BlockGossipError(GossipAction.REJECT, {
@@ -3,7 +3,6 @@ import {
3
3
  createSingleSignatureSetFromComponents,
4
4
  getExecutionPayloadBidSigningRoot,
5
5
  isActiveBuilder,
6
- isStatePostGloas,
7
6
  } from "@lodestar/state-transition";
8
7
  import {gloas} from "@lodestar/types";
9
8
  import {toRootHex} from "@lodestar/utils";
@@ -33,9 +32,6 @@ async function validateExecutionPayloadBid(
33
32
  const parentBlockRootHex = toRootHex(bid.parentBlockRoot);
34
33
  const parentBlockHashHex = toRootHex(bid.parentBlockHash);
35
34
  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
- }
39
35
 
40
36
  // [IGNORE] `bid.slot` is the current slot or the next slot.
41
37
  const currentSlot = chain.clock.currentSlot;
@@ -87,9 +83,9 @@ async function validateExecutionPayloadBid(
87
83
  });
88
84
  }
89
85
 
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);
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);
93
89
  if (bestBid !== null && bestBid.value >= bid.value) {
94
90
  throw new ExecutionPayloadBidError(GossipAction.IGNORE, {
95
91
  code: ExecutionPayloadBidErrorCode.BID_TOO_LOW,
@@ -1,9 +1,5 @@
1
1
  import {PayloadStatus} from "@lodestar/fork-choice";
2
- import {
3
- computeStartSlotAtEpoch,
4
- getExecutionPayloadEnvelopeSignatureSet,
5
- isStatePostGloas,
6
- } from "@lodestar/state-transition";
2
+ import {computeStartSlotAtEpoch, getExecutionPayloadEnvelopeSignatureSet} from "@lodestar/state-transition";
7
3
  import {gloas} from "@lodestar/types";
8
4
  import {toRootHex} from "@lodestar/utils";
9
5
  import {ExecutionPayloadEnvelopeError, ExecutionPayloadEnvelopeErrorCode, GossipAction} from "../errors/index.js";
@@ -117,9 +113,6 @@ async function validateExecutionPayloadEnvelope(
117
113
  slot: envelope.slot,
118
114
  });
119
115
  });
120
- if (!isStatePostGloas(blockState)) {
121
- throw new Error(`Expected gloas+ state for execution payload envelope validation, got fork=${blockState.forkName}`);
122
- }
123
116
 
124
117
  const signatureSet = getExecutionPayloadEnvelopeSignatureSet(
125
118
  chain.config,
@@ -2,7 +2,6 @@ import {
2
2
  computeEpochAtSlot,
3
3
  createSingleSignatureSetFromComponents,
4
4
  getPayloadAttestationDataSigningRoot,
5
- isStatePostGloas,
6
5
  } from "@lodestar/state-transition";
7
6
  import {RootHex, gloas, ssz} from "@lodestar/types";
8
7
  import {toRootHex} from "@lodestar/utils";
@@ -67,9 +66,6 @@ async function validatePayloadAttestationMessage(
67
66
  }
68
67
 
69
68
  const state = chain.getHeadState();
70
- if (!isStatePostGloas(state)) {
71
- throw new Error(`Expected gloas+ state for payload attestation validation, got fork=${state.forkName}`);
72
- }
73
69
 
74
70
  // [REJECT] The message's block `data.beacon_block_root` passes validation.
75
71
  // TODO GLOAS: implement this. Technically if we cannot get proto block from fork choice,