@lodestar/state-transition 1.50.0-dev.040a952dd7 → 1.50.0-dev.199b9d3a1f

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