From 764f5ec7cfca83a0ebd5b25bb96ba955653f068c Mon Sep 17 00:00:00 2001 From: Hernando Castano Date: Fri, 23 Apr 2021 14:40:36 -0400 Subject: [PATCH 1/3] Add `rococo-dev` chain option --- cli/src/command.rs | 3 ++- node/service/src/chain_spec.rs | 30 ++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/cli/src/command.rs b/cli/src/command.rs index bf8a1d218806..a76aaec6523e 100644 --- a/cli/src/command.rs +++ b/cli/src/command.rs @@ -88,6 +88,7 @@ impl SubstrateCli for Cli { "westend-staging" => Box::new(service::chain_spec::westend_staging_testnet_config()?), "rococo-staging" => Box::new(service::chain_spec::rococo_staging_testnet_config()?), "rococo-local" => Box::new(service::chain_spec::rococo_local_testnet_config()?), + "rococo-dev" => Box::new(service::chain_spec::rococo_development_config()?), "rococo" => Box::new(service::chain_spec::rococo_config()?), "wococo" => Box::new(service::chain_spec::wococo_config()?), path => { @@ -140,7 +141,7 @@ fn set_default_ss58_version(spec: &Box) { } const DEV_ONLY_ERROR_PATTERN: &'static str = - "can only use subcommand with --chain [polkadot-dev, kusama-dev, westend-dev], got "; + "can only use subcommand with --chain [polkadot-dev, kusama-dev, westend-dev, rococo-dev], got "; fn ensure_dev(spec: &Box) -> std::result::Result<(), String> { if spec.is_dev() { diff --git a/node/service/src/chain_spec.rs b/node/service/src/chain_spec.rs index 0eba38ead14a..2d883cedeac0 100644 --- a/node/service/src/chain_spec.rs +++ b/node/service/src/chain_spec.rs @@ -1509,6 +1509,15 @@ fn westend_development_config_genesis(wasm_binary: &[u8]) -> westend::GenesisCon ) } +fn rococo_development_config_genesis(wasm_binary: &[u8]) -> rococo_runtime::GenesisConfig { + rococo_testnet_genesis( + wasm_binary, + vec![get_authority_keys_from_seed("Alice")], + get_account_id_from_seed::("Alice"), + None, + ) +} + /// Polkadot development config (single validator Alice) pub fn polkadot_development_config() -> Result { let wasm_binary = polkadot::WASM_BINARY.ok_or("Polkadot development wasm not available")?; @@ -1560,6 +1569,27 @@ pub fn westend_development_config() -> Result { )) } +/// Rococo development config (single validator Alice) +pub fn rococo_development_config() -> Result { + let wasm_binary = rococo::WASM_BINARY.ok_or("Rococo development wasm not available")?; + + Ok(RococoChainSpec::from_genesis( + "Development", + "rococo_dev", + ChainType::Development, + move || RococoGenesisExt { + runtime_genesis_config: rococo_development_config_genesis(wasm_binary), + // Use 1 minute session length. + session_length_in_blocks: Some(10), + }, + vec![], + None, + Some(DEFAULT_PROTOCOL_ID), + None, + Default::default(), + )) +} + fn polkadot_local_testnet_genesis(wasm_binary: &[u8]) -> polkadot::GenesisConfig { polkadot_testnet_genesis( wasm_binary, From 7a5c5177209e1a2cb41587715490bb98868ff2f4 Mon Sep 17 00:00:00 2001 From: Hernando Castano Date: Fri, 23 Apr 2021 15:20:50 -0400 Subject: [PATCH 2/3] Add `wococo-dev` CLI option --- cli/src/command.rs | 3 ++- node/service/src/chain_spec.rs | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/cli/src/command.rs b/cli/src/command.rs index a76aaec6523e..cf414e49c162 100644 --- a/cli/src/command.rs +++ b/cli/src/command.rs @@ -91,6 +91,7 @@ impl SubstrateCli for Cli { "rococo-dev" => Box::new(service::chain_spec::rococo_development_config()?), "rococo" => Box::new(service::chain_spec::rococo_config()?), "wococo" => Box::new(service::chain_spec::wococo_config()?), + "wococo-dev" => Box::new(service::chain_spec::wococo_development_config()?), path => { let path = std::path::PathBuf::from(path); @@ -141,7 +142,7 @@ fn set_default_ss58_version(spec: &Box) { } const DEV_ONLY_ERROR_PATTERN: &'static str = - "can only use subcommand with --chain [polkadot-dev, kusama-dev, westend-dev, rococo-dev], got "; + "can only use subcommand with --chain [polkadot-dev, kusama-dev, westend-dev, rococo-dev, wococo-dev], got "; fn ensure_dev(spec: &Box) -> std::result::Result<(), String> { if spec.is_dev() { diff --git a/node/service/src/chain_spec.rs b/node/service/src/chain_spec.rs index 2d883cedeac0..905238b2398b 100644 --- a/node/service/src/chain_spec.rs +++ b/node/service/src/chain_spec.rs @@ -1590,6 +1590,28 @@ pub fn rococo_development_config() -> Result { )) } +/// Wococo development config (single validator Alice) +pub fn wococo_development_config() -> Result { + const WOCOCO_DEV_PROTOCOL_ID: &str = "woco"; + let wasm_binary = rococo::WASM_BINARY.ok_or("Wococo development wasm not available")?; + + Ok(RococoChainSpec::from_genesis( + "Development", + "wococo_dev", + ChainType::Development, + move || RococoGenesisExt { + runtime_genesis_config: rococo_development_config_genesis(wasm_binary), + // Use 1 minute session length. + session_length_in_blocks: Some(10), + }, + vec![], + None, + Some(WOCOCO_DEV_PROTOCOL_ID), + None, + Default::default(), + )) +} + fn polkadot_local_testnet_genesis(wasm_binary: &[u8]) -> polkadot::GenesisConfig { polkadot_testnet_genesis( wasm_binary, From c05fc00c8d43ce4587c1185689b579c0c1a1271c Mon Sep 17 00:00:00 2001 From: Hernando Castano Date: Fri, 23 Apr 2021 15:26:11 -0400 Subject: [PATCH 3/3] Sort Chain ID match arms --- cli/src/command.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/cli/src/command.rs b/cli/src/command.rs index cf414e49c162..db771f512313 100644 --- a/cli/src/command.rs +++ b/cli/src/command.rs @@ -74,22 +74,22 @@ impl SubstrateCli for Cli { .unwrap_or("polkadot") } else { id }; Ok(match id { - "polkadot-dev" | "dev" => Box::new(service::chain_spec::polkadot_development_config()?), - "polkadot-local" => Box::new(service::chain_spec::polkadot_local_testnet_config()?), - "polkadot-staging" => Box::new(service::chain_spec::polkadot_staging_testnet_config()?), + "kusama" => Box::new(service::chain_spec::kusama_config()?), "kusama-dev" => Box::new(service::chain_spec::kusama_development_config()?), "kusama-local" => Box::new(service::chain_spec::kusama_local_testnet_config()?), "kusama-staging" => Box::new(service::chain_spec::kusama_staging_testnet_config()?), "polkadot" => Box::new(service::chain_spec::polkadot_config()?), + "polkadot-dev" | "dev" => Box::new(service::chain_spec::polkadot_development_config()?), + "polkadot-local" => Box::new(service::chain_spec::polkadot_local_testnet_config()?), + "polkadot-staging" => Box::new(service::chain_spec::polkadot_staging_testnet_config()?), + "rococo" => Box::new(service::chain_spec::rococo_config()?), + "rococo-dev" => Box::new(service::chain_spec::rococo_development_config()?), + "rococo-local" => Box::new(service::chain_spec::rococo_local_testnet_config()?), + "rococo-staging" => Box::new(service::chain_spec::rococo_staging_testnet_config()?), "westend" => Box::new(service::chain_spec::westend_config()?), - "kusama" => Box::new(service::chain_spec::kusama_config()?), "westend-dev" => Box::new(service::chain_spec::westend_development_config()?), "westend-local" => Box::new(service::chain_spec::westend_local_testnet_config()?), "westend-staging" => Box::new(service::chain_spec::westend_staging_testnet_config()?), - "rococo-staging" => Box::new(service::chain_spec::rococo_staging_testnet_config()?), - "rococo-local" => Box::new(service::chain_spec::rococo_local_testnet_config()?), - "rococo-dev" => Box::new(service::chain_spec::rococo_development_config()?), - "rococo" => Box::new(service::chain_spec::rococo_config()?), "wococo" => Box::new(service::chain_spec::wococo_config()?), "wococo-dev" => Box::new(service::chain_spec::wococo_development_config()?), path => {