Correct issue with network message passing (#1439)

## Issue Addressed

Sync was breaking occasionally. The root cause appears to be identify crashing as events we being sent to the protocol after nodes were banned. Have not been able to reproduce sync issues since this update. 

## Proposed Changes

Only send messages to sub-behaviour protocols if the peer manager thinks the peer is connected. All other messages are dropped.
This commit is contained in:
Age Manning
2020-08-03 09:35:53 +00:00
parent 142e033c34
commit f634f073a8
5 changed files with 102 additions and 111 deletions

View File

@@ -146,7 +146,7 @@ impl<T: BeaconChainTypes> Router<T> {
request_id,
error,
} => {
warn!(self.log, "RPC Error";
debug!(self.log, "RPC Error";
"peer_id" => peer_id.to_string(),
"request_id" => request_id,
"error" => error.to_string(),

View File

@@ -819,10 +819,24 @@ impl<T: BeaconChainTypes> SyncingChain<T> {
batch: Batch<T::EthSpec>,
) {
let request = batch.to_blocks_by_range_request();
if let Ok(request_id) = network.blocks_by_range_request(batch.current_peer.clone(), request)
{
// add the batch to pending list
self.pending_batches.insert(request_id, batch);
match network.blocks_by_range_request(batch.current_peer.clone(), request) {
Ok(request_id) => {
// add the batch to pending list
self.pending_batches.insert(request_id, batch);
}
Err(e) => {
warn!(self.log, "Batch request failed";
"chain_id" => self.id,
"start_slot" => batch.start_slot,
"end_slot" => batch.end_slot -1, // The -1 shows inclusive blocks
"id" => *batch.id,
"peer" => format!("{}", batch.current_peer),
"retries" => batch.retries,
"error" => e,
"re-processes" => batch.reprocess_retries);
self.failed_batch(network, batch);
}
}
}
}