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:
Branislav Kontur
2022-12-02 14:06:39 +01:00
committed by GitHub
parent 3b2ec9eade
commit c3df7db394
68 changed files with 5319 additions and 212 deletions
@@ -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;