mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-19 05:48:31 +00:00
Remove queue_entire_balance_and_reset_validator
This commit is contained in:
@@ -2,7 +2,7 @@ use safe_arith::SafeArith;
|
|||||||
use std::mem;
|
use std::mem;
|
||||||
use types::{
|
use types::{
|
||||||
BeaconState, BeaconStateElectra, BeaconStateError as Error, ChainSpec, Epoch, EpochCache,
|
BeaconState, BeaconStateElectra, BeaconStateError as Error, ChainSpec, Epoch, EpochCache,
|
||||||
EthSpec, Fork,
|
EthSpec, Fork, PendingBalanceDeposit,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Transform a `Deneb` state into an `Electra` state.
|
/// 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
|
// Process validators to queue entire balance and reset them
|
||||||
for (index, _) in pre_activation {
|
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
|
// Ensure early adopters of compounding credentials go through the activation churn
|
||||||
|
|||||||
@@ -2156,33 +2156,6 @@ impl<E: EthSpec> BeaconState<E> {
|
|||||||
Ok(())
|
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.
|
/// Change the withdrawal prefix of the given `validator_index` to the compounding withdrawal validator prefix.
|
||||||
pub fn switch_to_compounding_validator(
|
pub fn switch_to_compounding_validator(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
|||||||
Reference in New Issue
Block a user