@lodestar/state-transition 1.50.0-dev.11028e782c → 1.50.0-dev.15ca1827f4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/block/indexedBuilderState.d.ts +19 -0
- package/lib/block/indexedBuilderState.d.ts.map +1 -0
- package/lib/block/indexedBuilderState.js +60 -0
- package/lib/block/indexedBuilderState.js.map +1 -0
- package/lib/block/processBuilderDepositRequest.d.ts +2 -2
- package/lib/block/processBuilderDepositRequest.d.ts.map +1 -1
- package/lib/block/processBuilderDepositRequest.js +5 -4
- package/lib/block/processBuilderDepositRequest.js.map +1 -1
- package/lib/block/processBuilderExitRequest.d.ts +2 -2
- package/lib/block/processBuilderExitRequest.d.ts.map +1 -1
- package/lib/block/processBuilderExitRequest.js +4 -3
- package/lib/block/processBuilderExitRequest.js.map +1 -1
- package/lib/block/processParentExecutionPayload.d.ts.map +1 -1
- package/lib/block/processParentExecutionPayload.js +23 -18
- package/lib/block/processParentExecutionPayload.js.map +1 -1
- package/lib/index.d.ts +3 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -1
- package/lib/rewards/attestationsRewards.d.ts.map +1 -1
- package/lib/rewards/attestationsRewards.js +8 -1
- package/lib/rewards/attestationsRewards.js.map +1 -1
- package/lib/stateView/beaconStateView.d.ts +22 -21
- package/lib/stateView/beaconStateView.d.ts.map +1 -1
- package/lib/stateView/beaconStateView.js +71 -71
- package/lib/stateView/beaconStateView.js.map +1 -1
- package/lib/stateView/interface.d.ts +34 -21
- package/lib/stateView/interface.d.ts.map +1 -1
- package/lib/stateView/interface.js.map +1 -1
- package/lib/stateView/nativeBeaconStateView.d.ts +92 -100
- package/lib/stateView/nativeBeaconStateView.d.ts.map +1 -1
- package/lib/stateView/nativeBeaconStateView.js +339 -368
- package/lib/stateView/nativeBeaconStateView.js.map +1 -1
- package/lib/stateView/stateViewFactory.d.ts +6 -5
- package/lib/stateView/stateViewFactory.d.ts.map +1 -1
- package/lib/stateView/stateViewFactory.js +12 -8
- package/lib/stateView/stateViewFactory.js.map +1 -1
- package/lib/util/gloas.d.ts +11 -14
- package/lib/util/gloas.d.ts.map +1 -1
- package/lib/util/gloas.js +2 -42
- package/lib/util/gloas.js.map +1 -1
- package/lib/util/index.d.ts +1 -1
- package/lib/util/index.d.ts.map +1 -1
- package/lib/util/index.js +1 -1
- package/lib/util/index.js.map +1 -1
- package/lib/util/sszBytes.d.ts +2 -0
- package/lib/util/sszBytes.d.ts.map +1 -1
- package/lib/util/sszBytes.js +14 -1
- package/lib/util/sszBytes.js.map +1 -1
- package/package.json +7 -7
- package/src/block/indexedBuilderState.ts +65 -0
- package/src/block/processBuilderDepositRequest.ts +6 -17
- package/src/block/processBuilderExitRequest.ts +5 -9
- package/src/block/processParentExecutionPayload.ts +27 -23
- package/src/index.ts +4 -1
- package/src/rewards/attestationsRewards.ts +8 -1
- package/src/stateView/beaconStateView.ts +75 -76
- package/src/stateView/interface.ts +61 -21
- package/src/stateView/nativeBeaconStateView.ts +354 -375
- package/src/stateView/stateViewFactory.ts +21 -12
- package/src/util/gloas.ts +2 -53
- package/src/util/index.ts +1 -0
- package/src/util/sszBytes.ts +19 -1
|
@@ -55,10 +55,13 @@ import {StateTransitionModules, StateTransitionOpts} from "../stateTransition.js
|
|
|
55
55
|
import {EpochShuffling} from "../util/epochShuffling.js";
|
|
56
56
|
import {PreVerifyBuilderDepositsResult} from "../util/preVerifyBuilderDeposits.js";
|
|
57
57
|
|
|
58
|
-
/**
|
|
59
|
-
export type
|
|
58
|
+
/** Signed block to apply in a state transition. */
|
|
59
|
+
export type BlockSTFInput = {
|
|
60
60
|
block: SignedBeaconBlock | SignedBlindedBeaconBlock;
|
|
61
|
-
/**
|
|
61
|
+
/**
|
|
62
|
+
* Fork-specific SSZ serialization of `block`, using the matching full or blinded block type. Native
|
|
63
|
+
* implementations serialize `block` when omitted.
|
|
64
|
+
*/
|
|
62
65
|
ssz?: Uint8Array;
|
|
63
66
|
};
|
|
64
67
|
|
|
@@ -159,6 +162,13 @@ export interface IBeaconStateView {
|
|
|
159
162
|
// TODO is there a better name that is less implementation specific but still conveys the meaning?
|
|
160
163
|
isStateValidatorsNodesPopulated(): boolean;
|
|
161
164
|
|
|
165
|
+
// Lifecycle
|
|
166
|
+
/**
|
|
167
|
+
* Release resources owned by this view.
|
|
168
|
+
* Do not use the view after calling this method.
|
|
169
|
+
*/
|
|
170
|
+
release(): void;
|
|
171
|
+
|
|
162
172
|
// Serialization
|
|
163
173
|
/** Set `preloadValidatorsAndBalances` only when the whole state will be consumed
|
|
164
174
|
* immediately (e.g. CP reload before block replay). */
|
|
@@ -178,9 +188,9 @@ export interface IBeaconStateView {
|
|
|
178
188
|
hashTreeRoot(): Uint8Array;
|
|
179
189
|
|
|
180
190
|
// State transition
|
|
181
|
-
computeNewStateRoot(input:
|
|
191
|
+
computeNewStateRoot(input: BlockSTFInput, modules: StateTransitionModules): ComputeNewStateRootResult;
|
|
182
192
|
stateTransition(
|
|
183
|
-
|
|
193
|
+
input: BlockSTFInput,
|
|
184
194
|
options: StateTransitionOpts,
|
|
185
195
|
modules: StateTransitionModules
|
|
186
196
|
): IBeaconStateView;
|
|
@@ -317,33 +327,63 @@ export type IBeaconStateViewLatestFork = Omit<
|
|
|
317
327
|
/**
|
|
318
328
|
* Contract a BeaconStateView backing implementation must satisfy.
|
|
319
329
|
*
|
|
320
|
-
* Differs from `IBeaconStateViewLatestFork` in
|
|
321
|
-
* -
|
|
322
|
-
*
|
|
323
|
-
*
|
|
324
|
-
* -
|
|
325
|
-
* `loadOtherState`, `withParentPayloadApplied`) return `IBeaconStateViewNative`
|
|
326
|
-
* so callers can re-wrap without an `as unknown` cast. Param lists are reused
|
|
327
|
-
* via `Parameters<...>` to avoid duplicating signatures.
|
|
328
|
-
* - `computeNewStateRoot` is implemented by the wrapper because its inputs differ
|
|
329
|
-
* between the TypeScript and Zig implementations.
|
|
330
|
-
*
|
|
331
|
-
* The TS-side `BeaconStateView` also structurally satisfies this contract since
|
|
332
|
-
* `BitArray` exposes `uint8Array` and `bitLen`.
|
|
330
|
+
* Differs from `IBeaconStateViewLatestFork` in these ways:
|
|
331
|
+
* - SSZ-backed lists use serialized bytes or native typed arrays at the FFI boundary.
|
|
332
|
+
* - Methods that produce another view return `IBeaconStateViewNative` so callers can re-wrap them.
|
|
333
|
+
* - `stateTransition` accepts the native block inputs and omits JS-only modules.
|
|
334
|
+
* - `computeNewStateRoot` is implemented by the wrapper because its inputs differ between implementations.
|
|
333
335
|
*/
|
|
334
336
|
export type IBeaconStateViewNative = Omit<
|
|
335
337
|
IBeaconStateViewLatestFork,
|
|
338
|
+
| "builderPendingPayments"
|
|
339
|
+
| "builderPendingWithdrawals"
|
|
340
|
+
| "computeAttestationsRewards"
|
|
341
|
+
| "computeBlockRewards"
|
|
336
342
|
| "computeNewStateRoot"
|
|
343
|
+
| "computeSyncCommitteeRewards"
|
|
344
|
+
| "eth1Data"
|
|
337
345
|
| "executionPayloadAvailability"
|
|
346
|
+
| "getBeaconCommittee"
|
|
347
|
+
| "getIndicesInPayloadTimelinessCommittee"
|
|
348
|
+
| "getPayloadTimelinessCommittee"
|
|
338
349
|
| "loadOtherState"
|
|
339
|
-
| "
|
|
350
|
+
| "pendingConsolidations"
|
|
351
|
+
| "pendingDeposits"
|
|
352
|
+
| "pendingPartialWithdrawals"
|
|
353
|
+
| "preVerifyBuilderDepositsPreGloas"
|
|
354
|
+
| "clearPreGloasBuilderDepositCache"
|
|
340
355
|
| "processSlots"
|
|
356
|
+
| "proposerLookahead"
|
|
357
|
+
| "stateTransition"
|
|
341
358
|
| "withParentPayloadApplied"
|
|
342
359
|
> & {
|
|
360
|
+
pendingDeposits: Uint8Array;
|
|
361
|
+
pendingPartialWithdrawals: Uint8Array;
|
|
362
|
+
pendingConsolidations: Uint8Array;
|
|
363
|
+
proposerLookahead: Uint32Array;
|
|
364
|
+
// UintBn64 lowers to number across the FFI boundary; the wrapper lifts it back to bigint
|
|
365
|
+
eth1Data: phase0.Eth1Data;
|
|
343
366
|
executionPayloadAvailability: {uint8Array: Uint8Array; bitLen: number};
|
|
367
|
+
computeBlockRewards(
|
|
368
|
+
signedBlockBytes: Uint8Array,
|
|
369
|
+
isBlinded: boolean,
|
|
370
|
+
proposerRewards?: RewardCache
|
|
371
|
+
): rewards.BlockRewards;
|
|
372
|
+
computeAttestationsRewards(validatorIds?: (ValidatorIndex | string)[]): rewards.AttestationsRewards;
|
|
373
|
+
computeSyncCommitteeRewards(
|
|
374
|
+
block: BeaconBlock,
|
|
375
|
+
validatorIds: (ValidatorIndex | string)[]
|
|
376
|
+
): rewards.SyncCommitteeRewards;
|
|
377
|
+
getBeaconCommittee(slot: Slot, index: CommitteeIndex): Uint32Array;
|
|
378
|
+
getIndexInPayloadTimelinessCommittee?(validatorIndex: ValidatorIndex, slot: Slot): number;
|
|
379
|
+
getIndicesInPayloadTimelinessCommittee?(validatorIndex: ValidatorIndex, slot: Slot): number[];
|
|
344
380
|
loadOtherState(...args: Parameters<IBeaconStateViewLatestFork["loadOtherState"]>): IBeaconStateViewNative;
|
|
345
|
-
stateTransition(
|
|
346
|
-
|
|
381
|
+
stateTransition(
|
|
382
|
+
signedBlockBytes: Uint8Array,
|
|
383
|
+
isBlinded: boolean,
|
|
384
|
+
options?: StateTransitionOpts
|
|
385
|
+
): IBeaconStateViewNative;
|
|
386
|
+
processSlots(slot: Slot, opts?: {dontTransferCache?: boolean}): IBeaconStateViewNative;
|
|
347
387
|
withParentPayloadApplied(
|
|
348
388
|
...args: Parameters<IBeaconStateViewLatestFork["withParentPayloadApplied"]>
|
|
349
389
|
): IBeaconStateViewNative;
|