mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-15 10:52:43 +00:00
exit updates
This commit is contained in:
@@ -19,16 +19,22 @@ pub fn initiate_validator_exit<E: EthSpec>(
|
||||
state.build_exit_cache(spec)?;
|
||||
|
||||
// Compute exit queue epoch
|
||||
let delayed_epoch = state.compute_activation_exit_epoch(state.current_epoch(), spec)?;
|
||||
let mut exit_queue_epoch = state
|
||||
.exit_cache()
|
||||
.max_epoch()?
|
||||
.map_or(delayed_epoch, |epoch| max(epoch, delayed_epoch));
|
||||
let exit_queue_churn = state.exit_cache().get_churn_at(exit_queue_epoch)?;
|
||||
let exit_queue_epoch = if state.fork_name_unchecked() >= ForkName::Electra {
|
||||
let effective_balance = state.get_validator(index)?.effective_balance;
|
||||
state.compute_exit_epoch_and_update_churn(effective_balance, spec)?
|
||||
} else {
|
||||
let delayed_epoch = state.compute_activation_exit_epoch(state.current_epoch(), spec)?;
|
||||
let mut exit_queue_epoch = state
|
||||
.exit_cache()
|
||||
.max_epoch()?
|
||||
.map_or(delayed_epoch, |epoch| max(epoch, delayed_epoch));
|
||||
let exit_queue_churn = state.exit_cache().get_churn_at(exit_queue_epoch)?;
|
||||
|
||||
if exit_queue_churn >= state.get_validator_churn_limit(spec)? {
|
||||
exit_queue_epoch.safe_add_assign(1)?;
|
||||
}
|
||||
if exit_queue_churn >= state.get_validator_churn_limit(spec)? {
|
||||
exit_queue_epoch.safe_add_assign(1)?;
|
||||
}
|
||||
exit_queue_epoch
|
||||
};
|
||||
|
||||
let validator = state.get_validator_cow(index)?;
|
||||
|
||||
|
||||
@@ -451,7 +451,10 @@ pub enum ExitInvalid {
|
||||
/// The specified validator has already initiated exit.
|
||||
AlreadyInitiatedExit(u64),
|
||||
/// The exit is for a future epoch.
|
||||
FutureEpoch { state: Epoch, exit: Epoch },
|
||||
FutureEpoch {
|
||||
state: Epoch,
|
||||
exit: Epoch,
|
||||
},
|
||||
/// The validator has not been active for long enough.
|
||||
TooYoungToExit {
|
||||
current_epoch: Epoch,
|
||||
@@ -462,6 +465,7 @@ pub enum ExitInvalid {
|
||||
/// There was an error whilst attempting to get a set of signatures. The signatures may have
|
||||
/// been invalid or an internal error occurred.
|
||||
SignatureSetError(SignatureSetError),
|
||||
PendingWithdrawalInQueue(u64),
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
|
||||
@@ -79,5 +79,16 @@ pub fn verify_exit<E: EthSpec>(
|
||||
);
|
||||
}
|
||||
|
||||
// [New in Electra:EIP7251]
|
||||
// Only exit validator if it has no pending withdrawals in the queue
|
||||
if let Ok(pending_balance_to_withdraw) =
|
||||
state.get_pending_balance_to_withdraw(exit.validator_index as usize)
|
||||
{
|
||||
verify!(
|
||||
pending_balance_to_withdraw == 0,
|
||||
ExitInvalid::PendingWithdrawalInQueue(exit.validator_index)
|
||||
);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user