From 15220ae56587bf925154d1ed47f02e6124f4a081 Mon Sep 17 00:00:00 2001 From: Paul Hauner Date: Mon, 9 Sep 2019 01:55:43 -0400 Subject: [PATCH] Fix minor vec access panic opportunity --- .../src/per_block_processing/signature_sets.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/eth2/state_processing/src/per_block_processing/signature_sets.rs b/eth2/state_processing/src/per_block_processing/signature_sets.rs index dec529247..4f1a06670 100644 --- a/eth2/state_processing/src/per_block_processing/signature_sets.rs +++ b/eth2/state_processing/src/per_block_processing/signature_sets.rs @@ -42,8 +42,12 @@ pub fn block_proposal_signature_set<'a, T: EthSpec>( block_signed_root: Option, spec: &'a ChainSpec, ) -> Result> { - let block_proposer = &state.validators - [state.get_beacon_proposer_index(block.slot, RelativeEpoch::Current, spec)?]; + let proposer_index = + state.get_beacon_proposer_index(block.slot, RelativeEpoch::Current, spec)?; + let block_proposer = &state + .validators + .get(proposer_index) + .ok_or_else(|| Error::ValidatorUnknown(proposer_index as u64))?; let domain = spec.get_domain( block.slot.epoch(T::slots_per_epoch()),