Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support single collator config in toml #253

Merged
merged 1 commit into from
Aug 28, 2024
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
15 changes: 14 additions & 1 deletion crates/configuration/src/parachain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,13 @@ pub struct ParachainConfig {
genesis_overrides: Option<serde_json::Value>,
#[serde(skip_serializing_if = "std::vec::Vec::is_empty", default)]
pub(crate) collators: Vec<NodeConfig>,
// 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<NodeConfig>,
}

impl ParachainConfig {
Expand Down Expand Up @@ -246,7 +253,11 @@ impl ParachainConfig {

/// The collators of the parachain.
pub fn collators(&self) -> Vec<&NodeConfig> {
self.collators.iter().collect::<Vec<_>>()
let mut cols = self.collators.iter().collect::<Vec<_>>();
if let Some(col) = self.collator.as_ref() {
cols.push(col);
}
cols
}
}

Expand Down Expand Up @@ -304,6 +315,7 @@ impl<C: Context> Default for ParachainConfigBuilder<Initial, C> {
is_cumulus_based: true,
bootnodes_addresses: vec![],
collators: vec![],
collator: None,
},
validation_context: Default::default(),
errors: vec![],
Expand Down Expand Up @@ -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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading