Check proposer index during block production (#2740)

## Issue Addressed

Resolves #2612 

## Proposed Changes

Implements both the checks mentioned in the original issue. 
1. Verifies the `randao_reveal` in the beacon node
2. Cross checks the proposer index after getting back the block from the beacon node.

## Additional info
The block production time increases by ~10x because of the signature verification on the beacon node (based on the `beacon_block_production_process_seconds` metric) when running on a local testnet.
This commit is contained in:
Pawan Dhananjay
2021-11-01 07:44:40 +00:00
parent ffb04e1a9e
commit 4499adc7fd
3 changed files with 18 additions and 2 deletions

View File

@@ -259,6 +259,7 @@ impl<T: SlotClock + 'static, E: EthSpec> BlockService<T, E> {
let randao_reveal_ref = &randao_reveal;
let self_ref = &self;
let proposer_index = self.validator_store.validator_index(&validator_pubkey);
let validator_pubkey_ref = &validator_pubkey;
let signed_block = self
.beacon_nodes
@@ -274,6 +275,13 @@ impl<T: SlotClock + 'static, E: EthSpec> BlockService<T, E> {
.data;
drop(get_timer);
if proposer_index != Some(block.proposer_index()) {
return Err(
"Proposer index does not match block proposer. Beacon chain re-orged"
.to_string(),
);
}
let signed_block = self_ref
.validator_store
.sign_block(*validator_pubkey_ref, block, current_slot)