mirror of
https://github.com/sigp/lighthouse.git
synced 2026-07-03 12:54:27 +00:00
Re-add NoPeers error
This commit is contained in:
@@ -301,6 +301,14 @@ impl<T: BeaconChainTypes> BackFillSync<T> {
|
|||||||
|
|
||||||
pub fn peer_disconnected(&mut self, peer_id: &PeerId) {
|
pub fn peer_disconnected(&mut self, peer_id: &PeerId) {
|
||||||
self.peers.write().remove(peer_id);
|
self.peers.write().remove(peer_id);
|
||||||
|
|
||||||
|
if self.peers.read().is_empty() {
|
||||||
|
info!(
|
||||||
|
"reason" = "insufficient_synced_peers",
|
||||||
|
"Backfill sync paused"
|
||||||
|
);
|
||||||
|
self.set_state(BackFillState::Paused);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// An RPC error has occurred.
|
/// An RPC error has occurred.
|
||||||
@@ -946,6 +954,15 @@ impl<T: BeaconChainTypes> BackFillSync<T> {
|
|||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
Err(e) => match e {
|
Err(e) => match e {
|
||||||
|
RpcRequestSendError::NoPeers => {
|
||||||
|
// If we are here the chain has no more synced peers
|
||||||
|
info!(
|
||||||
|
"reason" = "insufficient_synced_peers",
|
||||||
|
"Backfill sync paused"
|
||||||
|
);
|
||||||
|
self.set_state(BackFillState::Paused);
|
||||||
|
return Err(BackFillError::Paused);
|
||||||
|
}
|
||||||
RpcRequestSendError::InternalError(e) => {
|
RpcRequestSendError::InternalError(e) => {
|
||||||
// NOTE: under normal conditions this shouldn't happen but we handle it anyway
|
// NOTE: under normal conditions this shouldn't happen but we handle it anyway
|
||||||
warn!(%batch_id, error = ?e, %batch,"Could not send batch request");
|
warn!(%batch_id, error = ?e, %batch,"Could not send batch request");
|
||||||
|
|||||||
@@ -98,6 +98,7 @@ pub enum RpcRequestSendError {
|
|||||||
// If RpcRequestSendError has a single variant `InternalError` it's to signal to downstream
|
// If RpcRequestSendError has a single variant `InternalError` it's to signal to downstream
|
||||||
// consumers that sends are expected to be infallible. If this assumption changes in the future,
|
// consumers that sends are expected to be infallible. If this assumption changes in the future,
|
||||||
// add a new variant.
|
// add a new variant.
|
||||||
|
NoPeers,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq)]
|
#[derive(Debug, PartialEq, Eq)]
|
||||||
|
|||||||
@@ -138,9 +138,7 @@ impl<T: BeaconChainTypes> BlockComponentsByRangeRequest<T> {
|
|||||||
else {
|
else {
|
||||||
// When a peer disconnects and is removed from the SyncingChain peer set, if the set
|
// When a peer disconnects and is removed from the SyncingChain peer set, if the set
|
||||||
// reaches zero the SyncingChain is removed.
|
// reaches zero the SyncingChain is removed.
|
||||||
return Err(RpcRequestSendError::InternalError(
|
return Err(RpcRequestSendError::NoPeers);
|
||||||
"A batch peer set should never be empty".to_string(),
|
|
||||||
));
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let blocks_req_id = cx.send_blocks_by_range_request(block_peer, request.clone(), id)?;
|
let blocks_req_id = cx.send_blocks_by_range_request(block_peer, request.clone(), id)?;
|
||||||
@@ -269,6 +267,10 @@ impl<T: BeaconChainTypes> BlockComponentsByRangeRequest<T> {
|
|||||||
RpcRequestSendError::InternalError(e) => {
|
RpcRequestSendError::InternalError(e) => {
|
||||||
Error::InternalError(e)
|
Error::InternalError(e)
|
||||||
}
|
}
|
||||||
|
RpcRequestSendError::NoPeers => Error::InternalError(
|
||||||
|
"send_custody_by_range_request does not error with NoPeers"
|
||||||
|
.to_owned(),
|
||||||
|
),
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
*state = FuluEnabledState::CustodyRequest {
|
*state = FuluEnabledState::CustodyRequest {
|
||||||
|
|||||||
@@ -957,7 +957,7 @@ impl<T: BeaconChainTypes> SyncingChain<T> {
|
|||||||
return Ok(KeepChain);
|
return Ok(KeepChain);
|
||||||
}
|
}
|
||||||
Err(e) => match e {
|
Err(e) => match e {
|
||||||
RpcRequestSendError::InternalError(e) => {
|
e @ (RpcRequestSendError::NoPeers | RpcRequestSendError::InternalError(_)) => {
|
||||||
// NOTE: under normal conditions this shouldn't happen but we handle it anyway
|
// NOTE: under normal conditions this shouldn't happen but we handle it anyway
|
||||||
warn!(%batch_id, error = ?e, "batch_id" = %batch_id, %batch, "Could not send batch request");
|
warn!(%batch_id, error = ?e, "batch_id" = %batch_id, %batch, "Could not send batch request");
|
||||||
// register the failed download and check if the batch can be retried
|
// register the failed download and check if the batch can be retried
|
||||||
|
|||||||
Reference in New Issue
Block a user