From 12296dc400beb3cad74aa98539dffbb82c4e71fa Mon Sep 17 00:00:00 2001 From: Tuyen Nguyen Date: Fri, 23 Aug 2024 09:35:11 +0700 Subject: [PATCH] fix: effectiveBalanceLimit should be per validator --- .../src/epoch/processEffectiveBalanceUpdates.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/packages/state-transition/src/epoch/processEffectiveBalanceUpdates.ts b/packages/state-transition/src/epoch/processEffectiveBalanceUpdates.ts index fe20c0d6e0ca..0ea4b49dddf4 100644 --- a/packages/state-transition/src/epoch/processEffectiveBalanceUpdates.ts +++ b/packages/state-transition/src/epoch/processEffectiveBalanceUpdates.ts @@ -47,10 +47,6 @@ export function processEffectiveBalanceUpdates( const balances = cache.balances ?? state.balances.getAll(); const currentEpochValidators = cache.validators; const newCompoundingValidators = cache.newCompoundingValidators ?? new Set(); - let effectiveBalanceLimit: number | null = null; - if (fork < ForkSeq.electra) { - effectiveBalanceLimit = MAX_EFFECTIVE_BALANCE; - } let numUpdate = 0; for (let i = 0, len = balances.length; i < len; i++) { @@ -60,8 +56,11 @@ export function processEffectiveBalanceUpdates( let effectiveBalanceIncrement = effectiveBalanceIncrements[i]; let effectiveBalance = effectiveBalanceIncrement * EFFECTIVE_BALANCE_INCREMENT; - // from electra - if (effectiveBalanceLimit === null) { + let effectiveBalanceLimit: number; + if (fork < ForkSeq.electra) { + effectiveBalanceLimit = MAX_EFFECTIVE_BALANCE; + } else { + // from electra, effectiveBalanceLimit is per validator const isCompoundingValidator = hasCompoundingWithdrawalCredential(currentEpochValidators[i].withdrawalCredentials) || newCompoundingValidators.has(i);