@lodestar/state-transition 1.49.0-rc.0 → 1.50.0-dev.01cc10ce70

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 +15 -6
  22. package/lib/rewards/attestationsRewards.js.map +1 -1
  23. package/lib/stateView/beaconStateView.d.ts +24 -19
  24. package/lib/stateView/beaconStateView.d.ts.map +1 -1
  25. package/lib/stateView/beaconStateView.js +83 -63
  26. package/lib/stateView/beaconStateView.js.map +1 -1
  27. package/lib/stateView/interface.d.ts +36 -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 +94 -98
  31. package/lib/stateView/nativeBeaconStateView.d.ts.map +1 -1
  32. package/lib/stateView/nativeBeaconStateView.js +343 -358
  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 +17 -5
  61. package/src/stateView/beaconStateView.ts +93 -68
  62. package/src/stateView/interface.ts +63 -21
  63. package/src/stateView/nativeBeaconStateView.ts +360 -365
  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,32 +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;
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;
107
107
 
108
108
  constructor(readonly cachedState: CachedBeaconStateAllForks) {
109
109
  this.config = cachedState.config;
110
110
  }
111
111
 
112
+ release(): void {}
113
+
112
114
  // phase0
113
115
 
114
116
  get forkName(): ForkName {
@@ -124,10 +126,10 @@ export class BeaconStateView implements IBeaconStateViewLatestFork {
124
126
  }
125
127
 
126
128
  get fork(): Fork {
127
- if (this._fork === null) {
128
- this._fork = this.cachedState.fork.toValue();
129
+ if (this.cachedFork === null) {
130
+ this.cachedFork = this.cachedState.fork.toValue();
129
131
  }
130
- return this._fork;
132
+ return this.cachedFork;
131
133
  }
132
134
 
133
135
  get epoch(): number {
@@ -147,10 +149,10 @@ export class BeaconStateView implements IBeaconStateViewLatestFork {
147
149
  }
148
150
 
149
151
  get latestBlockHeader(): phase0.BeaconBlockHeader {
150
- if (this._latestBlockHeader === null) {
151
- this._latestBlockHeader = this.cachedState.latestBlockHeader.toValue();
152
+ if (this.cachedLatestBlockHeader === null) {
153
+ this.cachedLatestBlockHeader = this.cachedState.latestBlockHeader.toValue();
152
154
  }
153
- return this._latestBlockHeader;
155
+ return this.cachedLatestBlockHeader;
154
156
  }
155
157
 
156
158
  get previousJustifiedCheckpoint(): Checkpoint {
@@ -186,13 +188,13 @@ export class BeaconStateView implements IBeaconStateViewLatestFork {
186
188
  throw new Error("previousEpochParticipation is not available before Altair");
187
189
  }
188
190
 
189
- if (this._previousEpochParticipation === null) {
190
- this._previousEpochParticipation = (
191
+ if (this.cachedPreviousEpochParticipation === null) {
192
+ this.cachedPreviousEpochParticipation = (
191
193
  this.cachedState as CachedBeaconStateAltair
192
194
  ).previousEpochParticipation.serialize();
193
195
  }
194
196
 
195
- return this._previousEpochParticipation;
197
+ return this.cachedPreviousEpochParticipation;
196
198
  }
197
199
 
198
200
  // altair
@@ -202,13 +204,13 @@ export class BeaconStateView implements IBeaconStateViewLatestFork {
202
204
  throw new Error("currentEpochParticipation is not available before Altair");
203
205
  }
204
206
 
205
- if (this._currentEpochParticipation === null) {
206
- this._currentEpochParticipation = (
207
+ if (this.cachedCurrentEpochParticipation === null) {
208
+ this.cachedCurrentEpochParticipation = (
207
209
  this.cachedState as CachedBeaconStateAltair
208
210
  ).currentEpochParticipation.serialize();
209
211
  }
210
212
 
211
- return this._currentEpochParticipation;
213
+ return this.cachedCurrentEpochParticipation;
212
214
  }
213
215
 
214
216
  getPreviousEpochParticipation(validatorIndex: ValidatorIndex): number {
@@ -236,13 +238,13 @@ export class BeaconStateView implements IBeaconStateViewLatestFork {
236
238
  throw new Error("latestExecutionPayloadHeader is not available after Gloas");
237
239
  }
238
240
 
239
- if (this._latestExecutionPayloadHeader === null) {
240
- this._latestExecutionPayloadHeader = (
241
+ if (this.cachedLatestExecutionPayloadHeader === null) {
242
+ this.cachedLatestExecutionPayloadHeader = (
241
243
  this.cachedState as CachedBeaconStateExecutions
242
244
  ).latestExecutionPayloadHeader.toValue();
243
245
  }
244
246
 
245
- return this._latestExecutionPayloadHeader;
247
+ return this.cachedLatestExecutionPayloadHeader;
246
248
  }
247
249
 
248
250
  /**
@@ -268,11 +270,11 @@ export class BeaconStateView implements IBeaconStateViewLatestFork {
268
270
  throw new Error("Historical summaries are not supported before Capella");
269
271
  }
270
272
 
271
- if (this._historicalSummaries === null) {
272
- this._historicalSummaries = (this.cachedState as CachedBeaconStateCapella).historicalSummaries.toValue();
273
+ if (this.cachedHistoricalSummaries === null) {
274
+ this.cachedHistoricalSummaries = (this.cachedState as CachedBeaconStateCapella).historicalSummaries.toValue();
273
275
  }
274
276
 
275
- return this._historicalSummaries;
277
+ return this.cachedHistoricalSummaries;
276
278
  }
277
279
 
278
280
  // electra
@@ -282,11 +284,11 @@ export class BeaconStateView implements IBeaconStateViewLatestFork {
282
284
  throw new Error("Pending deposits are not supported before Electra");
283
285
  }
284
286
 
285
- if (this._pendingDeposits === null) {
286
- this._pendingDeposits = (this.cachedState as CachedBeaconStateElectra).pendingDeposits.toValue();
287
+ if (this.cachedPendingDeposits === null) {
288
+ this.cachedPendingDeposits = (this.cachedState as CachedBeaconStateElectra).pendingDeposits.toValue();
287
289
  }
288
290
 
289
- return this._pendingDeposits;
291
+ return this.cachedPendingDeposits;
290
292
  }
291
293
 
292
294
  get pendingDepositsCount(): number {
@@ -302,13 +304,13 @@ export class BeaconStateView implements IBeaconStateViewLatestFork {
302
304
  throw new Error("Pending partial withdrawals are not supported before Electra");
303
305
  }
304
306
 
305
- if (this._pendingPartialWithdrawals === null) {
306
- this._pendingPartialWithdrawals = (
307
+ if (this.cachedPendingPartialWithdrawals === null) {
308
+ this.cachedPendingPartialWithdrawals = (
307
309
  this.cachedState as CachedBeaconStateElectra
308
310
  ).pendingPartialWithdrawals.toValue();
309
311
  }
310
312
 
311
- return this._pendingPartialWithdrawals;
313
+ return this.cachedPendingPartialWithdrawals;
312
314
  }
313
315
 
314
316
  get pendingPartialWithdrawalsCount(): number {
@@ -324,11 +326,11 @@ export class BeaconStateView implements IBeaconStateViewLatestFork {
324
326
  throw new Error("Pending consolidations are not supported before Electra");
325
327
  }
326
328
 
327
- if (this._pendingConsolidations === null) {
328
- this._pendingConsolidations = (this.cachedState as CachedBeaconStateElectra).pendingConsolidations.toValue();
329
+ if (this.cachedPendingConsolidations === null) {
330
+ this.cachedPendingConsolidations = (this.cachedState as CachedBeaconStateElectra).pendingConsolidations.toValue();
329
331
  }
330
332
 
331
- return this._pendingConsolidations;
333
+ return this.cachedPendingConsolidations;
332
334
  }
333
335
 
334
336
  get pendingConsolidationsCount(): number {
@@ -346,11 +348,11 @@ export class BeaconStateView implements IBeaconStateViewLatestFork {
346
348
  throw new Error("Proposer lookahead is not supported before Fulu");
347
349
  }
348
350
 
349
- if (this._proposerLookahead === null) {
350
- this._proposerLookahead = (this.cachedState as CachedBeaconStateFulu).proposerLookahead.toValue();
351
+ if (this.cachedProposerLookahead === null) {
352
+ this.cachedProposerLookahead = (this.cachedState as CachedBeaconStateFulu).proposerLookahead.toValue();
351
353
  }
352
354
 
353
- return this._proposerLookahead;
355
+ return this.cachedProposerLookahead;
354
356
  }
355
357
 
356
358
  preVerifyBuilderDepositsPreGloas(maxBuilderDeposits: number, maxDurationMs: number): PreVerifyBuilderDepositsResult {
@@ -379,13 +381,13 @@ export class BeaconStateView implements IBeaconStateViewLatestFork {
379
381
  throw new Error("executionPayloadAvailability is not available before Gloas");
380
382
  }
381
383
 
382
- if (this._executionPayloadAvailability === null) {
383
- this._executionPayloadAvailability = (
384
+ if (this.cachedExecutionPayloadAvailability === null) {
385
+ this.cachedExecutionPayloadAvailability = (
384
386
  this.cachedState as CachedBeaconStateGloas
385
387
  ).executionPayloadAvailability.toValue();
386
388
  }
387
389
 
388
- return this._executionPayloadAvailability;
390
+ return this.cachedExecutionPayloadAvailability;
389
391
  }
390
392
 
391
393
  get latestExecutionPayloadBid(): ExecutionPayloadBid {
@@ -393,12 +395,12 @@ export class BeaconStateView implements IBeaconStateViewLatestFork {
393
395
  throw new Error("latestExecutionPayloadBid is not available before Gloas");
394
396
  }
395
397
 
396
- if (this._latestExecutionPayloadBid === null) {
397
- this._latestExecutionPayloadBid = (
398
+ if (this.cachedLatestExecutionPayloadBid === null) {
399
+ this.cachedLatestExecutionPayloadBid = (
398
400
  this.cachedState as CachedBeaconStateGloas
399
401
  ).latestExecutionPayloadBid.toValue();
400
402
  }
401
- return this._latestExecutionPayloadBid;
403
+ return this.cachedLatestExecutionPayloadBid;
402
404
  }
403
405
 
404
406
  get payloadExpectedWithdrawals(): capella.Withdrawal[] {
@@ -406,12 +408,36 @@ export class BeaconStateView implements IBeaconStateViewLatestFork {
406
408
  throw new Error("payloadExpectedWithdrawals is not available before Gloas");
407
409
  }
408
410
 
409
- if (this._payloadExpectedWithdrawals === null) {
410
- this._payloadExpectedWithdrawals = (
411
+ if (this.cachedPayloadExpectedWithdrawals === null) {
412
+ this.cachedPayloadExpectedWithdrawals = (
411
413
  this.cachedState as CachedBeaconStateGloas
412
414
  ).payloadExpectedWithdrawals.toValue();
413
415
  }
414
- return this._payloadExpectedWithdrawals;
416
+ return this.cachedPayloadExpectedWithdrawals;
417
+ }
418
+
419
+ get builderPendingPayments(): gloas.BuilderPendingPayments {
420
+ if (this.config.getForkSeq(this.cachedState.slot) < ForkSeq.gloas) {
421
+ throw new Error("Pending builder payments are not supported before Gloas");
422
+ }
423
+
424
+ if (this.cachedBuilderPendingPayments === null) {
425
+ this.cachedBuilderPendingPayments = (this.cachedState as CachedBeaconStateGloas).builderPendingPayments.toValue();
426
+ }
427
+ return this.cachedBuilderPendingPayments;
428
+ }
429
+
430
+ get builderPendingWithdrawals(): gloas.BuilderPendingWithdrawals {
431
+ if (this.config.getForkSeq(this.cachedState.slot) < ForkSeq.gloas) {
432
+ throw new Error("Pending builder withdrawals are not supported before Gloas");
433
+ }
434
+
435
+ if (this.cachedBuilderPendingWithdrawals === null) {
436
+ this.cachedBuilderPendingWithdrawals = (
437
+ this.cachedState as CachedBeaconStateGloas
438
+ ).builderPendingWithdrawals.toValue();
439
+ }
440
+ return this.cachedBuilderPendingWithdrawals;
415
441
  }
416
442
 
417
443
  getBuilder(index: BuilderIndex): gloas.Builder {
@@ -562,11 +588,11 @@ export class BeaconStateView implements IBeaconStateViewLatestFork {
562
588
  throw new Error("currentSyncCommittee is not available before Altair");
563
589
  }
564
590
 
565
- if (this._currentSyncCommittee === null) {
566
- this._currentSyncCommittee = (this.cachedState as CachedBeaconStateAltair).currentSyncCommittee.toValue();
591
+ if (this.cachedCurrentSyncCommittee === null) {
592
+ this.cachedCurrentSyncCommittee = (this.cachedState as CachedBeaconStateAltair).currentSyncCommittee.toValue();
567
593
  }
568
594
 
569
- return this._currentSyncCommittee;
595
+ return this.cachedCurrentSyncCommittee;
570
596
  }
571
597
 
572
598
  get nextSyncCommittee(): SyncCommittee {
@@ -574,11 +600,11 @@ export class BeaconStateView implements IBeaconStateViewLatestFork {
574
600
  throw new Error("nextSyncCommittee is not available before Altair");
575
601
  }
576
602
 
577
- if (this._nextSyncCommittee === null) {
578
- this._nextSyncCommittee = (this.cachedState as CachedBeaconStateAltair).nextSyncCommittee.toValue();
603
+ if (this.cachedNextSyncCommittee === null) {
604
+ this.cachedNextSyncCommittee = (this.cachedState as CachedBeaconStateAltair).nextSyncCommittee.toValue();
579
605
  }
580
606
 
581
- return this._nextSyncCommittee;
607
+ return this.cachedNextSyncCommittee;
582
608
  }
583
609
 
584
610
  get currentSyncCommitteeIndexed(): SyncCommitteeCache {
@@ -846,7 +872,7 @@ export class BeaconStateView implements IBeaconStateViewLatestFork {
846
872
 
847
873
  // State transition
848
874
 
849
- computeNewStateRoot({block}: ComputeNewStateRootInput, modules: StateTransitionModules): ComputeNewStateRootResult {
875
+ computeNewStateRoot({block}: BlockSTFInput, modules: StateTransitionModules): ComputeNewStateRootResult {
850
876
  const postState = new BeaconStateView(
851
877
  stateTransition(this.cachedState, block, computeNewStateRootStateTransitionOpts, modules)
852
878
  );
@@ -854,12 +880,11 @@ export class BeaconStateView implements IBeaconStateViewLatestFork {
854
880
  }
855
881
 
856
882
  stateTransition(
857
- signedBlock: SignedBeaconBlock | SignedBlindedBeaconBlock,
883
+ {block}: BlockSTFInput,
858
884
  options: StateTransitionOpts,
859
- {metrics, validatorMonitor}: StateTransitionModules
885
+ modules: StateTransitionModules
860
886
  ): IBeaconStateView {
861
- const newState = stateTransition(this.cachedState, signedBlock, options, {metrics, validatorMonitor});
862
- return new BeaconStateView(newState);
887
+ return new BeaconStateView(stateTransition(this.cachedState, block, options, modules));
863
888
  }
864
889
 
865
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;
@@ -277,6 +287,8 @@ export interface IBeaconStateViewGloas extends IBeaconStateViewFulu {
277
287
  executionPayloadAvailability: BitArray;
278
288
  latestExecutionPayloadBid: ExecutionPayloadBid;
279
289
  payloadExpectedWithdrawals: capella.Withdrawal[];
290
+ builderPendingPayments: gloas.BuilderPendingPayments;
291
+ builderPendingWithdrawals: gloas.BuilderPendingWithdrawals;
280
292
  getBuilder(index: BuilderIndex): gloas.Builder;
281
293
  getBuildersLength(): number;
282
294
  canBuilderCoverBid(builderIndex: BuilderIndex, bidAmount: number): boolean;
@@ -315,33 +327,63 @@ export type IBeaconStateViewLatestFork = Omit<
315
327
  /**
316
328
  * Contract a BeaconStateView backing implementation must satisfy.
317
329
  *
318
- * Differs from `IBeaconStateViewLatestFork` in two ways:
319
- * - `executionPayloadAvailability` is a raw `{uint8Array, bitLen}` POJO — a
320
- * native (`.node`) binding cannot construct a `BitArray` across FFI.
321
- * `NativeBeaconStateView` lifts it back to `BitArray` for beacon-node.
322
- * - Methods that produce another view (`stateTransition`, `processSlots`,
323
- * `loadOtherState`, `withParentPayloadApplied`) return `IBeaconStateViewNative`
324
- * so callers can re-wrap without an `as unknown` cast. Param lists are reused
325
- * via `Parameters<...>` to avoid duplicating signatures.
326
- * - `computeNewStateRoot` is implemented by the wrapper because its inputs differ
327
- * between the TypeScript and Zig implementations.
328
- *
329
- * The TS-side `BeaconStateView` also structurally satisfies this contract since
330
- * `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.
331
335
  */
332
336
  export type IBeaconStateViewNative = Omit<
333
337
  IBeaconStateViewLatestFork,
338
+ | "builderPendingPayments"
339
+ | "builderPendingWithdrawals"
340
+ | "computeAttestationsRewards"
341
+ | "computeBlockRewards"
334
342
  | "computeNewStateRoot"
343
+ | "computeSyncCommitteeRewards"
344
+ | "eth1Data"
335
345
  | "executionPayloadAvailability"
346
+ | "getBeaconCommittee"
347
+ | "getIndicesInPayloadTimelinessCommittee"
348
+ | "getPayloadTimelinessCommittee"
336
349
  | "loadOtherState"
337
- | "stateTransition"
350
+ | "pendingConsolidations"
351
+ | "pendingDeposits"
352
+ | "pendingPartialWithdrawals"
353
+ | "preVerifyBuilderDepositsPreGloas"
354
+ | "clearPreGloasBuilderDepositCache"
338
355
  | "processSlots"
356
+ | "proposerLookahead"
357
+ | "stateTransition"
339
358
  | "withParentPayloadApplied"
340
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;
341
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[];
342
380
  loadOtherState(...args: Parameters<IBeaconStateViewLatestFork["loadOtherState"]>): IBeaconStateViewNative;
343
- stateTransition(...args: Parameters<IBeaconStateViewLatestFork["stateTransition"]>): IBeaconStateViewNative;
344
- 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;
345
387
  withParentPayloadApplied(
346
388
  ...args: Parameters<IBeaconStateViewLatestFork["withParentPayloadApplied"]>
347
389
  ): IBeaconStateViewNative;