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