Skip to content

Commit

Permalink
removed redundant param
Browse files Browse the repository at this point in the history
  • Loading branch information
ltitanb committed Jul 30, 2024
1 parent e0e1c7c commit 3be5eeb
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 21 deletions.
1 change: 0 additions & 1 deletion config.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 0 additions & 3 deletions crates/common/src/pbs/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,4 @@ pub struct PbsConfig {
/// 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,
/// If it's too late in the slot, skip get header and force local build
#[serde(default = "default_bool::<false>")]
pub skip_header_late_in_slot: bool,
}
14 changes: 12 additions & 2 deletions crates/pbs/src/mev_boost/get_header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,24 @@ pub async fn get_header<S: BuilderApiState>(
req_headers: HeaderMap,
state: PbsState<S>,
) -> eyre::Result<Option<GetHeaderReponse>> {
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())?);
Expand Down
12 changes: 1 addition & 11 deletions crates/pbs/src/routes/get_header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand All @@ -31,16 +31,6 @@ pub async fn handle_get_header<S: BuilderApiState, T: BuilderApi<S>>(
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) => {
Expand Down
4 changes: 0 additions & 4 deletions crates/pbs/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3be5eeb

Please sign in to comment.