From afde7b7786e906218528ae92ff438eb7ea62eb02 Mon Sep 17 00:00:00 2001 From: NC Date: Wed, 17 Apr 2024 17:59:26 +0800 Subject: [PATCH] Remove churn limit in processRegistryUpdates --- packages/state-transition/src/cache/epochCache.ts | 4 ++-- .../src/cache/epochTransitionCache.ts | 4 ++-- .../src/epoch/processRegistryUpdates.ts | 15 +++++++++------ packages/state-transition/src/util/genesis.ts | 2 +- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/packages/state-transition/src/cache/epochCache.ts b/packages/state-transition/src/cache/epochCache.ts index e61fe751f3dd..804f606ab76a 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 4a8fa7286d6c..537d84f3cdbb 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 14ae1cfaa531..d9ff7bd63d0b 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 797ca7cc1aee..537edc7f976f 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);