mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 04:41:03 +00:00
BridgeHubKusama - initial setup - (chain_spec + basic runtime without any bridging pallets) (#1764)
* [BridgeHub] Setup Rococo backbone parachain * [BridgeHub] Setup Wococo parachain backbone (reused from Rococo) [Bridge-Backport] Rebase-fix BridgeHub] Added zombienet startup tomls for Rococo/Wococo Fix typo * [BridgeHub] Added chain_spec for live Rococo/Wococo * [BridgeHub] Clean bridge-hub-rococo runtime * [BridgeHub] Add bridge-hub-rococo to CI pipelines * [BridgeHub] Added bridge-hub-kusama - empty runtime/chain_spec setup * Fixes * Fixes for BH * Fixes for other runtimes - align all * Fixes - const * Fixes const * Fixes * Fix kusama-local * Sample zombienet runs * Fixes * Fixes for benchmarking * Fixes CI * Fixes * ".git/.scripts/bench-bot.sh" pallet bridge-hub-kusama bridge-hubs frame_system * ".git/.scripts/bench-bot.sh" pallet bridge-hub-kusama bridge-hubs pallet_collator_selection * ".git/.scripts/bench-bot.sh" pallet bridge-hub-kusama bridge-hubs pallet_balances * ".git/.scripts/bench-bot.sh" pallet bridge-hub-kusama bridge-hubs pallet_session * Fixes name * Fixes readme * ".git/.scripts/bench-bot.sh" pallet bridge-hub-kusama bridge-hubs pallet_timestamp * ".git/.scripts/bench-bot.sh" pallet bridge-hub-kusama bridge-hubs cumulus_pallet_xcmp_queue * ".git/.scripts/bench-bot.sh" pallet bridge-hub-kusama bridge-hubs pallet_collator_selection * Fixes * Fixes * rustfmt * Fixes * Added pallet_utility/pallet_multisig * Blind try for regex pr-custom-review.yml (added bridge-hub-kusama + collectives-polkadot) * Fixes * Fixes * ".git/.scripts/bench-bot.sh" pallet bridge-hub-kusama bridge-hubs pallet_utility * ".git/.scripts/bench-bot.sh" pallet bridge-hub-kusama bridge-hubs pallet_multisig * Trying to fix sed expression? * Added license headers + correct "DAG:" desc Co-authored-by: command-bot <>
This commit is contained in:
@@ -28,6 +28,8 @@ statemine-runtime = { path = "../parachains/runtimes/assets/statemine" }
|
||||
westmint-runtime = { path = "../parachains/runtimes/assets/westmint" }
|
||||
collectives-polkadot-runtime = { path = "../parachains/runtimes/collectives/collectives-polkadot" }
|
||||
contracts-rococo-runtime = { path = "../parachains/runtimes/contracts/contracts-rococo" }
|
||||
bridge-hub-rococo-runtime = { path = "../parachains/runtimes/bridge-hubs/bridge-hub-rococo" }
|
||||
bridge-hub-kusama-runtime = { path = "../parachains/runtimes/bridge-hubs/bridge-hub-kusama" }
|
||||
penpal-runtime = { path = "../parachains/runtimes/testing/penpal" }
|
||||
jsonrpsee = { version = "0.15.1", features = ["server"] }
|
||||
parachains-common = { path = "../parachains/common" }
|
||||
|
||||
@@ -0,0 +1,497 @@
|
||||
// Copyright 2019-2021 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Cumulus.
|
||||
|
||||
// Cumulus is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// Cumulus is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use cumulus_primitives_core::ParaId;
|
||||
use parachains_common::Balance as BridgeHubBalance;
|
||||
use sc_chain_spec::ChainSpec;
|
||||
use sc_cli::RuntimeVersion;
|
||||
use std::{path::PathBuf, str::FromStr};
|
||||
|
||||
/// Collects all supported BridgeHub configurations
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum BridgeHubRuntimeType {
|
||||
Rococo,
|
||||
RococoLocal,
|
||||
// used by benchmarks
|
||||
RococoDevelopment,
|
||||
|
||||
Wococo,
|
||||
WococoLocal,
|
||||
|
||||
Kusama,
|
||||
KusamaLocal,
|
||||
// used by benchmarks
|
||||
KusamaDevelopment,
|
||||
}
|
||||
|
||||
impl FromStr for BridgeHubRuntimeType {
|
||||
type Err = String;
|
||||
|
||||
fn from_str(value: &str) -> Result<Self, Self::Err> {
|
||||
match value {
|
||||
kusama::BRIDGE_HUB_KUSAMA => Ok(BridgeHubRuntimeType::Kusama),
|
||||
kusama::BRIDGE_HUB_KUSAMA_LOCAL => Ok(BridgeHubRuntimeType::KusamaLocal),
|
||||
kusama::BRIDGE_HUB_KUSAMA_DEVELOPMENT => Ok(BridgeHubRuntimeType::KusamaDevelopment),
|
||||
rococo::BRIDGE_HUB_ROCOCO => Ok(BridgeHubRuntimeType::Rococo),
|
||||
rococo::BRIDGE_HUB_ROCOCO_LOCAL => Ok(BridgeHubRuntimeType::RococoLocal),
|
||||
rococo::BRIDGE_HUB_ROCOCO_DEVELOPMENT => Ok(BridgeHubRuntimeType::RococoDevelopment),
|
||||
wococo::BRIDGE_HUB_WOCOCO => Ok(BridgeHubRuntimeType::Wococo),
|
||||
wococo::BRIDGE_HUB_WOCOCO_LOCAL => Ok(BridgeHubRuntimeType::WococoLocal),
|
||||
_ => Err(format!("Value '{}' is not configured yet", value)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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::Kusama |
|
||||
BridgeHubRuntimeType::KusamaLocal |
|
||||
BridgeHubRuntimeType::KusamaDevelopment =>
|
||||
Ok(Box::new(kusama::BridgeHubChainSpec::from_json_file(path)?)),
|
||||
BridgeHubRuntimeType::Rococo |
|
||||
BridgeHubRuntimeType::RococoLocal |
|
||||
BridgeHubRuntimeType::RococoDevelopment =>
|
||||
Ok(Box::new(rococo::BridgeHubChainSpec::from_json_file(path)?)),
|
||||
BridgeHubRuntimeType::Wococo | BridgeHubRuntimeType::WococoLocal =>
|
||||
Ok(Box::new(wococo::BridgeHubChainSpec::from_json_file(path)?)),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn load_config(&self) -> Result<Box<dyn ChainSpec>, String> {
|
||||
match self {
|
||||
BridgeHubRuntimeType::Kusama =>
|
||||
Ok(Box::new(kusama::BridgeHubChainSpec::from_json_bytes(
|
||||
&include_bytes!("../../../parachains/chain-specs/bridge-hub-kusama.json")[..],
|
||||
)?)),
|
||||
BridgeHubRuntimeType::KusamaLocal => Ok(Box::new(kusama::local_config(
|
||||
kusama::BRIDGE_HUB_KUSAMA_LOCAL,
|
||||
"Kusama BridgeHub Local",
|
||||
"kusama-local",
|
||||
ParaId::new(1003),
|
||||
))),
|
||||
BridgeHubRuntimeType::KusamaDevelopment => Ok(Box::new(kusama::local_config(
|
||||
kusama::BRIDGE_HUB_KUSAMA_DEVELOPMENT,
|
||||
"Kusama BridgeHub Development",
|
||||
"kusama-dev",
|
||||
ParaId::new(1003),
|
||||
))),
|
||||
BridgeHubRuntimeType::Rococo => Ok(Box::new(rococo::live_config(
|
||||
rococo::BRIDGE_HUB_ROCOCO,
|
||||
"Rococo BridgeHub",
|
||||
"rococo",
|
||||
ParaId::new(1013),
|
||||
|_| (),
|
||||
))),
|
||||
BridgeHubRuntimeType::RococoLocal => Ok(Box::new(rococo::local_config(
|
||||
rococo::BRIDGE_HUB_ROCOCO_LOCAL,
|
||||
"Rococo BridgeHub Local",
|
||||
"rococo-local",
|
||||
ParaId::new(1013),
|
||||
|_| (),
|
||||
))),
|
||||
BridgeHubRuntimeType::RococoDevelopment => Ok(Box::new(rococo::local_config(
|
||||
rococo::BRIDGE_HUB_ROCOCO_DEVELOPMENT,
|
||||
"Rococo BridgeHub Development",
|
||||
"rococo-dev",
|
||||
ParaId::new(1013),
|
||||
|_| (),
|
||||
))),
|
||||
BridgeHubRuntimeType::Wococo => Ok(Box::new(wococo::live_config(
|
||||
wococo::BRIDGE_HUB_WOCOCO,
|
||||
"Wococo BridgeHub",
|
||||
"wococo",
|
||||
ParaId::new(1013),
|
||||
))),
|
||||
BridgeHubRuntimeType::WococoLocal => Ok(Box::new(wococo::local_config(
|
||||
wococo::BRIDGE_HUB_WOCOCO_LOCAL,
|
||||
"Wococo BridgeHub Local",
|
||||
"wococo-local",
|
||||
ParaId::new(1013),
|
||||
))),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn runtime_version(&self) -> &'static RuntimeVersion {
|
||||
match self {
|
||||
BridgeHubRuntimeType::Kusama |
|
||||
BridgeHubRuntimeType::KusamaLocal |
|
||||
BridgeHubRuntimeType::KusamaDevelopment => &bridge_hub_kusama_runtime::VERSION,
|
||||
BridgeHubRuntimeType::Rococo |
|
||||
BridgeHubRuntimeType::RococoLocal |
|
||||
BridgeHubRuntimeType::RococoDevelopment |
|
||||
BridgeHubRuntimeType::Wococo |
|
||||
BridgeHubRuntimeType::WococoLocal => {
|
||||
// this is intentional, for Rococo/Wococo we just want to have one runtime, which is configured for both sides
|
||||
&bridge_hub_rococo_runtime::VERSION
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Check if 'id' satisfy BridgeHub-like format
|
||||
fn ensure_id(id: &str) -> Result<&str, String> {
|
||||
if id.starts_with(BridgeHubRuntimeType::ID_PREFIX) {
|
||||
Ok(id)
|
||||
} else {
|
||||
Err(format!(
|
||||
"Invalid 'id' attribute ({}), should start with prefix: {}",
|
||||
id,
|
||||
BridgeHubRuntimeType::ID_PREFIX
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
/// Sub-module for Rococo setup
|
||||
pub mod rococo {
|
||||
use super::{BridgeHubBalance, ParaId};
|
||||
use crate::chain_spec::{
|
||||
get_account_id_from_seed, get_collator_keys_from_seed, Extensions, SAFE_XCM_VERSION,
|
||||
};
|
||||
use parachains_common::{AccountId, AuraId};
|
||||
use sc_chain_spec::ChainType;
|
||||
use sp_core::sr25519;
|
||||
|
||||
pub(crate) const BRIDGE_HUB_ROCOCO: &str = "bridge-hub-rococo";
|
||||
pub(crate) const BRIDGE_HUB_ROCOCO_LOCAL: &str = "bridge-hub-rococo-local";
|
||||
pub(crate) const BRIDGE_HUB_ROCOCO_DEVELOPMENT: &str = "bridge-hub-rococo-dev";
|
||||
const BRIDGE_HUB_ROCOCO_ED: BridgeHubBalance =
|
||||
bridge_hub_rococo_runtime::constants::currency::EXISTENTIAL_DEPOSIT;
|
||||
|
||||
/// Specialized `ChainSpec` for the normal parachain runtime.
|
||||
pub type BridgeHubChainSpec =
|
||||
sc_service::GenericChainSpec<bridge_hub_rococo_runtime::GenesisConfig, Extensions>;
|
||||
|
||||
pub type RuntimeApi = bridge_hub_rococo_runtime::RuntimeApi;
|
||||
|
||||
pub fn live_config<ModifyProperties: Fn(&mut sc_chain_spec::Properties)>(
|
||||
id: &str,
|
||||
chain_name: &str,
|
||||
relay_chain: &str,
|
||||
para_id: ParaId,
|
||||
modify_props: ModifyProperties,
|
||||
) -> BridgeHubChainSpec {
|
||||
// Rococo defaults
|
||||
let mut properties = sc_chain_spec::Properties::new();
|
||||
properties.insert("ss58Format".into(), 42.into());
|
||||
properties.insert("tokenSymbol".into(), "ROC".into());
|
||||
properties.insert("tokenDecimals".into(), 12.into());
|
||||
modify_props(&mut properties);
|
||||
|
||||
BridgeHubChainSpec::from_genesis(
|
||||
// Name
|
||||
chain_name,
|
||||
// ID
|
||||
super::ensure_id(id).expect("invalid id"),
|
||||
ChainType::Live,
|
||||
move || {
|
||||
genesis(
|
||||
// initial collators.
|
||||
vec![
|
||||
(
|
||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
||||
get_collator_keys_from_seed::<AuraId>("Alice"),
|
||||
),
|
||||
(
|
||||
get_account_id_from_seed::<sr25519::Public>("Bob"),
|
||||
get_collator_keys_from_seed::<AuraId>("Bob"),
|
||||
),
|
||||
],
|
||||
vec![
|
||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Bob"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Charlie"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Dave"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Eve"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Ferdie"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Dave//stash"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Eve//stash"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),
|
||||
],
|
||||
para_id,
|
||||
)
|
||||
},
|
||||
Vec::new(),
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
Some(properties),
|
||||
Extensions { relay_chain: relay_chain.to_string(), para_id: para_id.into() },
|
||||
)
|
||||
}
|
||||
|
||||
pub fn local_config<ModifyProperties: Fn(&mut sc_chain_spec::Properties)>(
|
||||
id: &str,
|
||||
chain_name: &str,
|
||||
relay_chain: &str,
|
||||
para_id: ParaId,
|
||||
modify_props: ModifyProperties,
|
||||
) -> BridgeHubChainSpec {
|
||||
// Rococo defaults
|
||||
let mut properties = sc_chain_spec::Properties::new();
|
||||
properties.insert("ss58Format".into(), 42.into());
|
||||
properties.insert("tokenSymbol".into(), "ROC".into());
|
||||
properties.insert("tokenDecimals".into(), 12.into());
|
||||
modify_props(&mut properties);
|
||||
|
||||
BridgeHubChainSpec::from_genesis(
|
||||
// Name
|
||||
chain_name,
|
||||
// ID
|
||||
super::ensure_id(id).expect("invalid id"),
|
||||
ChainType::Local,
|
||||
move || {
|
||||
genesis(
|
||||
// initial collators.
|
||||
vec![
|
||||
(
|
||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
||||
get_collator_keys_from_seed::<AuraId>("Alice"),
|
||||
),
|
||||
(
|
||||
get_account_id_from_seed::<sr25519::Public>("Bob"),
|
||||
get_collator_keys_from_seed::<AuraId>("Bob"),
|
||||
),
|
||||
],
|
||||
vec![
|
||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Bob"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Charlie"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Dave"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Eve"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Ferdie"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Dave//stash"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Eve//stash"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),
|
||||
],
|
||||
para_id,
|
||||
)
|
||||
},
|
||||
Vec::new(),
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
Some(properties),
|
||||
Extensions { relay_chain: relay_chain.to_string(), para_id: para_id.into() },
|
||||
)
|
||||
}
|
||||
|
||||
fn genesis(
|
||||
invulnerables: Vec<(AccountId, AuraId)>,
|
||||
endowed_accounts: Vec<AccountId>,
|
||||
id: ParaId,
|
||||
) -> bridge_hub_rococo_runtime::GenesisConfig {
|
||||
bridge_hub_rococo_runtime::GenesisConfig {
|
||||
system: bridge_hub_rococo_runtime::SystemConfig {
|
||||
code: bridge_hub_rococo_runtime::WASM_BINARY
|
||||
.expect("WASM binary was not build, please build it!")
|
||||
.to_vec(),
|
||||
},
|
||||
balances: bridge_hub_rococo_runtime::BalancesConfig {
|
||||
balances: endowed_accounts.iter().cloned().map(|k| (k, 1 << 60)).collect(),
|
||||
},
|
||||
parachain_info: bridge_hub_rococo_runtime::ParachainInfoConfig { parachain_id: id },
|
||||
collator_selection: bridge_hub_rococo_runtime::CollatorSelectionConfig {
|
||||
invulnerables: invulnerables.iter().cloned().map(|(acc, _)| acc).collect(),
|
||||
candidacy_bond: BRIDGE_HUB_ROCOCO_ED * 16,
|
||||
..Default::default()
|
||||
},
|
||||
session: bridge_hub_rococo_runtime::SessionConfig {
|
||||
keys: invulnerables
|
||||
.into_iter()
|
||||
.map(|(acc, aura)| {
|
||||
(
|
||||
acc.clone(), // account id
|
||||
acc, // validator id
|
||||
bridge_hub_rococo_runtime::SessionKeys { aura }, // session keys
|
||||
)
|
||||
})
|
||||
.collect(),
|
||||
},
|
||||
aura: Default::default(),
|
||||
aura_ext: Default::default(),
|
||||
parachain_system: Default::default(),
|
||||
polkadot_xcm: bridge_hub_rococo_runtime::PolkadotXcmConfig {
|
||||
safe_xcm_version: Some(SAFE_XCM_VERSION),
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Sub-module for Wococo setup (reuses stuff from Rococo)
|
||||
pub mod wococo {
|
||||
use super::ParaId;
|
||||
use crate::chain_spec::bridge_hubs::rococo;
|
||||
|
||||
pub(crate) const BRIDGE_HUB_WOCOCO: &str = "bridge-hub-wococo";
|
||||
pub(crate) const BRIDGE_HUB_WOCOCO_LOCAL: &str = "bridge-hub-wococo-local";
|
||||
|
||||
pub type BridgeHubChainSpec = rococo::BridgeHubChainSpec;
|
||||
pub type RuntimeApi = rococo::RuntimeApi;
|
||||
|
||||
pub fn local_config(
|
||||
id: &str,
|
||||
chain_name: &str,
|
||||
relay_chain: &str,
|
||||
para_id: ParaId,
|
||||
) -> BridgeHubChainSpec {
|
||||
rococo::local_config(id, chain_name, relay_chain, para_id, |properties| {
|
||||
properties.insert("tokenSymbol".into(), "WOOK".into());
|
||||
})
|
||||
}
|
||||
|
||||
pub fn live_config(
|
||||
id: &str,
|
||||
chain_name: &str,
|
||||
relay_chain: &str,
|
||||
para_id: ParaId,
|
||||
) -> BridgeHubChainSpec {
|
||||
rococo::live_config(id, chain_name, relay_chain, para_id, |properties| {
|
||||
properties.insert("tokenSymbol".into(), "WOOK".into());
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/// Sub-module for Kusama setup (reuses stuff from 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,
|
||||
};
|
||||
use parachains_common::{AccountId, AuraId};
|
||||
use sc_chain_spec::ChainType;
|
||||
use sp_core::sr25519;
|
||||
|
||||
pub(crate) const BRIDGE_HUB_KUSAMA: &str = "bridge-hub-kusama";
|
||||
pub(crate) const BRIDGE_HUB_KUSAMA_LOCAL: &str = "bridge-hub-kusama-local";
|
||||
pub(crate) const BRIDGE_HUB_KUSAMA_DEVELOPMENT: &str = "bridge-hub-kusama-dev";
|
||||
const BRIDGE_HUB_KUSAMA_ED: BridgeHubBalance =
|
||||
bridge_hub_kusama_runtime::constants::currency::EXISTENTIAL_DEPOSIT;
|
||||
|
||||
/// Specialized `ChainSpec` for the normal parachain runtime.
|
||||
pub type BridgeHubChainSpec =
|
||||
sc_service::GenericChainSpec<bridge_hub_kusama_runtime::GenesisConfig, Extensions>;
|
||||
pub type RuntimeApi = bridge_hub_kusama_runtime::RuntimeApi;
|
||||
|
||||
pub fn local_config(
|
||||
id: &str,
|
||||
chain_name: &str,
|
||||
relay_chain: &str,
|
||||
para_id: ParaId,
|
||||
) -> BridgeHubChainSpec {
|
||||
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::from_genesis(
|
||||
// Name
|
||||
chain_name,
|
||||
// ID
|
||||
super::ensure_id(id).expect("invalid id"),
|
||||
ChainType::Local,
|
||||
move || {
|
||||
genesis(
|
||||
// initial collators.
|
||||
vec![
|
||||
(
|
||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
||||
get_collator_keys_from_seed::<AuraId>("Alice"),
|
||||
),
|
||||
(
|
||||
get_account_id_from_seed::<sr25519::Public>("Bob"),
|
||||
get_collator_keys_from_seed::<AuraId>("Bob"),
|
||||
),
|
||||
],
|
||||
vec![
|
||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Bob"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Charlie"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Dave"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Eve"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Ferdie"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Charlie//stash"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Dave//stash"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Eve//stash"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Ferdie//stash"),
|
||||
],
|
||||
para_id,
|
||||
)
|
||||
},
|
||||
Vec::new(),
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
Some(properties),
|
||||
Extensions { relay_chain: relay_chain.to_string(), para_id: para_id.into() },
|
||||
)
|
||||
}
|
||||
|
||||
fn genesis(
|
||||
invulnerables: Vec<(AccountId, AuraId)>,
|
||||
endowed_accounts: Vec<AccountId>,
|
||||
id: ParaId,
|
||||
) -> bridge_hub_kusama_runtime::GenesisConfig {
|
||||
bridge_hub_kusama_runtime::GenesisConfig {
|
||||
system: bridge_hub_kusama_runtime::SystemConfig {
|
||||
code: bridge_hub_kusama_runtime::WASM_BINARY
|
||||
.expect("WASM binary was not build, please build it!")
|
||||
.to_vec(),
|
||||
},
|
||||
balances: bridge_hub_kusama_runtime::BalancesConfig {
|
||||
balances: endowed_accounts
|
||||
.iter()
|
||||
.cloned()
|
||||
.map(|k| (k, BRIDGE_HUB_KUSAMA_ED * 524_288))
|
||||
.collect(),
|
||||
},
|
||||
parachain_info: bridge_hub_kusama_runtime::ParachainInfoConfig { parachain_id: id },
|
||||
collator_selection: bridge_hub_kusama_runtime::CollatorSelectionConfig {
|
||||
invulnerables: invulnerables.iter().cloned().map(|(acc, _)| acc).collect(),
|
||||
candidacy_bond: BRIDGE_HUB_KUSAMA_ED * 16,
|
||||
..Default::default()
|
||||
},
|
||||
session: bridge_hub_kusama_runtime::SessionConfig {
|
||||
keys: invulnerables
|
||||
.into_iter()
|
||||
.map(|(acc, aura)| {
|
||||
(
|
||||
acc.clone(), // account id
|
||||
acc, // validator id
|
||||
bridge_hub_kusama_runtime::SessionKeys { aura }, // session keys
|
||||
)
|
||||
})
|
||||
.collect(),
|
||||
},
|
||||
aura: Default::default(),
|
||||
aura_ext: Default::default(),
|
||||
parachain_system: Default::default(),
|
||||
polkadot_xcm: bridge_hub_kusama_runtime::PolkadotXcmConfig {
|
||||
safe_xcm_version: Some(SAFE_XCM_VERSION),
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,7 @@ use serde::{Deserialize, Serialize};
|
||||
use sp_core::{Pair, Public};
|
||||
use sp_runtime::traits::{IdentifyAccount, Verify};
|
||||
|
||||
pub mod bridge_hubs;
|
||||
pub mod collectives;
|
||||
pub mod contracts;
|
||||
pub mod penpal;
|
||||
|
||||
@@ -18,8 +18,9 @@ use crate::{
|
||||
chain_spec,
|
||||
cli::{Cli, RelayChainCli, Subcommand},
|
||||
service::{
|
||||
new_partial, Block, CollectivesPolkadotRuntimeExecutor, StatemineRuntimeExecutor,
|
||||
StatemintRuntimeExecutor, WestmintRuntimeExecutor,
|
||||
new_partial, Block, BridgeHubKusamaRuntimeExecutor, BridgeHubRococoRuntimeExecutor,
|
||||
CollectivesPolkadotRuntimeExecutor, StatemineRuntimeExecutor, StatemintRuntimeExecutor,
|
||||
WestmintRuntimeExecutor,
|
||||
},
|
||||
};
|
||||
use codec::Encode;
|
||||
@@ -53,6 +54,7 @@ enum Runtime {
|
||||
ContractsRococo,
|
||||
CollectivesPolkadot,
|
||||
CollectivesWestend,
|
||||
BridgeHub(chain_spec::bridge_hubs::BridgeHubRuntimeType),
|
||||
}
|
||||
|
||||
trait RuntimeResolver {
|
||||
@@ -104,6 +106,11 @@ fn runtime(id: &str) -> Runtime {
|
||||
Runtime::CollectivesPolkadot
|
||||
} else if id.starts_with("collectives-westend") {
|
||||
Runtime::CollectivesWestend
|
||||
} else if id.starts_with(chain_spec::bridge_hubs::BridgeHubRuntimeType::ID_PREFIX) {
|
||||
Runtime::BridgeHub(
|
||||
id.parse::<chain_spec::bridge_hubs::BridgeHubRuntimeType>()
|
||||
.expect("Invalid value"),
|
||||
)
|
||||
} else {
|
||||
log::warn!("No specific runtime was recognized for ChainSpec's id: '{}', so Runtime::default() will be used", id);
|
||||
Runtime::default()
|
||||
@@ -188,6 +195,15 @@ fn load_spec(id: &str) -> std::result::Result<Box<dyn ChainSpec>, String> {
|
||||
&include_bytes!("../../parachains/chain-specs/contracts-rococo.json")[..],
|
||||
)?),
|
||||
|
||||
// -- BridgeHub
|
||||
bridge_like_id
|
||||
if bridge_like_id
|
||||
.starts_with(chain_spec::bridge_hubs::BridgeHubRuntimeType::ID_PREFIX) =>
|
||||
bridge_like_id
|
||||
.parse::<chain_spec::bridge_hubs::BridgeHubRuntimeType>()
|
||||
.expect("invalid value")
|
||||
.load_config()?,
|
||||
|
||||
// -- Penpall
|
||||
"penpal-kusama" => Box::new(chain_spec::penpal::get_penpal_chain_spec(
|
||||
para_id.expect("Must specify parachain id"),
|
||||
@@ -223,6 +239,8 @@ fn load_spec(id: &str) -> std::result::Result<Box<dyn ChainSpec>, String> {
|
||||
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.into())?,
|
||||
Runtime::Penpal(_para_id) =>
|
||||
Box::new(chain_spec::penpal::PenpalChainSpec::from_json_file(path)?),
|
||||
Runtime::Default => Box::new(
|
||||
@@ -300,6 +318,8 @@ impl SubstrateCli for Cli {
|
||||
Runtime::Shell => &shell_runtime::VERSION,
|
||||
Runtime::Seedling => &seedling_runtime::VERSION,
|
||||
Runtime::ContractsRococo => &contracts_rococo_runtime::VERSION,
|
||||
Runtime::BridgeHub(bridge_hub_runtime_type) =>
|
||||
bridge_hub_runtime_type.runtime_version(),
|
||||
Runtime::Penpal(_) => &penpal_runtime::VERSION,
|
||||
Runtime::Default => &rococo_parachain_runtime::VERSION,
|
||||
}
|
||||
@@ -457,6 +477,48 @@ macro_rules! construct_async_run {
|
||||
{ $( $code )* }.map(|v| (v, task_manager))
|
||||
})
|
||||
},
|
||||
Runtime::BridgeHub(bridge_hub_runtime_type) => {
|
||||
match bridge_hub_runtime_type {
|
||||
chain_spec::bridge_hubs::BridgeHubRuntimeType::Kusama |
|
||||
chain_spec::bridge_hubs::BridgeHubRuntimeType::KusamaLocal |
|
||||
chain_spec::bridge_hubs::BridgeHubRuntimeType::KusamaDevelopment => {
|
||||
runner.async_run(|$config| {
|
||||
let $components = new_partial::<chain_spec::bridge_hubs::kusama::RuntimeApi, _>(
|
||||
&$config,
|
||||
crate::service::aura_build_import_queue::<_, AuraId>,
|
||||
)?;
|
||||
|
||||
let task_manager = $components.task_manager;
|
||||
{ $( $code )* }.map(|v| (v, task_manager))
|
||||
})
|
||||
},
|
||||
chain_spec::bridge_hubs::BridgeHubRuntimeType::Rococo |
|
||||
chain_spec::bridge_hubs::BridgeHubRuntimeType::RococoLocal |
|
||||
chain_spec::bridge_hubs::BridgeHubRuntimeType::RococoDevelopment => {
|
||||
runner.async_run(|$config| {
|
||||
let $components = new_partial::<chain_spec::bridge_hubs::rococo::RuntimeApi, _>(
|
||||
&$config,
|
||||
crate::service::aura_build_import_queue::<_, AuraId>,
|
||||
)?;
|
||||
|
||||
let task_manager = $components.task_manager;
|
||||
{ $( $code )* }.map(|v| (v, task_manager))
|
||||
})
|
||||
},
|
||||
chain_spec::bridge_hubs::BridgeHubRuntimeType::Wococo |
|
||||
chain_spec::bridge_hubs::BridgeHubRuntimeType::WococoLocal => {
|
||||
runner.async_run(|$config| {
|
||||
let $components = new_partial::<chain_spec::bridge_hubs::wococo::RuntimeApi, _>(
|
||||
&$config,
|
||||
crate::service::aura_build_import_queue::<_, AuraId>,
|
||||
)?;
|
||||
|
||||
let task_manager = $components.task_manager;
|
||||
{ $( $code )* }.map(|v| (v, task_manager))
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
Runtime::Penpal(_) | Runtime::Default => {
|
||||
runner.async_run(|$config| {
|
||||
let $components = new_partial::<
|
||||
@@ -547,7 +609,8 @@ pub fn run() -> Result<()> {
|
||||
match cmd {
|
||||
BenchmarkCmd::Pallet(cmd) =>
|
||||
if cfg!(feature = "runtime-benchmarks") {
|
||||
runner.sync_run(|config| match config.chain_spec.runtime() {
|
||||
runner.sync_run(|config| {
|
||||
match config.chain_spec.runtime() {
|
||||
Runtime::Statemine =>
|
||||
cmd.run::<Block, StatemineRuntimeExecutor>(config),
|
||||
Runtime::Westmint => cmd.run::<Block, WestmintRuntimeExecutor>(config),
|
||||
@@ -555,11 +618,28 @@ pub fn run() -> Result<()> {
|
||||
cmd.run::<Block, StatemintRuntimeExecutor>(config),
|
||||
Runtime::CollectivesPolkadot | Runtime::CollectivesWestend =>
|
||||
cmd.run::<Block, CollectivesPolkadotRuntimeExecutor>(config),
|
||||
Runtime::BridgeHub(bridge_hub_runtime_type) => match bridge_hub_runtime_type {
|
||||
chain_spec::bridge_hubs::BridgeHubRuntimeType::Kusama |
|
||||
chain_spec::bridge_hubs::BridgeHubRuntimeType::KusamaLocal |
|
||||
chain_spec::bridge_hubs::BridgeHubRuntimeType::KusamaDevelopment =>
|
||||
cmd.run::<Block, BridgeHubKusamaRuntimeExecutor>(config),
|
||||
chain_spec::bridge_hubs::BridgeHubRuntimeType::Rococo |
|
||||
chain_spec::bridge_hubs::BridgeHubRuntimeType::RococoLocal |
|
||||
chain_spec::bridge_hubs::BridgeHubRuntimeType::RococoDevelopment =>
|
||||
cmd.run::<Block, BridgeHubRococoRuntimeExecutor>(config),
|
||||
_ => Err(format!(
|
||||
"Chain '{:?}' doesn't support benchmarking for bridge_hub_runtime_type: {:?}",
|
||||
config.chain_spec.runtime(),
|
||||
bridge_hub_runtime_type
|
||||
)
|
||||
.into()),
|
||||
}
|
||||
_ => Err(format!(
|
||||
"Chain '{:?}' doesn't support benchmarking",
|
||||
config.chain_spec.runtime()
|
||||
)
|
||||
.into()),
|
||||
}
|
||||
})
|
||||
} else {
|
||||
Err("Benchmarking wasn't enabled when building the node. \
|
||||
@@ -620,6 +700,32 @@ pub fn run() -> Result<()> {
|
||||
task_manager,
|
||||
))
|
||||
}),
|
||||
Runtime::BridgeHub(bridge_hub_runtime_type) => match bridge_hub_runtime_type {
|
||||
chain_spec::bridge_hubs::BridgeHubRuntimeType::Kusama |
|
||||
chain_spec::bridge_hubs::BridgeHubRuntimeType::KusamaLocal |
|
||||
chain_spec::bridge_hubs::BridgeHubRuntimeType::KusamaDevelopment =>
|
||||
runner.async_run(|config| {
|
||||
Ok((
|
||||
cmd.run::<Block, BridgeHubKusamaRuntimeExecutor>(config),
|
||||
task_manager,
|
||||
))
|
||||
}),
|
||||
chain_spec::bridge_hubs::BridgeHubRuntimeType::Rococo |
|
||||
chain_spec::bridge_hubs::BridgeHubRuntimeType::RococoLocal |
|
||||
chain_spec::bridge_hubs::BridgeHubRuntimeType::RococoDevelopment =>
|
||||
runner.async_run(|config| {
|
||||
Ok((
|
||||
cmd.run::<Block, BridgeHubRococoRuntimeExecutor>(config),
|
||||
task_manager,
|
||||
))
|
||||
}),
|
||||
_ => Err(format!(
|
||||
"Chain '{:?}' doesn't support try-runtime for bridge_hub_runtime_type: {:?}",
|
||||
runner.config().chain_spec.runtime(),
|
||||
bridge_hub_runtime_type
|
||||
)
|
||||
.into()),
|
||||
},
|
||||
Runtime::Shell => runner.async_run(|config| {
|
||||
Ok((
|
||||
cmd.run::<Block, crate::service::ShellRuntimeExecutor>(config),
|
||||
@@ -746,6 +852,35 @@ pub fn run() -> Result<()> {
|
||||
.await
|
||||
.map(|r| r.0)
|
||||
.map_err(Into::into),
|
||||
Runtime::BridgeHub(bridge_hub_runtime_type) => match bridge_hub_runtime_type {
|
||||
chain_spec::bridge_hubs::BridgeHubRuntimeType::Kusama |
|
||||
chain_spec::bridge_hubs::BridgeHubRuntimeType::KusamaLocal |
|
||||
chain_spec::bridge_hubs::BridgeHubRuntimeType::KusamaDevelopment =>
|
||||
crate::service::start_generic_aura_node::<
|
||||
chain_spec::bridge_hubs::kusama::RuntimeApi,
|
||||
AuraId,
|
||||
>(config, polkadot_config, collator_options, id, hwbench)
|
||||
.await
|
||||
.map(|r| r.0),
|
||||
chain_spec::bridge_hubs::BridgeHubRuntimeType::Rococo |
|
||||
chain_spec::bridge_hubs::BridgeHubRuntimeType::RococoLocal |
|
||||
chain_spec::bridge_hubs::BridgeHubRuntimeType::RococoDevelopment =>
|
||||
crate::service::start_generic_aura_node::<
|
||||
chain_spec::bridge_hubs::rococo::RuntimeApi,
|
||||
AuraId,
|
||||
>(config, polkadot_config, collator_options, id, hwbench)
|
||||
.await
|
||||
.map(|r| r.0),
|
||||
chain_spec::bridge_hubs::BridgeHubRuntimeType::Wococo |
|
||||
chain_spec::bridge_hubs::BridgeHubRuntimeType::WococoLocal =>
|
||||
crate::service::start_generic_aura_node::<
|
||||
chain_spec::bridge_hubs::wococo::RuntimeApi,
|
||||
AuraId,
|
||||
>(config, polkadot_config, collator_options, id, hwbench)
|
||||
.await
|
||||
.map(|r| r.0),
|
||||
}
|
||||
.map_err(Into::into),
|
||||
Runtime::Penpal(_) | Runtime::Default =>
|
||||
crate::service::start_rococo_parachain_node(
|
||||
config,
|
||||
|
||||
@@ -150,6 +150,36 @@ impl sc_executor::NativeExecutionDispatch for CollectivesPolkadotRuntimeExecutor
|
||||
}
|
||||
}
|
||||
|
||||
// Native BridgeHubKusama executor instance.
|
||||
pub struct BridgeHubKusamaRuntimeExecutor;
|
||||
|
||||
impl sc_executor::NativeExecutionDispatch for BridgeHubKusamaRuntimeExecutor {
|
||||
type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;
|
||||
|
||||
fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {
|
||||
bridge_hub_kusama_runtime::api::dispatch(method, data)
|
||||
}
|
||||
|
||||
fn native_version() -> sc_executor::NativeVersion {
|
||||
bridge_hub_kusama_runtime::native_version()
|
||||
}
|
||||
}
|
||||
|
||||
// Native BridgeHubRococo executor instance.
|
||||
pub struct BridgeHubRococoRuntimeExecutor;
|
||||
|
||||
impl sc_executor::NativeExecutionDispatch for BridgeHubRococoRuntimeExecutor {
|
||||
type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;
|
||||
|
||||
fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {
|
||||
bridge_hub_rococo_runtime::api::dispatch(method, data)
|
||||
}
|
||||
|
||||
fn native_version() -> sc_executor::NativeVersion {
|
||||
bridge_hub_rococo_runtime::native_version()
|
||||
}
|
||||
}
|
||||
|
||||
// Native contracts executor instance.
|
||||
pub struct ContractsRococoRuntimeExecutor;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user