@lodestar/state-transition 1.44.0-dev.f507c14622 → 1.44.0-dev.ff43f013ea
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/stateView/interface.d.ts +25 -0
- package/lib/stateView/interface.d.ts.map +1 -1
- package/lib/stateView/interface.js.map +1 -1
- package/lib/stateView/nativeBeaconStateView.d.ts +226 -0
- package/lib/stateView/nativeBeaconStateView.d.ts.map +1 -0
- package/lib/stateView/nativeBeaconStateView.js +698 -0
- package/lib/stateView/nativeBeaconStateView.js.map +1 -0
- package/lib/stateView/stateViewFactory.d.ts.map +1 -1
- package/lib/stateView/stateViewFactory.js +2 -0
- package/lib/stateView/stateViewFactory.js.map +1 -1
- package/package.json +7 -7
- package/src/stateView/interface.ts +29 -0
- package/src/stateView/nativeBeaconStateView.ts +893 -0
- package/src/stateView/stateViewFactory.ts +2 -0
|
@@ -0,0 +1,698 @@
|
|
|
1
|
+
import { BitArray } from "@chainsafe/ssz";
|
|
2
|
+
import { isStatePostGloas, } from "./interface.js";
|
|
3
|
+
/**
|
|
4
|
+
* Wraps a native binding (the auto-generated JS interface produced by a `.node`
|
|
5
|
+
* file) and exposes it as a fully-conformant `IBeaconStateViewLatestFork`.
|
|
6
|
+
*
|
|
7
|
+
* The binding is typed `IBeaconStateViewNative` — identical to
|
|
8
|
+
* `IBeaconStateViewLatestFork` except `executionPayloadAvailability` is a raw
|
|
9
|
+
* `{uint8Array, bitLen}` POJO. The `executionPayloadAvailability` getter lifts
|
|
10
|
+
* that POJO back to a `BitArray` so beacon-node consumers see no difference from
|
|
11
|
+
* the TS-side `BeaconStateView`.
|
|
12
|
+
*
|
|
13
|
+
* Every getter that returns a value stable for the view's lifetime is cached so
|
|
14
|
+
* the binding is hit at most once per field per view. Only mutable counters
|
|
15
|
+
* (`proposerRewards`, `clonedCount`, `clonedCountWithTransferCache`) stay
|
|
16
|
+
* pass-through. Methods with arguments are pass-through too — caching them
|
|
17
|
+
* would need a per-arg map and isn't worth it without a hot-path signal.
|
|
18
|
+
*/
|
|
19
|
+
export class NativeBeaconStateView {
|
|
20
|
+
binding;
|
|
21
|
+
// phase0
|
|
22
|
+
_forkName = null;
|
|
23
|
+
_slot = null;
|
|
24
|
+
_fork = null;
|
|
25
|
+
_epoch = null;
|
|
26
|
+
_genesisTime = null;
|
|
27
|
+
_genesisValidatorsRoot = null;
|
|
28
|
+
_eth1Data = null;
|
|
29
|
+
_latestBlockHeader = null;
|
|
30
|
+
_previousJustifiedCheckpoint = null;
|
|
31
|
+
_currentJustifiedCheckpoint = null;
|
|
32
|
+
_finalizedCheckpoint = null;
|
|
33
|
+
// shuffling / decision roots / proposers
|
|
34
|
+
_previousDecisionRoot = null;
|
|
35
|
+
_currentDecisionRoot = null;
|
|
36
|
+
_nextDecisionRoot = null;
|
|
37
|
+
// previousProposers can be null, so use undefined as the "not loaded" sentinel
|
|
38
|
+
_previousProposers = undefined;
|
|
39
|
+
_currentProposers = null;
|
|
40
|
+
_nextProposers = null;
|
|
41
|
+
// validators / balances
|
|
42
|
+
_effectiveBalanceIncrements = null;
|
|
43
|
+
_validatorCount = null;
|
|
44
|
+
_activeValidatorCount = null;
|
|
45
|
+
// backward compat
|
|
46
|
+
_createdWithTransferCache = null;
|
|
47
|
+
// altair
|
|
48
|
+
_currentSyncCommittee = null;
|
|
49
|
+
_nextSyncCommittee = null;
|
|
50
|
+
_previousEpochParticipation = null;
|
|
51
|
+
_currentEpochParticipation = null;
|
|
52
|
+
_currentSyncCommitteeIndexed = null;
|
|
53
|
+
_syncProposerReward = null;
|
|
54
|
+
// bellatrix
|
|
55
|
+
_latestExecutionPayloadHeader = null;
|
|
56
|
+
_payloadBlockNumber = null;
|
|
57
|
+
_isExecutionStateType = null;
|
|
58
|
+
_isMergeTransitionComplete = null;
|
|
59
|
+
// capella
|
|
60
|
+
_historicalSummaries = null;
|
|
61
|
+
// electra
|
|
62
|
+
_pendingPartialWithdrawals = null;
|
|
63
|
+
_pendingConsolidations = null;
|
|
64
|
+
_pendingDeposits = null;
|
|
65
|
+
_pendingDepositsCount = null;
|
|
66
|
+
_pendingPartialWithdrawalsCount = null;
|
|
67
|
+
_pendingConsolidationsCount = null;
|
|
68
|
+
// fulu
|
|
69
|
+
_proposerLookahead = null;
|
|
70
|
+
// gloas
|
|
71
|
+
_executionPayloadAvailability = null;
|
|
72
|
+
_latestBlockHash = null;
|
|
73
|
+
_latestExecutionPayloadBid = null;
|
|
74
|
+
_payloadExpectedWithdrawals = null;
|
|
75
|
+
// Per-argument caches for argument-taking methods. The binding is treated as
|
|
76
|
+
// immutable for the view's lifetime, so a given argument always yields the
|
|
77
|
+
// same result. Maps grow only with touched arguments — typical call patterns
|
|
78
|
+
// (e.g. a handful of slots per attestation pool scan) keep them tiny.
|
|
79
|
+
_getBlockRootAtSlot = new Map();
|
|
80
|
+
_getBlockRootAtEpoch = new Map();
|
|
81
|
+
_getStateRootAtSlot = new Map();
|
|
82
|
+
_getRandaoMix = new Map();
|
|
83
|
+
_getShufflingAtEpoch = new Map();
|
|
84
|
+
_getShufflingDecisionRoot = new Map();
|
|
85
|
+
_getBeaconProposer = new Map();
|
|
86
|
+
// getBeaconProposerOrNull can return null, so use .has() to distinguish "not cached" from "cached null"
|
|
87
|
+
_getBeaconProposerOrNull = new Map();
|
|
88
|
+
_getValidator = new Map();
|
|
89
|
+
_getBalance = new Map();
|
|
90
|
+
_getIndexedSyncCommitteeAtEpoch = new Map();
|
|
91
|
+
_getIndexedSyncCommittee = new Map();
|
|
92
|
+
_getSingleProof = new Map();
|
|
93
|
+
_getEpochPTCs = new Map();
|
|
94
|
+
_getBuilder = new Map();
|
|
95
|
+
// No-arg method caches
|
|
96
|
+
_getPreviousShuffling = null;
|
|
97
|
+
_getCurrentShuffling = null;
|
|
98
|
+
_getNextShuffling = null;
|
|
99
|
+
_getEffectiveBalanceIncrementsZeroInactive = null;
|
|
100
|
+
_getAllValidators = null;
|
|
101
|
+
_getAllBalances = null;
|
|
102
|
+
_getLatestWeakSubjectivityCheckpointEpoch = null;
|
|
103
|
+
_getFinalizedRootProof = null;
|
|
104
|
+
_computeUnrealizedCheckpoints = null;
|
|
105
|
+
_computeAnchorCheckpoint = null;
|
|
106
|
+
_isStateValidatorsNodesPopulated = null;
|
|
107
|
+
_toValue = null;
|
|
108
|
+
_serialize = null;
|
|
109
|
+
_serializedSize = null;
|
|
110
|
+
_serializeValidators = null;
|
|
111
|
+
_serializedValidatorsSize = null;
|
|
112
|
+
_hashTreeRoot = null;
|
|
113
|
+
_getSyncCommitteesWitness = null;
|
|
114
|
+
_getExpectedWithdrawals = null;
|
|
115
|
+
constructor(binding) {
|
|
116
|
+
this.binding = binding;
|
|
117
|
+
}
|
|
118
|
+
// Binding returns pojo object {uint8Array: Uint8Array; bitLen: number}
|
|
119
|
+
// this class wrap it with BitArray to conform to the api
|
|
120
|
+
get executionPayloadAvailability() {
|
|
121
|
+
if (this._executionPayloadAvailability === null) {
|
|
122
|
+
const pojo = this.binding.executionPayloadAvailability;
|
|
123
|
+
this._executionPayloadAvailability = new BitArray(pojo.uint8Array, pojo.bitLen);
|
|
124
|
+
}
|
|
125
|
+
return this._executionPayloadAvailability;
|
|
126
|
+
}
|
|
127
|
+
// ─── phase0 ──────────────────────────────────────────────────────────────
|
|
128
|
+
get forkName() {
|
|
129
|
+
if (this._forkName === null) {
|
|
130
|
+
this._forkName = this.binding.forkName;
|
|
131
|
+
}
|
|
132
|
+
return this._forkName;
|
|
133
|
+
}
|
|
134
|
+
get slot() {
|
|
135
|
+
if (this._slot === null) {
|
|
136
|
+
this._slot = this.binding.slot;
|
|
137
|
+
}
|
|
138
|
+
return this._slot;
|
|
139
|
+
}
|
|
140
|
+
get fork() {
|
|
141
|
+
if (this._fork === null) {
|
|
142
|
+
this._fork = this.binding.fork;
|
|
143
|
+
}
|
|
144
|
+
return this._fork;
|
|
145
|
+
}
|
|
146
|
+
get epoch() {
|
|
147
|
+
if (this._epoch === null) {
|
|
148
|
+
this._epoch = this.binding.epoch;
|
|
149
|
+
}
|
|
150
|
+
return this._epoch;
|
|
151
|
+
}
|
|
152
|
+
get genesisTime() {
|
|
153
|
+
if (this._genesisTime === null) {
|
|
154
|
+
this._genesisTime = this.binding.genesisTime;
|
|
155
|
+
}
|
|
156
|
+
return this._genesisTime;
|
|
157
|
+
}
|
|
158
|
+
get genesisValidatorsRoot() {
|
|
159
|
+
if (this._genesisValidatorsRoot === null) {
|
|
160
|
+
this._genesisValidatorsRoot = this.binding.genesisValidatorsRoot;
|
|
161
|
+
}
|
|
162
|
+
return this._genesisValidatorsRoot;
|
|
163
|
+
}
|
|
164
|
+
get eth1Data() {
|
|
165
|
+
if (this._eth1Data === null) {
|
|
166
|
+
this._eth1Data = this.binding.eth1Data;
|
|
167
|
+
}
|
|
168
|
+
return this._eth1Data;
|
|
169
|
+
}
|
|
170
|
+
get latestBlockHeader() {
|
|
171
|
+
if (this._latestBlockHeader === null) {
|
|
172
|
+
this._latestBlockHeader = this.binding.latestBlockHeader;
|
|
173
|
+
}
|
|
174
|
+
return this._latestBlockHeader;
|
|
175
|
+
}
|
|
176
|
+
get previousJustifiedCheckpoint() {
|
|
177
|
+
if (this._previousJustifiedCheckpoint === null) {
|
|
178
|
+
this._previousJustifiedCheckpoint = this.binding.previousJustifiedCheckpoint;
|
|
179
|
+
}
|
|
180
|
+
return this._previousJustifiedCheckpoint;
|
|
181
|
+
}
|
|
182
|
+
get currentJustifiedCheckpoint() {
|
|
183
|
+
if (this._currentJustifiedCheckpoint === null) {
|
|
184
|
+
this._currentJustifiedCheckpoint = this.binding.currentJustifiedCheckpoint;
|
|
185
|
+
}
|
|
186
|
+
return this._currentJustifiedCheckpoint;
|
|
187
|
+
}
|
|
188
|
+
get finalizedCheckpoint() {
|
|
189
|
+
if (this._finalizedCheckpoint === null) {
|
|
190
|
+
this._finalizedCheckpoint = this.binding.finalizedCheckpoint;
|
|
191
|
+
}
|
|
192
|
+
return this._finalizedCheckpoint;
|
|
193
|
+
}
|
|
194
|
+
getBlockRootAtSlot(slot) {
|
|
195
|
+
let cached = this._getBlockRootAtSlot.get(slot);
|
|
196
|
+
if (cached === undefined) {
|
|
197
|
+
cached = this.binding.getBlockRootAtSlot(slot);
|
|
198
|
+
this._getBlockRootAtSlot.set(slot, cached);
|
|
199
|
+
}
|
|
200
|
+
return cached;
|
|
201
|
+
}
|
|
202
|
+
getBlockRootAtEpoch(epoch) {
|
|
203
|
+
let cached = this._getBlockRootAtEpoch.get(epoch);
|
|
204
|
+
if (cached === undefined) {
|
|
205
|
+
cached = this.binding.getBlockRootAtEpoch(epoch);
|
|
206
|
+
this._getBlockRootAtEpoch.set(epoch, cached);
|
|
207
|
+
}
|
|
208
|
+
return cached;
|
|
209
|
+
}
|
|
210
|
+
getStateRootAtSlot(slot) {
|
|
211
|
+
let cached = this._getStateRootAtSlot.get(slot);
|
|
212
|
+
if (cached === undefined) {
|
|
213
|
+
cached = this.binding.getStateRootAtSlot(slot);
|
|
214
|
+
this._getStateRootAtSlot.set(slot, cached);
|
|
215
|
+
}
|
|
216
|
+
return cached;
|
|
217
|
+
}
|
|
218
|
+
getRandaoMix(epoch) {
|
|
219
|
+
let cached = this._getRandaoMix.get(epoch);
|
|
220
|
+
if (cached === undefined) {
|
|
221
|
+
cached = this.binding.getRandaoMix(epoch);
|
|
222
|
+
this._getRandaoMix.set(epoch, cached);
|
|
223
|
+
}
|
|
224
|
+
return cached;
|
|
225
|
+
}
|
|
226
|
+
// Shuffling and committees
|
|
227
|
+
getShufflingAtEpoch(epoch) {
|
|
228
|
+
let cached = this._getShufflingAtEpoch.get(epoch);
|
|
229
|
+
if (cached === undefined) {
|
|
230
|
+
cached = this.binding.getShufflingAtEpoch(epoch);
|
|
231
|
+
this._getShufflingAtEpoch.set(epoch, cached);
|
|
232
|
+
}
|
|
233
|
+
return cached;
|
|
234
|
+
}
|
|
235
|
+
get previousDecisionRoot() {
|
|
236
|
+
if (this._previousDecisionRoot === null) {
|
|
237
|
+
this._previousDecisionRoot = this.binding.previousDecisionRoot;
|
|
238
|
+
}
|
|
239
|
+
return this._previousDecisionRoot;
|
|
240
|
+
}
|
|
241
|
+
get currentDecisionRoot() {
|
|
242
|
+
if (this._currentDecisionRoot === null) {
|
|
243
|
+
this._currentDecisionRoot = this.binding.currentDecisionRoot;
|
|
244
|
+
}
|
|
245
|
+
return this._currentDecisionRoot;
|
|
246
|
+
}
|
|
247
|
+
get nextDecisionRoot() {
|
|
248
|
+
if (this._nextDecisionRoot === null) {
|
|
249
|
+
this._nextDecisionRoot = this.binding.nextDecisionRoot;
|
|
250
|
+
}
|
|
251
|
+
return this._nextDecisionRoot;
|
|
252
|
+
}
|
|
253
|
+
getShufflingDecisionRoot(epoch) {
|
|
254
|
+
let cached = this._getShufflingDecisionRoot.get(epoch);
|
|
255
|
+
if (cached === undefined) {
|
|
256
|
+
cached = this.binding.getShufflingDecisionRoot(epoch);
|
|
257
|
+
this._getShufflingDecisionRoot.set(epoch, cached);
|
|
258
|
+
}
|
|
259
|
+
return cached;
|
|
260
|
+
}
|
|
261
|
+
getPreviousShuffling() {
|
|
262
|
+
if (this._getPreviousShuffling === null) {
|
|
263
|
+
this._getPreviousShuffling = this.binding.getPreviousShuffling();
|
|
264
|
+
}
|
|
265
|
+
return this._getPreviousShuffling;
|
|
266
|
+
}
|
|
267
|
+
getCurrentShuffling() {
|
|
268
|
+
if (this._getCurrentShuffling === null) {
|
|
269
|
+
this._getCurrentShuffling = this.binding.getCurrentShuffling();
|
|
270
|
+
}
|
|
271
|
+
return this._getCurrentShuffling;
|
|
272
|
+
}
|
|
273
|
+
getNextShuffling() {
|
|
274
|
+
if (this._getNextShuffling === null) {
|
|
275
|
+
this._getNextShuffling = this.binding.getNextShuffling();
|
|
276
|
+
}
|
|
277
|
+
return this._getNextShuffling;
|
|
278
|
+
}
|
|
279
|
+
// Proposer shuffling
|
|
280
|
+
get previousProposers() {
|
|
281
|
+
if (this._previousProposers === undefined) {
|
|
282
|
+
this._previousProposers = this.binding.previousProposers;
|
|
283
|
+
}
|
|
284
|
+
return this._previousProposers;
|
|
285
|
+
}
|
|
286
|
+
get currentProposers() {
|
|
287
|
+
if (this._currentProposers === null) {
|
|
288
|
+
this._currentProposers = this.binding.currentProposers;
|
|
289
|
+
}
|
|
290
|
+
return this._currentProposers;
|
|
291
|
+
}
|
|
292
|
+
get nextProposers() {
|
|
293
|
+
if (this._nextProposers === null) {
|
|
294
|
+
this._nextProposers = this.binding.nextProposers;
|
|
295
|
+
}
|
|
296
|
+
return this._nextProposers;
|
|
297
|
+
}
|
|
298
|
+
getBeaconProposer(slot) {
|
|
299
|
+
let cached = this._getBeaconProposer.get(slot);
|
|
300
|
+
if (cached === undefined) {
|
|
301
|
+
cached = this.binding.getBeaconProposer(slot);
|
|
302
|
+
this._getBeaconProposer.set(slot, cached);
|
|
303
|
+
}
|
|
304
|
+
return cached;
|
|
305
|
+
}
|
|
306
|
+
getBeaconProposerOrNull(slot) {
|
|
307
|
+
if (!this._getBeaconProposerOrNull.has(slot)) {
|
|
308
|
+
this._getBeaconProposerOrNull.set(slot, this.binding.getBeaconProposerOrNull(slot));
|
|
309
|
+
}
|
|
310
|
+
// biome-ignore lint/style/noNonNullAssertion: has() check guarantees a value
|
|
311
|
+
return this._getBeaconProposerOrNull.get(slot);
|
|
312
|
+
}
|
|
313
|
+
// Validators and balances
|
|
314
|
+
get effectiveBalanceIncrements() {
|
|
315
|
+
if (this._effectiveBalanceIncrements === null) {
|
|
316
|
+
this._effectiveBalanceIncrements = this.binding.effectiveBalanceIncrements;
|
|
317
|
+
}
|
|
318
|
+
return this._effectiveBalanceIncrements;
|
|
319
|
+
}
|
|
320
|
+
getEffectiveBalanceIncrementsZeroInactive() {
|
|
321
|
+
if (this._getEffectiveBalanceIncrementsZeroInactive === null) {
|
|
322
|
+
this._getEffectiveBalanceIncrementsZeroInactive = this.binding.getEffectiveBalanceIncrementsZeroInactive();
|
|
323
|
+
}
|
|
324
|
+
return this._getEffectiveBalanceIncrementsZeroInactive;
|
|
325
|
+
}
|
|
326
|
+
getBalance(index) {
|
|
327
|
+
let cached = this._getBalance.get(index);
|
|
328
|
+
if (cached === undefined) {
|
|
329
|
+
cached = this.binding.getBalance(index);
|
|
330
|
+
this._getBalance.set(index, cached);
|
|
331
|
+
}
|
|
332
|
+
return cached;
|
|
333
|
+
}
|
|
334
|
+
getValidator(index) {
|
|
335
|
+
let cached = this._getValidator.get(index);
|
|
336
|
+
if (cached === undefined) {
|
|
337
|
+
cached = this.binding.getValidator(index);
|
|
338
|
+
this._getValidator.set(index, cached);
|
|
339
|
+
}
|
|
340
|
+
return cached;
|
|
341
|
+
}
|
|
342
|
+
getValidatorsByStatus(statuses, currentEpoch) {
|
|
343
|
+
return this.binding.getValidatorsByStatus(statuses, currentEpoch);
|
|
344
|
+
}
|
|
345
|
+
get validatorCount() {
|
|
346
|
+
if (this._validatorCount === null) {
|
|
347
|
+
this._validatorCount = this.binding.validatorCount;
|
|
348
|
+
}
|
|
349
|
+
return this._validatorCount;
|
|
350
|
+
}
|
|
351
|
+
get activeValidatorCount() {
|
|
352
|
+
if (this._activeValidatorCount === null) {
|
|
353
|
+
this._activeValidatorCount = this.binding.activeValidatorCount;
|
|
354
|
+
}
|
|
355
|
+
return this._activeValidatorCount;
|
|
356
|
+
}
|
|
357
|
+
getAllValidators() {
|
|
358
|
+
if (this._getAllValidators === null) {
|
|
359
|
+
this._getAllValidators = this.binding.getAllValidators();
|
|
360
|
+
}
|
|
361
|
+
return this._getAllValidators;
|
|
362
|
+
}
|
|
363
|
+
getAllBalances() {
|
|
364
|
+
if (this._getAllBalances === null) {
|
|
365
|
+
this._getAllBalances = this.binding.getAllBalances();
|
|
366
|
+
}
|
|
367
|
+
return this._getAllBalances;
|
|
368
|
+
}
|
|
369
|
+
// API
|
|
370
|
+
get proposerRewards() {
|
|
371
|
+
return this.binding.proposerRewards;
|
|
372
|
+
}
|
|
373
|
+
computeBlockRewards(block, proposerRewards) {
|
|
374
|
+
return this.binding.computeBlockRewards(block, proposerRewards);
|
|
375
|
+
}
|
|
376
|
+
computeAttestationsRewards(validatorIds) {
|
|
377
|
+
return this.binding.computeAttestationsRewards(validatorIds);
|
|
378
|
+
}
|
|
379
|
+
getLatestWeakSubjectivityCheckpointEpoch() {
|
|
380
|
+
if (this._getLatestWeakSubjectivityCheckpointEpoch === null) {
|
|
381
|
+
this._getLatestWeakSubjectivityCheckpointEpoch = this.binding.getLatestWeakSubjectivityCheckpointEpoch();
|
|
382
|
+
}
|
|
383
|
+
return this._getLatestWeakSubjectivityCheckpointEpoch;
|
|
384
|
+
}
|
|
385
|
+
// Validation
|
|
386
|
+
getVoluntaryExitValidity(signedVoluntaryExit, verifySignature) {
|
|
387
|
+
return this.binding.getVoluntaryExitValidity(signedVoluntaryExit, verifySignature);
|
|
388
|
+
}
|
|
389
|
+
isValidVoluntaryExit(signedVoluntaryExit, verifySignature) {
|
|
390
|
+
return this.binding.isValidVoluntaryExit(signedVoluntaryExit, verifySignature);
|
|
391
|
+
}
|
|
392
|
+
// Proofs
|
|
393
|
+
getFinalizedRootProof() {
|
|
394
|
+
if (this._getFinalizedRootProof === null) {
|
|
395
|
+
this._getFinalizedRootProof = this.binding.getFinalizedRootProof();
|
|
396
|
+
}
|
|
397
|
+
return this._getFinalizedRootProof;
|
|
398
|
+
}
|
|
399
|
+
getSingleProof(gindex) {
|
|
400
|
+
let cached = this._getSingleProof.get(gindex);
|
|
401
|
+
if (cached === undefined) {
|
|
402
|
+
cached = this.binding.getSingleProof(gindex);
|
|
403
|
+
this._getSingleProof.set(gindex, cached);
|
|
404
|
+
}
|
|
405
|
+
return cached;
|
|
406
|
+
}
|
|
407
|
+
createMultiProof(descriptor) {
|
|
408
|
+
return this.binding.createMultiProof(descriptor);
|
|
409
|
+
}
|
|
410
|
+
// Fork choice
|
|
411
|
+
computeUnrealizedCheckpoints() {
|
|
412
|
+
if (this._computeUnrealizedCheckpoints === null) {
|
|
413
|
+
this._computeUnrealizedCheckpoints = this.binding.computeUnrealizedCheckpoints();
|
|
414
|
+
}
|
|
415
|
+
return this._computeUnrealizedCheckpoints;
|
|
416
|
+
}
|
|
417
|
+
computeAnchorCheckpoint() {
|
|
418
|
+
if (this._computeAnchorCheckpoint === null) {
|
|
419
|
+
this._computeAnchorCheckpoint = this.binding.computeAnchorCheckpoint();
|
|
420
|
+
}
|
|
421
|
+
return this._computeAnchorCheckpoint;
|
|
422
|
+
}
|
|
423
|
+
// Backward compatibility
|
|
424
|
+
get clonedCount() {
|
|
425
|
+
return this.binding.clonedCount;
|
|
426
|
+
}
|
|
427
|
+
get clonedCountWithTransferCache() {
|
|
428
|
+
return this.binding.clonedCountWithTransferCache;
|
|
429
|
+
}
|
|
430
|
+
get createdWithTransferCache() {
|
|
431
|
+
if (this._createdWithTransferCache === null) {
|
|
432
|
+
this._createdWithTransferCache = this.binding.createdWithTransferCache;
|
|
433
|
+
}
|
|
434
|
+
return this._createdWithTransferCache;
|
|
435
|
+
}
|
|
436
|
+
isStateValidatorsNodesPopulated() {
|
|
437
|
+
if (this._isStateValidatorsNodesPopulated === null) {
|
|
438
|
+
this._isStateValidatorsNodesPopulated = this.binding.isStateValidatorsNodesPopulated();
|
|
439
|
+
}
|
|
440
|
+
return this._isStateValidatorsNodesPopulated;
|
|
441
|
+
}
|
|
442
|
+
// Serialization
|
|
443
|
+
loadOtherState(stateBytes, seedValidatorsBytes, opts) {
|
|
444
|
+
return new NativeBeaconStateView(this.binding.loadOtherState(stateBytes, seedValidatorsBytes, opts));
|
|
445
|
+
}
|
|
446
|
+
toValue() {
|
|
447
|
+
if (this._toValue === null) {
|
|
448
|
+
this._toValue = this.binding.toValue();
|
|
449
|
+
}
|
|
450
|
+
return this._toValue;
|
|
451
|
+
}
|
|
452
|
+
serialize() {
|
|
453
|
+
if (this._serialize === null) {
|
|
454
|
+
this._serialize = this.binding.serialize();
|
|
455
|
+
}
|
|
456
|
+
return this._serialize;
|
|
457
|
+
}
|
|
458
|
+
serializedSize() {
|
|
459
|
+
if (this._serializedSize === null) {
|
|
460
|
+
this._serializedSize = this.binding.serializedSize();
|
|
461
|
+
}
|
|
462
|
+
return this._serializedSize;
|
|
463
|
+
}
|
|
464
|
+
serializeToBytes(output, offset) {
|
|
465
|
+
return this.binding.serializeToBytes(output, offset);
|
|
466
|
+
}
|
|
467
|
+
serializeValidators() {
|
|
468
|
+
if (this._serializeValidators === null) {
|
|
469
|
+
this._serializeValidators = this.binding.serializeValidators();
|
|
470
|
+
}
|
|
471
|
+
return this._serializeValidators;
|
|
472
|
+
}
|
|
473
|
+
serializedValidatorsSize() {
|
|
474
|
+
if (this._serializedValidatorsSize === null) {
|
|
475
|
+
this._serializedValidatorsSize = this.binding.serializedValidatorsSize();
|
|
476
|
+
}
|
|
477
|
+
return this._serializedValidatorsSize;
|
|
478
|
+
}
|
|
479
|
+
serializeValidatorsToBytes(output, offset) {
|
|
480
|
+
return this.binding.serializeValidatorsToBytes(output, offset);
|
|
481
|
+
}
|
|
482
|
+
hashTreeRoot() {
|
|
483
|
+
if (this._hashTreeRoot === null) {
|
|
484
|
+
this._hashTreeRoot = this.binding.hashTreeRoot();
|
|
485
|
+
}
|
|
486
|
+
return this._hashTreeRoot;
|
|
487
|
+
}
|
|
488
|
+
// State transition
|
|
489
|
+
stateTransition(signedBlock, options, modules) {
|
|
490
|
+
return new NativeBeaconStateView(this.binding.stateTransition(signedBlock, options, modules));
|
|
491
|
+
}
|
|
492
|
+
processSlots(slot, epochTransitionCacheOpts, modules) {
|
|
493
|
+
return new NativeBeaconStateView(this.binding.processSlots(slot, epochTransitionCacheOpts, modules));
|
|
494
|
+
}
|
|
495
|
+
// ─── altair ──────────────────────────────────────────────────────────────
|
|
496
|
+
get previousEpochParticipation() {
|
|
497
|
+
if (this._previousEpochParticipation === null) {
|
|
498
|
+
this._previousEpochParticipation = this.binding.previousEpochParticipation;
|
|
499
|
+
}
|
|
500
|
+
return this._previousEpochParticipation;
|
|
501
|
+
}
|
|
502
|
+
get currentEpochParticipation() {
|
|
503
|
+
if (this._currentEpochParticipation === null) {
|
|
504
|
+
this._currentEpochParticipation = this.binding.currentEpochParticipation;
|
|
505
|
+
}
|
|
506
|
+
return this._currentEpochParticipation;
|
|
507
|
+
}
|
|
508
|
+
getPreviousEpochParticipation(validatorIndex) {
|
|
509
|
+
return this.previousEpochParticipation[validatorIndex];
|
|
510
|
+
}
|
|
511
|
+
getCurrentEpochParticipation(validatorIndex) {
|
|
512
|
+
return this.currentEpochParticipation[validatorIndex];
|
|
513
|
+
}
|
|
514
|
+
get currentSyncCommittee() {
|
|
515
|
+
if (this._currentSyncCommittee === null) {
|
|
516
|
+
this._currentSyncCommittee = this.binding.currentSyncCommittee;
|
|
517
|
+
}
|
|
518
|
+
return this._currentSyncCommittee;
|
|
519
|
+
}
|
|
520
|
+
get nextSyncCommittee() {
|
|
521
|
+
if (this._nextSyncCommittee === null) {
|
|
522
|
+
this._nextSyncCommittee = this.binding.nextSyncCommittee;
|
|
523
|
+
}
|
|
524
|
+
return this._nextSyncCommittee;
|
|
525
|
+
}
|
|
526
|
+
get currentSyncCommitteeIndexed() {
|
|
527
|
+
if (this._currentSyncCommitteeIndexed === null) {
|
|
528
|
+
this._currentSyncCommitteeIndexed = this.binding.currentSyncCommitteeIndexed;
|
|
529
|
+
}
|
|
530
|
+
return this._currentSyncCommitteeIndexed;
|
|
531
|
+
}
|
|
532
|
+
get syncProposerReward() {
|
|
533
|
+
if (this._syncProposerReward === null) {
|
|
534
|
+
this._syncProposerReward = this.binding.syncProposerReward;
|
|
535
|
+
}
|
|
536
|
+
return this._syncProposerReward;
|
|
537
|
+
}
|
|
538
|
+
getIndexedSyncCommitteeAtEpoch(epoch) {
|
|
539
|
+
let cached = this._getIndexedSyncCommitteeAtEpoch.get(epoch);
|
|
540
|
+
if (cached === undefined) {
|
|
541
|
+
cached = this.binding.getIndexedSyncCommitteeAtEpoch(epoch);
|
|
542
|
+
this._getIndexedSyncCommitteeAtEpoch.set(epoch, cached);
|
|
543
|
+
}
|
|
544
|
+
return cached;
|
|
545
|
+
}
|
|
546
|
+
getIndexedSyncCommittee(slot) {
|
|
547
|
+
let cached = this._getIndexedSyncCommittee.get(slot);
|
|
548
|
+
if (cached === undefined) {
|
|
549
|
+
cached = this.binding.getIndexedSyncCommittee(slot);
|
|
550
|
+
this._getIndexedSyncCommittee.set(slot, cached);
|
|
551
|
+
}
|
|
552
|
+
return cached;
|
|
553
|
+
}
|
|
554
|
+
computeSyncCommitteeRewards(block, validatorIds) {
|
|
555
|
+
return this.binding.computeSyncCommitteeRewards(block, validatorIds);
|
|
556
|
+
}
|
|
557
|
+
getSyncCommitteesWitness() {
|
|
558
|
+
if (this._getSyncCommitteesWitness === null) {
|
|
559
|
+
this._getSyncCommitteesWitness = this.binding.getSyncCommitteesWitness();
|
|
560
|
+
}
|
|
561
|
+
return this._getSyncCommitteesWitness;
|
|
562
|
+
}
|
|
563
|
+
// ─── bellatrix ───────────────────────────────────────────────────────────
|
|
564
|
+
get latestExecutionPayloadHeader() {
|
|
565
|
+
if (this._latestExecutionPayloadHeader === null) {
|
|
566
|
+
this._latestExecutionPayloadHeader = this.binding.latestExecutionPayloadHeader;
|
|
567
|
+
}
|
|
568
|
+
return this._latestExecutionPayloadHeader;
|
|
569
|
+
}
|
|
570
|
+
get payloadBlockNumber() {
|
|
571
|
+
if (this._payloadBlockNumber === null) {
|
|
572
|
+
this._payloadBlockNumber = this.binding.payloadBlockNumber;
|
|
573
|
+
}
|
|
574
|
+
return this._payloadBlockNumber;
|
|
575
|
+
}
|
|
576
|
+
get isExecutionStateType() {
|
|
577
|
+
if (this._isExecutionStateType === null) {
|
|
578
|
+
this._isExecutionStateType = this.binding.isExecutionStateType;
|
|
579
|
+
}
|
|
580
|
+
return this._isExecutionStateType;
|
|
581
|
+
}
|
|
582
|
+
get isMergeTransitionComplete() {
|
|
583
|
+
if (this._isMergeTransitionComplete === null) {
|
|
584
|
+
this._isMergeTransitionComplete = this.binding.isMergeTransitionComplete;
|
|
585
|
+
}
|
|
586
|
+
return this._isMergeTransitionComplete;
|
|
587
|
+
}
|
|
588
|
+
isExecutionEnabled(block) {
|
|
589
|
+
return this.binding.isExecutionEnabled(block);
|
|
590
|
+
}
|
|
591
|
+
// ─── capella ─────────────────────────────────────────────────────────────
|
|
592
|
+
get historicalSummaries() {
|
|
593
|
+
if (this._historicalSummaries === null) {
|
|
594
|
+
this._historicalSummaries = this.binding.historicalSummaries;
|
|
595
|
+
}
|
|
596
|
+
return this._historicalSummaries;
|
|
597
|
+
}
|
|
598
|
+
getExpectedWithdrawals() {
|
|
599
|
+
if (this._getExpectedWithdrawals === null) {
|
|
600
|
+
this._getExpectedWithdrawals = this.binding.getExpectedWithdrawals();
|
|
601
|
+
}
|
|
602
|
+
return this._getExpectedWithdrawals;
|
|
603
|
+
}
|
|
604
|
+
// ─── electra ─────────────────────────────────────────────────────────────
|
|
605
|
+
get pendingDeposits() {
|
|
606
|
+
if (this._pendingDeposits === null) {
|
|
607
|
+
this._pendingDeposits = this.binding.pendingDeposits;
|
|
608
|
+
}
|
|
609
|
+
return this._pendingDeposits;
|
|
610
|
+
}
|
|
611
|
+
get pendingDepositsCount() {
|
|
612
|
+
if (this._pendingDepositsCount === null) {
|
|
613
|
+
this._pendingDepositsCount = this.binding.pendingDepositsCount;
|
|
614
|
+
}
|
|
615
|
+
return this._pendingDepositsCount;
|
|
616
|
+
}
|
|
617
|
+
get pendingPartialWithdrawals() {
|
|
618
|
+
if (this._pendingPartialWithdrawals === null) {
|
|
619
|
+
this._pendingPartialWithdrawals = this.binding.pendingPartialWithdrawals;
|
|
620
|
+
}
|
|
621
|
+
return this._pendingPartialWithdrawals;
|
|
622
|
+
}
|
|
623
|
+
get pendingPartialWithdrawalsCount() {
|
|
624
|
+
if (this._pendingPartialWithdrawalsCount === null) {
|
|
625
|
+
this._pendingPartialWithdrawalsCount = this.binding.pendingPartialWithdrawalsCount;
|
|
626
|
+
}
|
|
627
|
+
return this._pendingPartialWithdrawalsCount;
|
|
628
|
+
}
|
|
629
|
+
get pendingConsolidations() {
|
|
630
|
+
if (this._pendingConsolidations === null) {
|
|
631
|
+
this._pendingConsolidations = this.binding.pendingConsolidations;
|
|
632
|
+
}
|
|
633
|
+
return this._pendingConsolidations;
|
|
634
|
+
}
|
|
635
|
+
get pendingConsolidationsCount() {
|
|
636
|
+
if (this._pendingConsolidationsCount === null) {
|
|
637
|
+
this._pendingConsolidationsCount = this.binding.pendingConsolidationsCount;
|
|
638
|
+
}
|
|
639
|
+
return this._pendingConsolidationsCount;
|
|
640
|
+
}
|
|
641
|
+
// ─── fulu ────────────────────────────────────────────────────────────────
|
|
642
|
+
get proposerLookahead() {
|
|
643
|
+
if (this._proposerLookahead === null) {
|
|
644
|
+
this._proposerLookahead = this.binding.proposerLookahead;
|
|
645
|
+
}
|
|
646
|
+
return this._proposerLookahead;
|
|
647
|
+
}
|
|
648
|
+
// ─── gloas ───────────────────────────────────────────────────────────────
|
|
649
|
+
get latestBlockHash() {
|
|
650
|
+
if (this._latestBlockHash === null) {
|
|
651
|
+
this._latestBlockHash = this.binding.latestBlockHash;
|
|
652
|
+
}
|
|
653
|
+
return this._latestBlockHash;
|
|
654
|
+
}
|
|
655
|
+
// executionPayloadAvailability getter is defined near the top of the class.
|
|
656
|
+
get latestExecutionPayloadBid() {
|
|
657
|
+
if (this._latestExecutionPayloadBid === null) {
|
|
658
|
+
this._latestExecutionPayloadBid = this.binding.latestExecutionPayloadBid;
|
|
659
|
+
}
|
|
660
|
+
return this._latestExecutionPayloadBid;
|
|
661
|
+
}
|
|
662
|
+
get payloadExpectedWithdrawals() {
|
|
663
|
+
if (this._payloadExpectedWithdrawals === null) {
|
|
664
|
+
this._payloadExpectedWithdrawals = this.binding.payloadExpectedWithdrawals;
|
|
665
|
+
}
|
|
666
|
+
return this._payloadExpectedWithdrawals;
|
|
667
|
+
}
|
|
668
|
+
getBuilder(index) {
|
|
669
|
+
let cached = this._getBuilder.get(index);
|
|
670
|
+
if (cached === undefined) {
|
|
671
|
+
cached = this.binding.getBuilder(index);
|
|
672
|
+
this._getBuilder.set(index, cached);
|
|
673
|
+
}
|
|
674
|
+
return cached;
|
|
675
|
+
}
|
|
676
|
+
canBuilderCoverBid(builderIndex, bidAmount) {
|
|
677
|
+
return this.binding.canBuilderCoverBid(builderIndex, bidAmount);
|
|
678
|
+
}
|
|
679
|
+
getEpochPTCs(epoch) {
|
|
680
|
+
let cached = this._getEpochPTCs.get(epoch);
|
|
681
|
+
if (cached === undefined) {
|
|
682
|
+
cached = this.binding.getEpochPTCs(epoch);
|
|
683
|
+
this._getEpochPTCs.set(epoch, cached);
|
|
684
|
+
}
|
|
685
|
+
return cached;
|
|
686
|
+
}
|
|
687
|
+
getIndicesInPayloadTimelinessCommittee(validatorIndex, slot) {
|
|
688
|
+
return this.binding.getIndicesInPayloadTimelinessCommittee(validatorIndex, slot);
|
|
689
|
+
}
|
|
690
|
+
withParentPayloadApplied(executionRequests) {
|
|
691
|
+
const view = new NativeBeaconStateView(this.binding.withParentPayloadApplied(executionRequests));
|
|
692
|
+
if (!isStatePostGloas(view)) {
|
|
693
|
+
throw new Error("Expected gloas state from withParentPayloadApplied");
|
|
694
|
+
}
|
|
695
|
+
return view;
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
//# sourceMappingURL=nativeBeaconStateView.js.map
|