diff --git a/config.example.toml b/config.example.toml index 7b6a4a11..138876d9 100644 --- a/config.example.toml +++ b/config.example.toml @@ -116,12 +116,12 @@ validator_pubkeys = [ loader = "./mux_keys.example.json" timeout_get_header_ms = 900 late_in_slot_time_ms = 1500 -# For each mux, one or more [[pbs_mux.relays]] can be defined, which will be used for the matching validator pubkeys -# Only the relays defined here will be used, and the rest of the relays defined in the main config will be ignored -# Any field defined here will override the default value from the relay config with the same id in [[relays]] +# For each mux, one or more [[mux.relays]] can be defined, which will be used for the matching validator pubkeys +# Only the relays defined here will be used, and the relays defined in the main [[relays]] config will be ignored +# The fields specified here are the same as in [[relays]] (headers, enable_timing_games, target_first_request_ms, frequency_get_header_ms) [[mux.relays]] -id = "example-relay" -headers = { X-MyCustomHeader = "ADifferentCustomValue" } +id = "mux-relay-1" +url = "http://0xa119589bb33ef52acbb8116832bec2b58fca590fe5c85eac5d3230b44d5bc09fe73ccd21f88eab31d6de16194d17782e@def.xyz" # Configuration for the Signer Module, only required if any `commit` module is present, or if `pbs.with_signer = true` # Currently two types of Signer modules are supported (only one can be used at a time): diff --git a/configs/pbs-mux.toml b/configs/pbs-mux.toml index f9efa1d5..0bb139f4 100644 --- a/configs/pbs-mux.toml +++ b/configs/pbs-mux.toml @@ -7,18 +7,14 @@ port = 18550 timeout_get_header_ms = 950 late_in_slot_time_ms = 2000 +# Used for all validators except the ones in the mux [[relays]] id = "relay-1" url = "http://0xa1cec75a3f0661e99299274182938151e8433c61a19222347ea1313d839229cb4ce4e3e5aa2bdeb71c8fcf1b084963c2@abc.xyz" -[[relays]] -id = "relay-2" -url = "http://0xa119589bb33ef52acbb8116832bec2b58fca590fe5c85eac5d3230b44d5bc09fe73ccd21f88eab31d6de16194d17782e@def.xyz" -enable_timing_games = true -target_first_request_ms = 200 [[mux]] -id = "test_mux" +id = "timing-mux" validator_pubkeys = [ "0x80c7f782b2467c5898c5516a8b6595d75623960b4afc4f71ee07d40985d20e117ba35e7cd352a3e75fb85a8668a3b745", ] @@ -28,4 +24,6 @@ late_in_slot_time_ms = 1500 [[mux.relays]] id = "relay-2" -enable_timing_games = false +url = "http://0xa119589bb33ef52acbb8116832bec2b58fca590fe5c85eac5d3230b44d5bc09fe73ccd21f88eab31d6de16194d17782e@def.xyz" +enable_timing_games = true +target_first_request_ms = 200 diff --git a/crates/common/src/config/mux.rs b/crates/common/src/config/mux.rs index 17ab084b..87ada0a8 100644 --- a/crates/common/src/config/mux.rs +++ b/crates/common/src/config/mux.rs @@ -5,11 +5,11 @@ use std::{ }; use alloy::rpc::types::beacon::BlsPublicKey; -use eyre::{bail, ensure, eyre, Context}; +use eyre::{bail, ensure, Context}; use serde::{Deserialize, Serialize}; use super::{load_optional_env_var, PbsConfig, RelayConfig, MUX_PATH_ENV}; -use crate::pbs::{RelayClient, RelayEntry}; +use crate::pbs::RelayClient; #[derive(Debug, Deserialize, Serialize)] pub struct PbsMuxes { @@ -29,7 +29,6 @@ impl PbsMuxes { pub fn validate_and_fill( self, default_pbs: &PbsConfig, - default_relays: &[RelayConfig], ) -> eyre::Result> { let mut muxes = self.muxes; @@ -61,33 +60,8 @@ impl PbsMuxes { ); let mut relay_clients = Vec::with_capacity(mux.relays.len()); - for partial_relay in mux.relays.into_iter() { - // create a new config overriding only the missing fields - let partial_id = partial_relay.id()?; - // assume that there is always a relay defined in the default config. If this - // becomes too much of a burden, we can change this to allow defining relays - // that are exclusively used by a mux - let default_relay = default_relays - .iter() - .find(|r| r.id() == partial_id) - .ok_or_else(|| eyre!("default relay config not found for: {}", partial_id))?; - - let full_config = RelayConfig { - id: Some(partial_id.to_string()), - entry: partial_relay.entry.unwrap_or(default_relay.entry.clone()), - headers: partial_relay.headers.or(default_relay.headers.clone()), - enable_timing_games: partial_relay - .enable_timing_games - .unwrap_or(default_relay.enable_timing_games), - target_first_request_ms: partial_relay - .target_first_request_ms - .or(default_relay.target_first_request_ms), - frequency_get_header_ms: partial_relay - .frequency_get_header_ms - .or(default_relay.frequency_get_header_ms), - }; - - relay_clients.push(RelayClient::new(full_config)?); + for config in mux.relays.into_iter() { + relay_clients.push(RelayClient::new(config)?); } let config = PbsConfig { @@ -117,7 +91,7 @@ pub struct MuxConfig { /// Identifier for this mux config pub id: String, /// Relays to use for this mux config - pub relays: Vec, + pub relays: Vec, /// Which validator pubkeys to match against this mux config #[serde(default)] pub validator_pubkeys: Vec, @@ -142,33 +116,6 @@ impl MuxConfig { } } -#[derive(Debug, Clone, Deserialize, Serialize)] -/// A relay config with all optional fields. See [`RelayConfig`] for the -/// description of the fields. -pub struct PartialRelayConfig { - pub id: Option, - #[serde(rename = "url")] - pub entry: Option, - pub headers: Option>, - pub enable_timing_games: Option, - pub target_first_request_ms: Option, - pub frequency_get_header_ms: Option, -} - -impl PartialRelayConfig { - pub fn id(&self) -> eyre::Result<&str> { - match &self.id { - Some(id) => Ok(id.as_str()), - None => { - let entry = self.entry.as_ref().ok_or_else(|| { - eyre!("relays in [[mux]] need to specifify either an `id` or a `url`") - })?; - Ok(entry.id.as_str()) - } - } - } -} - #[derive(Debug, Clone, Deserialize, Serialize)] #[serde(untagged)] pub enum MuxKeysLoader { diff --git a/crates/common/src/config/pbs.rs b/crates/common/src/config/pbs.rs index 0144ce88..d5075848 100644 --- a/crates/common/src/config/pbs.rs +++ b/crates/common/src/config/pbs.rs @@ -181,10 +181,8 @@ pub fn load_pbs_config() -> Result { SocketAddr::from((config.pbs.pbs_config.host, config.pbs.pbs_config.port)) }; - let muxes = config - .muxes - .map(|muxes| muxes.validate_and_fill(&config.pbs.pbs_config, &config.relays)) - .transpose()?; + let muxes = + config.muxes.map(|muxes| muxes.validate_and_fill(&config.pbs.pbs_config)).transpose()?; let relay_clients = config.relays.into_iter().map(RelayClient::new).collect::>>()?; @@ -234,9 +232,7 @@ pub fn load_pbs_custom_config() -> Result<(PbsModuleConfig, }; let muxes = match cb_config.muxes { - Some(muxes) => Some( - muxes.validate_and_fill(&cb_config.pbs.static_config.pbs_config, &cb_config.relays)?, - ), + Some(muxes) => Some(muxes.validate_and_fill(&cb_config.pbs.static_config.pbs_config)?), None => None, };