@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.
- package/lib/block/indexedBuilderState.d.ts +19 -0
- package/lib/block/indexedBuilderState.d.ts.map +1 -0
- package/lib/block/indexedBuilderState.js +60 -0
- package/lib/block/indexedBuilderState.js.map +1 -0
- package/lib/block/processBuilderDepositRequest.d.ts +2 -2
- package/lib/block/processBuilderDepositRequest.d.ts.map +1 -1
- package/lib/block/processBuilderDepositRequest.js +5 -4
- package/lib/block/processBuilderDepositRequest.js.map +1 -1
- package/lib/block/processBuilderExitRequest.d.ts +2 -2
- package/lib/block/processBuilderExitRequest.d.ts.map +1 -1
- package/lib/block/processBuilderExitRequest.js +4 -3
- package/lib/block/processBuilderExitRequest.js.map +1 -1
- package/lib/block/processParentExecutionPayload.d.ts.map +1 -1
- package/lib/block/processParentExecutionPayload.js +23 -18
- package/lib/block/processParentExecutionPayload.js.map +1 -1
- package/lib/index.d.ts +3 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -1
- package/lib/rewards/attestationsRewards.d.ts.map +1 -1
- package/lib/rewards/attestationsRewards.js +15 -6
- package/lib/rewards/attestationsRewards.js.map +1 -1
- package/lib/stateView/beaconStateView.d.ts +24 -19
- package/lib/stateView/beaconStateView.d.ts.map +1 -1
- package/lib/stateView/beaconStateView.js +83 -63
- package/lib/stateView/beaconStateView.js.map +1 -1
- package/lib/stateView/interface.d.ts +36 -21
- package/lib/stateView/interface.d.ts.map +1 -1
- package/lib/stateView/interface.js.map +1 -1
- package/lib/stateView/nativeBeaconStateView.d.ts +94 -98
- package/lib/stateView/nativeBeaconStateView.d.ts.map +1 -1
- package/lib/stateView/nativeBeaconStateView.js +343 -358
- package/lib/stateView/nativeBeaconStateView.js.map +1 -1
- package/lib/stateView/stateViewFactory.d.ts +10 -17
- package/lib/stateView/stateViewFactory.d.ts.map +1 -1
- package/lib/stateView/stateViewFactory.js +17 -13
- package/lib/stateView/stateViewFactory.js.map +1 -1
- package/lib/util/gloas.d.ts +11 -14
- package/lib/util/gloas.d.ts.map +1 -1
- package/lib/util/gloas.js +2 -42
- package/lib/util/gloas.js.map +1 -1
- package/lib/util/index.d.ts +1 -0
- package/lib/util/index.d.ts.map +1 -1
- package/lib/util/index.js +1 -0
- package/lib/util/index.js.map +1 -1
- package/lib/util/sszBytes.d.ts +16 -17
- package/lib/util/sszBytes.d.ts.map +1 -1
- package/lib/util/sszBytes.js +93 -20
- package/lib/util/sszBytes.js.map +1 -1
- package/lib/util/weakSubjectivity.d.ts +11 -6
- package/lib/util/weakSubjectivity.d.ts.map +1 -1
- package/lib/util/weakSubjectivity.js +22 -28
- package/lib/util/weakSubjectivity.js.map +1 -1
- package/package.json +7 -7
- package/src/block/indexedBuilderState.ts +65 -0
- package/src/block/processBuilderDepositRequest.ts +6 -17
- package/src/block/processBuilderExitRequest.ts +5 -9
- package/src/block/processParentExecutionPayload.ts +27 -23
- package/src/index.ts +4 -1
- package/src/rewards/attestationsRewards.ts +17 -5
- package/src/stateView/beaconStateView.ts +93 -68
- package/src/stateView/interface.ts +63 -21
- package/src/stateView/nativeBeaconStateView.ts +360 -365
- package/src/stateView/stateViewFactory.ts +29 -27
- package/src/util/gloas.ts +2 -53
- package/src/util/index.ts +6 -0
- package/src/util/sszBytes.ts +129 -22
- 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
|
-
|
|
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
|
|
87
|
-
private
|
|
84
|
+
private cachedFork: Fork | null = null;
|
|
85
|
+
private cachedLatestBlockHeader: phase0.BeaconBlockHeader | null = null;
|
|
88
86
|
// altair
|
|
89
|
-
private
|
|
90
|
-
private
|
|
91
|
-
private
|
|
92
|
-
private
|
|
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
|
|
92
|
+
private cachedLatestExecutionPayloadHeader: ExecutionPayloadHeader | null = null;
|
|
95
93
|
// capella
|
|
96
|
-
private
|
|
94
|
+
private cachedHistoricalSummaries: capella.HistoricalSummaries | null = null;
|
|
97
95
|
// electra
|
|
98
|
-
private
|
|
99
|
-
private
|
|
100
|
-
private
|
|
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
|
|
100
|
+
private cachedProposerLookahead: fulu.ProposerLookahead | null = null;
|
|
103
101
|
// gloas
|
|
104
|
-
private
|
|
105
|
-
private
|
|
106
|
-
private
|
|
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.
|
|
128
|
-
this.
|
|
129
|
+
if (this.cachedFork === null) {
|
|
130
|
+
this.cachedFork = this.cachedState.fork.toValue();
|
|
129
131
|
}
|
|
130
|
-
return this.
|
|
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.
|
|
151
|
-
this.
|
|
152
|
+
if (this.cachedLatestBlockHeader === null) {
|
|
153
|
+
this.cachedLatestBlockHeader = this.cachedState.latestBlockHeader.toValue();
|
|
152
154
|
}
|
|
153
|
-
return this.
|
|
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.
|
|
190
|
-
this.
|
|
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.
|
|
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.
|
|
206
|
-
this.
|
|
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.
|
|
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.
|
|
240
|
-
this.
|
|
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.
|
|
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.
|
|
272
|
-
this.
|
|
273
|
+
if (this.cachedHistoricalSummaries === null) {
|
|
274
|
+
this.cachedHistoricalSummaries = (this.cachedState as CachedBeaconStateCapella).historicalSummaries.toValue();
|
|
273
275
|
}
|
|
274
276
|
|
|
275
|
-
return this.
|
|
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.
|
|
286
|
-
this.
|
|
287
|
+
if (this.cachedPendingDeposits === null) {
|
|
288
|
+
this.cachedPendingDeposits = (this.cachedState as CachedBeaconStateElectra).pendingDeposits.toValue();
|
|
287
289
|
}
|
|
288
290
|
|
|
289
|
-
return this.
|
|
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.
|
|
306
|
-
this.
|
|
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.
|
|
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.
|
|
328
|
-
this.
|
|
329
|
+
if (this.cachedPendingConsolidations === null) {
|
|
330
|
+
this.cachedPendingConsolidations = (this.cachedState as CachedBeaconStateElectra).pendingConsolidations.toValue();
|
|
329
331
|
}
|
|
330
332
|
|
|
331
|
-
return this.
|
|
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.
|
|
350
|
-
this.
|
|
351
|
+
if (this.cachedProposerLookahead === null) {
|
|
352
|
+
this.cachedProposerLookahead = (this.cachedState as CachedBeaconStateFulu).proposerLookahead.toValue();
|
|
351
353
|
}
|
|
352
354
|
|
|
353
|
-
return this.
|
|
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.
|
|
383
|
-
this.
|
|
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.
|
|
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.
|
|
397
|
-
this.
|
|
398
|
+
if (this.cachedLatestExecutionPayloadBid === null) {
|
|
399
|
+
this.cachedLatestExecutionPayloadBid = (
|
|
398
400
|
this.cachedState as CachedBeaconStateGloas
|
|
399
401
|
).latestExecutionPayloadBid.toValue();
|
|
400
402
|
}
|
|
401
|
-
return this.
|
|
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.
|
|
410
|
-
this.
|
|
411
|
+
if (this.cachedPayloadExpectedWithdrawals === null) {
|
|
412
|
+
this.cachedPayloadExpectedWithdrawals = (
|
|
411
413
|
this.cachedState as CachedBeaconStateGloas
|
|
412
414
|
).payloadExpectedWithdrawals.toValue();
|
|
413
415
|
}
|
|
414
|
-
return this.
|
|
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.
|
|
566
|
-
this.
|
|
591
|
+
if (this.cachedCurrentSyncCommittee === null) {
|
|
592
|
+
this.cachedCurrentSyncCommittee = (this.cachedState as CachedBeaconStateAltair).currentSyncCommittee.toValue();
|
|
567
593
|
}
|
|
568
594
|
|
|
569
|
-
return this.
|
|
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.
|
|
578
|
-
this.
|
|
603
|
+
if (this.cachedNextSyncCommittee === null) {
|
|
604
|
+
this.cachedNextSyncCommittee = (this.cachedState as CachedBeaconStateAltair).nextSyncCommittee.toValue();
|
|
579
605
|
}
|
|
580
606
|
|
|
581
|
-
return this.
|
|
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}:
|
|
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
|
-
|
|
883
|
+
{block}: BlockSTFInput,
|
|
858
884
|
options: StateTransitionOpts,
|
|
859
|
-
|
|
885
|
+
modules: StateTransitionModules
|
|
860
886
|
): IBeaconStateView {
|
|
861
|
-
|
|
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
|
-
/**
|
|
59
|
-
export type
|
|
58
|
+
/** Signed block to apply in a state transition. */
|
|
59
|
+
export type BlockSTFInput = {
|
|
60
60
|
block: SignedBeaconBlock | SignedBlindedBeaconBlock;
|
|
61
|
-
/**
|
|
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:
|
|
191
|
+
computeNewStateRoot(input: BlockSTFInput, modules: StateTransitionModules): ComputeNewStateRootResult;
|
|
182
192
|
stateTransition(
|
|
183
|
-
|
|
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
|
|
319
|
-
* -
|
|
320
|
-
*
|
|
321
|
-
*
|
|
322
|
-
* -
|
|
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
|
-
| "
|
|
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(
|
|
344
|
-
|
|
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;
|