Skip to content

Commit

Permalink
pbs_modules
Browse files Browse the repository at this point in the history
  • Loading branch information
irfanshaik11 committed Jan 19, 2025
1 parent a0bf67c commit d3b8eaa
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 13 deletions.
14 changes: 7 additions & 7 deletions crates/cli/src/docker_init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);

Expand All @@ -290,15 +290,15 @@ 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,
environment: Environment::KvPair(pbs_envs),
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()),
Expand Down
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
5 changes: 5 additions & 0 deletions crates/common/src/config/mux.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
pub use crate::config::module::{StaticModuleConfig};

use std::{
collections::{HashMap, HashSet},
path::{Path, PathBuf},
Expand Down Expand Up @@ -108,6 +110,8 @@ 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
#[serde(default)]
pub validator_pubkeys: Vec<BlsPublicKey>,
Expand All @@ -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 =
Expand Down
6 changes: 3 additions & 3 deletions crates/common/src/config/pbs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,12 +198,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 @@ -235,7 +235,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 d3b8eaa

Please sign in to comment.