From 3be5eeb7c5d4d43873bb4d24e42675fd4e955d61 Mon Sep 17 00:00:00 2001 From: ltitanb Date: Tue, 30 Jul 2024 11:51:27 +0100 Subject: [PATCH] removed redundant param --- config.example.toml | 1 - crates/common/src/pbs/config.rs | 3 --- crates/pbs/src/mev_boost/get_header.rs | 14 ++++++++++++-- crates/pbs/src/routes/get_header.rs | 12 +----------- crates/pbs/src/state.rs | 4 ---- 5 files changed, 13 insertions(+), 21 deletions(-) diff --git a/config.example.toml b/config.example.toml index afcc22a..bfd1add 100644 --- a/config.example.toml +++ b/config.example.toml @@ -10,7 +10,6 @@ skip_sigverify = true min_bid_eth = 0.0 late_in_slot_time_ms = 2000 -skip_header_late_in_slot = true [[relays]] id = "example-relay" diff --git a/crates/common/src/pbs/config.rs b/crates/common/src/pbs/config.rs index c63f84f..aadbf33 100644 --- a/crates/common/src/pbs/config.rs +++ b/crates/common/src/pbs/config.rs @@ -52,7 +52,4 @@ pub struct PbsConfig { /// How late in the slot we consider to be "late" #[serde(default = "default_u64::")] pub late_in_slot_time_ms: u64, - /// If it's too late in the slot, skip get header and force local build - #[serde(default = "default_bool::")] - pub skip_header_late_in_slot: bool, } diff --git a/crates/pbs/src/mev_boost/get_header.rs b/crates/pbs/src/mev_boost/get_header.rs index 287071e..e8d2b3c 100644 --- a/crates/pbs/src/mev_boost/get_header.rs +++ b/crates/pbs/src/mev_boost/get_header.rs @@ -32,14 +32,24 @@ pub async fn get_header( req_headers: HeaderMap, state: PbsState, ) -> eyre::Result> { - let (_, slot_uuid) = state.get_slot_and_uuid(); - let ms_into_slot = ms_into_slot(params.slot, state.config.chain); let max_timeout_ms = state .pbs_config() .timeout_get_header_ms .min(state.pbs_config().late_in_slot_time_ms.saturating_sub(ms_into_slot)); + if max_timeout_ms == 0 { + warn!( + ms_into_slot, + threshold = state.pbs_config().late_in_slot_time_ms, + "late in slot, skipping relay requests" + ); + + return Ok(None) + } + + let (_, slot_uuid) = state.get_slot_and_uuid(); + // prepare headers, except for start time which is set in `send_one_get_header` let mut send_headers = HeaderMap::new(); send_headers.insert(HEADER_SLOT_UUID_KEY, HeaderValue::from_str(&slot_uuid.to_string())?); diff --git a/crates/pbs/src/routes/get_header.rs b/crates/pbs/src/routes/get_header.rs index 8dcb3bc..1691a6b 100644 --- a/crates/pbs/src/routes/get_header.rs +++ b/crates/pbs/src/routes/get_header.rs @@ -6,7 +6,7 @@ use axum::{ }; use cb_common::utils::{get_user_agent, ms_into_slot}; use reqwest::StatusCode; -use tracing::{error, info, warn}; +use tracing::{error, info}; use uuid::Uuid; use crate::{ @@ -31,16 +31,6 @@ pub async fn handle_get_header>( let ms_into_slot = ms_into_slot(params.slot, state.config.chain); info!(?ua, parent_hash=%params.parent_hash, validator_pubkey=%params.pubkey, ms_into_slot); - if state.is_late_in_slot(ms_into_slot) && state.pbs_config().skip_header_late_in_slot { - // too late into slot, force local build - warn!( - ms_into_slot, - threshold = state.pbs_config().late_in_slot_time_ms, - "late in slot, skipping relay requests" - ); - BEACON_NODE_STATUS.with_label_values(&["204", GET_HEADER_ENDPOINT_TAG]).inc(); - return Ok(StatusCode::NO_CONTENT.into_response()); - } match T::get_header(params, req_headers, state.clone()).await { Ok(res) => { diff --git a/crates/pbs/src/state.rs b/crates/pbs/src/state.rs index 870d1f1..9daa1dc 100644 --- a/crates/pbs/src/state.rs +++ b/crates/pbs/src/state.rs @@ -82,10 +82,6 @@ where *guard } - pub fn is_late_in_slot(&self, ms_into_slot: u64) -> bool { - ms_into_slot > self.config.pbs_config.late_in_slot_time_ms - } - // Getters pub fn pbs_config(&self) -> &PbsConfig { &self.config.pbs_config