Correct parent lookup (#1027)

* Correct parent-lookup with block gossip verification

* Further update port conflicts in tests
This commit is contained in:
Age Manning
2020-04-20 16:54:37 +10:00
committed by GitHub
parent 2d3acadfb5
commit 7acb136974
5 changed files with 154 additions and 153 deletions

View File

@@ -490,9 +490,17 @@ impl<T: BeaconChainTypes> Processor<T> {
/// across the network.
pub fn should_forward_block(
&mut self,
peer_id: &PeerId,
block: Box<SignedBeaconBlock<T::EthSpec>>,
) -> Result<GossipVerifiedBlock<T>, BlockError> {
self.chain.verify_block_for_gossip(*block)
let result = self.chain.verify_block_for_gossip(*block.clone());
if let Err(BlockError::ParentUnknown(_)) = result {
// if we don't know the parent, start a parent lookup
// TODO: Modify the return to avoid the block clone.
self.send_to_sync(SyncMessage::UnknownBlock(peer_id.clone(), block));
}
result
}
/// Process a gossip message declaring a new block.
@@ -534,7 +542,8 @@ impl<T: BeaconChainTypes> Processor<T> {
}
BlockProcessingOutcome::ParentUnknown { .. } => {
// Inform the sync manager to find parents for this block
debug!(self.log, "Block with unknown parent received";
// This should not occur. It should be checked by `should_forward_block`
error!(self.log, "Block with unknown parent attempted to be processed";
"peer_id" => format!("{:?}",peer_id));
self.send_to_sync(SyncMessage::UnknownBlock(peer_id, block));
}