Skip to content

Commit

Permalink
feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanBratanov committed Dec 12, 2024
1 parent a539083 commit 8441b42
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
}
Expand Down

0 comments on commit 8441b42

Please sign in to comment.