@lodestar/state-transition 1.50.0-dev.8ba9d1dd30 → 1.50.0-dev.9203d3d7da

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