Skip to content

Commit 1458617

Browse files
authored
chore: allow empty relays list in the config (#344)
1 parent c69fee2 commit 1458617

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

crates/common/src/config/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ pub use utils::*;
2626
#[derive(Debug, Deserialize, Serialize)]
2727
pub struct CommitBoostConfig {
2828
pub chain: Chain,
29+
#[serde(default)]
2930
pub relays: Vec<RelayConfig>,
3031
pub pbs: StaticPbsConfig,
3132
#[serde(flatten)]

crates/common/src/config/pbs.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,14 @@ pub async fn load_pbs_config() -> Result<PbsModuleConfig> {
229229
let config = CommitBoostConfig::from_env_path()?;
230230
config.validate().await?;
231231

232+
// Make sure relays isn't empty - since the config is still technically valid if
233+
// there are no relays for things like Docker compose generation, this check
234+
// isn't in validate().
235+
ensure!(
236+
!config.relays.is_empty(),
237+
"At least one relay must be configured to run the PBS service"
238+
);
239+
232240
// use endpoint from env if set, otherwise use default host and port
233241
let endpoint = if let Some(endpoint) = load_optional_env_var(PBS_ENDPOINT_ENV) {
234242
endpoint.parse()?

tests/tests/config.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,3 +170,15 @@ async fn test_validate_missing_rpc_url() -> Result<()> {
170170
.contains("rpc_url is required if extra_validation_enabled is true"));
171171
Ok(())
172172
}
173+
174+
#[tokio::test]
175+
async fn test_validate_config_with_no_relays() -> Result<()> {
176+
// Create a config with no relays
177+
let mut config = load_happy_config().await?;
178+
config.relays.clear();
179+
180+
// Make sure it validates correctly
181+
let result = config.validate().await;
182+
assert!(result.is_ok());
183+
Ok(())
184+
}

0 commit comments

Comments
 (0)