Skip to content

Commit

Permalink
vec added
Browse files Browse the repository at this point in the history
  • Loading branch information
Rachit2323 committed Jan 19, 2025
1 parent e2b5eb2 commit 1fe1cc9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 21 deletions.
6 changes: 3 additions & 3 deletions crates/common/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub use utils::*;
pub struct CommitBoostConfig {
pub chain: Chain,
pub relays: Vec<RelayConfig>,
pub pbs: StaticPbsConfig,
pub pbs_modules: Vec<StaticPbsConfig>,
#[serde(flatten)]
pub muxes: Option<PbsMuxes>,
pub modules: Option<Vec<StaticModuleConfig>>,
Expand All @@ -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(())
}

Expand Down Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions crates/common/src/config/mux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ pub struct MuxConfig {
pub id: String,
/// Relays to use for this mux config
pub relays: Vec<RelayConfig>,

/// PBS Modules to use for this mux config
pub modules: Vec<StaticModuleConfig>,
/// Which validator pubkeys to match against this mux config
Expand Down
22 changes: 4 additions & 18 deletions crates/common/src/config/pbs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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::<false>")]
pub with_signer: bool,
}

#[derive(Debug, Deserialize, Serialize)]
pub struct StaticPbsConfig {
Expand Down Expand Up @@ -214,12 +200,12 @@ pub async fn load_pbs_config() -> Result<PbsModuleConfig> {
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,
Expand Down Expand Up @@ -251,7 +237,7 @@ pub async fn load_pbs_config() -> Result<PbsModuleConfig> {
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,
Expand Down

0 comments on commit 1fe1cc9

Please sign in to comment.