@lodestar/state-transition 1.50.0-dev.023ad6c012 → 1.50.0-dev.03c05fa09a

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