From f1cb935bc077e06626bf1d48f8a5b21c2a042650 Mon Sep 17 00:00:00 2001 From: Joe Clapis Date: Thu, 24 Jul 2025 02:08:37 -0400 Subject: [PATCH] The relays list in the config can now be omitted if not running PBS --- crates/common/src/config/mod.rs | 1 + crates/common/src/config/pbs.rs | 8 ++++++++ tests/tests/config.rs | 12 ++++++++++++ 3 files changed, 21 insertions(+) diff --git a/crates/common/src/config/mod.rs b/crates/common/src/config/mod.rs index b782999b..664fd13e 100644 --- a/crates/common/src/config/mod.rs +++ b/crates/common/src/config/mod.rs @@ -26,6 +26,7 @@ pub use utils::*; #[derive(Debug, Deserialize, Serialize)] pub struct CommitBoostConfig { pub chain: Chain, + #[serde(default)] pub relays: Vec, pub pbs: StaticPbsConfig, #[serde(flatten)] diff --git a/crates/common/src/config/pbs.rs b/crates/common/src/config/pbs.rs index 53d8ccd9..d04b3394 100644 --- a/crates/common/src/config/pbs.rs +++ b/crates/common/src/config/pbs.rs @@ -229,6 +229,14 @@ pub async fn load_pbs_config() -> Result { let config = CommitBoostConfig::from_env_path()?; config.validate().await?; + // Make sure relays isn't empty - since the config is still technically valid if + // there are no relays for things like Docker compose generation, this check + // isn't in validate(). + ensure!( + !config.relays.is_empty(), + "At least one relay must be configured to run the PBS service" + ); + // use endpoint from env if set, otherwise use default host and port let endpoint = if let Some(endpoint) = load_optional_env_var(PBS_ENDPOINT_ENV) { endpoint.parse()? diff --git a/tests/tests/config.rs b/tests/tests/config.rs index f6f31d96..b5f6dba1 100644 --- a/tests/tests/config.rs +++ b/tests/tests/config.rs @@ -170,3 +170,15 @@ async fn test_validate_missing_rpc_url() -> Result<()> { .contains("rpc_url is required if extra_validation_enabled is true")); Ok(()) } + +#[tokio::test] +async fn test_validate_config_with_no_relays() -> Result<()> { + // Create a config with no relays + let mut config = load_happy_config().await?; + config.relays.clear(); + + // Make sure it validates correctly + let result = config.validate().await; + assert!(result.is_ok()); + Ok(()) +}