Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions crates/common/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ pub use utils::*;
#[derive(Debug, Deserialize, Serialize)]
pub struct CommitBoostConfig {
pub chain: Chain,
#[serde(default)]
pub relays: Vec<RelayConfig>,
pub pbs: StaticPbsConfig,
#[serde(flatten)]
Expand Down
8 changes: 8 additions & 0 deletions crates/common/src/config/pbs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,14 @@ pub async fn load_pbs_config() -> Result<PbsModuleConfig> {
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()?
Expand Down
12 changes: 12 additions & 0 deletions tests/tests/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}
Loading