mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-15 02:42:38 +00:00
Minor refactorings
This commit is contained in:
@@ -600,9 +600,7 @@ pub fn get_expected_withdrawals<E: EthSpec>(
|
||||
address: validator
|
||||
.get_execution_withdrawal_address(spec)
|
||||
.ok_or(BlockProcessingError::WithdrawalCredentialsInvalid)?,
|
||||
amount: balance.safe_sub(
|
||||
validator.get_max_effective_balance(spec, state.fork_name_unchecked()),
|
||||
)?,
|
||||
amount: balance.safe_sub(validator.get_max_effective_balance(spec, fork_name))?,
|
||||
});
|
||||
withdrawal_index.safe_add_assign(1)?;
|
||||
}
|
||||
|
||||
@@ -2329,21 +2329,12 @@ impl<E: EthSpec> BeaconState<E> {
|
||||
| BeaconState::Bellatrix(_)
|
||||
| BeaconState::Capella(_)
|
||||
| BeaconState::Deneb(_) => Err(Error::IncorrectStateVariant),
|
||||
BeaconState::Electra(_) => {
|
||||
let state = self.as_electra_mut()?;
|
||||
|
||||
BeaconState::Electra(_) | BeaconState::Fulu(_) => {
|
||||
// Consume the balance and update state variables
|
||||
state.exit_balance_to_consume = exit_balance_to_consume.safe_sub(exit_balance)?;
|
||||
state.earliest_exit_epoch = earliest_exit_epoch;
|
||||
Ok(state.earliest_exit_epoch)
|
||||
}
|
||||
BeaconState::Fulu(_) => {
|
||||
let state = self.as_fulu_mut()?;
|
||||
|
||||
// Consume the balance and update state variables
|
||||
state.exit_balance_to_consume = exit_balance_to_consume.safe_sub(exit_balance)?;
|
||||
state.earliest_exit_epoch = earliest_exit_epoch;
|
||||
Ok(state.earliest_exit_epoch)
|
||||
*self.exit_balance_to_consume_mut()? =
|
||||
exit_balance_to_consume.safe_sub(exit_balance)?;
|
||||
*self.earliest_exit_epoch_mut()? = earliest_exit_epoch;
|
||||
self.earliest_exit_epoch()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2385,23 +2376,12 @@ impl<E: EthSpec> BeaconState<E> {
|
||||
| BeaconState::Bellatrix(_)
|
||||
| BeaconState::Capella(_)
|
||||
| BeaconState::Deneb(_) => Err(Error::IncorrectStateVariant),
|
||||
BeaconState::Electra(_) => {
|
||||
let state = self.as_electra_mut()?;
|
||||
|
||||
BeaconState::Electra(_) | BeaconState::Fulu(_) => {
|
||||
// Consume the balance and update state variables.
|
||||
state.consolidation_balance_to_consume =
|
||||
*self.consolidation_balance_to_consume_mut()? =
|
||||
consolidation_balance_to_consume.safe_sub(consolidation_balance)?;
|
||||
state.earliest_consolidation_epoch = earliest_consolidation_epoch;
|
||||
Ok(state.earliest_consolidation_epoch)
|
||||
}
|
||||
BeaconState::Fulu(_) => {
|
||||
let state = self.as_fulu_mut()?;
|
||||
|
||||
// Consume the balance and update state variables.
|
||||
state.consolidation_balance_to_consume =
|
||||
consolidation_balance_to_consume.safe_sub(consolidation_balance)?;
|
||||
state.earliest_consolidation_epoch = earliest_consolidation_epoch;
|
||||
Ok(state.earliest_consolidation_epoch)
|
||||
*self.earliest_consolidation_epoch_mut()? = earliest_consolidation_epoch;
|
||||
self.earliest_consolidation_epoch()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user