From 9cec5dc073ae4fa4608b787c1b624589add92fd0 Mon Sep 17 00:00:00 2001 From: Michael Sproul Date: Mon, 17 Jun 2019 17:20:28 +1000 Subject: [PATCH] process slashings: fix subtraction overflow --- .../src/per_epoch_processing/process_slashings.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eth2/state_processing/src/per_epoch_processing/process_slashings.rs b/eth2/state_processing/src/per_epoch_processing/process_slashings.rs index 3213b3230..d17dd1622 100644 --- a/eth2/state_processing/src/per_epoch_processing/process_slashings.rs +++ b/eth2/state_processing/src/per_epoch_processing/process_slashings.rs @@ -15,8 +15,8 @@ pub fn process_slashings( let total_penalities = total_at_end - total_at_start; for (index, validator) in state.validator_registry.iter().enumerate() { - let should_penalize = current_epoch.as_usize() - == validator.withdrawable_epoch.as_usize() - T::LatestSlashedExitLength::to_usize() / 2; + let should_penalize = current_epoch.as_usize() + T::LatestSlashedExitLength::to_usize() / 2 + == validator.withdrawable_epoch.as_usize(); if validator.slashed && should_penalize { let effective_balance = state.get_effective_balance(index, spec)?;