From 24d28aec6fbc01cbcd8c6207e0aa7aff6b8867fd Mon Sep 17 00:00:00 2001 From: Branislav Kontur Date: Mon, 2 Sep 2024 13:25:49 +0200 Subject: [PATCH] Re-use `sp_genesis_builder::DEV_RUNTIME_PRESET` --- Cargo.lock | 1 + .../assets/asset-hub-rococo/src/genesis_config_presets.rs | 5 ++--- .../assets/asset-hub-westend/src/genesis_config_presets.rs | 5 ++--- .../bridge-hub-rococo/src/genesis_config_presets.rs | 5 ++--- cumulus/polkadot-parachain/Cargo.toml | 1 + cumulus/polkadot-parachain/src/chain_spec/asset_hubs.rs | 4 ++-- cumulus/polkadot-parachain/src/chain_spec/bridge_hubs.rs | 2 +- 7 files changed, 11 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 89ba98f5fc7f..5b68d2736bdd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -14026,6 +14026,7 @@ dependencies = [ "serde_json", "shell-runtime", "sp-core", + "sp-genesis-builder", "sp-runtime", "staging-xcm", "substrate-build-script-utils", diff --git a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/genesis_config_presets.rs b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/genesis_config_presets.rs index 5cb08f8b6a9f..d61205bf154b 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/genesis_config_presets.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-rococo/src/genesis_config_presets.rs @@ -71,7 +71,6 @@ fn asset_hub_rococo_genesis( /// Encapsulates names of predefined presets. mod preset_names { - pub const PRESET_DEVELOPMENT: &str = "development"; pub const PRESET_LOCAL: &str = "local"; pub const PRESET_GENESIS: &str = "genesis"; } @@ -141,7 +140,7 @@ pub fn get_preset(id: &PresetId) -> Option> { ROC * 1_000_000, 1000.into(), ), - Ok(PRESET_DEVELOPMENT) => asset_hub_rococo_genesis( + Ok(sp_genesis_builder::DEV_RUNTIME_PRESET) => asset_hub_rococo_genesis( // initial collators. vec![( get_account_id_from_seed::("Alice"), @@ -171,7 +170,7 @@ pub fn preset_names() -> Vec { use preset_names::*; vec![ PresetId::from(PRESET_GENESIS), - PresetId::from(PRESET_DEVELOPMENT), + PresetId::from(sp_genesis_builder::DEV_RUNTIME_PRESET), PresetId::from(PRESET_LOCAL), ] } diff --git a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/genesis_config_presets.rs b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/genesis_config_presets.rs index f4f621c0c242..66adcf54d16b 100644 --- a/cumulus/parachains/runtimes/assets/asset-hub-westend/src/genesis_config_presets.rs +++ b/cumulus/parachains/runtimes/assets/asset-hub-westend/src/genesis_config_presets.rs @@ -73,7 +73,6 @@ fn asset_hub_westend_genesis( /// Encapsulates names of predefined presets. mod preset_names { - pub const PRESET_DEVELOPMENT: &str = "development"; pub const PRESET_LOCAL: &str = "local"; pub const PRESET_GENESIS: &str = "genesis"; } @@ -139,7 +138,7 @@ pub fn get_preset(id: &PresetId) -> Option> { WND * 1_000_000, 1000.into(), ), - Ok(PRESET_DEVELOPMENT) => asset_hub_westend_genesis( + Ok(sp_genesis_builder::DEV_RUNTIME_PRESET) => asset_hub_westend_genesis( // initial collators. vec![( get_account_id_from_seed::("Alice"), @@ -169,7 +168,7 @@ pub fn preset_names() -> Vec { use preset_names::*; vec![ PresetId::from(PRESET_GENESIS), - PresetId::from(PRESET_DEVELOPMENT), + PresetId::from(sp_genesis_builder::DEV_RUNTIME_PRESET), PresetId::from(PRESET_LOCAL), ] } diff --git a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/genesis_config_presets.rs b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/genesis_config_presets.rs index 34e9c6be6d7a..461fecffb0ec 100644 --- a/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/genesis_config_presets.rs +++ b/cumulus/parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/genesis_config_presets.rs @@ -80,7 +80,6 @@ fn bridge_hub_rococo_genesis( /// Encapsulates names of predefined presets. mod preset_names { - pub const PRESET_DEVELOPMENT: &str = "development"; pub const PRESET_LOCAL: &str = "local"; } @@ -118,7 +117,7 @@ pub fn get_preset(id: &sp_genesis_builder::PresetId) -> Option("Bob")), rococo_runtime_constants::system_parachain::ASSET_HUB_ID.into(), ), - Ok(PRESET_DEVELOPMENT) => bridge_hub_rococo_genesis( + Ok(sp_genesis_builder::DEV_RUNTIME_PRESET) => bridge_hub_rococo_genesis( // initial collators. vec![ ( @@ -160,5 +159,5 @@ pub fn get_preset(id: &sp_genesis_builder::PresetId) -> Option Vec { use preset_names::*; - vec![PresetId::from(PRESET_DEVELOPMENT), PresetId::from(PRESET_LOCAL)] + vec![PresetId::from(sp_genesis_builder::DEV_RUNTIME_PRESET), PresetId::from(PRESET_LOCAL)] } diff --git a/cumulus/polkadot-parachain/Cargo.toml b/cumulus/polkadot-parachain/Cargo.toml index 383e0f158bf4..e8b49177e1a6 100644 --- a/cumulus/polkadot-parachain/Cargo.toml +++ b/cumulus/polkadot-parachain/Cargo.toml @@ -47,6 +47,7 @@ testnet-parachains-constants = { features = [ # Substrate sp-runtime = { workspace = true } sp-core = { workspace = true, default-features = true } +sp-genesis-builder = { workspace = true, default-features = true } sc-cli = { workspace = true, default-features = true } sc-service = { workspace = true, default-features = true } sc-chain-spec = { workspace = true, default-features = true } diff --git a/cumulus/polkadot-parachain/src/chain_spec/asset_hubs.rs b/cumulus/polkadot-parachain/src/chain_spec/asset_hubs.rs index b6a2ecba0548..20e329946fb9 100644 --- a/cumulus/polkadot-parachain/src/chain_spec/asset_hubs.rs +++ b/cumulus/polkadot-parachain/src/chain_spec/asset_hubs.rs @@ -30,7 +30,7 @@ pub fn asset_hub_westend_development_config() -> GenericChainSpec { .with_name("Westend Asset Hub Development") .with_id("asset-hub-westend-dev") .with_chain_type(ChainType::Local) - .with_genesis_config_preset_name("development") + .with_genesis_config_preset_name(sp_genesis_builder::DEV_RUNTIME_PRESET) .with_properties(properties) .build() } @@ -97,7 +97,7 @@ fn asset_hub_rococo_like_development_config( .with_name(name) .with_id(chain_id) .with_chain_type(ChainType::Local) - .with_genesis_config_preset_name("development") + .with_genesis_config_preset_name(sp_genesis_builder::DEV_RUNTIME_PRESET) .with_properties(properties) .build() } diff --git a/cumulus/polkadot-parachain/src/chain_spec/bridge_hubs.rs b/cumulus/polkadot-parachain/src/chain_spec/bridge_hubs.rs index 07f18fd150d3..60b5bf10e114 100644 --- a/cumulus/polkadot-parachain/src/chain_spec/bridge_hubs.rs +++ b/cumulus/polkadot-parachain/src/chain_spec/bridge_hubs.rs @@ -160,7 +160,7 @@ pub mod rococo { .with_id(super::ensure_id(id).expect("invalid id")) .with_chain_type(chain_type.clone()) .with_genesis_config_preset_name(match chain_type { - ChainType::Development => "development", + ChainType::Development => sp_genesis_builder::DEV_RUNTIME_PRESET, ChainType::Local => "local", _ => panic!("chain_type: {chain_type:?} not supported here!"), })