@lodestar/state-transition 1.50.0-dev.033e6b7138 → 1.50.0-dev.040a952dd7

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 (68) 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 +10 -17
  35. package/lib/stateView/stateViewFactory.d.ts.map +1 -1
  36. package/lib/stateView/stateViewFactory.js +17 -13
  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 -0
  43. package/lib/util/index.d.ts.map +1 -1
  44. package/lib/util/index.js +1 -0
  45. package/lib/util/index.js.map +1 -1
  46. package/lib/util/sszBytes.d.ts +16 -17
  47. package/lib/util/sszBytes.d.ts.map +1 -1
  48. package/lib/util/sszBytes.js +93 -20
  49. package/lib/util/sszBytes.js.map +1 -1
  50. package/lib/util/weakSubjectivity.d.ts +11 -6
  51. package/lib/util/weakSubjectivity.d.ts.map +1 -1
  52. package/lib/util/weakSubjectivity.js +22 -28
  53. package/lib/util/weakSubjectivity.js.map +1 -1
  54. package/package.json +7 -7
  55. package/src/block/indexedBuilderState.ts +65 -0
  56. package/src/block/processBuilderDepositRequest.ts +6 -17
  57. package/src/block/processBuilderExitRequest.ts +5 -9
  58. package/src/block/processParentExecutionPayload.ts +27 -23
  59. package/src/index.ts +4 -1
  60. package/src/rewards/attestationsRewards.ts +8 -1
  61. package/src/stateView/beaconStateView.ts +75 -76
  62. package/src/stateView/interface.ts +61 -21
  63. package/src/stateView/nativeBeaconStateView.ts +354 -375
  64. package/src/stateView/stateViewFactory.ts +29 -27
  65. package/src/util/gloas.ts +2 -53
  66. package/src/util/index.ts +6 -0
  67. package/src/util/sszBytes.ts +129 -22
  68. package/src/util/weakSubjectivity.ts +43 -40
