diff --git a/crates/configuration/src/network.rs b/crates/configuration/src/network.rs index 9569f6fdf64dfb5ec1d06e5f2725ccf2f04ec964..6dc94955dd65514f65a7a0efbfd0f9bd8f8823f3 100644 --- a/crates/configuration/src/network.rs +++ b/crates/configuration/src/network.rs @@ -82,7 +82,7 @@ impl NetworkConfig { // retrieve the defaults relaychain for assigning to nodes if needed let relaychain_default_command: Option<Command> = - network_config.relaychain().default_command().cloned(); + network_config.relaychain().default_command().cloned() | network_config.relaychain().command().cloned(); let relaychain_default_image: Option<Image> = network_config.relaychain().default_image().cloned(); diff --git a/crates/configuration/src/parachain.rs b/crates/configuration/src/parachain.rs index 8dd9c9bcd9a8c3f01041ce59794ff395c4ed690e..bc2989bd7b2d7506d330e15aa73a4e43ebdd2fc7 100644 --- a/crates/configuration/src/parachain.rs +++ b/crates/configuration/src/parachain.rs @@ -119,7 +119,7 @@ pub struct ParachainConfig { genesis_state_generator: Option<Command>, chain_spec_path: Option<AssetLocation>, #[serde(rename = "cumulus_based")] - is_cumulus_based: bool, + is_cumulus_based: Option<bool>, #[serde(skip_serializing_if = "std::vec::Vec::is_empty", default)] bootnodes_addresses: Vec<Multiaddr>, genesis_overrides: Option<serde_json::Value>, @@ -210,7 +210,11 @@ impl ParachainConfig { /// Whether the parachain is based on cumulus. pub fn is_cumulus_based(&self) -> bool { - self.is_cumulus_based + if let Some(true) = self.is_cumulus_based { + true + } else { + false + } } /// The bootnodes addresses the collators will connect to. @@ -258,7 +262,7 @@ impl Default for ParachainConfigBuilder<Initial> { genesis_state_generator: None, genesis_overrides: None, chain_spec_path: None, - is_cumulus_based: true, + is_cumulus_based: Some(true), bootnodes_addresses: vec![], collators: vec![], }, @@ -575,7 +579,7 @@ impl ParachainConfigBuilder<WithId> { pub fn cumulus_based(self, choice: bool) -> Self { Self::transition( ParachainConfig { - is_cumulus_based: choice, + is_cumulus_based: Some(choice), ..self.config }, self.validation_context, diff --git a/crates/configuration/src/relaychain.rs b/crates/configuration/src/relaychain.rs index f226b79d7ba985e3042989ce3bbf746f37bee898..cbf6fa80827a95b90333bea7a6eccef408f37a6f 100644 --- a/crates/configuration/src/relaychain.rs +++ b/crates/configuration/src/relaychain.rs @@ -28,6 +28,7 @@ pub struct RelaychainConfig { #[serde(skip_serializing_if = "std::vec::Vec::is_empty", default)] nodes: Vec<NodeConfig>, genesis_overrides: Option<serde_json::Value>, + command: Option<Command>, } impl RelaychainConfig { @@ -66,6 +67,12 @@ impl RelaychainConfig { self.chain_spec_path.as_ref() } + /// The non-default command used for nodes. + pub fn command(&self) -> Option<&Command> { + self.command.as_ref() + } + + /// The number of `random nominators` to create for chains using staking, this is used in tandem with `max_nominations` to simulate the amount of nominators and nominations. pub fn random_nominators_count(&self) -> Option<u32> { self.random_nominators_count @@ -118,6 +125,7 @@ impl Default for RelaychainConfigBuilder<Initial> { default_db_snapshot: None, default_args: vec![], chain_spec_path: None, + command: None, random_nominators_count: None, max_nominations: None, genesis_overrides: None, diff --git a/crates/examples/examples/0001-simple.toml b/crates/examples/examples/0001-simple.toml index 53f1bcfba9ab553fa81e93809bf6ea024352add2..020072c542bce286b99bfaa04e6352b54217bf42 100644 --- a/crates/examples/examples/0001-simple.toml +++ b/crates/examples/examples/0001-simple.toml @@ -1,22 +1,27 @@ [settings] timeout = 1000 +node_spawn_timeout = 1000 [relaychain] default_image = "docker.io/parity/polkadot-sdk:latest" chain = "rococo-local" -command = "polkadot" +default_command = "polkadot" [[relaychain.nodes]] name = "alice" args = [ "--alice", "-lruntime=debug,parachain=trace" ] + is_bootnode = true [[relaychain.nodes]] name = "bob" args = [ "--bob", "-lruntime=debug,parachain=trace" ] + is_bootnode = true [[parachains]] id = 100 addToGenesis = false +balance = 200000000 +chain="some" [parachains.collator] name = "collator01" diff --git a/crates/examples/examples/simple_network_example.rs b/crates/examples/examples/simple_network_example.rs index dff2f03bbb59645c103886bc68fc6dd66b1a9cfc..d30c043a162060823b55d805604ba7c2f024a177 100644 --- a/crates/examples/examples/simple_network_example.rs +++ b/crates/examples/examples/simple_network_example.rs @@ -1,16 +1,23 @@ +use std::time::Duration; + use configuration::NetworkConfig; +use orchestrator::Orchestrator; +use provider::NativeProvider; +use support::fs::local::LocalFileSystem; -fn main() { +#[tokio::main] +async fn main() -> Result<(), Box<dyn std::error::Error>> { + let config = NetworkConfig::load_from_toml("./crates/examples/examples/0001-simple.toml").expect("errored?"); - let load_from_toml = - NetworkConfig::load_from_toml("./0001-simple.toml").unwrap(); + let fs = LocalFileSystem; + let provider = NativeProvider::new(fs.clone()); + let orchestrator = Orchestrator::new(fs, provider); + orchestrator.spawn(config).await?; + println!("🚀🚀🚀🚀 network deployed"); + // For now let just loop.... + #[allow(clippy::empty_loop)] + loop {} - // let config = NetworkConfigBuilder::new() - // .with_relaychain(|r| { - // r.with_chain("rococo-local") - // .with_node(|node| node.with_name("alice").with_command("polkadot")) - // }) - // .build(); + // Ok(()) - println!("{:?}", load_from_toml); }