@@ -671,13 +671,16 @@ pub fn signature_verify_chain_segment<T: BeaconChainTypes>(
671671 let pubkey_cache = get_validator_pubkey_cache ( chain) ?;
672672 let mut signature_verifier = get_signature_verifier ( & state, & pubkey_cache, & chain. spec ) ;
673673 for svb in & mut signature_verified_blocks {
674- signature_verifier. include_all_signatures ( svb. block . as_block ( ) , & mut svb. consensus_context ) ?;
674+ signature_verifier
675+ . include_all_signatures ( svb. block . as_block ( ) , & mut svb. consensus_context ) ?;
675676 }
676677
677678 if signature_verifier. verify ( ) . is_err ( ) {
678679 return Err ( BlockError :: InvalidSignature ( InvalidSignature :: Unknown ) ) ;
679680 }
680681
682+ drop ( pubkey_cache) ;
683+
681684 if let Some ( signature_verified_block) = signature_verified_blocks. first_mut ( ) {
682685 signature_verified_block. parent = Some ( parent) ;
683686 }
@@ -974,17 +977,19 @@ impl<T: BeaconChainTypes> GossipVerifiedBlock<T> {
974977 let expected_proposer = proposer. index ;
975978 let fork = proposer. fork ;
976979
977- let pubkey_cache = get_validator_pubkey_cache ( chain) ?;
978- let pubkey = pubkey_cache
979- . get ( block. message ( ) . proposer_index ( ) as usize )
980- . ok_or_else ( || BlockError :: UnknownValidator ( block. message ( ) . proposer_index ( ) ) ) ?;
981- let signature_is_valid = block. verify_signature (
982- Some ( block_root) ,
983- pubkey,
984- & fork,
985- chain. genesis_validators_root ,
986- & chain. spec ,
987- ) ;
980+ let signature_is_valid = {
981+ let pubkey_cache = get_validator_pubkey_cache ( chain) ?;
982+ let pubkey = pubkey_cache
983+ . get ( block. message ( ) . proposer_index ( ) as usize )
984+ . ok_or_else ( || BlockError :: UnknownValidator ( block. message ( ) . proposer_index ( ) ) ) ?;
985+ block. verify_signature (
986+ Some ( block_root) ,
987+ pubkey,
988+ & fork,
989+ chain. genesis_validators_root ,
990+ & chain. spec ,
991+ )
992+ } ;
988993
989994 if !signature_is_valid {
990995 return Err ( BlockError :: InvalidSignature (
@@ -1116,14 +1121,14 @@ impl<T: BeaconChainTypes> SignatureVerifiedBlock<T> {
11161121
11171122 let pubkey_cache = get_validator_pubkey_cache ( chain) ?;
11181123
1124+ let mut signature_verifier = get_signature_verifier ( & state, & pubkey_cache, & chain. spec ) ;
1125+
11191126 let mut consensus_context =
11201127 ConsensusContext :: new ( block. slot ( ) ) . set_current_block_root ( block_root) ;
11211128
1122- let mut signature_verifier = get_signature_verifier ( & state, & pubkey_cache, & chain. spec ) ;
11231129 signature_verifier. include_all_signatures ( block. as_block ( ) , & mut consensus_context) ?;
1124- let signatures_valid = signature_verifier. verify ( ) . is_ok ( ) ;
11251130
1126- if signatures_valid {
1131+ if signature_verifier . verify ( ) . is_ok ( ) {
11271132 Ok ( Self {
11281133 consensus_context,
11291134 block,
0 commit comments