process slashings: fix subtraction overflow

This commit is contained in:
Michael Sproul 2019-06-17 17:20:28 +10:00
parent 03c50354f4
commit 9cec5dc073
No known key found for this signature in database
GPG Key ID: 77B1309D2E54E914

View File

@ -15,8 +15,8 @@ pub fn process_slashings<T: EthSpec>(
let total_penalities = total_at_end - total_at_start; let total_penalities = total_at_end - total_at_start;
for (index, validator) in state.validator_registry.iter().enumerate() { for (index, validator) in state.validator_registry.iter().enumerate() {
let should_penalize = current_epoch.as_usize() let should_penalize = current_epoch.as_usize() + T::LatestSlashedExitLength::to_usize() / 2
== validator.withdrawable_epoch.as_usize() - T::LatestSlashedExitLength::to_usize() / 2; == validator.withdrawable_epoch.as_usize();
if validator.slashed && should_penalize { if validator.slashed && should_penalize {
let effective_balance = state.get_effective_balance(index, spec)?; let effective_balance = state.get_effective_balance(index, spec)?;