polkadot-parachain: one chain-spec for all (#2457)

This PR removes some `ChainSpec` types which are not necessary
(left-overs from #1256). Currently `ChainSpec` does not have to be
generic over the specific `RuntimeGenesisConfig`, it is enough to use
single type for all:

https://github.com/paritytech/polkadot-sdk/blob/9f787018857660440182142adc806954d7d07709/cumulus/polkadot-parachain/src/chain_spec/mod.rs#L53-L54


related to: https://github.com/paritytech/polkadot-sdk/issues/25

---------

Co-authored-by: command-bot <>
This commit is contained in:
Michal Kucharczyk
2023-11-25 09:56:17 +01:00
committed by GitHub
parent ffc64fd255
commit d5d15a1802
11 changed files with 137 additions and 241 deletions
@@ -15,7 +15,8 @@
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
use crate::chain_spec::{
get_account_id_from_seed, get_collator_keys_from_seed, Extensions, SAFE_XCM_VERSION,
get_account_id_from_seed, get_collator_keys_from_seed, Extensions, GenericChainSpec,
SAFE_XCM_VERSION,
};
use cumulus_primitives_core::ParaId;
use hex_literal::hex;
@@ -23,16 +24,6 @@ use parachains_common::{AccountId, AssetHubPolkadotAuraId, AuraId, Balance as As
use sc_service::ChainType;
use sp_core::{crypto::UncheckedInto, sr25519};
/// Specialized `ChainSpec` for the normal parachain runtime.
pub type AssetHubPolkadotChainSpec =
sc_service::GenericChainSpec<asset_hub_polkadot_runtime::RuntimeGenesisConfig, Extensions>;
pub type AssetHubKusamaChainSpec =
sc_service::GenericChainSpec<asset_hub_kusama_runtime::RuntimeGenesisConfig, Extensions>;
pub type AssetHubWestendChainSpec =
sc_service::GenericChainSpec<asset_hub_westend_runtime::RuntimeGenesisConfig, Extensions>;
pub type AssetHubRococoChainSpec =
sc_service::GenericChainSpec<asset_hub_rococo_runtime::RuntimeGenesisConfig, Extensions>;
const ASSET_HUB_POLKADOT_ED: AssetHubBalance =
parachains_common::polkadot::currency::EXISTENTIAL_DEPOSIT;
const ASSET_HUB_KUSAMA_ED: AssetHubBalance =
@@ -72,13 +63,13 @@ pub fn asset_hub_westend_session_keys(keys: AuraId) -> asset_hub_westend_runtime
asset_hub_westend_runtime::SessionKeys { aura: keys }
}
pub fn asset_hub_polkadot_development_config() -> AssetHubPolkadotChainSpec {
pub fn asset_hub_polkadot_development_config() -> GenericChainSpec {
let mut properties = sc_chain_spec::Properties::new();
properties.insert("ss58Format".into(), 0.into());
properties.insert("tokenSymbol".into(), "DOT".into());
properties.insert("tokenDecimals".into(), 10.into());
AssetHubPolkadotChainSpec::builder(
GenericChainSpec::builder(
asset_hub_polkadot_runtime::WASM_BINARY
.expect("WASM binary was not built, please build it!"),
Extensions { relay_chain: "polkadot-dev".into(), para_id: 1000 },
@@ -104,13 +95,13 @@ pub fn asset_hub_polkadot_development_config() -> AssetHubPolkadotChainSpec {
.build()
}
pub fn asset_hub_polkadot_local_config() -> AssetHubPolkadotChainSpec {
pub fn asset_hub_polkadot_local_config() -> GenericChainSpec {
let mut properties = sc_chain_spec::Properties::new();
properties.insert("ss58Format".into(), 0.into());
properties.insert("tokenSymbol".into(), "DOT".into());
properties.insert("tokenDecimals".into(), 10.into());
AssetHubPolkadotChainSpec::builder(
GenericChainSpec::builder(
asset_hub_polkadot_runtime::WASM_BINARY
.expect("WASM binary was not built, please build it!"),
Extensions { relay_chain: "polkadot-local".into(), para_id: 1000 },
@@ -152,13 +143,13 @@ pub fn asset_hub_polkadot_local_config() -> AssetHubPolkadotChainSpec {
}
// Not used for syncing, but just to determine the genesis values set for the upgrade from shell.
pub fn asset_hub_polkadot_config() -> AssetHubPolkadotChainSpec {
pub fn asset_hub_polkadot_config() -> GenericChainSpec {
let mut properties = sc_chain_spec::Properties::new();
properties.insert("ss58Format".into(), 0.into());
properties.insert("tokenSymbol".into(), "DOT".into());
properties.insert("tokenDecimals".into(), 10.into());
AssetHubPolkadotChainSpec::builder(
GenericChainSpec::builder(
asset_hub_polkadot_runtime::WASM_BINARY
.expect("WASM binary was not built, please build it!"),
Extensions { relay_chain: "polkadot".into(), para_id: 1000 },
@@ -249,13 +240,13 @@ fn asset_hub_polkadot_genesis(
})
}
pub fn asset_hub_kusama_development_config() -> AssetHubKusamaChainSpec {
pub fn asset_hub_kusama_development_config() -> GenericChainSpec {
let mut properties = sc_chain_spec::Properties::new();
properties.insert("ss58Format".into(), 2.into());
properties.insert("tokenSymbol".into(), "KSM".into());
properties.insert("tokenDecimals".into(), 12.into());
AssetHubKusamaChainSpec::builder(
GenericChainSpec::builder(
asset_hub_kusama_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"),
Extensions { relay_chain: "kusama-dev".into(), para_id: 1000 },
)
@@ -280,13 +271,13 @@ pub fn asset_hub_kusama_development_config() -> AssetHubKusamaChainSpec {
.build()
}
pub fn asset_hub_kusama_local_config() -> AssetHubKusamaChainSpec {
pub fn asset_hub_kusama_local_config() -> GenericChainSpec {
let mut properties = sc_chain_spec::Properties::new();
properties.insert("ss58Format".into(), 2.into());
properties.insert("tokenSymbol".into(), "KSM".into());
properties.insert("tokenDecimals".into(), 12.into());
AssetHubKusamaChainSpec::builder(
GenericChainSpec::builder(
asset_hub_kusama_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"),
Extensions { relay_chain: "kusama-local".into(), para_id: 1000 },
)
@@ -325,13 +316,13 @@ pub fn asset_hub_kusama_local_config() -> AssetHubKusamaChainSpec {
.build()
}
pub fn asset_hub_kusama_config() -> AssetHubKusamaChainSpec {
pub fn asset_hub_kusama_config() -> GenericChainSpec {
let mut properties = sc_chain_spec::Properties::new();
properties.insert("ss58Format".into(), 2.into());
properties.insert("tokenSymbol".into(), "KSM".into());
properties.insert("tokenDecimals".into(), 12.into());
AssetHubKusamaChainSpec::builder(
GenericChainSpec::builder(
asset_hub_kusama_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"),
Extensions { relay_chain: "kusama".into(), para_id: 1000 },
)
@@ -407,12 +398,12 @@ fn asset_hub_kusama_genesis(
})
}
pub fn asset_hub_westend_development_config() -> AssetHubWestendChainSpec {
pub fn asset_hub_westend_development_config() -> GenericChainSpec {
let mut properties = sc_chain_spec::Properties::new();
properties.insert("tokenSymbol".into(), "WND".into());
properties.insert("tokenDecimals".into(), 12.into());
AssetHubWestendChainSpec::builder(
GenericChainSpec::builder(
asset_hub_westend_runtime::WASM_BINARY
.expect("WASM binary was not built, please build it!"),
Extensions { relay_chain: "westend".into(), para_id: 1000 },
@@ -439,12 +430,12 @@ pub fn asset_hub_westend_development_config() -> AssetHubWestendChainSpec {
.build()
}
pub fn asset_hub_westend_local_config() -> AssetHubWestendChainSpec {
pub fn asset_hub_westend_local_config() -> GenericChainSpec {
let mut properties = sc_chain_spec::Properties::new();
properties.insert("tokenSymbol".into(), "WND".into());
properties.insert("tokenDecimals".into(), 12.into());
AssetHubWestendChainSpec::builder(
GenericChainSpec::builder(
asset_hub_westend_runtime::WASM_BINARY
.expect("WASM binary was not built, please build it!"),
Extensions { relay_chain: "westend-local".into(), para_id: 1000 },
@@ -485,12 +476,12 @@ pub fn asset_hub_westend_local_config() -> AssetHubWestendChainSpec {
.build()
}
pub fn asset_hub_westend_config() -> AssetHubWestendChainSpec {
pub fn asset_hub_westend_config() -> GenericChainSpec {
let mut properties = sc_chain_spec::Properties::new();
properties.insert("tokenSymbol".into(), "WND".into());
properties.insert("tokenDecimals".into(), 12.into());
AssetHubWestendChainSpec::builder(
GenericChainSpec::builder(
asset_hub_westend_runtime::WASM_BINARY
.expect("WASM binary was not built, please build it!"),
Extensions { relay_chain: "westend".into(), para_id: 1000 },
@@ -569,7 +560,7 @@ fn asset_hub_westend_genesis(
})
}
pub fn asset_hub_rococo_development_config() -> AssetHubRococoChainSpec {
pub fn asset_hub_rococo_development_config() -> GenericChainSpec {
let mut properties = sc_chain_spec::Properties::new();
properties.insert("ss58Format".into(), 42.into());
properties.insert("tokenSymbol".into(), "ROC".into());
@@ -587,8 +578,8 @@ fn asset_hub_rococo_like_development_config(
name: &str,
chain_id: &str,
para_id: u32,
) -> AssetHubRococoChainSpec {
AssetHubRococoChainSpec::builder(
) -> GenericChainSpec {
GenericChainSpec::builder(
asset_hub_rococo_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"),
Extensions { relay_chain: "rococo-dev".into(), para_id },
)
@@ -614,7 +605,7 @@ fn asset_hub_rococo_like_development_config(
.build()
}
pub fn asset_hub_rococo_local_config() -> AssetHubRococoChainSpec {
pub fn asset_hub_rococo_local_config() -> GenericChainSpec {
let mut properties = sc_chain_spec::Properties::new();
properties.insert("ss58Format".into(), 42.into());
properties.insert("tokenSymbol".into(), "ROC".into());
@@ -632,8 +623,8 @@ fn asset_hub_rococo_like_local_config(
name: &str,
chain_id: &str,
para_id: u32,
) -> AssetHubRococoChainSpec {
AssetHubRococoChainSpec::builder(
) -> GenericChainSpec {
GenericChainSpec::builder(
asset_hub_rococo_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"),
Extensions { relay_chain: "rococo-local".into(), para_id },
)
@@ -673,12 +664,12 @@ fn asset_hub_rococo_like_local_config(
.build()
}
pub fn asset_hub_rococo_genesis_config() -> AssetHubRococoChainSpec {
pub fn asset_hub_rococo_genesis_config() -> GenericChainSpec {
let mut properties = sc_chain_spec::Properties::new();
properties.insert("tokenSymbol".into(), "ROC".into());
properties.insert("tokenDecimals".into(), 12.into());
let para_id = 1000;
AssetHubRococoChainSpec::builder(
GenericChainSpec::builder(
asset_hub_rococo_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"),
Extensions { relay_chain: "rococo".into(), para_id },
)
@@ -14,12 +14,12 @@
// You should have received a copy of the GNU General Public License
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
use crate::chain_spec::{get_account_id_from_seed, get_collator_keys_from_seed};
use crate::chain_spec::{get_account_id_from_seed, get_collator_keys_from_seed, GenericChainSpec};
use cumulus_primitives_core::ParaId;
use parachains_common::Balance as BridgeHubBalance;
use sc_chain_spec::ChainSpec;
use sp_core::sr25519;
use std::{path::PathBuf, str::FromStr};
use std::str::FromStr;
/// Collects all supported BridgeHub configurations
#[derive(Debug, PartialEq)]
@@ -71,31 +71,9 @@ impl FromStr for BridgeHubRuntimeType {
impl BridgeHubRuntimeType {
pub const ID_PREFIX: &'static str = "bridge-hub";
pub fn chain_spec_from_json_file(&self, path: PathBuf) -> Result<Box<dyn ChainSpec>, String> {
match self {
BridgeHubRuntimeType::Polkadot |
BridgeHubRuntimeType::PolkadotLocal |
BridgeHubRuntimeType::PolkadotDevelopment =>
Ok(Box::new(polkadot::BridgeHubChainSpec::from_json_file(path)?)),
BridgeHubRuntimeType::Kusama |
BridgeHubRuntimeType::KusamaLocal |
BridgeHubRuntimeType::KusamaDevelopment =>
Ok(Box::new(kusama::BridgeHubChainSpec::from_json_file(path)?)),
BridgeHubRuntimeType::Westend |
BridgeHubRuntimeType::WestendLocal |
BridgeHubRuntimeType::WestendDevelopment =>
Ok(Box::new(westend::BridgeHubChainSpec::from_json_file(path)?)),
BridgeHubRuntimeType::Rococo |
BridgeHubRuntimeType::RococoLocal |
BridgeHubRuntimeType::RococoDevelopment =>
Ok(Box::new(rococo::BridgeHubChainSpec::from_json_file(path)?)),
}
}
pub fn load_config(&self) -> Result<Box<dyn ChainSpec>, String> {
match self {
BridgeHubRuntimeType::Polkadot =>
Ok(Box::new(polkadot::BridgeHubChainSpec::from_json_bytes(
BridgeHubRuntimeType::Polkadot => Ok(Box::new(GenericChainSpec::from_json_bytes(
&include_bytes!("../../chain-specs/bridge-hub-polkadot.json")[..],
)?)),
BridgeHubRuntimeType::PolkadotLocal => Ok(Box::new(polkadot::local_config(
@@ -110,8 +88,7 @@ impl BridgeHubRuntimeType {
"polkadot-dev",
ParaId::new(1002),
))),
BridgeHubRuntimeType::Kusama =>
Ok(Box::new(kusama::BridgeHubChainSpec::from_json_bytes(
BridgeHubRuntimeType::Kusama => Ok(Box::new(GenericChainSpec::from_json_bytes(
&include_bytes!("../../chain-specs/bridge-hub-kusama.json")[..],
)?)),
BridgeHubRuntimeType::KusamaLocal => Ok(Box::new(kusama::local_config(
@@ -126,8 +103,7 @@ impl BridgeHubRuntimeType {
"kusama-dev",
ParaId::new(1003),
))),
BridgeHubRuntimeType::Westend =>
Ok(Box::new(westend::BridgeHubChainSpec::from_json_bytes(
BridgeHubRuntimeType::Westend => Ok(Box::new(GenericChainSpec::from_json_bytes(
&include_bytes!("../../chain-specs/bridge-hub-westend.json")[..],
)?)),
BridgeHubRuntimeType::WestendLocal => Ok(Box::new(westend::local_config(
@@ -144,8 +120,7 @@ impl BridgeHubRuntimeType {
ParaId::new(1002),
Some("Bob".to_string()),
))),
BridgeHubRuntimeType::Rococo =>
Ok(Box::new(rococo::BridgeHubChainSpec::from_json_bytes(
BridgeHubRuntimeType::Rococo => Ok(Box::new(GenericChainSpec::from_json_bytes(
&include_bytes!("../../chain-specs/bridge-hub-rococo.json")[..],
)?)),
BridgeHubRuntimeType::RococoLocal => Ok(Box::new(rococo::local_config(
@@ -184,7 +159,7 @@ fn ensure_id(id: &str) -> Result<&str, String> {
/// Sub-module for Rococo setup
pub mod rococo {
use super::{get_account_id_from_seed, get_collator_keys_from_seed, sr25519, ParaId};
use crate::chain_spec::{Extensions, SAFE_XCM_VERSION};
use crate::chain_spec::{Extensions, GenericChainSpec, SAFE_XCM_VERSION};
use parachains_common::{AccountId, AuraId};
use sc_chain_spec::ChainType;
@@ -196,9 +171,6 @@ pub mod rococo {
const BRIDGE_HUB_ROCOCO_ED: BridgeHubBalance =
parachains_common::rococo::currency::EXISTENTIAL_DEPOSIT;
/// Specialized `ChainSpec` for the normal parachain runtime.
pub type BridgeHubChainSpec = sc_service::GenericChainSpec<(), Extensions>;
pub fn local_config<ModifyProperties: Fn(&mut sc_chain_spec::Properties)>(
id: &str,
chain_name: &str,
@@ -206,7 +178,7 @@ pub mod rococo {
para_id: ParaId,
bridges_pallet_owner_seed: Option<String>,
modify_props: ModifyProperties,
) -> BridgeHubChainSpec {
) -> GenericChainSpec {
// Rococo defaults
let mut properties = sc_chain_spec::Properties::new();
properties.insert("ss58Format".into(), 42.into());
@@ -214,7 +186,7 @@ pub mod rococo {
properties.insert("tokenDecimals".into(), 12.into());
modify_props(&mut properties);
BridgeHubChainSpec::builder(
GenericChainSpec::builder(
bridge_hub_rococo_runtime::WASM_BINARY
.expect("WASM binary was not built, please build it!"),
Extensions { relay_chain: relay_chain.to_string(), para_id: para_id.into() },
@@ -303,7 +275,8 @@ pub mod rococo {
pub mod kusama {
use super::{BridgeHubBalance, ParaId};
use crate::chain_spec::{
get_account_id_from_seed, get_collator_keys_from_seed, Extensions, SAFE_XCM_VERSION,
get_account_id_from_seed, get_collator_keys_from_seed, Extensions, GenericChainSpec,
SAFE_XCM_VERSION,
};
use parachains_common::{AccountId, AuraId};
use sc_chain_spec::ChainType;
@@ -315,21 +288,18 @@ pub mod kusama {
const BRIDGE_HUB_KUSAMA_ED: BridgeHubBalance =
parachains_common::kusama::currency::EXISTENTIAL_DEPOSIT;
/// Specialized `ChainSpec` for the normal parachain runtime.
pub type BridgeHubChainSpec = sc_service::GenericChainSpec<(), Extensions>;
pub fn local_config(
id: &str,
chain_name: &str,
relay_chain: &str,
para_id: ParaId,
) -> BridgeHubChainSpec {
) -> GenericChainSpec {
let mut properties = sc_chain_spec::Properties::new();
properties.insert("ss58Format".into(), 2.into());
properties.insert("tokenSymbol".into(), "KSM".into());
properties.insert("tokenDecimals".into(), 12.into());
BridgeHubChainSpec::builder(
GenericChainSpec::builder(
bridge_hub_kusama_runtime::WASM_BINARY
.expect("WASM binary was not built, please build it!"),
Extensions { relay_chain: relay_chain.to_string(), para_id: para_id.into() },
@@ -411,7 +381,7 @@ pub mod kusama {
/// Sub-module for Westend setup.
pub mod westend {
use super::{get_account_id_from_seed, get_collator_keys_from_seed, sr25519, ParaId};
use crate::chain_spec::{Extensions, SAFE_XCM_VERSION};
use crate::chain_spec::{Extensions, GenericChainSpec, SAFE_XCM_VERSION};
use parachains_common::{AccountId, AuraId};
use sc_chain_spec::ChainType;
@@ -423,22 +393,18 @@ pub mod westend {
const BRIDGE_HUB_WESTEND_ED: BridgeHubBalance =
parachains_common::westend::currency::EXISTENTIAL_DEPOSIT;
/// Specialized `ChainSpec` for the normal parachain runtime.
pub type BridgeHubChainSpec =
sc_service::GenericChainSpec<bridge_hub_westend_runtime::RuntimeGenesisConfig, Extensions>;
pub fn local_config(
id: &str,
chain_name: &str,
relay_chain: &str,
para_id: ParaId,
bridges_pallet_owner_seed: Option<String>,
) -> BridgeHubChainSpec {
) -> GenericChainSpec {
let mut properties = sc_chain_spec::Properties::new();
properties.insert("tokenSymbol".into(), "WND".into());
properties.insert("tokenDecimals".into(), 12.into());
BridgeHubChainSpec::builder(
GenericChainSpec::builder(
bridge_hub_westend_runtime::WASM_BINARY
.expect("WASM binary was not build, please build it!"),
Extensions { relay_chain: relay_chain.to_string(), para_id: para_id.into() },
@@ -527,7 +493,8 @@ pub mod westend {
pub mod polkadot {
use super::{BridgeHubBalance, ParaId};
use crate::chain_spec::{
get_account_id_from_seed, get_collator_keys_from_seed, Extensions, SAFE_XCM_VERSION,
get_account_id_from_seed, get_collator_keys_from_seed, Extensions, GenericChainSpec,
SAFE_XCM_VERSION,
};
use parachains_common::{AccountId, AuraId};
use sc_chain_spec::ChainType;
@@ -539,21 +506,18 @@ pub mod polkadot {
const BRIDGE_HUB_POLKADOT_ED: BridgeHubBalance =
parachains_common::polkadot::currency::EXISTENTIAL_DEPOSIT;
/// Specialized `ChainSpec` for the normal parachain runtime.
pub type BridgeHubChainSpec = sc_service::GenericChainSpec<(), Extensions>;
pub fn local_config(
id: &str,
chain_name: &str,
relay_chain: &str,
para_id: ParaId,
) -> BridgeHubChainSpec {
) -> GenericChainSpec {
let mut properties = sc_chain_spec::Properties::new();
properties.insert("ss58Format".into(), 0.into());
properties.insert("tokenSymbol".into(), "DOT".into());
properties.insert("tokenDecimals".into(), 10.into());
BridgeHubChainSpec::builder(
GenericChainSpec::builder(
bridge_hub_polkadot_runtime::WASM_BINARY
.expect("WASM binary was not built, please build it!"),
Extensions { relay_chain: relay_chain.to_string(), para_id: para_id.into() },
@@ -15,16 +15,14 @@
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
use crate::chain_spec::{
get_account_id_from_seed, get_collator_keys_from_seed, Extensions, SAFE_XCM_VERSION,
get_account_id_from_seed, get_collator_keys_from_seed, Extensions, GenericChainSpec,
SAFE_XCM_VERSION,
};
use cumulus_primitives_core::ParaId;
use parachains_common::{AccountId, AuraId, Balance as CollectivesBalance};
use sc_service::ChainType;
use sp_core::sr25519;
pub type CollectivesPolkadotChainSpec = sc_service::GenericChainSpec<(), Extensions>;
pub type CollectivesWestendChainSpec = sc_service::GenericChainSpec<(), Extensions>;
const COLLECTIVES_POLKADOT_ED: CollectivesBalance =
parachains_common::polkadot::currency::EXISTENTIAL_DEPOSIT;
const COLLECTIVES_WESTEND_ED: CollectivesBalance =
@@ -39,13 +37,13 @@ pub fn collectives_polkadot_session_keys(
collectives_polkadot_runtime::SessionKeys { aura: keys }
}
pub fn collectives_polkadot_development_config() -> CollectivesPolkadotChainSpec {
pub fn collectives_polkadot_development_config() -> GenericChainSpec {
let mut properties = sc_chain_spec::Properties::new();
properties.insert("ss58Format".into(), 0.into());
properties.insert("tokenSymbol".into(), "DOT".into());
properties.insert("tokenDecimals".into(), 10.into());
CollectivesPolkadotChainSpec::builder(
GenericChainSpec::builder(
collectives_polkadot_runtime::WASM_BINARY
.expect("WASM binary was not built, please build it!"),
Extensions { relay_chain: "polkadot-dev".into(), para_id: 1002 },
@@ -75,13 +73,13 @@ pub fn collectives_polkadot_development_config() -> CollectivesPolkadotChainSpec
}
/// Collectives Polkadot Local Config.
pub fn collectives_polkadot_local_config() -> CollectivesPolkadotChainSpec {
pub fn collectives_polkadot_local_config() -> GenericChainSpec {
let mut properties = sc_chain_spec::Properties::new();
properties.insert("ss58Format".into(), 0.into());
properties.insert("tokenSymbol".into(), "DOT".into());
properties.insert("tokenDecimals".into(), 10.into());
CollectivesPolkadotChainSpec::builder(
GenericChainSpec::builder(
collectives_polkadot_runtime::WASM_BINARY
.expect("WASM binary was not built, please build it!"),
Extensions { relay_chain: "polkadot-local".into(), para_id: 1002 },
@@ -169,13 +167,13 @@ pub fn collectives_westend_session_keys(keys: AuraId) -> collectives_westend_run
collectives_westend_runtime::SessionKeys { aura: keys }
}
pub fn collectives_westend_development_config() -> CollectivesWestendChainSpec {
pub fn collectives_westend_development_config() -> GenericChainSpec {
let mut properties = sc_chain_spec::Properties::new();
properties.insert("ss58Format".into(), 42.into());
properties.insert("tokenSymbol".into(), "WND".into());
properties.insert("tokenDecimals".into(), 12.into());
CollectivesWestendChainSpec::builder(
GenericChainSpec::builder(
collectives_westend_runtime::WASM_BINARY
.expect("WASM binary was not built, please build it!"),
Extensions { relay_chain: "westend-dev".into(), para_id: 1002 },
@@ -205,13 +203,13 @@ pub fn collectives_westend_development_config() -> CollectivesWestendChainSpec {
}
/// Collectives Westend Local Config.
pub fn collectives_westend_local_config() -> CollectivesWestendChainSpec {
pub fn collectives_westend_local_config() -> GenericChainSpec {
let mut properties = sc_chain_spec::Properties::new();
properties.insert("ss58Format".into(), 42.into());
properties.insert("tokenSymbol".into(), "WND".into());
properties.insert("tokenDecimals".into(), 12.into());
CollectivesWestendChainSpec::builder(
GenericChainSpec::builder(
collectives_westend_runtime::WASM_BINARY
.expect("WASM binary was not built, please build it!"),
Extensions { relay_chain: "westend-local".into(), para_id: 1002 },
@@ -15,7 +15,8 @@
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
use crate::chain_spec::{
get_account_id_from_seed, get_collator_keys_from_seed, Extensions, SAFE_XCM_VERSION,
get_account_id_from_seed, get_collator_keys_from_seed, Extensions, GenericChainSpec,
SAFE_XCM_VERSION,
};
use cumulus_primitives_core::ParaId;
use hex_literal::hex;
@@ -23,8 +24,6 @@ use parachains_common::{AccountId, AuraId};
use sc_service::ChainType;
use sp_core::{crypto::UncheckedInto, sr25519};
pub type ContractsRococoChainSpec = sc_service::GenericChainSpec<(), Extensions>;
/// No relay chain suffix because the id is the same over all relay chains.
const CONTRACTS_PARACHAIN_ID: u32 = 1002;
@@ -32,12 +31,12 @@ const CONTRACTS_PARACHAIN_ID: u32 = 1002;
const CONTRACTS_ROCOCO_ED: contracts_rococo_runtime::Balance =
parachains_common::rococo::currency::EXISTENTIAL_DEPOSIT;
pub fn contracts_rococo_development_config() -> ContractsRococoChainSpec {
pub fn contracts_rococo_development_config() -> GenericChainSpec {
let mut properties = sc_chain_spec::Properties::new();
properties.insert("tokenSymbol".into(), "ROC".into());
properties.insert("tokenDecimals".into(), 12.into());
ContractsRococoChainSpec::builder(
GenericChainSpec::builder(
contracts_rococo_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"),
Extensions {
relay_chain: "rococo-local".into(), // You MUST set this to the correct network!
@@ -79,12 +78,12 @@ pub fn contracts_rococo_development_config() -> ContractsRococoChainSpec {
.build()
}
pub fn contracts_rococo_local_config() -> ContractsRococoChainSpec {
pub fn contracts_rococo_local_config() -> GenericChainSpec {
let mut properties = sc_chain_spec::Properties::new();
properties.insert("tokenSymbol".into(), "ROC".into());
properties.insert("tokenDecimals".into(), 12.into());
ContractsRococoChainSpec::builder(
GenericChainSpec::builder(
contracts_rococo_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"),
Extensions {
relay_chain: "rococo-local".into(), // You MUST set this to the correct network!
@@ -126,13 +125,13 @@ pub fn contracts_rococo_local_config() -> ContractsRococoChainSpec {
.build()
}
pub fn contracts_rococo_config() -> ContractsRococoChainSpec {
pub fn contracts_rococo_config() -> GenericChainSpec {
// Give your base currency a unit name and decimal places
let mut properties = sc_chain_spec::Properties::new();
properties.insert("tokenSymbol".into(), "ROC".into());
properties.insert("tokenDecimals".into(), 12.into());
ContractsRococoChainSpec::builder(
GenericChainSpec::builder(
contracts_rococo_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"),
Extensions { relay_chain: "rococo".into(), para_id: CONTRACTS_PARACHAIN_ID }
)
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
use crate::chain_spec::{get_account_id_from_seed, Extensions};
use crate::chain_spec::{get_account_id_from_seed, Extensions, GenericChainSpec};
use cumulus_primitives_core::ParaId;
use parachains_common::AuraId;
use sc_service::ChainType;
@@ -22,12 +22,8 @@ use sp_core::sr25519;
use super::get_collator_keys_from_seed;
/// Specialized `ChainSpec` for the Glutton parachain runtime.
pub type GluttonChainSpec = sc_service::GenericChainSpec<(), Extensions>;
pub type GluttonWestendChainSpec = sc_service::GenericChainSpec<(), Extensions>;
pub fn glutton_development_config(para_id: ParaId) -> GluttonChainSpec {
GluttonChainSpec::builder(
pub fn glutton_development_config(para_id: ParaId) -> GenericChainSpec {
GenericChainSpec::builder(
glutton_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"),
Extensions { relay_chain: "kusama-dev".into(), para_id: para_id.into() },
)
@@ -41,8 +37,8 @@ pub fn glutton_development_config(para_id: ParaId) -> GluttonChainSpec {
.build()
}
pub fn glutton_local_config(para_id: ParaId) -> GluttonChainSpec {
GluttonChainSpec::builder(
pub fn glutton_local_config(para_id: ParaId) -> GenericChainSpec {
GenericChainSpec::builder(
glutton_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"),
Extensions { relay_chain: "kusama-local".into(), para_id: para_id.into() },
)
@@ -59,11 +55,11 @@ pub fn glutton_local_config(para_id: ParaId) -> GluttonChainSpec {
.build()
}
pub fn glutton_config(para_id: ParaId) -> GluttonChainSpec {
pub fn glutton_config(para_id: ParaId) -> GenericChainSpec {
let mut properties = sc_chain_spec::Properties::new();
properties.insert("ss58Format".into(), 2.into());
GluttonChainSpec::builder(
GenericChainSpec::builder(
glutton_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"),
Extensions { relay_chain: "kusama".into(), para_id: para_id.into() },
)
@@ -94,8 +90,8 @@ fn glutton_genesis(parachain_id: ParaId, collators: Vec<AuraId>) -> serde_json::
})
}
pub fn glutton_westend_development_config(para_id: ParaId) -> GluttonWestendChainSpec {
GluttonWestendChainSpec::builder(
pub fn glutton_westend_development_config(para_id: ParaId) -> GenericChainSpec {
GenericChainSpec::builder(
glutton_westend_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"),
Extensions { relay_chain: "westend-dev".into(), para_id: para_id.into() },
)
@@ -109,8 +105,8 @@ pub fn glutton_westend_development_config(para_id: ParaId) -> GluttonWestendChai
.build()
}
pub fn glutton_westend_local_config(para_id: ParaId) -> GluttonWestendChainSpec {
GluttonWestendChainSpec::builder(
pub fn glutton_westend_local_config(para_id: ParaId) -> GenericChainSpec {
GenericChainSpec::builder(
glutton_westend_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"),
Extensions { relay_chain: "westend-local".into(), para_id: para_id.into() },
)
@@ -127,11 +123,11 @@ pub fn glutton_westend_local_config(para_id: ParaId) -> GluttonWestendChainSpec
.build()
}
pub fn glutton_westend_config(para_id: ParaId) -> GluttonWestendChainSpec {
pub fn glutton_westend_config(para_id: ParaId) -> GenericChainSpec {
let mut properties = sc_chain_spec::Properties::new();
properties.insert("ss58Format".into(), 42.into());
GluttonChainSpec::builder(
GenericChainSpec::builder(
glutton_westend_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"),
Extensions { relay_chain: "westend".into(), para_id: para_id.into() },
)
@@ -50,6 +50,9 @@ impl Extensions {
}
}
/// Generic chain spec for all polkadot-parachain runtimes
pub type GenericChainSpec = sc_service::GenericChainSpec<(), Extensions>;
/// Helper function to generate a crypto pair from seed
pub fn get_from_seed<TPublic: Public>(seed: &str) -> <TPublic::Pair as Pair>::Public {
TPublic::Pair::from_string(&format!("//{}", seed), None)
@@ -15,23 +15,22 @@
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
use crate::chain_spec::{
get_account_id_from_seed, get_collator_keys_from_seed, Extensions, SAFE_XCM_VERSION,
get_account_id_from_seed, get_collator_keys_from_seed, Extensions, GenericChainSpec,
SAFE_XCM_VERSION,
};
use cumulus_primitives_core::ParaId;
use parachains_common::{AccountId, AuraId};
use sc_service::ChainType;
use sp_core::sr25519;
/// Specialized `ChainSpec` for the normal parachain runtime.
pub type PenpalChainSpec = sc_service::GenericChainSpec<(), Extensions>;
pub fn get_penpal_chain_spec(id: ParaId, relay_chain: &str) -> PenpalChainSpec {
pub fn get_penpal_chain_spec(id: ParaId, relay_chain: &str) -> GenericChainSpec {
// Give your base currency a unit name and decimal places
let mut properties = sc_chain_spec::Properties::new();
properties.insert("tokenSymbol".into(), "UNIT".into());
properties.insert("tokenDecimals".into(), 12u32.into());
properties.insert("ss58Format".into(), 42u32.into());
PenpalChainSpec::builder(
GenericChainSpec::builder(
penpal_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"),
Extensions {
relay_chain: relay_chain.into(), // You MUST set this to the correct network!
@@ -16,7 +16,7 @@
//! ChainSpecs dedicated to Rococo parachain setups (for testing and example purposes)
use crate::chain_spec::{get_from_seed, Extensions, SAFE_XCM_VERSION};
use crate::chain_spec::{get_from_seed, Extensions, GenericChainSpec, SAFE_XCM_VERSION};
use cumulus_primitives_core::ParaId;
use hex_literal::hex;
use parachains_common::AccountId;
@@ -25,10 +25,8 @@ use rococo_parachain_runtime::AuraId;
use sc_chain_spec::ChainType;
use sp_core::{crypto::UncheckedInto, sr25519};
pub type RococoParachainChainSpec = sc_service::GenericChainSpec<(), Extensions>;
pub fn rococo_parachain_local_config() -> RococoParachainChainSpec {
RococoParachainChainSpec::builder(
pub fn rococo_parachain_local_config() -> GenericChainSpec {
GenericChainSpec::builder(
rococo_parachain_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"),
Extensions { relay_chain: "rococo-local".into(), para_id: 1000 },
)
@@ -57,9 +55,9 @@ pub fn rococo_parachain_local_config() -> RococoParachainChainSpec {
.build()
}
pub fn staging_rococo_parachain_local_config() -> RococoParachainChainSpec {
pub fn staging_rococo_parachain_local_config() -> GenericChainSpec {
#[allow(deprecated)]
RococoParachainChainSpec::builder(
GenericChainSpec::builder(
rococo_parachain_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"),
Extensions { relay_chain: "rococo-local".into(), para_id: 1000 },
)
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
use crate::chain_spec::{get_account_id_from_seed, Extensions};
use crate::chain_spec::{get_account_id_from_seed, Extensions, GenericChainSpec};
use cumulus_primitives_core::ParaId;
use parachains_common::{AccountId, AuraId};
use sc_service::ChainType;
@@ -22,11 +22,8 @@ use sp_core::sr25519;
use super::get_collator_keys_from_seed;
/// Specialized `ChainSpec` for the seedling parachain runtime.
pub type SeedlingChainSpec = sc_service::GenericChainSpec<(), Extensions>;
pub fn get_seedling_chain_spec() -> SeedlingChainSpec {
SeedlingChainSpec::builder(
pub fn get_seedling_chain_spec() -> GenericChainSpec {
GenericChainSpec::builder(
seedling_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"),
Extensions { relay_chain: "westend".into(), para_id: 2000 },
)
@@ -14,18 +14,15 @@
// You should have received a copy of the GNU General Public License
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
use crate::chain_spec::Extensions;
use crate::chain_spec::{Extensions, GenericChainSpec};
use cumulus_primitives_core::ParaId;
use parachains_common::AuraId;
use sc_service::ChainType;
use super::get_collator_keys_from_seed;
/// Specialized `ChainSpec` for the shell parachain runtime.
pub type ShellChainSpec = sc_service::GenericChainSpec<(), Extensions>;
pub fn get_shell_chain_spec() -> ShellChainSpec {
ShellChainSpec::builder(
pub fn get_shell_chain_spec() -> GenericChainSpec {
GenericChainSpec::builder(
shell_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"),
Extensions { relay_chain: "westend".into(), para_id: 1000 },
)
+12 -58
View File
@@ -16,6 +16,7 @@
use crate::{
chain_spec,
chain_spec::GenericChainSpec,
cli::{Cli, RelayChainCli, Subcommand},
fake_runtime_api::{
asset_hub_polkadot_aura::RuntimeApi as AssetHubPolkadotRuntimeApi, aura::RuntimeApi,
@@ -128,16 +129,13 @@ fn load_spec(id: &str) -> std::result::Result<Box<dyn ChainSpec>, String> {
// - Defaul-like
"staging" =>
Box::new(chain_spec::rococo_parachain::staging_rococo_parachain_local_config()),
"tick" =>
Box::new(chain_spec::rococo_parachain::RococoParachainChainSpec::from_json_bytes(
"tick" => Box::new(GenericChainSpec::from_json_bytes(
&include_bytes!("../chain-specs/tick.json")[..],
)?),
"trick" =>
Box::new(chain_spec::rococo_parachain::RococoParachainChainSpec::from_json_bytes(
"trick" => Box::new(GenericChainSpec::from_json_bytes(
&include_bytes!("../chain-specs/trick.json")[..],
)?),
"track" =>
Box::new(chain_spec::rococo_parachain::RococoParachainChainSpec::from_json_bytes(
"track" => Box::new(GenericChainSpec::from_json_bytes(
&include_bytes!("../chain-specs/track.json")[..],
)?),
@@ -154,8 +152,7 @@ fn load_spec(id: &str) -> std::result::Result<Box<dyn ChainSpec>, String> {
"asset-hub-polkadot-genesis" | "statemint-genesis" =>
Box::new(chain_spec::asset_hubs::asset_hub_polkadot_config()),
// the shell-based chain spec as used for syncing
"asset-hub-polkadot" | "statemint" =>
Box::new(chain_spec::asset_hubs::AssetHubPolkadotChainSpec::from_json_bytes(
"asset-hub-polkadot" | "statemint" => Box::new(GenericChainSpec::from_json_bytes(
&include_bytes!("../chain-specs/asset-hub-polkadot.json")[..],
)?),
@@ -168,8 +165,7 @@ fn load_spec(id: &str) -> std::result::Result<Box<dyn ChainSpec>, String> {
"asset-hub-kusama-genesis" | "statemine-genesis" =>
Box::new(chain_spec::asset_hubs::asset_hub_kusama_config()),
// the shell-based chain spec as used for syncing
"asset-hub-kusama" | "statemine" =>
Box::new(chain_spec::asset_hubs::AssetHubKusamaChainSpec::from_json_bytes(
"asset-hub-kusama" | "statemine" => Box::new(GenericChainSpec::from_json_bytes(
&include_bytes!("../chain-specs/asset-hub-kusama.json")[..],
)?),
@@ -181,8 +177,7 @@ fn load_spec(id: &str) -> std::result::Result<Box<dyn ChainSpec>, String> {
// the chain spec as used for generating the upgrade genesis values
"asset-hub-rococo-genesis" =>
Box::new(chain_spec::asset_hubs::asset_hub_rococo_genesis_config()),
"asset-hub-rococo" =>
Box::new(chain_spec::asset_hubs::AssetHubRococoChainSpec::from_json_bytes(
"asset-hub-rococo" => Box::new(GenericChainSpec::from_json_bytes(
&include_bytes!("../chain-specs/asset-hub-rococo.json")[..],
)?),
@@ -195,8 +190,7 @@ fn load_spec(id: &str) -> std::result::Result<Box<dyn ChainSpec>, String> {
"asset-hub-westend-genesis" | "westmint-genesis" =>
Box::new(chain_spec::asset_hubs::asset_hub_westend_config()),
// the shell-based chain spec as used for syncing
"asset-hub-westend" | "westmint" =>
Box::new(chain_spec::asset_hubs::AssetHubWestendChainSpec::from_json_bytes(
"asset-hub-westend" | "westmint" => Box::new(GenericChainSpec::from_json_bytes(
&include_bytes!("../chain-specs/asset-hub-westend.json")[..],
)?),
@@ -205,16 +199,14 @@ fn load_spec(id: &str) -> std::result::Result<Box<dyn ChainSpec>, String> {
Box::new(chain_spec::collectives::collectives_polkadot_development_config()),
"collectives-polkadot-local" =>
Box::new(chain_spec::collectives::collectives_polkadot_local_config()),
"collectives-polkadot" =>
Box::new(chain_spec::collectives::CollectivesPolkadotChainSpec::from_json_bytes(
"collectives-polkadot" => Box::new(GenericChainSpec::from_json_bytes(
&include_bytes!("../chain-specs/collectives-polkadot.json")[..],
)?),
"collectives-westend-dev" =>
Box::new(chain_spec::collectives::collectives_westend_development_config()),
"collectives-westend-local" =>
Box::new(chain_spec::collectives::collectives_westend_local_config()),
"collectives-westend" =>
Box::new(chain_spec::collectives::CollectivesWestendChainSpec::from_json_bytes(
"collectives-westend" => Box::new(GenericChainSpec::from_json_bytes(
&include_bytes!("../chain-specs/collectives-westend.json")[..],
)?),
@@ -224,8 +216,7 @@ fn load_spec(id: &str) -> std::result::Result<Box<dyn ChainSpec>, String> {
"contracts-rococo-local" =>
Box::new(chain_spec::contracts::contracts_rococo_local_config()),
"contracts-rococo-genesis" => Box::new(chain_spec::contracts::contracts_rococo_config()),
"contracts-rococo" =>
Box::new(chain_spec::contracts::ContractsRococoChainSpec::from_json_bytes(
"contracts-rococo" => Box::new(GenericChainSpec::from_json_bytes(
&include_bytes!("../chain-specs/contracts-rococo.json")[..],
)?),
@@ -279,44 +270,7 @@ fn load_spec(id: &str) -> std::result::Result<Box<dyn ChainSpec>, String> {
},
// -- Loading a specific spec from disk
path => {
let path: PathBuf = path.into();
match path.runtime() {
Runtime::AssetHubPolkadot => Box::new(
chain_spec::asset_hubs::AssetHubPolkadotChainSpec::from_json_file(path)?,
),
Runtime::AssetHubKusama =>
Box::new(chain_spec::asset_hubs::AssetHubKusamaChainSpec::from_json_file(path)?),
Runtime::AssetHubRococo =>
Box::new(chain_spec::asset_hubs::AssetHubRococoChainSpec::from_json_file(path)?),
Runtime::AssetHubWestend => Box::new(
chain_spec::asset_hubs::AssetHubWestendChainSpec::from_json_file(path)?,
),
Runtime::CollectivesPolkadot => Box::new(
chain_spec::collectives::CollectivesPolkadotChainSpec::from_json_file(path)?,
),
Runtime::CollectivesWestend => Box::new(
chain_spec::collectives::CollectivesWestendChainSpec::from_json_file(path)?,
),
Runtime::Shell =>
Box::new(chain_spec::shell::ShellChainSpec::from_json_file(path)?),
Runtime::Seedling =>
Box::new(chain_spec::seedling::SeedlingChainSpec::from_json_file(path)?),
Runtime::ContractsRococo =>
Box::new(chain_spec::contracts::ContractsRococoChainSpec::from_json_file(path)?),
Runtime::BridgeHub(bridge_hub_runtime_type) =>
bridge_hub_runtime_type.chain_spec_from_json_file(path)?,
Runtime::Penpal(_para_id) =>
Box::new(chain_spec::penpal::PenpalChainSpec::from_json_file(path)?),
Runtime::GluttonWestend =>
Box::new(chain_spec::glutton::GluttonChainSpec::from_json_file(path)?),
Runtime::Glutton =>
Box::new(chain_spec::glutton::GluttonChainSpec::from_json_file(path)?),
Runtime::Default => Box::new(
chain_spec::rococo_parachain::RococoParachainChainSpec::from_json_file(path)?,
),
}
},
path => Box::new(GenericChainSpec::from_json_file(path.into())?),
})
}