-
Notifications
You must be signed in to change notification settings - Fork 745
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add req/resp metrics from additional PeerDAS list #6430
base: unstable
Are you sure you want to change the base?
Changes from 2 commits
11ad2ae
eb5a60c
556df28
3769eef
807ffc6
5a92a92
0682cd1
92a7453
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
use crate::metrics; | ||
use crate::rpc::methods::*; | ||
use crate::rpc::protocol::{ | ||
Encoding, ProtocolId, RPCError, SupportedProtocol, ERROR_TYPE_MAX, ERROR_TYPE_MIN, | ||
|
@@ -359,6 +360,11 @@ impl<E: EthSpec> Encoder<OutboundRequest<E>> for SSZSnappyOutboundCodec<E> { | |
|
||
// Write compressed bytes to `dst` | ||
dst.extend_from_slice(writer.get_ref()); | ||
metrics::inc_counter_vec_by( | ||
&metrics::TOTAL_RPC_REQUESTS_BYTES_SENT, | ||
&[item.into()], | ||
dst.len() as u64, | ||
); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Feels wrong to place a metric inside an |
||
Ok(()) | ||
} | ||
} | ||
|
@@ -538,68 +544,150 @@ fn handle_rpc_request<E: EthSpec>( | |
spec: &ChainSpec, | ||
) -> Result<Option<InboundRequest<E>>, RPCError> { | ||
match versioned_protocol { | ||
SupportedProtocol::StatusV1 => Ok(Some(InboundRequest::Status( | ||
StatusMessage::from_ssz_bytes(decoded_buffer)?, | ||
))), | ||
SupportedProtocol::StatusV1 => { | ||
metrics::inc_counter_vec_by( | ||
&metrics::TOTAL_RPC_REQUESTS_BYTES_RECEIVED, | ||
&["status"], | ||
decoded_buffer.len() as u64, | ||
); | ||
Ok(Some(InboundRequest::Status(StatusMessage::from_ssz_bytes( | ||
decoded_buffer, | ||
)?))) | ||
} | ||
SupportedProtocol::GoodbyeV1 => Ok(Some(InboundRequest::Goodbye( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do I need to count |
||
GoodbyeReason::from_ssz_bytes(decoded_buffer)?, | ||
))), | ||
SupportedProtocol::BlocksByRangeV2 => Ok(Some(InboundRequest::BlocksByRange( | ||
OldBlocksByRangeRequest::V2(OldBlocksByRangeRequestV2::from_ssz_bytes(decoded_buffer)?), | ||
))), | ||
SupportedProtocol::BlocksByRangeV1 => Ok(Some(InboundRequest::BlocksByRange( | ||
OldBlocksByRangeRequest::V1(OldBlocksByRangeRequestV1::from_ssz_bytes(decoded_buffer)?), | ||
))), | ||
SupportedProtocol::BlocksByRootV2 => Ok(Some(InboundRequest::BlocksByRoot( | ||
BlocksByRootRequest::V2(BlocksByRootRequestV2 { | ||
block_roots: RuntimeVariableList::from_ssz_bytes( | ||
SupportedProtocol::BlocksByRangeV2 => { | ||
metrics::inc_counter_vec_by( | ||
&metrics::TOTAL_RPC_REQUESTS_BYTES_RECEIVED, | ||
&["blocks_by_range"], | ||
decoded_buffer.len() as u64, | ||
); | ||
Ok(Some(InboundRequest::BlocksByRange( | ||
OldBlocksByRangeRequest::V2(OldBlocksByRangeRequestV2::from_ssz_bytes( | ||
decoded_buffer, | ||
spec.max_request_blocks as usize, | ||
)?, | ||
}), | ||
))), | ||
SupportedProtocol::BlocksByRootV1 => Ok(Some(InboundRequest::BlocksByRoot( | ||
BlocksByRootRequest::V1(BlocksByRootRequestV1 { | ||
block_roots: RuntimeVariableList::from_ssz_bytes( | ||
)?), | ||
))) | ||
} | ||
SupportedProtocol::BlocksByRangeV1 => { | ||
metrics::inc_counter_vec_by( | ||
&metrics::TOTAL_RPC_REQUESTS_BYTES_RECEIVED, | ||
&["blocks_by_range"], | ||
decoded_buffer.len() as u64, | ||
); | ||
Ok(Some(InboundRequest::BlocksByRange( | ||
OldBlocksByRangeRequest::V1(OldBlocksByRangeRequestV1::from_ssz_bytes( | ||
decoded_buffer, | ||
spec.max_request_blocks as usize, | ||
)?, | ||
}), | ||
))), | ||
SupportedProtocol::BlobsByRangeV1 => Ok(Some(InboundRequest::BlobsByRange( | ||
BlobsByRangeRequest::from_ssz_bytes(decoded_buffer)?, | ||
))), | ||
)?), | ||
))) | ||
} | ||
SupportedProtocol::BlocksByRootV2 => { | ||
metrics::inc_counter_vec_by( | ||
&metrics::TOTAL_RPC_REQUESTS_BYTES_RECEIVED, | ||
&["blocks_by_root"], | ||
decoded_buffer.len() as u64, | ||
); | ||
Ok(Some(InboundRequest::BlocksByRoot(BlocksByRootRequest::V2( | ||
BlocksByRootRequestV2 { | ||
block_roots: RuntimeVariableList::from_ssz_bytes( | ||
decoded_buffer, | ||
spec.max_request_blocks as usize, | ||
)?, | ||
}, | ||
)))) | ||
} | ||
SupportedProtocol::BlocksByRootV1 => { | ||
metrics::inc_counter_vec_by( | ||
&metrics::TOTAL_RPC_REQUESTS_BYTES_RECEIVED, | ||
&["blocks_by_root"], | ||
decoded_buffer.len() as u64, | ||
); | ||
Ok(Some(InboundRequest::BlocksByRoot(BlocksByRootRequest::V1( | ||
BlocksByRootRequestV1 { | ||
block_roots: RuntimeVariableList::from_ssz_bytes( | ||
decoded_buffer, | ||
spec.max_request_blocks as usize, | ||
)?, | ||
}, | ||
)))) | ||
} | ||
SupportedProtocol::BlobsByRangeV1 => { | ||
metrics::inc_counter_vec_by( | ||
&metrics::TOTAL_RPC_REQUESTS_BYTES_RECEIVED, | ||
&["blobs_by_range"], | ||
decoded_buffer.len() as u64, | ||
); | ||
Ok(Some(InboundRequest::BlobsByRange( | ||
BlobsByRangeRequest::from_ssz_bytes(decoded_buffer)?, | ||
))) | ||
} | ||
SupportedProtocol::BlobsByRootV1 => { | ||
metrics::inc_counter_vec_by( | ||
&metrics::TOTAL_RPC_REQUESTS_BYTES_RECEIVED, | ||
&["blobs_by_root"], | ||
decoded_buffer.len() as u64, | ||
); | ||
Ok(Some(InboundRequest::BlobsByRoot(BlobsByRootRequest { | ||
blob_ids: RuntimeVariableList::from_ssz_bytes( | ||
decoded_buffer, | ||
spec.max_request_blob_sidecars as usize, | ||
)?, | ||
}))) | ||
} | ||
SupportedProtocol::DataColumnsByRangeV1 => Ok(Some(InboundRequest::DataColumnsByRange( | ||
DataColumnsByRangeRequest::from_ssz_bytes(decoded_buffer)?, | ||
))), | ||
SupportedProtocol::DataColumnsByRootV1 => Ok(Some(InboundRequest::DataColumnsByRoot( | ||
DataColumnsByRootRequest { | ||
data_column_ids: RuntimeVariableList::from_ssz_bytes( | ||
decoded_buffer, | ||
spec.max_request_data_column_sidecars as usize, | ||
)?, | ||
}, | ||
))), | ||
SupportedProtocol::DataColumnsByRangeV1 => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's a lot of repetition in this match, you can turn |
||
metrics::inc_counter_vec_by( | ||
&metrics::TOTAL_RPC_REQUESTS_BYTES_RECEIVED, | ||
&["data_columns_by_range"], | ||
decoded_buffer.len() as u64, | ||
); | ||
Ok(Some(InboundRequest::DataColumnsByRange( | ||
DataColumnsByRangeRequest::from_ssz_bytes(decoded_buffer)?, | ||
))) | ||
} | ||
SupportedProtocol::DataColumnsByRootV1 => { | ||
metrics::inc_counter_vec_by( | ||
&metrics::TOTAL_RPC_REQUESTS_BYTES_RECEIVED, | ||
&["data_columns_by_root"], | ||
decoded_buffer.len() as u64, | ||
); | ||
Ok(Some(InboundRequest::DataColumnsByRoot( | ||
DataColumnsByRootRequest { | ||
data_column_ids: RuntimeVariableList::from_ssz_bytes( | ||
decoded_buffer, | ||
spec.max_request_data_column_sidecars as usize, | ||
)?, | ||
}, | ||
))) | ||
} | ||
SupportedProtocol::PingV1 => Ok(Some(InboundRequest::Ping(Ping { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do I need to count |
||
data: u64::from_ssz_bytes(decoded_buffer)?, | ||
}))), | ||
SupportedProtocol::LightClientBootstrapV1 => Ok(Some( | ||
InboundRequest::LightClientBootstrap(LightClientBootstrapRequest { | ||
root: Hash256::from_ssz_bytes(decoded_buffer)?, | ||
}), | ||
)), | ||
SupportedProtocol::LightClientBootstrapV1 => { | ||
metrics::inc_counter_vec_by( | ||
&metrics::TOTAL_RPC_REQUESTS_BYTES_RECEIVED, | ||
&["light_client_bootstrap"], | ||
decoded_buffer.len() as u64, | ||
); | ||
Ok(Some(InboundRequest::LightClientBootstrap( | ||
LightClientBootstrapRequest { | ||
root: Hash256::from_ssz_bytes(decoded_buffer)?, | ||
}, | ||
))) | ||
} | ||
SupportedProtocol::LightClientOptimisticUpdateV1 => { | ||
metrics::inc_counter_vec_by( | ||
&metrics::TOTAL_RPC_REQUESTS_BYTES_RECEIVED, | ||
&["light_client_optimistic_update"], | ||
decoded_buffer.len() as u64, | ||
); | ||
Ok(Some(InboundRequest::LightClientOptimisticUpdate)) | ||
} | ||
SupportedProtocol::LightClientFinalityUpdateV1 => { | ||
metrics::inc_counter_vec_by( | ||
&metrics::TOTAL_RPC_REQUESTS_BYTES_RECEIVED, | ||
&["light_client_finality_update"], | ||
decoded_buffer.len() as u64, | ||
); | ||
Ok(Some(InboundRequest::LightClientFinalityUpdate)) | ||
} | ||
// MetaData requests return early from InboundUpgrade and do not reach the decoder. | ||
|
@@ -636,7 +724,7 @@ fn handle_rpc_request<E: EthSpec>( | |
/// `decoded_buffer` should be an ssz-encoded bytestream with | ||
/// length = length-prefix received in the beginning of the stream. | ||
/// | ||
/// For BlocksByRange/BlocksByRoot reponses, decodes the appropriate response | ||
/// For BlocksByRange/BlocksByRoot responses, decodes the appropriate response | ||
/// according to the received `ForkName`. | ||
fn handle_rpc_response<E: EthSpec>( | ||
versioned_protocol: SupportedProtocol, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We generally avoid renaming metrics as it is a breaking change for users, but I do agree the current name is not just unclear but also a bit misleading, so I think this is a good change. I'll marked this PR as breaking change so we remember to mention it in our release notes.
This dashboard needs to be updated too:
https://github.com/sigp/lighthouse-metrics/blob/9c654c48d108180cfec48398c9410ae80839047e/dashboards/Network.json#L2620