Remove queue_entire_balance_and_reset_validator

This commit is contained in:
Pawan Dhananjay
2024-10-10 13:57:42 -07:00
parent 3fa7790e0d
commit 3d595e6c0f
2 changed files with 21 additions and 29 deletions

View File

@@ -2,7 +2,7 @@ use safe_arith::SafeArith;
use std::mem;
use types::{
BeaconState, BeaconStateElectra, BeaconStateError as Error, ChainSpec, Epoch, EpochCache,
EthSpec, Fork,
EthSpec, Fork, PendingBalanceDeposit,
};
/// Transform a `Deneb` state into an `Electra` state.
@@ -57,7 +57,26 @@ pub fn upgrade_to_electra<E: EthSpec>(
// Process validators to queue entire balance and reset them
for (index, _) in pre_activation {
post.queue_entire_balance_and_reset_validator(index, spec)?;
let balance = post
.balances_mut()
.get_mut(index)
.ok_or(Error::UnknownValidator(index))?;
let balance_copy = *balance;
*balance = 0_u64;
let validator = post
.validators_mut()
.get_mut(index)
.ok_or(Error::UnknownValidator(index))?;
validator.effective_balance = 0;
validator.activation_eligibility_epoch = spec.far_future_epoch;
post.pending_balance_deposits_mut()?
.push(PendingBalanceDeposit {
index: index as u64,
amount: balance_copy,
})
.map_err(Error::MilhouseError)?;
}
// Ensure early adopters of compounding credentials go through the activation churn

View File

@@ -2156,33 +2156,6 @@ impl<E: EthSpec> BeaconState<E> {
Ok(())
}
pub fn queue_entire_balance_and_reset_validator(
&mut self,
validator_index: usize,
spec: &ChainSpec,
) -> Result<(), Error> {
let balance = self
.balances_mut()
.get_mut(validator_index)
.ok_or(Error::UnknownValidator(validator_index))?;
let balance_copy = *balance;
*balance = 0_u64;
let validator = self
.validators_mut()
.get_mut(validator_index)
.ok_or(Error::UnknownValidator(validator_index))?;
validator.effective_balance = 0;
validator.activation_eligibility_epoch = spec.far_future_epoch;
self.pending_balance_deposits_mut()?
.push(PendingBalanceDeposit {
index: validator_index as u64,
amount: balance_copy,
})
.map_err(Into::into)
}
/// Change the withdrawal prefix of the given `validator_index` to the compounding withdrawal validator prefix.
pub fn switch_to_compounding_validator(
&mut self,