Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: rename getValidatorMaxEffectiveBalance #7070

Merged
merged 2 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions packages/state-transition/src/block/processWithdrawals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {toRootHex} from "@lodestar/utils";
import {CachedBeaconStateCapella, CachedBeaconStateElectra} from "../types.js";
import {
decreaseBalance,
getValidatorMaxEffectiveBalance,
getMaxEffectiveBalance,
hasEth1WithdrawalCredential,
hasExecutionWithdrawalCredential,
isCapellaPayloadHeader,
Expand Down Expand Up @@ -173,8 +173,7 @@ export function getExpectedWithdrawals(
});
withdrawalIndex++;
} else if (
effectiveBalance ===
(isPostElectra ? getValidatorMaxEffectiveBalance(withdrawalCredentials) : MAX_EFFECTIVE_BALANCE) &&
effectiveBalance === (isPostElectra ? getMaxEffectiveBalance(withdrawalCredentials) : MAX_EFFECTIVE_BALANCE) &&
balance > effectiveBalance
) {
// capella partial withdrawal
Expand Down
4 changes: 2 additions & 2 deletions packages/state-transition/src/util/genesis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions packages/state-transition/src/util/validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
);

Expand Down
Loading