From 836eaf559baff48b8f7e0edf90e588e8d78033fc Mon Sep 17 00:00:00 2001 From: Paul Hauner Date: Mon, 16 Nov 2020 06:28:09 +0000 Subject: [PATCH] Check whistle-blower index (#1911) ## Issue Addressed - Resolves #1910 ## Proposed Changes See #1910 ## Additional Info NA --- consensus/state_processing/src/common/slash_validator.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/consensus/state_processing/src/common/slash_validator.rs b/consensus/state_processing/src/common/slash_validator.rs index 0b0874819..a5e5604e8 100644 --- a/consensus/state_processing/src/common/slash_validator.rs +++ b/consensus/state_processing/src/common/slash_validator.rs @@ -45,6 +45,13 @@ pub fn slash_validator( validator_effective_balance.safe_div(spec.whistleblower_reward_quotient)?; let proposer_reward = whistleblower_reward.safe_div(spec.proposer_reward_quotient)?; + // Ensure the whistleblower index is in the validator registry. + if state.validators.get(whistleblower_index).is_none() { + return Err(BeaconStateError::UnknownValidator( + whistleblower_index as u64, + )); + } + increase_balance(state, proposer_index, proposer_reward)?; increase_balance( state,