@lodestar/state-transition 1.47.0-dev.d2f4b96574 → 1.47.0-dev.d79d81f994
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/isValidIndexedAttestation.d.ts +2 -3
- package/lib/block/isValidIndexedAttestation.d.ts.map +1 -1
- package/lib/block/isValidIndexedAttestation.js +4 -4
- package/lib/block/isValidIndexedAttestation.js.map +1 -1
- package/lib/block/isValidIndexedPayloadAttestation.d.ts.map +1 -1
- package/lib/block/isValidIndexedPayloadAttestation.js +1 -1
- package/lib/block/isValidIndexedPayloadAttestation.js.map +1 -1
- package/lib/block/processAttestationPhase0.d.ts.map +1 -1
- package/lib/block/processAttestationPhase0.js +1 -1
- package/lib/block/processAttestationPhase0.js.map +1 -1
- package/lib/block/processAttestationsAltair.js +2 -2
- package/lib/block/processAttestationsAltair.js.map +1 -1
- package/lib/block/processAttesterSlashing.d.ts +1 -2
- package/lib/block/processAttesterSlashing.d.ts.map +1 -1
- package/lib/block/processAttesterSlashing.js +3 -3
- package/lib/block/processAttesterSlashing.js.map +1 -1
- package/lib/block/processDeposit.d.ts.map +1 -1
- package/lib/block/processDeposit.js +21 -46
- package/lib/block/processDeposit.js.map +1 -1
- package/lib/block/processExecutionPayloadBid.d.ts.map +1 -1
- package/lib/block/processExecutionPayloadBid.js +2 -5
- package/lib/block/processExecutionPayloadBid.js.map +1 -1
- package/lib/block/processProposerSlashing.d.ts +1 -2
- package/lib/block/processProposerSlashing.d.ts.map +1 -1
- package/lib/block/processProposerSlashing.js +3 -3
- package/lib/block/processProposerSlashing.js.map +1 -1
- package/lib/block/processRandao.js +1 -1
- package/lib/block/processRandao.js.map +1 -1
- package/lib/block/processSyncCommittee.js +1 -1
- package/lib/block/processSyncCommittee.js.map +1 -1
- package/lib/block/processVoluntaryExit.d.ts.map +1 -1
- package/lib/block/processVoluntaryExit.js +1 -2
- package/lib/block/processVoluntaryExit.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 +5 -6
- package/lib/cache/epochCache.js.map +1 -1
- package/lib/cache/stateCache.js +1 -1
- package/lib/cache/stateCache.js.map +1 -1
- package/lib/cache/syncCommitteeCache.d.ts +2 -3
- package/lib/cache/syncCommitteeCache.d.ts.map +1 -1
- package/lib/cache/syncCommitteeCache.js.map +1 -1
- package/lib/epoch/processSyncCommitteeUpdates.js +1 -1
- package/lib/epoch/processSyncCommitteeUpdates.js.map +1 -1
- package/lib/index.d.ts +3 -4
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -3
- package/lib/index.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.js +1 -1
- package/lib/lightClient/spec/utils.js.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 +11 -0
- package/lib/metrics.d.ts.map +1 -1
- package/lib/metrics.js +22 -0
- 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/attestationsRewards.js.map +1 -1
- package/lib/rewards/syncCommitteeRewards.d.ts +1 -1
- package/lib/rewards/syncCommitteeRewards.d.ts.map +1 -1
- package/lib/rewards/syncCommitteeRewards.js +3 -1
- package/lib/rewards/syncCommitteeRewards.js.map +1 -1
- package/lib/signatureSets/blsToExecutionChange.d.ts.map +1 -1
- package/lib/signatureSets/blsToExecutionChange.js +1 -2
- package/lib/signatureSets/blsToExecutionChange.js.map +1 -1
- package/lib/signatureSets/executionPayloadEnvelope.d.ts +2 -3
- package/lib/signatureSets/executionPayloadEnvelope.d.ts.map +1 -1
- package/lib/signatureSets/executionPayloadEnvelope.js +6 -7
- package/lib/signatureSets/executionPayloadEnvelope.js.map +1 -1
- package/lib/signatureSets/proposer.d.ts +1 -2
- package/lib/signatureSets/proposer.d.ts.map +1 -1
- package/lib/signatureSets/proposer.js +2 -2
- package/lib/signatureSets/proposer.js.map +1 -1
- package/lib/signatureSets/randao.d.ts +1 -2
- package/lib/signatureSets/randao.d.ts.map +1 -1
- package/lib/signatureSets/randao.js +2 -2
- package/lib/signatureSets/randao.js.map +1 -1
- package/lib/signatureSets/voluntaryExits.d.ts +1 -2
- package/lib/signatureSets/voluntaryExits.d.ts.map +1 -1
- package/lib/signatureSets/voluntaryExits.js +3 -4
- package/lib/signatureSets/voluntaryExits.js.map +1 -1
- package/lib/slot/upgradeStateToGloas.d.ts +2 -1
- package/lib/slot/upgradeStateToGloas.d.ts.map +1 -1
- package/lib/slot/upgradeStateToGloas.js +65 -21
- package/lib/slot/upgradeStateToGloas.js.map +1 -1
- package/lib/stateTransition.js +8 -3
- package/lib/stateTransition.js.map +1 -1
- package/lib/stateView/beaconStateView.d.ts +2 -1
- package/lib/stateView/beaconStateView.d.ts.map +1 -1
- package/lib/stateView/beaconStateView.js +6 -1
- package/lib/stateView/beaconStateView.js.map +1 -1
- package/lib/stateView/computeNewStateRoot.d.ts +6 -0
- package/lib/stateView/computeNewStateRoot.d.ts.map +1 -0
- package/lib/stateView/computeNewStateRoot.js +28 -0
- package/lib/stateView/computeNewStateRoot.js.map +1 -0
- package/lib/stateView/interface.d.ts +17 -2
- package/lib/stateView/interface.d.ts.map +1 -1
- package/lib/stateView/interface.js.map +1 -1
- package/lib/stateView/nativeBeaconStateView.d.ts +2 -1
- package/lib/stateView/nativeBeaconStateView.d.ts.map +1 -1
- package/lib/stateView/nativeBeaconStateView.js +5 -0
- package/lib/stateView/nativeBeaconStateView.js.map +1 -1
- package/lib/stateView/stateViewFactory.d.ts +1 -1
- package/lib/stateView/stateViewFactory.d.ts.map +1 -1
- package/lib/stateView/stateViewFactory.js +2 -13
- package/lib/stateView/stateViewFactory.js.map +1 -1
- package/lib/testUtils/index.d.ts +1 -0
- package/lib/testUtils/index.d.ts.map +1 -1
- package/lib/testUtils/index.js +1 -0
- package/lib/testUtils/index.js.map +1 -1
- package/lib/testUtils/interopPubkeyCache.d.ts +7 -0
- package/lib/testUtils/interopPubkeyCache.d.ts.map +1 -0
- package/lib/testUtils/interopPubkeyCache.js +92 -0
- package/lib/testUtils/interopPubkeyCache.js.map +1 -0
- package/lib/testUtils/state.d.ts.map +1 -1
- package/lib/testUtils/state.js +5 -5
- package/lib/testUtils/state.js.map +1 -1
- package/lib/testUtils/testFileCache.d.ts.map +1 -1
- package/lib/testUtils/testFileCache.js +3 -0
- package/lib/testUtils/testFileCache.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 +27 -35
- package/lib/testUtils/util.js.map +1 -1
- package/lib/util/gloas.d.ts +6 -0
- package/lib/util/gloas.d.ts.map +1 -1
- package/lib/util/gloas.js +25 -11
- package/lib/util/gloas.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/pendingDepositsLookup.d.ts +12 -0
- package/lib/util/pendingDepositsLookup.d.ts.map +1 -1
- package/lib/util/pendingDepositsLookup.js +19 -1
- package/lib/util/pendingDepositsLookup.js.map +1 -1
- package/lib/util/signatureSets.d.ts +5 -13
- package/lib/util/signatureSets.d.ts.map +1 -1
- package/lib/util/signatureSets.js +30 -39
- package/lib/util/signatureSets.js.map +1 -1
- package/lib/util/syncCommittee.js +1 -1
- package/lib/util/syncCommittee.js.map +1 -1
- package/package.json +11 -12
- package/src/block/isValidIndexedAttestation.ts +2 -8
- package/src/block/isValidIndexedPayloadAttestation.ts +1 -4
- package/src/block/processAttestationPhase0.ts +0 -1
- package/src/block/processAttestationsAltair.ts +2 -2
- package/src/block/processAttesterSlashing.ts +2 -13
- package/src/block/processDeposit.ts +35 -47
- package/src/block/processExecutionPayloadBid.ts +8 -6
- package/src/block/processProposerSlashing.ts +2 -11
- package/src/block/processRandao.ts +1 -1
- package/src/block/processSyncCommittee.ts +1 -1
- package/src/block/processVoluntaryExit.ts +1 -4
- package/src/cache/epochCache.ts +6 -7
- package/src/cache/stateCache.ts +1 -1
- package/src/cache/syncCommitteeCache.ts +3 -2
- package/src/epoch/processSyncCommitteeUpdates.ts +1 -1
- package/src/index.ts +8 -7
- 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 +23 -0
- package/src/rewards/attestationsRewards.ts +1 -1
- package/src/rewards/syncCommitteeRewards.ts +4 -2
- package/src/signatureSets/blsToExecutionChange.ts +1 -2
- package/src/signatureSets/executionPayloadEnvelope.ts +14 -15
- package/src/signatureSets/proposer.ts +1 -3
- package/src/signatureSets/randao.ts +2 -3
- package/src/signatureSets/voluntaryExits.ts +2 -5
- package/src/slot/upgradeStateToGloas.ts +75 -24
- package/src/stateTransition.ts +8 -3
- package/src/stateView/beaconStateView.ts +16 -1
- package/src/stateView/computeNewStateRoot.ts +35 -0
- package/src/stateView/interface.ts +24 -1
- package/src/stateView/nativeBeaconStateView.ts +10 -0
- package/src/stateView/stateViewFactory.ts +2 -14
- package/src/testUtils/index.ts +1 -0
- package/src/testUtils/interopPubkeyCache.ts +100 -0
- package/src/testUtils/state.ts +5 -11
- package/src/testUtils/testFileCache.ts +3 -0
- package/src/testUtils/util.ts +26 -38
- package/src/util/gloas.ts +40 -11
- package/src/util/interop.ts +1 -1
- package/src/util/pendingDepositsLookup.ts +20 -1
- package/src/util/signatureSets.ts +34 -51
- package/src/util/syncCommittee.ts +1 -1
- package/lib/cache/pubkeyCache.d.ts +0 -28
- package/lib/cache/pubkeyCache.d.ts.map +0 -1
- package/lib/cache/pubkeyCache.js +0 -49
- package/lib/cache/pubkeyCache.js.map +0 -1
- package/src/cache/pubkeyCache.ts +0 -74
|
@@ -32,7 +32,7 @@ export function processSyncAggregate(
|
|
|
32
32
|
participantIndices
|
|
33
33
|
);
|
|
34
34
|
// When there's no participation we consider the signature valid and just ignore it
|
|
35
|
-
if (signatureSet !== null && !verifySignatureSet(signatureSet
|
|
35
|
+
if (signatureSet !== null && !verifySignatureSet(signatureSet)) {
|
|
36
36
|
throw Error("Sync committee signature invalid");
|
|
37
37
|
}
|
|
38
38
|
}
|
|
@@ -93,10 +93,7 @@ function getValidatorVoluntaryExitValidity(
|
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
// Verify signature
|
|
96
|
-
if (
|
|
97
|
-
verifySignature &&
|
|
98
|
-
!verifyVoluntaryExitSignature(config, epochCtx.pubkeyCache, new BeaconStateView(state), signedVoluntaryExit)
|
|
99
|
-
) {
|
|
96
|
+
if (verifySignature && !verifyVoluntaryExitSignature(config, new BeaconStateView(state), signedVoluntaryExit)) {
|
|
100
97
|
return VoluntaryExitValidity.invalidSignature;
|
|
101
98
|
}
|
|
102
99
|
|
package/src/cache/epochCache.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {PublicKey} from "@chainsafe/blst";
|
|
1
|
+
import {PublicKey} from "@chainsafe/lodestar-z/blst";
|
|
2
|
+
import {type PubkeyCache, pubkeyCache as defaultPubkeyCache} from "@chainsafe/lodestar-z/pubkeys";
|
|
2
3
|
import {BeaconConfig, ChainConfig, createBeaconConfig} from "@lodestar/config";
|
|
3
4
|
import {
|
|
4
5
|
ATTESTATION_SUBNET_COUNT,
|
|
@@ -56,7 +57,6 @@ import {sumTargetUnslashedBalanceIncrements} from "../util/targetUnslashedBalanc
|
|
|
56
57
|
import {BuilderDepositSignatureCache} from "./builderDepositSignatureCache.js";
|
|
57
58
|
import {EffectiveBalanceIncrements, getEffectiveBalanceIncrementsWithLen} from "./effectiveBalanceIncrements.js";
|
|
58
59
|
import {EpochTransitionCache} from "./epochTransitionCache.js";
|
|
59
|
-
import {PubkeyCache, createPubkeyCache, syncPubkeys} from "./pubkeyCache.js";
|
|
60
60
|
import {CachedBeaconStateAllForks, CachedBeaconStateFulu, CachedBeaconStateGloas} from "./stateCache.js";
|
|
61
61
|
import {
|
|
62
62
|
SyncCommitteeCache,
|
|
@@ -341,10 +341,10 @@ export class EpochCache {
|
|
|
341
341
|
const validators = state.validators.getAllReadonlyValues();
|
|
342
342
|
const validatorCount = validators.length;
|
|
343
343
|
|
|
344
|
-
// syncPubkeys here to ensure EpochCacheImmutableData is
|
|
344
|
+
// syncPubkeys here to ensure EpochCacheImmutableData is populated before computing the rest of caches
|
|
345
345
|
// - computeSyncCommitteeCache() needs a fully populated pubkeyCache
|
|
346
346
|
if (!opts?.skipSyncPubkeys) {
|
|
347
|
-
syncPubkeys(
|
|
347
|
+
pubkeyCache.syncPubkeys(validators);
|
|
348
348
|
}
|
|
349
349
|
|
|
350
350
|
const effectiveBalanceIncrements = getEffectiveBalanceIncrementsWithLen(validatorCount);
|
|
@@ -908,7 +908,7 @@ export class EpochCache {
|
|
|
908
908
|
}
|
|
909
909
|
|
|
910
910
|
addPubkey(index: ValidatorIndex, pubkey: Uint8Array): void {
|
|
911
|
-
this.pubkeyCache.
|
|
911
|
+
this.pubkeyCache.append(index, pubkey);
|
|
912
912
|
}
|
|
913
913
|
|
|
914
914
|
getShufflingAtSlot(slot: Slot): EpochShuffling {
|
|
@@ -1123,7 +1123,6 @@ export function createEmptyEpochCacheImmutableData(
|
|
|
1123
1123
|
): EpochCacheImmutableData {
|
|
1124
1124
|
return {
|
|
1125
1125
|
config: createBeaconConfig(chainConfig, state.genesisValidatorsRoot),
|
|
1126
|
-
|
|
1127
|
-
pubkeyCache: createPubkeyCache(),
|
|
1126
|
+
pubkeyCache: defaultPubkeyCache,
|
|
1128
1127
|
};
|
|
1129
1128
|
}
|
package/src/cache/stateCache.ts
CHANGED
|
@@ -187,7 +187,7 @@ export function loadCachedBeaconState<T extends CachedBeaconStateAllForks>(
|
|
|
187
187
|
const validators = migratedState.validators;
|
|
188
188
|
for (const validatorIndex of modifiedValidators) {
|
|
189
189
|
const validator = validators.getReadonly(validatorIndex);
|
|
190
|
-
pubkeyCache.
|
|
190
|
+
pubkeyCache.append(validatorIndex, validator.pubkey);
|
|
191
191
|
}
|
|
192
192
|
|
|
193
193
|
return createCachedBeaconState(
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import {type PubkeyCache} from "@chainsafe/lodestar-z/pubkeys";
|
|
1
2
|
import {CompositeViewDU} from "@chainsafe/ssz";
|
|
2
3
|
import {ValidatorIndex, ssz} from "@lodestar/types";
|
|
3
4
|
import {toPubkeyHex} from "@lodestar/utils";
|
|
@@ -38,7 +39,7 @@ export function getSyncCommitteeCache(validatorIndices: Uint32Array): SyncCommit
|
|
|
38
39
|
|
|
39
40
|
export function computeSyncCommitteeCache(
|
|
40
41
|
syncCommittee: CompositeViewDU<typeof ssz.altair.SyncCommittee>,
|
|
41
|
-
pubkeyCache:
|
|
42
|
+
pubkeyCache: PubkeyCache
|
|
42
43
|
): SyncCommitteeCache {
|
|
43
44
|
const validatorIndices = computeSyncCommitteeValidatorIndices(syncCommittee, pubkeyCache);
|
|
44
45
|
const validatorIndexMap = computeValidatorSyncCommitteeIndexMap(validatorIndices);
|
|
@@ -78,7 +79,7 @@ export function computeValidatorSyncCommitteeIndexMap(
|
|
|
78
79
|
*/
|
|
79
80
|
function computeSyncCommitteeValidatorIndices(
|
|
80
81
|
syncCommittee: CompositeViewDU<typeof ssz.altair.SyncCommittee>,
|
|
81
|
-
pubkeyCache:
|
|
82
|
+
pubkeyCache: PubkeyCache
|
|
82
83
|
): Uint32Array {
|
|
83
84
|
const pubkeys = syncCommittee.pubkeys.getAllReadonly();
|
|
84
85
|
const validatorIndices = new Uint32Array(pubkeys.length);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {aggregateSerializedPublicKeys} from "@chainsafe/blst";
|
|
1
|
+
import {aggregateSerializedPublicKeys} from "@chainsafe/lodestar-z/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";
|
package/src/index.ts
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
export {
|
|
2
|
-
type BlockExternalData,
|
|
3
|
-
DataAvailabilityStatus,
|
|
4
|
-
ExecutionPayloadStatus,
|
|
5
|
-
} from "./block/externalData.js";
|
|
1
|
+
export {type BlockExternalData, DataAvailabilityStatus, ExecutionPayloadStatus} from "./block/externalData.js";
|
|
6
2
|
export {getAttestationParticipationStatus, processAttestationsAltair} from "./block/processAttestationsAltair.js";
|
|
7
3
|
export {assertValidAttesterSlashing} from "./block/processAttesterSlashing.js";
|
|
8
4
|
export {isValidBlsToExecutionChange} from "./block/processBlsToExecutionChange.js";
|
|
@@ -10,7 +6,11 @@ export {isValidBlsToExecutionChange} from "./block/processBlsToExecutionChange.j
|
|
|
10
6
|
export {becomesNewEth1Data} from "./block/processEth1Data.js";
|
|
11
7
|
export {assertValidProposerSlashing} from "./block/processProposerSlashing.js";
|
|
12
8
|
// BeaconChain validation
|
|
13
|
-
export {
|
|
9
|
+
export {
|
|
10
|
+
VoluntaryExitValidity,
|
|
11
|
+
getVoluntaryExitValidity,
|
|
12
|
+
isValidVoluntaryExit,
|
|
13
|
+
} from "./block/processVoluntaryExit.js";
|
|
14
14
|
// Withdrawals for new blocks
|
|
15
15
|
export {getExpectedWithdrawals} from "./block/processWithdrawals.js";
|
|
16
16
|
export {ProposerRewardType} from "./block/types.js";
|
|
@@ -25,7 +25,6 @@ export {
|
|
|
25
25
|
createEmptyEpochCacheImmutableData,
|
|
26
26
|
} from "./cache/epochCache.js";
|
|
27
27
|
export {type EpochTransitionCache, beforeProcessEpoch} from "./cache/epochTransitionCache.js";
|
|
28
|
-
export {type PubkeyCache, createPubkeyCache, syncPubkeys} from "./cache/pubkeyCache.js";
|
|
29
28
|
// Main state caches
|
|
30
29
|
export {
|
|
31
30
|
type BeaconStateCache,
|
|
@@ -44,6 +43,8 @@ export * from "./signatureSets/index.js";
|
|
|
44
43
|
export * from "./stateTransition.js";
|
|
45
44
|
export {BeaconStateView} from "./stateView/beaconStateView.js";
|
|
46
45
|
export {
|
|
46
|
+
type ComputeNewStateRootInput,
|
|
47
|
+
type ComputeNewStateRootResult,
|
|
47
48
|
type IBeaconStateView,
|
|
48
49
|
type IBeaconStateViewAltair,
|
|
49
50
|
type IBeaconStateViewBellatrix,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {PublicKey} from "@chainsafe/blst";
|
|
1
|
+
import type {PublicKey} from "@chainsafe/lodestar-z/blst";
|
|
2
2
|
import {BeaconConfig} from "@lodestar/config";
|
|
3
3
|
import {LightClientBootstrap, LightClientHeader, LightClientUpdate, SyncPeriod} from "@lodestar/types";
|
|
4
4
|
import {computeSyncPeriodAtSlot} from "../../util/epoch.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {PublicKey, Signature, fastAggregateVerify} from "@chainsafe/blst";
|
|
1
|
+
import {PublicKey, Signature, fastAggregateVerify} from "@chainsafe/lodestar-z/blst";
|
|
2
2
|
import {ChainForkConfig} from "@lodestar/config";
|
|
3
3
|
import {DOMAIN_SYNC_COMMITTEE, GENESIS_SLOT, MIN_SYNC_COMMITTEE_PARTICIPANTS} from "@lodestar/params";
|
|
4
4
|
import {LightClientUpdate, Root, ssz} from "@lodestar/types";
|
package/src/metrics.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import {ForkName} from "@lodestar/params";
|
|
1
2
|
import {MetricsRegister} from "@lodestar/utils";
|
|
2
3
|
import {ProposerRewardType} from "./block/types.js";
|
|
3
4
|
import {EpochTransitionStep} from "./epoch/index.js";
|
|
@@ -31,6 +32,28 @@ export function getMetrics(register: MetricsRegister) {
|
|
|
31
32
|
labelNames: ["step"],
|
|
32
33
|
buckets: [0.01, 0.05, 0.1, 0.2, 0.5, 0.75, 1],
|
|
33
34
|
}),
|
|
35
|
+
forkUpgradeTime: register.histogram<{fork: ForkName}>({
|
|
36
|
+
name: "lodestar_stfn_fork_upgrade_seconds",
|
|
37
|
+
help: "Time to upgrade the state at a fork boundary in seconds",
|
|
38
|
+
labelNames: ["fork"],
|
|
39
|
+
// The gloas upgrade is unbounded (see onboardBuildersTime), hence the long tail
|
|
40
|
+
buckets: [0.05, 0.1, 0.25, 0.5, 1, 2, 5, 10, 30],
|
|
41
|
+
}),
|
|
42
|
+
onboardBuildersTime: register.histogram({
|
|
43
|
+
name: "lodestar_stfn_gloas_onboard_builders_seconds",
|
|
44
|
+
help: "Time spent in onboardBuildersFromPendingDeposits at the gloas fork transition",
|
|
45
|
+
buckets: [0.05, 0.1, 0.25, 0.5, 1, 2, 5, 10, 30],
|
|
46
|
+
}),
|
|
47
|
+
onboardBuildersDeposits: register.gauge<{outcome: "onboarded" | "topup" | "kept" | "dropped"}>({
|
|
48
|
+
name: "lodestar_stfn_gloas_onboard_builders_deposits",
|
|
49
|
+
help: "Pending deposits handled at the gloas fork transition, by outcome",
|
|
50
|
+
labelNames: ["outcome"],
|
|
51
|
+
}),
|
|
52
|
+
onboardBuildersSignatureChecks: register.gauge<{source: "cache" | "verified"}>({
|
|
53
|
+
name: "lodestar_stfn_gloas_onboard_builders_signature_checks",
|
|
54
|
+
help: "Builder deposit signature checks at the gloas fork transition. `verified` means the pre-verify cache missed and BLS ran inline, on the fork transition's critical path",
|
|
55
|
+
labelNames: ["source"],
|
|
56
|
+
}),
|
|
34
57
|
processBlockTime: register.histogram({
|
|
35
58
|
name: "lodestar_stfn_process_block_seconds",
|
|
36
59
|
help: "Time to process a single block in seconds",
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import {type PubkeyCache} from "@chainsafe/lodestar-z/pubkeys";
|
|
1
2
|
import {BeaconConfig} from "@lodestar/config";
|
|
2
3
|
import {
|
|
3
4
|
EFFECTIVE_BALANCE_INCREMENT,
|
|
@@ -15,7 +16,6 @@ import {
|
|
|
15
16
|
import {ValidatorIndex, rewards} from "@lodestar/types";
|
|
16
17
|
import {fromHex} from "@lodestar/utils";
|
|
17
18
|
import {EpochTransitionCache, beforeProcessEpoch} from "../cache/epochTransitionCache.js";
|
|
18
|
-
import {PubkeyCache} from "../cache/pubkeyCache.js";
|
|
19
19
|
import {CachedBeaconStateAllForks, CachedBeaconStateAltair} from "../types.js";
|
|
20
20
|
import {
|
|
21
21
|
FLAG_ELIGIBLE_ATTESTER,
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import {type PubkeyCache} from "@chainsafe/lodestar-z/pubkeys";
|
|
1
2
|
import {BeaconConfig} from "@lodestar/config";
|
|
2
3
|
import {ForkName, SYNC_COMMITTEE_SIZE} from "@lodestar/params";
|
|
3
4
|
import {BeaconBlock, ValidatorIndex, altair, rewards} from "@lodestar/types";
|
|
4
|
-
import {
|
|
5
|
+
import {toPubkeyHex} from "@lodestar/utils";
|
|
5
6
|
import {CachedBeaconStateAllForks, CachedBeaconStateAltair} from "../cache/stateCache.js";
|
|
6
7
|
|
|
7
8
|
export async function computeSyncCommitteeRewards(
|
|
@@ -48,7 +49,8 @@ export async function computeSyncCommitteeRewards(
|
|
|
48
49
|
if (validatorIds.length) {
|
|
49
50
|
const filtersSet = new Set(validatorIds);
|
|
50
51
|
return rewards.filter((reward) => {
|
|
51
|
-
const
|
|
52
|
+
const pubkey = pubkeyCache.getPubkeyBytes(reward.validatorIndex);
|
|
53
|
+
const pubkeyHex = pubkey === undefined ? undefined : toPubkeyHex(pubkey);
|
|
52
54
|
return filtersSet.has(reward.validatorIndex) || (pubkeyHex !== undefined && filtersSet.has(pubkeyHex));
|
|
53
55
|
});
|
|
54
56
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import {PublicKey} from "@chainsafe/blst";
|
|
2
1
|
import {BeaconConfig} from "@lodestar/config";
|
|
3
2
|
import {DOMAIN_BLS_TO_EXECUTION_CHANGE, ForkName} from "@lodestar/params";
|
|
4
3
|
import {capella, ssz} from "@lodestar/types";
|
|
@@ -26,7 +25,7 @@ export function getBlsToExecutionChangeSignatureSet(
|
|
|
26
25
|
type: SignatureSetType.single,
|
|
27
26
|
// The withdrawal pubkey is the same as signedBLSToExecutionChange's fromBlsPubkey as it should
|
|
28
27
|
// be validated against the withdrawal credentials digest
|
|
29
|
-
pubkey:
|
|
28
|
+
pubkey: signedBLSToExecutionChange.message.fromBlsPubkey,
|
|
30
29
|
signingRoot: computeSigningRoot(ssz.capella.BLSToExecutionChange, signedBLSToExecutionChange.message, domain),
|
|
31
30
|
signature: signedBLSToExecutionChange.signature,
|
|
32
31
|
};
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import {PublicKey} from "@chainsafe/blst";
|
|
2
1
|
import {BeaconConfig} from "@lodestar/config";
|
|
3
2
|
import {BUILDER_INDEX_SELF_BUILD, DOMAIN_BEACON_BUILDER} from "@lodestar/params";
|
|
4
3
|
import {ValidatorIndex, gloas, ssz} from "@lodestar/types";
|
|
5
|
-
import {PubkeyCache} from "../cache/pubkeyCache.js";
|
|
6
4
|
import {IBeaconStateView, isStatePostGloas} from "../stateView/interface.js";
|
|
7
5
|
import {computeSigningRoot} from "../util/index.js";
|
|
8
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
type ISignatureSet,
|
|
8
|
+
createIndexedSignatureSetFromComponents,
|
|
9
|
+
createSingleSignatureSetFromComponents,
|
|
10
|
+
} from "../util/signatureSets.js";
|
|
9
11
|
|
|
10
12
|
export function getExecutionPayloadEnvelopeSigningRoot(
|
|
11
13
|
config: BeaconConfig,
|
|
@@ -18,24 +20,21 @@ export function getExecutionPayloadEnvelopeSigningRoot(
|
|
|
18
20
|
|
|
19
21
|
export function getExecutionPayloadEnvelopeSignatureSet(
|
|
20
22
|
config: BeaconConfig,
|
|
21
|
-
pubkeyCache: PubkeyCache,
|
|
22
23
|
state: IBeaconStateView,
|
|
23
24
|
signedEnvelope: gloas.SignedExecutionPayloadEnvelope,
|
|
24
25
|
proposerIndex: ValidatorIndex
|
|
25
|
-
):
|
|
26
|
+
): ISignatureSet {
|
|
26
27
|
if (!isStatePostGloas(state)) {
|
|
27
28
|
throw new Error(`Expected gloas+ state for execution payload envelope signature, got fork=${state.forkName}`);
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
const envelope = signedEnvelope.message;
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
signedEnvelope.signature
|
|
40
|
-
);
|
|
32
|
+
const signingRoot = getExecutionPayloadEnvelopeSigningRoot(config, envelope);
|
|
33
|
+
return envelope.builderIndex === BUILDER_INDEX_SELF_BUILD
|
|
34
|
+
? createIndexedSignatureSetFromComponents(proposerIndex, signingRoot, signedEnvelope.signature)
|
|
35
|
+
: createSingleSignatureSetFromComponents(
|
|
36
|
+
state.getBuilder(envelope.builderIndex).pubkey,
|
|
37
|
+
signingRoot,
|
|
38
|
+
signedEnvelope.signature
|
|
39
|
+
);
|
|
41
40
|
}
|
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
import {BeaconConfig} from "@lodestar/config";
|
|
2
2
|
import {DOMAIN_BEACON_PROPOSER} from "@lodestar/params";
|
|
3
3
|
import {SignedBeaconBlock, SignedBlindedBeaconBlock, Slot, isBlindedBeaconBlock, phase0, ssz} from "@lodestar/types";
|
|
4
|
-
import {PubkeyCache} from "../cache/pubkeyCache.js";
|
|
5
4
|
import {computeSigningRoot} from "../util/index.js";
|
|
6
5
|
import {ISignatureSet, SignatureSetType, verifySignatureSet} from "../util/signatureSets.js";
|
|
7
6
|
|
|
8
7
|
export function verifyProposerSignature(
|
|
9
8
|
config: BeaconConfig,
|
|
10
|
-
pubkeyCache: PubkeyCache,
|
|
11
9
|
signedBlock: SignedBeaconBlock | SignedBlindedBeaconBlock
|
|
12
10
|
): boolean {
|
|
13
11
|
const signatureSet = getBlockProposerSignatureSet(config, signedBlock);
|
|
14
|
-
return verifySignatureSet(signatureSet
|
|
12
|
+
return verifySignatureSet(signatureSet);
|
|
15
13
|
}
|
|
16
14
|
|
|
17
15
|
export function getBlockProposerSignatureSet(
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import {BeaconConfig} from "@lodestar/config";
|
|
2
2
|
import {DOMAIN_RANDAO} from "@lodestar/params";
|
|
3
3
|
import {BeaconBlock, ssz} from "@lodestar/types";
|
|
4
|
-
import {PubkeyCache} from "../cache/pubkeyCache.js";
|
|
5
4
|
import {
|
|
6
5
|
ISignatureSet,
|
|
7
6
|
SignatureSetType,
|
|
@@ -10,8 +9,8 @@ import {
|
|
|
10
9
|
verifySignatureSet,
|
|
11
10
|
} from "../util/index.js";
|
|
12
11
|
|
|
13
|
-
export function verifyRandaoSignature(config: BeaconConfig,
|
|
14
|
-
return verifySignatureSet(getRandaoRevealSignatureSet(config, block)
|
|
12
|
+
export function verifyRandaoSignature(config: BeaconConfig, block: BeaconBlock): boolean {
|
|
13
|
+
return verifySignatureSet(getRandaoRevealSignatureSet(config, block));
|
|
15
14
|
}
|
|
16
15
|
|
|
17
16
|
/**
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import {PublicKey} from "@chainsafe/blst";
|
|
2
1
|
import {BeaconConfig} from "@lodestar/config";
|
|
3
2
|
import {ForkSeq} from "@lodestar/params";
|
|
4
3
|
import {SignedBeaconBlock, Slot, phase0, ssz} from "@lodestar/types";
|
|
5
|
-
import {PubkeyCache} from "../cache/pubkeyCache.js";
|
|
6
4
|
import {IBeaconStateView, IBeaconStateViewGloas, isStatePostGloas} from "../stateView/interface.js";
|
|
7
5
|
import {
|
|
8
6
|
ISignatureSet,
|
|
@@ -16,11 +14,10 @@ import {
|
|
|
16
14
|
|
|
17
15
|
export function verifyVoluntaryExitSignature(
|
|
18
16
|
config: BeaconConfig,
|
|
19
|
-
pubkeyCache: PubkeyCache,
|
|
20
17
|
state: IBeaconStateView,
|
|
21
18
|
signedVoluntaryExit: phase0.SignedVoluntaryExit
|
|
22
19
|
): boolean {
|
|
23
|
-
return verifySignatureSet(getVoluntaryExitSignatureSet(config, state, signedVoluntaryExit)
|
|
20
|
+
return verifySignatureSet(getVoluntaryExitSignatureSet(config, state, signedVoluntaryExit));
|
|
24
21
|
}
|
|
25
22
|
|
|
26
23
|
/**
|
|
@@ -81,7 +78,7 @@ export function getBuilderVoluntaryExitSignatureSet(
|
|
|
81
78
|
|
|
82
79
|
return {
|
|
83
80
|
type: SignatureSetType.single,
|
|
84
|
-
pubkey:
|
|
81
|
+
pubkey: builder.pubkey,
|
|
85
82
|
signingRoot: computeSigningRoot(ssz.phase0.VoluntaryExit, signedVoluntaryExit.message, domain),
|
|
86
83
|
signature: signedVoluntaryExit.signature,
|
|
87
84
|
};
|
|
@@ -10,13 +10,14 @@ import {
|
|
|
10
10
|
ProgressiveListCompositeType,
|
|
11
11
|
ValueOf,
|
|
12
12
|
} from "@chainsafe/ssz";
|
|
13
|
-
import {PAYLOAD_BUILDER_VERSION, SLOTS_PER_HISTORICAL_ROOT} from "@lodestar/params";
|
|
14
|
-
import {ssz} from "@lodestar/types";
|
|
13
|
+
import {BUILDER_INDEX_SELF_BUILD, PAYLOAD_BUILDER_VERSION, SLOTS_PER_HISTORICAL_ROOT} from "@lodestar/params";
|
|
14
|
+
import {BuilderIndex, ssz} from "@lodestar/types";
|
|
15
15
|
import {toPubkeyHex} from "@lodestar/utils";
|
|
16
16
|
import {isValidDepositSignature} from "../block/processDeposit.js";
|
|
17
17
|
import {getCachedBeaconState} from "../cache/stateCache.js";
|
|
18
|
+
import type {BeaconStateTransitionMetrics} from "../metrics.js";
|
|
18
19
|
import {CachedBeaconStateFulu, CachedBeaconStateGloas} from "../types.js";
|
|
19
|
-
import {
|
|
20
|
+
import {appendBuilderToRegistry, initializePtcWindow, isBuilderWithdrawalCredential} from "../util/gloas.js";
|
|
20
21
|
import {isValidatorKnown} from "../util/index.js";
|
|
21
22
|
import {PendingDepositsLookup} from "../util/pendingDepositsLookup.js";
|
|
22
23
|
import {progressiveListRootNode} from "../util/ssz.js";
|
|
@@ -24,7 +25,10 @@ import {progressiveListRootNode} from "../util/ssz.js";
|
|
|
24
25
|
/**
|
|
25
26
|
* Upgrade a state from Fulu to Gloas.
|
|
26
27
|
*/
|
|
27
|
-
export function upgradeStateToGloas(
|
|
28
|
+
export function upgradeStateToGloas(
|
|
29
|
+
stateFulu: CachedBeaconStateFulu,
|
|
30
|
+
metrics?: BeaconStateTransitionMetrics | null
|
|
31
|
+
): CachedBeaconStateGloas {
|
|
28
32
|
const {config} = stateFulu;
|
|
29
33
|
|
|
30
34
|
ssz.fulu.BeaconState.commitViewDU(stateFulu);
|
|
@@ -69,11 +73,21 @@ export function upgradeStateToGloas(stateFulu: CachedBeaconStateFulu): CachedBea
|
|
|
69
73
|
);
|
|
70
74
|
stateGloasView.currentSyncCommittee = stateGloasCloned.currentSyncCommittee;
|
|
71
75
|
stateGloasView.nextSyncCommittee = stateGloasCloned.nextSyncCommittee;
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
76
|
+
const latestExecutionPayloadBid = ssz.gloas.ExecutionPayloadBid.toViewDU({
|
|
77
|
+
parentBlockHash: stateFulu.latestExecutionPayloadHeader.parentHash,
|
|
78
|
+
parentBlockRoot: stateFulu.latestBlockHeader.parentRoot,
|
|
79
|
+
blockHash: stateFulu.latestExecutionPayloadHeader.blockHash,
|
|
80
|
+
prevRandao: stateFulu.latestExecutionPayloadHeader.prevRandao,
|
|
81
|
+
feeRecipient: ssz.ExecutionAddress.defaultValue(),
|
|
82
|
+
gasLimit: BigInt(stateFulu.latestExecutionPayloadHeader.gasLimit),
|
|
83
|
+
builderIndex: BUILDER_INDEX_SELF_BUILD,
|
|
84
|
+
slot: stateFulu.latestBlockHeader.slot,
|
|
85
|
+
value: 0,
|
|
86
|
+
executionPayment: 0n,
|
|
87
|
+
blobKzgCommitments: ssz.gloas.BlobKzgCommitments.defaultValue(),
|
|
88
|
+
executionRequestsRoot: ssz.gloas.ExecutionRequests.hashTreeRoot(ssz.gloas.ExecutionRequests.defaultValue()),
|
|
89
|
+
});
|
|
90
|
+
stateGloasView.latestExecutionPayloadBid = latestExecutionPayloadBid;
|
|
77
91
|
stateGloasView.nextWithdrawalIndex = stateGloasCloned.nextWithdrawalIndex;
|
|
78
92
|
stateGloasView.nextWithdrawalValidatorIndex = stateGloasCloned.nextWithdrawalValidatorIndex;
|
|
79
93
|
stateGloasView.historicalSummaries = stateGloasCloned.historicalSummaries;
|
|
@@ -106,7 +120,7 @@ export function upgradeStateToGloas(stateFulu: CachedBeaconStateFulu): CachedBea
|
|
|
106
120
|
const stateGloas = getCachedBeaconState(stateGloasView, stateFulu);
|
|
107
121
|
|
|
108
122
|
// Process pending builder deposits at the fork boundary
|
|
109
|
-
onboardBuildersFromPendingDeposits(stateGloas);
|
|
123
|
+
onboardBuildersFromPendingDeposits(stateGloas, metrics);
|
|
110
124
|
|
|
111
125
|
stateGloas.commit();
|
|
112
126
|
// Clear cache to ensure the cache of fulu fields is not used by new gloas fields
|
|
@@ -164,10 +178,29 @@ function migrateBasicListToGloas<ElementType extends BasicType<unknown>>(
|
|
|
164
178
|
* Applies any pending deposits for builders to onboard builders during the fork transition
|
|
165
179
|
* Spec: https://github.com/ethereum/consensus-specs/blob/v1.7.0-alpha.8/specs/gloas/fork.md#new-onboard_builders_from_pending_deposits
|
|
166
180
|
*/
|
|
167
|
-
function onboardBuildersFromPendingDeposits(
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
181
|
+
function onboardBuildersFromPendingDeposits(
|
|
182
|
+
state: CachedBeaconStateGloas,
|
|
183
|
+
metrics?: BeaconStateTransitionMetrics | null
|
|
184
|
+
): void {
|
|
185
|
+
const timer = metrics?.onboardBuildersTime.startTimer();
|
|
186
|
+
|
|
187
|
+
// Counted so the duration above is interpretable: this loop walks the whole pending
|
|
188
|
+
// deposit queue, and its cost is dominated by whichever branch the queue happens to
|
|
189
|
+
// hit. `verified` signature checks are the ones the pre-verify cache missed, i.e. BLS
|
|
190
|
+
// running inline on the fork transition's critical path. The signature totals include
|
|
191
|
+
// the checks hasPendingValidator() does internally, which dominate when a builder
|
|
192
|
+
// deposit is preceded by same-pubkey validator deposits.
|
|
193
|
+
let onboarded = 0;
|
|
194
|
+
let topups = 0;
|
|
195
|
+
let kept = 0;
|
|
196
|
+
let dropped = 0;
|
|
197
|
+
let sigFromCache = 0;
|
|
198
|
+
let sigVerified = 0;
|
|
199
|
+
|
|
200
|
+
// Track pubkeys of new builders added when applying deposits, mapped to their registry
|
|
201
|
+
// index. `state.builders` starts empty at the fork and this loop only ever appends, so the
|
|
202
|
+
// index is stable and a top-up can go straight to it instead of scanning.
|
|
203
|
+
const builderIndexByPubkey = new Map<string, BuilderIndex>();
|
|
171
204
|
|
|
172
205
|
const pendingDeposits = ssz.gloas.PendingDeposits.defaultViewDU();
|
|
173
206
|
const pendingDepositsLookup = PendingDepositsLookup.buildEmpty();
|
|
@@ -182,18 +215,15 @@ function onboardBuildersFromPendingDeposits(state: CachedBeaconStateGloas): void
|
|
|
182
215
|
if (isValidatorKnown(state, validatorIndex)) {
|
|
183
216
|
pendingDeposits.push(deposit);
|
|
184
217
|
pendingDepositsLookup.add(depositValue, pubkeyHex);
|
|
218
|
+
kept++;
|
|
185
219
|
continue;
|
|
186
220
|
}
|
|
187
221
|
|
|
188
|
-
|
|
222
|
+
const builderIndex = builderIndexByPubkey.get(pubkeyHex);
|
|
223
|
+
if (builderIndex !== undefined) {
|
|
189
224
|
// Top up an already-onboarded builder
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
if (toPubkeyHex(state.builders.getReadonly(j).pubkey) === pubkeyHex) {
|
|
193
|
-
state.builders.get(j).balance += deposit.amount;
|
|
194
|
-
break;
|
|
195
|
-
}
|
|
196
|
-
}
|
|
225
|
+
state.builders.get(builderIndex).balance += deposit.amount;
|
|
226
|
+
topups++;
|
|
197
227
|
continue;
|
|
198
228
|
}
|
|
199
229
|
|
|
@@ -203,6 +233,7 @@ function onboardBuildersFromPendingDeposits(state: CachedBeaconStateGloas): void
|
|
|
203
233
|
if (!isBuilderWithdrawalCredential(deposit.withdrawalCredentials)) {
|
|
204
234
|
pendingDeposits.push(deposit);
|
|
205
235
|
pendingDepositsLookup.add(depositValue, pubkeyHex);
|
|
236
|
+
kept++;
|
|
206
237
|
continue;
|
|
207
238
|
}
|
|
208
239
|
if (
|
|
@@ -210,6 +241,7 @@ function onboardBuildersFromPendingDeposits(state: CachedBeaconStateGloas): void
|
|
|
210
241
|
) {
|
|
211
242
|
pendingDeposits.push(deposit);
|
|
212
243
|
pendingDepositsLookup.add(depositValue, pubkeyHex);
|
|
244
|
+
kept++;
|
|
213
245
|
continue;
|
|
214
246
|
}
|
|
215
247
|
|
|
@@ -219,6 +251,11 @@ function onboardBuildersFromPendingDeposits(state: CachedBeaconStateGloas): void
|
|
|
219
251
|
// The prepareNextSlot scheduler pre-verifies these signatures in the epochs before the fork
|
|
220
252
|
// A cache miss falls back to verifying this one deposit — no worse than pre-cache.
|
|
221
253
|
const cached = state.epochCtx.builderDepositSignatureCache.getSignatureValidity(depositValue);
|
|
254
|
+
if (cached === null) {
|
|
255
|
+
sigVerified++;
|
|
256
|
+
} else {
|
|
257
|
+
sigFromCache++;
|
|
258
|
+
}
|
|
222
259
|
const isValid =
|
|
223
260
|
cached ??
|
|
224
261
|
isValidDepositSignature(
|
|
@@ -229,10 +266,11 @@ function onboardBuildersFromPendingDeposits(state: CachedBeaconStateGloas): void
|
|
|
229
266
|
deposit.signature
|
|
230
267
|
);
|
|
231
268
|
if (!isValid) {
|
|
269
|
+
dropped++;
|
|
232
270
|
continue;
|
|
233
271
|
}
|
|
234
272
|
|
|
235
|
-
|
|
273
|
+
appendBuilderToRegistry(
|
|
236
274
|
state,
|
|
237
275
|
deposit.pubkey,
|
|
238
276
|
PAYLOAD_BUILDER_VERSION,
|
|
@@ -240,8 +278,21 @@ function onboardBuildersFromPendingDeposits(state: CachedBeaconStateGloas): void
|
|
|
240
278
|
deposit.amount,
|
|
241
279
|
deposit.slot
|
|
242
280
|
);
|
|
243
|
-
|
|
281
|
+
// appendBuilderToRegistry() pushes, so the new builder is the last entry
|
|
282
|
+
builderIndexByPubkey.set(pubkeyHex, state.builders.length - 1);
|
|
283
|
+
onboarded++;
|
|
244
284
|
}
|
|
245
285
|
|
|
246
286
|
state.pendingDeposits = pendingDeposits;
|
|
287
|
+
|
|
288
|
+
timer?.();
|
|
289
|
+
if (metrics) {
|
|
290
|
+
metrics.onboardBuildersDeposits.set({outcome: "onboarded"}, onboarded);
|
|
291
|
+
metrics.onboardBuildersDeposits.set({outcome: "topup"}, topups);
|
|
292
|
+
metrics.onboardBuildersDeposits.set({outcome: "kept"}, kept);
|
|
293
|
+
metrics.onboardBuildersDeposits.set({outcome: "dropped"}, dropped);
|
|
294
|
+
const lookupChecks = pendingDepositsLookup.signatureChecks;
|
|
295
|
+
metrics.onboardBuildersSignatureChecks.set({source: "cache"}, sigFromCache + lookupChecks.fromCache);
|
|
296
|
+
metrics.onboardBuildersSignatureChecks.set({source: "verified"}, sigVerified + lookupChecks.verified);
|
|
297
|
+
}
|
|
247
298
|
}
|
package/src/stateTransition.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {SLOTS_PER_EPOCH} from "@lodestar/params";
|
|
1
|
+
import {ForkName, SLOTS_PER_EPOCH} from "@lodestar/params";
|
|
2
2
|
import {Epoch, SignedBeaconBlock, SignedBlindedBeaconBlock, Slot, ssz} from "@lodestar/types";
|
|
3
3
|
import {toRootHex} from "@lodestar/utils";
|
|
4
4
|
import {BlockExternalData, DataAvailabilityStatus, ExecutionPayloadStatus} from "./block/externalData.js";
|
|
@@ -113,7 +113,7 @@ export function stateTransition(
|
|
|
113
113
|
postState = processSlotsWithTransientCache(postState, blockSlot, options, {metrics, validatorMonitor});
|
|
114
114
|
|
|
115
115
|
// Verify proposer signature only
|
|
116
|
-
if (verifyProposer && !verifyProposerSignature(postState.config,
|
|
116
|
+
if (verifyProposer && !verifyProposerSignature(postState.config, signedBlock)) {
|
|
117
117
|
throw new Error("Invalid block signature");
|
|
118
118
|
}
|
|
119
119
|
|
|
@@ -278,7 +278,12 @@ function processSlotsWithTransientCache(
|
|
|
278
278
|
postState = upgradeStateToFulu(postState as CachedBeaconStateElectra) as CachedBeaconStateAllForks;
|
|
279
279
|
}
|
|
280
280
|
if (stateEpoch === config.GLOAS_FORK_EPOCH) {
|
|
281
|
-
|
|
281
|
+
// Timed, unlike the other fork upgrades: this one does unbounded work.
|
|
282
|
+
// onboardBuildersFromPendingDeposits walks the entire pending deposit queue, so its
|
|
283
|
+
// cost is set by whatever is sitting in that queue when the fork lands.
|
|
284
|
+
const timer = metrics?.forkUpgradeTime.startTimer({fork: ForkName.gloas});
|
|
285
|
+
postState = upgradeStateToGloas(postState as CachedBeaconStateFulu, metrics) as CachedBeaconStateAllForks;
|
|
286
|
+
timer?.();
|
|
282
287
|
}
|
|
283
288
|
if (stateEpoch === config.HEZE_FORK_EPOCH) {
|
|
284
289
|
postState = upgradeStateToHeze(postState as CachedBeaconStateGloas) as CachedBeaconStateAllForks;
|
|
@@ -70,7 +70,15 @@ import {loadState} from "../util/loadState/loadState.js";
|
|
|
70
70
|
import {PreVerifyBuilderDepositsResult, preVerifyBuilderDepositsPreGloas} from "../util/preVerifyBuilderDeposits.js";
|
|
71
71
|
import {getRandaoMix} from "../util/seed.js";
|
|
72
72
|
import {getLatestWeakSubjectivityCheckpointEpoch} from "../util/weakSubjectivity.js";
|
|
73
|
-
import {
|
|
73
|
+
import {computeNewStateRootStateTransitionOpts, getComputeNewStateRootResult} from "./computeNewStateRoot.js";
|
|
74
|
+
import {
|
|
75
|
+
ComputeNewStateRootInput,
|
|
76
|
+
ComputeNewStateRootResult,
|
|
77
|
+
IBeaconStateView,
|
|
78
|
+
IBeaconStateViewGloas,
|
|
79
|
+
IBeaconStateViewLatestFork,
|
|
80
|
+
isStatePostGloas,
|
|
81
|
+
} from "./interface.js";
|
|
74
82
|
|
|
75
83
|
export class BeaconStateView implements IBeaconStateViewLatestFork {
|
|
76
84
|
private readonly config: BeaconConfig;
|
|
@@ -823,6 +831,13 @@ export class BeaconStateView implements IBeaconStateViewLatestFork {
|
|
|
823
831
|
|
|
824
832
|
// State transition
|
|
825
833
|
|
|
834
|
+
computeNewStateRoot({block}: ComputeNewStateRootInput, modules: StateTransitionModules): ComputeNewStateRootResult {
|
|
835
|
+
const postState = new BeaconStateView(
|
|
836
|
+
stateTransition(this.cachedState, block, computeNewStateRootStateTransitionOpts, modules)
|
|
837
|
+
);
|
|
838
|
+
return getComputeNewStateRootResult(postState, modules);
|
|
839
|
+
}
|
|
840
|
+
|
|
826
841
|
stateTransition(
|
|
827
842
|
signedBlock: SignedBeaconBlock | SignedBlindedBeaconBlock,
|
|
828
843
|
options: StateTransitionOpts,
|