@lodestar/state-transition 1.41.0-dev.b847afb846 → 1.41.0-dev.bb16850567
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/externalData.js +4 -2
- package/lib/block/externalData.js.map +1 -1
- package/lib/block/index.d.ts +3 -3
- package/lib/block/index.js.map +1 -1
- package/lib/block/initiateValidatorExit.js.map +1 -1
- package/lib/block/isValidIndexedAttestation.js.map +1 -1
- package/lib/block/isValidIndexedPayloadAttestation.js.map +1 -1
- package/lib/block/processAttestationPhase0.js.map +1 -1
- package/lib/block/processAttestations.js.map +1 -1
- package/lib/block/processAttestationsAltair.js.map +1 -1
- package/lib/block/processAttesterSlashing.js.map +1 -1
- package/lib/block/processBlobKzgCommitments.js.map +1 -1
- package/lib/block/processBlockHeader.js.map +1 -1
- package/lib/block/processBlsToExecutionChange.js.map +1 -1
- package/lib/block/processConsolidationRequest.js.map +1 -1
- package/lib/block/processDeposit.js.map +1 -1
- package/lib/block/processDepositRequest.js.map +1 -1
- package/lib/block/processEth1Data.js.map +1 -1
- package/lib/block/processExecutionPayload.js.map +1 -1
- package/lib/block/processExecutionPayloadBid.d.ts +1 -1
- package/lib/block/processExecutionPayloadBid.js.map +1 -1
- package/lib/block/processExecutionPayloadEnvelope.d.ts +5 -2
- package/lib/block/processExecutionPayloadEnvelope.d.ts.map +1 -1
- package/lib/block/processExecutionPayloadEnvelope.js +20 -14
- package/lib/block/processExecutionPayloadEnvelope.js.map +1 -1
- package/lib/block/processOperations.js.map +1 -1
- package/lib/block/processPayloadAttestation.d.ts +1 -1
- package/lib/block/processPayloadAttestation.js.map +1 -1
- package/lib/block/processProposerSlashing.js.map +1 -1
- package/lib/block/processRandao.js.map +1 -1
- package/lib/block/processSyncCommittee.js.map +1 -1
- package/lib/block/processVoluntaryExit.d.ts.map +1 -1
- package/lib/block/processVoluntaryExit.js +51 -48
- package/lib/block/processVoluntaryExit.js.map +1 -1
- package/lib/block/processWithdrawalRequest.js.map +1 -1
- package/lib/block/processWithdrawals.js.map +1 -1
- package/lib/block/slashValidator.js.map +1 -1
- package/lib/block/types.js +2 -1
- package/lib/block/types.js.map +1 -1
- package/lib/cache/effectiveBalanceIncrements.js.map +1 -1
- package/lib/cache/epochCache.d.ts.map +1 -1
- package/lib/cache/epochCache.js +2 -1
- package/lib/cache/epochCache.js.map +1 -1
- package/lib/cache/epochTransitionCache.js.map +1 -1
- package/lib/cache/pubkeyCache.js.map +1 -1
- package/lib/cache/rewardCache.js.map +1 -1
- package/lib/cache/stateCache.js.map +1 -1
- package/lib/cache/syncCommitteeCache.js.map +1 -1
- package/lib/epoch/computeUnrealizedCheckpoints.js.map +1 -1
- package/lib/epoch/getAttestationDeltas.js.map +1 -1
- package/lib/epoch/getRewardsAndPenalties.js.map +1 -1
- package/lib/epoch/index.d.ts +1 -1
- package/lib/epoch/index.js +2 -1
- package/lib/epoch/index.js.map +1 -1
- package/lib/epoch/processBuilderPendingPayments.d.ts +1 -1
- package/lib/epoch/processBuilderPendingPayments.js.map +1 -1
- package/lib/epoch/processEffectiveBalanceUpdates.js.map +1 -1
- package/lib/epoch/processEth1DataReset.js.map +1 -1
- package/lib/epoch/processHistoricalRootsUpdate.js.map +1 -1
- package/lib/epoch/processHistoricalSummariesUpdate.js.map +1 -1
- package/lib/epoch/processInactivityUpdates.js.map +1 -1
- package/lib/epoch/processJustificationAndFinalization.js.map +1 -1
- package/lib/epoch/processParticipationFlagUpdates.js.map +1 -1
- package/lib/epoch/processParticipationRecordUpdates.js.map +1 -1
- package/lib/epoch/processPendingAttestations.js.map +1 -1
- package/lib/epoch/processPendingConsolidations.js.map +1 -1
- package/lib/epoch/processPendingDeposits.js.map +1 -1
- package/lib/epoch/processProposerLookahead.js.map +1 -1
- package/lib/epoch/processRandaoMixesReset.js.map +1 -1
- package/lib/epoch/processRegistryUpdates.js.map +1 -1
- package/lib/epoch/processRewardsAndPenalties.js.map +1 -1
- package/lib/epoch/processSlashings.js.map +1 -1
- package/lib/epoch/processSlashingsReset.js.map +1 -1
- package/lib/epoch/processSyncCommitteeUpdates.js.map +1 -1
- package/lib/lightClient/proofs.js.map +1 -1
- package/lib/metrics.d.ts.map +1 -1
- package/lib/metrics.js.map +1 -1
- package/lib/rewards/attestationsRewards.js.map +1 -1
- package/lib/rewards/blockRewards.js.map +1 -1
- package/lib/rewards/syncCommitteeRewards.js.map +1 -1
- package/lib/signatureSets/attesterSlashings.js.map +1 -1
- package/lib/signatureSets/blsToExecutionChange.js.map +1 -1
- package/lib/signatureSets/executionPayloadBid.js.map +1 -1
- package/lib/signatureSets/executionPayloadEnvelope.js.map +1 -1
- package/lib/signatureSets/index.d.ts +2 -1
- package/lib/signatureSets/index.d.ts.map +1 -1
- package/lib/signatureSets/index.js +3 -2
- package/lib/signatureSets/index.js.map +1 -1
- package/lib/signatureSets/indexedAttestation.js.map +1 -1
- package/lib/signatureSets/indexedPayloadAttestation.js.map +1 -1
- package/lib/signatureSets/proposer.js.map +1 -1
- package/lib/signatureSets/proposerSlashings.js.map +1 -1
- package/lib/signatureSets/randao.js.map +1 -1
- package/lib/signatureSets/voluntaryExits.d.ts +7 -3
- package/lib/signatureSets/voluntaryExits.d.ts.map +1 -1
- package/lib/signatureSets/voluntaryExits.js +30 -9
- package/lib/signatureSets/voluntaryExits.js.map +1 -1
- package/lib/slot/index.js.map +1 -1
- package/lib/slot/upgradeStateToAltair.js.map +1 -1
- package/lib/slot/upgradeStateToBellatrix.js.map +1 -1
- package/lib/slot/upgradeStateToCapella.js.map +1 -1
- package/lib/slot/upgradeStateToDeneb.js.map +1 -1
- package/lib/slot/upgradeStateToElectra.js.map +1 -1
- package/lib/slot/upgradeStateToFulu.js.map +1 -1
- package/lib/slot/upgradeStateToGloas.js.map +1 -1
- package/lib/stateTransition.js +4 -2
- package/lib/stateTransition.js.map +1 -1
- package/lib/stateView/beaconStateView.d.ts +18 -2
- package/lib/stateView/beaconStateView.d.ts.map +1 -1
- package/lib/stateView/beaconStateView.js +60 -3
- package/lib/stateView/beaconStateView.js.map +1 -1
- package/lib/stateView/interface.d.ts +19 -2
- package/lib/stateView/interface.d.ts.map +1 -1
- package/lib/testUtils/cache.d.ts +2 -0
- package/lib/testUtils/cache.d.ts.map +1 -0
- package/lib/testUtils/cache.js +7 -0
- package/lib/testUtils/cache.js.map +1 -0
- package/lib/testUtils/index.d.ts +6 -0
- package/lib/testUtils/index.d.ts.map +1 -0
- package/lib/testUtils/index.js +6 -0
- package/lib/testUtils/index.js.map +1 -0
- package/lib/testUtils/infura.d.ts +3 -0
- package/lib/testUtils/infura.d.ts.map +1 -0
- package/lib/testUtils/infura.js +8 -0
- package/lib/testUtils/infura.js.map +1 -0
- package/lib/testUtils/interop.d.ts +2 -0
- package/lib/testUtils/interop.d.ts.map +1 -0
- package/lib/testUtils/interop.js +24 -0
- package/lib/testUtils/interop.js.map +1 -0
- package/lib/testUtils/params.d.ts +18 -0
- package/lib/testUtils/params.d.ts.map +1 -0
- package/lib/testUtils/params.js +20 -0
- package/lib/testUtils/params.js.map +1 -0
- package/lib/testUtils/state.d.ts +20 -0
- package/lib/testUtils/state.d.ts.map +1 -0
- package/lib/testUtils/state.js +78 -0
- package/lib/testUtils/state.js.map +1 -0
- package/lib/testUtils/testFileCache.d.ts +17 -0
- package/lib/testUtils/testFileCache.d.ts.map +1 -0
- package/lib/testUtils/testFileCache.js +96 -0
- package/lib/testUtils/testFileCache.js.map +1 -0
- package/lib/testUtils/util.d.ts +50 -0
- package/lib/testUtils/util.d.ts.map +1 -0
- package/lib/testUtils/util.js +329 -0
- package/lib/testUtils/util.js.map +1 -0
- package/lib/util/aggregator.js.map +1 -1
- package/lib/util/altair.js.map +1 -1
- package/lib/util/array.js.map +1 -1
- package/lib/util/attestation.js.map +1 -1
- package/lib/util/attesterStatus.js.map +1 -1
- package/lib/util/balance.js.map +1 -1
- package/lib/util/blindedBlock.js.map +1 -1
- package/lib/util/blockRoot.js.map +1 -1
- package/lib/util/capella.js.map +1 -1
- package/lib/util/computeAnchorCheckpoint.js.map +1 -1
- package/lib/util/deposit.js.map +1 -1
- package/lib/util/domain.js.map +1 -1
- package/lib/util/electra.js.map +1 -1
- package/lib/util/epoch.js.map +1 -1
- package/lib/util/epochShuffling.js.map +1 -1
- package/lib/util/execution.js.map +1 -1
- package/lib/util/finality.js.map +1 -1
- package/lib/util/fulu.js.map +1 -1
- package/lib/util/genesis.js.map +1 -1
- package/lib/util/gloas.js.map +1 -1
- package/lib/util/interop.js.map +1 -1
- package/lib/util/loadState/findModifiedInactivityScores.js.map +1 -1
- package/lib/util/loadState/findModifiedValidators.js.map +1 -1
- package/lib/util/loadState/loadState.js.map +1 -1
- package/lib/util/loadState/loadValidator.js.map +1 -1
- package/lib/util/rootCache.d.ts.map +1 -1
- package/lib/util/rootCache.js.map +1 -1
- package/lib/util/seed.d.ts +0 -8
- package/lib/util/seed.d.ts.map +1 -1
- package/lib/util/seed.js +0 -64
- package/lib/util/seed.js.map +1 -1
- package/lib/util/shuffling.js +2 -1
- package/lib/util/shuffling.js.map +1 -1
- package/lib/util/signatureSets.js +2 -1
- package/lib/util/signatureSets.js.map +1 -1
- package/lib/util/signingRoot.js.map +1 -1
- package/lib/util/slot.js.map +1 -1
- package/lib/util/sszBytes.js.map +1 -1
- package/lib/util/syncCommittee.js.map +1 -1
- package/lib/util/targetUnslashedBalance.js.map +1 -1
- package/lib/util/validator.js.map +1 -1
- package/lib/util/weakSubjectivity.js.map +1 -1
- package/package.json +15 -10
- package/src/block/index.ts +3 -3
- package/src/block/isValidIndexedPayloadAttestation.ts +2 -2
- package/src/block/processAttestationsAltair.ts +1 -1
- package/src/block/processExecutionPayloadBid.ts +4 -4
- package/src/block/processExecutionPayloadEnvelope.ts +35 -21
- package/src/block/processOperations.ts +1 -1
- package/src/block/processPayloadAttestation.ts +2 -2
- package/src/block/processVoluntaryExit.ts +77 -54
- package/src/block/processWithdrawals.ts +1 -1
- package/src/epoch/index.ts +1 -1
- package/src/epoch/processBuilderPendingPayments.ts +2 -2
- package/src/signatureSets/index.ts +4 -1
- package/src/signatureSets/voluntaryExits.ts +51 -9
- package/src/stateView/beaconStateView.ts +72 -7
- package/src/stateView/interface.ts +19 -2
- package/src/testUtils/cache.ts +8 -0
- package/src/testUtils/index.ts +5 -0
- package/src/testUtils/infura.ts +10 -0
- package/src/testUtils/interop.ts +29 -0
- package/src/testUtils/params.ts +23 -0
- package/src/testUtils/state.ts +110 -0
- package/src/testUtils/testFileCache.ts +127 -0
- package/src/testUtils/util.ts +429 -0
- package/src/util/seed.ts +0 -71
|
@@ -7,18 +7,25 @@ import {
|
|
|
7
7
|
} from "@lodestar/params";
|
|
8
8
|
import {gloas, ssz} from "@lodestar/types";
|
|
9
9
|
import {byteArrayEquals, toHex, toRootHex} from "@lodestar/utils";
|
|
10
|
-
import {CachedBeaconStateGloas} from "../types.
|
|
11
|
-
import {computeSigningRoot, computeTimeAtSlot} from "../util/index.
|
|
12
|
-
import {processConsolidationRequest} from "./processConsolidationRequest.
|
|
13
|
-
import {processDepositRequest} from "./processDepositRequest.
|
|
14
|
-
import {processWithdrawalRequest} from "./processWithdrawalRequest.
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
import {CachedBeaconStateGloas} from "../types.js";
|
|
11
|
+
import {computeSigningRoot, computeTimeAtSlot} from "../util/index.js";
|
|
12
|
+
import {processConsolidationRequest} from "./processConsolidationRequest.js";
|
|
13
|
+
import {processDepositRequest} from "./processDepositRequest.js";
|
|
14
|
+
import {processWithdrawalRequest} from "./processWithdrawalRequest.js";
|
|
15
|
+
|
|
16
|
+
export type ProcessExecutionPayloadEnvelopeOpts = {
|
|
17
|
+
dontTransferCache?: boolean;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
// Unlike other block processing functions which mutate state in-place, this function
|
|
21
|
+
// clones the state and returns the post-state, similar to stateTransition().
|
|
22
|
+
// This function does not call execution engine to verify payload. Need to call it from other place.
|
|
17
23
|
export function processExecutionPayloadEnvelope(
|
|
18
24
|
state: CachedBeaconStateGloas,
|
|
19
25
|
signedEnvelope: gloas.SignedExecutionPayloadEnvelope,
|
|
20
|
-
verify: boolean
|
|
21
|
-
|
|
26
|
+
verify: boolean,
|
|
27
|
+
opts?: ProcessExecutionPayloadEnvelopeOpts
|
|
28
|
+
): CachedBeaconStateGloas {
|
|
22
29
|
const envelope = signedEnvelope.message;
|
|
23
30
|
const payload = envelope.payload;
|
|
24
31
|
const fork = state.config.getForkSeq(envelope.slot);
|
|
@@ -27,42 +34,49 @@ export function processExecutionPayloadEnvelope(
|
|
|
27
34
|
throw Error(`Execution payload envelope has invalid signature builderIndex=${envelope.builderIndex}`);
|
|
28
35
|
}
|
|
29
36
|
|
|
30
|
-
|
|
37
|
+
// .clone() before mutating state, similar to stateTransition()
|
|
38
|
+
const postState = state.clone(opts?.dontTransferCache) as CachedBeaconStateGloas;
|
|
39
|
+
|
|
40
|
+
validateExecutionPayloadEnvelope(postState, envelope);
|
|
31
41
|
|
|
32
42
|
const requests = envelope.executionRequests;
|
|
33
43
|
|
|
34
44
|
for (const deposit of requests.deposits) {
|
|
35
|
-
processDepositRequest(fork,
|
|
45
|
+
processDepositRequest(fork, postState, deposit);
|
|
36
46
|
}
|
|
37
47
|
|
|
38
48
|
for (const withdrawal of requests.withdrawals) {
|
|
39
|
-
processWithdrawalRequest(fork,
|
|
49
|
+
processWithdrawalRequest(fork, postState, withdrawal);
|
|
40
50
|
}
|
|
41
51
|
|
|
42
52
|
for (const consolidation of requests.consolidations) {
|
|
43
|
-
processConsolidationRequest(
|
|
53
|
+
processConsolidationRequest(postState, consolidation);
|
|
44
54
|
}
|
|
45
55
|
|
|
46
56
|
// Queue the builder payment
|
|
47
|
-
const paymentIndex = SLOTS_PER_EPOCH + (
|
|
48
|
-
const payment =
|
|
57
|
+
const paymentIndex = SLOTS_PER_EPOCH + (postState.slot % SLOTS_PER_EPOCH);
|
|
58
|
+
const payment = postState.builderPendingPayments.get(paymentIndex).clone();
|
|
49
59
|
const amount = payment.withdrawal.amount;
|
|
50
60
|
|
|
51
61
|
if (amount > 0) {
|
|
52
|
-
|
|
62
|
+
postState.builderPendingWithdrawals.push(payment.withdrawal);
|
|
53
63
|
}
|
|
54
64
|
|
|
55
|
-
|
|
65
|
+
postState.builderPendingPayments.set(paymentIndex, ssz.gloas.BuilderPendingPayment.defaultViewDU());
|
|
56
66
|
|
|
57
67
|
// Cache the execution payload hash
|
|
58
|
-
|
|
59
|
-
|
|
68
|
+
postState.executionPayloadAvailability.set(postState.slot % SLOTS_PER_HISTORICAL_ROOT, true);
|
|
69
|
+
postState.latestBlockHash = payload.blockHash;
|
|
60
70
|
|
|
61
|
-
|
|
71
|
+
postState.commit();
|
|
72
|
+
|
|
73
|
+
if (verify && !byteArrayEquals(envelope.stateRoot, postState.hashTreeRoot())) {
|
|
62
74
|
throw new Error(
|
|
63
|
-
`Envelope's state root does not match state envelope=${toRootHex(envelope.stateRoot)} state=${toRootHex(
|
|
75
|
+
`Envelope's state root does not match state envelope=${toRootHex(envelope.stateRoot)} state=${toRootHex(postState.hashTreeRoot())}`
|
|
64
76
|
);
|
|
65
77
|
}
|
|
78
|
+
|
|
79
|
+
return postState;
|
|
66
80
|
}
|
|
67
81
|
|
|
68
82
|
function validateExecutionPayloadEnvelope(
|
|
@@ -14,7 +14,7 @@ import {processBlsToExecutionChange} from "./processBlsToExecutionChange.js";
|
|
|
14
14
|
import {processConsolidationRequest} from "./processConsolidationRequest.js";
|
|
15
15
|
import {processDeposit} from "./processDeposit.js";
|
|
16
16
|
import {processDepositRequest} from "./processDepositRequest.js";
|
|
17
|
-
import {processPayloadAttestation} from "./processPayloadAttestation.
|
|
17
|
+
import {processPayloadAttestation} from "./processPayloadAttestation.js";
|
|
18
18
|
import {processProposerSlashing} from "./processProposerSlashing.js";
|
|
19
19
|
import {processVoluntaryExit} from "./processVoluntaryExit.js";
|
|
20
20
|
import {processWithdrawalRequest} from "./processWithdrawalRequest.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {gloas} from "@lodestar/types";
|
|
2
2
|
import {byteArrayEquals} from "@lodestar/utils";
|
|
3
|
-
import {CachedBeaconStateGloas} from "../types.
|
|
4
|
-
import {isValidIndexedPayloadAttestation} from "./isValidIndexedPayloadAttestation.
|
|
3
|
+
import {CachedBeaconStateGloas} from "../types.js";
|
|
4
|
+
import {isValidIndexedPayloadAttestation} from "./isValidIndexedPayloadAttestation.js";
|
|
5
5
|
|
|
6
6
|
export function processPayloadAttestation(
|
|
7
7
|
state: CachedBeaconStateGloas,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {PublicKey, Signature, verify} from "@chainsafe/blst";
|
|
2
1
|
import {FAR_FUTURE_EPOCH, ForkSeq} from "@lodestar/params";
|
|
3
|
-
import {phase0
|
|
2
|
+
import {phase0} from "@lodestar/types";
|
|
4
3
|
import {verifyVoluntaryExitSignature} from "../signatureSets/index.js";
|
|
4
|
+
import {BeaconStateView} from "../stateView/beaconStateView.js";
|
|
5
5
|
import {CachedBeaconStateAllForks, CachedBeaconStateElectra, CachedBeaconStateGloas} from "../types.js";
|
|
6
6
|
import {
|
|
7
7
|
convertValidatorIndexToBuilderIndex,
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
isActiveBuilder,
|
|
11
11
|
isBuilderIndex,
|
|
12
12
|
} from "../util/gloas.js";
|
|
13
|
-
import {
|
|
13
|
+
import {getPendingBalanceToWithdraw, isActiveValidator} from "../util/index.js";
|
|
14
14
|
import {initiateValidatorExit} from "./index.js";
|
|
15
15
|
|
|
16
16
|
export enum VoluntaryExitValidity {
|
|
@@ -35,57 +35,20 @@ export function processVoluntaryExit(
|
|
|
35
35
|
verifySignature = true
|
|
36
36
|
): void {
|
|
37
37
|
const voluntaryExit = signedVoluntaryExit.message;
|
|
38
|
-
const currentEpoch = getCurrentEpoch(state);
|
|
39
38
|
|
|
40
|
-
|
|
41
|
-
if (
|
|
42
|
-
throw Error(`
|
|
39
|
+
const validity = getVoluntaryExitValidity(fork, state, signedVoluntaryExit, verifySignature);
|
|
40
|
+
if (validity !== VoluntaryExitValidity.valid) {
|
|
41
|
+
throw Error(`Invalid voluntary exit at forkSeq=${fork} reason=${validity}`);
|
|
43
42
|
}
|
|
44
43
|
|
|
45
|
-
// Check if this is a builder exit
|
|
46
44
|
if (fork >= ForkSeq.gloas && isBuilderIndex(voluntaryExit.validatorIndex)) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
// Verify the builder is active
|
|
52
|
-
if (!isActiveBuilder(builder, state.finalizedCheckpoint.epoch)) {
|
|
53
|
-
throw Error(`Builder ${builderIndex} is not active`);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// Only exit builder if it has no pending withdrawals in the queue
|
|
57
|
-
if (getPendingBalanceToWithdrawForBuilder(stateGloas, builderIndex) !== 0) {
|
|
58
|
-
throw Error(`Builder ${builderIndex} has pending withdrawals`);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// Verify signature
|
|
62
|
-
if (verifySignature) {
|
|
63
|
-
const domain = state.config.getDomainForVoluntaryExit(state.slot);
|
|
64
|
-
const signingRoot = computeSigningRoot(ssz.phase0.VoluntaryExit, voluntaryExit, domain);
|
|
65
|
-
|
|
66
|
-
try {
|
|
67
|
-
const publicKey = PublicKey.fromBytes(builder.pubkey);
|
|
68
|
-
const signature = Signature.fromBytes(signedVoluntaryExit.signature, true);
|
|
69
|
-
|
|
70
|
-
if (!verify(signingRoot, publicKey, signature)) {
|
|
71
|
-
throw Error("BLS verify failed");
|
|
72
|
-
}
|
|
73
|
-
} catch (e) {
|
|
74
|
-
throw Error(`Builder ${builderIndex} invalid exit signature reason=${(e as Error).message}`);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// Initiate builder exit
|
|
79
|
-
initiateBuilderExit(stateGloas, builderIndex);
|
|
45
|
+
initiateBuilderExit(
|
|
46
|
+
state as CachedBeaconStateGloas,
|
|
47
|
+
convertValidatorIndexToBuilderIndex(voluntaryExit.validatorIndex)
|
|
48
|
+
);
|
|
80
49
|
return;
|
|
81
50
|
}
|
|
82
51
|
|
|
83
|
-
// Handle validator exit
|
|
84
|
-
const validity = getVoluntaryExitValidity(fork, state, signedVoluntaryExit, verifySignature);
|
|
85
|
-
if (validity !== VoluntaryExitValidity.valid) {
|
|
86
|
-
throw Error(`Invalid voluntary exit at forkSeq=${fork} reason=${validity}`);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
52
|
const validator = state.validators.get(signedVoluntaryExit.message.validatorIndex);
|
|
90
53
|
initiateValidatorExit(fork, state, validator);
|
|
91
54
|
}
|
|
@@ -95,10 +58,74 @@ export function getVoluntaryExitValidity(
|
|
|
95
58
|
state: CachedBeaconStateAllForks,
|
|
96
59
|
signedVoluntaryExit: phase0.SignedVoluntaryExit,
|
|
97
60
|
verifySignature = true
|
|
61
|
+
): VoluntaryExitValidity {
|
|
62
|
+
const currentEpoch = state.epochCtx.epoch;
|
|
63
|
+
const voluntaryExit = signedVoluntaryExit.message;
|
|
64
|
+
|
|
65
|
+
// Exits must specify an epoch when they become valid; they are not valid before then
|
|
66
|
+
if (currentEpoch < voluntaryExit.epoch) {
|
|
67
|
+
return VoluntaryExitValidity.earlyEpoch;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Check if this is a builder exit
|
|
71
|
+
if (fork >= ForkSeq.gloas && isBuilderIndex(voluntaryExit.validatorIndex)) {
|
|
72
|
+
return getBuilderVoluntaryExitValidity(state as CachedBeaconStateGloas, signedVoluntaryExit, verifySignature);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return getValidatorVoluntaryExitValidity(fork, state, signedVoluntaryExit, verifySignature);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function getBuilderVoluntaryExitValidity(
|
|
79
|
+
state: CachedBeaconStateGloas,
|
|
80
|
+
signedVoluntaryExit: phase0.SignedVoluntaryExit,
|
|
81
|
+
verifySignature: boolean
|
|
82
|
+
): VoluntaryExitValidity {
|
|
83
|
+
const {config, epochCtx} = state;
|
|
84
|
+
const builderIndex = convertValidatorIndexToBuilderIndex(signedVoluntaryExit.message.validatorIndex);
|
|
85
|
+
|
|
86
|
+
if (builderIndex >= state.builders.length) {
|
|
87
|
+
return VoluntaryExitValidity.inactive;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const builder = state.builders.getReadonly(builderIndex);
|
|
91
|
+
|
|
92
|
+
// Verify the builder is active
|
|
93
|
+
if (!isActiveBuilder(builder, state.finalizedCheckpoint.epoch)) {
|
|
94
|
+
return builder.withdrawableEpoch !== FAR_FUTURE_EPOCH
|
|
95
|
+
? VoluntaryExitValidity.alreadyExited
|
|
96
|
+
: VoluntaryExitValidity.inactive;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// Only exit builder if it has no pending withdrawals in the queue
|
|
100
|
+
if (getPendingBalanceToWithdrawForBuilder(state, builderIndex) !== 0) {
|
|
101
|
+
return VoluntaryExitValidity.pendingWithdrawals;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Verify signature
|
|
105
|
+
if (
|
|
106
|
+
verifySignature &&
|
|
107
|
+
!verifyVoluntaryExitSignature(config, epochCtx.pubkeyCache, new BeaconStateView(state), signedVoluntaryExit)
|
|
108
|
+
) {
|
|
109
|
+
return VoluntaryExitValidity.invalidSignature;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return VoluntaryExitValidity.valid;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function getValidatorVoluntaryExitValidity(
|
|
116
|
+
fork: ForkSeq,
|
|
117
|
+
state: CachedBeaconStateAllForks,
|
|
118
|
+
signedVoluntaryExit: phase0.SignedVoluntaryExit,
|
|
119
|
+
verifySignature: boolean
|
|
98
120
|
): VoluntaryExitValidity {
|
|
99
121
|
const {config, epochCtx} = state;
|
|
100
122
|
const voluntaryExit = signedVoluntaryExit.message;
|
|
101
|
-
|
|
123
|
+
|
|
124
|
+
if (voluntaryExit.validatorIndex >= state.validators.length) {
|
|
125
|
+
return VoluntaryExitValidity.inactive;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const validator = state.validators.getReadonly(voluntaryExit.validatorIndex);
|
|
102
129
|
const currentEpoch = epochCtx.epoch;
|
|
103
130
|
|
|
104
131
|
// verify the validator is active
|
|
@@ -111,11 +138,6 @@ export function getVoluntaryExitValidity(
|
|
|
111
138
|
return VoluntaryExitValidity.alreadyExited;
|
|
112
139
|
}
|
|
113
140
|
|
|
114
|
-
// exits must specify an epoch when they become valid; they are not valid before then
|
|
115
|
-
if (currentEpoch < voluntaryExit.epoch) {
|
|
116
|
-
return VoluntaryExitValidity.earlyEpoch;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
141
|
// verify the validator had been active long enough
|
|
120
142
|
if (currentEpoch < validator.activationEpoch + config.SHARD_COMMITTEE_PERIOD) {
|
|
121
143
|
return VoluntaryExitValidity.shortTimeActive;
|
|
@@ -129,9 +151,10 @@ export function getVoluntaryExitValidity(
|
|
|
129
151
|
return VoluntaryExitValidity.pendingWithdrawals;
|
|
130
152
|
}
|
|
131
153
|
|
|
154
|
+
// Verify signature
|
|
132
155
|
if (
|
|
133
156
|
verifySignature &&
|
|
134
|
-
!verifyVoluntaryExitSignature(
|
|
157
|
+
!verifyVoluntaryExitSignature(config, epochCtx.pubkeyCache, new BeaconStateView(state), signedVoluntaryExit)
|
|
135
158
|
) {
|
|
136
159
|
return VoluntaryExitValidity.invalidSignature;
|
|
137
160
|
}
|
package/src/epoch/index.ts
CHANGED
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
CachedBeaconStatePhase0,
|
|
17
17
|
EpochTransitionCache,
|
|
18
18
|
} from "../types.js";
|
|
19
|
-
import {processBuilderPendingPayments} from "./processBuilderPendingPayments.
|
|
19
|
+
import {processBuilderPendingPayments} from "./processBuilderPendingPayments.js";
|
|
20
20
|
import {processEffectiveBalanceUpdates} from "./processEffectiveBalanceUpdates.js";
|
|
21
21
|
import {processEth1DataReset} from "./processEth1DataReset.js";
|
|
22
22
|
import {processHistoricalRootsUpdate} from "./processHistoricalRootsUpdate.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {SLOTS_PER_EPOCH} from "@lodestar/params";
|
|
2
2
|
import {ssz} from "@lodestar/types";
|
|
3
|
-
import {CachedBeaconStateGloas} from "../types.
|
|
4
|
-
import {getBuilderPaymentQuorumThreshold} from "../util/gloas.
|
|
3
|
+
import {CachedBeaconStateGloas} from "../types.js";
|
|
4
|
+
import {getBuilderPaymentQuorumThreshold} from "../util/gloas.js";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Processes the builder pending payments from the previous epoch.
|
|
@@ -3,6 +3,8 @@ import {ForkSeq} from "@lodestar/params";
|
|
|
3
3
|
import {IndexedAttestation, SignedBeaconBlock, altair, capella} from "@lodestar/types";
|
|
4
4
|
import {getSyncCommitteeSignatureSet} from "../block/processSyncCommittee.js";
|
|
5
5
|
import {SyncCommitteeCache} from "../cache/syncCommitteeCache.js";
|
|
6
|
+
import {BeaconStateView} from "../stateView/beaconStateView.js";
|
|
7
|
+
import {CachedBeaconStateAllForks} from "../types.js";
|
|
6
8
|
import {ISignatureSet} from "../util/index.js";
|
|
7
9
|
import {getAttesterSlashingsSignatureSets} from "./attesterSlashings.js";
|
|
8
10
|
import {getBlsToExecutionChangeSignatureSets} from "./blsToExecutionChange.js";
|
|
@@ -30,6 +32,7 @@ export * from "./voluntaryExits.js";
|
|
|
30
32
|
export function getBlockSignatureSets(
|
|
31
33
|
config: BeaconConfig,
|
|
32
34
|
currentSyncCommitteeIndexed: SyncCommitteeCache,
|
|
35
|
+
state: CachedBeaconStateAllForks,
|
|
33
36
|
signedBlock: SignedBeaconBlock,
|
|
34
37
|
indexedAttestations: IndexedAttestation[],
|
|
35
38
|
opts?: {
|
|
@@ -45,7 +48,7 @@ export function getBlockSignatureSets(
|
|
|
45
48
|
...getProposerSlashingsSignatureSets(config, signedBlock),
|
|
46
49
|
...getAttesterSlashingsSignatureSets(config, signedBlock),
|
|
47
50
|
...getAttestationsSignatureSets(config, signedBlock, indexedAttestations),
|
|
48
|
-
...getVoluntaryExitsSignatureSets(config, signedBlock),
|
|
51
|
+
...getVoluntaryExitsSignatureSets(config, new BeaconStateView(state), signedBlock),
|
|
49
52
|
];
|
|
50
53
|
|
|
51
54
|
if (!opts?.skipProposerSignature) {
|
|
@@ -1,27 +1,56 @@
|
|
|
1
|
+
import {PublicKey} from "@chainsafe/blst";
|
|
1
2
|
import {BeaconConfig} from "@lodestar/config";
|
|
3
|
+
import {ForkSeq} from "@lodestar/params";
|
|
2
4
|
import {SignedBeaconBlock, Slot, phase0, ssz} from "@lodestar/types";
|
|
3
5
|
import {PubkeyCache} from "../cache/pubkeyCache.js";
|
|
6
|
+
import {IBeaconStateView} from "../stateView/interface.js";
|
|
4
7
|
import {
|
|
5
8
|
ISignatureSet,
|
|
6
9
|
SignatureSetType,
|
|
7
10
|
computeSigningRoot,
|
|
8
11
|
computeStartSlotAtEpoch,
|
|
12
|
+
convertValidatorIndexToBuilderIndex,
|
|
13
|
+
isBuilderIndex,
|
|
9
14
|
verifySignatureSet,
|
|
10
15
|
} from "../util/index.js";
|
|
11
16
|
|
|
12
17
|
export function verifyVoluntaryExitSignature(
|
|
13
18
|
config: BeaconConfig,
|
|
14
19
|
pubkeyCache: PubkeyCache,
|
|
15
|
-
|
|
20
|
+
state: IBeaconStateView,
|
|
16
21
|
signedVoluntaryExit: phase0.SignedVoluntaryExit
|
|
17
22
|
): boolean {
|
|
18
|
-
return verifySignatureSet(getVoluntaryExitSignatureSet(config,
|
|
23
|
+
return verifySignatureSet(getVoluntaryExitSignatureSet(config, state, signedVoluntaryExit), pubkeyCache);
|
|
19
24
|
}
|
|
20
25
|
|
|
21
26
|
/**
|
|
22
27
|
* Extract signatures to allow validating all block signatures at once
|
|
23
28
|
*/
|
|
24
29
|
export function getVoluntaryExitSignatureSet(
|
|
30
|
+
config: BeaconConfig,
|
|
31
|
+
state: IBeaconStateView,
|
|
32
|
+
signedVoluntaryExit: phase0.SignedVoluntaryExit
|
|
33
|
+
): ISignatureSet {
|
|
34
|
+
const fork = config.getForkSeq(state.slot);
|
|
35
|
+
|
|
36
|
+
if (fork >= ForkSeq.gloas && isBuilderVoluntaryExit(signedVoluntaryExit)) {
|
|
37
|
+
return getBuilderVoluntaryExitSignatureSet(config, state, signedVoluntaryExit);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return getValidatorVoluntaryExitSignatureSet(config, state.slot, signedVoluntaryExit);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function getVoluntaryExitsSignatureSets(
|
|
44
|
+
config: BeaconConfig,
|
|
45
|
+
state: IBeaconStateView,
|
|
46
|
+
signedBlock: SignedBeaconBlock
|
|
47
|
+
): ISignatureSet[] {
|
|
48
|
+
return signedBlock.message.body.voluntaryExits.map((voluntaryExit) =>
|
|
49
|
+
getVoluntaryExitSignatureSet(config, state, voluntaryExit)
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function getValidatorVoluntaryExitSignatureSet(
|
|
25
54
|
config: BeaconConfig,
|
|
26
55
|
stateSlot: Slot,
|
|
27
56
|
signedVoluntaryExit: phase0.SignedVoluntaryExit
|
|
@@ -37,11 +66,24 @@ export function getVoluntaryExitSignatureSet(
|
|
|
37
66
|
};
|
|
38
67
|
}
|
|
39
68
|
|
|
40
|
-
export function
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
);
|
|
69
|
+
export function getBuilderVoluntaryExitSignatureSet(
|
|
70
|
+
config: BeaconConfig,
|
|
71
|
+
state: IBeaconStateView,
|
|
72
|
+
signedVoluntaryExit: phase0.SignedVoluntaryExit
|
|
73
|
+
): ISignatureSet {
|
|
74
|
+
const messageSlot = computeStartSlotAtEpoch(signedVoluntaryExit.message.epoch);
|
|
75
|
+
const domain = config.getDomainForVoluntaryExit(state.slot, messageSlot);
|
|
76
|
+
const builderIndex = convertValidatorIndexToBuilderIndex(signedVoluntaryExit.message.validatorIndex);
|
|
77
|
+
const builder = state.getBuilder(builderIndex);
|
|
78
|
+
|
|
79
|
+
return {
|
|
80
|
+
type: SignatureSetType.single,
|
|
81
|
+
pubkey: PublicKey.fromBytes(builder.pubkey),
|
|
82
|
+
signingRoot: computeSigningRoot(ssz.phase0.VoluntaryExit, signedVoluntaryExit.message, domain),
|
|
83
|
+
signature: signedVoluntaryExit.signature,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export function isBuilderVoluntaryExit(signedVoluntaryExit: phase0.SignedVoluntaryExit): boolean {
|
|
88
|
+
return isBuilderIndex(signedVoluntaryExit.message.validatorIndex);
|
|
47
89
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {CompactMultiProof, ProofType, Tree, createProof} from "@chainsafe/persistent-merkle-tree";
|
|
2
2
|
import {ByteViews} from "@chainsafe/ssz";
|
|
3
3
|
import {BeaconConfig} from "@lodestar/config";
|
|
4
|
-
import {ForkSeq, SLOTS_PER_HISTORICAL_ROOT} from "@lodestar/params";
|
|
4
|
+
import {ForkSeq, SLOTS_PER_HISTORICAL_ROOT, isForkPostGloas} from "@lodestar/params";
|
|
5
5
|
import {
|
|
6
6
|
BeaconBlock,
|
|
7
7
|
BlindedBeaconBlock,
|
|
@@ -27,6 +27,7 @@ import {
|
|
|
27
27
|
rewards,
|
|
28
28
|
} from "@lodestar/types";
|
|
29
29
|
import {Checkpoint, Fork} from "@lodestar/types/phase0";
|
|
30
|
+
import {processExecutionPayloadEnvelope} from "../block/index.js";
|
|
30
31
|
import {VoluntaryExitValidity, getVoluntaryExitValidity} from "../block/processVoluntaryExit.js";
|
|
31
32
|
import {getExpectedWithdrawals} from "../block/processWithdrawals.js";
|
|
32
33
|
import {EffectiveBalanceIncrements} from "../cache/effectiveBalanceIncrements.js";
|
|
@@ -75,10 +76,12 @@ export class BeaconStateView implements IBeaconStateView {
|
|
|
75
76
|
// altair
|
|
76
77
|
private _currentSyncCommittee: SyncCommittee | null = null;
|
|
77
78
|
private _nextSyncCommittee: SyncCommittee | null = null;
|
|
78
|
-
private _previousEpochParticipation:
|
|
79
|
-
private _currentEpochParticipation:
|
|
79
|
+
private _previousEpochParticipation: Uint8Array | null = null;
|
|
80
|
+
private _currentEpochParticipation: Uint8Array | null = null;
|
|
80
81
|
// bellatrix
|
|
81
82
|
private _latestExecutionPayloadHeader: ExecutionPayloadHeader | null = null;
|
|
83
|
+
// Caches the cross-fork latestBlockHash value
|
|
84
|
+
private _latestBlockHash: Bytes32 | null = null;
|
|
82
85
|
// capella
|
|
83
86
|
private _historicalSummaries: capella.HistoricalSummaries | null = null;
|
|
84
87
|
// electra
|
|
@@ -159,7 +162,7 @@ export class BeaconStateView implements IBeaconStateView {
|
|
|
159
162
|
return getRandaoMix(this.cachedState, epoch);
|
|
160
163
|
}
|
|
161
164
|
|
|
162
|
-
get previousEpochParticipation():
|
|
165
|
+
get previousEpochParticipation(): Uint8Array {
|
|
163
166
|
if (this.config.getForkSeq(this.cachedState.slot) < ForkSeq.altair) {
|
|
164
167
|
throw new Error("previousEpochParticipation is not available before Altair");
|
|
165
168
|
}
|
|
@@ -167,7 +170,7 @@ export class BeaconStateView implements IBeaconStateView {
|
|
|
167
170
|
if (this._previousEpochParticipation === null) {
|
|
168
171
|
this._previousEpochParticipation = (
|
|
169
172
|
this.cachedState as CachedBeaconStateAltair
|
|
170
|
-
).previousEpochParticipation.
|
|
173
|
+
).previousEpochParticipation.serialize();
|
|
171
174
|
}
|
|
172
175
|
|
|
173
176
|
return this._previousEpochParticipation;
|
|
@@ -175,7 +178,7 @@ export class BeaconStateView implements IBeaconStateView {
|
|
|
175
178
|
|
|
176
179
|
// altair
|
|
177
180
|
|
|
178
|
-
get currentEpochParticipation():
|
|
181
|
+
get currentEpochParticipation(): Uint8Array {
|
|
179
182
|
if (this.config.getForkSeq(this.cachedState.slot) < ForkSeq.altair) {
|
|
180
183
|
throw new Error("currentEpochParticipation is not available before Altair");
|
|
181
184
|
}
|
|
@@ -183,12 +186,26 @@ export class BeaconStateView implements IBeaconStateView {
|
|
|
183
186
|
if (this._currentEpochParticipation === null) {
|
|
184
187
|
this._currentEpochParticipation = (
|
|
185
188
|
this.cachedState as CachedBeaconStateAltair
|
|
186
|
-
).currentEpochParticipation.
|
|
189
|
+
).currentEpochParticipation.serialize();
|
|
187
190
|
}
|
|
188
191
|
|
|
189
192
|
return this._currentEpochParticipation;
|
|
190
193
|
}
|
|
191
194
|
|
|
195
|
+
getPreviousEpochParticipation(validatorIndex: ValidatorIndex): number {
|
|
196
|
+
if (this.config.getForkSeq(this.cachedState.slot) < ForkSeq.altair) {
|
|
197
|
+
throw new Error("previousEpochParticipation is not available before Altair");
|
|
198
|
+
}
|
|
199
|
+
return (this.cachedState as CachedBeaconStateAltair).previousEpochParticipation.get(validatorIndex);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
getCurrentEpochParticipation(validatorIndex: ValidatorIndex): number {
|
|
203
|
+
if (this.config.getForkSeq(this.cachedState.slot) < ForkSeq.altair) {
|
|
204
|
+
throw new Error("currentEpochParticipation is not available before Altair");
|
|
205
|
+
}
|
|
206
|
+
return (this.cachedState as CachedBeaconStateAltair).currentEpochParticipation.get(validatorIndex);
|
|
207
|
+
}
|
|
208
|
+
|
|
192
209
|
// bellatrix
|
|
193
210
|
|
|
194
211
|
get latestExecutionPayloadHeader(): ExecutionPayloadHeader {
|
|
@@ -205,6 +222,46 @@ export class BeaconStateView implements IBeaconStateView {
|
|
|
205
222
|
return this._latestExecutionPayloadHeader;
|
|
206
223
|
}
|
|
207
224
|
|
|
225
|
+
/**
|
|
226
|
+
* Cross-fork accessor for the execution block hash of the most recently included payload.
|
|
227
|
+
* Pre-gloas: reads from latestExecutionPayloadHeader.blockHash.
|
|
228
|
+
* Gloas+: reads the dedicated latestBlockHash field (EIP-7732).
|
|
229
|
+
*/
|
|
230
|
+
get latestBlockHash(): Bytes32 {
|
|
231
|
+
const forkSeq = this.config.getForkSeq(this.cachedState.slot);
|
|
232
|
+
if (forkSeq < ForkSeq.bellatrix) {
|
|
233
|
+
throw new Error("latestBlockHash is not available before Bellatrix");
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
if (this._latestBlockHash === null) {
|
|
237
|
+
if (forkSeq >= ForkSeq.gloas) {
|
|
238
|
+
this._latestBlockHash = (this.cachedState as CachedBeaconStateGloas).latestBlockHash;
|
|
239
|
+
} else {
|
|
240
|
+
this._latestBlockHash = (
|
|
241
|
+
this.cachedState as CachedBeaconStateExecutions
|
|
242
|
+
).latestExecutionPayloadHeader.blockHash;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
return this._latestBlockHash;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* The execution block number of the most recently included payload.
|
|
251
|
+
* Named payloadBlockNumber (not latestBlockNumber) to mirror ExecutionPayloadHeader.blockNumber pre-gloas.
|
|
252
|
+
* Only available from bellatrix through fulu — not tracked on BeaconState in gloas+ (EIP-7732).
|
|
253
|
+
*/
|
|
254
|
+
get payloadBlockNumber(): number {
|
|
255
|
+
const forkSeq = this.config.getForkSeq(this.cachedState.slot);
|
|
256
|
+
if (forkSeq < ForkSeq.bellatrix) {
|
|
257
|
+
throw new Error("payloadBlockNumber is not available before Bellatrix");
|
|
258
|
+
}
|
|
259
|
+
if (forkSeq >= ForkSeq.gloas) {
|
|
260
|
+
throw new Error("payloadBlockNumber is not available post-gloas");
|
|
261
|
+
}
|
|
262
|
+
return (this.cachedState as CachedBeaconStateExecutions).latestExecutionPayloadHeader.blockNumber;
|
|
263
|
+
}
|
|
264
|
+
|
|
208
265
|
// capella
|
|
209
266
|
|
|
210
267
|
get historicalSummaries(): capella.HistoricalSummaries {
|
|
@@ -703,6 +760,14 @@ export class BeaconStateView implements IBeaconStateView {
|
|
|
703
760
|
const newState = processSlots(this.cachedState, slot, epochTransitionCacheOpts, modules);
|
|
704
761
|
return new BeaconStateView(newState);
|
|
705
762
|
}
|
|
763
|
+
|
|
764
|
+
processExecutionPayloadEnvelope(signedEnvelope: gloas.SignedExecutionPayloadEnvelope, verify: boolean): void {
|
|
765
|
+
const fork = this.config.getForkName(this.cachedState.slot);
|
|
766
|
+
if (!isForkPostGloas(fork)) {
|
|
767
|
+
throw Error(`processExecutionPayloadEnvelope is only available for gloas+ forks, got fork=${fork}`);
|
|
768
|
+
}
|
|
769
|
+
processExecutionPayloadEnvelope(this.cachedState as CachedBeaconStateGloas, signedEnvelope, verify);
|
|
770
|
+
}
|
|
706
771
|
}
|
|
707
772
|
|
|
708
773
|
/**
|
|
@@ -55,11 +55,27 @@ export interface IBeaconStateView {
|
|
|
55
55
|
getRandaoMix(epoch: Epoch): Bytes32;
|
|
56
56
|
|
|
57
57
|
// altair
|
|
58
|
-
previousEpochParticipation:
|
|
59
|
-
currentEpochParticipation:
|
|
58
|
+
previousEpochParticipation: Uint8Array;
|
|
59
|
+
currentEpochParticipation: Uint8Array;
|
|
60
|
+
getPreviousEpochParticipation(validatorIndex: ValidatorIndex): number;
|
|
61
|
+
getCurrentEpochParticipation(validatorIndex: ValidatorIndex): number;
|
|
60
62
|
|
|
61
63
|
// bellatrix
|
|
62
64
|
latestExecutionPayloadHeader: ExecutionPayloadHeader;
|
|
65
|
+
/**
|
|
66
|
+
* Cross-fork accessor for the execution block hash of the most recently included payload.
|
|
67
|
+
* Pre-gloas: returns latestExecutionPayloadHeader.blockHash (bellatrix–fulu).
|
|
68
|
+
* Gloas+: returns the dedicated latestBlockHash state field (EIP-7732).
|
|
69
|
+
* Throws before bellatrix.
|
|
70
|
+
*/
|
|
71
|
+
latestBlockHash: Bytes32;
|
|
72
|
+
/**
|
|
73
|
+
* The execution block number of the most recently included payload.
|
|
74
|
+
* Named payloadBlockNumber (not latestBlockNumber) to mirror ExecutionPayloadHeader.blockNumber pre-gloas.
|
|
75
|
+
* Only available from bellatrix through fulu — not tracked on BeaconState in gloas+ (EIP-7732).
|
|
76
|
+
* Throws before bellatrix and from gloas onwards.
|
|
77
|
+
*/
|
|
78
|
+
payloadBlockNumber: number;
|
|
63
79
|
|
|
64
80
|
// capella
|
|
65
81
|
historicalSummaries: capella.HistoricalSummaries;
|
|
@@ -193,4 +209,5 @@ export interface IBeaconStateView {
|
|
|
193
209
|
epochTransitionCacheOpts?: EpochTransitionCacheOpts & {dontTransferCache?: boolean},
|
|
194
210
|
modules?: StateTransitionModules
|
|
195
211
|
): IBeaconStateView;
|
|
212
|
+
processExecutionPayloadEnvelope(signedEnvelope: gloas.SignedExecutionPayloadEnvelope, verify: boolean): void;
|
|
196
213
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import {fileURLToPath} from "node:url";
|
|
3
|
+
|
|
4
|
+
// Global variable __dirname no longer available in ES6 modules.
|
|
5
|
+
// Solutions: https://stackoverflow.com/questions/46745014/alternative-for-dirname-in-node-js-when-using-es6-modules
|
|
6
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
7
|
+
|
|
8
|
+
export const testCachePath = path.join(__dirname, "../../test/test-cache");
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import {NetworkName} from "@lodestar/config/networks";
|
|
2
|
+
|
|
3
|
+
export function getInfuraBeaconUrl(network: NetworkName): string {
|
|
4
|
+
const INFURA_ETH2_CREDENTIALS = process.env.INFURA_ETH2_CREDENTIALS;
|
|
5
|
+
if (!INFURA_ETH2_CREDENTIALS) {
|
|
6
|
+
throw Error("Must set ENV INFURA_ETH2_CREDENTIALS");
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
return `https://${INFURA_ETH2_CREDENTIALS}@eth2-beacon-${network}.infura.io`;
|
|
10
|
+
}
|