@lodestar/state-transition 1.50.0-dev.2e668c516f → 1.50.0-dev.335476095e

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 (63) hide show
  1. package/lib/block/indexedBuilderState.d.ts +19 -0
  2. package/lib/block/indexedBuilderState.d.ts.map +1 -0
  3. package/lib/block/indexedBuilderState.js +60 -0
  4. package/lib/block/indexedBuilderState.js.map +1 -0
  5. package/lib/block/processBuilderDepositRequest.d.ts +2 -2
  6. package/lib/block/processBuilderDepositRequest.d.ts.map +1 -1
  7. package/lib/block/processBuilderDepositRequest.js +5 -4
  8. package/lib/block/processBuilderDepositRequest.js.map +1 -1
  9. package/lib/block/processBuilderExitRequest.d.ts +2 -2
  10. package/lib/block/processBuilderExitRequest.d.ts.map +1 -1
  11. package/lib/block/processBuilderExitRequest.js +4 -3
  12. package/lib/block/processBuilderExitRequest.js.map +1 -1
  13. package/lib/block/processParentExecutionPayload.d.ts.map +1 -1
  14. package/lib/block/processParentExecutionPayload.js +23 -18
  15. package/lib/block/processParentExecutionPayload.js.map +1 -1
  16. package/lib/index.d.ts +3 -1
  17. package/lib/index.d.ts.map +1 -1
  18. package/lib/index.js +2 -0
  19. package/lib/index.js.map +1 -1
  20. package/lib/rewards/attestationsRewards.d.ts.map +1 -1
  21. package/lib/rewards/attestationsRewards.js +8 -1
  22. package/lib/rewards/attestationsRewards.js.map +1 -1
  23. package/lib/stateView/beaconStateView.d.ts +22 -21
  24. package/lib/stateView/beaconStateView.d.ts.map +1 -1
  25. package/lib/stateView/beaconStateView.js +71 -71
  26. package/lib/stateView/beaconStateView.js.map +1 -1
  27. package/lib/stateView/interface.d.ts +34 -21
  28. package/lib/stateView/interface.d.ts.map +1 -1
  29. package/lib/stateView/interface.js.map +1 -1
  30. package/lib/stateView/nativeBeaconStateView.d.ts +92 -100
  31. package/lib/stateView/nativeBeaconStateView.d.ts.map +1 -1
  32. package/lib/stateView/nativeBeaconStateView.js +339 -368
  33. package/lib/stateView/nativeBeaconStateView.js.map +1 -1
  34. package/lib/stateView/stateViewFactory.d.ts +6 -5
  35. package/lib/stateView/stateViewFactory.d.ts.map +1 -1
  36. package/lib/stateView/stateViewFactory.js +12 -8
  37. package/lib/stateView/stateViewFactory.js.map +1 -1
  38. package/lib/util/gloas.d.ts +11 -14
  39. package/lib/util/gloas.d.ts.map +1 -1
  40. package/lib/util/gloas.js +2 -42
  41. package/lib/util/gloas.js.map +1 -1
  42. package/lib/util/index.d.ts +1 -1
  43. package/lib/util/index.d.ts.map +1 -1
  44. package/lib/util/index.js +1 -1
  45. package/lib/util/index.js.map +1 -1
  46. package/lib/util/sszBytes.d.ts +2 -0
  47. package/lib/util/sszBytes.d.ts.map +1 -1
  48. package/lib/util/sszBytes.js +14 -1
  49. package/lib/util/sszBytes.js.map +1 -1
  50. package/package.json +7 -7
  51. package/src/block/indexedBuilderState.ts +65 -0
  52. package/src/block/processBuilderDepositRequest.ts +6 -17
  53. package/src/block/processBuilderExitRequest.ts +5 -9
  54. package/src/block/processParentExecutionPayload.ts +27 -23
  55. package/src/index.ts +4 -1
  56. package/src/rewards/attestationsRewards.ts +8 -1
  57. package/src/stateView/beaconStateView.ts +75 -76
  58. package/src/stateView/interface.ts +61 -21
  59. package/src/stateView/nativeBeaconStateView.ts +354 -375
  60. package/src/stateView/stateViewFactory.ts +21 -12
  61. package/src/util/gloas.ts +2 -53
  62. package/src/util/index.ts +1 -0
  63. package/src/util/sszBytes.ts +19 -1
