diff --git a/crates/cli/src/docker_init.rs b/crates/cli/src/docker_init.rs index 5d25736..98acdae 100644 --- a/crates/cli/src/docker_init.rs +++ b/crates/cli/src/docker_init.rs @@ -88,7 +88,7 @@ pub async fn handle_docker_init(config_path: String, output_dir: String) -> Resu let mut warnings = Vec::new(); - let mut needs_signer_module = cb_config.pbs.with_signer; + let mut needs_signer_module = cb_config.pbs_modules[0].with_signer; // setup modules if let Some(modules_config) = cb_config.modules { @@ -267,13 +267,13 @@ pub async fn handle_docker_init(config_path: String, output_dir: String) -> Resu // ports let host_endpoint = - SocketAddr::from((cb_config.pbs.pbs_config.host, cb_config.pbs.pbs_config.port)); - let ports = Ports::Short(vec![format!("{}:{}", host_endpoint, cb_config.pbs.pbs_config.port)]); - warnings.push(format!("pbs has an exported port on {}", cb_config.pbs.pbs_config.port)); + SocketAddr::from((cb_config.pbs_modules[0].pbs_config.host, cb_config.pbs_modules[0].pbs_config.port)); + let ports = Ports::Short(vec![format!("{}:{}", host_endpoint, cb_config.pbs_modules[0].pbs_config.port)]); + warnings.push(format!("pbs has an exported port on {}", cb_config.pbs_modules[0].pbs_config.port)); // inside the container expose on 0.0.0.0 let container_endpoint = - SocketAddr::from((Ipv4Addr::UNSPECIFIED, cb_config.pbs.pbs_config.port)); + SocketAddr::from((Ipv4Addr::UNSPECIFIED, cb_config.pbs_modules[0].pbs_config.port)); let (key, val) = get_env_val(PBS_ENDPOINT_ENV, &container_endpoint.to_string()); pbs_envs.insert(key, val); @@ -290,7 +290,7 @@ pub async fn handle_docker_init(config_path: String, output_dir: String) -> Resu let pbs_service = Service { container_name: Some("cb_pbs".to_owned()), - image: Some(cb_config.pbs.docker_image), + image: Some(cb_config.pbs_modules[0].docker_image.clone()), ports, networks: pbs_networs, volumes: pbs_volumes, @@ -298,7 +298,7 @@ pub async fn handle_docker_init(config_path: String, output_dir: String) -> Resu healthcheck: Some(Healthcheck { test: Some(HealthcheckTest::Single(format!( "curl -f http://localhost:{}{}{}", - cb_config.pbs.pbs_config.port, BUILDER_API_PATH, GET_STATUS_PATH + cb_config.pbs_modules[0].pbs_config.port, BUILDER_API_PATH, GET_STATUS_PATH ))), interval: Some("30s".into()), timeout: Some("5s".into()), diff --git a/crates/common/src/config/mod.rs b/crates/common/src/config/mod.rs index b097d02..82ebc4a 100644 --- a/crates/common/src/config/mod.rs +++ b/crates/common/src/config/mod.rs @@ -27,7 +27,7 @@ pub use utils::*; pub struct CommitBoostConfig { pub chain: Chain, pub relays: Vec, - pub pbs: StaticPbsConfig, + pub pbs_modules: Vec, #[serde(flatten)] pub muxes: Option, pub modules: Option>, @@ -39,7 +39,7 @@ pub struct CommitBoostConfig { impl CommitBoostConfig { /// Validate config pub async fn validate(&self) -> Result<()> { - self.pbs.pbs_config.validate(self.chain).await?; + self.pbs_modules[0].pbs_config.validate(self.chain).await?; Ok(()) } @@ -74,7 +74,7 @@ impl CommitBoostConfig { let config = CommitBoostConfig { chain, relays: helper_config.relays, - pbs: helper_config.pbs, + pbs_modules: vec![helper_config.pbs], muxes: helper_config.muxes, modules: helper_config.modules, signer: helper_config.signer, diff --git a/crates/common/src/config/mux.rs b/crates/common/src/config/mux.rs index 32ff8e9..4b3a1fb 100644 --- a/crates/common/src/config/mux.rs +++ b/crates/common/src/config/mux.rs @@ -1,3 +1,5 @@ +pub use crate::config::module::{StaticModuleConfig}; + use std::{ collections::{HashMap, HashSet}, path::{Path, PathBuf}, @@ -108,6 +110,8 @@ pub struct MuxConfig { pub id: String, /// Relays to use for this mux config pub relays: Vec, + /// PBS Modules to use for this mux config + pub modules: Vec, /// Which validator pubkeys to match against this mux config #[serde(default)] pub validator_pubkeys: Vec, @@ -121,6 +125,7 @@ impl MuxConfig { /// Returns the env, actual path, and internal path to use for the file /// loader pub fn loader_env(&self) -> Option<(String, String, String)> { + self.loader.as_ref().and_then(|loader| match loader { MuxKeysLoader::File(path_buf) => { let path = diff --git a/crates/common/src/config/pbs.rs b/crates/common/src/config/pbs.rs index 5e42b6c..08ca48d 100644 --- a/crates/common/src/config/pbs.rs +++ b/crates/common/src/config/pbs.rs @@ -198,12 +198,12 @@ pub async fn load_pbs_config() -> Result { let endpoint = if let Some(endpoint) = load_optional_env_var(PBS_ENDPOINT_ENV) { endpoint.parse()? } else { - SocketAddr::from((config.pbs.pbs_config.host, config.pbs.pbs_config.port)) + SocketAddr::from((config.pbs_modules[0].pbs_config.host, config.pbs_modules[0].pbs_config.port)) }; let muxes = match config.muxes { Some(muxes) => { - let mux_configs = muxes.validate_and_fill(config.chain, &config.pbs.pbs_config).await?; + let mux_configs = muxes.validate_and_fill(config.chain, &config.pbs_modules[0].pbs_config).await?; Some(mux_configs) } None => None, @@ -235,7 +235,7 @@ pub async fn load_pbs_config() -> Result { Ok(PbsModuleConfig { chain: config.chain, endpoint, - pbs_config: Arc::new(config.pbs.pbs_config), + pbs_config: Arc::new(config.pbs_modules[0].pbs_config.clone()), relays: relay_clients, all_relays, signer_client: None,