From 1fe1cc9a1ec9f05b58d42c26013adb1faeb525b0 Mon Sep 17 00:00:00 2001 From: Rachit2323 Date: Sun, 19 Jan 2025 22:42:59 +0530 Subject: [PATCH] vec added --- crates/common/src/config/mod.rs | 6 +++--- crates/common/src/config/mux.rs | 1 + crates/common/src/config/pbs.rs | 22 ++++------------------ 3 files changed, 8 insertions(+), 21 deletions(-) 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 e113c19..b8a1851 100644 --- a/crates/common/src/config/mux.rs +++ b/crates/common/src/config/mux.rs @@ -109,6 +109,7 @@ 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 diff --git a/crates/common/src/config/pbs.rs b/crates/common/src/config/pbs.rs index 7b9ba94..e2a7794 100644 --- a/crates/common/src/config/pbs.rs +++ b/crates/common/src/config/pbs.rs @@ -16,8 +16,7 @@ use serde::{de::DeserializeOwned, Deserialize, Serialize}; use url::Url; use super::{ - constants::PBS_IMAGE_DEFAULT, load_optional_env_var, CommitBoostConfig, RuntimeMuxConfig, - PBS_ENDPOINT_ENV, + constants::PBS_IMAGE_DEFAULT, load_optional_env_var, CommitBoostConfig, MuxConfig, RuntimeMuxConfig, PBS_ENDPOINT_ENV }; use crate::{ commit::client::SignerClient, @@ -148,19 +147,6 @@ impl PbsConfig { } } -/// Static pbs config from config file -#[derive(Debug, Deserialize, Serialize)] -pub struct StaticPbsConfig { - /// Docker image of the module - #[serde(default = "default_pbs")] - pub docker_image: String, - /// Config of pbs module - #[serde(flatten)] - pub pbs_config: PbsConfig, - /// Whether to enable the signer client - #[serde(default = "default_bool::")] - pub with_signer: bool, -} #[derive(Debug, Deserialize, Serialize)] pub struct StaticPbsConfig { @@ -214,12 +200,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, @@ -251,7 +237,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,