From eaa95fdd8f8a3b9e0b8dc22ed31cdbfb74cc4bf6 Mon Sep 17 00:00:00 2001 From: NC <17676176+ensi321@users.noreply.github.com> Date: Fri, 27 Sep 2024 11:51:44 -0700 Subject: [PATCH 1/8] initial commit --- .../spec/presets/epoch_processing.test.ts | 2 +- packages/params/src/index.ts | 3 ++- packages/params/src/presets/mainnet.ts | 3 ++- packages/params/src/presets/minimal.ts | 3 ++- packages/params/src/types.ts | 6 +++-- .../src/block/processDeposit.ts | 8 +++--- packages/state-transition/src/epoch/index.ts | 10 +++---- .../epoch/processEffectiveBalanceUpdates.ts | 2 +- ...eDeposits.ts => processPendingDeposits.ts} | 16 ++++++------ .../src/slot/upgradeStateToElectra.ts | 4 +-- packages/state-transition/src/util/electra.ts | 26 ++++++++++++------- packages/state-transition/src/util/genesis.ts | 4 +-- .../test/perf/analyzeEpochs.ts | 2 +- packages/types/src/electra/sszTypes.ts | 19 +++++++++----- packages/types/src/electra/types.ts | 2 +- packages/validator/src/util/params.ts | 3 ++- .../test/unit/utils/interopConfigs.ts | 8 +++--- 17 files changed, 70 insertions(+), 51 deletions(-) rename packages/state-transition/src/epoch/{processPendingBalanceDeposits.ts => processPendingDeposits.ts} (81%) diff --git a/packages/beacon-node/test/spec/presets/epoch_processing.test.ts b/packages/beacon-node/test/spec/presets/epoch_processing.test.ts index 604243400aa0..2307511f5f3e 100644 --- a/packages/beacon-node/test/spec/presets/epoch_processing.test.ts +++ b/packages/beacon-node/test/spec/presets/epoch_processing.test.ts @@ -46,7 +46,7 @@ const epochTransitionFns: Record = { epochFns.processSyncCommitteeUpdates(fork, state as CachedBeaconStateAltair); }, historical_summaries_update: epochFns.processHistoricalSummariesUpdate as EpochTransitionFn, - pending_balance_deposits: epochFns.processPendingBalanceDeposits as EpochTransitionFn, + pending_balance_deposits: epochFns.processPendingDeposits as EpochTransitionFn, pending_consolidations: epochFns.processPendingConsolidations as EpochTransitionFn, }; diff --git a/packages/params/src/index.ts b/packages/params/src/index.ts index aa6e97641526..544113e3f8e1 100644 --- a/packages/params/src/index.ts +++ b/packages/params/src/index.ts @@ -96,7 +96,7 @@ export const { MAX_EFFECTIVE_BALANCE_ELECTRA, MIN_ACTIVATION_BALANCE, - PENDING_BALANCE_DEPOSITS_LIMIT, + PENDING_DEPOSITS_LIMIT, PENDING_PARTIAL_WITHDRAWALS_LIMIT, PENDING_CONSOLIDATIONS_LIMIT, MIN_SLASHING_PENALTY_QUOTIENT_ELECTRA, @@ -107,6 +107,7 @@ export const { MAX_ATTESTER_SLASHINGS_ELECTRA, MAX_ATTESTATIONS_ELECTRA, MAX_PENDING_PARTIALS_PER_WITHDRAWALS_SWEEP, + MAX_PENDING_DEPOSITS_PER_EPOCH, WHISTLEBLOWER_REWARD_QUOTIENT_ELECTRA, } = activePreset; diff --git a/packages/params/src/presets/mainnet.ts b/packages/params/src/presets/mainnet.ts index ca599e990df4..b488927e77b3 100644 --- a/packages/params/src/presets/mainnet.ts +++ b/packages/params/src/presets/mainnet.ts @@ -125,11 +125,12 @@ export const mainnetPreset: BeaconPreset = { MAX_ATTESTER_SLASHINGS_ELECTRA: 1, MAX_ATTESTATIONS_ELECTRA: 8, MAX_PENDING_PARTIALS_PER_WITHDRAWALS_SWEEP: 8, + MAX_PENDING_DEPOSITS_PER_EPOCH: 16, // 2**11 * 10**9 (= 2,048,000,000,000) Gwei MAX_EFFECTIVE_BALANCE_ELECTRA: 2048000000000, MIN_SLASHING_PENALTY_QUOTIENT_ELECTRA: 4096, MIN_ACTIVATION_BALANCE: 32000000000, - PENDING_BALANCE_DEPOSITS_LIMIT: 134217728, + PENDING_DEPOSITS_LIMIT: 134217728, PENDING_PARTIAL_WITHDRAWALS_LIMIT: 134217728, PENDING_CONSOLIDATIONS_LIMIT: 262144, MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD: 1, diff --git a/packages/params/src/presets/minimal.ts b/packages/params/src/presets/minimal.ts index 5dc8fc10d803..a6389d2f86ab 100644 --- a/packages/params/src/presets/minimal.ts +++ b/packages/params/src/presets/minimal.ts @@ -126,11 +126,12 @@ export const minimalPreset: BeaconPreset = { MAX_ATTESTER_SLASHINGS_ELECTRA: 1, MAX_ATTESTATIONS_ELECTRA: 8, MAX_PENDING_PARTIALS_PER_WITHDRAWALS_SWEEP: 1, + MAX_PENDING_DEPOSITS_PER_EPOCH: 16, // 2**11 * 10**9 (= 2,048,000,000,000) Gwei MAX_EFFECTIVE_BALANCE_ELECTRA: 2048000000000, MIN_SLASHING_PENALTY_QUOTIENT_ELECTRA: 4096, MIN_ACTIVATION_BALANCE: 32000000000, - PENDING_BALANCE_DEPOSITS_LIMIT: 134217728, + PENDING_DEPOSITS_LIMIT: 134217728, PENDING_PARTIAL_WITHDRAWALS_LIMIT: 64, PENDING_CONSOLIDATIONS_LIMIT: 64, MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD: 1, diff --git a/packages/params/src/types.ts b/packages/params/src/types.ts index e867b4a3cf71..f1dcb05136e9 100644 --- a/packages/params/src/types.ts +++ b/packages/params/src/types.ts @@ -89,10 +89,11 @@ export type BeaconPreset = { MAX_ATTESTER_SLASHINGS_ELECTRA: number; MAX_ATTESTATIONS_ELECTRA: number; MAX_PENDING_PARTIALS_PER_WITHDRAWALS_SWEEP: number; + MAX_PENDING_DEPOSITS_PER_EPOCH: number, MAX_EFFECTIVE_BALANCE_ELECTRA: number; MIN_SLASHING_PENALTY_QUOTIENT_ELECTRA: number; MIN_ACTIVATION_BALANCE: number; - PENDING_BALANCE_DEPOSITS_LIMIT: number; + PENDING_DEPOSITS_LIMIT: number; PENDING_PARTIAL_WITHDRAWALS_LIMIT: number; PENDING_CONSOLIDATIONS_LIMIT: number; MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD: number; @@ -189,10 +190,11 @@ export const beaconPresetTypes: BeaconPresetTypes = { MAX_ATTESTER_SLASHINGS_ELECTRA: "number", MAX_ATTESTATIONS_ELECTRA: "number", MAX_PENDING_PARTIALS_PER_WITHDRAWALS_SWEEP: "number", + MAX_PENDING_DEPOSITS_PER_EPOCH: "number", MAX_EFFECTIVE_BALANCE_ELECTRA: "number", MIN_SLASHING_PENALTY_QUOTIENT_ELECTRA: "number", MIN_ACTIVATION_BALANCE: "number", - PENDING_BALANCE_DEPOSITS_LIMIT: "number", + PENDING_DEPOSITS_LIMIT: "number", PENDING_PARTIAL_WITHDRAWALS_LIMIT: "number", PENDING_CONSOLIDATIONS_LIMIT: "number", MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD: "number", diff --git a/packages/state-transition/src/block/processDeposit.ts b/packages/state-transition/src/block/processDeposit.ts index ee75dff0dfd1..5a93f7617e49 100644 --- a/packages/state-transition/src/block/processDeposit.ts +++ b/packages/state-transition/src/block/processDeposit.ts @@ -75,11 +75,11 @@ export function applyDeposit( increaseBalance(state, cachedIndex, amount); } else if (fork >= ForkSeq.electra) { const stateElectra = state as CachedBeaconStateElectra; - const pendingBalanceDeposit = ssz.electra.PendingBalanceDeposit.toViewDU({ + const pendingDeposit = ssz.electra.PendingDeposit.toViewDU({ index: cachedIndex, amount: BigInt(amount), }); - stateElectra.pendingBalanceDeposits.push(pendingBalanceDeposit); + stateElectra.pendingDeposits.push(pendingDeposit); if ( hasCompoundingWithdrawalCredential(withdrawalCredentials) && @@ -143,11 +143,11 @@ function addValidatorToRegistry( } else if (fork >= ForkSeq.electra) { state.balances.push(0); const stateElectra = state as CachedBeaconStateElectra; - const pendingBalanceDeposit = ssz.electra.PendingBalanceDeposit.toViewDU({ + const pendingDeposit = ssz.electra.PendingDeposit.toViewDU({ index: validatorIndex, amount: BigInt(amount), }); - stateElectra.pendingBalanceDeposits.push(pendingBalanceDeposit); + stateElectra.pendingDeposits.push(pendingDeposit); } } diff --git a/packages/state-transition/src/epoch/index.ts b/packages/state-transition/src/epoch/index.ts index bfb415b9ed6a..b0b1651321d5 100644 --- a/packages/state-transition/src/epoch/index.ts +++ b/packages/state-transition/src/epoch/index.ts @@ -28,7 +28,7 @@ import {processRewardsAndPenalties} from "./processRewardsAndPenalties.js"; import {processSlashings} from "./processSlashings.js"; import {processSlashingsReset} from "./processSlashingsReset.js"; import {processSyncCommitteeUpdates} from "./processSyncCommitteeUpdates.js"; -import {processPendingBalanceDeposits} from "./processPendingBalanceDeposits.js"; +import {processPendingDeposits} from "./processPendingDeposits.js"; import {processPendingConsolidations} from "./processPendingConsolidations.js"; // For spec tests @@ -48,7 +48,7 @@ export { processParticipationFlagUpdates, processSyncCommitteeUpdates, processHistoricalSummariesUpdate, - processPendingBalanceDeposits, + processPendingDeposits, processPendingConsolidations, }; @@ -70,7 +70,7 @@ export enum EpochTransitionStep { processEffectiveBalanceUpdates = "processEffectiveBalanceUpdates", processParticipationFlagUpdates = "processParticipationFlagUpdates", processSyncCommitteeUpdates = "processSyncCommitteeUpdates", - processPendingBalanceDeposits = "processPendingBalanceDeposits", + processPendingDeposits = "processPendingDeposits", processPendingConsolidations = "processPendingConsolidations", } @@ -131,9 +131,9 @@ export function processEpoch( const stateElectra = state as CachedBeaconStateElectra; { const timer = metrics?.epochTransitionStepTime.startTimer({ - step: EpochTransitionStep.processPendingBalanceDeposits, + step: EpochTransitionStep.processPendingDeposits, }); - processPendingBalanceDeposits(stateElectra, cache); + processPendingDeposits(stateElectra, cache); timer?.(); } diff --git a/packages/state-transition/src/epoch/processEffectiveBalanceUpdates.ts b/packages/state-transition/src/epoch/processEffectiveBalanceUpdates.ts index 0ea4b49dddf4..26180d0d9f34 100644 --- a/packages/state-transition/src/epoch/processEffectiveBalanceUpdates.ts +++ b/packages/state-transition/src/epoch/processEffectiveBalanceUpdates.ts @@ -42,7 +42,7 @@ export function processEffectiveBalanceUpdates( // update effective balances with hysteresis // epochTransitionCache.balances is initialized in processRewardsAndPenalties() - // and updated in processPendingBalanceDeposits() and processPendingConsolidations() + // and updated in processPendingDeposits() and processPendingConsolidations() // so it's recycled here for performance. const balances = cache.balances ?? state.balances.getAll(); const currentEpochValidators = cache.validators; diff --git a/packages/state-transition/src/epoch/processPendingBalanceDeposits.ts b/packages/state-transition/src/epoch/processPendingDeposits.ts similarity index 81% rename from packages/state-transition/src/epoch/processPendingBalanceDeposits.ts rename to packages/state-transition/src/epoch/processPendingDeposits.ts index bef3ec0b2724..6874b9146473 100644 --- a/packages/state-transition/src/epoch/processPendingBalanceDeposits.ts +++ b/packages/state-transition/src/epoch/processPendingDeposits.ts @@ -7,12 +7,12 @@ import {getActivationExitChurnLimit} from "../util/validator.js"; * Starting from Electra: * Process pending balance deposits from state subject to churn limit and depsoitBalanceToConsume. * For each eligible `deposit`, call `increaseBalance()`. - * Remove the processed deposits from `state.pendingBalanceDeposits`. + * Remove the processed deposits from `state.pendingDeposits`. * Update `state.depositBalanceToConsume` for the next epoch * - * TODO Electra: Update ssz library to support batch push to `pendingBalanceDeposits` + * TODO Electra: Update ssz library to support batch push to `pendingDeposits` */ -export function processPendingBalanceDeposits(state: CachedBeaconStateElectra, cache: EpochTransitionCache): void { +export function processPendingDeposits(state: CachedBeaconStateElectra, cache: EpochTransitionCache): void { const nextEpoch = state.epochCtx.epoch + 1; const availableForProcessing = state.depositBalanceToConsume + BigInt(getActivationExitChurnLimit(state.epochCtx)); let processedAmount = 0n; @@ -21,7 +21,7 @@ export function processPendingBalanceDeposits(state: CachedBeaconStateElectra, c const validators = state.validators; const cachedBalances = cache.balances; - for (const deposit of state.pendingBalanceDeposits.getAllReadonly()) { + for (const deposit of state.pendingDeposits.getAllReadonly()) { const {amount, index: depositIndex} = deposit; const validator = validators.getReadonly(depositIndex); @@ -54,10 +54,10 @@ export function processPendingBalanceDeposits(state: CachedBeaconStateElectra, c nextDepositIndex++; } - const remainingPendingBalanceDeposits = state.pendingBalanceDeposits.sliceFrom(nextDepositIndex); - state.pendingBalanceDeposits = remainingPendingBalanceDeposits; + const remainingPendingDeposits = state.pendingDeposits.sliceFrom(nextDepositIndex); + state.pendingDeposits = remainingPendingDeposits; - if (remainingPendingBalanceDeposits.length === 0) { + if (remainingPendingDeposits.length === 0) { state.depositBalanceToConsume = 0n; } else { state.depositBalanceToConsume = availableForProcessing - processedAmount; @@ -65,6 +65,6 @@ export function processPendingBalanceDeposits(state: CachedBeaconStateElectra, c // TODO Electra: add a function in ListCompositeTreeView to support batch push operation for (const deposit of depositsToPostpone) { - state.pendingBalanceDeposits.push(deposit); + state.pendingDeposits.push(deposit); } } diff --git a/packages/state-transition/src/slot/upgradeStateToElectra.ts b/packages/state-transition/src/slot/upgradeStateToElectra.ts index 0bd36a909b46..e368a95dd58b 100644 --- a/packages/state-transition/src/slot/upgradeStateToElectra.ts +++ b/packages/state-transition/src/slot/upgradeStateToElectra.ts @@ -81,8 +81,8 @@ export function upgradeStateToElectra(stateDeneb: CachedBeaconStateDeneb): Cache stateElectraView.earliestExitEpoch = Math.max(...exitEpochs) + 1; stateElectraView.consolidationBalanceToConsume = BigInt(0); stateElectraView.earliestConsolidationEpoch = computeActivationExitEpoch(currentEpochPre); - // stateElectraView.pendingBalanceDeposits = ssz.electra.PendingBalanceDeposits.defaultViewDU(); - // pendingBalanceDeposits, pendingPartialWithdrawals, pendingConsolidations are default values + // stateElectraView.pendingDeposits = ssz.electra.PendingDeposits.defaultViewDU(); + // pendingDeposits, pendingPartialWithdrawals, pendingConsolidations are default values // TODO-electra: can we improve this? stateElectraView.commit(); const tmpElectraState = getCachedBeaconState(stateElectraView, stateDeneb); diff --git a/packages/state-transition/src/util/electra.ts b/packages/state-transition/src/util/electra.ts index ac34da6407de..3f766dea7129 100644 --- a/packages/state-transition/src/util/electra.ts +++ b/packages/state-transition/src/util/electra.ts @@ -1,7 +1,8 @@ -import {COMPOUNDING_WITHDRAWAL_PREFIX, FAR_FUTURE_EPOCH, MIN_ACTIVATION_BALANCE} from "@lodestar/params"; +import {COMPOUNDING_WITHDRAWAL_PREFIX, FAR_FUTURE_EPOCH, GENESIS_SLOT, MIN_ACTIVATION_BALANCE} from "@lodestar/params"; import {ValidatorIndex, ssz} from "@lodestar/types"; import {CachedBeaconStateElectra} from "../types.js"; import {hasEth1WithdrawalCredential} from "./capella.js"; +import { G2_POINT_AT_INFINITY } from "../constants/constants.js"; export function hasCompoundingWithdrawalCredential(withdrawalCredentials: Uint8Array): boolean { return withdrawalCredentials[0] === COMPOUNDING_WITHDRAWAL_PREFIX; @@ -30,14 +31,18 @@ export function switchToCompoundingValidator(state: CachedBeaconStateElectra, in export function queueExcessActiveBalance(state: CachedBeaconStateElectra, index: ValidatorIndex): void { const balance = state.balances.get(index); if (balance > MIN_ACTIVATION_BALANCE) { + const validator = state.validators.getReadonly(index); const excessBalance = balance - MIN_ACTIVATION_BALANCE; state.balances.set(index, MIN_ACTIVATION_BALANCE); - const pendingBalanceDeposit = ssz.electra.PendingBalanceDeposit.toViewDU({ - index, - amount: BigInt(excessBalance), + const pendingDeposit = ssz.electra.PendingDeposit.toViewDU({ + pubkey: validator.pubkey, + withdrawalCredentials: validator.withdrawalCredentials, + amount: excessBalance, + signature: G2_POINT_AT_INFINITY, // TODO Electra: convert buffer to uint8Array + slot: GENESIS_SLOT, }); - state.pendingBalanceDeposits.push(pendingBalanceDeposit); + state.pendingDeposits.push(pendingDeposit); } } @@ -50,9 +55,12 @@ export function queueEntireBalanceAndResetValidator(state: CachedBeaconStateElec state.epochCtx.effectiveBalanceIncrementsSet(index, 0); validator.activationEligibilityEpoch = FAR_FUTURE_EPOCH; - const pendingBalanceDeposit = ssz.electra.PendingBalanceDeposit.toViewDU({ - index, - amount: BigInt(balance), + const pendingDeposit = ssz.electra.PendingDeposit.toViewDU({ + pubkey: validator.pubkey, + withdrawalCredentials: validator.withdrawalCredentials, + amount: balance, + signature: G2_POINT_AT_INFINITY, // TODO Electra: convert buffer to uint8Array + slot: GENESIS_SLOT, }); - state.pendingBalanceDeposits.push(pendingBalanceDeposit); + state.pendingDeposits.push(pendingDeposit); } diff --git a/packages/state-transition/src/util/genesis.ts b/packages/state-transition/src/util/genesis.ts index 54507d0ef235..20c8f5c9dca2 100644 --- a/packages/state-transition/src/util/genesis.ts +++ b/packages/state-transition/src/util/genesis.ts @@ -171,10 +171,10 @@ export function applyDeposits( if (fork >= ForkSeq.electra) { const stateElectra = state as CachedBeaconStateElectra; stateElectra.commit(); - for (const {index: validatorIndex, amount} of stateElectra.pendingBalanceDeposits.getAllReadonly()) { + for (const {index: validatorIndex, amount} of stateElectra.pendingDeposits.getAllReadonly()) { increaseBalance(state, validatorIndex, Number(amount)); } - stateElectra.pendingBalanceDeposits = ssz.electra.PendingBalanceDeposits.defaultViewDU(); + stateElectra.pendingDeposits = ssz.electra.PendingDeposits.defaultViewDU(); } // Process activations diff --git a/packages/state-transition/test/perf/analyzeEpochs.ts b/packages/state-transition/test/perf/analyzeEpochs.ts index deb0861427bf..2f1485a809b1 100644 --- a/packages/state-transition/test/perf/analyzeEpochs.ts +++ b/packages/state-transition/test/perf/analyzeEpochs.ts @@ -153,7 +153,7 @@ async function analyzeEpochs(network: NetworkName, fromEpoch?: number): Promise< // processSlashingsAllForks: function of process.indicesToSlash // processSlashingsReset: free // -- electra - // processPendingBalanceDeposits: - + // processPendingDeposits: - // processPendingConsolidations: - // -- altair // processInactivityUpdates: - diff --git a/packages/types/src/electra/sszTypes.ts b/packages/types/src/electra/sszTypes.ts index 9d995c38efd5..7200af5f4ead 100644 --- a/packages/types/src/electra/sszTypes.ts +++ b/packages/types/src/electra/sszTypes.ts @@ -17,7 +17,7 @@ import { MAX_ATTESTER_SLASHINGS_ELECTRA, MAX_WITHDRAWAL_REQUESTS_PER_PAYLOAD, MAX_CONSOLIDATION_REQUESTS_PER_PAYLOAD, - PENDING_BALANCE_DEPOSITS_LIMIT, + PENDING_DEPOSITS_LIMIT, PENDING_PARTIAL_WITHDRAWALS_LIMIT, PENDING_CONSOLIDATIONS_LIMIT, FINALIZED_ROOT_DEPTH_ELECTRA, @@ -249,15 +249,20 @@ export const SignedBuilderBid = new ContainerType( {typeName: "SignedBuilderBid", jsonCase: "eth2"} ); -export const PendingBalanceDeposit = new ContainerType( +export const PendingDeposit = new ContainerType( { - index: ValidatorIndex, - amount: Gwei, + pubkey: BLSPubkey, + withdrawalCredentials: Bytes32, + // this is actually gwei uintbn64 type, but super unlikely to get a high amount here + // to warrant a bn type + amount: UintNum64, + signature: BLSSignature, + slot: Slot, }, - {typeName: "PendingBalanceDeposit", jsonCase: "eth2"} + {typeName: "PendingDeposit", jsonCase: "eth2"} ); -export const PendingBalanceDeposits = new ListCompositeType(PendingBalanceDeposit, PENDING_BALANCE_DEPOSITS_LIMIT); +export const PendingDeposits = new ListCompositeType(PendingDeposit, PENDING_DEPOSITS_LIMIT); export const PendingPartialWithdrawal = new ContainerType( { @@ -325,7 +330,7 @@ export const BeaconState = new ContainerType( earliestExitEpoch: Epoch, // New in ELECTRA:EIP7251 consolidationBalanceToConsume: Gwei, // New in ELECTRA:EIP7251 earliestConsolidationEpoch: Epoch, // New in ELECTRA:EIP7251 - pendingBalanceDeposits: PendingBalanceDeposits, // New in ELECTRA:EIP7251 + pendingDeposits: PendingDeposits, // New in ELECTRA:EIP7251 pendingPartialWithdrawals: new ListCompositeType(PendingPartialWithdrawal, PENDING_PARTIAL_WITHDRAWALS_LIMIT), // New in ELECTRA:EIP7251 pendingConsolidations: new ListCompositeType(PendingConsolidation, PENDING_CONSOLIDATIONS_LIMIT), // New in ELECTRA:EIP7251 }, diff --git a/packages/types/src/electra/types.ts b/packages/types/src/electra/types.ts index f7996cf336f9..691de409ed91 100644 --- a/packages/types/src/electra/types.ts +++ b/packages/types/src/electra/types.ts @@ -42,7 +42,7 @@ export type LightClientFinalityUpdate = ValueOf; export type LightClientStore = ValueOf; -export type PendingBalanceDeposit = ValueOf; +export type PendingDeposit = ValueOf; export type PendingPartialWithdrawal = ValueOf; export type PendingConsolidation = ValueOf; diff --git a/packages/validator/src/util/params.ts b/packages/validator/src/util/params.ts index 6d6705f512df..51df32ab4848 100644 --- a/packages/validator/src/util/params.ts +++ b/packages/validator/src/util/params.ts @@ -228,10 +228,11 @@ function getSpecCriticalParams(localConfig: ChainConfig): Record Date: Mon, 7 Oct 2024 14:26:24 -0700 Subject: [PATCH 2/8] process deposits on epoch processing --- packages/params/src/types.ts | 2 +- .../src/block/processDeposit.ts | 72 ++++++----- .../src/block/processDepositRequest.ts | 13 +- .../src/epoch/processPendingDeposits.ts | 113 +++++++++++++----- packages/state-transition/src/util/electra.ts | 8 +- packages/state-transition/src/util/genesis.ts | 9 +- 6 files changed, 137 insertions(+), 80 deletions(-) diff --git a/packages/params/src/types.ts b/packages/params/src/types.ts index f1dcb05136e9..bb32f3690e49 100644 --- a/packages/params/src/types.ts +++ b/packages/params/src/types.ts @@ -89,7 +89,7 @@ export type BeaconPreset = { MAX_ATTESTER_SLASHINGS_ELECTRA: number; MAX_ATTESTATIONS_ELECTRA: number; MAX_PENDING_PARTIALS_PER_WITHDRAWALS_SWEEP: number; - MAX_PENDING_DEPOSITS_PER_EPOCH: number, + MAX_PENDING_DEPOSITS_PER_EPOCH: number; MAX_EFFECTIVE_BALANCE_ELECTRA: number; MIN_SLASHING_PENALTY_QUOTIENT_ELECTRA: number; MIN_ACTIVATION_BALANCE: number; diff --git a/packages/state-transition/src/block/processDeposit.ts b/packages/state-transition/src/block/processDeposit.ts index 5a93f7617e49..2ac590cb85fe 100644 --- a/packages/state-transition/src/block/processDeposit.ts +++ b/packages/state-transition/src/block/processDeposit.ts @@ -8,6 +8,7 @@ import { EFFECTIVE_BALANCE_INCREMENT, FAR_FUTURE_EPOCH, ForkSeq, + GENESIS_SLOT, MAX_EFFECTIVE_BALANCE, } from "@lodestar/params"; @@ -18,10 +19,8 @@ import {ZERO_HASH} from "../constants/index.js"; import { computeDomain, computeSigningRoot, - hasCompoundingWithdrawalCredential, - hasEth1WithdrawalCredential, + getMaxEffectiveBalance, increaseBalance, - switchToCompoundingValidator, } from "../util/index.js"; import {CachedBeaconStateAllForks, CachedBeaconStateAltair, CachedBeaconStateElectra} from "../types.js"; @@ -62,37 +61,42 @@ export function applyDeposit( deposit: DepositData | DepositRequest ): void { const {config, validators, epochCtx} = state; - const {pubkey, withdrawalCredentials, amount} = deposit; + const {pubkey, withdrawalCredentials, amount, signature} = deposit; const cachedIndex = epochCtx.getValidatorIndex(pubkey); - if (cachedIndex === null || !Number.isSafeInteger(cachedIndex) || cachedIndex >= validators.length) { - if (isValidDepositSignature(config, pubkey, withdrawalCredentials, amount, deposit.signature)) { - addValidatorToRegistry(fork, state, pubkey, withdrawalCredentials, amount); - } - } else { - if (fork < ForkSeq.electra) { + const isNewValidator = cachedIndex === null || !Number.isSafeInteger(cachedIndex) || cachedIndex >= validators.length; + + if (fork < ForkSeq.electra) { + if (isNewValidator) { + if (isValidDepositSignature(config, pubkey, withdrawalCredentials, amount, signature)) { + addValidatorToRegistry(fork, state, pubkey, withdrawalCredentials, amount); + } + } else { // increase balance by deposit amount right away pre-electra increaseBalance(state, cachedIndex, amount); - } else if (fork >= ForkSeq.electra) { - const stateElectra = state as CachedBeaconStateElectra; - const pendingDeposit = ssz.electra.PendingDeposit.toViewDU({ - index: cachedIndex, - amount: BigInt(amount), - }); - stateElectra.pendingDeposits.push(pendingDeposit); + } + } else { + const stateElectra = state as CachedBeaconStateElectra; + const pendingDeposit = ssz.electra.PendingDeposit.toViewDU({ + pubkey, + withdrawalCredentials, + amount, + signature, + slot: GENESIS_SLOT, // Use GENESIS_SLOT to distinguish from a pending deposit request + }); - if ( - hasCompoundingWithdrawalCredential(withdrawalCredentials) && - hasEth1WithdrawalCredential(validators.getReadonly(cachedIndex).withdrawalCredentials) && - isValidDepositSignature(config, pubkey, withdrawalCredentials, amount, deposit.signature) - ) { - switchToCompoundingValidator(stateElectra, cachedIndex); + if (isNewValidator) { + if (isValidDepositSignature(config, pubkey, withdrawalCredentials, amount, deposit.signature)) { + addValidatorToRegistry(fork, state, pubkey, withdrawalCredentials, 0); + stateElectra.pendingDeposits.push(pendingDeposit); } + } else { + stateElectra.pendingDeposits.push(pendingDeposit); } } } -function addValidatorToRegistry( +export function addValidatorToRegistry( fork: ForkSeq, state: CachedBeaconStateAllForks, pubkey: BLSPubkey, @@ -101,8 +105,10 @@ function addValidatorToRegistry( ): void { const {validators, epochCtx} = state; // add validator and balance entries - const effectiveBalance = - fork < ForkSeq.electra ? Math.min(amount - (amount % EFFECTIVE_BALANCE_INCREMENT), MAX_EFFECTIVE_BALANCE) : 0; + const effectiveBalance = Math.min( + amount - (amount % EFFECTIVE_BALANCE_INCREMENT), + fork < ForkSeq.electra ? MAX_EFFECTIVE_BALANCE : getMaxEffectiveBalance(withdrawalCredentials) + ); validators.push( ssz.phase0.Validator.toViewDU({ pubkey, @@ -138,20 +144,10 @@ function addValidatorToRegistry( stateAltair.currentEpochParticipation.push(0); } - if (fork < ForkSeq.electra) { - state.balances.push(amount); - } else if (fork >= ForkSeq.electra) { - state.balances.push(0); - const stateElectra = state as CachedBeaconStateElectra; - const pendingDeposit = ssz.electra.PendingDeposit.toViewDU({ - index: validatorIndex, - amount: BigInt(amount), - }); - stateElectra.pendingDeposits.push(pendingDeposit); - } + state.balances.push(amount); } -function isValidDepositSignature( +export function isValidDepositSignature( config: BeaconConfig, pubkey: Uint8Array, withdrawalCredentials: Uint8Array, diff --git a/packages/state-transition/src/block/processDepositRequest.ts b/packages/state-transition/src/block/processDepositRequest.ts index e5dd99a40c4e..a349c372d51b 100644 --- a/packages/state-transition/src/block/processDepositRequest.ts +++ b/packages/state-transition/src/block/processDepositRequest.ts @@ -1,8 +1,7 @@ -import {electra} from "@lodestar/types"; +import {electra, ssz} from "@lodestar/types"; import {ForkSeq, UNSET_DEPOSIT_REQUESTS_START_INDEX} from "@lodestar/params"; import {CachedBeaconStateElectra} from "../types.js"; -import {applyDeposit} from "./processDeposit.js"; export function processDepositRequest( fork: ForkSeq, @@ -13,5 +12,13 @@ export function processDepositRequest( state.depositRequestsStartIndex = BigInt(depositRequest.index); } - applyDeposit(fork, state, depositRequest); + // Create pending deposit + const pendingDeposit = ssz.electra.PendingDeposit.toViewDU({ + pubkey: depositRequest.pubkey, + withdrawalCredentials: depositRequest.withdrawalCredentials, + amount: depositRequest.amount, + signature: depositRequest.signature, + slot: state.slot, + }); + state.pendingDeposits.push(pendingDeposit); } diff --git a/packages/state-transition/src/epoch/processPendingDeposits.ts b/packages/state-transition/src/epoch/processPendingDeposits.ts index 6874b9146473..7d05d582f88f 100644 --- a/packages/state-transition/src/epoch/processPendingDeposits.ts +++ b/packages/state-transition/src/epoch/processPendingDeposits.ts @@ -1,7 +1,10 @@ -import {FAR_FUTURE_EPOCH} from "@lodestar/params"; +import {FAR_FUTURE_EPOCH, ForkSeq, GENESIS_SLOT, MAX_PENDING_DEPOSITS_PER_EPOCH} from "@lodestar/params"; +import {PendingDeposit} from "@lodestar/types/lib/electra/types.js"; import {CachedBeaconStateElectra, EpochTransitionCache} from "../types.js"; import {increaseBalance} from "../util/balance.js"; import {getActivationExitChurnLimit} from "../util/validator.js"; +import {computeStartSlotAtEpoch} from "../util/epoch.js"; +import {addValidatorToRegistry, isValidDepositSignature} from "../block/processDeposit.js"; /** * Starting from Electra: @@ -15,41 +18,61 @@ import {getActivationExitChurnLimit} from "../util/validator.js"; export function processPendingDeposits(state: CachedBeaconStateElectra, cache: EpochTransitionCache): void { const nextEpoch = state.epochCtx.epoch + 1; const availableForProcessing = state.depositBalanceToConsume + BigInt(getActivationExitChurnLimit(state.epochCtx)); - let processedAmount = 0n; + let processedAmount = 0; let nextDepositIndex = 0; const depositsToPostpone = []; - const validators = state.validators; - const cachedBalances = cache.balances; + let isChurnLimitReached = false; + const finalizedSlot = computeStartSlotAtEpoch(state.finalizedCheckpoint.epoch); for (const deposit of state.pendingDeposits.getAllReadonly()) { - const {amount, index: depositIndex} = deposit; - const validator = validators.getReadonly(depositIndex); + // Do not process deposit requests if Eth1 bridge deposits are not yet applied. + if ( + // Is deposit request + deposit.slot > GENESIS_SLOT && + // There are pending Eth1 bridge deposits + state.eth1DepositIndex < state.depositRequestsStartIndex + ) { + break; + } - // Validator is exiting, postpone the deposit until after withdrawable epoch - if (validator.exitEpoch < FAR_FUTURE_EPOCH) { - if (nextEpoch <= validator.withdrawableEpoch) { - depositsToPostpone.push(deposit); - } else { - // Deposited balance will never become active. Increase balance but do not consume churn - increaseBalance(state, depositIndex, Number(amount)); - if (cachedBalances) { - cachedBalances[depositIndex] += Number(amount); - } - } + // Check if deposit has been finalized, otherwise, stop processing. + if (deposit.slot > finalizedSlot) { + break; + } + + // Check if number of processed deposits has not reached the limit, otherwise, stop processing. + if (nextDepositIndex >= MAX_PENDING_DEPOSITS_PER_EPOCH) { + break; + } + + // Read validator state + let isValidatorExited = false; + let isValidatorWithdrawn = false; + + const validatorIndex = state.epochCtx.getValidatorIndex(deposit.pubkey); + if (validatorIndex !== null) { + const validator = state.validators.getReadonly(validatorIndex); + isValidatorExited = validator.exitEpoch < FAR_FUTURE_EPOCH; + isValidatorWithdrawn = validator.withdrawableEpoch < nextEpoch; + } + + if (isValidatorWithdrawn) { + // Deposited balance will never become active. Increase balance but do not consume churn + applyPendingDeposit(state, deposit, cache); + } else if (isValidatorExited) { + // Validator is exiting, postpone the deposit until after withdrawable epoch + depositsToPostpone.push(deposit); } else { - // Validator is not exiting, attempt to process deposit - if (processedAmount + amount > availableForProcessing) { - // Deposit does not fit in the churn, no more deposit processing in this epoch. + // Check if deposit fits in the churn, otherwise, do no more deposit processing in this epoch. + isChurnLimitReached = processedAmount + deposit.amount > availableForProcessing; + if (isChurnLimitReached) { break; - } else { - // Deposit fits in the churn, process it. Increase balance and consume churn. - increaseBalance(state, depositIndex, Number(amount)); - if (cachedBalances) { - cachedBalances[depositIndex] += Number(amount); - } - processedAmount = processedAmount + amount; } + // Consume churn and apply deposit. + processedAmount += deposit.amount; + applyPendingDeposit(state, deposit, cache); } + // Regardless of how the deposit was handled, we move on in the queue. nextDepositIndex++; } @@ -57,14 +80,38 @@ export function processPendingDeposits(state: CachedBeaconStateElectra, cache: E const remainingPendingDeposits = state.pendingDeposits.sliceFrom(nextDepositIndex); state.pendingDeposits = remainingPendingDeposits; - if (remainingPendingDeposits.length === 0) { - state.depositBalanceToConsume = 0n; - } else { - state.depositBalanceToConsume = availableForProcessing - processedAmount; - } - // TODO Electra: add a function in ListCompositeTreeView to support batch push operation for (const deposit of depositsToPostpone) { state.pendingDeposits.push(deposit); } + + // Accumulate churn only if the churn limit has been hit. + if (isChurnLimitReached) { + state.depositBalanceToConsume = availableForProcessing - BigInt(processedAmount); + } else { + state.depositBalanceToConsume = 0n; + } +} + +function applyPendingDeposit( + state: CachedBeaconStateElectra, + deposit: PendingDeposit, + cache: EpochTransitionCache +): void { + const validatorIndex = state.epochCtx.getValidatorIndex(deposit.pubkey); + const {pubkey, withdrawalCredentials, amount, signature} = deposit; + const cachedBalances = cache.balances; + + if (validatorIndex === null) { + // Verify the deposit signature (proof of possession) which is not checked by the deposit contract + if (isValidDepositSignature(state.config, pubkey, withdrawalCredentials, amount, signature)) { + addValidatorToRegistry(ForkSeq.electra, state, pubkey, withdrawalCredentials, amount); + } + } else { + // Increase balance + increaseBalance(state, validatorIndex, deposit.amount); + if (cachedBalances) { + cachedBalances[validatorIndex] += amount; + } + } } diff --git a/packages/state-transition/src/util/electra.ts b/packages/state-transition/src/util/electra.ts index 3f766dea7129..994a427fc14a 100644 --- a/packages/state-transition/src/util/electra.ts +++ b/packages/state-transition/src/util/electra.ts @@ -1,8 +1,8 @@ import {COMPOUNDING_WITHDRAWAL_PREFIX, FAR_FUTURE_EPOCH, GENESIS_SLOT, MIN_ACTIVATION_BALANCE} from "@lodestar/params"; import {ValidatorIndex, ssz} from "@lodestar/types"; import {CachedBeaconStateElectra} from "../types.js"; +import {G2_POINT_AT_INFINITY} from "../constants/constants.js"; import {hasEth1WithdrawalCredential} from "./capella.js"; -import { G2_POINT_AT_INFINITY } from "../constants/constants.js"; export function hasCompoundingWithdrawalCredential(withdrawalCredentials: Uint8Array): boolean { return withdrawalCredentials[0] === COMPOUNDING_WITHDRAWAL_PREFIX; @@ -39,7 +39,9 @@ export function queueExcessActiveBalance(state: CachedBeaconStateElectra, index: pubkey: validator.pubkey, withdrawalCredentials: validator.withdrawalCredentials, amount: excessBalance, - signature: G2_POINT_AT_INFINITY, // TODO Electra: convert buffer to uint8Array + // Use bls.G2_POINT_AT_INFINITY as a signature field placeholder + signature: new Uint8Array(G2_POINT_AT_INFINITY), + // Use GENESIS_SLOT to distinguish from a pending deposit request slot: GENESIS_SLOT, }); state.pendingDeposits.push(pendingDeposit); @@ -59,7 +61,7 @@ export function queueEntireBalanceAndResetValidator(state: CachedBeaconStateElec pubkey: validator.pubkey, withdrawalCredentials: validator.withdrawalCredentials, amount: balance, - signature: G2_POINT_AT_INFINITY, // TODO Electra: convert buffer to uint8Array + signature: new Uint8Array(G2_POINT_AT_INFINITY), slot: GENESIS_SLOT, }); state.pendingDeposits.push(pendingDeposit); diff --git a/packages/state-transition/src/util/genesis.ts b/packages/state-transition/src/util/genesis.ts index 20c8f5c9dca2..aca81258a47a 100644 --- a/packages/state-transition/src/util/genesis.ts +++ b/packages/state-transition/src/util/genesis.ts @@ -171,8 +171,13 @@ export function applyDeposits( if (fork >= ForkSeq.electra) { const stateElectra = state as CachedBeaconStateElectra; stateElectra.commit(); - for (const {index: validatorIndex, amount} of stateElectra.pendingDeposits.getAllReadonly()) { - increaseBalance(state, validatorIndex, Number(amount)); + for (const {pubkey, amount} of stateElectra.pendingDeposits.getAllReadonly()) { + const validatorIndex = state.epochCtx.getValidatorIndex(pubkey); + if (validatorIndex === null) { + // Should not happen if the gensis state is correct + continue; + } + increaseBalance(state, validatorIndex, amount); } stateElectra.pendingDeposits = ssz.electra.PendingDeposits.defaultViewDU(); } From 5fa44495484678cc00d08868b7c14a1815fd58c9 Mon Sep 17 00:00:00 2001 From: NC <17676176+ensi321@users.noreply.github.com> Date: Mon, 7 Oct 2024 14:27:06 -0700 Subject: [PATCH 3/8] lint --- packages/state-transition/src/block/processDeposit.ts | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/packages/state-transition/src/block/processDeposit.ts b/packages/state-transition/src/block/processDeposit.ts index 2ac590cb85fe..39f166da42d9 100644 --- a/packages/state-transition/src/block/processDeposit.ts +++ b/packages/state-transition/src/block/processDeposit.ts @@ -16,12 +16,7 @@ import {DepositData} from "@lodestar/types/lib/phase0/types.js"; import {DepositRequest} from "@lodestar/types/lib/electra/types.js"; import {BeaconConfig} from "@lodestar/config"; import {ZERO_HASH} from "../constants/index.js"; -import { - computeDomain, - computeSigningRoot, - getMaxEffectiveBalance, - increaseBalance, -} from "../util/index.js"; +import {computeDomain, computeSigningRoot, getMaxEffectiveBalance, increaseBalance} from "../util/index.js"; import {CachedBeaconStateAllForks, CachedBeaconStateAltair, CachedBeaconStateElectra} from "../types.js"; /** From 4b6a28d7f719d93c976e155fca6461637948c296 Mon Sep 17 00:00:00 2001 From: NC <17676176+ensi321@users.noreply.github.com> Date: Mon, 7 Oct 2024 16:54:25 -0700 Subject: [PATCH 4/8] Fix spec test --- packages/beacon-node/test/spec/presets/epoch_processing.test.ts | 2 +- packages/beacon-node/test/spec/specTestVersioning.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/beacon-node/test/spec/presets/epoch_processing.test.ts b/packages/beacon-node/test/spec/presets/epoch_processing.test.ts index 2307511f5f3e..932ad25b481e 100644 --- a/packages/beacon-node/test/spec/presets/epoch_processing.test.ts +++ b/packages/beacon-node/test/spec/presets/epoch_processing.test.ts @@ -46,7 +46,7 @@ const epochTransitionFns: Record = { epochFns.processSyncCommitteeUpdates(fork, state as CachedBeaconStateAltair); }, historical_summaries_update: epochFns.processHistoricalSummariesUpdate as EpochTransitionFn, - pending_balance_deposits: epochFns.processPendingDeposits as EpochTransitionFn, + pending_deposits: epochFns.processPendingDeposits as EpochTransitionFn, pending_consolidations: epochFns.processPendingConsolidations as EpochTransitionFn, }; diff --git a/packages/beacon-node/test/spec/specTestVersioning.ts b/packages/beacon-node/test/spec/specTestVersioning.ts index d4bc192f6cad..bef42fd1cdfa 100644 --- a/packages/beacon-node/test/spec/specTestVersioning.ts +++ b/packages/beacon-node/test/spec/specTestVersioning.ts @@ -15,7 +15,7 @@ import {DownloadTestsOptions} from "@lodestar/spec-test-util/downloadTests"; const __dirname = path.dirname(fileURLToPath(import.meta.url)); export const ethereumConsensusSpecsTests: DownloadTestsOptions = { - specVersion: "v1.5.0-alpha.6", + specVersion: "v1.5.0-alpha.7", // Target directory is the host package root: 'packages/*/spec-tests' outputDir: path.join(__dirname, "../../spec-tests"), specTestsRepoUrl: "https://github.com/ethereum/consensus-spec-tests", From a5817e671cb579e6597e33b193acec0098343d4e Mon Sep 17 00:00:00 2001 From: NC <17676176+ensi321@users.noreply.github.com> Date: Wed, 9 Oct 2024 19:19:57 -0700 Subject: [PATCH 5/8] Remove commented out code --- packages/state-transition/src/slot/upgradeStateToElectra.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/state-transition/src/slot/upgradeStateToElectra.ts b/packages/state-transition/src/slot/upgradeStateToElectra.ts index e368a95dd58b..b64ac242f83c 100644 --- a/packages/state-transition/src/slot/upgradeStateToElectra.ts +++ b/packages/state-transition/src/slot/upgradeStateToElectra.ts @@ -81,8 +81,6 @@ export function upgradeStateToElectra(stateDeneb: CachedBeaconStateDeneb): Cache stateElectraView.earliestExitEpoch = Math.max(...exitEpochs) + 1; stateElectraView.consolidationBalanceToConsume = BigInt(0); stateElectraView.earliestConsolidationEpoch = computeActivationExitEpoch(currentEpochPre); - // stateElectraView.pendingDeposits = ssz.electra.PendingDeposits.defaultViewDU(); - // pendingDeposits, pendingPartialWithdrawals, pendingConsolidations are default values // TODO-electra: can we improve this? stateElectraView.commit(); const tmpElectraState = getCachedBeaconState(stateElectraView, stateDeneb); From 6c60fc8b17b90663629b4293885f23421d14fb23 Mon Sep 17 00:00:00 2001 From: NC <17676176+ensi321@users.noreply.github.com> Date: Thu, 10 Oct 2024 15:28:48 -0700 Subject: [PATCH 6/8] Update packages/state-transition/src/epoch/processPendingDeposits.ts Co-authored-by: twoeths --- packages/state-transition/src/epoch/processPendingDeposits.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/state-transition/src/epoch/processPendingDeposits.ts b/packages/state-transition/src/epoch/processPendingDeposits.ts index 7d05d582f88f..53af3ab38763 100644 --- a/packages/state-transition/src/epoch/processPendingDeposits.ts +++ b/packages/state-transition/src/epoch/processPendingDeposits.ts @@ -109,7 +109,7 @@ function applyPendingDeposit( } } else { // Increase balance - increaseBalance(state, validatorIndex, deposit.amount); + increaseBalance(state, validatorIndex, amount); if (cachedBalances) { cachedBalances[validatorIndex] += amount; } From 51ae010eb2da532bc7a5df1ac656271b90613365 Mon Sep 17 00:00:00 2001 From: NC <17676176+ensi321@users.noreply.github.com> Date: Thu, 10 Oct 2024 15:37:59 -0700 Subject: [PATCH 7/8] Address comments --- packages/state-transition/src/block/processDeposit.ts | 2 +- packages/state-transition/src/util/electra.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/state-transition/src/block/processDeposit.ts b/packages/state-transition/src/block/processDeposit.ts index 39f166da42d9..7aab5e32b368 100644 --- a/packages/state-transition/src/block/processDeposit.ts +++ b/packages/state-transition/src/block/processDeposit.ts @@ -59,7 +59,7 @@ export function applyDeposit( const {pubkey, withdrawalCredentials, amount, signature} = deposit; const cachedIndex = epochCtx.getValidatorIndex(pubkey); - const isNewValidator = cachedIndex === null || !Number.isSafeInteger(cachedIndex) || cachedIndex >= validators.length; + const isNewValidator = cachedIndex === null || !Number.isSafeInteger(cachedIndex); if (fork < ForkSeq.electra) { if (isNewValidator) { diff --git a/packages/state-transition/src/util/electra.ts b/packages/state-transition/src/util/electra.ts index 994a427fc14a..90dd9a3881df 100644 --- a/packages/state-transition/src/util/electra.ts +++ b/packages/state-transition/src/util/electra.ts @@ -40,7 +40,7 @@ export function queueExcessActiveBalance(state: CachedBeaconStateElectra, index: withdrawalCredentials: validator.withdrawalCredentials, amount: excessBalance, // Use bls.G2_POINT_AT_INFINITY as a signature field placeholder - signature: new Uint8Array(G2_POINT_AT_INFINITY), + signature: G2_POINT_AT_INFINITY, // Use GENESIS_SLOT to distinguish from a pending deposit request slot: GENESIS_SLOT, }); @@ -61,7 +61,7 @@ export function queueEntireBalanceAndResetValidator(state: CachedBeaconStateElec pubkey: validator.pubkey, withdrawalCredentials: validator.withdrawalCredentials, amount: balance, - signature: new Uint8Array(G2_POINT_AT_INFINITY), + signature: G2_POINT_AT_INFINITY, slot: GENESIS_SLOT, }); state.pendingDeposits.push(pendingDeposit); From a78be9ca02bdfa4907ad0c3405815e3b398b47c4 Mon Sep 17 00:00:00 2001 From: NC <17676176+ensi321@users.noreply.github.com> Date: Thu, 10 Oct 2024 17:23:37 -0700 Subject: [PATCH 8/8] lint --- packages/state-transition/src/block/processDeposit.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/state-transition/src/block/processDeposit.ts b/packages/state-transition/src/block/processDeposit.ts index 7aab5e32b368..f900cdc39bad 100644 --- a/packages/state-transition/src/block/processDeposit.ts +++ b/packages/state-transition/src/block/processDeposit.ts @@ -55,7 +55,7 @@ export function applyDeposit( state: CachedBeaconStateAllForks, deposit: DepositData | DepositRequest ): void { - const {config, validators, epochCtx} = state; + const {config, epochCtx} = state; const {pubkey, withdrawalCredentials, amount, signature} = deposit; const cachedIndex = epochCtx.getValidatorIndex(pubkey);