mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-22 22:34:45 +00:00
Merge remote-tracking branch 'origin/unstable' into tree-states
This commit is contained in:
@@ -47,7 +47,6 @@ pub fn process_epoch<T: EthSpec>(
|
||||
process_slashings(
|
||||
state,
|
||||
participation_cache.current_epoch_total_active_balance(),
|
||||
spec.proportional_slashing_multiplier_altair,
|
||||
spec,
|
||||
)?;
|
||||
|
||||
|
||||
@@ -119,7 +119,7 @@ pub fn get_inactivity_penalty_deltas<T: EthSpec>(
|
||||
.safe_mul(state.get_inactivity_score(index)?)?;
|
||||
let penalty_denominator = spec
|
||||
.inactivity_score_bias
|
||||
.safe_mul(spec.inactivity_penalty_quotient_altair)?;
|
||||
.safe_mul(spec.inactivity_penalty_quotient_for_state(state))?;
|
||||
delta.penalize(penalty_numerator.safe_div(penalty_denominator)?)?;
|
||||
}
|
||||
deltas
|
||||
|
||||
@@ -43,7 +43,6 @@ pub fn process_epoch<T: EthSpec>(
|
||||
process_slashings(
|
||||
state,
|
||||
validator_statuses.total_balances.current_epoch(),
|
||||
spec.proportional_slashing_multiplier,
|
||||
spec,
|
||||
)?;
|
||||
|
||||
|
||||
@@ -6,14 +6,15 @@ use types::{BeaconState, ChainSpec, EthSpec, GetBalanceMut, GetValidatorMut, Uns
|
||||
pub fn process_slashings<T: EthSpec>(
|
||||
state: &mut BeaconState<T>,
|
||||
total_balance: u64,
|
||||
slashing_multiplier: u64,
|
||||
spec: &ChainSpec,
|
||||
) -> Result<(), Error> {
|
||||
let epoch = state.current_epoch();
|
||||
let sum_slashings = state.get_all_slashings().iter().copied().safe_sum()?;
|
||||
|
||||
let adjusted_total_slashing_balance =
|
||||
std::cmp::min(sum_slashings.safe_mul(slashing_multiplier)?, total_balance);
|
||||
let adjusted_total_slashing_balance = std::cmp::min(
|
||||
sum_slashings.safe_mul(spec.proportional_slashing_multiplier_for_state(state))?,
|
||||
total_balance,
|
||||
);
|
||||
|
||||
let (validators, mut balances) = state.validators_and_balances_mut();
|
||||
for index in 0..validators.len() {
|
||||
|
||||
Reference in New Issue
Block a user