mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-30 20:57:10 +00:00
Add sync request metrics (#7790)
Add error rates metrics on unstable to benchmark against tree-sync. In my branch there are frequent errors but mostly connections errors as the node is still finding it set of stable peers. These metrics are very useful and unstable can benefit from them ahead of tree-sync Add three new metrics: - sync_rpc_requests_success_total: Total count of sync RPC requests successes - sync_rpc_requests_error_total: Total count of sync RPC requests errors - sync_rpc_request_duration_sec: Time to complete a successful sync RPC requesst Co-Authored-By: dapplion <35266934+dapplion@users.noreply.github.com>
This commit is contained in:
@@ -1430,7 +1430,7 @@ impl<T: BeaconChainTypes> SyncNetworkContext<T> {
|
||||
}
|
||||
})
|
||||
});
|
||||
self.on_rpc_response_result(id, "BlocksByRoot", resp, peer_id, |_| 1)
|
||||
self.on_rpc_response_result(resp, peer_id)
|
||||
}
|
||||
|
||||
pub(crate) fn on_single_blob_response(
|
||||
@@ -1459,7 +1459,7 @@ impl<T: BeaconChainTypes> SyncNetworkContext<T> {
|
||||
}
|
||||
})
|
||||
});
|
||||
self.on_rpc_response_result(id, "BlobsByRoot", resp, peer_id, |_| 1)
|
||||
self.on_rpc_response_result(resp, peer_id)
|
||||
}
|
||||
|
||||
#[allow(clippy::type_complexity)]
|
||||
@@ -1472,7 +1472,7 @@ impl<T: BeaconChainTypes> SyncNetworkContext<T> {
|
||||
let resp = self
|
||||
.data_columns_by_root_requests
|
||||
.on_response(id, rpc_event);
|
||||
self.on_rpc_response_result(id, "DataColumnsByRoot", resp, peer_id, |_| 1)
|
||||
self.on_rpc_response_result(resp, peer_id)
|
||||
}
|
||||
|
||||
#[allow(clippy::type_complexity)]
|
||||
@@ -1483,7 +1483,7 @@ impl<T: BeaconChainTypes> SyncNetworkContext<T> {
|
||||
rpc_event: RpcEvent<Arc<SignedBeaconBlock<T::EthSpec>>>,
|
||||
) -> Option<RpcResponseResult<Vec<Arc<SignedBeaconBlock<T::EthSpec>>>>> {
|
||||
let resp = self.blocks_by_range_requests.on_response(id, rpc_event);
|
||||
self.on_rpc_response_result(id, "BlocksByRange", resp, peer_id, |b| b.len())
|
||||
self.on_rpc_response_result(resp, peer_id)
|
||||
}
|
||||
|
||||
#[allow(clippy::type_complexity)]
|
||||
@@ -1494,7 +1494,7 @@ impl<T: BeaconChainTypes> SyncNetworkContext<T> {
|
||||
rpc_event: RpcEvent<Arc<BlobSidecar<T::EthSpec>>>,
|
||||
) -> Option<RpcResponseResult<Vec<Arc<BlobSidecar<T::EthSpec>>>>> {
|
||||
let resp = self.blobs_by_range_requests.on_response(id, rpc_event);
|
||||
self.on_rpc_response_result(id, "BlobsByRangeRequest", resp, peer_id, |b| b.len())
|
||||
self.on_rpc_response_result(resp, peer_id)
|
||||
}
|
||||
|
||||
#[allow(clippy::type_complexity)]
|
||||
@@ -1507,36 +1507,15 @@ impl<T: BeaconChainTypes> SyncNetworkContext<T> {
|
||||
let resp = self
|
||||
.data_columns_by_range_requests
|
||||
.on_response(id, rpc_event);
|
||||
self.on_rpc_response_result(id, "DataColumnsByRange", resp, peer_id, |d| d.len())
|
||||
self.on_rpc_response_result(resp, peer_id)
|
||||
}
|
||||
|
||||
fn on_rpc_response_result<I: std::fmt::Display, R, F: FnOnce(&R) -> usize>(
|
||||
/// Common handler for consistent scoring of RpcResponseError
|
||||
fn on_rpc_response_result<R>(
|
||||
&mut self,
|
||||
id: I,
|
||||
method: &'static str,
|
||||
resp: Option<RpcResponseResult<R>>,
|
||||
peer_id: PeerId,
|
||||
get_count: F,
|
||||
) -> Option<RpcResponseResult<R>> {
|
||||
match &resp {
|
||||
None => {}
|
||||
Some(Ok((v, _))) => {
|
||||
debug!(
|
||||
%id,
|
||||
method,
|
||||
count = get_count(v),
|
||||
"Sync RPC request completed"
|
||||
);
|
||||
}
|
||||
Some(Err(e)) => {
|
||||
debug!(
|
||||
%id,
|
||||
method,
|
||||
error = ?e,
|
||||
"Sync RPC request error"
|
||||
);
|
||||
}
|
||||
}
|
||||
if let Some(Err(RpcResponseError::VerifyError(e))) = &resp {
|
||||
self.report_peer(peer_id, PeerAction::LowToleranceError, e.into());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user