mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 04:01:02 +00:00
Added new empty shell runtime for BridgeHubPolkadot (without bridging stuff) for onboarding parachain on Polkadot (#2137)
* Added new empty shell runtime for `BridgeHubPolkadot` (without bridging stuff) for onboarding parachain on Polkadot * Fix benchmarks/try-runtime * ".git/.scripts/commands/bench/bench.sh" pallet bridge-hub-polkadot bridge-hubs frame_system * ".git/.scripts/commands/bench/bench.sh" pallet bridge-hub-polkadot bridge-hubs pallet_balances * ".git/.scripts/commands/bench/bench.sh" pallet bridge-hub-polkadot bridge-hubs pallet_multisig * ".git/.scripts/commands/bench/bench.sh" pallet bridge-hub-polkadot bridge-hubs pallet_xcm * Fixes * ".git/.scripts/commands/bench/bench.sh" pallet bridge-hub-polkadot bridge-hubs pallet_session * ".git/.scripts/commands/bench/bench.sh" pallet bridge-hub-polkadot bridge-hubs pallet_utility * ".git/.scripts/commands/bench/bench.sh" pallet bridge-hub-polkadot bridge-hubs pallet_timestamp * ".git/.scripts/commands/bench/bench.sh" pallet bridge-hub-polkadot bridge-hubs pallet_collator_selection * ".git/.scripts/commands/bench/bench.sh" pallet bridge-hub-polkadot bridge-hubs cumulus_pallet_xcmp_queue * PR fixes * Rebase fix * Fix new runtime api * ".git/.scripts/commands/bench/bench.sh" xcm bridge-hub-polkadot bridge-hubs pallet_xcm_benchmarks::fungible * ".git/.scripts/commands/bench/bench.sh" xcm bridge-hub-polkadot bridge-hubs pallet_xcm_benchmarks::generic * Updated aura/bootNodes in `create_bridge_hub_polkadot_spec.sh` --------- Co-authored-by: command-bot <>
This commit is contained in:
@@ -36,6 +36,11 @@ pub enum BridgeHubRuntimeType {
|
||||
// used by benchmarks
|
||||
KusamaDevelopment,
|
||||
|
||||
Polkadot,
|
||||
PolkadotLocal,
|
||||
// used by benchmarks
|
||||
PolkadotDevelopment,
|
||||
|
||||
// used with kusama runtime
|
||||
Westend,
|
||||
}
|
||||
@@ -45,6 +50,10 @@ impl FromStr for BridgeHubRuntimeType {
|
||||
|
||||
fn from_str(value: &str) -> Result<Self, Self::Err> {
|
||||
match value {
|
||||
polkadot::BRIDGE_HUB_POLKADOT => Ok(BridgeHubRuntimeType::Polkadot),
|
||||
polkadot::BRIDGE_HUB_POLKADOT_LOCAL => Ok(BridgeHubRuntimeType::PolkadotLocal),
|
||||
polkadot::BRIDGE_HUB_POLKADOT_DEVELOPMENT =>
|
||||
Ok(BridgeHubRuntimeType::PolkadotDevelopment),
|
||||
kusama::BRIDGE_HUB_KUSAMA => Ok(BridgeHubRuntimeType::Kusama),
|
||||
kusama::BRIDGE_HUB_KUSAMA_LOCAL => Ok(BridgeHubRuntimeType::KusamaLocal),
|
||||
kusama::BRIDGE_HUB_KUSAMA_DEVELOPMENT => Ok(BridgeHubRuntimeType::KusamaDevelopment),
|
||||
@@ -64,6 +73,10 @@ impl BridgeHubRuntimeType {
|
||||
|
||||
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 =>
|
||||
@@ -81,6 +94,22 @@ impl BridgeHubRuntimeType {
|
||||
|
||||
pub fn load_config(&self) -> Result<Box<dyn ChainSpec>, String> {
|
||||
match self {
|
||||
BridgeHubRuntimeType::Polkadot =>
|
||||
Ok(Box::new(polkadot::BridgeHubChainSpec::from_json_bytes(
|
||||
&include_bytes!("../../../parachains/chain-specs/bridge-hub-polkadot.json")[..],
|
||||
)?)),
|
||||
BridgeHubRuntimeType::PolkadotLocal => Ok(Box::new(polkadot::local_config(
|
||||
polkadot::BRIDGE_HUB_POLKADOT_LOCAL,
|
||||
"Polkadot BridgeHub Local",
|
||||
"polkadot-local",
|
||||
ParaId::new(1002),
|
||||
))),
|
||||
BridgeHubRuntimeType::PolkadotDevelopment => Ok(Box::new(polkadot::local_config(
|
||||
polkadot::BRIDGE_HUB_POLKADOT_DEVELOPMENT,
|
||||
"Polkadot BridgeHub Development",
|
||||
"polkadot-dev",
|
||||
ParaId::new(1002),
|
||||
))),
|
||||
BridgeHubRuntimeType::Kusama =>
|
||||
Ok(Box::new(kusama::BridgeHubChainSpec::from_json_bytes(
|
||||
&include_bytes!("../../../parachains/chain-specs/bridge-hub-kusama.json")[..],
|
||||
@@ -126,19 +155,22 @@ impl BridgeHubRuntimeType {
|
||||
wococo::BRIDGE_HUB_WOCOCO,
|
||||
"Wococo BridgeHub",
|
||||
"wococo",
|
||||
ParaId::new(1013),
|
||||
ParaId::new(1014),
|
||||
))),
|
||||
BridgeHubRuntimeType::WococoLocal => Ok(Box::new(wococo::local_config(
|
||||
wococo::BRIDGE_HUB_WOCOCO_LOCAL,
|
||||
"Wococo BridgeHub Local",
|
||||
"wococo-local",
|
||||
ParaId::new(1013),
|
||||
ParaId::new(1014),
|
||||
))),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn runtime_version(&self) -> &'static RuntimeVersion {
|
||||
match self {
|
||||
BridgeHubRuntimeType::Polkadot |
|
||||
BridgeHubRuntimeType::PolkadotLocal |
|
||||
BridgeHubRuntimeType::PolkadotDevelopment => &bridge_hub_polkadot_runtime::VERSION,
|
||||
BridgeHubRuntimeType::Kusama |
|
||||
BridgeHubRuntimeType::KusamaLocal |
|
||||
BridgeHubRuntimeType::KusamaDevelopment => &bridge_hub_kusama_runtime::VERSION,
|
||||
@@ -515,3 +547,126 @@ pub mod westend {
|
||||
pub type BridgeHubChainSpec = kusama::BridgeHubChainSpec;
|
||||
pub type RuntimeApi = bridge_hub_kusama_runtime::RuntimeApi;
|
||||
}
|
||||
|
||||
/// Sub-module for Polkadot setup
|
||||
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,
|
||||
};
|
||||
use parachains_common::{AccountId, AuraId};
|
||||
use sc_chain_spec::ChainType;
|
||||
use sp_core::sr25519;
|
||||
|
||||
pub(crate) const BRIDGE_HUB_POLKADOT: &str = "bridge-hub-polkadot";
|
||||
pub(crate) const BRIDGE_HUB_POLKADOT_LOCAL: &str = "bridge-hub-polkadot-local";
|
||||
pub(crate) const BRIDGE_HUB_POLKADOT_DEVELOPMENT: &str = "bridge-hub-polkadot-dev";
|
||||
const BRIDGE_HUB_POLKADOT_ED: BridgeHubBalance =
|
||||
bridge_hub_polkadot_runtime::constants::currency::EXISTENTIAL_DEPOSIT;
|
||||
|
||||
/// Specialized `ChainSpec` for the normal parachain runtime.
|
||||
pub type BridgeHubChainSpec =
|
||||
sc_service::GenericChainSpec<bridge_hub_polkadot_runtime::GenesisConfig, Extensions>;
|
||||
pub type RuntimeApi = bridge_hub_polkadot_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(), 0.into());
|
||||
properties.insert("tokenSymbol".into(), "DOT".into());
|
||||
properties.insert("tokenDecimals".into(), 10.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_polkadot_runtime::GenesisConfig {
|
||||
bridge_hub_polkadot_runtime::GenesisConfig {
|
||||
system: bridge_hub_polkadot_runtime::SystemConfig {
|
||||
code: bridge_hub_polkadot_runtime::WASM_BINARY
|
||||
.expect("WASM binary was not build, please build it!")
|
||||
.to_vec(),
|
||||
},
|
||||
balances: bridge_hub_polkadot_runtime::BalancesConfig {
|
||||
balances: endowed_accounts
|
||||
.iter()
|
||||
.cloned()
|
||||
.map(|k| (k, BRIDGE_HUB_POLKADOT_ED * 4096))
|
||||
.collect(),
|
||||
},
|
||||
parachain_info: bridge_hub_polkadot_runtime::ParachainInfoConfig { parachain_id: id },
|
||||
collator_selection: bridge_hub_polkadot_runtime::CollatorSelectionConfig {
|
||||
invulnerables: invulnerables.iter().cloned().map(|(acc, _)| acc).collect(),
|
||||
candidacy_bond: BRIDGE_HUB_POLKADOT_ED * 16,
|
||||
..Default::default()
|
||||
},
|
||||
session: bridge_hub_polkadot_runtime::SessionConfig {
|
||||
keys: invulnerables
|
||||
.into_iter()
|
||||
.map(|(acc, aura)| {
|
||||
(
|
||||
acc.clone(), // account id
|
||||
acc, // validator id
|
||||
bridge_hub_polkadot_runtime::SessionKeys { aura }, // session keys
|
||||
)
|
||||
})
|
||||
.collect(),
|
||||
},
|
||||
aura: Default::default(),
|
||||
aura_ext: Default::default(),
|
||||
parachain_system: Default::default(),
|
||||
polkadot_xcm: bridge_hub_polkadot_runtime::PolkadotXcmConfig {
|
||||
safe_xcm_version: Some(SAFE_XCM_VERSION),
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user