state_proc: verify sig in process_block_header

This commit is contained in:
Michael Sproul 2019-06-04 16:37:36 +10:00
parent c05cf6c256
commit 49e19e2b7d
No known key found for this signature in database
GPG Key ID: 77B1309D2E54E914

View File

@ -77,15 +77,12 @@ fn per_block_processing_signature_optional<T: EthSpec>(
should_verify_block_signature: bool, should_verify_block_signature: bool,
spec: &ChainSpec, spec: &ChainSpec,
) -> Result<(), Error> { ) -> Result<(), Error> {
process_block_header(state, block, spec)?; process_block_header(state, block, spec, should_verify_block_signature)?;
// Ensure the current and previous epoch caches are built. // Ensure the current and previous epoch caches are built.
state.build_committee_cache(RelativeEpoch::Previous, spec)?; state.build_committee_cache(RelativeEpoch::Previous, spec)?;
state.build_committee_cache(RelativeEpoch::Current, spec)?; state.build_committee_cache(RelativeEpoch::Current, spec)?;
if should_verify_block_signature {
verify_block_signature(&state, &block, &spec)?;
}
process_randao(&mut state, &block, &spec)?; process_randao(&mut state, &block, &spec)?;
process_eth1_data(&mut state, &block.body.eth1_data, spec)?; process_eth1_data(&mut state, &block.body.eth1_data, spec)?;
process_proposer_slashings(&mut state, &block.body.proposer_slashings, spec)?; process_proposer_slashings(&mut state, &block.body.proposer_slashings, spec)?;
@ -105,6 +102,7 @@ pub fn process_block_header<T: EthSpec>(
state: &mut BeaconState<T>, state: &mut BeaconState<T>,
block: &BeaconBlock, block: &BeaconBlock,
spec: &ChainSpec, spec: &ChainSpec,
should_verify_block_signature: bool,
) -> Result<(), Error> { ) -> Result<(), Error> {
verify!(block.slot == state.slot, Invalid::StateSlotMismatch); verify!(block.slot == state.slot, Invalid::StateSlotMismatch);
@ -125,6 +123,10 @@ pub fn process_block_header<T: EthSpec>(
let proposer = &state.validator_registry[proposer_idx]; let proposer = &state.validator_registry[proposer_idx];
verify!(!proposer.slashed, Invalid::ProposerSlashed(proposer_idx)); verify!(!proposer.slashed, Invalid::ProposerSlashed(proposer_idx));
if should_verify_block_signature {
verify_block_signature(&state, &block, &spec)?;
}
Ok(()) Ok(())
} }