@lodestar/state-transition 1.51.0-dev.2b933d3b9a → 1.51.0-dev.2bcbe7ce2d
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/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/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 -6
- package/lib/stateView/nativeBeaconStateView.d.ts.map +1 -1
- package/lib/stateView/nativeBeaconStateView.js +85 -25
- package/lib/stateView/nativeBeaconStateView.js.map +1 -1
- package/lib/stateView/stateViewFactory.d.ts.map +1 -1
- package/lib/stateView/stateViewFactory.js +5 -4
- 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/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/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/rewards/attestationsRewards.ts +1 -1
- package/src/rewards/syncCommitteeRewards.ts +1 -1
- package/src/stateView/beaconStateView.ts +5 -1
- package/src/stateView/interface.ts +1 -10
- package/src/stateView/nativeBeaconStateView.ts +86 -29
- package/src/stateView/stateViewFactory.ts +5 -4
- 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/interop.ts +1 -1
- package/src/util/seed.ts +1 -1
- package/src/util/signatureSets.ts +1 -1
- package/src/util/syncCommittee.ts +1 -1
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"bugs": {
|
|
12
12
|
"url": "https://github.com/ChainSafe/lodestar/issues"
|
|
13
13
|
},
|
|
14
|
-
"version": "1.51.0-dev.
|
|
14
|
+
"version": "1.51.0-dev.2bcbe7ce2d",
|
|
15
15
|
"type": "module",
|
|
16
16
|
"exports": {
|
|
17
17
|
".": {
|
|
@@ -66,17 +66,17 @@
|
|
|
66
66
|
"types": "lib/index.d.ts",
|
|
67
67
|
"dependencies": {
|
|
68
68
|
"@chainsafe/as-sha256": "^1.2.5",
|
|
69
|
-
"@chainsafe/lodestar-z": "catalog:",
|
|
70
69
|
"@chainsafe/persistent-merkle-tree": "^1.3.1",
|
|
71
|
-
"@chainsafe/ssz": "^1.
|
|
72
|
-
"@lodestar/config": "^1.51.0-dev.
|
|
73
|
-
"@lodestar/
|
|
74
|
-
"@lodestar/
|
|
75
|
-
"@lodestar/
|
|
70
|
+
"@chainsafe/ssz": "^1.9.0",
|
|
71
|
+
"@lodestar/config": "^1.51.0-dev.2bcbe7ce2d",
|
|
72
|
+
"@lodestar/native": "^1.51.0-dev.2bcbe7ce2d",
|
|
73
|
+
"@lodestar/params": "^1.51.0-dev.2bcbe7ce2d",
|
|
74
|
+
"@lodestar/types": "^1.51.0-dev.2bcbe7ce2d",
|
|
75
|
+
"@lodestar/utils": "^1.51.0-dev.2bcbe7ce2d",
|
|
76
76
|
"@vekexasia/bigint-buffer2": "^1.1.1"
|
|
77
77
|
},
|
|
78
78
|
"devDependencies": {
|
|
79
|
-
"@lodestar/test-utils": "^1.51.0-dev.
|
|
79
|
+
"@lodestar/test-utils": "^1.51.0-dev.2bcbe7ce2d"
|
|
80
80
|
},
|
|
81
81
|
"keywords": [
|
|
82
82
|
"ethereum",
|
|
@@ -84,5 +84,5 @@
|
|
|
84
84
|
"beacon",
|
|
85
85
|
"blockchain"
|
|
86
86
|
],
|
|
87
|
-
"gitHead": "
|
|
87
|
+
"gitHead": "45314f9f511749795738da0f641502f8bb162957"
|
|
88
88
|
}
|
package/src/block/index.ts
CHANGED
|
@@ -23,27 +23,26 @@ import {processSyncAggregate} from "./processSyncCommittee.js";
|
|
|
23
23
|
import {processWithdrawals} from "./processWithdrawals.js";
|
|
24
24
|
import {BlockProcessStep, ProcessBlockOpts, ProposerRewardType} from "./types.js";
|
|
25
25
|
|
|
26
|
+
export * from "./externalData.js";
|
|
27
|
+
export * from "./initiateValidatorExit.js";
|
|
28
|
+
export * from "./isValidIndexedAttestation.js";
|
|
29
|
+
export * from "./processBuilderDepositRequest.js";
|
|
30
|
+
export * from "./processBuilderExitRequest.js";
|
|
31
|
+
export * from "./processDepositRequest.js";
|
|
32
|
+
export * from "./processOperations.js";
|
|
26
33
|
// Spec tests
|
|
27
34
|
export {
|
|
28
35
|
processBlockHeader,
|
|
36
|
+
processEth1Data,
|
|
29
37
|
processExecutionPayload,
|
|
38
|
+
processExecutionPayloadBid,
|
|
39
|
+
processParentExecutionPayload,
|
|
40
|
+
processPayloadAttestation,
|
|
30
41
|
processRandao,
|
|
31
|
-
processEth1Data,
|
|
32
42
|
processSyncAggregate,
|
|
33
43
|
processWithdrawals,
|
|
34
|
-
processExecutionPayloadBid,
|
|
35
|
-
processPayloadAttestation,
|
|
36
|
-
processParentExecutionPayload,
|
|
37
44
|
};
|
|
38
45
|
|
|
39
|
-
export * from "./externalData.js";
|
|
40
|
-
export * from "./initiateValidatorExit.js";
|
|
41
|
-
export * from "./isValidIndexedAttestation.js";
|
|
42
|
-
export * from "./processBuilderDepositRequest.js";
|
|
43
|
-
export * from "./processBuilderExitRequest.js";
|
|
44
|
-
export * from "./processDepositRequest.js";
|
|
45
|
-
export * from "./processOperations.js";
|
|
46
|
-
|
|
47
46
|
export function processBlock(
|
|
48
47
|
fork: ForkSeq,
|
|
49
48
|
state: CachedBeaconStateAllForks,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import {BeaconConfig} from "@lodestar/config";
|
|
1
2
|
import {
|
|
2
3
|
BLS_VERIFIER_MAX_BATCH_SIZE,
|
|
3
4
|
BLS_VERIFIER_SET_TYPE,
|
|
4
5
|
type BlsSignatureSet,
|
|
5
6
|
verifySignatureSets,
|
|
6
|
-
} from "@
|
|
7
|
-
import {BeaconConfig} from "@lodestar/config";
|
|
7
|
+
} from "@lodestar/native/bls-verifier";
|
|
8
8
|
import {
|
|
9
9
|
DEPOSIT_CONTRACT_TREE_DEPTH,
|
|
10
10
|
DOMAIN_DEPOSIT,
|
|
@@ -22,15 +22,15 @@ import {processWithdrawalRequest} from "./processWithdrawalRequest.js";
|
|
|
22
22
|
import {ProcessBlockOpts, ProcessOperationsStep} from "./types.js";
|
|
23
23
|
|
|
24
24
|
export {
|
|
25
|
-
processProposerSlashing,
|
|
26
|
-
processAttesterSlashing,
|
|
27
25
|
processAttestations,
|
|
26
|
+
processAttesterSlashing,
|
|
27
|
+
processBlsToExecutionChange,
|
|
28
|
+
processConsolidationRequest,
|
|
28
29
|
processDeposit,
|
|
30
|
+
processDepositRequest,
|
|
31
|
+
processProposerSlashing,
|
|
29
32
|
processVoluntaryExit,
|
|
30
33
|
processWithdrawalRequest,
|
|
31
|
-
processBlsToExecutionChange,
|
|
32
|
-
processDepositRequest,
|
|
33
|
-
processConsolidationRequest,
|
|
34
34
|
};
|
|
35
35
|
|
|
36
36
|
export function processOperations(
|
package/src/cache/epochCache.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {PublicKey} from "@chainsafe/lodestar-z/blst";
|
|
2
|
-
import {type PubkeyCache, pubkeyCache as defaultPubkeyCache} from "@chainsafe/lodestar-z/pubkeys";
|
|
3
1
|
import {BeaconConfig, ChainConfig, createBeaconConfig} from "@lodestar/config";
|
|
2
|
+
import {PublicKey} from "@lodestar/native/blst";
|
|
3
|
+
import {type PubkeyCache, pubkeyCache as defaultPubkeyCache} from "@lodestar/native/pubkeys";
|
|
4
4
|
import {
|
|
5
5
|
ATTESTATION_SUBNET_COUNT,
|
|
6
6
|
DOMAIN_BEACON_PROPOSER,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {type PubkeyCache} from "@chainsafe/lodestar-z/pubkeys";
|
|
2
1
|
import {CompositeViewDU} from "@chainsafe/ssz";
|
|
2
|
+
import {type PubkeyCache} from "@lodestar/native/pubkeys";
|
|
3
3
|
import {ValidatorIndex, ssz} from "@lodestar/types";
|
|
4
4
|
import {toPubkeyHex} from "@lodestar/utils";
|
|
5
5
|
|
package/src/epoch/index.ts
CHANGED
|
@@ -37,32 +37,31 @@ import {processSlashings} from "./processSlashings.js";
|
|
|
37
37
|
import {processSlashingsReset} from "./processSlashingsReset.js";
|
|
38
38
|
import {processSyncCommitteeUpdates} from "./processSyncCommitteeUpdates.js";
|
|
39
39
|
|
|
40
|
+
export {computeUnrealizedCheckpoints} from "./computeUnrealizedCheckpoints.js";
|
|
40
41
|
// For spec tests
|
|
41
42
|
export {getRewardsAndPenalties} from "./processRewardsAndPenalties.js";
|
|
42
43
|
export {
|
|
43
|
-
|
|
44
|
-
processInactivityUpdates,
|
|
45
|
-
processRewardsAndPenalties,
|
|
46
|
-
processRegistryUpdates,
|
|
47
|
-
processSlashings,
|
|
48
|
-
processEth1DataReset,
|
|
44
|
+
processBuilderPendingPayments,
|
|
49
45
|
processEffectiveBalanceUpdates,
|
|
50
|
-
|
|
51
|
-
processRandaoMixesReset,
|
|
46
|
+
processEth1DataReset,
|
|
52
47
|
processHistoricalRootsUpdate,
|
|
53
|
-
processParticipationRecordUpdates,
|
|
54
|
-
processParticipationFlagUpdates,
|
|
55
|
-
processSyncCommitteeUpdates,
|
|
56
48
|
processHistoricalSummariesUpdate,
|
|
57
|
-
|
|
49
|
+
processInactivityUpdates,
|
|
50
|
+
processJustificationAndFinalization,
|
|
51
|
+
processParticipationFlagUpdates,
|
|
52
|
+
processParticipationRecordUpdates,
|
|
58
53
|
processPendingConsolidations,
|
|
54
|
+
processPendingDeposits,
|
|
59
55
|
processProposerLookahead,
|
|
60
56
|
processPtcWindow,
|
|
61
|
-
|
|
57
|
+
processRandaoMixesReset,
|
|
58
|
+
processRegistryUpdates,
|
|
59
|
+
processRewardsAndPenalties,
|
|
60
|
+
processSlashings,
|
|
61
|
+
processSlashingsReset,
|
|
62
|
+
processSyncCommitteeUpdates,
|
|
62
63
|
};
|
|
63
64
|
|
|
64
|
-
export {computeUnrealizedCheckpoints} from "./computeUnrealizedCheckpoints.js";
|
|
65
|
-
|
|
66
65
|
const maxValidatorsPerStateSlashing = SLOTS_PER_EPOCH * MAX_ATTESTER_SLASHINGS * MAX_VALIDATORS_PER_COMMITTEE;
|
|
67
66
|
const maxSafeValidators = Math.floor(Number.MAX_SAFE_INTEGER / MAX_EFFECTIVE_BALANCE);
|
|
68
67
|
|
|
@@ -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";
|
|
@@ -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";
|
|
@@ -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,8 +344,6 @@ 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"
|
|
@@ -365,7 +361,6 @@ export type IBeaconStateViewNative = Omit<
|
|
|
365
361
|
pendingPartialWithdrawals: Uint8Array;
|
|
366
362
|
pendingConsolidations: Uint8Array;
|
|
367
363
|
proposerLookahead: Uint32Array;
|
|
368
|
-
// UintBn64 lowers to number across the FFI boundary; the wrapper lifts it back to bigint
|
|
369
364
|
eth1Data: phase0.Eth1Data;
|
|
370
365
|
executionPayloadAvailability: {uint8Array: Uint8Array; bitLen: number};
|
|
371
366
|
computeBlockRewards(
|
|
@@ -379,8 +374,6 @@ export type IBeaconStateViewNative = Omit<
|
|
|
379
374
|
validatorIds: (ValidatorIndex | string)[]
|
|
380
375
|
): rewards.SyncCommitteeRewards;
|
|
381
376
|
getBeaconCommittee(slot: Slot, index: CommitteeIndex): Uint32Array;
|
|
382
|
-
getIndexInPayloadTimelinessCommittee?(validatorIndex: ValidatorIndex, slot: Slot): number;
|
|
383
|
-
getIndicesInPayloadTimelinessCommittee?(validatorIndex: ValidatorIndex, slot: Slot): number[];
|
|
384
377
|
loadOtherState(...args: Parameters<IBeaconStateViewLatestFork["loadOtherState"]>): IBeaconStateViewNative;
|
|
385
378
|
stateTransition(
|
|
386
379
|
signedBlockBytes: Uint8Array,
|
|
@@ -388,9 +381,7 @@ export type IBeaconStateViewNative = Omit<
|
|
|
388
381
|
options?: StateTransitionOpts
|
|
389
382
|
): IBeaconStateViewNative;
|
|
390
383
|
processSlots(slot: Slot, opts?: {dontTransferCache?: boolean}): IBeaconStateViewNative;
|
|
391
|
-
withParentPayloadApplied(
|
|
392
|
-
...args: Parameters<IBeaconStateViewLatestFork["withParentPayloadApplied"]>
|
|
393
|
-
): IBeaconStateViewNative;
|
|
384
|
+
withParentPayloadApplied(executionRequestsBytes: Uint8Array): IBeaconStateViewNative;
|
|
394
385
|
};
|
|
395
386
|
|
|
396
387
|
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";
|
|
@@ -39,6 +40,7 @@ import {SyncCommitteeWitness} from "../lightClient/types.js";
|
|
|
39
40
|
import {StateTransitionModules, StateTransitionOpts} from "../stateTransition.js";
|
|
40
41
|
import {EpochShuffling} from "../util/epochShuffling.js";
|
|
41
42
|
import {PreVerifyBuilderDepositsResult} from "../util/preVerifyBuilderDeposits.js";
|
|
43
|
+
import {getStateSlotFromBytes} from "../util/sszBytes.js";
|
|
42
44
|
import {computeNewStateRootStateTransitionOpts, getComputeNewStateRootResult} from "./computeNewStateRoot.js";
|
|
43
45
|
import {
|
|
44
46
|
BlockSTFInput,
|
|
@@ -47,8 +49,15 @@ import {
|
|
|
47
49
|
IBeaconStateViewGloas,
|
|
48
50
|
IBeaconStateViewLatestFork,
|
|
49
51
|
IBeaconStateViewNative,
|
|
52
|
+
isStatePostGloas,
|
|
50
53
|
} from "./interface.js";
|
|
51
54
|
|
|
55
|
+
export function assertNativeForkSupported(config: BeaconConfig, slot: Slot): void {
|
|
56
|
+
if (config.getForkSeq(slot) > ForkSeq.gloas) {
|
|
57
|
+
throw Error(`Native state transition does not support ${config.getForkName(slot)}`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
52
61
|
/**
|
|
53
62
|
* Wraps a native binding (the auto-generated JS interface produced by a `.node`
|
|
54
63
|
* file) and exposes it as a fully-conformant `IBeaconStateViewLatestFork`.
|
|
@@ -115,6 +124,14 @@ export class NativeBeaconStateView implements IBeaconStateViewLatestFork {
|
|
|
115
124
|
private cachedPendingConsolidationsCount: number | null = null;
|
|
116
125
|
// fulu
|
|
117
126
|
private cachedProposerLookahead: fulu.ProposerLookahead | null = null;
|
|
127
|
+
// gloas
|
|
128
|
+
private cachedLatestBlockHash: Bytes32 | null = null;
|
|
129
|
+
private cachedExecutionPayloadAvailability: BitArray | null = null;
|
|
130
|
+
private cachedLatestExecutionPayloadBid: ExecutionPayloadBid | null = null;
|
|
131
|
+
private cachedPayloadExpectedWithdrawals: capella.Withdrawal[] | null = null;
|
|
132
|
+
private cachedBuilderPendingPayments: gloas.BuilderPendingPayments | null = null;
|
|
133
|
+
private cachedBuilderPendingWithdrawals: gloas.BuilderPendingWithdrawals | null = null;
|
|
134
|
+
private cachedBuildersLength: number | null = null;
|
|
118
135
|
// Per-argument caches for argument-taking methods. The binding is treated as
|
|
119
136
|
// immutable for the view's lifetime, so a given argument always yields the
|
|
120
137
|
// same result. Maps grow only with touched arguments — typical call patterns
|
|
@@ -174,7 +191,11 @@ export class NativeBeaconStateView implements IBeaconStateViewLatestFork {
|
|
|
174
191
|
}
|
|
175
192
|
|
|
176
193
|
get executionPayloadAvailability(): BitArray {
|
|
177
|
-
|
|
194
|
+
if (this.cachedExecutionPayloadAvailability === null) {
|
|
195
|
+
const {uint8Array, bitLen} = this.binding.executionPayloadAvailability;
|
|
196
|
+
this.cachedExecutionPayloadAvailability = new BitArray(uint8Array, bitLen);
|
|
197
|
+
}
|
|
198
|
+
return this.cachedExecutionPayloadAvailability;
|
|
178
199
|
}
|
|
179
200
|
|
|
180
201
|
// ─── phase0 ──────────────────────────────────────────────────────────────
|
|
@@ -598,6 +619,7 @@ export class NativeBeaconStateView implements IBeaconStateViewLatestFork {
|
|
|
598
619
|
seedValidatorsBytes?: Uint8Array,
|
|
599
620
|
opts?: {preloadValidatorsAndBalances?: boolean}
|
|
600
621
|
): IBeaconStateView {
|
|
622
|
+
assertNativeForkSupported(this.config, getStateSlotFromBytes(stateBytes));
|
|
601
623
|
return new NativeBeaconStateView(this.config, this.binding.loadOtherState(stateBytes, seedValidatorsBytes, opts));
|
|
602
624
|
}
|
|
603
625
|
|
|
@@ -663,6 +685,7 @@ export class NativeBeaconStateView implements IBeaconStateViewLatestFork {
|
|
|
663
685
|
options: StateTransitionOpts,
|
|
664
686
|
_modules: StateTransitionModules
|
|
665
687
|
): IBeaconStateView {
|
|
688
|
+
assertNativeForkSupported(this.config, block.message.slot);
|
|
666
689
|
const isBlinded = isBlindedBeaconBlock(block.message);
|
|
667
690
|
const signedBlockBytes =
|
|
668
691
|
ssz ??
|
|
@@ -675,6 +698,7 @@ export class NativeBeaconStateView implements IBeaconStateViewLatestFork {
|
|
|
675
698
|
}
|
|
676
699
|
|
|
677
700
|
processSlots(slot: Slot, opts?: {dontTransferCache?: boolean}, _modules?: StateTransitionModules): IBeaconStateView {
|
|
701
|
+
assertNativeForkSupported(this.config, slot);
|
|
678
702
|
return new NativeBeaconStateView(this.config, this.binding.processSlots(slot, opts));
|
|
679
703
|
}
|
|
680
704
|
|
|
@@ -832,7 +856,8 @@ export class NativeBeaconStateView implements IBeaconStateViewLatestFork {
|
|
|
832
856
|
|
|
833
857
|
get pendingDeposits(): electra.PendingDeposits {
|
|
834
858
|
if (this.cachedPendingDeposits === null) {
|
|
835
|
-
|
|
859
|
+
const type = sszTypesFor(this.forkName as ForkPostElectra).PendingDeposits;
|
|
860
|
+
this.cachedPendingDeposits = type.deserialize(this.binding.pendingDeposits);
|
|
836
861
|
}
|
|
837
862
|
return this.cachedPendingDeposits;
|
|
838
863
|
}
|
|
@@ -846,9 +871,8 @@ export class NativeBeaconStateView implements IBeaconStateViewLatestFork {
|
|
|
846
871
|
|
|
847
872
|
get pendingPartialWithdrawals(): electra.PendingPartialWithdrawals {
|
|
848
873
|
if (this.cachedPendingPartialWithdrawals === null) {
|
|
849
|
-
this.
|
|
850
|
-
|
|
851
|
-
);
|
|
874
|
+
const type = sszTypesFor(this.forkName as ForkPostElectra).PendingPartialWithdrawals;
|
|
875
|
+
this.cachedPendingPartialWithdrawals = type.deserialize(this.binding.pendingPartialWithdrawals);
|
|
852
876
|
}
|
|
853
877
|
return this.cachedPendingPartialWithdrawals;
|
|
854
878
|
}
|
|
@@ -862,9 +886,8 @@ export class NativeBeaconStateView implements IBeaconStateViewLatestFork {
|
|
|
862
886
|
|
|
863
887
|
get pendingConsolidations(): electra.PendingConsolidations {
|
|
864
888
|
if (this.cachedPendingConsolidations === null) {
|
|
865
|
-
this.
|
|
866
|
-
|
|
867
|
-
);
|
|
889
|
+
const type = sszTypesFor(this.forkName as ForkPostElectra).PendingConsolidations;
|
|
890
|
+
this.cachedPendingConsolidations = type.deserialize(this.binding.pendingConsolidations);
|
|
868
891
|
}
|
|
869
892
|
return this.cachedPendingConsolidations;
|
|
870
893
|
}
|
|
@@ -889,60 +912,94 @@ export class NativeBeaconStateView implements IBeaconStateViewLatestFork {
|
|
|
889
912
|
_maxBuilderDeposits: number,
|
|
890
913
|
_maxDurationMs: number
|
|
891
914
|
): PreVerifyBuilderDepositsResult {
|
|
892
|
-
|
|
915
|
+
// The native fork upgrade verifies directly; it does not maintain a warm-up cache.
|
|
916
|
+
return {
|
|
917
|
+
validBuilderSignaturesCount: 0,
|
|
918
|
+
invalidBuilderSignaturesCount: 0,
|
|
919
|
+
validValidatorSignaturesCount: 0,
|
|
920
|
+
invalidValidatorSignaturesCount: 0,
|
|
921
|
+
scannedPendingDeposits: 0,
|
|
922
|
+
totalCachedDeposits: 0,
|
|
923
|
+
totalBuilderPubkeys: 0,
|
|
924
|
+
pendingDepositsCount: this.pendingDepositsCount,
|
|
925
|
+
};
|
|
893
926
|
}
|
|
894
927
|
|
|
895
928
|
clearPreGloasBuilderDepositCache(): void {
|
|
896
|
-
|
|
929
|
+
// The native implementation has no pre-Gloas deposit cache to clear.
|
|
897
930
|
}
|
|
898
931
|
|
|
899
932
|
// ─── gloas ───────────────────────────────────────────────────────────────
|
|
900
933
|
|
|
901
934
|
get latestBlockHash(): Bytes32 {
|
|
902
|
-
|
|
935
|
+
if (this.cachedLatestBlockHash === null) {
|
|
936
|
+
this.cachedLatestBlockHash = this.binding.latestBlockHash;
|
|
937
|
+
}
|
|
938
|
+
return this.cachedLatestBlockHash;
|
|
903
939
|
}
|
|
904
940
|
|
|
905
941
|
get latestExecutionPayloadBid(): ExecutionPayloadBid {
|
|
906
|
-
|
|
942
|
+
if (this.cachedLatestExecutionPayloadBid === null) {
|
|
943
|
+
this.cachedLatestExecutionPayloadBid = this.binding.latestExecutionPayloadBid;
|
|
944
|
+
}
|
|
945
|
+
return this.cachedLatestExecutionPayloadBid;
|
|
907
946
|
}
|
|
908
947
|
|
|
909
948
|
get payloadExpectedWithdrawals(): capella.Withdrawal[] {
|
|
910
|
-
|
|
949
|
+
if (this.cachedPayloadExpectedWithdrawals === null) {
|
|
950
|
+
this.cachedPayloadExpectedWithdrawals = this.binding.payloadExpectedWithdrawals;
|
|
951
|
+
}
|
|
952
|
+
return this.cachedPayloadExpectedWithdrawals;
|
|
911
953
|
}
|
|
912
954
|
|
|
913
955
|
get builderPendingPayments(): gloas.BuilderPendingPayments {
|
|
914
|
-
|
|
956
|
+
if (this.cachedBuilderPendingPayments === null) {
|
|
957
|
+
this.cachedBuilderPendingPayments = this.binding.builderPendingPayments;
|
|
958
|
+
}
|
|
959
|
+
return this.cachedBuilderPendingPayments;
|
|
915
960
|
}
|
|
916
961
|
|
|
917
962
|
get builderPendingWithdrawals(): gloas.BuilderPendingWithdrawals {
|
|
918
|
-
|
|
963
|
+
if (this.cachedBuilderPendingWithdrawals === null) {
|
|
964
|
+
this.cachedBuilderPendingWithdrawals = this.binding.builderPendingWithdrawals;
|
|
965
|
+
}
|
|
966
|
+
return this.cachedBuilderPendingWithdrawals;
|
|
919
967
|
}
|
|
920
968
|
|
|
921
|
-
getBuilder(
|
|
922
|
-
|
|
969
|
+
getBuilder(index: BuilderIndex): gloas.Builder {
|
|
970
|
+
return this.binding.getBuilder(index);
|
|
923
971
|
}
|
|
924
972
|
|
|
925
973
|
getBuildersLength(): number {
|
|
926
|
-
|
|
974
|
+
if (this.cachedBuildersLength === null) {
|
|
975
|
+
this.cachedBuildersLength = this.binding.getBuildersLength();
|
|
976
|
+
}
|
|
977
|
+
return this.cachedBuildersLength;
|
|
927
978
|
}
|
|
928
979
|
|
|
929
|
-
canBuilderCoverBid(
|
|
930
|
-
|
|
980
|
+
canBuilderCoverBid(builderIndex: BuilderIndex, bidAmount: number): boolean {
|
|
981
|
+
return this.binding.canBuilderCoverBid(builderIndex, bidAmount);
|
|
931
982
|
}
|
|
932
983
|
|
|
933
|
-
getEpochPTCs(
|
|
934
|
-
|
|
984
|
+
getEpochPTCs(epoch: Epoch): Uint32Array[] {
|
|
985
|
+
return this.binding.getEpochPTCs(epoch);
|
|
935
986
|
}
|
|
936
987
|
|
|
937
|
-
getPayloadTimelinessCommittee(
|
|
938
|
-
|
|
988
|
+
getPayloadTimelinessCommittee(slot: Slot): Uint32Array {
|
|
989
|
+
return this.binding.getPayloadTimelinessCommittee(slot);
|
|
939
990
|
}
|
|
940
991
|
|
|
941
|
-
getIndicesInPayloadTimelinessCommittee(
|
|
942
|
-
|
|
992
|
+
getIndicesInPayloadTimelinessCommittee(validatorIndex: ValidatorIndex, slot: Slot): number[] {
|
|
993
|
+
return this.binding.getIndicesInPayloadTimelinessCommittee(validatorIndex, slot);
|
|
943
994
|
}
|
|
944
995
|
|
|
945
|
-
withParentPayloadApplied(
|
|
946
|
-
|
|
996
|
+
withParentPayloadApplied(executionRequests: gloas.ExecutionRequests): IBeaconStateViewGloas {
|
|
997
|
+
const bytes = ssz.gloas.ExecutionRequests.serialize(executionRequests);
|
|
998
|
+
const state = new NativeBeaconStateView(this.config, this.binding.withParentPayloadApplied(bytes));
|
|
999
|
+
if (!isStatePostGloas(state)) {
|
|
1000
|
+
state.release();
|
|
1001
|
+
throw Error("Expected Gloas state after applying the parent payload");
|
|
1002
|
+
}
|
|
1003
|
+
return state;
|
|
947
1004
|
}
|
|
948
1005
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
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
|
-
import {getStateTypeFromBytes} from "../util/sszBytes.js";
|
|
5
|
+
import {getStateSlotFromBytes, getStateTypeFromBytes} from "../util/sszBytes.js";
|
|
6
6
|
import {BeaconStateView} from "./beaconStateView.js";
|
|
7
7
|
import {IBeaconStateView, IBeaconStateViewNative} from "./interface.js";
|
|
8
|
-
import {NativeBeaconStateView} from "./nativeBeaconStateView.js";
|
|
8
|
+
import {NativeBeaconStateView, assertNativeForkSupported} from "./nativeBeaconStateView.js";
|
|
9
9
|
|
|
10
10
|
// ---- createBeaconStateView (startup path) ----
|
|
11
11
|
|
|
@@ -62,6 +62,7 @@ export function createBeaconStateViewForHistoricalRegen(opts: RegenNodeJSOpts |
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
function createNativeBeaconStateView(config: BeaconConfig, stateBytes: Uint8Array): IBeaconStateView {
|
|
65
|
+
assertNativeForkSupported(config, getStateSlotFromBytes(stateBytes));
|
|
65
66
|
const nativeConfig = new bindings.BeaconConfig(config, config.genesisValidatorsRoot);
|
|
66
67
|
return new NativeBeaconStateView(
|
|
67
68
|
config,
|
|
@@ -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/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,
|