Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions config.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ skip_sigverify = false
# Can be specified as a float or a string for extra precision (e.g. "0.01")
# OPTIONAL, DEFAULT: 0.0
min_bid_eth = 0.0
# List of URLs of relay monitors to send registrations to
# OPTIONAL
relay_monitors = []
# How late in milliseconds in the slot is "late". This impacts the `get_header` requests, by shortening timeouts for `get_header` calls to
# relays and make sure a header is returned within this deadline. If the request from the CL comes later in the slot, then fetching headers is skipped
# to force local building and miniminzing the risk of missed slots. See also the timing games section below
Expand Down
3 changes: 0 additions & 3 deletions crates/common/src/config/pbs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,6 @@ pub struct PbsConfig {
/// Minimum bid that will be accepted from get_header
#[serde(rename = "min_bid_eth", with = "as_eth_str", default = "default_u256")]
pub min_bid_wei: U256,
/// List of relay monitor urls in the form of scheme://host
#[serde(default)]
pub relay_monitors: Vec<Url>,
/// How late in the slot we consider to be "late"
#[serde(default = "default_u64::<LATE_IN_SLOT_TIME_MS>")]
pub late_in_slot_time_ms: u64,
Expand Down
60 changes: 3 additions & 57 deletions crates/pbs/src/routes/register_validator.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
use std::time::Instant;

use alloy::rpc::types::beacon::relay::ValidatorRegistration;
use axum::{extract::State, http::HeaderMap, response::IntoResponse, Json};
use cb_common::{
pbs::{BuilderEvent, REGISTER_VALIDATOR_PATH},
utils::get_user_agent,
DEFAULT_REQUEST_TIMEOUT,
};
use reqwest::{StatusCode, Url};
use tracing::{debug, error, info, trace};
use cb_common::{pbs::BuilderEvent, utils::get_user_agent};
use reqwest::StatusCode;
use tracing::{error, info, trace};
use uuid::Uuid;

use crate::{
Expand All @@ -34,13 +28,6 @@ pub async fn handle_register_validator<S: BuilderApiState, A: BuilderApi<S>>(

info!(ua, num_registrations = registrations.len());

if state.has_monitors() {
// send registrations to monitors
for relay_monitor in state.pbs_config().relay_monitors.clone() {
tokio::spawn(send_relay_monitor_registrations(registrations.clone(), relay_monitor));
}
}

if let Err(err) = A::register_validator(registrations, req_headers, state.clone()).await {
state.publish_event(BuilderEvent::RegisterValidatorResponse);
error!(%err, "all relays failed registration");
Expand All @@ -57,44 +44,3 @@ pub async fn handle_register_validator<S: BuilderApiState, A: BuilderApi<S>>(
Ok(StatusCode::OK)
}
}

#[tracing::instrument(skip_all, name = "monitor", fields(url = relay_monitor_url.host_str().unwrap_or_default()))]
async fn send_relay_monitor_registrations(
registrations: Vec<ValidatorRegistration>,
relay_monitor_url: Url,
) {
let Ok(url) = relay_monitor_url.join(REGISTER_VALIDATOR_PATH) else {
error!("invalid URL");
return;
};

let start_request = Instant::now();
let res = match reqwest::Client::new()
.post(url)
.timeout(DEFAULT_REQUEST_TIMEOUT)
.json(&registrations)
.send()
.await
{
Ok(res) => res,
Err(err) => {
error!(%err, "failed monitor registration");
return;
}
};
let request_latency = start_request.elapsed();

let code = res.status();
match res.bytes().await {
Ok(response_bytes) => {
if code.is_success() {
debug!(?code, latency = ?request_latency, "relay monitor registration successful");
} else {
let err = String::from_utf8_lossy(&response_bytes);
error!(?code, %err, "failed monitor registration");
}
}

Err(err) => error!(%err, "failed to decode monitor response"),
}
}
4 changes: 0 additions & 4 deletions crates/pbs/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,6 @@ where
}
}

pub fn has_monitors(&self) -> bool {
!self.config.pbs_config.relay_monitors.is_empty()
}

pub fn extra_validation_enabled(&self) -> bool {
self.config.pbs_config.extra_validation_enabled
}
Expand Down
3 changes: 1 addition & 2 deletions tests/data/configs/pbs.happy.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ timeout_get_payload_ms = 4000
timeout_register_validator_ms = 3000
skip_sigverify = false
min_bid_eth = 0.5
relay_monitors = []
late_in_slot_time_ms = 2000
extra_validation_enabled = false
rpc_url = "https://ethereum-holesky-rpc.publicnode.com"
Expand All @@ -23,4 +22,4 @@ url = "http://0xa1cec75a3f0661e99299274182938151e8433c61a19222347ea1313d839229cb
headers = { X-MyCustomHeader = "MyCustomHeader" }
enable_timing_games = false
target_first_request_ms = 200
frequency_get_header_ms = 300
frequency_get_header_ms = 300
1 change: 0 additions & 1 deletion tests/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ pub fn get_pbs_static_config(port: u16) -> PbsConfig {
skip_sigverify: false,
min_bid_wei: U256::ZERO,
late_in_slot_time_ms: u64::MAX,
relay_monitors: vec![],
extra_validation_enabled: false,
rpc_url: None,
}
Expand Down
1 change: 0 additions & 1 deletion tests/tests/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ async fn test_load_pbs_happy() -> Result<()> {
dbg!(&config.pbs.pbs_config.min_bid_wei);
dbg!(&U256::from(0.5));
assert_eq!(config.pbs.pbs_config.min_bid_wei, U256::from((0.5 * WEI_PER_ETH as f64) as u64));
assert!(config.pbs.pbs_config.relay_monitors.is_empty());
assert_eq!(config.pbs.pbs_config.late_in_slot_time_ms, 2000);
assert_eq!(config.pbs.pbs_config.extra_validation_enabled, false);
assert_eq!(
Expand Down