diff --git a/crates/configuration/src/parachain.rs b/crates/configuration/src/parachain.rs index 6e5574b8d..98888e94d 100644 --- a/crates/configuration/src/parachain.rs +++ b/crates/configuration/src/parachain.rs @@ -141,6 +141,13 @@ pub struct ParachainConfig { genesis_overrides: Option, #[serde(skip_serializing_if = "std::vec::Vec::is_empty", default)] pub(crate) collators: Vec, + // Single collator config, added for backward compatibility + // with `toml` networks definitions from v1. + // This field can only be set loading an old `toml` definition + // with `[parachain.collator]` key. + // NOTE: if the file also contains multiple collators defined in + // `[[parachain.collators]], the single configuration will be added to the bottom. + collator: Option, } impl ParachainConfig { @@ -246,7 +253,11 @@ impl ParachainConfig { /// The collators of the parachain. pub fn collators(&self) -> Vec<&NodeConfig> { - self.collators.iter().collect::>() + let mut cols = self.collators.iter().collect::>(); + if let Some(col) = self.collator.as_ref() { + cols.push(col); + } + cols } } @@ -304,6 +315,7 @@ impl Default for ParachainConfigBuilder { is_cumulus_based: true, bootnodes_addresses: vec![], collators: vec![], + collator: None, }, validation_context: Default::default(), errors: vec![], @@ -1233,6 +1245,7 @@ mod tests { let parachain = load_from_toml_small.parachains()[0]; assert_eq!(parachain.registration_strategy(), None); + assert_eq!(parachain.collators().len(), 1); } #[test] diff --git a/crates/configuration/testing/snapshots/0003-small-network_w_parachain.toml b/crates/configuration/testing/snapshots/0003-small-network_w_parachain.toml index b998a14c0..a330ec7c8 100644 --- a/crates/configuration/testing/snapshots/0003-small-network_w_parachain.toml +++ b/crates/configuration/testing/snapshots/0003-small-network_w_parachain.toml @@ -32,7 +32,7 @@ default_db_snapshot = "https://storage.com/path/to/db_snapshot.tgz" chain_spec_path = "/path/to/my/chain/spec.json" cumulus_based = true -[[parachains.collators]] +[parachains.collator] name = "john" validator = true invulnerable = true