From 2f72904a77394f5a2636324ec7a453701f3178a3 Mon Sep 17 00:00:00 2001 From: NC <17676176+ensi321@users.noreply.github.com> Date: Fri, 6 Sep 2024 15:02:35 -0700 Subject: [PATCH 1/2] Rename getValidatorMaxEffectiveBalance --- packages/state-transition/src/block/processWithdrawals.ts | 4 ++-- packages/state-transition/src/util/genesis.ts | 4 ++-- packages/state-transition/src/util/validator.ts | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/state-transition/src/block/processWithdrawals.ts b/packages/state-transition/src/block/processWithdrawals.ts index 185ddd80eb3..62db88774ce 100644 --- a/packages/state-transition/src/block/processWithdrawals.ts +++ b/packages/state-transition/src/block/processWithdrawals.ts @@ -14,7 +14,7 @@ import {toRootHex} from "@lodestar/utils"; import {CachedBeaconStateCapella, CachedBeaconStateElectra} from "../types.js"; import { decreaseBalance, - getValidatorMaxEffectiveBalance, + getMaxEffectiveBalance, hasEth1WithdrawalCredential, hasExecutionWithdrawalCredential, isCapellaPayloadHeader, @@ -174,7 +174,7 @@ export function getExpectedWithdrawals( withdrawalIndex++; } else if ( effectiveBalance === - (isPostElectra ? getValidatorMaxEffectiveBalance(withdrawalCredentials) : MAX_EFFECTIVE_BALANCE) && + (isPostElectra ? getMaxEffectiveBalance(withdrawalCredentials) : MAX_EFFECTIVE_BALANCE) && balance > effectiveBalance ) { // capella partial withdrawal diff --git a/packages/state-transition/src/util/genesis.ts b/packages/state-transition/src/util/genesis.ts index 02bcef00bb5..54507d0ef23 100644 --- a/packages/state-transition/src/util/genesis.ts +++ b/packages/state-transition/src/util/genesis.ts @@ -18,7 +18,7 @@ import {EpochCacheImmutableData} from "../cache/epochCache.js"; import {processDeposit} from "../block/processDeposit.js"; import {increaseBalance} from "../index.js"; import {computeEpochAtSlot} from "./epoch.js"; -import {getActiveValidatorIndices, getValidatorMaxEffectiveBalance} from "./validator.js"; +import {getActiveValidatorIndices, getMaxEffectiveBalance} from "./validator.js"; import {getTemporaryBlockHeader} from "./blockRoot.js"; import {newFilledArray} from "./array.js"; import {getNextSyncCommittee} from "./syncCommittee.js"; @@ -195,7 +195,7 @@ export function applyDeposits( const balance = balancesArr[i]; const effectiveBalance = Math.min( balance - (balance % EFFECTIVE_BALANCE_INCREMENT), - getValidatorMaxEffectiveBalance(validator.withdrawalCredentials) + getMaxEffectiveBalance(validator.withdrawalCredentials) ); validator.effectiveBalance = effectiveBalance; diff --git a/packages/state-transition/src/util/validator.ts b/packages/state-transition/src/util/validator.ts index 728f14587fd..ebad21d9d25 100644 --- a/packages/state-transition/src/util/validator.ts +++ b/packages/state-transition/src/util/validator.ts @@ -75,7 +75,7 @@ export function getConsolidationChurnLimit(epochCtx: EpochCache): number { return getBalanceChurnLimit(epochCtx) - getActivationExitChurnLimit(epochCtx); } -export function getValidatorMaxEffectiveBalance(withdrawalCredentials: Uint8Array): number { +export function getMaxEffectiveBalance(withdrawalCredentials: Uint8Array): number { // Compounding withdrawal credential only available since Electra if (hasCompoundingWithdrawalCredential(withdrawalCredentials)) { return MAX_EFFECTIVE_BALANCE_ELECTRA; @@ -85,7 +85,7 @@ export function getValidatorMaxEffectiveBalance(withdrawalCredentials: Uint8Arra } export function getActiveBalance(state: CachedBeaconStateElectra, validatorIndex: ValidatorIndex): number { - const validatorMaxEffectiveBalance = getValidatorMaxEffectiveBalance( + const validatorMaxEffectiveBalance = getMaxEffectiveBalance( state.validators.getReadonly(validatorIndex).withdrawalCredentials ); From 1f42b8a3799edc2f6c3ce9ed36872b003ecf526b Mon Sep 17 00:00:00 2001 From: NC <17676176+ensi321@users.noreply.github.com> Date: Sat, 7 Sep 2024 09:21:16 -0700 Subject: [PATCH 2/2] Lint --- packages/state-transition/src/block/processWithdrawals.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/state-transition/src/block/processWithdrawals.ts b/packages/state-transition/src/block/processWithdrawals.ts index 62db88774ce..d4dfd47b4d9 100644 --- a/packages/state-transition/src/block/processWithdrawals.ts +++ b/packages/state-transition/src/block/processWithdrawals.ts @@ -173,8 +173,7 @@ export function getExpectedWithdrawals( }); withdrawalIndex++; } else if ( - effectiveBalance === - (isPostElectra ? getMaxEffectiveBalance(withdrawalCredentials) : MAX_EFFECTIVE_BALANCE) && + effectiveBalance === (isPostElectra ? getMaxEffectiveBalance(withdrawalCredentials) : MAX_EFFECTIVE_BALANCE) && balance > effectiveBalance ) { // capella partial withdrawal