1
1
use std:: { sync:: Arc , time:: Duration } ;
2
2
3
- use alloy:: primitives:: { B256 , U256 } ;
4
- use alloy:: rpc:: types:: beacon:: BlsPublicKey ;
3
+ use alloy:: {
4
+ primitives:: { B256 , U256 } ,
5
+ rpc:: types:: beacon:: BlsPublicKey ,
6
+ } ;
5
7
use axum:: http:: { HeaderMap , HeaderValue } ;
6
8
use cb_common:: {
7
9
config:: PbsConfig ,
@@ -15,8 +17,9 @@ use reqwest::{header::USER_AGENT, StatusCode};
15
17
use tracing:: { debug, error} ;
16
18
17
19
use crate :: {
20
+ constants:: GET_HEADER_ENDPOINT_TAG ,
18
21
error:: { PbsError , ValidationError } ,
19
- metrics:: { RELAY_RESPONSES , RELAY_RESPONSE_TIME } ,
22
+ metrics:: { RELAY_LATENCY , RELAY_STATUS_CODE } ,
20
23
state:: { BuilderApiState , PbsState } ,
21
24
types:: { SignedExecutionPayloadHeader , EMPTY_TX_ROOT_HASH } ,
22
25
GetHeaderParams , GetHeaderReponse ,
@@ -84,7 +87,8 @@ async fn send_get_header(
84
87
) -> Result < Option < GetHeaderReponse > , PbsError > {
85
88
let url = relay. get_header_url ( slot, parent_hash, validator_pubkey) ;
86
89
87
- let timer = RELAY_RESPONSE_TIME . with_label_values ( & [ "get_header" , & relay. id ] ) . start_timer ( ) ;
90
+ let timer =
91
+ RELAY_LATENCY . with_label_values ( & [ GET_HEADER_ENDPOINT_TAG , & relay. id ] ) . start_timer ( ) ;
88
92
let res = client
89
93
. get ( url)
90
94
. timeout ( Duration :: from_millis ( config. timeout_get_header_ms ) )
@@ -94,7 +98,9 @@ async fn send_get_header(
94
98
timer. observe_duration ( ) ;
95
99
96
100
let status = res. status ( ) ;
97
- RELAY_RESPONSES . with_label_values ( & [ & status. to_string ( ) , "get_header" , & relay. id ] ) . inc ( ) ;
101
+ RELAY_STATUS_CODE
102
+ . with_label_values ( & [ status. as_str ( ) , GET_HEADER_ENDPOINT_TAG , & relay. id ] )
103
+ . inc ( ) ;
98
104
99
105
let response_bytes = res. bytes ( ) . await ?;
100
106
if !status. is_success ( ) {
@@ -184,8 +190,10 @@ fn validate_header(
184
190
185
191
#[ cfg( test) ]
186
192
mod tests {
187
- use alloy:: primitives:: { B256 , U256 } ;
188
- use alloy:: rpc:: types:: beacon:: BlsPublicKey ;
193
+ use alloy:: {
194
+ primitives:: { B256 , U256 } ,
195
+ rpc:: types:: beacon:: BlsPublicKey ,
196
+ } ;
189
197
use blst:: min_pk;
190
198
use cb_common:: { pbs:: RelayEntry , signature:: sign_builder_message, types:: Chain } ;
191
199
0 commit comments