@lodestar/state-transition 1.46.0-dev.b3cb0f603b → 1.46.0-dev.b9d4e89e49

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 (257) hide show
  1. package/lib/block/externalData.js +2 -4
  2. package/lib/block/externalData.js.map +1 -1
  3. package/lib/block/index.d.ts.map +1 -1
  4. package/lib/block/index.js +3 -2
  5. package/lib/block/index.js.map +1 -1
  6. package/lib/block/initiateValidatorExit.js.map +1 -1
  7. package/lib/block/isValidIndexedAttestation.js.map +1 -1
  8. package/lib/block/isValidIndexedPayloadAttestation.js.map +1 -1
  9. package/lib/block/processAttestationPhase0.js.map +1 -1
  10. package/lib/block/processAttestations.d.ts +2 -2
  11. package/lib/block/processAttestations.d.ts.map +1 -1
  12. package/lib/block/processAttestations.js +2 -2
  13. package/lib/block/processAttestations.js.map +1 -1
  14. package/lib/block/processAttestationsAltair.d.ts +3 -3
  15. package/lib/block/processAttestationsAltair.d.ts.map +1 -1
  16. package/lib/block/processAttestationsAltair.js +7 -4
  17. package/lib/block/processAttestationsAltair.js.map +1 -1
  18. package/lib/block/processAttesterSlashing.js.map +1 -1
  19. package/lib/block/processBlobKzgCommitments.js.map +1 -1
  20. package/lib/block/processBlockHeader.js.map +1 -1
  21. package/lib/block/processBlsToExecutionChange.js.map +1 -1
  22. package/lib/block/processBuilderDepositRequest.js.map +1 -1
  23. package/lib/block/processBuilderExitRequest.js.map +1 -1
  24. package/lib/block/processConsolidationRequest.js.map +1 -1
  25. package/lib/block/processDeposit.js.map +1 -1
  26. package/lib/block/processDepositRequest.js.map +1 -1
  27. package/lib/block/processEth1Data.js.map +1 -1
  28. package/lib/block/processExecutionPayload.js.map +1 -1
  29. package/lib/block/processExecutionPayloadBid.d.ts +3 -3
  30. package/lib/block/processExecutionPayloadBid.d.ts.map +1 -1
  31. package/lib/block/processExecutionPayloadBid.js +10 -3
  32. package/lib/block/processExecutionPayloadBid.js.map +1 -1
  33. package/lib/block/processOperations.d.ts +2 -2
  34. package/lib/block/processOperations.d.ts.map +1 -1
  35. package/lib/block/processOperations.js +2 -2
  36. package/lib/block/processOperations.js.map +1 -1
  37. package/lib/block/processParentExecutionPayload.js.map +1 -1
  38. package/lib/block/processPayloadAttestation.js.map +1 -1
  39. package/lib/block/processProposerSlashing.js.map +1 -1
  40. package/lib/block/processRandao.js.map +1 -1
  41. package/lib/block/processSyncCommittee.js.map +1 -1
  42. package/lib/block/processVoluntaryExit.js +1 -2
  43. package/lib/block/processVoluntaryExit.js.map +1 -1
  44. package/lib/block/processWithdrawalRequest.d.ts.map +1 -1
  45. package/lib/block/processWithdrawalRequest.js +2 -2
  46. package/lib/block/processWithdrawalRequest.js.map +1 -1
  47. package/lib/block/processWithdrawals.js.map +1 -1
  48. package/lib/block/slashValidator.js.map +1 -1
  49. package/lib/block/types.js +1 -2
  50. package/lib/block/types.js.map +1 -1
  51. package/lib/cache/effectiveBalanceIncrements.js.map +1 -1
  52. package/lib/cache/epochCache.js +1 -2
  53. package/lib/cache/epochCache.js.map +1 -1
  54. package/lib/cache/epochTransitionCache.js.map +1 -1
  55. package/lib/cache/pubkeyCache.js.map +1 -1
  56. package/lib/cache/rewardCache.js.map +1 -1
  57. package/lib/cache/stateCache.d.ts +2 -1
  58. package/lib/cache/stateCache.d.ts.map +1 -1
  59. package/lib/cache/stateCache.js +3 -2
  60. package/lib/cache/stateCache.js.map +1 -1
  61. package/lib/cache/syncCommitteeCache.js.map +1 -1
  62. package/lib/cache/types.d.ts +1 -0
  63. package/lib/cache/types.d.ts.map +1 -1
  64. package/lib/epoch/computeUnrealizedCheckpoints.js.map +1 -1
  65. package/lib/epoch/getAttestationDeltas.js.map +1 -1
  66. package/lib/epoch/getRewardsAndPenalties.js.map +1 -1
  67. package/lib/epoch/index.js +1 -2
  68. package/lib/epoch/index.js.map +1 -1
  69. package/lib/epoch/processBuilderPendingPayments.js.map +1 -1
  70. package/lib/epoch/processEffectiveBalanceUpdates.js.map +1 -1
  71. package/lib/epoch/processEth1DataReset.js.map +1 -1
  72. package/lib/epoch/processHistoricalRootsUpdate.js.map +1 -1
  73. package/lib/epoch/processHistoricalSummariesUpdate.js.map +1 -1
  74. package/lib/epoch/processInactivityUpdates.js.map +1 -1
  75. package/lib/epoch/processJustificationAndFinalization.js.map +1 -1
  76. package/lib/epoch/processParticipationFlagUpdates.js.map +1 -1
  77. package/lib/epoch/processParticipationRecordUpdates.js.map +1 -1
  78. package/lib/epoch/processPendingAttestations.js.map +1 -1
  79. package/lib/epoch/processPendingConsolidations.js.map +1 -1
  80. package/lib/epoch/processPendingDeposits.js.map +1 -1
  81. package/lib/epoch/processProposerLookahead.js.map +1 -1
  82. package/lib/epoch/processPtcWindow.js.map +1 -1
  83. package/lib/epoch/processRandaoMixesReset.js.map +1 -1
  84. package/lib/epoch/processRegistryUpdates.js.map +1 -1
  85. package/lib/epoch/processRewardsAndPenalties.js.map +1 -1
  86. package/lib/epoch/processSlashings.js.map +1 -1
  87. package/lib/epoch/processSlashingsReset.js.map +1 -1
  88. package/lib/epoch/processSyncCommitteeUpdates.js.map +1 -1
  89. package/lib/index.d.ts +2 -2
  90. package/lib/index.d.ts.map +1 -1
  91. package/lib/index.js +1 -1
  92. package/lib/index.js.map +1 -1
  93. package/lib/lightClient/proofs.js.map +1 -1
  94. package/lib/lightClient/spec/index.js.map +1 -1
  95. package/lib/lightClient/spec/isBetterUpdate.js.map +1 -1
  96. package/lib/lightClient/spec/processLightClientUpdate.js.map +1 -1
  97. package/lib/lightClient/spec/store.js.map +1 -1
  98. package/lib/lightClient/spec/utils.d.ts +0 -2
  99. package/lib/lightClient/spec/utils.d.ts.map +1 -1
  100. package/lib/lightClient/spec/utils.js +8 -2
  101. package/lib/lightClient/spec/utils.js.map +1 -1
  102. package/lib/lightClient/spec/validateLightClientBootstrap.js.map +1 -1
  103. package/lib/lightClient/spec/validateLightClientUpdate.js.map +1 -1
  104. package/lib/metrics.d.ts.map +1 -1
  105. package/lib/metrics.js +3 -2
  106. package/lib/metrics.js.map +1 -1
  107. package/lib/rewards/attestationsRewards.js.map +1 -1
  108. package/lib/rewards/blockRewards.d.ts.map +1 -1
  109. package/lib/rewards/blockRewards.js +7 -4
  110. package/lib/rewards/blockRewards.js.map +1 -1
  111. package/lib/rewards/syncCommitteeRewards.js.map +1 -1
  112. package/lib/signatureSets/attesterSlashings.js.map +1 -1
  113. package/lib/signatureSets/blsToExecutionChange.js.map +1 -1
  114. package/lib/signatureSets/executionPayloadBid.d.ts +2 -2
  115. package/lib/signatureSets/executionPayloadBid.d.ts.map +1 -1
  116. package/lib/signatureSets/executionPayloadBid.js +7 -5
  117. package/lib/signatureSets/executionPayloadBid.js.map +1 -1
  118. package/lib/signatureSets/executionPayloadEnvelope.js.map +1 -1
  119. package/lib/signatureSets/index.js.map +1 -1
  120. package/lib/signatureSets/indexedAttestation.js.map +1 -1
  121. package/lib/signatureSets/indexedPayloadAttestation.js.map +1 -1
  122. package/lib/signatureSets/proposer.js.map +1 -1
  123. package/lib/signatureSets/proposerPreferences.js.map +1 -1
  124. package/lib/signatureSets/proposerSlashings.js.map +1 -1
  125. package/lib/signatureSets/randao.js.map +1 -1
  126. package/lib/signatureSets/voluntaryExits.js.map +1 -1
  127. package/lib/slot/index.d.ts +1 -0
  128. package/lib/slot/index.d.ts.map +1 -1
  129. package/lib/slot/index.js +1 -0
  130. package/lib/slot/index.js.map +1 -1
  131. package/lib/slot/upgradeStateToAltair.js +1 -1
  132. package/lib/slot/upgradeStateToAltair.js.map +1 -1
  133. package/lib/slot/upgradeStateToBellatrix.js.map +1 -1
  134. package/lib/slot/upgradeStateToCapella.js.map +1 -1
  135. package/lib/slot/upgradeStateToDeneb.js.map +1 -1
  136. package/lib/slot/upgradeStateToElectra.js.map +1 -1
  137. package/lib/slot/upgradeStateToFulu.js.map +1 -1
  138. package/lib/slot/upgradeStateToGloas.js +1 -1
  139. package/lib/slot/upgradeStateToGloas.js.map +1 -1
  140. package/lib/slot/upgradeStateToHeze.d.ts +7 -0
  141. package/lib/slot/upgradeStateToHeze.d.ts.map +1 -0
  142. package/lib/slot/upgradeStateToHeze.js +83 -0
  143. package/lib/slot/upgradeStateToHeze.js.map +1 -0
  144. package/lib/stateTransition.d.ts.map +1 -1
  145. package/lib/stateTransition.js +6 -5
  146. package/lib/stateTransition.js.map +1 -1
  147. package/lib/stateView/beaconStateView.js.map +1 -1
  148. package/lib/stateView/interface.d.ts +8 -3
  149. package/lib/stateView/interface.d.ts.map +1 -1
  150. package/lib/stateView/interface.js +4 -1
  151. package/lib/stateView/interface.js.map +1 -1
  152. package/lib/stateView/nativeBeaconStateView.js.map +1 -1
  153. package/lib/stateView/stateViewFactory.js.map +1 -1
  154. package/lib/testUtils/infura.js.map +1 -1
  155. package/lib/testUtils/interop.js.map +1 -1
  156. package/lib/testUtils/params.d.ts.map +1 -1
  157. package/lib/testUtils/state.js +1 -1
  158. package/lib/testUtils/state.js.map +1 -1
  159. package/lib/testUtils/testFileCache.js.map +1 -1
  160. package/lib/testUtils/util.d.ts +1 -1
  161. package/lib/testUtils/util.d.ts.map +1 -1
  162. package/lib/testUtils/util.js +2 -2
  163. package/lib/testUtils/util.js.map +1 -1
  164. package/lib/types.d.ts +2 -2
  165. package/lib/types.d.ts.map +1 -1
  166. package/lib/util/aggregator.js.map +1 -1
  167. package/lib/util/altair.js.map +1 -1
  168. package/lib/util/array.js.map +1 -1
  169. package/lib/util/attestation.js.map +1 -1
  170. package/lib/util/attesterStatus.js.map +1 -1
  171. package/lib/util/balance.js.map +1 -1
  172. package/lib/util/blindedBlock.js.map +1 -1
  173. package/lib/util/blockRoot.js.map +1 -1
  174. package/lib/util/capella.js.map +1 -1
  175. package/lib/util/clock.d.ts +6 -0
  176. package/lib/util/clock.d.ts.map +1 -1
  177. package/lib/util/clock.js +1 -2
  178. package/lib/util/clock.js.map +1 -1
  179. package/lib/util/computeAnchorCheckpoint.js.map +1 -1
  180. package/lib/util/deposit.d.ts.map +1 -1
  181. package/lib/util/deposit.js +10 -8
  182. package/lib/util/deposit.js.map +1 -1
  183. package/lib/util/domain.js.map +1 -1
  184. package/lib/util/electra.js.map +1 -1
  185. package/lib/util/epoch.js.map +1 -1
  186. package/lib/util/epochShuffling.js.map +1 -1
  187. package/lib/util/execution.js.map +1 -1
  188. package/lib/util/finality.js.map +1 -1
  189. package/lib/util/fulu.js.map +1 -1
  190. package/lib/util/genesis.d.ts.map +1 -1
  191. package/lib/util/genesis.js +7 -2
  192. package/lib/util/genesis.js.map +1 -1
  193. package/lib/util/gloas.d.ts +2 -1
  194. package/lib/util/gloas.d.ts.map +1 -1
  195. package/lib/util/gloas.js +7 -4
  196. package/lib/util/gloas.js.map +1 -1
  197. package/lib/util/interop.js.map +1 -1
  198. package/lib/util/loadState/findModifiedInactivityScores.js.map +1 -1
  199. package/lib/util/loadState/findModifiedValidators.js.map +1 -1
  200. package/lib/util/loadState/loadState.d.ts.map +1 -1
  201. package/lib/util/loadState/loadState.js +36 -5
  202. package/lib/util/loadState/loadState.js.map +1 -1
  203. package/lib/util/loadState/loadValidator.js.map +1 -1
  204. package/lib/util/pendingDepositsLookup.js.map +1 -1
  205. package/lib/util/rootCache.js.map +1 -1
  206. package/lib/util/seed.js.map +1 -1
  207. package/lib/util/shuffling.js +1 -2
  208. package/lib/util/shuffling.js.map +1 -1
  209. package/lib/util/signatureSets.js +1 -2
  210. package/lib/util/signatureSets.js.map +1 -1
  211. package/lib/util/signingRoot.js.map +1 -1
  212. package/lib/util/slot.js.map +1 -1
  213. package/lib/util/ssz.d.ts +5 -0
  214. package/lib/util/ssz.d.ts.map +1 -1
  215. package/lib/util/ssz.js +8 -1
  216. package/lib/util/ssz.js.map +1 -1
  217. package/lib/util/sszBytes.js.map +1 -1
  218. package/lib/util/syncCommittee.js.map +1 -1
  219. package/lib/util/targetUnslashedBalance.js.map +1 -1
  220. package/lib/util/validator.d.ts +5 -0
  221. package/lib/util/validator.d.ts.map +1 -1
  222. package/lib/util/validator.js +9 -0
  223. package/lib/util/validator.js.map +1 -1
  224. package/lib/util/weakSubjectivity.d.ts +1 -0
  225. package/lib/util/weakSubjectivity.d.ts.map +1 -1
  226. package/lib/util/weakSubjectivity.js +20 -8
  227. package/lib/util/weakSubjectivity.js.map +1 -1
  228. package/package.json +9 -9
  229. package/src/block/index.ts +4 -3
  230. package/src/block/processAttestations.ts +10 -2
  231. package/src/block/processAttestationsAltair.ts +10 -4
  232. package/src/block/processExecutionPayloadBid.ts +22 -9
  233. package/src/block/processOperations.ts +3 -2
  234. package/src/block/processWithdrawalRequest.ts +6 -2
  235. package/src/cache/stateCache.ts +5 -2
  236. package/src/cache/types.ts +1 -0
  237. package/src/index.ts +4 -0
  238. package/src/lightClient/spec/utils.ts +9 -2
  239. package/src/metrics.ts +3 -2
  240. package/src/rewards/blockRewards.ts +20 -5
  241. package/src/signatureSets/executionPayloadBid.ts +7 -9
  242. package/src/slot/index.ts +1 -0
  243. package/src/slot/upgradeStateToAltair.ts +1 -0
  244. package/src/slot/upgradeStateToGloas.ts +1 -1
  245. package/src/slot/upgradeStateToHeze.ts +91 -0
  246. package/src/stateTransition.ts +5 -0
  247. package/src/stateView/interface.ts +13 -2
  248. package/src/testUtils/state.ts +1 -1
  249. package/src/testUtils/util.ts +2 -2
  250. package/src/types.ts +2 -0
  251. package/src/util/deposit.ts +11 -9
  252. package/src/util/genesis.ts +8 -2
  253. package/src/util/gloas.ts +9 -5
  254. package/src/util/loadState/loadState.ts +50 -11
  255. package/src/util/ssz.ts +9 -1
  256. package/src/util/validator.ts +17 -0
  257. package/src/util/weakSubjectivity.ts +61 -22
