@lodestar/state-transition 1.51.0-dev.83da04fef3 → 1.51.0-dev.8a64241e1b
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/index.d.ts +1 -1
- package/lib/block/index.d.ts.map +1 -1
- package/lib/block/index.js +2 -2
- package/lib/block/index.js.map +1 -1
- package/lib/block/processDeposit.d.ts.map +1 -1
- package/lib/block/processDeposit.js +1 -1
- package/lib/block/processDeposit.js.map +1 -1
- package/lib/block/processOperations.d.ts +1 -1
- package/lib/block/processOperations.d.ts.map +1 -1
- package/lib/block/processOperations.js +1 -1
- package/lib/block/processOperations.js.map +1 -1
- package/lib/cache/epochCache.d.ts +2 -2
- package/lib/cache/epochCache.d.ts.map +1 -1
- package/lib/cache/epochCache.js +1 -1
- package/lib/cache/epochCache.js.map +1 -1
- package/lib/cache/syncCommitteeCache.d.ts +1 -1
- package/lib/cache/syncCommitteeCache.d.ts.map +1 -1
- package/lib/epoch/index.d.ts +2 -2
- package/lib/epoch/index.d.ts.map +1 -1
- package/lib/epoch/index.js +2 -2
- package/lib/epoch/index.js.map +1 -1
- package/lib/epoch/processSyncCommitteeUpdates.js +1 -1
- package/lib/epoch/processSyncCommitteeUpdates.js.map +1 -1
- package/lib/lightClient/spec/store.d.ts +1 -1
- package/lib/lightClient/spec/store.d.ts.map +1 -1
- package/lib/lightClient/spec/utils.d.ts.map +1 -1
- package/lib/lightClient/spec/utils.js +1 -1
- package/lib/lightClient/spec/utils.js.map +1 -1
- package/lib/lightClient/spec/validateLightClientUpdate.d.ts.map +1 -1
- package/lib/lightClient/spec/validateLightClientUpdate.js +1 -1
- package/lib/lightClient/spec/validateLightClientUpdate.js.map +1 -1
- package/lib/metrics.d.ts +1 -1
- package/lib/metrics.d.ts.map +1 -1
- package/lib/metrics.js +4 -4
- package/lib/metrics.js.map +1 -1
- package/lib/rewards/attestationsRewards.d.ts +1 -1
- package/lib/rewards/attestationsRewards.d.ts.map +1 -1
- package/lib/rewards/syncCommitteeRewards.d.ts +1 -1
- package/lib/rewards/syncCommitteeRewards.d.ts.map +1 -1
- package/lib/signatureSets/inclusionList.d.ts +5 -0
- package/lib/signatureSets/inclusionList.d.ts.map +1 -0
- package/lib/signatureSets/inclusionList.js +14 -0
- package/lib/signatureSets/inclusionList.js.map +1 -0
- package/lib/signatureSets/index.d.ts +1 -0
- package/lib/signatureSets/index.d.ts.map +1 -1
- package/lib/signatureSets/index.js +1 -0
- package/lib/signatureSets/index.js.map +1 -1
- package/lib/stateTransition.js +2 -2
- package/lib/stateTransition.js.map +1 -1
- package/lib/stateView/beaconStateView.d.ts +1 -0
- package/lib/stateView/beaconStateView.d.ts.map +1 -1
- package/lib/stateView/beaconStateView.js +5 -1
- package/lib/stateView/beaconStateView.js.map +1 -1
- package/lib/stateView/interface.d.ts +2 -4
- package/lib/stateView/interface.d.ts.map +1 -1
- package/lib/stateView/interface.js.map +1 -1
- package/lib/stateView/nativeBeaconStateView.d.ts +14 -7
- package/lib/stateView/nativeBeaconStateView.d.ts.map +1 -1
- package/lib/stateView/nativeBeaconStateView.js +67 -26
- package/lib/stateView/nativeBeaconStateView.js.map +1 -1
- package/lib/stateView/stateViewFactory.d.ts.map +1 -1
- package/lib/stateView/stateViewFactory.js +2 -2
- package/lib/stateView/stateViewFactory.js.map +1 -1
- package/lib/testUtils/interopPubkeyCache.js +1 -1
- package/lib/testUtils/interopPubkeyCache.js.map +1 -1
- package/lib/testUtils/state.d.ts.map +1 -1
- package/lib/testUtils/state.js +1 -1
- package/lib/testUtils/state.js.map +1 -1
- package/lib/testUtils/util.d.ts +1 -1
- package/lib/testUtils/util.d.ts.map +1 -1
- package/lib/testUtils/util.js +2 -2
- package/lib/testUtils/util.js.map +1 -1
- package/lib/util/blindedBlock.d.ts.map +1 -1
- package/lib/util/blindedBlock.js +4 -12
- package/lib/util/blindedBlock.js.map +1 -1
- package/lib/util/epochShuffling.d.ts.map +1 -1
- package/lib/util/epochShuffling.js +1 -1
- package/lib/util/epochShuffling.js.map +1 -1
- package/lib/util/genesis.d.ts.map +1 -1
- package/lib/util/genesis.js +8 -1
- package/lib/util/genesis.js.map +1 -1
- package/lib/util/inclusionListCommittee.d.ts +9 -0
- package/lib/util/inclusionListCommittee.d.ts.map +1 -0
- package/lib/util/inclusionListCommittee.js +18 -0
- package/lib/util/inclusionListCommittee.js.map +1 -0
- package/lib/util/index.d.ts +1 -0
- package/lib/util/index.d.ts.map +1 -1
- package/lib/util/index.js +1 -0
- package/lib/util/index.js.map +1 -1
- package/lib/util/interop.d.ts +1 -1
- package/lib/util/interop.d.ts.map +1 -1
- package/lib/util/interop.js +1 -1
- package/lib/util/interop.js.map +1 -1
- package/lib/util/seed.js +1 -1
- package/lib/util/seed.js.map +1 -1
- package/lib/util/shuffling.d.ts +3 -0
- package/lib/util/shuffling.d.ts.map +1 -1
- package/lib/util/shuffling.js +41 -1
- package/lib/util/shuffling.js.map +1 -1
- package/lib/util/signatureSets.d.ts +1 -1
- package/lib/util/signatureSets.d.ts.map +1 -1
- package/lib/util/signatureSets.js +1 -1
- package/lib/util/signatureSets.js.map +1 -1
- package/lib/util/syncCommittee.d.ts.map +1 -1
- package/lib/util/syncCommittee.js +1 -1
- package/lib/util/syncCommittee.js.map +1 -1
- package/package.json +9 -9
- package/src/block/index.ts +11 -12
- package/src/block/processDeposit.ts +2 -2
- package/src/block/processOperations.ts +5 -5
- package/src/cache/epochCache.ts +2 -2
- package/src/cache/syncCommitteeCache.ts +1 -1
- package/src/epoch/index.ts +14 -15
- package/src/epoch/processSyncCommitteeUpdates.ts +1 -1
- package/src/lightClient/spec/store.ts +1 -1
- package/src/lightClient/spec/utils.ts +1 -1
- package/src/lightClient/spec/validateLightClientUpdate.ts +1 -1
- package/src/metrics.ts +5 -4
- package/src/rewards/attestationsRewards.ts +1 -1
- package/src/rewards/syncCommitteeRewards.ts +1 -1
- package/src/signatureSets/inclusionList.ts +20 -0
- package/src/signatureSets/index.ts +1 -0
- package/src/stateTransition.ts +2 -2
- package/src/stateView/beaconStateView.ts +5 -1
- package/src/stateView/interface.ts +1 -12
- package/src/stateView/nativeBeaconStateView.ts +67 -33
- package/src/stateView/stateViewFactory.ts +2 -2
- package/src/testUtils/interopPubkeyCache.ts +1 -1
- package/src/testUtils/state.ts +1 -1
- package/src/testUtils/util.ts +2 -2
- package/src/util/blindedBlock.ts +4 -12
- package/src/util/epochShuffling.ts +1 -1
- package/src/util/genesis.ts +9 -1
- package/src/util/inclusionListCommittee.ts +17 -0
- package/src/util/index.ts +1 -0
- package/src/util/interop.ts +1 -1
- package/src/util/seed.ts +1 -1
- package/src/util/shuffling.ts +46 -1
- package/src/util/signatureSets.ts +1 -1
- package/src/util/syncCommittee.ts +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {aggregateSerializedPublicKeys} from "@
|
|
1
|
+
import {aggregateSerializedPublicKeys} from "@lodestar/native/blst";
|
|
2
2
|
import {EPOCHS_PER_SYNC_COMMITTEE_PERIOD, ForkSeq} from "@lodestar/params";
|
|
3
3
|
import {ssz} from "@lodestar/types";
|
|
4
4
|
import {CachedBeaconStateAltair} from "../types.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type {PublicKey} from "@chainsafe/lodestar-z/blst";
|
|
2
1
|
import {BeaconConfig} from "@lodestar/config";
|
|
2
|
+
import type {PublicKey} from "@lodestar/native/blst";
|
|
3
3
|
import {LightClientBootstrap, LightClientHeader, LightClientUpdate, SyncPeriod} from "@lodestar/types";
|
|
4
4
|
import {computeSyncPeriodAtSlot} from "../../util/epoch.js";
|
|
5
5
|
import type {LightClientUpdateSummary} from "./isBetterUpdate.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {PublicKey} from "@chainsafe/lodestar-z/blst";
|
|
2
1
|
import {Tree} from "@chainsafe/persistent-merkle-tree";
|
|
3
2
|
import {BitArray} from "@chainsafe/ssz";
|
|
4
3
|
import {ChainForkConfig} from "@lodestar/config";
|
|
4
|
+
import {PublicKey} from "@lodestar/native/blst";
|
|
5
5
|
import {
|
|
6
6
|
BLOCK_BODY_EXECUTION_PAYLOAD_GINDEX,
|
|
7
7
|
CURRENT_SYNC_COMMITTEE_GINDEX,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {PublicKey, Signature, fastAggregateVerify} from "@chainsafe/lodestar-z/blst";
|
|
2
1
|
import {ChainForkConfig} from "@lodestar/config";
|
|
2
|
+
import {PublicKey, Signature, fastAggregateVerify} from "@lodestar/native/blst";
|
|
3
3
|
import {DOMAIN_SYNC_COMMITTEE, GENESIS_SLOT, MIN_SYNC_COMMITTEE_PARTICIPANTS} from "@lodestar/params";
|
|
4
4
|
import {LightClientUpdate, Root, ssz} from "@lodestar/types";
|
|
5
5
|
import type {ILightClientStore, SyncCommitteeFast} from "./store.js";
|
package/src/metrics.ts
CHANGED
|
@@ -156,19 +156,20 @@ export function getMetrics(register: MetricsRegister) {
|
|
|
156
156
|
}
|
|
157
157
|
|
|
158
158
|
export function onStateCloneMetrics(
|
|
159
|
-
|
|
159
|
+
clonedState: CachedBeaconStateAllForks,
|
|
160
|
+
clonedCount: number,
|
|
160
161
|
metrics: BeaconStateTransitionMetrics,
|
|
161
162
|
source: StateCloneSource
|
|
162
163
|
): void {
|
|
163
|
-
metrics.preStateClonedCount.observe(
|
|
164
|
+
metrics.preStateClonedCount.observe(clonedCount);
|
|
164
165
|
|
|
165
|
-
if (isBalancesNodesPopulated(
|
|
166
|
+
if (isBalancesNodesPopulated(clonedState)) {
|
|
166
167
|
metrics.preStateBalancesNodesPopulatedHit.inc({source});
|
|
167
168
|
} else {
|
|
168
169
|
metrics.preStateBalancesNodesPopulatedMiss.inc({source});
|
|
169
170
|
}
|
|
170
171
|
|
|
171
|
-
if (isValidatorsNodesPopulated(
|
|
172
|
+
if (isValidatorsNodesPopulated(clonedState)) {
|
|
172
173
|
metrics.preStateValidatorsNodesPopulatedHit.inc({source});
|
|
173
174
|
} else {
|
|
174
175
|
metrics.preStateValidatorsNodesPopulatedMiss.inc({source});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {type PubkeyCache} from "@chainsafe/lodestar-z/pubkeys";
|
|
2
1
|
import {BeaconConfig} from "@lodestar/config";
|
|
2
|
+
import {type PubkeyCache} from "@lodestar/native/pubkeys";
|
|
3
3
|
import {ForkName, SYNC_COMMITTEE_SIZE} from "@lodestar/params";
|
|
4
4
|
import {BeaconBlock, ValidatorIndex, altair, rewards} from "@lodestar/types";
|
|
5
5
|
import {toPubkeyHex} from "@lodestar/utils";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {BeaconConfig} from "@lodestar/config";
|
|
2
|
+
import {DOMAIN_INCLUSION_LIST_COMMITTEE} from "@lodestar/params";
|
|
3
|
+
import {Slot, heze, ssz} from "@lodestar/types";
|
|
4
|
+
import {ISignatureSet, SignatureSetType, computeSigningRoot} from "../util/index.js";
|
|
5
|
+
|
|
6
|
+
export function getInclusionListSignatureSet(
|
|
7
|
+
config: BeaconConfig,
|
|
8
|
+
stateSlot: Slot,
|
|
9
|
+
signedInclusionList: heze.SignedInclusionList
|
|
10
|
+
): ISignatureSet {
|
|
11
|
+
const message = signedInclusionList.message;
|
|
12
|
+
const domain = config.getDomain(stateSlot, DOMAIN_INCLUSION_LIST_COMMITTEE, message.slot);
|
|
13
|
+
|
|
14
|
+
return {
|
|
15
|
+
type: SignatureSetType.indexed,
|
|
16
|
+
index: message.validatorIndex,
|
|
17
|
+
signingRoot: computeSigningRoot(ssz.heze.InclusionList, message, domain),
|
|
18
|
+
signature: signedInclusionList.signature,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
@@ -18,6 +18,7 @@ export * from "./attesterSlashings.js";
|
|
|
18
18
|
export * from "./blsToExecutionChange.js";
|
|
19
19
|
export * from "./executionPayloadBid.js";
|
|
20
20
|
export * from "./executionPayloadEnvelope.js";
|
|
21
|
+
export * from "./inclusionList.js";
|
|
21
22
|
export * from "./indexedAttestation.js";
|
|
22
23
|
export * from "./indexedPayloadAttestation.js";
|
|
23
24
|
export * from "./proposer.js";
|
package/src/stateTransition.ts
CHANGED
|
@@ -101,7 +101,7 @@ export function stateTransition(
|
|
|
101
101
|
let postState = state.clone(options.dontTransferCache);
|
|
102
102
|
|
|
103
103
|
if (metrics) {
|
|
104
|
-
onStateCloneMetrics(postState, metrics, StateCloneSource.stateTransition);
|
|
104
|
+
onStateCloneMetrics(postState, state.clonedCount, metrics, StateCloneSource.stateTransition);
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
// State is already a ViewDU, which won't commit changes. Equivalent to .setStateCachesAsTransient()
|
|
@@ -168,7 +168,7 @@ export function processSlots(
|
|
|
168
168
|
let postState = state.clone(opts?.dontTransferCache);
|
|
169
169
|
|
|
170
170
|
if (metrics) {
|
|
171
|
-
onStateCloneMetrics(postState, metrics, StateCloneSource.processSlots);
|
|
171
|
+
onStateCloneMetrics(postState, state.clonedCount, metrics, StateCloneSource.processSlots);
|
|
172
172
|
}
|
|
173
173
|
|
|
174
174
|
// State is already a ViewDU, which won't commit changes. Equivalent to .setStateCachesAsTransient()
|
|
@@ -84,6 +84,7 @@ export class BeaconStateView implements IBeaconStateViewLatestFork {
|
|
|
84
84
|
// phase0
|
|
85
85
|
private cachedFork: Fork | null = null;
|
|
86
86
|
private cachedLatestBlockHeader: phase0.BeaconBlockHeader | null = null;
|
|
87
|
+
private cachedEffectiveBalanceIncrementsZeroInactive: EffectiveBalanceIncrements | null = null;
|
|
87
88
|
// altair
|
|
88
89
|
private cachedCurrentSyncCommittee: SyncCommittee | null = null;
|
|
89
90
|
private cachedNextSyncCommittee: SyncCommittee | null = null;
|
|
@@ -638,7 +639,10 @@ export class BeaconStateView implements IBeaconStateViewLatestFork {
|
|
|
638
639
|
}
|
|
639
640
|
|
|
640
641
|
getEffectiveBalanceIncrementsZeroInactive(): EffectiveBalanceIncrements {
|
|
641
|
-
|
|
642
|
+
if (this.cachedEffectiveBalanceIncrementsZeroInactive === null) {
|
|
643
|
+
this.cachedEffectiveBalanceIncrementsZeroInactive = getEffectiveBalanceIncrementsZeroInactive(this.cachedState);
|
|
644
|
+
}
|
|
645
|
+
return this.cachedEffectiveBalanceIncrementsZeroInactive;
|
|
642
646
|
}
|
|
643
647
|
|
|
644
648
|
getBalance(index: number): number {
|
|
@@ -336,8 +336,6 @@ export type IBeaconStateViewLatestFork = Omit<
|
|
|
336
336
|
*/
|
|
337
337
|
export type IBeaconStateViewNative = Omit<
|
|
338
338
|
IBeaconStateViewLatestFork,
|
|
339
|
-
| "builderPendingPayments"
|
|
340
|
-
| "builderPendingWithdrawals"
|
|
341
339
|
| "computeAttestationsRewards"
|
|
342
340
|
| "computeBlockRewards"
|
|
343
341
|
| "computeNewStateRoot"
|
|
@@ -346,14 +344,10 @@ export type IBeaconStateViewNative = Omit<
|
|
|
346
344
|
| "eth1Data"
|
|
347
345
|
| "executionPayloadAvailability"
|
|
348
346
|
| "getBeaconCommittee"
|
|
349
|
-
| "getIndicesInPayloadTimelinessCommittee"
|
|
350
|
-
| "getPayloadTimelinessCommittee"
|
|
351
347
|
| "loadOtherState"
|
|
352
348
|
| "pendingConsolidations"
|
|
353
349
|
| "pendingDeposits"
|
|
354
350
|
| "pendingPartialWithdrawals"
|
|
355
|
-
| "preVerifyBuilderDepositsPreGloas"
|
|
356
|
-
| "clearPreGloasBuilderDepositCache"
|
|
357
351
|
| "processSlots"
|
|
358
352
|
| "proposerLookahead"
|
|
359
353
|
| "stateTransition"
|
|
@@ -365,7 +359,6 @@ export type IBeaconStateViewNative = Omit<
|
|
|
365
359
|
pendingPartialWithdrawals: Uint8Array;
|
|
366
360
|
pendingConsolidations: Uint8Array;
|
|
367
361
|
proposerLookahead: Uint32Array;
|
|
368
|
-
// UintBn64 lowers to number across the FFI boundary; the wrapper lifts it back to bigint
|
|
369
362
|
eth1Data: phase0.Eth1Data;
|
|
370
363
|
executionPayloadAvailability: {uint8Array: Uint8Array; bitLen: number};
|
|
371
364
|
computeBlockRewards(
|
|
@@ -379,8 +372,6 @@ export type IBeaconStateViewNative = Omit<
|
|
|
379
372
|
validatorIds: (ValidatorIndex | string)[]
|
|
380
373
|
): rewards.SyncCommitteeRewards;
|
|
381
374
|
getBeaconCommittee(slot: Slot, index: CommitteeIndex): Uint32Array;
|
|
382
|
-
getIndexInPayloadTimelinessCommittee?(validatorIndex: ValidatorIndex, slot: Slot): number;
|
|
383
|
-
getIndicesInPayloadTimelinessCommittee?(validatorIndex: ValidatorIndex, slot: Slot): number[];
|
|
384
375
|
loadOtherState(...args: Parameters<IBeaconStateViewLatestFork["loadOtherState"]>): IBeaconStateViewNative;
|
|
385
376
|
stateTransition(
|
|
386
377
|
signedBlockBytes: Uint8Array,
|
|
@@ -388,9 +379,7 @@ export type IBeaconStateViewNative = Omit<
|
|
|
388
379
|
options?: StateTransitionOpts
|
|
389
380
|
): IBeaconStateViewNative;
|
|
390
381
|
processSlots(slot: Slot, opts?: {dontTransferCache?: boolean}): IBeaconStateViewNative;
|
|
391
|
-
withParentPayloadApplied(
|
|
392
|
-
...args: Parameters<IBeaconStateViewLatestFork["withParentPayloadApplied"]>
|
|
393
|
-
): IBeaconStateViewNative;
|
|
382
|
+
withParentPayloadApplied(executionRequestsBytes: Uint8Array): IBeaconStateViewNative;
|
|
394
383
|
};
|
|
395
384
|
|
|
396
385
|
export function isStatePostAltair(state: IBeaconStateView): state is IBeaconStateViewAltair {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {CompactMultiProof} from "@chainsafe/persistent-merkle-tree";
|
|
2
2
|
import {BitArray, ByteViews} from "@chainsafe/ssz";
|
|
3
3
|
import type {BeaconConfig} from "@lodestar/config";
|
|
4
|
-
import {ForkName, ForkSeq} from "@lodestar/params";
|
|
4
|
+
import {ForkName, ForkPostElectra, ForkSeq} from "@lodestar/params";
|
|
5
5
|
import {
|
|
6
6
|
BeaconBlock,
|
|
7
7
|
BeaconState,
|
|
@@ -28,6 +28,7 @@ import {
|
|
|
28
28
|
phase0,
|
|
29
29
|
rewards,
|
|
30
30
|
ssz,
|
|
31
|
+
sszTypesFor,
|
|
31
32
|
} from "@lodestar/types";
|
|
32
33
|
import {Checkpoint, Fork} from "@lodestar/types/phase0";
|
|
33
34
|
import {VoluntaryExitValidity} from "../block/processVoluntaryExit.js";
|
|
@@ -47,6 +48,7 @@ import {
|
|
|
47
48
|
IBeaconStateViewGloas,
|
|
48
49
|
IBeaconStateViewLatestFork,
|
|
49
50
|
IBeaconStateViewNative,
|
|
51
|
+
isStatePostGloas,
|
|
50
52
|
} from "./interface.js";
|
|
51
53
|
|
|
52
54
|
/**
|
|
@@ -115,6 +117,14 @@ export class NativeBeaconStateView implements IBeaconStateViewLatestFork {
|
|
|
115
117
|
private cachedPendingConsolidationsCount: number | null = null;
|
|
116
118
|
// fulu
|
|
117
119
|
private cachedProposerLookahead: fulu.ProposerLookahead | null = null;
|
|
120
|
+
// gloas
|
|
121
|
+
private cachedLatestBlockHash: Bytes32 | null = null;
|
|
122
|
+
private cachedExecutionPayloadAvailability: BitArray | null = null;
|
|
123
|
+
private cachedLatestExecutionPayloadBid: ExecutionPayloadBid | null = null;
|
|
124
|
+
private cachedPayloadExpectedWithdrawals: capella.Withdrawal[] | null = null;
|
|
125
|
+
private cachedBuilderPendingPayments: gloas.BuilderPendingPayments | null = null;
|
|
126
|
+
private cachedBuilderPendingWithdrawals: gloas.BuilderPendingWithdrawals | null = null;
|
|
127
|
+
private cachedBuildersLength: number | null = null;
|
|
118
128
|
// Per-argument caches for argument-taking methods. The binding is treated as
|
|
119
129
|
// immutable for the view's lifetime, so a given argument always yields the
|
|
120
130
|
// same result. Maps grow only with touched arguments — typical call patterns
|
|
@@ -174,7 +184,11 @@ export class NativeBeaconStateView implements IBeaconStateViewLatestFork {
|
|
|
174
184
|
}
|
|
175
185
|
|
|
176
186
|
get executionPayloadAvailability(): BitArray {
|
|
177
|
-
|
|
187
|
+
if (this.cachedExecutionPayloadAvailability === null) {
|
|
188
|
+
const {uint8Array, bitLen} = this.binding.executionPayloadAvailability;
|
|
189
|
+
this.cachedExecutionPayloadAvailability = new BitArray(uint8Array, bitLen);
|
|
190
|
+
}
|
|
191
|
+
return this.cachedExecutionPayloadAvailability;
|
|
178
192
|
}
|
|
179
193
|
|
|
180
194
|
// ─── phase0 ──────────────────────────────────────────────────────────────
|
|
@@ -832,7 +846,8 @@ export class NativeBeaconStateView implements IBeaconStateViewLatestFork {
|
|
|
832
846
|
|
|
833
847
|
get pendingDeposits(): electra.PendingDeposits {
|
|
834
848
|
if (this.cachedPendingDeposits === null) {
|
|
835
|
-
|
|
849
|
+
const type = sszTypesFor(this.forkName as ForkPostElectra).PendingDeposits;
|
|
850
|
+
this.cachedPendingDeposits = type.deserialize(this.binding.pendingDeposits);
|
|
836
851
|
}
|
|
837
852
|
return this.cachedPendingDeposits;
|
|
838
853
|
}
|
|
@@ -846,9 +861,8 @@ export class NativeBeaconStateView implements IBeaconStateViewLatestFork {
|
|
|
846
861
|
|
|
847
862
|
get pendingPartialWithdrawals(): electra.PendingPartialWithdrawals {
|
|
848
863
|
if (this.cachedPendingPartialWithdrawals === null) {
|
|
849
|
-
this.
|
|
850
|
-
|
|
851
|
-
);
|
|
864
|
+
const type = sszTypesFor(this.forkName as ForkPostElectra).PendingPartialWithdrawals;
|
|
865
|
+
this.cachedPendingPartialWithdrawals = type.deserialize(this.binding.pendingPartialWithdrawals);
|
|
852
866
|
}
|
|
853
867
|
return this.cachedPendingPartialWithdrawals;
|
|
854
868
|
}
|
|
@@ -862,9 +876,8 @@ export class NativeBeaconStateView implements IBeaconStateViewLatestFork {
|
|
|
862
876
|
|
|
863
877
|
get pendingConsolidations(): electra.PendingConsolidations {
|
|
864
878
|
if (this.cachedPendingConsolidations === null) {
|
|
865
|
-
this.
|
|
866
|
-
|
|
867
|
-
);
|
|
879
|
+
const type = sszTypesFor(this.forkName as ForkPostElectra).PendingConsolidations;
|
|
880
|
+
this.cachedPendingConsolidations = type.deserialize(this.binding.pendingConsolidations);
|
|
868
881
|
}
|
|
869
882
|
return this.cachedPendingConsolidations;
|
|
870
883
|
}
|
|
@@ -885,64 +898,85 @@ export class NativeBeaconStateView implements IBeaconStateViewLatestFork {
|
|
|
885
898
|
return this.cachedProposerLookahead;
|
|
886
899
|
}
|
|
887
900
|
|
|
888
|
-
preVerifyBuilderDepositsPreGloas(
|
|
889
|
-
|
|
890
|
-
_maxDurationMs: number
|
|
891
|
-
): PreVerifyBuilderDepositsResult {
|
|
892
|
-
throw new Error("NativeBeaconStateView does not support Gloas");
|
|
901
|
+
preVerifyBuilderDepositsPreGloas(maxBuilderDeposits: number, maxDurationMs: number): PreVerifyBuilderDepositsResult {
|
|
902
|
+
return this.binding.preVerifyBuilderDepositsPreGloas(maxBuilderDeposits, maxDurationMs);
|
|
893
903
|
}
|
|
894
904
|
|
|
895
905
|
clearPreGloasBuilderDepositCache(): void {
|
|
896
|
-
|
|
906
|
+
this.binding.clearPreGloasBuilderDepositCache();
|
|
897
907
|
}
|
|
898
908
|
|
|
899
909
|
// ─── gloas ───────────────────────────────────────────────────────────────
|
|
900
910
|
|
|
901
911
|
get latestBlockHash(): Bytes32 {
|
|
902
|
-
|
|
912
|
+
if (this.cachedLatestBlockHash === null) {
|
|
913
|
+
this.cachedLatestBlockHash = this.binding.latestBlockHash;
|
|
914
|
+
}
|
|
915
|
+
return this.cachedLatestBlockHash;
|
|
903
916
|
}
|
|
904
917
|
|
|
905
918
|
get latestExecutionPayloadBid(): ExecutionPayloadBid {
|
|
906
|
-
|
|
919
|
+
if (this.cachedLatestExecutionPayloadBid === null) {
|
|
920
|
+
this.cachedLatestExecutionPayloadBid = this.binding.latestExecutionPayloadBid;
|
|
921
|
+
}
|
|
922
|
+
return this.cachedLatestExecutionPayloadBid;
|
|
907
923
|
}
|
|
908
924
|
|
|
909
925
|
get payloadExpectedWithdrawals(): capella.Withdrawal[] {
|
|
910
|
-
|
|
926
|
+
if (this.cachedPayloadExpectedWithdrawals === null) {
|
|
927
|
+
this.cachedPayloadExpectedWithdrawals = this.binding.payloadExpectedWithdrawals;
|
|
928
|
+
}
|
|
929
|
+
return this.cachedPayloadExpectedWithdrawals;
|
|
911
930
|
}
|
|
912
931
|
|
|
913
932
|
get builderPendingPayments(): gloas.BuilderPendingPayments {
|
|
914
|
-
|
|
933
|
+
if (this.cachedBuilderPendingPayments === null) {
|
|
934
|
+
this.cachedBuilderPendingPayments = this.binding.builderPendingPayments;
|
|
935
|
+
}
|
|
936
|
+
return this.cachedBuilderPendingPayments;
|
|
915
937
|
}
|
|
916
938
|
|
|
917
939
|
get builderPendingWithdrawals(): gloas.BuilderPendingWithdrawals {
|
|
918
|
-
|
|
940
|
+
if (this.cachedBuilderPendingWithdrawals === null) {
|
|
941
|
+
this.cachedBuilderPendingWithdrawals = this.binding.builderPendingWithdrawals;
|
|
942
|
+
}
|
|
943
|
+
return this.cachedBuilderPendingWithdrawals;
|
|
919
944
|
}
|
|
920
945
|
|
|
921
|
-
getBuilder(
|
|
922
|
-
|
|
946
|
+
getBuilder(index: BuilderIndex): gloas.Builder {
|
|
947
|
+
return this.binding.getBuilder(index);
|
|
923
948
|
}
|
|
924
949
|
|
|
925
950
|
getBuildersLength(): number {
|
|
926
|
-
|
|
951
|
+
if (this.cachedBuildersLength === null) {
|
|
952
|
+
this.cachedBuildersLength = this.binding.getBuildersLength();
|
|
953
|
+
}
|
|
954
|
+
return this.cachedBuildersLength;
|
|
927
955
|
}
|
|
928
956
|
|
|
929
|
-
canBuilderCoverBid(
|
|
930
|
-
|
|
957
|
+
canBuilderCoverBid(builderIndex: BuilderIndex, bidAmount: number): boolean {
|
|
958
|
+
return this.binding.canBuilderCoverBid(builderIndex, bidAmount);
|
|
931
959
|
}
|
|
932
960
|
|
|
933
|
-
getEpochPTCs(
|
|
934
|
-
|
|
961
|
+
getEpochPTCs(epoch: Epoch): Uint32Array[] {
|
|
962
|
+
return this.binding.getEpochPTCs(epoch);
|
|
935
963
|
}
|
|
936
964
|
|
|
937
|
-
getPayloadTimelinessCommittee(
|
|
938
|
-
|
|
965
|
+
getPayloadTimelinessCommittee(slot: Slot): Uint32Array {
|
|
966
|
+
return this.binding.getPayloadTimelinessCommittee(slot);
|
|
939
967
|
}
|
|
940
968
|
|
|
941
|
-
getIndicesInPayloadTimelinessCommittee(
|
|
942
|
-
|
|
969
|
+
getIndicesInPayloadTimelinessCommittee(validatorIndex: ValidatorIndex, slot: Slot): number[] {
|
|
970
|
+
return this.binding.getIndicesInPayloadTimelinessCommittee(validatorIndex, slot);
|
|
943
971
|
}
|
|
944
972
|
|
|
945
|
-
withParentPayloadApplied(
|
|
946
|
-
|
|
973
|
+
withParentPayloadApplied(executionRequests: gloas.ExecutionRequests): IBeaconStateViewGloas {
|
|
974
|
+
const bytes = ssz.gloas.ExecutionRequests.serialize(executionRequests);
|
|
975
|
+
const state = new NativeBeaconStateView(this.config, this.binding.withParentPayloadApplied(bytes));
|
|
976
|
+
if (!isStatePostGloas(state)) {
|
|
977
|
+
state.release();
|
|
978
|
+
throw Error("Expected Gloas state after applying the parent payload");
|
|
979
|
+
}
|
|
980
|
+
return state;
|
|
947
981
|
}
|
|
948
982
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import bindings from "@chainsafe/lodestar-z";
|
|
2
|
-
import {pubkeyCache} from "@chainsafe/lodestar-z/pubkeys";
|
|
3
1
|
import {BeaconConfig} from "@lodestar/config";
|
|
2
|
+
import bindings from "@lodestar/native";
|
|
3
|
+
import {pubkeyCache} from "@lodestar/native/pubkeys";
|
|
4
4
|
import {createCachedBeaconState} from "../cache/stateCache.js";
|
|
5
5
|
import {getStateTypeFromBytes} from "../util/sszBytes.js";
|
|
6
6
|
import {BeaconStateView} from "./beaconStateView.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import {pubkeyCache} from "@
|
|
3
|
+
import {pubkeyCache} from "@lodestar/native/pubkeys";
|
|
4
4
|
import {interopSecretKey} from "../util/interop.js";
|
|
5
5
|
import {testCachePath} from "./cache.js";
|
|
6
6
|
|
package/src/testUtils/state.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {pubkeyCache} from "@chainsafe/lodestar-z/pubkeys";
|
|
2
1
|
import {ChainForkConfig, createBeaconConfig} from "@lodestar/config";
|
|
3
2
|
import {config, config as minimalConfig} from "@lodestar/config/default";
|
|
3
|
+
import {pubkeyCache} from "@lodestar/native/pubkeys";
|
|
4
4
|
import {
|
|
5
5
|
EPOCHS_PER_HISTORICAL_VECTOR,
|
|
6
6
|
EPOCHS_PER_SLASHINGS_VECTOR,
|
package/src/testUtils/util.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {PublicKey, SecretKey} from "@chainsafe/lodestar-z/blst";
|
|
2
|
-
import {pubkeyCache} from "@chainsafe/lodestar-z/pubkeys";
|
|
3
1
|
import {BitArray, fromHexString} from "@chainsafe/ssz";
|
|
4
2
|
import {BeaconConfig, createBeaconConfig, createChainForkConfig} from "@lodestar/config";
|
|
5
3
|
import {config} from "@lodestar/config/default";
|
|
4
|
+
import {PublicKey, SecretKey} from "@lodestar/native/blst";
|
|
5
|
+
import {pubkeyCache} from "@lodestar/native/pubkeys";
|
|
6
6
|
import {
|
|
7
7
|
BUILDER_WITHDRAWAL_PREFIX,
|
|
8
8
|
DOMAIN_DEPOSIT,
|
package/src/util/blindedBlock.ts
CHANGED
|
@@ -33,13 +33,9 @@ export function blindedOrFullBlockHashTreeRoot(
|
|
|
33
33
|
): Root {
|
|
34
34
|
return isBlindedBeaconBlock(blindedOrFull)
|
|
35
35
|
? // Blinded
|
|
36
|
-
config
|
|
37
|
-
.getPostBellatrixForkTypes(blindedOrFull.slot)
|
|
38
|
-
.BlindedBeaconBlock.hashTreeRoot(blindedOrFull)
|
|
36
|
+
config.getPostBellatrixForkTypes(blindedOrFull.slot).BlindedBeaconBlock.hashTreeRoot(blindedOrFull)
|
|
39
37
|
: // Full
|
|
40
|
-
config
|
|
41
|
-
.getForkTypes(blindedOrFull.slot)
|
|
42
|
-
.BeaconBlock.hashTreeRoot(blindedOrFull);
|
|
38
|
+
config.getForkTypes(blindedOrFull.slot).BeaconBlock.hashTreeRoot(blindedOrFull);
|
|
43
39
|
}
|
|
44
40
|
|
|
45
41
|
export function blindedOrFullBlockToHeader(
|
|
@@ -48,13 +44,9 @@ export function blindedOrFullBlockToHeader(
|
|
|
48
44
|
): BeaconBlockHeader {
|
|
49
45
|
const bodyRoot = isBlindedBeaconBlock(blindedOrFull)
|
|
50
46
|
? // Blinded
|
|
51
|
-
config
|
|
52
|
-
.getPostBellatrixForkTypes(blindedOrFull.slot)
|
|
53
|
-
.BlindedBeaconBlockBody.hashTreeRoot(blindedOrFull.body)
|
|
47
|
+
config.getPostBellatrixForkTypes(blindedOrFull.slot).BlindedBeaconBlockBody.hashTreeRoot(blindedOrFull.body)
|
|
54
48
|
: // Full
|
|
55
|
-
config
|
|
56
|
-
.getForkTypes(blindedOrFull.slot)
|
|
57
|
-
.BeaconBlockBody.hashTreeRoot(blindedOrFull.body);
|
|
49
|
+
config.getForkTypes(blindedOrFull.slot).BeaconBlockBody.hashTreeRoot(blindedOrFull.body);
|
|
58
50
|
|
|
59
51
|
return {
|
|
60
52
|
slot: blindedOrFull.slot,
|
package/src/util/genesis.ts
CHANGED
|
@@ -8,9 +8,10 @@ import {
|
|
|
8
8
|
GENESIS_EPOCH,
|
|
9
9
|
GENESIS_SLOT,
|
|
10
10
|
MAX_EFFECTIVE_BALANCE,
|
|
11
|
+
MIN_SEED_LOOKAHEAD,
|
|
11
12
|
UNSET_DEPOSIT_REQUESTS_START_INDEX,
|
|
12
13
|
} from "@lodestar/params";
|
|
13
|
-
import {Bytes32, Root, TimeSeconds, phase0, ssz} from "@lodestar/types";
|
|
14
|
+
import {Bytes32, Root, TimeSeconds, ValidatorIndex, phase0, ssz} from "@lodestar/types";
|
|
14
15
|
import {applyDeposit, processDeposit} from "../block/processDeposit.js";
|
|
15
16
|
import {EpochCacheImmutableData} from "../cache/epochCache.js";
|
|
16
17
|
import {createCachedBeaconState} from "../cache/stateCache.js";
|
|
@@ -26,6 +27,7 @@ import {
|
|
|
26
27
|
import {newFilledArray} from "./array.js";
|
|
27
28
|
import {getTemporaryBlockHeader} from "./blockRoot.js";
|
|
28
29
|
import {computeEpochAtSlot} from "./epoch.js";
|
|
30
|
+
import {computeProposerIndices} from "./seed.js";
|
|
29
31
|
import {getNextSyncCommittee} from "./syncCommittee.js";
|
|
30
32
|
import {getActiveValidatorIndices, getMaxEffectiveBalance} from "./validator.js";
|
|
31
33
|
|
|
@@ -352,6 +354,12 @@ export function initializeBeaconStateFromEth1(
|
|
|
352
354
|
// Fulu retires the legacy bridge after the genesis deposits.
|
|
353
355
|
stateFulu.depositRequestsStartIndex = BigInt(stateFulu.eth1DepositIndex);
|
|
354
356
|
}
|
|
357
|
+
const proposerLookahead: ValidatorIndex[] = [];
|
|
358
|
+
for (let epoch = GENESIS_EPOCH; epoch <= GENESIS_EPOCH + MIN_SEED_LOOKAHEAD; epoch++) {
|
|
359
|
+
const activeIndices = getActiveValidatorIndices(state, epoch);
|
|
360
|
+
proposerLookahead.push(...computeProposerIndices(fork, state, {activeIndices}, epoch));
|
|
361
|
+
}
|
|
362
|
+
stateFulu.proposerLookahead = ssz.fulu.ProposerLookahead.toViewDU(proposerLookahead);
|
|
355
363
|
}
|
|
356
364
|
|
|
357
365
|
if (fork >= ForkSeq.gloas) {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import {ValidatorIndex} from "@lodestar/types";
|
|
2
|
+
|
|
3
|
+
/** Spec `InclusionListCommittee` of one slot */
|
|
4
|
+
export class InclusionListCommittee {
|
|
5
|
+
constructor(readonly validatorIndices: Uint32Array) {}
|
|
6
|
+
|
|
7
|
+
/** Positions of `validatorIndex`, several when the committee cycles over a slot with fewer validators than its size */
|
|
8
|
+
getCommitteeIndices(validatorIndex: ValidatorIndex): number[] {
|
|
9
|
+
const committeeIndices: number[] = [];
|
|
10
|
+
for (let i = 0; i < this.validatorIndices.length; i++) {
|
|
11
|
+
if (this.validatorIndices[i] === validatorIndex) {
|
|
12
|
+
committeeIndices.push(i);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return committeeIndices;
|
|
16
|
+
}
|
|
17
|
+
}
|
package/src/util/index.ts
CHANGED
|
@@ -17,6 +17,7 @@ export * from "./execution.js";
|
|
|
17
17
|
export * from "./finality.js";
|
|
18
18
|
export * from "./genesis.js";
|
|
19
19
|
export * from "./gloas.js";
|
|
20
|
+
export * from "./inclusionListCommittee.js";
|
|
20
21
|
export * from "./interop.js";
|
|
21
22
|
export * from "./loadState/index.js";
|
|
22
23
|
export * from "./pendingDepositsLookup.js";
|
package/src/util/interop.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {toBufferBE} from "@vekexasia/bigint-buffer2";
|
|
2
2
|
import {digest} from "@chainsafe/as-sha256";
|
|
3
|
-
import {SecretKey} from "@
|
|
3
|
+
import {SecretKey} from "@lodestar/native/blst";
|
|
4
4
|
import {bytesToBigInt, intToBytes} from "@lodestar/utils";
|
|
5
5
|
|
|
6
6
|
let curveOrder: bigint;
|
package/src/util/seed.ts
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
computePtcIndicesForEpoch,
|
|
4
4
|
computeProposerIndex as nativeComputeProposerIndex,
|
|
5
5
|
computeSyncCommitteeIndices as nativeComputeSyncCommitteeIndices,
|
|
6
|
-
} from "@
|
|
6
|
+
} from "@lodestar/native/shuffle";
|
|
7
7
|
import {
|
|
8
8
|
DOMAIN_BEACON_PROPOSER,
|
|
9
9
|
DOMAIN_PTC_ATTESTER,
|
package/src/util/shuffling.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {ForkName, ForkSeq, SLOTS_PER_EPOCH, isForkPostFulu} from "@lodestar/params";
|
|
1
|
+
import {ForkName, ForkSeq, INCLUSION_LIST_COMMITTEE_SIZE, SLOTS_PER_EPOCH, isForkPostFulu} from "@lodestar/params";
|
|
2
2
|
import {
|
|
3
3
|
Attestation,
|
|
4
4
|
CommitteeIndex,
|
|
@@ -15,6 +15,7 @@ import {IBeaconStateView} from "../stateView/interface.js";
|
|
|
15
15
|
import {getBlockRootAtSlot} from "./blockRoot.js";
|
|
16
16
|
import {computeStartSlotAtEpoch} from "./epoch.js";
|
|
17
17
|
import {EpochShuffling} from "./epochShuffling.js";
|
|
18
|
+
import {InclusionListCommittee} from "./inclusionListCommittee.js";
|
|
18
19
|
|
|
19
20
|
/**
|
|
20
21
|
* Block root that decided the proposer shuffling for `proposalEpoch` (keys that shuffling).
|
|
@@ -196,6 +197,50 @@ export function getBeaconCommittee(epochShuffling: EpochShuffling, slot: Slot, i
|
|
|
196
197
|
return getBeaconCommittees(epochShuffling, slot, [index])[0];
|
|
197
198
|
}
|
|
198
199
|
|
|
200
|
+
/** Inclusion list committees of a shuffling by slot index, computed on first use and freed with the shuffling */
|
|
201
|
+
// TODO HEZE: replace this module-level map with an extended EpochShuffling tracked by the beacon-node ShufflingCache
|
|
202
|
+
const inclusionListCommitteesByShuffling = new WeakMap<EpochShuffling, InclusionListCommittee[]>();
|
|
203
|
+
|
|
204
|
+
/** Spec get_inclusion_list_committee: cycle over the slot's concatenated beacon committees */
|
|
205
|
+
export function getInclusionListCommittee(epochShuffling: EpochShuffling, slot: Slot): InclusionListCommittee {
|
|
206
|
+
let committees = inclusionListCommitteesByShuffling.get(epochShuffling);
|
|
207
|
+
if (committees === undefined) {
|
|
208
|
+
committees = [];
|
|
209
|
+
inclusionListCommitteesByShuffling.set(epochShuffling, committees);
|
|
210
|
+
}
|
|
211
|
+
const slotIndex = slot % SLOTS_PER_EPOCH;
|
|
212
|
+
let committee = committees[slotIndex];
|
|
213
|
+
if (committee === undefined) {
|
|
214
|
+
committee = new InclusionListCommittee(computeInclusionListCommittee(epochShuffling.committees[slotIndex]));
|
|
215
|
+
committees[slotIndex] = committee;
|
|
216
|
+
}
|
|
217
|
+
return committee;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
function computeInclusionListCommittee(slotCommittees: Uint32Array[]): Uint32Array {
|
|
221
|
+
let totalLen = 0;
|
|
222
|
+
for (const committee of slotCommittees) {
|
|
223
|
+
totalLen += committee.length;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
const result = new Uint32Array(INCLUSION_LIST_COMMITTEE_SIZE);
|
|
227
|
+
if (totalLen === 0) {
|
|
228
|
+
return result;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
for (let i = 0; i < INCLUSION_LIST_COMMITTEE_SIZE; i++) {
|
|
232
|
+
let offset = i % totalLen;
|
|
233
|
+
for (const committee of slotCommittees) {
|
|
234
|
+
if (offset < committee.length) {
|
|
235
|
+
result[i] = committee[offset];
|
|
236
|
+
break;
|
|
237
|
+
}
|
|
238
|
+
offset -= committee.length;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
return result;
|
|
242
|
+
}
|
|
243
|
+
|
|
199
244
|
/**
|
|
200
245
|
* Return a Uint32Array[] representing committees validator indices
|
|
201
246
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {BLS_VERIFIER_SET_TYPE, type BlsSignatureSet, verifySignatureSets} from "@
|
|
1
|
+
import {BLS_VERIFIER_SET_TYPE, type BlsSignatureSet, verifySignatureSets} from "@lodestar/native/bls-verifier";
|
|
2
2
|
import {Root} from "@lodestar/types";
|
|
3
3
|
|
|
4
4
|
export enum SignatureSetType {
|