@@ -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 {
@@ -55,10 +55,13 @@ import {StateTransitionModules, StateTransitionOpts} from "../stateTransition.js
55
55
  import {EpochShuffling} from "../util/epochShuffling.js";
56
56
  import {PreVerifyBuilderDepositsResult} from "../util/preVerifyBuilderDeposits.js";
57
57
 
58
- /** Inputs for computing the state root of a locally produced block. */
59
- export type ComputeNewStateRootInput = {
58
+ /** Signed block to apply in a state transition. */
59
+ export type BlockSTFInput = {
60
60
  block: SignedBeaconBlock | SignedBlindedBeaconBlock;
61
- /** Pre-serialized block bytes for native implementations. */
61
+ /**
62
+ * Fork-specific SSZ serialization of `block`, using the matching full or blinded block type. Native
63
+ * implementations serialize `block` when omitted.
64
+ */
62
65
  ssz?: Uint8Array;
63
66
  };
64
67
 
@@ -159,6 +162,13 @@ export interface IBeaconStateView {
159
162
  // TODO is there a better name that is less implementation specific but still conveys the meaning?
160
163
  isStateValidatorsNodesPopulated(): boolean;
161
164
 
165
+ // Lifecycle
166
+ /**
167
+ * Release resources owned by this view.
168
+ * Do not use the view after calling this method.
169
+ */
170
+ release(): void;
171
+
162
172
  // Serialization
163
173
  /** Set `preloadValidatorsAndBalances` only when the whole state will be consumed
164
174
  * immediately (e.g. CP reload before block replay). */
@@ -178,9 +188,9 @@ export interface IBeaconStateView {
178
188
  hashTreeRoot(): Uint8Array;
179
189
 
180
190
  // State transition
181
- computeNewStateRoot(input: ComputeNewStateRootInput, modules: StateTransitionModules): ComputeNewStateRootResult;
191
+ computeNewStateRoot(input: BlockSTFInput, modules: StateTransitionModules): ComputeNewStateRootResult;
182
192
  stateTransition(
183
- signedBlock: SignedBeaconBlock | SignedBlindedBeaconBlock,
193
+ input: BlockSTFInput,
184
194
  options: StateTransitionOpts,
185
195
  modules: StateTransitionModules
186
196
  ): IBeaconStateView;
@@ -317,33 +327,63 @@ export type IBeaconStateViewLatestFork = Omit<
317
327
  /**
318
328
  * Contract a BeaconStateView backing implementation must satisfy.
319
329
  *
320
- * Differs from `IBeaconStateViewLatestFork` in two ways:
321
- * - `executionPayloadAvailability` is a raw `{uint8Array, bitLen}` POJO — a
322
- * native (`.node`) binding cannot construct a `BitArray` across FFI.
323
- * `NativeBeaconStateView` lifts it back to `BitArray` for beacon-node.
324
- * - Methods that produce another view (`stateTransition`, `processSlots`,
325
- * `loadOtherState`, `withParentPayloadApplied`) return `IBeaconStateViewNative`
326
- * so callers can re-wrap without an `as unknown` cast. Param lists are reused
327
- * via `Parameters<...>` to avoid duplicating signatures.
328
- * - `computeNewStateRoot` is implemented by the wrapper because its inputs differ
329
- * between the TypeScript and Zig implementations.
330
- *
331
- * The TS-side `BeaconStateView` also structurally satisfies this contract since
332
- * `BitArray` exposes `uint8Array` and `bitLen`.
330
+ * Differs from `IBeaconStateViewLatestFork` in these ways:
331
+ * - SSZ-backed lists use serialized bytes or native typed arrays at the FFI boundary.
332
+ * - Methods that produce another view return `IBeaconStateViewNative` so callers can re-wrap them.
333
+ * - `stateTransition` accepts the native block inputs and omits JS-only modules.
334
+ * - `computeNewStateRoot` is implemented by the wrapper because its inputs differ between implementations.
333
335
  */
334
336
  export type IBeaconStateViewNative = Omit<
335
337
  IBeaconStateViewLatestFork,
338
+ | "builderPendingPayments"
339
+ | "builderPendingWithdrawals"
340
+ | "computeAttestationsRewards"
341
+ | "computeBlockRewards"
336
342
  | "computeNewStateRoot"
343
+ | "computeSyncCommitteeRewards"
344
+ | "eth1Data"
337
345
  | "executionPayloadAvailability"
346
+ | "getBeaconCommittee"
347
+ | "getIndicesInPayloadTimelinessCommittee"
348
+ | "getPayloadTimelinessCommittee"
338
349
  | "loadOtherState"
339
- | "stateTransition"
350
+ | "pendingConsolidations"
351
+ | "pendingDeposits"
352
+ | "pendingPartialWithdrawals"
353
+ | "preVerifyBuilderDepositsPreGloas"
354
+ | "clearPreGloasBuilderDepositCache"
340
355
  | "processSlots"
356
+ | "proposerLookahead"
357
+ | "stateTransition"
341
358
  | "withParentPayloadApplied"
342
359
  > & {
360
+ pendingDeposits: Uint8Array;
361
+ pendingPartialWithdrawals: Uint8Array;
362
+ pendingConsolidations: Uint8Array;
363
+ proposerLookahead: Uint32Array;
364
+ // UintBn64 lowers to number across the FFI boundary; the wrapper lifts it back to bigint
365
+ eth1Data: phase0.Eth1Data;
343
366
  executionPayloadAvailability: {uint8Array: Uint8Array; bitLen: number};
367
+ computeBlockRewards(
368
+ signedBlockBytes: Uint8Array,
369
+ isBlinded: boolean,
370
+ proposerRewards?: RewardCache
371
+ ): rewards.BlockRewards;
372
+ computeAttestationsRewards(validatorIds?: (ValidatorIndex | string)[]): rewards.AttestationsRewards;
373
+ computeSyncCommitteeRewards(
374
+ block: BeaconBlock,
375
+ validatorIds: (ValidatorIndex | string)[]
376
+ ): rewards.SyncCommitteeRewards;
377
+ getBeaconCommittee(slot: Slot, index: CommitteeIndex): Uint32Array;
378
+ getIndexInPayloadTimelinessCommittee?(validatorIndex: ValidatorIndex, slot: Slot): number;
379
+ getIndicesInPayloadTimelinessCommittee?(validatorIndex: ValidatorIndex, slot: Slot): number[];
344
380
  loadOtherState(...args: Parameters<IBeaconStateViewLatestFork["loadOtherState"]>): IBeaconStateViewNative;
345
- stateTransition(...args: Parameters<IBeaconStateViewLatestFork["stateTransition"]>): IBeaconStateViewNative;
346
- processSlots(...args: Parameters<IBeaconStateViewLatestFork["processSlots"]>): IBeaconStateViewNative;
381
+ stateTransition(
382
+ signedBlockBytes: Uint8Array,
383
+ isBlinded: boolean,
384
+ options?: StateTransitionOpts
385
+ ): IBeaconStateViewNative;
386
+ processSlots(slot: Slot, opts?: {dontTransferCache?: boolean}): IBeaconStateViewNative;
347
387
  withParentPayloadApplied(
348
388
  ...args: Parameters<IBeaconStateViewLatestFork["withParentPayloadApplied"]>
349
389
  ): IBeaconStateViewNative;