mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-11 18:04:18 +00:00
Remove all batches related to a peer on disconnect (#5969)
* Remove all batches related to a peer on disconnect * Cleanup map entries after disconnect * Allow lookups to continue in case of disconnections * Pretty response types * fmt * Fix lints * Remove lookup if it cannot progress * Fix tests * Remove poll_close on rpc behaviour * Remove redundant test * Fix issue raised by lion * Revert pretty response types * Cleanup * Fix test * Merge remote-tracking branch 'origin/release-v5.2.1' into rpc-error-on-disconnect-revert * Apply suggestions from joao Co-authored-by: João Oliveira <hello@jxs.pt> * Fix log * update request status on no peers found * Do not remove lookup after peer disconnection * Add comments about expected event api * Update single_block_lookup.rs * Update mod.rs * Merge branch 'rpc-error-on-disconnect-revert' into 5969-review * Merge pull request #10 from dapplion/5969-review Add comments about expected event api
This commit is contained in:
@@ -372,16 +372,39 @@ impl<T: BeaconChainTypes> SyncManager<T> {
|
||||
Err(_) => self.update_sync_state(),
|
||||
},
|
||||
}
|
||||
} else {
|
||||
debug!(
|
||||
self.log,
|
||||
"RPC error for range request has no associated entry in network context, ungraceful disconnect";
|
||||
"peer_id" => %peer_id,
|
||||
"request_id" => %id,
|
||||
"error" => ?error,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Handles a peer disconnect.
|
||||
///
|
||||
/// It is important that a peer disconnect retries all the batches/lookups as
|
||||
/// there is no way to guarantee that libp2p always emits a error along with
|
||||
/// the disconnect.
|
||||
fn peer_disconnect(&mut self, peer_id: &PeerId) {
|
||||
// Inject a Disconnected error on all requests associated with the disconnected peer
|
||||
// to retry all batches/lookups
|
||||
for request_id in self.network.peer_disconnected(peer_id) {
|
||||
self.inject_error(*peer_id, request_id, RPCError::Disconnected);
|
||||
}
|
||||
|
||||
// Remove peer from all data structures
|
||||
self.range_sync.peer_disconnect(&mut self.network, peer_id);
|
||||
let _ = self
|
||||
.backfill_sync
|
||||
.peer_disconnected(peer_id, &mut self.network);
|
||||
self.block_lookups.peer_disconnected(peer_id);
|
||||
|
||||
// Regardless of the outcome, we update the sync status.
|
||||
let _ = self.backfill_sync.peer_disconnected(peer_id);
|
||||
self.update_sync_state();
|
||||
}
|
||||
|
||||
@@ -951,7 +974,7 @@ impl<T: BeaconChainTypes> SyncManager<T> {
|
||||
self.network.insert_range_blocks_and_blobs_request(
|
||||
id,
|
||||
resp.sender_id,
|
||||
BlocksAndBlobsRequestInfo::new(resp.request_type),
|
||||
BlocksAndBlobsRequestInfo::new(resp.request_type, peer_id),
|
||||
);
|
||||
// inform range that the request needs to be treated as failed
|
||||
// With time we will want to downgrade this log
|
||||
|
||||
Reference in New Issue
Block a user