1- use std:: time:: Instant ;
2-
31use alloy:: rpc:: types:: beacon:: relay:: ValidatorRegistration ;
42use axum:: { extract:: State , http:: HeaderMap , response:: IntoResponse , Json } ;
5- use cb_common:: {
6- pbs:: { BuilderEvent , REGISTER_VALIDATOR_PATH } ,
7- utils:: get_user_agent,
8- DEFAULT_REQUEST_TIMEOUT ,
9- } ;
10- use reqwest:: { StatusCode , Url } ;
11- use tracing:: { debug, error, info, trace} ;
3+ use cb_common:: { pbs:: BuilderEvent , utils:: get_user_agent} ;
4+ use reqwest:: StatusCode ;
5+ use tracing:: { error, info, trace} ;
126use uuid:: Uuid ;
137
148use crate :: {
@@ -34,13 +28,6 @@ pub async fn handle_register_validator<S: BuilderApiState, A: BuilderApi<S>>(
3428
3529 info ! ( ua, num_registrations = registrations. len( ) ) ;
3630
37- if state. has_monitors ( ) {
38- // send registrations to monitors
39- for relay_monitor in state. pbs_config ( ) . relay_monitors . clone ( ) {
40- tokio:: spawn ( send_relay_monitor_registrations ( registrations. clone ( ) , relay_monitor) ) ;
41- }
42- }
43-
4431 if let Err ( err) = A :: register_validator ( registrations, req_headers, state. clone ( ) ) . await {
4532 state. publish_event ( BuilderEvent :: RegisterValidatorResponse ) ;
4633 error ! ( %err, "all relays failed registration" ) ;
@@ -57,44 +44,3 @@ pub async fn handle_register_validator<S: BuilderApiState, A: BuilderApi<S>>(
5744 Ok ( StatusCode :: OK )
5845 }
5946}
60-
61- #[ tracing:: instrument( skip_all, name = "monitor" , fields( url = relay_monitor_url. host_str( ) . unwrap_or_default( ) ) ) ]
62- async fn send_relay_monitor_registrations (
63- registrations : Vec < ValidatorRegistration > ,
64- relay_monitor_url : Url ,
65- ) {
66- let Ok ( url) = relay_monitor_url. join ( REGISTER_VALIDATOR_PATH ) else {
67- error ! ( "invalid URL" ) ;
68- return ;
69- } ;
70-
71- let start_request = Instant :: now ( ) ;
72- let res = match reqwest:: Client :: new ( )
73- . post ( url)
74- . timeout ( DEFAULT_REQUEST_TIMEOUT )
75- . json ( & registrations)
76- . send ( )
77- . await
78- {
79- Ok ( res) => res,
80- Err ( err) => {
81- error ! ( %err, "failed monitor registration" ) ;
82- return ;
83- }
84- } ;
85- let request_latency = start_request. elapsed ( ) ;
86-
87- let code = res. status ( ) ;
88- match res. bytes ( ) . await {
89- Ok ( response_bytes) => {
90- if code. is_success ( ) {
91- debug ! ( ?code, latency = ?request_latency, "relay monitor registration successful" ) ;
92- } else {
93- let err = String :: from_utf8_lossy ( & response_bytes) ;
94- error ! ( ?code, %err, "failed monitor registration" ) ;
95- }
96- }
97-
98- Err ( err) => error ! ( %err, "failed to decode monitor response" ) ,
99- }
100- }
0 commit comments