@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.
- 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 +8 -1
- package/lib/rewards/attestationsRewards.js.map +1 -1
- package/lib/stateView/beaconStateView.d.ts +22 -21
- package/lib/stateView/beaconStateView.d.ts.map +1 -1
- package/lib/stateView/beaconStateView.js +71 -71
- package/lib/stateView/beaconStateView.js.map +1 -1
- package/lib/stateView/interface.d.ts +34 -21
- package/lib/stateView/interface.d.ts.map +1 -1
- package/lib/stateView/interface.js.map +1 -1
- package/lib/stateView/nativeBeaconStateView.d.ts +92 -100
- package/lib/stateView/nativeBeaconStateView.d.ts.map +1 -1
- package/lib/stateView/nativeBeaconStateView.js +339 -368
- 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 +8 -1
- package/src/stateView/beaconStateView.ts +75 -76
- package/src/stateView/interface.ts +61 -21
- package/src/stateView/nativeBeaconStateView.ts +354 -375
- 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,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
|
|
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
|
|
107
|
-
private
|
|
108
|
-
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;
|
|
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.
|
|
130
|
-
this.
|
|
129
|
+
if (this.cachedFork === null) {
|
|
130
|
+
this.cachedFork = this.cachedState.fork.toValue();
|
|
131
131
|
}
|
|
132
|
-
return this.
|
|
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.
|
|
153
|
-
this.
|
|
152
|
+
if (this.cachedLatestBlockHeader === null) {
|
|
153
|
+
this.cachedLatestBlockHeader = this.cachedState.latestBlockHeader.toValue();
|
|
154
154
|
}
|
|
155
|
-
return this.
|
|
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.
|
|
192
|
-
this.
|
|
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.
|
|
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.
|
|
208
|
-
this.
|
|
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.
|
|
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.
|
|
242
|
-
this.
|
|
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.
|
|
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.
|
|
274
|
-
this.
|
|
273
|
+
if (this.cachedHistoricalSummaries === null) {
|
|
274
|
+
this.cachedHistoricalSummaries = (this.cachedState as CachedBeaconStateCapella).historicalSummaries.toValue();
|
|
275
275
|
}
|
|
276
276
|
|
|
277
|
-
return this.
|
|
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.
|
|
288
|
-
this.
|
|
287
|
+
if (this.cachedPendingDeposits === null) {
|
|
288
|
+
this.cachedPendingDeposits = (this.cachedState as CachedBeaconStateElectra).pendingDeposits.toValue();
|
|
289
289
|
}
|
|
290
290
|
|
|
291
|
-
return this.
|
|
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.
|
|
308
|
-
this.
|
|
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.
|
|
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.
|
|
330
|
-
this.
|
|
329
|
+
if (this.cachedPendingConsolidations === null) {
|
|
330
|
+
this.cachedPendingConsolidations = (this.cachedState as CachedBeaconStateElectra).pendingConsolidations.toValue();
|
|
331
331
|
}
|
|
332
332
|
|
|
333
|
-
return this.
|
|
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.
|
|
352
|
-
this.
|
|
351
|
+
if (this.cachedProposerLookahead === null) {
|
|
352
|
+
this.cachedProposerLookahead = (this.cachedState as CachedBeaconStateFulu).proposerLookahead.toValue();
|
|
353
353
|
}
|
|
354
354
|
|
|
355
|
-
return this.
|
|
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.
|
|
385
|
-
this.
|
|
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.
|
|
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.
|
|
399
|
-
this.
|
|
398
|
+
if (this.cachedLatestExecutionPayloadBid === null) {
|
|
399
|
+
this.cachedLatestExecutionPayloadBid = (
|
|
400
400
|
this.cachedState as CachedBeaconStateGloas
|
|
401
401
|
).latestExecutionPayloadBid.toValue();
|
|
402
402
|
}
|
|
403
|
-
return this.
|
|
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.
|
|
412
|
-
this.
|
|
411
|
+
if (this.cachedPayloadExpectedWithdrawals === null) {
|
|
412
|
+
this.cachedPayloadExpectedWithdrawals = (
|
|
413
413
|
this.cachedState as CachedBeaconStateGloas
|
|
414
414
|
).payloadExpectedWithdrawals.toValue();
|
|
415
415
|
}
|
|
416
|
-
return this.
|
|
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.
|
|
425
|
-
this.
|
|
424
|
+
if (this.cachedBuilderPendingPayments === null) {
|
|
425
|
+
this.cachedBuilderPendingPayments = (this.cachedState as CachedBeaconStateGloas).builderPendingPayments.toValue();
|
|
426
426
|
}
|
|
427
|
-
return this.
|
|
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.
|
|
436
|
-
this.
|
|
435
|
+
if (this.cachedBuilderPendingWithdrawals === null) {
|
|
436
|
+
this.cachedBuilderPendingWithdrawals = (
|
|
437
437
|
this.cachedState as CachedBeaconStateGloas
|
|
438
438
|
).builderPendingWithdrawals.toValue();
|
|
439
439
|
}
|
|
440
|
-
return this.
|
|
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.
|
|
592
|
-
this.
|
|
591
|
+
if (this.cachedCurrentSyncCommittee === null) {
|
|
592
|
+
this.cachedCurrentSyncCommittee = (this.cachedState as CachedBeaconStateAltair).currentSyncCommittee.toValue();
|
|
593
593
|
}
|
|
594
594
|
|
|
595
|
-
return this.
|
|
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.
|
|
604
|
-
this.
|
|
603
|
+
if (this.cachedNextSyncCommittee === null) {
|
|
604
|
+
this.cachedNextSyncCommittee = (this.cachedState as CachedBeaconStateAltair).nextSyncCommittee.toValue();
|
|
605
605
|
}
|
|
606
606
|
|
|
607
|
-
return this.
|
|
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}:
|
|
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
|
-
|
|
883
|
+
{block}: BlockSTFInput,
|
|
884
884
|
options: StateTransitionOpts,
|
|
885
|
-
|
|
885
|
+
modules: StateTransitionModules
|
|
886
886
|
): IBeaconStateView {
|
|
887
|
-
|
|
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
|
-
/**
|
|
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;
|
|
@@ -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
|
|
321
|
-
* -
|
|
322
|
-
*
|
|
323
|
-
*
|
|
324
|
-
* -
|
|
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
|
-
| "
|
|
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(
|
|
346
|
-
|
|
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;
|