diff --git a/packages/state-transition/src/cache/epochCache.ts b/packages/state-transition/src/cache/epochCache.ts index e61fe751f3d..804f606ab76 100644 --- a/packages/state-transition/src/cache/epochCache.ts +++ b/packages/state-transition/src/cache/epochCache.ts @@ -311,7 +311,7 @@ export class EpochCache { const nextEpoch = currentEpoch + 1; let totalActiveBalanceIncrements = 0; - let exitQueueEpoch = computeActivationExitEpoch(currentEpoch); // TODO Electra: New exit epoch calculation + let exitQueueEpoch = computeActivationExitEpoch(currentEpoch); let exitQueueChurn = 0; const validators = state.validators.getAllReadonlyValues(); @@ -590,7 +590,7 @@ export class EpochCache { ); // Maybe advance exitQueueEpoch at the end of the epoch if there haven't been any exists for a while - const exitQueueEpoch = computeActivationExitEpoch(currEpoch); // TODO Electra: New exit epoch calculation + const exitQueueEpoch = computeActivationExitEpoch(currEpoch); if (exitQueueEpoch > this.exitQueueEpoch) { this.exitQueueEpoch = exitQueueEpoch; this.exitQueueChurn = 0; diff --git a/packages/state-transition/src/cache/epochTransitionCache.ts b/packages/state-transition/src/cache/epochTransitionCache.ts index 4a8fa7286d6..537d84f3cdb 100644 --- a/packages/state-transition/src/cache/epochTransitionCache.ts +++ b/packages/state-transition/src/cache/epochTransitionCache.ts @@ -1,6 +1,6 @@ import {Epoch, ValidatorIndex} from "@lodestar/types"; import {intDiv} from "@lodestar/utils"; -import {EPOCHS_PER_SLASHINGS_VECTOR, FAR_FUTURE_EPOCH, ForkSeq, MAX_EFFECTIVE_BALANCE} from "@lodestar/params"; +import {EPOCHS_PER_SLASHINGS_VECTOR, FAR_FUTURE_EPOCH, ForkSeq, MAX_EFFECTIVE_BALANCE, MIN_ACTIVATION_BALANCE} from "@lodestar/params"; import { AttesterStatus, @@ -248,7 +248,7 @@ export function beforeProcessEpoch( // ``` if ( validator.activationEligibilityEpoch === FAR_FUTURE_EPOCH && - validator.effectiveBalance >= MAX_EFFECTIVE_BALANCE + validator.effectiveBalance >= MIN_ACTIVATION_BALANCE ) { indicesEligibleForActivationQueue.push(i); } diff --git a/packages/state-transition/src/epoch/processRegistryUpdates.ts b/packages/state-transition/src/epoch/processRegistryUpdates.ts index 14ae1cfaa53..d9ff7bd63d0 100644 --- a/packages/state-transition/src/epoch/processRegistryUpdates.ts +++ b/packages/state-transition/src/epoch/processRegistryUpdates.ts @@ -36,18 +36,21 @@ export function processRegistryUpdates( initiateValidatorExit(fork, state, validators.get(index)); } - // TODO Electra: New logic to set validator.activation_epoch - if (fork >= ForkSeq.electra) { - } - // set new activation eligibilities for (const index of cache.indicesEligibleForActivationQueue) { validators.get(index).activationEligibilityEpoch = epochCtx.epoch + 1; } const finalityEpoch = state.finalizedCheckpoint.epoch; - // dequeue validators for activation up to churn limit - for (const index of cache.indicesEligibleForActivation.slice(0, epochCtx.activationChurnLimit)) { + let indicesEligibleForActivation; + if (fork < ForkSeq.electra) { + // dequeue validators for activation up to churn limit + indicesEligibleForActivation = cache.indicesEligibleForActivation.slice(0, epochCtx.activationChurnLimit) + } else { + // no churn limit post-electra + indicesEligibleForActivation = cache.indicesEligibleForActivation; + } + for (const index of indicesEligibleForActivation) { const validator = validators.get(index); // placement in queue is finalized if (validator.activationEligibilityEpoch > finalityEpoch) { diff --git a/packages/state-transition/src/util/genesis.ts b/packages/state-transition/src/util/genesis.ts index 797ca7cc1ae..537edc7f976 100644 --- a/packages/state-transition/src/util/genesis.ts +++ b/packages/state-transition/src/util/genesis.ts @@ -180,7 +180,7 @@ export function applyDeposits( } const balance = balancesArr[i]; - const effectiveBalance = Math.min(balance - (balance % EFFECTIVE_BALANCE_INCREMENT), MAX_EFFECTIVE_BALANCE); // TODO Electra: Double check if we use MIN_ACTIVATION_BALANCE + const effectiveBalance = Math.min(balance - (balance % EFFECTIVE_BALANCE_INCREMENT), MAX_EFFECTIVE_BALANCE); validator.effectiveBalance = effectiveBalance; epochCtx.effectiveBalanceIncrementsSet(i, effectiveBalance);