@@ -1,13 +1,8 @@
1
1
  import {FAR_FUTURE_EPOCH, PAYLOAD_BUILDER_VERSION} from "@lodestar/params";
2
2
  import {gloas} from "@lodestar/types";
3
- import {CachedBeaconStateGloas} from "../types.js";
4
3
  import {computeEpochAtSlot} from "../util/epoch.js";
5
- import {
6
- addBuilderToRegistry,
7
- findBuilderIndexByPubkey,
8
- isBuilderWithdrawalCredential,
9
- isValidBuilderDepositSignature,
10
- } from "../util/gloas.js";
4
+ import {isBuilderWithdrawalCredential, isValidBuilderDepositSignature} from "../util/gloas.js";
5
+ import {IndexedBuilderState} from "./indexedBuilderState.js";
11
6
 
12
7
  /**
13
8
  * Process a builder deposit request from the execution layer: register a new builder
@@ -16,9 +11,10 @@ import {
16
11
  * Spec: https://github.com/ethereum/consensus-specs/blob/v1.7.0-alpha.11/specs/gloas/beacon-chain.md#new-process_builder_deposit_request
17
12
  */
18
13
  export function processBuilderDepositRequest(
19
- state: CachedBeaconStateGloas,
14
+ indexedState: IndexedBuilderState,
20
15
  request: gloas.BuilderDepositRequest
21
16
  ): void {
17
+ const {state} = indexedState;
22
18
  const {pubkey, withdrawalCredentials, amount, signature} = request;
23
19
 
24
20
  // Ignore deposits with unexpected withdrawal credential prefixes.
@@ -26,18 +22,11 @@ export function processBuilderDepositRequest(
26
22
  return;
27
23
  }
28
24
 
29
- const builderIndex = findBuilderIndexByPubkey(state, pubkey);
25
+ const builderIndex = indexedState.findBuilderIndexByPubkey(pubkey);
30
26
 
31
27
  if (builderIndex === null) {
32
28
  if (isValidBuilderDepositSignature(state.config, pubkey, withdrawalCredentials, amount, signature)) {
33
- addBuilderToRegistry(
34
- state,
35
- pubkey,
36
- PAYLOAD_BUILDER_VERSION,
37
- withdrawalCredentials.subarray(12),
38
- amount,
39
- state.slot
40
- );
29
+ indexedState.addBuilderToRegistry(pubkey, PAYLOAD_BUILDER_VERSION, withdrawalCredentials.subarray(12), amount);
41
30
  }
42
31
  return;
43
32
  }
@@ -1,12 +1,7 @@
1
1
  import {gloas} from "@lodestar/types";
2
2
  import {byteArrayEquals} from "@lodestar/utils";
3
- import {CachedBeaconStateGloas} from "../types.js";
4
- import {
5
- findBuilderIndexByPubkey,
6
- getPendingBalanceToWithdrawForBuilder,
7
- initiateBuilderExit,
8
- isActiveBuilder,
9
- } from "../util/gloas.js";
3
+ import {getPendingBalanceToWithdrawForBuilder, initiateBuilderExit, isActiveBuilder} from "../util/gloas.js";
4
+ import {IndexedBuilderState} from "./indexedBuilderState.js";
10
5
 
11
6
  /**
12
7
  * Apply a builder exit request. Authorizes the exit via `source_address` (the builder's
@@ -17,8 +12,9 @@ import {
17
12
  *
18
13
  * Spec: https://github.com/ethereum/consensus-specs/blob/v1.7.0-alpha.11/specs/gloas/beacon-chain.md#new-process_builder_exit_request
19
14
  */
20
- export function processBuilderExitRequest(state: CachedBeaconStateGloas, request: gloas.BuilderExitRequest): void {
21
- const builderIndex = findBuilderIndexByPubkey(state, request.pubkey);
15
+ export function processBuilderExitRequest(indexedState: IndexedBuilderState, request: gloas.BuilderExitRequest): void {
16
+ const {state} = indexedState;
17
+ const builderIndex = indexedState.findBuilderIndexByPubkey(request.pubkey);
22
18
  if (builderIndex === null) {
23
19
  return;
24
20
  }
@@ -3,6 +3,7 @@ import {BeaconBlock, gloas, ssz} from "@lodestar/types";
3
3
  import {byteArrayEquals, toRootHex} from "@lodestar/utils";
4
4
  import {CachedBeaconStateGloas} from "../types.js";
5
5
  import {computeEpochAtSlot} from "../util/epoch.js";
6
+ import {IndexedBuilderState} from "./indexedBuilderState.js";
6
7
  import {processBuilderDepositRequest} from "./processBuilderDepositRequest.js";
7
8
  import {processBuilderExitRequest} from "./processBuilderExitRequest.js";
8
9
  import {processConsolidationRequest} from "./processConsolidationRequest.js";
@@ -53,29 +54,8 @@ export function applyParentExecutionPayload(state: CachedBeaconStateGloas, reque
53
54
  const parentEpoch = computeEpochAtSlot(parentSlot);
54
55
  const currentEpoch = computeEpochAtSlot(state.slot);
55
56
 
56
- // Process execution requests from parent's payload. The execution
57
- // requests are processed at state.slot (child's slot), not the parent's slot.
58
- for (const deposit of requests.deposits) {
59
- processDepositRequest(fork, state, deposit);
60
- }
61
-
62
- for (const withdrawal of requests.withdrawals) {
63
- processWithdrawalRequest(fork, state, withdrawal);
64
- }
65
-
66
- for (const consolidation of requests.consolidations) {
67
- processConsolidationRequest(state, consolidation);
68
- }
69
-
70
- for (const builderDeposit of requests.builderDeposits) {
71
- processBuilderDepositRequest(state, builderDeposit);
72
- }
73
-
74
- for (const builderExit of requests.builderExits) {
75
- processBuilderExitRequest(state, builderExit);
76
- }
77
-
78
- // Settle the builder payment
57
+ // Settle the builder payment before the requests so that a builder exit request
58
+ // is rejected while the payment is pending
79
59
  if (parentEpoch === currentEpoch) {
80
60
  settleBuilderPayment(state, SLOTS_PER_EPOCH + (parentSlot % SLOTS_PER_EPOCH));
81
61
  } else if (parentEpoch === currentEpoch - 1) {
@@ -92,6 +72,30 @@ export function applyParentExecutionPayload(state: CachedBeaconStateGloas, reque
92
72
  );
93
73
  }
94
74
 
75
+ // Process execution requests from parent's payload. The execution
76
+ // requests are processed at state.slot (child's slot), not the parent's slot.
77
+ for (const deposit of requests.deposits) {
78
+ processDepositRequest(fork, state, deposit);
79
+ }
80
+
81
+ for (const withdrawal of requests.withdrawals) {
82
+ processWithdrawalRequest(fork, state, withdrawal);
83
+ }
84
+
85
+ for (const consolidation of requests.consolidations) {
86
+ processConsolidationRequest(state, consolidation);
87
+ }
88
+
89
+ if (requests.builderDeposits.length > 0 || requests.builderExits.length > 0) {
90
+ const indexedState = new IndexedBuilderState(state);
91
+ for (const builderDeposit of requests.builderDeposits) {
92
+ processBuilderDepositRequest(indexedState, builderDeposit);
93
+ }
94
+ for (const builderExit of requests.builderExits) {
95
+ processBuilderExitRequest(indexedState, builderExit);
96
+ }
97
+ }
98
+
95
99
  // Update parent payload availability and latest block hash
96
100
  state.executionPayloadAvailability.set(parentSlot % SLOTS_PER_HISTORICAL_ROOT, true);
97
101
  state.latestBlockHash = parentBid.blockHash;
package/src/index.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export {type BlockExternalData, DataAvailabilityStatus, ExecutionPayloadStatus} from "./block/externalData.js";
2
+ export {IndexedBuilderState} from "./block/indexedBuilderState.js";
2
3
  export {getAttestationParticipationStatus, processAttestationsAltair} from "./block/processAttestationsAltair.js";
3
4
  export {assertValidAttesterSlashing} from "./block/processAttesterSlashing.js";
4
5
  export {isValidBlsToExecutionChange} from "./block/processBlsToExecutionChange.js";
@@ -43,7 +44,7 @@ export * from "./signatureSets/index.js";
43
44
  export * from "./stateTransition.js";
44
45
  export {BeaconStateView} from "./stateView/beaconStateView.js";
45
46
  export {
46
- type ComputeNewStateRootInput,
47
+ type BlockSTFInput,
47
48
  type ComputeNewStateRootResult,
48
49
  type IBeaconStateView,
49
50
  type IBeaconStateViewAltair,
@@ -54,6 +55,7 @@ export {
54
55
  type IBeaconStateViewFulu,
55
56
  type IBeaconStateViewGloas,
56
57
  type IBeaconStateViewHeze,
58
+ type IBeaconStateViewNative,
57
59
  isStatePostAltair,
58
60
  isStatePostBellatrix,
59
61
  isStatePostCapella,
@@ -63,6 +65,7 @@ export {
63
65
  isStatePostGloas,
64
66
  isStatePostHeze,
65
67
  } from "./stateView/interface.js";
68
+ export {NativeBeaconStateView} from "./stateView/nativeBeaconStateView.js";
66
69
  export {createBeaconStateView, createBeaconStateViewForHistoricalRegen} from "./stateView/stateViewFactory.js";
67
70
  export type {
68
71
  BeaconStateAllForks,
@@ -18,6 +18,8 @@ import {
18
18
  import {ValidatorIndex, rewards} from "@lodestar/types";
19
19
  import {fromHex} from "@lodestar/utils";
20
20
  import {EpochTransitionCache, beforeProcessEpoch} from "../cache/epochTransitionCache.js";
21
+ import {processInactivityUpdates} from "../epoch/processInactivityUpdates.js";
22
+ import {processJustificationAndFinalization} from "../epoch/processJustificationAndFinalization.js";
21
23
  import {CachedBeaconStateAllForks, CachedBeaconStateAltair} from "../types.js";
22
24
  import {
23
25
  FLAG_ELIGIBLE_ATTESTER,
@@ -45,8 +47,13 @@ export async function computeAttestationsRewards(
45
47
  throw Error("Unsupported fork. Attestations rewards calculation is not available in phase0");
46
48
  }
47
49
 
48
- const stateAltair = state as CachedBeaconStateAltair;
50
+ // Rewards are computed after justification and inactivity updates in epoch processing, so apply both to a clone
51
+ // before reading finality and inactivity scores, see
52
+ // https://github.com/ethereum/consensus-specs/blob/v1.7.0-beta.2/specs/altair/beacon-chain.md#epoch-processing
53
+ const stateAltair = state.clone() as CachedBeaconStateAltair;
49
54
  const transitionCache = beforeProcessEpoch(stateAltair);
55
+ processJustificationAndFinalization(stateAltair, transitionCache);
56
+ processInactivityUpdates(stateAltair, transitionCache);
50
57
 
51
58
  const [idealRewards, penalties] = computeIdealAttestationsRewardsAndPenaltiesAltair(
52
59
  config,
@@ -14,8 +14,6 @@ import {
14
14
  ExecutionPayloadHeader,
15
15
  Root,
16
16
  RootHex,
17
- SignedBeaconBlock,
18
- SignedBlindedBeaconBlock,
19
17
  Slot,
20
18
  SyncCommittee,
21
19
  ValidatorIndex,
@@ -71,7 +69,7 @@ import {getRandaoMix} from "../util/seed.js";
71
69
  import {getLatestWeakSubjectivityCheckpointEpoch} from "../util/weakSubjectivity.js";
72
70
  import {computeNewStateRootStateTransitionOpts, getComputeNewStateRootResult} from "./computeNewStateRoot.js";
73
71
  import {
74
- ComputeNewStateRootInput,
72
+ BlockSTFInput,
75
73
  ComputeNewStateRootResult,
76
74
  IBeaconStateView,
77
75
  IBeaconStateViewGloas,
@@ -83,34 +81,36 @@ export class BeaconStateView implements IBeaconStateViewLatestFork {
83
81
  private readonly config: BeaconConfig;
84
82
  // Cached values extracted from the tree
85
83
  // phase0
86
- private _fork: Fork | null = null;
87
- private _latestBlockHeader: phase0.BeaconBlockHeader | null = null;
84
+ private cachedFork: Fork | null = null;
85
+ private cachedLatestBlockHeader: phase0.BeaconBlockHeader | null = null;
88
86
  // altair
89
- private _currentSyncCommittee: SyncCommittee | null = null;
90
- private _nextSyncCommittee: SyncCommittee | null = null;
91
- private _previousEpochParticipation: Uint8Array | null = null;
92
- private _currentEpochParticipation: Uint8Array | null = null;
87
+ private cachedCurrentSyncCommittee: SyncCommittee | null = null;
88
+ private cachedNextSyncCommittee: SyncCommittee | null = null;
89
+ private cachedPreviousEpochParticipation: Uint8Array | null = null;
90
+ private cachedCurrentEpochParticipation: Uint8Array | null = null;
93
91
  // bellatrix
94
- private _latestExecutionPayloadHeader: ExecutionPayloadHeader | null = null;
92
+ private cachedLatestExecutionPayloadHeader: ExecutionPayloadHeader | null = null;
95
93
  // capella
96
- private _historicalSummaries: capella.HistoricalSummaries | null = null;
94
+ private cachedHistoricalSummaries: capella.HistoricalSummaries | null = null;
97
95
  // electra
98
- private _pendingPartialWithdrawals: electra.PendingPartialWithdrawals | null = null;
99
- private _pendingConsolidations: electra.PendingConsolidations | null = null;
100
- private _pendingDeposits: electra.PendingDeposits | null = null;
96
+ private cachedPendingPartialWithdrawals: electra.PendingPartialWithdrawals | null = null;
97
+ private cachedPendingConsolidations: electra.PendingConsolidations | null = null;
98
+ private cachedPendingDeposits: electra.PendingDeposits | null = null;
101
99
  // fulu
102
- private _proposerLookahead: fulu.ProposerLookahead | null = null;
100
+ private cachedProposerLookahead: fulu.ProposerLookahead | null = null;
103
101
  // gloas
104
- private _executionPayloadAvailability: BitArray | null = null;
105
- private _latestExecutionPayloadBid: ExecutionPayloadBid | null = null;
106
- private _payloadExpectedWithdrawals: capella.Withdrawal[] | null = null;
107
- private _builderPendingPayments: gloas.BuilderPendingPayments | null = null;
108
- private _builderPendingWithdrawals: gloas.BuilderPendingWithdrawals | null = null;
102
+ private cachedExecutionPayloadAvailability: BitArray | null = null;
103
+ private cachedLatestExecutionPayloadBid: ExecutionPayloadBid | null = null;
104
+ private cachedPayloadExpectedWithdrawals: capella.Withdrawal[] | null = null;
105
+ private cachedBuilderPendingPayments: gloas.BuilderPendingPayments | null = null;
106
+ private cachedBuilderPendingWithdrawals: gloas.BuilderPendingWithdrawals | null = null;
109
107
 
110
108
  constructor(readonly cachedState: CachedBeaconStateAllForks) {
111
109
  this.config = cachedState.config;
112
110
  }
113
111
 
112
+ release(): void {}
113
+
114
114
  // phase0
115
115
 
116
116
  get forkName(): ForkName {
@@ -126,10 +126,10 @@ export class BeaconStateView implements IBeaconStateViewLatestFork {
126
126
  }
127
127
 
128
128
  get fork(): Fork {
129
- if (this._fork === null) {
130
- this._fork = this.cachedState.fork.toValue();
129
+ if (this.cachedFork === null) {
130
+ this.cachedFork = this.cachedState.fork.toValue();
131
131
  }
132
- return this._fork;
132
+ return this.cachedFork;
133
133
  }
134
134
 
135
135
  get epoch(): number {
@@ -149,10 +149,10 @@ export class BeaconStateView implements IBeaconStateViewLatestFork {
149
149
  }
150
150
 
151
151
  get latestBlockHeader(): phase0.BeaconBlockHeader {
152
- if (this._latestBlockHeader === null) {
153
- this._latestBlockHeader = this.cachedState.latestBlockHeader.toValue();
152
+ if (this.cachedLatestBlockHeader === null) {
153
+ this.cachedLatestBlockHeader = this.cachedState.latestBlockHeader.toValue();
154
154
  }
155
- return this._latestBlockHeader;
155
+ return this.cachedLatestBlockHeader;
156
156
  }
157
157
 
158
158
  get previousJustifiedCheckpoint(): Checkpoint {
@@ -188,13 +188,13 @@ export class BeaconStateView implements IBeaconStateViewLatestFork {
188
188
  throw new Error("previousEpochParticipation is not available before Altair");
189
189
  }
190
190
 
191
- if (this._previousEpochParticipation === null) {
192
- this._previousEpochParticipation = (
191
+ if (this.cachedPreviousEpochParticipation === null) {
192
+ this.cachedPreviousEpochParticipation = (
193
193
  this.cachedState as CachedBeaconStateAltair
194
194
  ).previousEpochParticipation.serialize();
195
195
  }
196
196
 
197
- return this._previousEpochParticipation;
197
+ return this.cachedPreviousEpochParticipation;
198
198
  }
199
199
 
200
200
  // altair
@@ -204,13 +204,13 @@ export class BeaconStateView implements IBeaconStateViewLatestFork {
204
204
  throw new Error("currentEpochParticipation is not available before Altair");
205
205
  }
206
206
 
207
- if (this._currentEpochParticipation === null) {
208
- this._currentEpochParticipation = (
207
+ if (this.cachedCurrentEpochParticipation === null) {
208
+ this.cachedCurrentEpochParticipation = (
209
209
  this.cachedState as CachedBeaconStateAltair
210
210
  ).currentEpochParticipation.serialize();
211
211
  }
212
212
 
213
- return this._currentEpochParticipation;
213
+ return this.cachedCurrentEpochParticipation;
214
214
  }
215
215
 
216
216
  getPreviousEpochParticipation(validatorIndex: ValidatorIndex): number {
@@ -238,13 +238,13 @@ export class BeaconStateView implements IBeaconStateViewLatestFork {
238
238
  throw new Error("latestExecutionPayloadHeader is not available after Gloas");
239
239
  }
240
240
 
241
- if (this._latestExecutionPayloadHeader === null) {
242
- this._latestExecutionPayloadHeader = (
241
+ if (this.cachedLatestExecutionPayloadHeader === null) {
242
+ this.cachedLatestExecutionPayloadHeader = (
243
243
  this.cachedState as CachedBeaconStateExecutions
244
244
  ).latestExecutionPayloadHeader.toValue();
245
245
  }
246
246
 
247
- return this._latestExecutionPayloadHeader;
247
+ return this.cachedLatestExecutionPayloadHeader;
248
248
  }
249
249
 
250
250
  /**
@@ -270,11 +270,11 @@ export class BeaconStateView implements IBeaconStateViewLatestFork {
270
270
  throw new Error("Historical summaries are not supported before Capella");
271
271
  }
272
272
 
273
- if (this._historicalSummaries === null) {
274
- this._historicalSummaries = (this.cachedState as CachedBeaconStateCapella).historicalSummaries.toValue();
273
+ if (this.cachedHistoricalSummaries === null) {
274
+ this.cachedHistoricalSummaries = (this.cachedState as CachedBeaconStateCapella).historicalSummaries.toValue();
275
275
  }
276
276
 
277
- return this._historicalSummaries;
277
+ return this.cachedHistoricalSummaries;
278
278
  }
279
279
 
280
280
  // electra
@@ -284,11 +284,11 @@ export class BeaconStateView implements IBeaconStateViewLatestFork {
284
284
  throw new Error("Pending deposits are not supported before Electra");
285
285
  }
286
286
 
287
- if (this._pendingDeposits === null) {
288
- this._pendingDeposits = (this.cachedState as CachedBeaconStateElectra).pendingDeposits.toValue();
287
+ if (this.cachedPendingDeposits === null) {
288
+ this.cachedPendingDeposits = (this.cachedState as CachedBeaconStateElectra).pendingDeposits.toValue();
289
289
  }
290
290
 
291
- return this._pendingDeposits;
291
+ return this.cachedPendingDeposits;
292
292
  }
293
293
 
294
294
  get pendingDepositsCount(): number {
@@ -304,13 +304,13 @@ export class BeaconStateView implements IBeaconStateViewLatestFork {
304
304
  throw new Error("Pending partial withdrawals are not supported before Electra");
305
305
  }
306
306
 
307
- if (this._pendingPartialWithdrawals === null) {
308
- this._pendingPartialWithdrawals = (
307
+ if (this.cachedPendingPartialWithdrawals === null) {
308
+ this.cachedPendingPartialWithdrawals = (
309
309
  this.cachedState as CachedBeaconStateElectra
310
310
  ).pendingPartialWithdrawals.toValue();
311
311
  }
312
312
 
313
- return this._pendingPartialWithdrawals;
313
+ return this.cachedPendingPartialWithdrawals;
314
314
  }
315
315
 
316
316
  get pendingPartialWithdrawalsCount(): number {
@@ -326,11 +326,11 @@ export class BeaconStateView implements IBeaconStateViewLatestFork {
326
326
  throw new Error("Pending consolidations are not supported before Electra");
327
327
  }
328
328
 
329
- if (this._pendingConsolidations === null) {
330
- this._pendingConsolidations = (this.cachedState as CachedBeaconStateElectra).pendingConsolidations.toValue();
329
+ if (this.cachedPendingConsolidations === null) {
330
+ this.cachedPendingConsolidations = (this.cachedState as CachedBeaconStateElectra).pendingConsolidations.toValue();
331
331
  }
332
332
 
333
- return this._pendingConsolidations;
333
+ return this.cachedPendingConsolidations;
334
334
  }
335
335
 
336
336
  get pendingConsolidationsCount(): number {
@@ -348,11 +348,11 @@ export class BeaconStateView implements IBeaconStateViewLatestFork {
348
348
  throw new Error("Proposer lookahead is not supported before Fulu");
349
349
  }
350
350
 
351
- if (this._proposerLookahead === null) {
352
- this._proposerLookahead = (this.cachedState as CachedBeaconStateFulu).proposerLookahead.toValue();
351
+ if (this.cachedProposerLookahead === null) {
352
+ this.cachedProposerLookahead = (this.cachedState as CachedBeaconStateFulu).proposerLookahead.toValue();
353
353
  }
354
354
 
355
- return this._proposerLookahead;
355
+ return this.cachedProposerLookahead;
356
356
  }
357
357
 
358
358
  preVerifyBuilderDepositsPreGloas(maxBuilderDeposits: number, maxDurationMs: number): PreVerifyBuilderDepositsResult {
@@ -381,13 +381,13 @@ export class BeaconStateView implements IBeaconStateViewLatestFork {
381
381
  throw new Error("executionPayloadAvailability is not available before Gloas");
382
382
  }
383
383
 
384
- if (this._executionPayloadAvailability === null) {
385
- this._executionPayloadAvailability = (
384
+ if (this.cachedExecutionPayloadAvailability === null) {
385
+ this.cachedExecutionPayloadAvailability = (
386
386
  this.cachedState as CachedBeaconStateGloas
387
387
  ).executionPayloadAvailability.toValue();
388
388
  }
389
389
 
390
- return this._executionPayloadAvailability;
390
+ return this.cachedExecutionPayloadAvailability;
391
391
  }
392
392
 
393
393
  get latestExecutionPayloadBid(): ExecutionPayloadBid {
@@ -395,12 +395,12 @@ export class BeaconStateView implements IBeaconStateViewLatestFork {
395
395
  throw new Error("latestExecutionPayloadBid is not available before Gloas");
396
396
  }
397
397
 
398
- if (this._latestExecutionPayloadBid === null) {
399
- this._latestExecutionPayloadBid = (
398
+ if (this.cachedLatestExecutionPayloadBid === null) {
399
+ this.cachedLatestExecutionPayloadBid = (
400
400
  this.cachedState as CachedBeaconStateGloas
401
401
  ).latestExecutionPayloadBid.toValue();
402
402
  }
403
- return this._latestExecutionPayloadBid;
403
+ return this.cachedLatestExecutionPayloadBid;
404
404
  }
405
405
 
406
406
  get payloadExpectedWithdrawals(): capella.Withdrawal[] {
@@ -408,12 +408,12 @@ export class BeaconStateView implements IBeaconStateViewLatestFork {
408
408
  throw new Error("payloadExpectedWithdrawals is not available before Gloas");
409
409
  }
410
410
 
411
- if (this._payloadExpectedWithdrawals === null) {
412
- this._payloadExpectedWithdrawals = (
411
+ if (this.cachedPayloadExpectedWithdrawals === null) {
412
+ this.cachedPayloadExpectedWithdrawals = (
413
413
  this.cachedState as CachedBeaconStateGloas
414
414
  ).payloadExpectedWithdrawals.toValue();
415
415
  }
416
- return this._payloadExpectedWithdrawals;
416
+ return this.cachedPayloadExpectedWithdrawals;
417
417
  }
418
418
 
419
419
  get builderPendingPayments(): gloas.BuilderPendingPayments {
@@ -421,10 +421,10 @@ export class BeaconStateView implements IBeaconStateViewLatestFork {
421
421
  throw new Error("Pending builder payments are not supported before Gloas");
422
422
  }
423
423
 
424
- if (this._builderPendingPayments === null) {
425
- this._builderPendingPayments = (this.cachedState as CachedBeaconStateGloas).builderPendingPayments.toValue();
424
+ if (this.cachedBuilderPendingPayments === null) {
425
+ this.cachedBuilderPendingPayments = (this.cachedState as CachedBeaconStateGloas).builderPendingPayments.toValue();
426
426
  }
427
- return this._builderPendingPayments;
427
+ return this.cachedBuilderPendingPayments;
428
428
  }
429
429
 
430
430
  get builderPendingWithdrawals(): gloas.BuilderPendingWithdrawals {
@@ -432,12 +432,12 @@ export class BeaconStateView implements IBeaconStateViewLatestFork {
432
432
  throw new Error("Pending builder withdrawals are not supported before Gloas");
433
433
  }
434
434
 
435
- if (this._builderPendingWithdrawals === null) {
436
- this._builderPendingWithdrawals = (
435
+ if (this.cachedBuilderPendingWithdrawals === null) {
436
+ this.cachedBuilderPendingWithdrawals = (
437
437
  this.cachedState as CachedBeaconStateGloas
438
438
  ).builderPendingWithdrawals.toValue();
439
439
  }
440
- return this._builderPendingWithdrawals;
440
+ return this.cachedBuilderPendingWithdrawals;
441
441
  }
442
442
 
443
443
  getBuilder(index: BuilderIndex): gloas.Builder {
@@ -588,11 +588,11 @@ export class BeaconStateView implements IBeaconStateViewLatestFork {
588
588
  throw new Error("currentSyncCommittee is not available before Altair");
589
589
  }
590
590
 
591
- if (this._currentSyncCommittee === null) {
592
- this._currentSyncCommittee = (this.cachedState as CachedBeaconStateAltair).currentSyncCommittee.toValue();
591
+ if (this.cachedCurrentSyncCommittee === null) {
592
+ this.cachedCurrentSyncCommittee = (this.cachedState as CachedBeaconStateAltair).currentSyncCommittee.toValue();
593
593
  }
594
594
 
595
- return this._currentSyncCommittee;
595
+ return this.cachedCurrentSyncCommittee;
596
596
  }
597
597
 
598
598
  get nextSyncCommittee(): SyncCommittee {
@@ -600,11 +600,11 @@ export class BeaconStateView implements IBeaconStateViewLatestFork {
600
600
  throw new Error("nextSyncCommittee is not available before Altair");
601
601
  }
602
602
 
603
- if (this._nextSyncCommittee === null) {
604
- this._nextSyncCommittee = (this.cachedState as CachedBeaconStateAltair).nextSyncCommittee.toValue();
603
+ if (this.cachedNextSyncCommittee === null) {
604
+ this.cachedNextSyncCommittee = (this.cachedState as CachedBeaconStateAltair).nextSyncCommittee.toValue();
605
605
  }
606
606
 
607
- return this._nextSyncCommittee;
607
+ return this.cachedNextSyncCommittee;
608
608
  }
609
609
 
610
610
  get currentSyncCommitteeIndexed(): SyncCommitteeCache {
@@ -872,7 +872,7 @@ export class BeaconStateView implements IBeaconStateViewLatestFork {
872
872
 
873
873
  // State transition
874
874
 
875
- computeNewStateRoot({block}: ComputeNewStateRootInput, modules: StateTransitionModules): ComputeNewStateRootResult {
875
+ computeNewStateRoot({block}: BlockSTFInput, modules: StateTransitionModules): ComputeNewStateRootResult {
876
876
  const postState = new BeaconStateView(
877
877
  stateTransition(this.cachedState, block, computeNewStateRootStateTransitionOpts, modules)
878
878
  );
@@ -880,12 +880,11 @@ export class BeaconStateView implements IBeaconStateViewLatestFork {
880
880
  }
881
881
 
882
882
  stateTransition(
883
- signedBlock: SignedBeaconBlock | SignedBlindedBeaconBlock,
883
+ {block}: BlockSTFInput,
884
884
  options: StateTransitionOpts,
885
- {metrics, validatorMonitor}: StateTransitionModules
885
+ modules: StateTransitionModules
886
886
  ): IBeaconStateView {
887
- const newState = stateTransition(this.cachedState, signedBlock, options, {metrics, validatorMonitor});
888
- return new BeaconStateView(newState);
887
+ return new BeaconStateView(stateTransition(this.cachedState, block, options, modules));
889
888
  }
890
889
 
891
890
  processSlots(slot: Slot, opts?: {dontTransferCache?: boolean}, modules?: StateTransitionModules): IBeaconStateView {