@@ -1,5 +1,5 @@
1
1
  import {ForkPostGloas, ForkSeq} from "@lodestar/params";
2
- import {BeaconBlock, BlindedBeaconBlock, altair, capella} from "@lodestar/types";
2
+ import {BeaconBlock, BlindedBeaconBlock, Slot, altair, capella} from "@lodestar/types";
3
3
  import {BeaconStateTransitionMetrics} from "../metrics.js";
4
4
  import {
5
5
  CachedBeaconStateAllForks,
@@ -86,8 +86,9 @@ export function processBlock(
86
86
  processExecutionPayload(fork, state as CachedBeaconStateBellatrix, block.body, externalData);
87
87
  }
88
88
 
89
+ let parentSlot: Slot | null = null;
89
90
  if (fork >= ForkSeq.gloas) {
90
- processExecutionPayloadBid(
91
+ parentSlot = processExecutionPayloadBid(
91
92
  state as CachedBeaconStateGloas,
92
93
  (block as BeaconBlock<ForkPostGloas>).body.signedExecutionPayloadBid
93
94
  );
@@ -95,7 +96,7 @@ export function processBlock(
95
96
 
96
97
  processRandao(state, block, verifySignatures);
97
98
  processEth1Data(state, block.body.eth1Data);
98
- processOperations(fork, state, block.body, opts, metrics);
99
+ processOperations(fork, state, block.body, parentSlot, opts, metrics);
99
100
  if (fork >= ForkSeq.altair) {
100
101
  processSyncAggregate(state, block as altair.BeaconBlock, verifySignatures);
101
102
  }
@@ -1,5 +1,5 @@
1
1
  import {ForkSeq} from "@lodestar/params";
2
- import {Attestation} from "@lodestar/types";
2
+ import {Attestation, Slot} from "@lodestar/types";
3
3
  import {BeaconStateTransitionMetrics} from "../metrics.js";
4
4
  import {CachedBeaconStateAllForks, CachedBeaconStateAltair, CachedBeaconStatePhase0} from "../types.js";
5
5
  import {processAttestationPhase0} from "./processAttestationPhase0.js";
@@ -12,6 +12,7 @@ export function processAttestations(
12
12
  fork: ForkSeq,
13
13
  state: CachedBeaconStateAllForks,
14
14
  attestations: Attestation[],
15
+ parentSlot: Slot | null,
15
16
  verifySignatures = true,
16
17
  metrics?: BeaconStateTransitionMetrics | null
17
18
  ): void {
@@ -20,6 +21,13 @@ export function processAttestations(
20
21
  processAttestationPhase0(state as CachedBeaconStatePhase0, attestation, verifySignatures);
21
22
  }
22
23
  } else {
23
- processAttestationsAltair(fork, state as CachedBeaconStateAltair, attestations, verifySignatures, metrics);
24
+ processAttestationsAltair(
25
+ fork,
26
+ state as CachedBeaconStateAltair,
27
+ attestations,
28
+ parentSlot,
29
+ verifySignatures,
30
+ metrics
31
+ );
24
32
  }
25
33
  }
@@ -14,7 +14,7 @@ import {
14
14
  TIMELY_TARGET_WEIGHT,
15
15
  WEIGHT_DENOMINATOR,
16
16
  } from "@lodestar/params";
17
- import {Attestation, Epoch, phase0} from "@lodestar/types";
17
+ import {Attestation, Epoch, Slot, phase0} from "@lodestar/types";
18
18
  import {byteArrayEquals, intSqrt} from "@lodestar/utils";
19
19
  import {BeaconStateTransitionMetrics} from "../metrics.js";
20
20
  import {getAttestationWithIndicesSignatureSet} from "../signatureSets/indexedAttestation.js";
@@ -37,6 +37,7 @@ export function processAttestationsAltair(
37
37
  fork: ForkSeq,
38
38
  state: CachedBeaconStateAltair | CachedBeaconStateGloas,
39
39
  attestations: Attestation[],
40
+ parentSlot: Slot | null,
40
41
  verifySignature = true,
41
42
  metrics?: BeaconStateTransitionMetrics | null
42
43
  ): void {
@@ -82,7 +83,8 @@ export function processAttestationsAltair(
82
83
  stateSlot - data.slot,
83
84
  epochCtx.epoch,
84
85
  rootCache,
85
- fork >= ForkSeq.gloas ? (state as CachedBeaconStateGloas).executionPayloadAvailability : null
86
+ fork >= ForkSeq.gloas ? (state as CachedBeaconStateGloas).executionPayloadAvailability : null,
87
+ parentSlot
86
88
  );
87
89
 
88
90
  // For each participant, update their participation
@@ -179,7 +181,8 @@ export function getAttestationParticipationStatus(
179
181
  inclusionDelay: number,
180
182
  currentEpoch: Epoch,
181
183
  rootCache: RootCache,
182
- executionPayloadAvailability: BitArray | null
184
+ executionPayloadAvailability: BitArray | null,
185
+ parentSlot: Slot | null
183
186
  ): {flags: number; isSameSlotAttestation: boolean} {
184
187
  const justifiedCheckpoint =
185
188
  data.target.epoch === currentEpoch ? rootCache.currentJustifiedCheckpoint : rootCache.previousJustifiedCheckpoint;
@@ -221,13 +224,16 @@ export function getAttestationParticipationStatus(
221
224
  if (executionPayloadAvailability === null) {
222
225
  throw new Error("Must supply executionPayloadAvailability post-gloas");
223
226
  }
227
+ if (parentSlot === null) {
228
+ throw new Error("Must supply parentSlot post-gloas");
229
+ }
224
230
 
225
231
  if (data.index !== 0 && data.index !== 1) {
226
232
  throw new Error(`data index must be 0 or 1 index=${data.index}`);
227
233
  }
228
234
 
229
235
  isMatchingPayload =
230
- Boolean(data.index) === executionPayloadAvailability.get(data.slot % SLOTS_PER_HISTORICAL_ROOT);
236
+ Boolean(data.index) === executionPayloadAvailability.get(parentSlot % SLOTS_PER_HISTORICAL_ROOT);
231
237
  }
232
238
 
233
239
  isMatchingHead = isMatchingHead && isMatchingPayload;
@@ -1,17 +1,23 @@
1
1
  import {PublicKey, Signature, verify} from "@chainsafe/blst";
2
- import {BUILDER_INDEX_SELF_BUILD, GENESIS_SLOT, PAYLOAD_BUILDER_VERSION, SLOTS_PER_EPOCH} from "@lodestar/params";
3
- import {gloas, ssz} from "@lodestar/types";
2
+ import {
3
+ BUILDER_INDEX_SELF_BUILD,
4
+ ForkSeq,
5
+ GENESIS_SLOT,
6
+ PAYLOAD_BUILDER_VERSION,
7
+ SLOTS_PER_EPOCH,
8
+ } from "@lodestar/params";
9
+ import {Slot, gloas, heze, ssz} from "@lodestar/types";
4
10
  import {byteArrayEquals, toHex, toRootHex} from "@lodestar/utils";
5
11
  import {G2_POINT_AT_INFINITY} from "../constants/constants.js";
6
12
  import {getExecutionPayloadBidSigningRoot} from "../signatureSets/executionPayloadBid.js";
7
- import {CachedBeaconStateGloas} from "../types.js";
13
+ import {CachedBeaconStateGloas, CachedBeaconStateHeze} from "../types.js";
8
14
  import {canBuilderCoverBid, isActiveBuilder} from "../util/gloas.js";
9
15
  import {getBlockRootAtSlot, getCurrentEpoch, getRandaoMix} from "../util/index.js";
10
16
 
11
17
  export function processExecutionPayloadBid(
12
- state: CachedBeaconStateGloas,
18
+ state: CachedBeaconStateGloas | CachedBeaconStateHeze,
13
19
  signedBid: gloas.SignedExecutionPayloadBid
14
- ): void {
20
+ ): Slot {
15
21
  const bid = signedBid.message;
16
22
  const {builderIndex, value: amount} = bid;
17
23
 
@@ -41,7 +47,7 @@ export function processExecutionPayloadBid(
41
47
  }
42
48
 
43
49
  // Verify that the builder has funds to cover the bid
44
- if (!canBuilderCoverBid(state, builderIndex, amount)) {
50
+ if (!canBuilderCoverBid(state as CachedBeaconStateGloas, builderIndex, amount)) {
45
51
  throw Error(`Invalid execution payload bid: builder ${builderIndex} has insufficient balance`);
46
52
  }
47
53
 
@@ -99,15 +105,22 @@ export function processExecutionPayloadBid(
99
105
  state.builderPendingPayments.set(SLOTS_PER_EPOCH + (bid.slot % SLOTS_PER_EPOCH), pendingPaymentView);
100
106
  }
101
107
 
102
- state.latestExecutionPayloadBid = ssz.gloas.ExecutionPayloadBid.toViewDU(bid);
108
+ const parentSlot = state.latestExecutionPayloadBid.slot;
109
+ if (state.config.getForkSeq(state.slot) >= ForkSeq.heze) {
110
+ state.latestExecutionPayloadBid = ssz.heze.ExecutionPayloadBid.toViewDU(bid as heze.ExecutionPayloadBid);
111
+ } else {
112
+ state.latestExecutionPayloadBid = ssz.gloas.ExecutionPayloadBid.toViewDU(bid);
113
+ }
114
+
115
+ return parentSlot;
103
116
  }
104
117
 
105
118
  function verifyExecutionPayloadBidSignature(
106
- state: CachedBeaconStateGloas,
119
+ state: CachedBeaconStateGloas | CachedBeaconStateHeze,
107
120
  pubkey: Uint8Array,
108
121
  signedBid: gloas.SignedExecutionPayloadBid
109
122
  ): boolean {
110
- const signingRoot = getExecutionPayloadBidSigningRoot(state.config, state.slot, signedBid.message);
123
+ const signingRoot = getExecutionPayloadBidSigningRoot(state.config, signedBid.message);
111
124
 
112
125
  try {
113
126
  const publicKey = PublicKey.fromBytes(pubkey);
@@ -7,7 +7,7 @@ import {
7
7
  MAX_PROPOSER_SLASHINGS,
8
8
  MAX_VOLUNTARY_EXITS,
9
9
  } from "@lodestar/params";
10
- import {BeaconBlockBody, capella, electra, gloas} from "@lodestar/types";
10
+ import {BeaconBlockBody, Slot, capella, electra, gloas} from "@lodestar/types";
11
11
  import {BeaconStateTransitionMetrics} from "../metrics.js";
12
12
  import {
13
13
  CachedBeaconStateAllForks,
@@ -44,6 +44,7 @@ export function processOperations(
44
44
  fork: ForkSeq,
45
45
  state: CachedBeaconStateAllForks,
46
46
  body: BeaconBlockBody,
47
+ parentSlot: Slot | null,
47
48
  opts: ProcessBlockOpts = {verifySignatures: true},
48
49
  metrics?: BeaconStateTransitionMetrics | null
49
50
  ): void {
@@ -67,7 +68,7 @@ export function processOperations(
67
68
  processAttesterSlashing(fork, state, attesterSlashing, opts.verifySignatures);
68
69
  }
69
70
 
70
- processAttestations(fork, state, body.attestations, opts.verifySignatures, metrics);
71
+ processAttestations(fork, state, body.attestations, parentSlot, opts.verifySignatures, metrics);
71
72
 
72
73
  for (const deposit of body.deposits) {
73
74
  processDeposit(fork, state, deposit);
@@ -8,7 +8,11 @@ import {
8
8
  import {electra, phase0, ssz} from "@lodestar/types";
9
9
  import {toHex} from "@lodestar/utils";
10
10
  import {CachedBeaconStateElectra, CachedBeaconStateGloas} from "../types.js";
11
- import {hasCompoundingWithdrawalCredential, hasExecutionWithdrawalCredential} from "../util/electra.js";
11
+ import {
12
+ hasCompoundingWithdrawalCredential,
13
+ hasExecutionWithdrawalCredential,
14
+ isValidatorKnown,
15
+ } from "../util/electra.js";
12
16
  import {computeExitEpochAndUpdateChurn} from "../util/epoch.js";
13
17
  import {getPendingBalanceToWithdraw, isActiveValidator} from "../util/validator.js";
14
18
  import {initiateValidatorExit} from "./initiateValidatorExit.js";
@@ -32,7 +36,7 @@ export function processWithdrawalRequest(
32
36
  // bail out if validator is not in beacon state
33
37
  // note that we don't need to check for 6110 unfinalized vals as they won't be eligible for withdraw/exit anyway
34
38
  const validatorIndex = pubkeyCache.getIndex(withdrawalRequest.validatorPubkey);
35
- if (validatorIndex === null) {
39
+ if (!isValidatorKnown(state, validatorIndex)) {
36
40
  return;
37
41
  }
38
42
 
@@ -1,5 +1,6 @@
1
1
  import {BeaconConfig} from "@lodestar/config";
2
2
  import {loadState} from "../util/loadState/loadState.js";
3
+ import {isViewDUNodesPopulated} from "../util/ssz.js";
3
4
  import {EpochCache, EpochCacheImmutableData, EpochCacheOpts} from "./epochCache.js";
4
5
  import {RewardCache, createEmptyRewardCache} from "./rewardCache.js";
5
6
  import {
@@ -12,6 +13,7 @@ import {
12
13
  BeaconStateExecutions,
13
14
  BeaconStateFulu,
14
15
  BeaconStateGloas,
16
+ BeaconStateHeze,
15
17
  BeaconStatePhase0,
16
18
  } from "./types.js";
17
19
 
@@ -136,6 +138,7 @@ export type CachedBeaconStateDeneb = CachedBeaconState<BeaconStateDeneb>;
136
138
  export type CachedBeaconStateElectra = CachedBeaconState<BeaconStateElectra>;
137
139
  export type CachedBeaconStateFulu = CachedBeaconState<BeaconStateFulu>;
138
140
  export type CachedBeaconStateGloas = CachedBeaconState<BeaconStateGloas>;
141
+ export type CachedBeaconStateHeze = CachedBeaconState<BeaconStateHeze>;
139
142
 
140
143
  export type CachedBeaconStateAllForks = CachedBeaconState<BeaconStateAllForks>;
141
144
  export type CachedBeaconStateExecutions = CachedBeaconState<BeaconStateExecutions>;
@@ -254,9 +257,9 @@ export function isCachedBeaconState<T extends BeaconStateAllForks>(
254
257
  // This cache is populated during epoch transition, and should be preserved for performance.
255
258
  // If the cache is missing too often, means that our clone strategy is not working well.
256
259
  export function isStateValidatorsNodesPopulated(state: CachedBeaconStateAllForks): boolean {
257
- return (state.validators as unknown as {nodesPopulated?: boolean}).nodesPopulated === true;
260
+ return isViewDUNodesPopulated(state.validators);
258
261
  }
259
262
 
260
263
  export function isStateBalancesNodesPopulated(state: CachedBeaconStateAllForks): boolean {
261
- return (state.balances as unknown as {nodesPopulated?: boolean}).nodesPopulated === true;
264
+ return isViewDUNodesPopulated(state.balances);
262
265
  }
@@ -11,6 +11,7 @@ export type BeaconStateDeneb = CompositeViewDU<SSZTypesFor<ForkName.deneb, "Beac
11
11
  export type BeaconStateElectra = CompositeViewDU<SSZTypesFor<ForkName.electra, "BeaconState">>;
12
12
  export type BeaconStateFulu = CompositeViewDU<SSZTypesFor<ForkName.fulu, "BeaconState">>;
13
13
  export type BeaconStateGloas = CompositeViewDU<SSZTypesFor<ForkName.gloas, "BeaconState">>;
14
+ export type BeaconStateHeze = CompositeViewDU<SSZTypesFor<ForkName.heze, "BeaconState">>;
14
15
 
15
16
  export type BeaconStateAllForks = CompositeViewDU<SSZTypesFor<ForkAll, "BeaconState">>;
16
17
  export type BeaconStateExecutions = CompositeViewDU<SSZTypesFor<ForkPostBellatrix & ForkPreGloas, "BeaconState">>;
package/src/index.ts CHANGED
@@ -52,6 +52,7 @@ export {
52
52
  type IBeaconStateViewElectra,
53
53
  type IBeaconStateViewFulu,
54
54
  type IBeaconStateViewGloas,
55
+ type IBeaconStateViewHeze,
55
56
  isStatePostAltair,
56
57
  isStatePostBellatrix,
57
58
  isStatePostCapella,
@@ -59,6 +60,7 @@ export {
59
60
  isStatePostElectra,
60
61
  isStatePostFulu,
61
62
  isStatePostGloas,
63
+ isStatePostHeze,
62
64
  } from "./stateView/interface.js";
63
65
  export {createBeaconStateView, createBeaconStateViewForHistoricalRegen} from "./stateView/stateViewFactory.js";
64
66
  export type {
@@ -71,6 +73,7 @@ export type {
71
73
  BeaconStateExecutions,
72
74
  BeaconStateFulu,
73
75
  BeaconStateGloas,
76
+ BeaconStateHeze,
74
77
  // Non-cached states
75
78
  BeaconStatePhase0,
76
79
  CachedBeaconStateAllForks,
@@ -82,6 +85,7 @@ export type {
82
85
  CachedBeaconStateExecutions,
83
86
  CachedBeaconStateFulu,
84
87
  CachedBeaconStateGloas,
88
+ CachedBeaconStateHeze,
85
89
  CachedBeaconStatePhase0,
86
90
  } from "./types.js";
87
91
  export * from "./util/index.js";
@@ -193,11 +193,11 @@ export function nextSyncCommitteeGindexAtFork(fork: ForkName): number {
193
193
  return NEXT_SYNC_COMMITTEE_GINDEX;
194
194
  }
195
195
 
196
- export function getGindexDepth(gindex: number): number {
196
+ function getGindexDepth(gindex: number): number {
197
197
  return Math.floor(Math.log2(gindex));
198
198
  }
199
199
 
200
- export function getGindexIndex(gindex: number): number {
200
+ function getGindexIndex(gindex: number): number {
201
201
  return gindex - 2 ** getGindexDepth(gindex);
202
202
  }
203
203
 
@@ -263,6 +263,7 @@ export function upgradeLightClientHeader(
263
263
  // Break if no further upgrades is required else fall through
264
264
  if (ForkSeq[targetFork] <= ForkSeq.fulu) break;
265
265
 
266
+ // biome-ignore lint/suspicious/noFallthroughSwitchClause: We need fall-through behavior here
266
267
  case ForkName.gloas:
267
268
  if (isGloasLightClientHeader(upgradedHeader)) {
268
269
  break;
@@ -272,6 +273,12 @@ export function upgradeLightClientHeader(
272
273
 
273
274
  // Break if no further upgrades is required else fall through
274
275
  if (ForkSeq[targetFork] <= ForkSeq.gloas) break;
276
+
277
+ case ForkName.heze:
278
+ // No changes to LightClientHeader in Heze
279
+
280
+ // Break if no further upgrades is required else fall through
281
+ if (ForkSeq[targetFork] <= ForkSeq.heze) break;
275
282
  }
276
283
  return upgradedHeader;
277
284
  }
package/src/metrics.ts CHANGED
@@ -3,6 +3,7 @@ import {ProposerRewardType} from "./block/types.js";
3
3
  import {EpochTransitionStep} from "./epoch/index.js";
4
4
  import {StateCloneSource, StateHashTreeRootSource} from "./stateTransition.js";
5
5
  import {CachedBeaconStateAllForks} from "./types.js";
6
+ import {isViewDUNodesPopulated} from "./util/ssz.js";
6
7
 
7
8
  export type BeaconStateTransitionMetrics = ReturnType<typeof getMetrics>;
8
9
 
@@ -159,9 +160,9 @@ export function onPostStateMetrics(postState: CachedBeaconStateAllForks, metrics
159
160
  // This cache is populated during epoch transition, and should be preserved for performance.
160
161
  // If the cache is missing too often, means that our clone strategy is not working well.
161
162
  function isValidatorsNodesPopulated(state: CachedBeaconStateAllForks): boolean {
162
- return (state.validators as unknown as {nodesPopulated?: boolean}).nodesPopulated === true;
163
+ return isViewDUNodesPopulated(state.validators);
163
164
  }
164
165
 
165
166
  function isBalancesNodesPopulated(state: CachedBeaconStateAllForks): boolean {
166
- return (state.balances as unknown as {nodesPopulated?: boolean}).nodesPopulated === true;
167
+ return isViewDUNodesPopulated(state.balances);
167
168
  }
@@ -4,11 +4,17 @@ import {
4
4
  WHISTLEBLOWER_REWARD_QUOTIENT,
5
5
  WHISTLEBLOWER_REWARD_QUOTIENT_ELECTRA,
6
6
  isForkPostElectra,
7
+ isForkPostGloas,
7
8
  } from "@lodestar/params";
8
- import {BeaconBlock, altair, phase0, rewards} from "@lodestar/types";
9
+ import {BeaconBlock, Slot, altair, phase0, rewards} from "@lodestar/types";
9
10
  import {processAttestationsAltair} from "../block/processAttestationsAltair.js";
10
11
  import {RewardCache} from "../cache/rewardCache.js";
11
- import {CachedBeaconStateAllForks, CachedBeaconStateAltair, CachedBeaconStatePhase0} from "../cache/stateCache.js";
12
+ import {
13
+ CachedBeaconStateAllForks,
14
+ CachedBeaconStateAltair,
15
+ CachedBeaconStateGloas,
16
+ CachedBeaconStatePhase0,
17
+ } from "../cache/stateCache.js";
12
18
  import {getAttesterSlashableIndices} from "../util/attestation.js";
13
19
 
14
20
  type SubRewardValue = number; // All reward values should be integer
@@ -36,10 +42,18 @@ export async function computeBlockRewards(
36
42
  let syncAggregateReward = cachedSyncAggregateReward;
37
43
 
38
44
  if (blockAttestationReward === 0) {
45
+ const parentSlot = isForkPostGloas(fork)
46
+ ? (preState as CachedBeaconStateGloas).latestExecutionPayloadBid.slot
47
+ : null;
39
48
  blockAttestationReward =
40
49
  fork === ForkName.phase0
41
50
  ? computeBlockAttestationRewardPhase0(block as phase0.BeaconBlock, preState as CachedBeaconStatePhase0)
42
- : computeBlockAttestationRewardAltair(config, block as altair.BeaconBlock, preState as CachedBeaconStateAltair);
51
+ : computeBlockAttestationRewardAltair(
52
+ config,
53
+ block as altair.BeaconBlock,
54
+ preState as CachedBeaconStateAltair,
55
+ parentSlot
56
+ );
43
57
  }
44
58
 
45
59
  if (syncAggregateReward === 0) {
@@ -79,12 +93,13 @@ function computeBlockAttestationRewardPhase0(
79
93
  function computeBlockAttestationRewardAltair(
80
94
  config: BeaconConfig,
81
95
  block: altair.BeaconBlock,
82
- preState: CachedBeaconStateAltair
96
+ preState: CachedBeaconStateAltair,
97
+ parentSlot: Slot | null
83
98
  ): SubRewardValue {
84
99
  const fork = config.getForkSeq(block.slot);
85
100
  const {attestations} = block.body;
86
101
 
87
- processAttestationsAltair(fork, preState, attestations, false);
102
+ processAttestationsAltair(fork, preState, attestations, parentSlot, false);
88
103
 
89
104
  return preState.proposerRewards.attestations;
90
105
  }
@@ -1,14 +1,12 @@
1
1
  import {BeaconConfig} from "@lodestar/config";
2
- import {DOMAIN_BEACON_BUILDER} from "@lodestar/params";
3
- import {Slot, gloas, ssz} from "@lodestar/types";
2
+ import {DOMAIN_BEACON_BUILDER, isForkPostGloas} from "@lodestar/params";
3
+ import {ExecutionPayloadBid, ssz, sszTypesFor} from "@lodestar/types";
4
4
  import {computeSigningRoot} from "../util/index.js";
5
5
 
6
- export function getExecutionPayloadBidSigningRoot(
7
- config: BeaconConfig,
8
- stateSlot: Slot,
9
- bid: gloas.ExecutionPayloadBid
10
- ): Uint8Array {
11
- const domain = config.getDomain(stateSlot, DOMAIN_BEACON_BUILDER);
6
+ export function getExecutionPayloadBidSigningRoot(config: BeaconConfig, bid: ExecutionPayloadBid): Uint8Array {
7
+ const fork = config.getForkName(bid.slot);
8
+ const domain = config.getDomain(bid.slot, DOMAIN_BEACON_BUILDER);
9
+ const sszType = isForkPostGloas(fork) ? sszTypesFor(fork).ExecutionPayloadBid : ssz.gloas.ExecutionPayloadBid;
12
10
 
13
- return computeSigningRoot(ssz.gloas.ExecutionPayloadBid, bid, domain);
11
+ return computeSigningRoot(sszType, bid, domain);
14
12
  }
package/src/slot/index.ts CHANGED
@@ -10,6 +10,7 @@ export {upgradeStateToDeneb} from "./upgradeStateToDeneb.js";
10
10
  export {upgradeStateToElectra} from "./upgradeStateToElectra.js";
11
11
  export {upgradeStateToFulu} from "./upgradeStateToFulu.js";
12
12
  export {upgradeStateToGloas} from "./upgradeStateToGloas.js";
13
+ export {upgradeStateToHeze} from "./upgradeStateToHeze.js";
13
14
 
14
15
  /**
15
16
  * Dial state to next slot. Common for all forks
@@ -137,6 +137,7 @@ function translateParticipation(
137
137
  attestation.inclusionDelay,
138
138
  epochCtx.epoch,
139
139
  rootCache,
140
+ null,
140
141
  null
141
142
  );
142
143
 
@@ -70,7 +70,7 @@ export function upgradeStateToGloas(stateFulu: CachedBeaconStateFulu): CachedBea
70
70
  stateGloasView.currentSyncCommittee = stateGloasCloned.currentSyncCommittee;
71
71
  stateGloasView.nextSyncCommittee = stateGloasCloned.nextSyncCommittee;
72
72
  stateGloasView.latestExecutionPayloadBid.blockHash = stateFulu.latestExecutionPayloadHeader.blockHash;
73
- stateGloasView.latestExecutionPayloadBid.gasLimit = stateFulu.latestExecutionPayloadHeader.gasLimit;
73
+ stateGloasView.latestExecutionPayloadBid.gasLimit = BigInt(stateFulu.latestExecutionPayloadHeader.gasLimit);
74
74
  stateGloasView.latestExecutionPayloadBid.executionRequestsRoot = ssz.gloas.ExecutionRequests.hashTreeRoot(
75
75
  ssz.gloas.ExecutionRequests.defaultValue()
76
76
  );
@@ -0,0 +1,91 @@
1
+ import {ssz} from "@lodestar/types";
2
+ import {getCachedBeaconState} from "../cache/stateCache.js";
3
+ import {CachedBeaconStateGloas, CachedBeaconStateHeze} from "../types.js";
4
+
5
+ /**
6
+ * Upgrade a state from Gloas to Heze.
7
+ * Spec: heze/fork.md `upgrade_to_heze`.
8
+ */
9
+ export function upgradeStateToHeze(stateGloas: CachedBeaconStateGloas): CachedBeaconStateHeze {
10
+ const {config} = stateGloas;
11
+
12
+ ssz.gloas.BeaconState.commitViewDU(stateGloas);
13
+ const stateHezeCloned = stateGloas;
14
+
15
+ const stateHezeView = ssz.heze.BeaconState.defaultViewDU();
16
+
17
+ stateHezeView.genesisTime = stateHezeCloned.genesisTime;
18
+ stateHezeView.genesisValidatorsRoot = stateHezeCloned.genesisValidatorsRoot;
19
+ stateHezeView.slot = stateHezeCloned.slot;
20
+ stateHezeView.fork = ssz.phase0.Fork.toViewDU({
21
+ previousVersion: stateGloas.fork.currentVersion,
22
+ currentVersion: config.HEZE_FORK_VERSION,
23
+ epoch: stateGloas.epochCtx.epoch,
24
+ });
25
+ stateHezeView.latestBlockHeader = stateHezeCloned.latestBlockHeader;
26
+ stateHezeView.blockRoots = stateHezeCloned.blockRoots;
27
+ stateHezeView.stateRoots = stateHezeCloned.stateRoots;
28
+ stateHezeView.historicalRoots = stateHezeCloned.historicalRoots;
29
+ stateHezeView.eth1Data = stateHezeCloned.eth1Data;
30
+ stateHezeView.eth1DataVotes = stateHezeCloned.eth1DataVotes;
31
+ stateHezeView.eth1DepositIndex = stateHezeCloned.eth1DepositIndex;
32
+ stateHezeView.validators = stateHezeCloned.validators;
33
+ stateHezeView.balances = stateHezeCloned.balances;
34
+ stateHezeView.randaoMixes = stateHezeCloned.randaoMixes;
35
+ stateHezeView.slashings = stateHezeCloned.slashings;
36
+ stateHezeView.previousEpochParticipation = stateHezeCloned.previousEpochParticipation;
37
+ stateHezeView.currentEpochParticipation = stateHezeCloned.currentEpochParticipation;
38
+ stateHezeView.justificationBits = stateHezeCloned.justificationBits;
39
+ stateHezeView.previousJustifiedCheckpoint = stateHezeCloned.previousJustifiedCheckpoint;
40
+ stateHezeView.currentJustifiedCheckpoint = stateHezeCloned.currentJustifiedCheckpoint;
41
+ stateHezeView.finalizedCheckpoint = stateHezeCloned.finalizedCheckpoint;
42
+ stateHezeView.inactivityScores = stateHezeCloned.inactivityScores;
43
+ stateHezeView.currentSyncCommittee = stateHezeCloned.currentSyncCommittee;
44
+ stateHezeView.nextSyncCommittee = stateHezeCloned.nextSyncCommittee;
45
+ stateHezeView.latestBlockHash = stateHezeCloned.latestBlockHash;
46
+ stateHezeView.nextWithdrawalIndex = stateHezeCloned.nextWithdrawalIndex;
47
+ stateHezeView.nextWithdrawalValidatorIndex = stateHezeCloned.nextWithdrawalValidatorIndex;
48
+ stateHezeView.historicalSummaries = stateHezeCloned.historicalSummaries;
49
+ stateHezeView.depositRequestsStartIndex = stateHezeCloned.depositRequestsStartIndex;
50
+ stateHezeView.depositBalanceToConsume = stateHezeCloned.depositBalanceToConsume;
51
+ stateHezeView.exitBalanceToConsume = stateHezeCloned.exitBalanceToConsume;
52
+ stateHezeView.earliestExitEpoch = stateHezeCloned.earliestExitEpoch;
53
+ stateHezeView.consolidationBalanceToConsume = stateHezeCloned.consolidationBalanceToConsume;
54
+ stateHezeView.earliestConsolidationEpoch = stateHezeCloned.earliestConsolidationEpoch;
55
+ stateHezeView.pendingDeposits = stateHezeCloned.pendingDeposits;
56
+ stateHezeView.pendingPartialWithdrawals = stateHezeCloned.pendingPartialWithdrawals;
57
+ stateHezeView.pendingConsolidations = stateHezeCloned.pendingConsolidations;
58
+ stateHezeView.proposerLookahead = stateHezeCloned.proposerLookahead;
59
+ stateHezeView.builders = stateHezeCloned.builders;
60
+ stateHezeView.nextWithdrawalBuilderIndex = stateHezeCloned.nextWithdrawalBuilderIndex;
61
+ stateHezeView.executionPayloadAvailability = stateHezeCloned.executionPayloadAvailability;
62
+ stateHezeView.builderPendingPayments = stateHezeCloned.builderPendingPayments;
63
+ stateHezeView.builderPendingWithdrawals = stateHezeCloned.builderPendingWithdrawals;
64
+
65
+ // [Modified in Heze:EIP7805] inclusion_list_bits = Bitvector[INCLUSION_LIST_COMMITTEE_SIZE]() (default zero)
66
+ const oldBid = stateHezeCloned.latestExecutionPayloadBid;
67
+ const newBid = ssz.heze.ExecutionPayloadBid.defaultViewDU();
68
+ newBid.parentBlockHash = oldBid.parentBlockHash;
69
+ newBid.parentBlockRoot = oldBid.parentBlockRoot;
70
+ newBid.blockHash = oldBid.blockHash;
71
+ newBid.prevRandao = oldBid.prevRandao;
72
+ newBid.feeRecipient = oldBid.feeRecipient;
73
+ newBid.gasLimit = oldBid.gasLimit;
74
+ newBid.builderIndex = oldBid.builderIndex;
75
+ newBid.slot = oldBid.slot;
76
+ newBid.value = oldBid.value;
77
+ newBid.executionPayment = oldBid.executionPayment;
78
+ newBid.blobKzgCommitments = oldBid.blobKzgCommitments;
79
+ newBid.executionRequestsRoot = oldBid.executionRequestsRoot;
80
+ stateHezeView.latestExecutionPayloadBid = newBid;
81
+
82
+ stateHezeView.payloadExpectedWithdrawals = stateHezeCloned.payloadExpectedWithdrawals;
83
+ stateHezeView.ptcWindow = stateHezeCloned.ptcWindow;
84
+
85
+ const stateHeze = getCachedBeaconState(stateHezeView, stateGloas);
86
+ stateHeze.commit();
87
+ // biome-ignore lint/complexity/useLiteralKeys: It is a protected attribute
88
+ stateHeze["clearCache"]();
89
+
90
+ return stateHeze;
91
+ }
@@ -16,6 +16,7 @@ import {
16
16
  upgradeStateToDeneb,
17
17
  upgradeStateToElectra,
18
18
  upgradeStateToGloas,
19
+ upgradeStateToHeze,
19
20
  } from "./slot/index.js";
20
21
  import {upgradeStateToFulu} from "./slot/upgradeStateToFulu.js";
21
22
  import {
@@ -26,6 +27,7 @@ import {
26
27
  CachedBeaconStateDeneb,
27
28
  CachedBeaconStateElectra,
28
29
  CachedBeaconStateFulu,
30
+ CachedBeaconStateGloas,
29
31
  CachedBeaconStatePhase0,
30
32
  } from "./types.js";
31
33
  import {computeEpochAtSlot} from "./util/index.js";
@@ -278,6 +280,9 @@ function processSlotsWithTransientCache(
278
280
  if (stateEpoch === config.GLOAS_FORK_EPOCH) {
279
281
  postState = upgradeStateToGloas(postState as CachedBeaconStateFulu) as CachedBeaconStateAllForks;
280
282
  }
283
+ if (stateEpoch === config.HEZE_FORK_EPOCH) {
284
+ postState = upgradeStateToHeze(postState as CachedBeaconStateGloas) as CachedBeaconStateAllForks;
285
+ }
281
286
 
282
287
  {
283
288
  const timer = metrics?.epochTransitionStepTime.startTimer({step: EpochTransitionStep.finalProcessEpoch});
@@ -9,6 +9,7 @@ import {
9
9
  ForkPostElectra,
10
10
  ForkPostFulu,
11
11
  ForkPostGloas,
12
+ ForkPostHeze,
12
13
  isForkPostAltair,
13
14
  isForkPostBellatrix,
14
15
  isForkPostCapella,
@@ -16,6 +17,7 @@ import {
16
17
  isForkPostElectra,
17
18
  isForkPostFulu,
18
19
  isForkPostGloas,
20
+ isForkPostHeze,
19
21
  } from "@lodestar/params";
20
22
  import {
21
23
  BeaconBlock,
@@ -267,14 +269,19 @@ export interface IBeaconStateViewGloas extends IBeaconStateViewFulu {
267
269
  withParentPayloadApplied(executionRequests: gloas.ExecutionRequests): IBeaconStateViewGloas;
268
270
  }
269
271
 
272
+ /** Heze+ state fields — use isStatePostHeze() guard */
273
+ export interface IBeaconStateViewHeze extends IBeaconStateViewGloas {
274
+ forkName: ForkPostHeze;
275
+ }
276
+
270
277
  /**
271
278
  * Type constraint for the concrete BeaconStateView class.
272
- * Requires all fields from the latest fork interface (IBeaconStateViewGloas) but keeps
279
+ * Requires all fields from the latest fork interface (IBeaconStateViewHeze) but keeps
273
280
  * forkName as ForkName since the class wraps any fork's state.
274
281
  * Sub-interfaces retain their narrowed forkName discriminants for caller-side type guards.
275
282
  */
276
283
  export type IBeaconStateViewLatestFork = Omit<
277
- IBeaconStateViewGloas,
284
+ IBeaconStateViewHeze,
278
285
  "forkName" | "latestExecutionPayloadHeader" | "payloadBlockNumber"
279
286
  > & {
280
287
  forkName: ForkName;
@@ -337,3 +344,7 @@ export function isStatePostFulu(state: IBeaconStateView): state is IBeaconStateV
337
344
  export function isStatePostGloas(state: IBeaconStateView): state is IBeaconStateViewGloas {
338
345
  return isForkPostGloas(state.forkName);
339
346
  }
347
+
348
+ export function isStatePostHeze(state: IBeaconStateView): state is IBeaconStateViewHeze {
349
+ return isForkPostHeze(state.forkName);
350
+ }
@@ -54,7 +54,7 @@ export function generateState(opts?: TestBeaconState): BeaconStatePhase0 {
54
54
  eth1Data: {
55
55
  depositRoot: Buffer.alloc(32),
56
56
  blockHash: Buffer.alloc(32),
57
- depositCount: 0,
57
+ depositCount: 0n,
58
58
  },
59
59
  eth1DataVotes: [],
60
60
  eth1DepositIndex: 0,
@@ -437,13 +437,13 @@ function buildPerformanceStatePhase0(pubkeysArg?: Uint8Array[]): phase0.BeaconSt
437
437
  historicalRoots: [],
438
438
  // Eth1
439
439
  eth1Data: {
440
- depositCount: pubkeys.length,
440
+ depositCount: BigInt(pubkeys.length),
441
441
  depositRoot: fromHexString("0xcb1f89a924cfd31224823db5a41b1643f10faa7aedf231f1e28887f6ee98c047"),
442
442
  blockHash: fromHexString("0x701fb2869ce16d0f1d14f6705725adb0dec6799da29006dfc6fff83960298f21"),
443
443
  },
444
444
  // minus one so that inserting 1 from block works
445
445
  eth1DataVotes: newFilledArray(EPOCHS_PER_ETH1_VOTING_PERIOD * SLOTS_PER_EPOCH - 1, {
446
- depositCount: 1,
446
+ depositCount: 1n,
447
447
  depositRoot: Buffer.alloc(32, 1),
448
448
  blockHash: Buffer.alloc(32, 1),
449
449
  }),