@lodestar/state-transition 1.50.0-dev.040a952dd7 → 1.50.0-dev.199b9d3a1f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.d.ts +1 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +0 -1
- package/lib/index.js.map +1 -1
- package/lib/stateView/beaconStateView.d.ts +21 -22
- 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 +21 -34
- package/lib/stateView/interface.d.ts.map +1 -1
- package/lib/stateView/interface.js.map +1 -1
- package/lib/stateView/nativeBeaconStateView.d.ts +100 -92
- package/lib/stateView/nativeBeaconStateView.d.ts.map +1 -1
- package/lib/stateView/nativeBeaconStateView.js +368 -339
- package/lib/stateView/nativeBeaconStateView.js.map +1 -1
- package/lib/stateView/stateViewFactory.d.ts +5 -6
- package/lib/stateView/stateViewFactory.d.ts.map +1 -1
- package/lib/stateView/stateViewFactory.js +8 -12
- package/lib/stateView/stateViewFactory.js.map +1 -1
- package/package.json +7 -7
- package/src/index.ts +1 -3
- package/src/stateView/beaconStateView.ts +76 -75
- package/src/stateView/interface.ts +21 -61
- package/src/stateView/nativeBeaconStateView.ts +375 -354
- package/src/stateView/stateViewFactory.ts +12 -21
|
@@ -55,13 +55,10 @@ 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
|
+
/** Inputs for computing the state root of a locally produced block. */
|
|
59
|
+
export type ComputeNewStateRootInput = {
|
|
60
60
|
block: SignedBeaconBlock | SignedBlindedBeaconBlock;
|
|
61
|
-
/**
|
|
62
|
-
* Fork-specific SSZ serialization of `block`, using the matching full or blinded block type. Native
|
|
63
|
-
* implementations serialize `block` when omitted.
|
|
64
|
-
*/
|
|
61
|
+
/** Pre-serialized block bytes for native implementations. */
|
|
65
62
|
ssz?: Uint8Array;
|
|
66
63
|
};
|
|
67
64
|
|
|
@@ -162,13 +159,6 @@ export interface IBeaconStateView {
|
|
|
162
159
|
// TODO is there a better name that is less implementation specific but still conveys the meaning?
|
|
163
160
|
isStateValidatorsNodesPopulated(): boolean;
|
|
164
161
|
|
|
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
|
-
|
|
172
162
|
// Serialization
|
|
173
163
|
/** Set `preloadValidatorsAndBalances` only when the whole state will be consumed
|
|
174
164
|
* immediately (e.g. CP reload before block replay). */
|
|
@@ -188,9 +178,9 @@ export interface IBeaconStateView {
|
|
|
188
178
|
hashTreeRoot(): Uint8Array;
|
|
189
179
|
|
|
190
180
|
// State transition
|
|
191
|
-
computeNewStateRoot(input:
|
|
181
|
+
computeNewStateRoot(input: ComputeNewStateRootInput, modules: StateTransitionModules): ComputeNewStateRootResult;
|
|
192
182
|
stateTransition(
|
|
193
|
-
|
|
183
|
+
signedBlock: SignedBeaconBlock | SignedBlindedBeaconBlock,
|
|
194
184
|
options: StateTransitionOpts,
|
|
195
185
|
modules: StateTransitionModules
|
|
196
186
|
): IBeaconStateView;
|
|
@@ -327,63 +317,33 @@ export type IBeaconStateViewLatestFork = Omit<
|
|
|
327
317
|
/**
|
|
328
318
|
* Contract a BeaconStateView backing implementation must satisfy.
|
|
329
319
|
*
|
|
330
|
-
* Differs from `IBeaconStateViewLatestFork` in
|
|
331
|
-
* -
|
|
332
|
-
*
|
|
333
|
-
*
|
|
334
|
-
* -
|
|
320
|
+
* Differs from `IBeaconStateViewLatestFork` in two ways:
|
|
321
|
+
* - `executionPayloadAvailability` is a raw `{uint8Array, bitLen}` POJO — a
|
|
322
|
+
* native (`.node`) binding cannot construct a `BitArray` across FFI.
|
|
323
|
+
* `NativeBeaconStateView` lifts it back to `BitArray` for beacon-node.
|
|
324
|
+
* - Methods that produce another view (`stateTransition`, `processSlots`,
|
|
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`.
|
|
335
333
|
*/
|
|
336
334
|
export type IBeaconStateViewNative = Omit<
|
|
337
335
|
IBeaconStateViewLatestFork,
|
|
338
|
-
| "builderPendingPayments"
|
|
339
|
-
| "builderPendingWithdrawals"
|
|
340
|
-
| "computeAttestationsRewards"
|
|
341
|
-
| "computeBlockRewards"
|
|
342
336
|
| "computeNewStateRoot"
|
|
343
|
-
| "computeSyncCommitteeRewards"
|
|
344
|
-
| "eth1Data"
|
|
345
337
|
| "executionPayloadAvailability"
|
|
346
|
-
| "getBeaconCommittee"
|
|
347
|
-
| "getIndicesInPayloadTimelinessCommittee"
|
|
348
|
-
| "getPayloadTimelinessCommittee"
|
|
349
338
|
| "loadOtherState"
|
|
350
|
-
| "pendingConsolidations"
|
|
351
|
-
| "pendingDeposits"
|
|
352
|
-
| "pendingPartialWithdrawals"
|
|
353
|
-
| "preVerifyBuilderDepositsPreGloas"
|
|
354
|
-
| "clearPreGloasBuilderDepositCache"
|
|
355
|
-
| "processSlots"
|
|
356
|
-
| "proposerLookahead"
|
|
357
339
|
| "stateTransition"
|
|
340
|
+
| "processSlots"
|
|
358
341
|
| "withParentPayloadApplied"
|
|
359
342
|
> & {
|
|
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;
|
|
366
343
|
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[];
|
|
380
344
|
loadOtherState(...args: Parameters<IBeaconStateViewLatestFork["loadOtherState"]>): IBeaconStateViewNative;
|
|
381
|
-
stateTransition(
|
|
382
|
-
|
|
383
|
-
isBlinded: boolean,
|
|
384
|
-
options?: StateTransitionOpts
|
|
385
|
-
): IBeaconStateViewNative;
|
|
386
|
-
processSlots(slot: Slot, opts?: {dontTransferCache?: boolean}): IBeaconStateViewNative;
|
|
345
|
+
stateTransition(...args: Parameters<IBeaconStateViewLatestFork["stateTransition"]>): IBeaconStateViewNative;
|
|
346
|
+
processSlots(...args: Parameters<IBeaconStateViewLatestFork["processSlots"]>): IBeaconStateViewNative;
|
|
387
347
|
withParentPayloadApplied(
|
|
388
348
|
...args: Parameters<IBeaconStateViewLatestFork["withParentPayloadApplied"]>
|
|
389
349
|
): IBeaconStateViewNative;
|