diff --git a/Cargo.lock b/Cargo.lock index cb1fe5ec65..5b8c8cfd1a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3379,6 +3379,7 @@ dependencies = [ "sp-block-builder 23.0.0", "sp-consensus-aura 0.29.0", "sp-core 25.0.0", + "sp-genesis-builder 0.4.0", "sp-inherents 23.0.0", "sp-offchain 23.0.0", "sp-runtime 28.0.0", diff --git a/chain-spec-generator/Cargo.toml b/chain-spec-generator/Cargo.toml index e164eb7545..79a4d87cca 100644 --- a/chain-spec-generator/Cargo.toml +++ b/chain-spec-generator/Cargo.toml @@ -40,6 +40,9 @@ bridge-hub-kusama-runtime = { path = "../system-parachains/bridge-hubs/bridge-hu encointer-kusama-runtime = { path = "../system-parachains/encointer" } glutton-kusama-runtime = { path = "../system-parachains/gluttons/glutton-kusama" } +# encointer is not migrated to the latest release, so we use compatible deps, when needed +sp-core-encointer-compatible = { package = "sp-core", version = "25.0.0" } + [features] runtime-benchmarks = [ "asset-hub-polkadot-runtime/runtime-benchmarks", diff --git a/chain-spec-generator/src/system_parachains_specs.rs b/chain-spec-generator/src/system_parachains_specs.rs index d92fac7c27..c3f5ee38fd 100644 --- a/chain-spec-generator/src/system_parachains_specs.rs +++ b/chain-spec-generator/src/system_parachains_specs.rs @@ -44,8 +44,7 @@ pub type BridgeHubKusamaChainSpec = sc_chain_spec::GenericChainSpec<(), Extensio pub type GluttonKusamaChainSpec = sc_chain_spec::GenericChainSpec<(), Extensions>; -pub type EncointerKusamaChainSpec = - sc_chain_spec::GenericChainSpec; +pub type EncointerKusamaChainSpec = sc_chain_spec::GenericChainSpec<(), Extensions>; const ASSET_HUB_POLKADOT_ED: Balance = parachains_common::polkadot::currency::EXISTENTIAL_DEPOSIT; @@ -518,55 +517,43 @@ pub fn glutton_kusama_local_testnet_config() -> Result, Strin } // EncointerKusama -fn encointer_kusama_genesis( - wasm_binary: &[u8], - endowed_accounts: Vec, - id: ParaId, -) -> encointer_kusama_runtime::RuntimeGenesisConfig { - encointer_kusama_runtime::RuntimeGenesisConfig { - system: encointer_kusama_runtime::SystemConfig { - code: wasm_binary.to_vec(), - ..Default::default() - }, - balances: encointer_kusama_runtime::BalancesConfig { +fn encointer_kusama_genesis(endowed_accounts: Vec, id: u32) -> serde_json::Value { + // The Encointer may not be migrated to the latest release, so we use compatible dependencies. + fn get_from_seed( + seed: &str, + ) -> ::Public { + use sp_core_encointer_compatible::Pair; + TPublic::Pair::from_string(&format!("//{}", seed), None) + .expect("static values are valid; qed") + .public() + } + + serde_json::json!({ + "balances": asset_hub_kusama_runtime::BalancesConfig { balances: endowed_accounts .iter() .cloned() .map(|k| (k, ENCOINTER_KUSAMA_ED * 4096)) .collect(), }, - parachain_info: encointer_kusama_runtime::ParachainInfoConfig { - parachain_id: id, + "parachainInfo": encointer_kusama_runtime::ParachainInfoConfig { + parachain_id: id.into(), ..Default::default() }, - collective: Default::default(), - encointer_balances: Default::default(), - encointer_ceremonies: Default::default(), - encointer_communities: Default::default(), - encointer_faucet: Default::default(), - encointer_scheduler: Default::default(), - membership: Default::default(), - treasury: Default::default(), - aura: encointer_kusama_runtime::AuraConfig { - authorities: vec![get_from_seed::("Alice").into()], + "polkadotXcm": { + "safeXcmVersion": Some(SAFE_XCM_VERSION), }, - aura_ext: Default::default(), - parachain_system: Default::default(), - polkadot_xcm: encointer_kusama_runtime::PolkadotXcmConfig { - safe_xcm_version: Some(SAFE_XCM_VERSION), - ..Default::default() + "aura": encointer_kusama_runtime::AuraConfig { + authorities: vec![get_from_seed::("Alice").into()], }, - } + }) } -fn encointer_kusama_local_genesis( - wasm_binary: &[u8], -) -> encointer_kusama_runtime::RuntimeGenesisConfig { +fn encointer_kusama_local_genesis(para_id: u32) -> serde_json::Value { encointer_kusama_genesis( // initial collators. - wasm_binary, testnet_accounts(), - 1001.into(), + para_id, ) } @@ -576,21 +563,16 @@ pub fn encointer_kusama_local_testnet_config() -> Result, Str properties.insert("tokenSymbol".into(), "KSM".into()); properties.insert("tokenDecimals".into(), 12.into()); - let wasm_binary = - encointer_kusama_runtime::WASM_BINARY.ok_or("EncointerKusama wasm not available")?; - - Ok(Box::new(EncointerKusamaChainSpec::from_genesis( - // Name - "Kusama Encointer Local", - // ID - "encointer-kusama-local", - ChainType::Local, - move || encointer_kusama_local_genesis(wasm_binary), - Vec::new(), - None, - None, - None, - Some(properties), - Extensions { relay_chain: "kusama-local".into(), para_id: 1001 }, - ))) + Ok(Box::new( + EncointerKusamaChainSpec::builder( + encointer_kusama_runtime::WASM_BINARY.expect("EncointerKusama wasm not available!"), + Extensions { relay_chain: "kusama-local".into(), para_id: 1001 }, + ) + .with_name("Kusama Encointer Local") + .with_id("encointer-kusama-local") + .with_chain_type(ChainType::Local) + .with_genesis_config_patch(encointer_kusama_local_genesis(1001)) + .with_properties(properties) + .build(), + )) }