diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/electra/helpers/BeaconStateAccessorsElectra.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/electra/helpers/BeaconStateAccessorsElectra.java index a4dc616877f..0c48f640f3c 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/electra/helpers/BeaconStateAccessorsElectra.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/electra/helpers/BeaconStateAccessorsElectra.java @@ -21,7 +21,6 @@ import tech.pegasys.teku.spec.config.SpecConfig; import tech.pegasys.teku.spec.config.SpecConfigDeneb; import tech.pegasys.teku.spec.config.SpecConfigElectra; -import tech.pegasys.teku.spec.datastructures.state.Validator; import tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState; import tech.pegasys.teku.spec.datastructures.state.beaconstate.versions.electra.BeaconStateElectra; import tech.pegasys.teku.spec.datastructures.state.versions.electra.PendingPartialWithdrawal; @@ -52,18 +51,6 @@ public UInt64 getActivationExitChurnLimit(final BeaconStateElectra state) { return getBalanceChurnLimit(state).min(configElectra.getMaxPerEpochActivationExitChurnLimit()); } - /** - * get_active_balance - * - * @param state The state to get the effective balance from - * @param validatorIndex the index of the validator - */ - public UInt64 getActiveBalance(final BeaconState state, final int validatorIndex) { - final Validator validator = state.getValidators().get(validatorIndex); - final UInt64 validatorBalance = state.getBalances().get(validatorIndex).get(); - return validatorBalance.min(validator.getEffectiveBalance()); - } - /** * get_pending_balance_to_withdraw * diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/electra/statetransition/epoch/EpochProcessorElectra.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/electra/statetransition/epoch/EpochProcessorElectra.java index 0852fcdc7d4..dd9e716baf6 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/electra/statetransition/epoch/EpochProcessorElectra.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/versions/electra/statetransition/epoch/EpochProcessorElectra.java @@ -323,13 +323,17 @@ public void processPendingConsolidations(final MutableBeaconState state) { } // Calculate the consolidated balance - final UInt64 activeBalance = - stateAccessorsElectra.getActiveBalance(state, pendingConsolidation.getSourceIndex()); + final UInt64 sourceEffectiveBalance = + state + .getBalances() + .get(pendingConsolidation.getSourceIndex()) + .get() + .min(sourceValidator.getEffectiveBalance()); // Move active balance to target. Excess balance is withdrawable. beaconStateMutators.decreaseBalance( - state, pendingConsolidation.getSourceIndex(), activeBalance); + state, pendingConsolidation.getSourceIndex(), sourceEffectiveBalance); beaconStateMutators.increaseBalance( - state, pendingConsolidation.getTargetIndex(), activeBalance); + state, pendingConsolidation.getTargetIndex(), sourceEffectiveBalance); nextPendingBalanceConsolidation++; }