From f0772baa7a18c9736cfce1414f6970bfe49f4c7a Mon Sep 17 00:00:00 2001 From: NingBo Wang <2536935847@qq.com> Date: Fri, 10 May 2024 15:34:18 +0800 Subject: [PATCH] Fix chain spec (#1243) --- Cargo.lock | 2 + Cargo.toml | 1 + node/cli/src/command.rs | 21 +- node/service/src/chain_spec/bifrost_kusama.rs | 471 +++--------------- .../src/chain_spec/bifrost_polkadot.rs | 304 ++++++----- node/service/src/collator_kusama.rs | 15 - node/service/src/collator_polkadot.rs | 15 - runtime/bifrost-kusama/Cargo.toml | 2 + runtime/bifrost-kusama/src/lib.rs | 11 + runtime/bifrost-polkadot/Cargo.toml | 2 + runtime/bifrost-polkadot/src/lib.rs | 11 + 11 files changed, 245 insertions(+), 610 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9d5afb17f..2d7f7f83f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1088,6 +1088,7 @@ dependencies = [ "sp-block-builder", "sp-consensus-aura", "sp-core", + "sp-genesis-builder", "sp-inherents", "sp-io", "sp-offchain", @@ -1240,6 +1241,7 @@ dependencies = [ "sp-block-builder", "sp-consensus-aura", "sp-core", + "sp-genesis-builder", "sp-inherents", "sp-io", "sp-offchain", diff --git a/Cargo.toml b/Cargo.toml index b110937d8..8884bcc67 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -188,6 +188,7 @@ sp-consensus-slots = { version = "0.32.0", default-featu sp-core = { version = "28.0.0", default-features = false } sp-debug-derive = { version = "14.0.0", default-features = false } sp-externalities = { version = "0.25.0", default-features = false } +sp-genesis-builder = { version = "0.7.0", default-features = false } sp-inherents = { version = "26.0.0", default-features = false } sp-io = { version = "30.0.0", default-features = false } sp-keyring = { version = "31.0.0", default-features = false } diff --git a/node/cli/src/command.rs b/node/cli/src/command.rs index eb1ca5ecf..2eefaf7aa 100644 --- a/node/cli/src/command.rs +++ b/node/cli/src/command.rs @@ -60,14 +60,7 @@ fn load_spec(id: &str) -> std::result::Result, String> { Box::new(service::chain_spec::bifrost_kusama::chainspec_config()), #[cfg(any(feature = "with-bifrost-kusama-runtime", feature = "with-bifrost-runtime"))] "bifrost-local" | "bifrost-kusama-local" => - Box::new(service::chain_spec::bifrost_kusama::local_testnet_config()?), - #[cfg(any(feature = "with-bifrost-kusama-runtime", feature = "with-bifrost-runtime"))] - "bifrost-kusama-rococo" => - Box::new(service::chain_spec::bifrost_kusama::rococo_testnet_config()?), - #[cfg(any(feature = "with-bifrost-kusama-runtime", feature = "with-bifrost-runtime"))] - "bifrost-kusama-rococo-local" => - Box::new(service::chain_spec::bifrost_kusama::rococo_local_config()?), - + Box::new(service::chain_spec::bifrost_kusama::local_testnet_config()), #[cfg(any(feature = "with-bifrost-polkadot-runtime", feature = "with-bifrost-runtime"))] "bifrost-polkadot" => Box::new(service::chain_spec::bifrost_polkadot::ChainSpec::from_json_bytes( @@ -77,11 +70,9 @@ fn load_spec(id: &str) -> std::result::Result, String> { "bifrost-polkadot-genesis" => Box::new(service::chain_spec::bifrost_polkadot::chainspec_config()), #[cfg(any(feature = "with-bifrost-polkadot-runtime", feature = "with-bifrost-runtime"))] "bifrost-polkadot-local" => - Box::new(service::chain_spec::bifrost_polkadot::local_testnet_config()?), - #[cfg(feature = "with-bifrost-kusama-runtime")] - "dev" => Box::new(service::chain_spec::bifrost_kusama::development_config()?), - #[cfg(feature = "with-bifrost-polkadot-runtime")] - "bifrost-polkadot-dev" => Box::new(service::chain_spec::bifrost_polkadot::development_config()?), + Box::new(service::chain_spec::bifrost_polkadot::local_testnet_config()), + #[cfg(any(feature = "with-bifrost-polkadot-runtime", feature = "with-bifrost-runtime"))] + "bifrost-paseo" => Box::new(service::chain_spec::bifrost_polkadot::paseo_config()), path => { let path = std::path::PathBuf::from(path); if path.to_str().map(|s| s.contains("bifrost-polkadot")) == Some(true) { @@ -194,7 +185,7 @@ macro_rules! with_runtime_or_err { if $chain_spec.is_bifrost_kusama() || $chain_spec.is_dev() { #[cfg(any(feature = "with-bifrost-kusama-runtime",feature = "with-bifrost-runtime"))] #[allow(unused_imports)] - use service::collator_kusama::{bifrost_kusama_runtime::{Block, RuntimeApi},BifrostExecutor as Executor,start_node,new_partial}; + use service::collator_kusama::{bifrost_kusama_runtime::{Block, RuntimeApi}, start_node,new_partial}; #[cfg(any(feature = "with-bifrost-kusama-runtime",feature = "with-bifrost-runtime"))] $( $code )* @@ -204,7 +195,7 @@ macro_rules! with_runtime_or_err { } else if $chain_spec.is_bifrost_polkadot() { #[cfg(any(feature = "with-bifrost-polkadot-runtime", feature = "with-bifrost-runtime"))] #[allow(unused_imports)] - use service::collator_polkadot::{bifrost_polkadot_runtime::{Block, RuntimeApi},BifrostPolkadotExecutor as Executor,start_node,new_partial}; + use service::collator_polkadot::{bifrost_polkadot_runtime::{Block, RuntimeApi}, start_node,new_partial}; #[cfg(any(feature = "with-bifrost-polkadot-runtime", feature = "with-bifrost-runtime"))] $( $code )* diff --git a/node/service/src/chain_spec/bifrost_kusama.rs b/node/service/src/chain_spec/bifrost_kusama.rs index 2ebb3cae8..a0561d014 100644 --- a/node/service/src/chain_spec/bifrost_kusama.rs +++ b/node/service/src/chain_spec/bifrost_kusama.rs @@ -16,40 +16,31 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . -use std::{ - fs::{read_dir, File}, - path::PathBuf, -}; - use bifrost_kusama_runtime::{ - constants::currency::DOLLARS, AccountId, AssetRegistryConfig, Balance, BalancesConfig, - BlockNumber, CouncilConfig, CouncilMembershipConfig, DefaultBlocksPerRound, DemocracyConfig, - IndicesConfig, InflationInfo, OracleMembershipConfig, ParachainInfoConfig, - ParachainStakingConfig, PolkadotXcmConfig, Range, RuntimeGenesisConfig, SS58Prefix, SalpConfig, - SessionConfig, TechnicalCommitteeConfig, TechnicalMembershipConfig, TokensConfig, - VestingConfig, + constants::currency::DOLLARS, AccountId, Balance, BalancesConfig, BlockNumber, + DefaultBlocksPerRound, InflationInfo, Range, RuntimeGenesisConfig, SS58Prefix, VestingConfig, }; -use bifrost_primitives::{CurrencyId, CurrencyId::*, TokenInfo, TokenSymbol, TokenSymbol::*}; +use bifrost_primitives::{CurrencyId, CurrencyId::*, TokenInfo, TokenSymbol::*}; use bifrost_runtime_common::AuraId; use cumulus_primitives_core::ParaId; use frame_benchmarking::{account, whitelisted_caller}; use hex_literal::hex; - use sc_chain_spec::Properties; use sc_service::ChainType; -use sc_telemetry::TelemetryEndpoints; use serde::de::DeserializeOwned; use serde_json as json; use sp_core::{crypto::UncheckedInto, sr25519}; -use sp_runtime::traits::Zero; +use sp_runtime::{traits::Zero, Perbill}; +use std::{ + collections::BTreeMap, + fs::{read_dir, File}, + path::PathBuf, +}; -use super::TELEMETRY_URL; use crate::chain_spec::{get_account_id_from_seed, get_from_seed, RelayExtensions}; const DEFAULT_PROTOCOL_ID: &str = "bifrost"; -use sp_runtime::Perbill; - /// Specialized `ChainSpec` for the bifrost runtime. pub type ChainSpec = sc_service::GenericChainSpec; @@ -86,7 +77,7 @@ pub fn inflation_config() -> InflationInfo { } fn bifrost_kusama_properties() -> Properties { - let mut properties = sc_chain_spec::Properties::new(); + let mut properties = Properties::new(); let mut token_symbol: Vec = vec![]; let mut token_decimals: Vec = vec![]; [ @@ -122,7 +113,6 @@ pub fn bifrost_genesis( balances: Vec<(AccountId, Balance)>, vestings: Vec<(AccountId, BlockNumber, BlockNumber, Balance)>, id: ParaId, - tokens: Vec<(AccountId, CurrencyId, Balance)>, council_membership: Vec, technical_committee_membership: Vec, salp_multisig_key: AccountId, @@ -132,34 +122,25 @@ pub fn bifrost_genesis( Vec<(CurrencyId, u32, u32, u32)>, ), oracle_membership: Vec, -) -> RuntimeGenesisConfig { - RuntimeGenesisConfig { - system: Default::default(), - balances: BalancesConfig { balances }, - indices: IndicesConfig { indices: vec![] }, - democracy: DemocracyConfig::default(), - council_membership: CouncilMembershipConfig { - members: council_membership.try_into().expect("convert error!"), - phantom: Default::default(), +) -> serde_json::Value { + serde_json::json!( { + "balances": { + "balances": balances }, - technical_membership: TechnicalMembershipConfig { - members: technical_committee_membership.try_into().expect("convert error!"), - phantom: Default::default(), + "councilMembership": { + "members": council_membership }, - oracle_membership: OracleMembershipConfig { - members: oracle_membership.try_into().expect("convert error!"), - phantom: Default::default(), + "oracleMembership": { + "members": oracle_membership }, - council: CouncilConfig { members: vec![], phantom: Default::default() }, - technical_committee: TechnicalCommitteeConfig { - members: vec![], - phantom: Default::default(), + "technicalCommittee": { + "members": technical_committee_membership }, - treasury: Default::default(), - phragmen_election: Default::default(), - parachain_info: ParachainInfoConfig { parachain_id: id, _config: Default::default() }, - session: SessionConfig { - keys: candidates + "parachainInfo": { + "parachainId": id + }, + "session": { + "keys": candidates .iter() .cloned() .map(|(acc, aura, _)| { @@ -169,104 +150,33 @@ pub fn bifrost_genesis( bifrost_kusama_runtime::SessionKeys { aura }, // session keys ) }) - .collect(), + .collect::>(), + }, + "polkadotXcm": { + "safeXcmVersion": 3 + }, + "vesting": { + "vesting": vestings }, - aura: Default::default(), - aura_ext: Default::default(), - parachain_system: Default::default(), - vesting: VestingConfig { vesting: vestings }, - tokens: TokensConfig { balances: tokens }, - asset_registry: AssetRegistryConfig { - currency: asset_registry.0, - vcurrency: asset_registry.1, - vsbond: asset_registry.2, - phantom: Default::default(), + "assetRegistry": { + "currency": asset_registry.0, + "vcurrency": asset_registry.1, + "vsbond": asset_registry.2 }, - polkadot_xcm: PolkadotXcmConfig { safe_xcm_version: Some(2), _config: Default::default() }, - salp: SalpConfig { initial_multisig_account: Some(salp_multisig_key) }, - parachain_staking: ParachainStakingConfig { - candidates: candidates + "salp": { "initialMultisigAccount": Some(salp_multisig_key) }, + "parachainStaking": { + "candidates": candidates .iter() .cloned() .map(|(account, _, bond)| (account, bond)) - .collect(), - delegations, - inflation_config: inflation_config(), + .collect::>(), + "delegations": delegations, + "inflationConfig": inflation_config(), }, - vtoken_voting: Default::default(), - transaction_payment: Default::default(), - zenlink_protocol: Default::default(), - } + }) } -fn development_config_genesis(id: ParaId) -> RuntimeGenesisConfig { - let endowed_accounts = vec![ - get_account_id_from_seed::("Alice"), - whitelisted_caller(), // Benchmarking whitelist_account - ]; - let balances = endowed_accounts.iter().cloned().map(|x| (x, ENDOWMENT())).collect(); - let vestings = endowed_accounts - .iter() - .cloned() - .map(|x| (x, 0u32, 100u32, ENDOWMENT() / 4)) - .collect(); - let tokens = endowed_accounts - .iter() - .flat_map(|x| { - vec![ - (x.clone(), Stable(KUSD), ENDOWMENT() * 10_000), - (x.clone(), Token(KAR), ENDOWMENT() * 10_000), - (x.clone(), Token(KSM), ENDOWMENT()), - (x.clone(), Token(DOT), ENDOWMENT()), - (x.clone(), VSToken(DOT), ENDOWMENT()), - ] - }) - .collect(); - - let council_membership = vec![get_account_id_from_seed::("Alice")]; - let technical_committee_membership = vec![get_account_id_from_seed::("Alice")]; - let oracle_membership = vec![get_account_id_from_seed::("Alice")]; - - let salp_multisig: AccountId = - hex!["49daa32c7287890f38b7e1a8cd2961723d36d20baa0bf3b82e0c4bdda93b1c0a"].into(); - - bifrost_genesis( - vec![( - get_account_id_from_seed::("Alice"), - get_from_seed::("Alice"), - ENDOWMENT() / 4, - )], - vec![], - balances, - vestings, - id, - tokens, - council_membership, - technical_committee_membership, - salp_multisig, - (vec![], vec![], vec![]), - oracle_membership, - ) -} - -pub fn development_config() -> Result { - #[allow(deprecated)] - Ok(ChainSpec::from_genesis( - "Bifrost Development", - "dev", - ChainType::Development, - move || development_config_genesis(PARA_ID.into()), - vec![], - None, - Some(DEFAULT_PROTOCOL_ID), - None, - Some(bifrost_kusama_properties()), - RelayExtensions { relay_chain: "westend-dev".into(), para_id: PARA_ID }, - bifrost_kusama_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"), - )) -} - -fn local_config_genesis(id: ParaId) -> RuntimeGenesisConfig { +pub fn local_testnet_config() -> ChainSpec { let endowed_accounts = vec![ get_account_id_from_seed::("Alice"), get_account_id_from_seed::("Bob"), @@ -274,12 +184,6 @@ fn local_config_genesis(id: ParaId) -> RuntimeGenesisConfig { get_account_id_from_seed::("Dave"), get_account_id_from_seed::("Eve"), get_account_id_from_seed::("Ferdie"), - get_account_id_from_seed::("Alice//stash"), - get_account_id_from_seed::("Bob//stash"), - get_account_id_from_seed::("Charlie//stash"), - get_account_id_from_seed::("Dave//stash"), - get_account_id_from_seed::("Eve//stash"), - get_account_id_from_seed::("Ferdie//stash"), whitelisted_caller(), // Benchmarking whitelist_account account("bechmarking_account_1", 0, 0), // dKwyFv7RL79j1pAukZnZtAmxwG6a3USBmjZyFCLRSbghdiV @@ -293,27 +197,6 @@ fn local_config_genesis(id: ParaId) -> RuntimeGenesisConfig { .cloned() .map(|x| (x, 0u32, 100u32, ENDOWMENT() / 4)) .collect(); - let tokens = endowed_accounts - .iter() - .flat_map(|x| { - vec![ - (x.clone(), Stable(KUSD), ENDOWMENT() * 10_000), - (x.clone(), Token(KAR), ENDOWMENT() * 10_000), - (x.clone(), Token(KSM), ENDOWMENT() * 4_000_000), - (x.clone(), VSToken(KSM), ENDOWMENT() * 4_000_000), - ( - x.clone(), - CurrencyId::VSBond(TokenSymbol::KSM, 3000, 13, 20), - ENDOWMENT() * 4_000_000, - ), - ( - x.clone(), - CurrencyId::VSBond(TokenSymbol::BNC, 2001, 13, 20), - ENDOWMENT() * 4_000_000, - ), - ] - }) - .collect(); let council_membership = vec![get_account_id_from_seed::("Alice")]; let technical_committee_membership = vec![get_account_id_from_seed::("Alice")]; @@ -327,209 +210,21 @@ fn local_config_genesis(id: ParaId) -> RuntimeGenesisConfig { (Stable(KUSD), DOLLARS / 10_000, None), (Token(KSM), DOLLARS / 10_000, None), (Token(ZLK), DOLLARS / 1000_000, None), - (Token(KAR), DOLLARS / 10_000, None), - (Token(RMRK), DOLLARS / 1000_000, None), - (Token(PHA), 4 * DOLLARS / 100, None), (Token(MOVR), DOLLARS / 1000_000, None), ]; - let vcurrency = vec![VSToken(KSM), VToken(BNC), VToken(KSM), VToken(MOVR)]; + let vcurrency = vec![VToken(BNC), VToken(KSM), VToken(MOVR)]; // vsBond - let vsbond = vec![ - // Token, ParaId, first_slot, last_slot - (Native(BNC), 2001u32, 13u32, 20u32), - (Token(KSM), 2011, 19, 26), - (Token(KSM), 2085, 15, 22), - (Token(KSM), 2087, 17, 24), - (Token(KSM), 2088, 15, 22), - (Token(KSM), 2090, 15, 22), - (Token(KSM), 2092, 15, 22), - (Token(KSM), 2095, 17, 24), - (Token(KSM), 2096, 17, 24), - (Token(KSM), 2100, 18, 25), - (Token(KSM), 2101, 18, 25), - (Token(KSM), 2102, 19, 26), - (Token(KSM), 2102, 21, 28), - (Token(KSM), 2102, 20, 27), - (Token(KSM), 2106, 19, 26), - (Token(KSM), 2114, 20, 27), - (Token(KSM), 2118, 22, 29), - (Token(KSM), 2119, 22, 29), - (Token(KSM), 2121, 22, 29), - (Token(KSM), 2124, 23, 30), - (Token(KSM), 2125, 23, 30), - (Token(KSM), 2127, 23, 30), - (Token(KSM), 2129, 24, 31), - ]; + let vsbond = vec![]; - bifrost_genesis( - vec![ - ( - get_account_id_from_seed::("Alice"), - get_from_seed::("Alice"), - ENDOWMENT() / 4, - ), - ( - get_account_id_from_seed::("Bob"), - get_from_seed::("Bob"), - ENDOWMENT() / 4, - ), - ], - vec![], - balances, - vestings, - id, - tokens, - council_membership, - technical_committee_membership, - salp_multisig, - (currency, vcurrency, vsbond), - oracle_membership, - ) -} - -pub fn local_testnet_config() -> Result { - #[allow(deprecated)] - Ok(ChainSpec::from_genesis( - "Bifrost Local Testnet", - "bifrost_local_testnet", - ChainType::Local, - move || local_config_genesis(PARA_ID.into()), - vec![], - None, - Some(DEFAULT_PROTOCOL_ID), - None, - Some(bifrost_kusama_properties()), - RelayExtensions { relay_chain: "kusama-local".into(), para_id: PARA_ID }, + ChainSpec::builder( bifrost_kusama_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"), - )) -} - -fn rococo_testnet_config_genesis(id: ParaId) -> RuntimeGenesisConfig { - let invulnerables: Vec<(AccountId, AuraId, Balance)> = vec![ - ( - // e2s2dTSWe9kHebF2FCbPGbXftDT7fY5AMDfib3j86zSi3v7 - hex!["66204aeda74f07f77a4b6945681296763706f98d0f8aebb1b9ccdf6e9b7ac13f"].into(), - hex!["66204aeda74f07f77a4b6945681296763706f98d0f8aebb1b9ccdf6e9b7ac13f"] - .unchecked_into(), - ENDOWMENT(), - ), - ( - // fFjUFbokagaDRQUDzVhDcMZQaDwQvvha74RMZnyoSWNpiBQ - hex!["9c2d45edb30d4bf0c285d6809e28c55e871f10578c5a3ea62da152d03761d266"].into(), - hex!["9c2d45edb30d4bf0c285d6809e28c55e871f10578c5a3ea62da152d03761d266"] - .unchecked_into(), - ENDOWMENT(), - ), - ( - // fBAbVJAsbWsKTedTVYGrBB3Usm6Vx635z1N9PX2tZ2boT37 - hex!["98b19fa5a3e98f693b7440de07b4744834ff0072cb704f1c6e33791953ac4924"].into(), - hex!["98b19fa5a3e98f693b7440de07b4744834ff0072cb704f1c6e33791953ac4924"] - .unchecked_into(), - ENDOWMENT(), - ), - ( - // c9eHvgbxTFzijvY3AnAKiRTHhi2hzS5SLCPzCkb4jP79MLu - hex!["12d3ab675d6503279133898efe246a63fdc8be685cc3f7bce079aac064108a7a"].into(), - hex!["12d3ab675d6503279133898efe246a63fdc8be685cc3f7bce079aac064108a7a"] - .unchecked_into(), - ENDOWMENT(), - ), - ]; - - let endowed_accounts: Vec = vec![ - // dDWnEWnx3GUgfugXh9mZtgj4CvJdmd8naYkWYCZGxjfb1Cz - hex!["420398e0150cd9d417fb8fd4027b75bd42717262e6eac97c55f2f8f84e8ffb3f"].into(), - // e2s2dTSWe9kHebF2FCbPGbXftDT7fY5AMDfib3j86zSi3v7 - hex!["66204aeda74f07f77a4b6945681296763706f98d0f8aebb1b9ccdf6e9b7ac13f"].into(), - // fFjUFbokagaDRQUDzVhDcMZQaDwQvvha74RMZnyoSWNpiBQ - hex!["9c2d45edb30d4bf0c285d6809e28c55e871f10578c5a3ea62da152d03761d266"].into(), - // fBAbVJAsbWsKTedTVYGrBB3Usm6Vx635z1N9PX2tZ2boT37 - hex!["98b19fa5a3e98f693b7440de07b4744834ff0072cb704f1c6e33791953ac4924"].into(), - // c9eHvgbxTFzijvY3AnAKiRTHhi2hzS5SLCPzCkb4jP79MLu - hex!["12d3ab675d6503279133898efe246a63fdc8be685cc3f7bce079aac064108a7a"].into(), - ]; - let balances = endowed_accounts.iter().cloned().map(|x| (x, ENDOWMENT())).collect(); - - let salp_multisig: AccountId = - hex!["e4da05f08e89bf6c43260d96f26fffcfc7deae5b465da08669a9d008e64c2c63"].into(); - - let council_membership = vec![ - // dDWnEWnx3GUgfugXh9mZtgj4CvJdmd8naYkWYCZGxjfb1Cz - hex!["420398e0150cd9d417fb8fd4027b75bd42717262e6eac97c55f2f8f84e8ffb3f"].into(), - ]; - let technical_committee_membership = vec![ - // dDWnEWnx3GUgfugXh9mZtgj4CvJdmd8naYkWYCZGxjfb1Cz - hex!["420398e0150cd9d417fb8fd4027b75bd42717262e6eac97c55f2f8f84e8ffb3f"].into(), - ]; - let oracle_membership = vec![ - // dDWnEWnx3GUgfugXh9mZtgj4CvJdmd8naYkWYCZGxjfb1Cz - hex!["420398e0150cd9d417fb8fd4027b75bd42717262e6eac97c55f2f8f84e8ffb3f"].into(), - ]; - - bifrost_genesis( - invulnerables, - vec![], - balances, - vec![], - id, - vec![], - council_membership, - technical_committee_membership, - salp_multisig, - ( - vec![ - (CurrencyId::Token(TokenSymbol::DOT), 100_000_000, None), - (CurrencyId::Token(TokenSymbol::KSM), 10_000_000, None), - ], - vec![], - vec![], - ), - oracle_membership, + RelayExtensions { relay_chain: "kusama-local".into(), para_id: PARA_ID }, ) -} - -pub fn rococo_testnet_config() -> Result { - #[allow(deprecated)] - Ok(ChainSpec::from_genesis( - "Bifrost K Rococo", - "bifrost-k-rococo", - ChainType::Live, - move || rococo_testnet_config_genesis(2030.into()), - vec![], - TelemetryEndpoints::new(vec![(TELEMETRY_URL.into(), 0)]).ok(), - Some(DEFAULT_PROTOCOL_ID), - None, - Some(bifrost_kusama_properties()), - RelayExtensions { relay_chain: "rococo".into(), para_id: 2030 }, - bifrost_kusama_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"), - )) -} - -fn rococo_local_config_genesis(id: ParaId) -> RuntimeGenesisConfig { - let endowed_accounts: Vec = vec![ - get_account_id_from_seed::("Alice"), - get_account_id_from_seed::("Bob"), - get_account_id_from_seed::("Charlie"), - get_account_id_from_seed::("Dave"), - get_account_id_from_seed::("Eve"), - get_account_id_from_seed::("Ferdie"), - get_account_id_from_seed::("Alice//stash"), - get_account_id_from_seed::("Bob//stash"), - get_account_id_from_seed::("Charlie//stash"), - get_account_id_from_seed::("Dave//stash"), - get_account_id_from_seed::("Eve//stash"), - get_account_id_from_seed::("Ferdie//stash"), - ]; - let balances = endowed_accounts.iter().cloned().map(|x| (x, ENDOWMENT())).collect(); - - let salp_multisig: AccountId = get_account_id_from_seed::("Alice"); - - let council_membership = vec![get_account_id_from_seed::("Alice")]; - let technical_committee_membership = vec![get_account_id_from_seed::("Alice")]; - let oracle_membership = vec![get_account_id_from_seed::("Alice")]; - - bifrost_genesis( + .with_name("Bifrost Local Testnet") + .with_id("bifrost_local_testnet") + .with_chain_type(ChainType::Local) + .with_genesis_config_patch(bifrost_genesis( vec![ ( get_account_id_from_seed::("Alice"), @@ -544,52 +239,20 @@ fn rococo_local_config_genesis(id: ParaId) -> RuntimeGenesisConfig { ], vec![], balances, - vec![], - id, - vec![], + vestings, + PARA_ID.into(), council_membership, technical_committee_membership, salp_multisig, - (vec![(Token(DOT), 100_000_000, None), (Token(KSM), 10_000_000, None)], vec![], vec![]), + (currency, vcurrency, vsbond), oracle_membership, - ) -} - -pub fn rococo_local_config() -> Result { - #[allow(deprecated)] - Ok(ChainSpec::from_genesis( - "Bifrost K Rococo Local", - "bifrost-k-rococo-local", - ChainType::Local, - move || rococo_local_config_genesis(2030.into()), - vec![], - TelemetryEndpoints::new(vec![(TELEMETRY_URL.into(), 0)]).ok(), - Some(DEFAULT_PROTOCOL_ID), - None, - Some(bifrost_kusama_properties()), - RelayExtensions { relay_chain: "rococo".into(), para_id: 2030 }, - bifrost_kusama_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"), )) + .with_properties(bifrost_kusama_properties()) + .with_protocol_id(DEFAULT_PROTOCOL_ID) + .build() } pub fn chainspec_config() -> ChainSpec { - #[allow(deprecated)] - ChainSpec::from_genesis( - "Bifrost", - "bifrost", - ChainType::Live, - move || bifrost_config_genesis(PARA_ID.into()), - vec![], - TelemetryEndpoints::new(vec![(TELEMETRY_URL.into(), 0)]).ok(), - Some(DEFAULT_PROTOCOL_ID), - None, - Some(bifrost_kusama_properties()), - RelayExtensions { relay_chain: "kusama".into(), para_id: PARA_ID }, - bifrost_kusama_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"), - ) -} - -fn bifrost_config_genesis(id: ParaId) -> RuntimeGenesisConfig { let invulnerables: Vec<(AccountId, AuraId, Balance)> = vec![ ( // eunwjK45qDugPXhnjxGUcMbifgdtgefzoW7PgMMpr39AXwh @@ -660,20 +323,28 @@ fn bifrost_config_genesis(id: ParaId) -> RuntimeGenesisConfig { let salp_multisig: AccountId = hex!["e4da05f08e89bf6c43260d96f26fffcfc7deae5b465da08669a9d008e64c2c63"].into(); - use sp_core::sp_std::collections::btree_map::BTreeMap; - bifrost_genesis( + ChainSpec::builder( + bifrost_kusama_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"), + RelayExtensions { relay_chain: "kusama".into(), para_id: PARA_ID }, + ) + .with_name("Bifrost") + .with_id("bifrost") + .with_chain_type(ChainType::Live) + .with_genesis_config_patch(bifrost_genesis( invulnerables, vec![], balances, vesting_configs.into_iter().flat_map(|vc| vc.vesting).collect(), - id, - vec![], // tokens + PARA_ID.into(), vec![], // council membership vec![], // technical committee membership salp_multisig, (vec![], vec![], vec![]), vec![], - ) + )) + .with_properties(bifrost_kusama_properties()) + .with_protocol_id(DEFAULT_PROTOCOL_ID) + .build() } fn config_from_json_file(path: PathBuf) -> Result { diff --git a/node/service/src/chain_spec/bifrost_polkadot.rs b/node/service/src/chain_spec/bifrost_polkadot.rs index a16502cd1..b500f9f54 100644 --- a/node/service/src/chain_spec/bifrost_polkadot.rs +++ b/node/service/src/chain_spec/bifrost_polkadot.rs @@ -16,11 +16,9 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . +use crate::chain_spec::{get_account_id_from_seed, get_from_seed, RelayExtensions}; use bifrost_polkadot_runtime::{ - constants::currency::DOLLARS, AccountId, AssetRegistryConfig, Balance, BalancesConfig, - BlockNumber, CollatorSelectionConfig, CouncilMembershipConfig, IndicesConfig, - OracleMembershipConfig, ParachainInfoConfig, PolkadotXcmConfig, RuntimeGenesisConfig, - SS58Prefix, SalpConfig, SessionConfig, TechnicalMembershipConfig, TokensConfig, VestingConfig, + constants::currency::DOLLARS, AccountId, Balance, BlockNumber, RuntimeGenesisConfig, SS58Prefix, }; use bifrost_primitives::{CurrencyId, CurrencyId::*, TokenInfo, TokenSymbol, DOT_TOKEN_ID}; use bifrost_runtime_common::AuraId; @@ -29,12 +27,7 @@ use frame_benchmarking::{account, whitelisted_caller}; use hex_literal::hex; use sc_chain_spec::Properties; use sc_service::ChainType; -use sc_telemetry::TelemetryEndpoints; use sp_core::{crypto::UncheckedInto, sr25519}; -use sp_runtime::traits::Zero; - -use super::TELEMETRY_URL; -use crate::chain_spec::{get_account_id_from_seed, get_from_seed, RelayExtensions}; const DEFAULT_PROTOCOL_ID: &str = "bifrost_polkadot"; @@ -74,7 +67,6 @@ pub fn bifrost_polkadot_genesis( balances: Vec<(AccountId, Balance)>, vestings: Vec<(AccountId, BlockNumber, BlockNumber, Balance)>, id: ParaId, - tokens: Vec<(AccountId, CurrencyId, Balance)>, council_membership: Vec, technical_committee_membership: Vec, salp_multisig_key: AccountId, @@ -84,36 +76,29 @@ pub fn bifrost_polkadot_genesis( Vec<(CurrencyId, u32, u32, u32)>, ), oracle_membership: Vec, -) -> RuntimeGenesisConfig { - RuntimeGenesisConfig { - system: Default::default(), - balances: BalancesConfig { balances }, - indices: IndicesConfig { indices: vec![] }, - democracy: Default::default(), - council_membership: CouncilMembershipConfig { - members: council_membership.try_into().expect("convert error!"), - phantom: Default::default(), +) -> serde_json::Value { + serde_json::json!( { + "balances": { + "balances": balances }, - technical_membership: TechnicalMembershipConfig { - members: technical_committee_membership.try_into().expect("convert error!"), - phantom: Default::default(), + "councilMembership": { + "members": council_membership }, - oracle_membership: OracleMembershipConfig { - members: oracle_membership.try_into().expect("convert error!"), - phantom: Default::default(), + "oracleMembership": { + "members": oracle_membership }, - council: Default::default(), - technical_committee: Default::default(), - treasury: Default::default(), - phragmen_election: Default::default(), - parachain_info: ParachainInfoConfig { parachain_id: id, _config: Default::default() }, - collator_selection: CollatorSelectionConfig { - invulnerables: invulnerables.iter().cloned().map(|(acc, _)| acc).collect(), - candidacy_bond: Zero::zero(), - ..Default::default() + "technicalCommittee": { + "members": technical_committee_membership }, - session: SessionConfig { - keys: invulnerables + "parachainInfo": { + "parachainId": id + }, + "collatorSelection": { + "invulnerables": invulnerables.iter().cloned().map(|(acc, _)| acc).collect::>(), + "candidacyBond": 0 + }, + "session": { + "keys": invulnerables .iter() .cloned() .map(|(acc, aura)| { @@ -123,84 +108,24 @@ pub fn bifrost_polkadot_genesis( bifrost_polkadot_runtime::SessionKeys { aura }, // session keys ) }) - .collect(), + .collect::>(), }, - aura: Default::default(), - aura_ext: Default::default(), - parachain_system: Default::default(), - vesting: VestingConfig { vesting: vestings }, - tokens: TokensConfig { balances: tokens }, - asset_registry: AssetRegistryConfig { - currency: asset_registry.0, - vcurrency: asset_registry.1, - vsbond: asset_registry.2, - phantom: Default::default(), + "vesting": { + "vesting": vestings }, - polkadot_xcm: PolkadotXcmConfig { safe_xcm_version: Some(2), _config: Default::default() }, - salp: SalpConfig { initial_multisig_account: Some(salp_multisig_key) }, - vtoken_voting: Default::default(), - transaction_payment: Default::default(), - zenlink_protocol: Default::default(), - } -} - -fn development_config_genesis(id: ParaId) -> RuntimeGenesisConfig { - let endowed_accounts = vec![ - get_account_id_from_seed::("Alice"), - whitelisted_caller(), // Benchmarking whitelist_account - ]; - let balances = endowed_accounts.iter().cloned().map(|x| (x, ENDOWMENT())).collect(); - let vestings = endowed_accounts - .iter() - .cloned() - .map(|x| (x, 0u32, 100u32, ENDOWMENT() / 4)) - .collect(); - let tokens = endowed_accounts - .iter() - .flat_map(|x| vec![(x.clone(), Token(TokenSymbol::DOT), ENDOWMENT())]) - .collect(); - - let council_membership = vec![get_account_id_from_seed::("Alice")]; - let technical_committee_membership = vec![get_account_id_from_seed::("Alice")]; - let oracle_membership = vec![get_account_id_from_seed::("Alice")]; - let salp_multisig: AccountId = - hex!["49daa32c7287890f38b7e1a8cd2961723d36d20baa0bf3b82e0c4bdda93b1c0a"].into(); - - bifrost_polkadot_genesis( - vec![( - get_account_id_from_seed::("Alice"), - get_from_seed::("Alice"), - )], - balances, - vestings, - id, - tokens, - council_membership, - technical_committee_membership, - salp_multisig, - (vec![], vec![], vec![]), - oracle_membership, - ) -} - -pub fn development_config() -> Result { - #[allow(deprecated)] - Ok(ChainSpec::from_genesis( - "Bifrost Polkadot Development", - "bifrost_polkadot_dev", - ChainType::Development, - move || development_config_genesis(PARA_ID.into()), - vec![], - None, - Some(DEFAULT_PROTOCOL_ID), - None, - Some(bifrost_polkadot_properties()), - RelayExtensions { relay_chain: "polkadot-dev".into(), para_id: PARA_ID }, - bifrost_polkadot_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"), - )) + "assetRegistry": { + "currency": asset_registry.0, + "vcurrency": asset_registry.1, + "vsbond": asset_registry.2 + }, + "polkadotXcm": { + "safeXcmVersion": 3 + }, + "salp": { "initialMultisigAccount": Some(salp_multisig_key) } + }) } -fn local_config_genesis(id: ParaId) -> RuntimeGenesisConfig { +pub fn local_testnet_config() -> ChainSpec { let endowed_accounts = vec![ get_account_id_from_seed::("Alice"), get_account_id_from_seed::("Bob"), @@ -208,25 +133,10 @@ fn local_config_genesis(id: ParaId) -> RuntimeGenesisConfig { get_account_id_from_seed::("Dave"), get_account_id_from_seed::("Eve"), get_account_id_from_seed::("Ferdie"), - get_account_id_from_seed::("Alice//stash"), - get_account_id_from_seed::("Bob//stash"), - get_account_id_from_seed::("Charlie//stash"), - get_account_id_from_seed::("Dave//stash"), - get_account_id_from_seed::("Eve//stash"), - get_account_id_from_seed::("Ferdie//stash"), whitelisted_caller(), // Benchmarking whitelist_account account("bechmarking_account_1", 0, 0), ]; let balances = endowed_accounts.iter().cloned().map(|x| (x, ENDOWMENT())).collect(); - let vestings = endowed_accounts - .iter() - .cloned() - .map(|x| (x, 0u32, 100u32, ENDOWMENT() / 4)) - .collect(); - let tokens = endowed_accounts - .iter() - .flat_map(|x| vec![(x.clone(), Token2(DOT_TOKEN_ID), ENDOWMENT() * 4_000_000)]) - .collect(); let council_membership = vec![get_account_id_from_seed::("Alice")]; let technical_committee_membership = vec![get_account_id_from_seed::("Alice")]; let oracle_membership = vec![get_account_id_from_seed::("Alice")]; @@ -242,7 +152,14 @@ fn local_config_genesis(id: ParaId) -> RuntimeGenesisConfig { ]; let vcurrency = vec![VSToken2(DOT_TOKEN_ID), VToken(TokenSymbol::BNC), VToken2(DOT_TOKEN_ID)]; - bifrost_polkadot_genesis( + ChainSpec::builder( + bifrost_polkadot_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"), + RelayExtensions { relay_chain: "polkadot-local".into(), para_id: PARA_ID }, + ) + .with_name("Bifrost Polkadot Local Testnet") + .with_id("bifrost_polkadot_local_testnet") + .with_chain_type(ChainType::Local) + .with_genesis_config_patch(bifrost_polkadot_genesis( vec![ ( get_account_id_from_seed::("Alice"), @@ -251,52 +168,100 @@ fn local_config_genesis(id: ParaId) -> RuntimeGenesisConfig { (get_account_id_from_seed::("Bob"), get_from_seed::("Bob")), ], balances, - vestings, - id, - tokens, + vec![], + PARA_ID.into(), council_membership, technical_committee_membership, salp_multisig, (currency, vcurrency, vec![]), oracle_membership, - ) -} - -pub fn local_testnet_config() -> Result { - #[allow(deprecated)] - Ok(ChainSpec::from_genesis( - "Bifrost Polkadot Local Testnet", - "bifrost_polkadot_local_testnet", - ChainType::Local, - move || local_config_genesis(PARA_ID.into()), - vec![], - None, - Some(DEFAULT_PROTOCOL_ID), - None, - Some(bifrost_polkadot_properties()), - RelayExtensions { relay_chain: "polkadot-local".into(), para_id: PARA_ID }, - bifrost_polkadot_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"), )) + .with_properties(bifrost_polkadot_properties()) + .with_protocol_id(DEFAULT_PROTOCOL_ID) + .build() } -pub fn chainspec_config() -> ChainSpec { - #[allow(deprecated)] - ChainSpec::from_genesis( - "Bifrost Polkadot", - "bifrost_polkadot", - ChainType::Live, - move || bifrost_polkadot_config_genesis(PARA_ID.into()), - vec![], - TelemetryEndpoints::new(vec![(TELEMETRY_URL.into(), 0)]).ok(), - Some(DEFAULT_PROTOCOL_ID), - None, - Some(bifrost_polkadot_properties()), - RelayExtensions { relay_chain: "polkadot".into(), para_id: PARA_ID }, +pub fn paseo_config() -> ChainSpec { + let invulnerables: Vec<(AccountId, AuraId)> = vec![ + ( + // e2s2dTSWe9kHebF2FCbPGbXftDT7fY5AMDfib3j86zSi3v7 + hex!["66204aeda74f07f77a4b6945681296763706f98d0f8aebb1b9ccdf6e9b7ac13f"].into(), + hex!["66204aeda74f07f77a4b6945681296763706f98d0f8aebb1b9ccdf6e9b7ac13f"] + .unchecked_into(), + ), + ( + // fFjUFbokagaDRQUDzVhDcMZQaDwQvvha74RMZnyoSWNpiBQ + hex!["9c2d45edb30d4bf0c285d6809e28c55e871f10578c5a3ea62da152d03761d266"].into(), + hex!["9c2d45edb30d4bf0c285d6809e28c55e871f10578c5a3ea62da152d03761d266"] + .unchecked_into(), + ), + ( + // fBAbVJAsbWsKTedTVYGrBB3Usm6Vx635z1N9PX2tZ2boT37 + hex!["98b19fa5a3e98f693b7440de07b4744834ff0072cb704f1c6e33791953ac4924"].into(), + hex!["98b19fa5a3e98f693b7440de07b4744834ff0072cb704f1c6e33791953ac4924"] + .unchecked_into(), + ), + ( + // c9eHvgbxTFzijvY3AnAKiRTHhi2hzS5SLCPzCkb4jP79MLu + hex!["12d3ab675d6503279133898efe246a63fdc8be685cc3f7bce079aac064108a7a"].into(), + hex!["12d3ab675d6503279133898efe246a63fdc8be685cc3f7bce079aac064108a7a"] + .unchecked_into(), + ), + ]; + + let endowed_accounts: Vec = vec![ + // dDWnEWnx3GUgfugXh9mZtgj4CvJdmd8naYkWYCZGxjfb1Cz + hex!["420398e0150cd9d417fb8fd4027b75bd42717262e6eac97c55f2f8f84e8ffb3f"].into(), + // e2s2dTSWe9kHebF2FCbPGbXftDT7fY5AMDfib3j86zSi3v7 + hex!["66204aeda74f07f77a4b6945681296763706f98d0f8aebb1b9ccdf6e9b7ac13f"].into(), + // fFjUFbokagaDRQUDzVhDcMZQaDwQvvha74RMZnyoSWNpiBQ + hex!["9c2d45edb30d4bf0c285d6809e28c55e871f10578c5a3ea62da152d03761d266"].into(), + // fBAbVJAsbWsKTedTVYGrBB3Usm6Vx635z1N9PX2tZ2boT37 + hex!["98b19fa5a3e98f693b7440de07b4744834ff0072cb704f1c6e33791953ac4924"].into(), + // c9eHvgbxTFzijvY3AnAKiRTHhi2hzS5SLCPzCkb4jP79MLu + hex!["12d3ab675d6503279133898efe246a63fdc8be685cc3f7bce079aac064108a7a"].into(), + ]; + let balances = endowed_accounts.iter().cloned().map(|x| (x, ENDOWMENT())).collect(); + + let salp_multisig: AccountId = + hex!["e4da05f08e89bf6c43260d96f26fffcfc7deae5b465da08669a9d008e64c2c63"].into(); + + let council_membership = vec![ + // dDWnEWnx3GUgfugXh9mZtgj4CvJdmd8naYkWYCZGxjfb1Cz + hex!["420398e0150cd9d417fb8fd4027b75bd42717262e6eac97c55f2f8f84e8ffb3f"].into(), + ]; + let technical_committee_membership = vec![ + // dDWnEWnx3GUgfugXh9mZtgj4CvJdmd8naYkWYCZGxjfb1Cz + hex!["420398e0150cd9d417fb8fd4027b75bd42717262e6eac97c55f2f8f84e8ffb3f"].into(), + ]; + let oracle_membership = vec![ + // dDWnEWnx3GUgfugXh9mZtgj4CvJdmd8naYkWYCZGxjfb1Cz + hex!["420398e0150cd9d417fb8fd4027b75bd42717262e6eac97c55f2f8f84e8ffb3f"].into(), + ]; + + ChainSpec::builder( bifrost_polkadot_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"), + RelayExtensions { relay_chain: "paseo".into(), para_id: PARA_ID }, ) + .with_name("Bifrost Paseo") + .with_id("bifrost_paseo") + .with_chain_type(ChainType::Live) + .with_genesis_config_patch(bifrost_polkadot_genesis( + invulnerables, + balances, + vec![], + PARA_ID.into(), + council_membership, + technical_committee_membership, + salp_multisig, + (vec![], vec![], vec![]), + oracle_membership, + )) + .with_properties(bifrost_polkadot_properties()) + .with_protocol_id(DEFAULT_PROTOCOL_ID) + .build() } - -fn bifrost_polkadot_config_genesis(id: ParaId) -> RuntimeGenesisConfig { +pub fn chainspec_config() -> ChainSpec { let invulnerables: Vec<(AccountId, AuraId)> = vec![ ( // dpEZwz5nHxEjQXcm3sjy6NTz83EGcBRXMBSyuuWSguiVGJB @@ -327,16 +292,25 @@ fn bifrost_polkadot_config_genesis(id: ParaId) -> RuntimeGenesisConfig { let salp_multisig: AccountId = hex!["e4da05f08e89bf6c43260d96f26fffcfc7deae5b465da08669a9d008e64c2c63"].into(); - bifrost_polkadot_genesis( + ChainSpec::builder( + bifrost_polkadot_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"), + RelayExtensions { relay_chain: "polkadot".into(), para_id: PARA_ID }, + ) + .with_name("Bifrost Polkadot") + .with_id("bifrost_polkadot") + .with_chain_type(ChainType::Live) + .with_genesis_config_patch(bifrost_polkadot_genesis( invulnerables, vec![], vec![], - id, - vec![], + PARA_ID.into(), vec![], vec![], salp_multisig, (vec![], vec![], vec![]), vec![], - ) + )) + .with_properties(bifrost_polkadot_properties()) + .with_protocol_id(DEFAULT_PROTOCOL_ID) + .build() } diff --git a/node/service/src/collator_kusama.rs b/node/service/src/collator_kusama.rs index 5ad72c31d..106cbae10 100644 --- a/node/service/src/collator_kusama.rs +++ b/node/service/src/collator_kusama.rs @@ -57,21 +57,6 @@ type HostFunctions = sp_io::SubstrateHostFunctions; type HostFunctions = (sp_io::SubstrateHostFunctions, frame_benchmarking::benchmarking::HostFunctions); -#[cfg(any(feature = "with-bifrost-kusama-runtime", feature = "with-bifrost-runtime"))] -pub struct BifrostExecutor; -#[cfg(any(feature = "with-bifrost-kusama-runtime", feature = "with-bifrost-runtime"))] -impl sc_executor::NativeExecutionDispatch for BifrostExecutor { - type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions; - - fn dispatch(method: &str, data: &[u8]) -> Option> { - bifrost_kusama_runtime::api::dispatch(method, data) - } - - fn native_version() -> sc_executor::NativeVersion { - bifrost_kusama_runtime::native_version() - } -} - pub type FullBackend = TFullBackend; pub type FullClient = TFullClient>; pub type MaybeFullSelectChain = Option>; diff --git a/node/service/src/collator_polkadot.rs b/node/service/src/collator_polkadot.rs index 8ccf92d4c..d1255f0bb 100644 --- a/node/service/src/collator_polkadot.rs +++ b/node/service/src/collator_polkadot.rs @@ -57,21 +57,6 @@ type HostFunctions = sp_io::SubstrateHostFunctions; type HostFunctions = (sp_io::SubstrateHostFunctions, frame_benchmarking::benchmarking::HostFunctions); -#[cfg(any(feature = "with-bifrost-polkadot-runtime", feature = "with-bifrost-runtime"))] -pub struct BifrostPolkadotExecutor; -#[cfg(any(feature = "with-bifrost-polkadot-runtime", feature = "with-bifrost-runtime"))] -impl sc_executor::NativeExecutionDispatch for BifrostPolkadotExecutor { - type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions; - - fn dispatch(method: &str, data: &[u8]) -> Option> { - bifrost_polkadot_runtime::api::dispatch(method, data) - } - - fn native_version() -> sc_executor::NativeVersion { - bifrost_polkadot_runtime::native_version() - } -} - pub type FullBackend = TFullBackend; pub type FullClient = TFullClient>; pub type MaybeFullSelectChain = Option>; diff --git a/runtime/bifrost-kusama/Cargo.toml b/runtime/bifrost-kusama/Cargo.toml index b53971ce3..e55515ed4 100644 --- a/runtime/bifrost-kusama/Cargo.toml +++ b/runtime/bifrost-kusama/Cargo.toml @@ -67,6 +67,7 @@ sp-staking = { workspace = true } sp-std = { workspace = true } sp-transaction-pool = { workspace = true } sp-version = { workspace = true } +sp-genesis-builder = { workspace = true } # Cumulus dependencies @@ -188,6 +189,7 @@ std = [ "pallet-utility/std", "pallet-whitelist/std", "sp-api/std", + "sp-genesis-builder/std", "sp-arithmetic/std", "sp-block-builder/std", "sp-consensus-aura/std", diff --git a/runtime/bifrost-kusama/src/lib.rs b/runtime/bifrost-kusama/src/lib.rs index a20c37998..2f682290a 100644 --- a/runtime/bifrost-kusama/src/lib.rs +++ b/runtime/bifrost-kusama/src/lib.rs @@ -89,6 +89,7 @@ use constants::currency::*; use cumulus_pallet_parachain_system::{RelayNumberStrictlyIncreases, RelaychainDataProvider}; use frame_support::{ dispatch::DispatchClass, + genesis_builder_helper::{build_config, create_default_config}, sp_runtime::traits::{Convert, ConvertInto}, traits::{ fungible::HoldConsideration, @@ -2506,6 +2507,16 @@ impl_runtime_apis! { Executive::try_execute_block(block, state_root_check,signature_check, select).unwrap() } } + + impl sp_genesis_builder::GenesisBuilder for Runtime { + fn create_default_config() -> Vec { + create_default_config::() + } + + fn build_config(config: Vec) -> sp_genesis_builder::Result { + build_config::(config) + } + } } struct CheckInherents; diff --git a/runtime/bifrost-polkadot/Cargo.toml b/runtime/bifrost-polkadot/Cargo.toml index e29f03cab..71bdb84f2 100644 --- a/runtime/bifrost-polkadot/Cargo.toml +++ b/runtime/bifrost-polkadot/Cargo.toml @@ -67,6 +67,7 @@ sp-staking = { workspace = true } sp-std = { workspace = true } sp-transaction-pool = { workspace = true } sp-version = { workspace = true } +sp-genesis-builder = { workspace = true } # Cumulus dependencies cumulus-pallet-aura-ext = { workspace = true } @@ -194,6 +195,7 @@ std = [ "sp-staking/std", "sp-std/std", "sp-transaction-pool/std", + "sp-genesis-builder/std", "cumulus-pallet-aura-ext/std", "cumulus-pallet-dmp-queue/std", diff --git a/runtime/bifrost-polkadot/src/lib.rs b/runtime/bifrost-polkadot/src/lib.rs index 70d554b7a..83ef9cfa3 100644 --- a/runtime/bifrost-polkadot/src/lib.rs +++ b/runtime/bifrost-polkadot/src/lib.rs @@ -89,6 +89,7 @@ use constants::currency::*; use cumulus_primitives_core::ParaId as CumulusParaId; use frame_support::{ dispatch::DispatchClass, + genesis_builder_helper::{build_config, create_default_config}, sp_runtime::traits::{Convert, ConvertInto}, traits::{ fungible::HoldConsideration, @@ -2258,6 +2259,16 @@ impl_runtime_apis! { Executive::try_execute_block(block, state_root_check,signature_check, select).unwrap() } } + + impl sp_genesis_builder::GenesisBuilder for Runtime { + fn create_default_config() -> Vec { + create_default_config::() + } + + fn build_config(config: Vec) -> sp_genesis_builder::Result { + build_config::(config) + } + } } struct CheckInherents;