From a9b079fa941a238b7b92ffa5df2d1bea5076614b Mon Sep 17 00:00:00 2001 From: Stefan Bratanov Date: Wed, 11 Dec 2024 08:58:26 +0000 Subject: [PATCH] feedback --- .../helpers/BeaconStateAccessorsElectra.java | 13 ------------- .../epoch/EpochProcessorElectra.java | 12 ++++++++---- 2 files changed, 8 insertions(+), 17 deletions(-) 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++; }