mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-07 00:42:42 +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)?;
|
state.build_exit_cache(spec)?;
|
||||||
|
|
||||||
// Compute exit queue epoch
|
// Compute exit queue epoch
|
||||||
let delayed_epoch = state.compute_activation_exit_epoch(state.current_epoch(), spec)?;
|
let exit_queue_epoch = if state.fork_name_unchecked() >= ForkName::Electra {
|
||||||
let mut exit_queue_epoch = state
|
let effective_balance = state.get_validator(index)?.effective_balance;
|
||||||
.exit_cache()
|
state.compute_exit_epoch_and_update_churn(effective_balance, spec)?
|
||||||
.max_epoch()?
|
} else {
|
||||||
.map_or(delayed_epoch, |epoch| max(epoch, delayed_epoch));
|
let delayed_epoch = state.compute_activation_exit_epoch(state.current_epoch(), spec)?;
|
||||||
let exit_queue_churn = state.exit_cache().get_churn_at(exit_queue_epoch)?;
|
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)? {
|
if exit_queue_churn >= state.get_validator_churn_limit(spec)? {
|
||||||
exit_queue_epoch.safe_add_assign(1)?;
|
exit_queue_epoch.safe_add_assign(1)?;
|
||||||
}
|
}
|
||||||
|
exit_queue_epoch
|
||||||
|
};
|
||||||
|
|
||||||
let validator = state.get_validator_cow(index)?;
|
let validator = state.get_validator_cow(index)?;
|
||||||
|
|
||||||
|
|||||||
@@ -451,7 +451,10 @@ pub enum ExitInvalid {
|
|||||||
/// The specified validator has already initiated exit.
|
/// The specified validator has already initiated exit.
|
||||||
AlreadyInitiatedExit(u64),
|
AlreadyInitiatedExit(u64),
|
||||||
/// The exit is for a future epoch.
|
/// 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.
|
/// The validator has not been active for long enough.
|
||||||
TooYoungToExit {
|
TooYoungToExit {
|
||||||
current_epoch: Epoch,
|
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
|
/// There was an error whilst attempting to get a set of signatures. The signatures may have
|
||||||
/// been invalid or an internal error occurred.
|
/// been invalid or an internal error occurred.
|
||||||
SignatureSetError(SignatureSetError),
|
SignatureSetError(SignatureSetError),
|
||||||
|
PendingWithdrawalInQueue(u64),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Clone)]
|
#[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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user