mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 06:21:02 +00:00
Rococo/Westend Coretime Runtime
New runtimes for the Coretime Chain (a.k.a. "Broker Chain") described in RFC-1. Replaces https://github.com/paritytech/cumulus/pull/2889 - [x] Add Agile Coretime pallet https://github.com/paritytech/substrate/pull/14568 - [x] Generate chain specs for local and testnets - [x] Deploy parachain on Rococo - Done: [rococo-coretime-rpc.polkadot.io](https://polkadot.js.org/apps/?rpc=wss%3A%2F%2Frococo-coretime-rpc.polkadot.io#/explorer) DevOps issue for Aura keygen: https://github.com/paritytech/devops/issues/2725 Edit (Dónal): This PR is mainly for Rococo, the Westend runtime is a shell with no `Broker` pallet. The Rococo runtime has the broker calls filtered for initial deployment. --------- Co-authored-by: Dónal Murray <donal.murray@parity.io> Co-authored-by: 0xmovses <r.v.melkonian@gmail.com> Co-authored-by: Liam Aharon <liam.aharon@hotmail.com> Co-authored-by: Bastian Köcher <git@kchr.de> Co-authored-by: Marcin S. <marcin@realemail.net> Co-authored-by: Bastian Köcher <info@kchr.de> Co-authored-by: command-bot <> Co-authored-by: Branislav Kontur <bkontur@gmail.com>
This commit is contained in:
@@ -0,0 +1,282 @@
|
||||
// Copyright 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 crate::chain_spec::GenericChainSpec;
|
||||
use cumulus_primitives_core::ParaId;
|
||||
use sc_chain_spec::{ChainSpec, ChainType};
|
||||
use std::{borrow::Cow, str::FromStr};
|
||||
|
||||
/// Collects all supported Coretime configurations.
|
||||
#[derive(Debug, PartialEq, Clone)]
|
||||
pub enum CoretimeRuntimeType {
|
||||
// Live
|
||||
Rococo,
|
||||
// Local
|
||||
RococoLocal,
|
||||
// Benchmarks
|
||||
RococoDevelopment,
|
||||
|
||||
// Local
|
||||
WestendLocal,
|
||||
// Benchmarks
|
||||
WestendDevelopment,
|
||||
}
|
||||
|
||||
impl FromStr for CoretimeRuntimeType {
|
||||
type Err = String;
|
||||
|
||||
fn from_str(value: &str) -> Result<Self, Self::Err> {
|
||||
match value {
|
||||
rococo::CORETIME_ROCOCO => Ok(CoretimeRuntimeType::Rococo),
|
||||
rococo::CORETIME_ROCOCO_LOCAL => Ok(CoretimeRuntimeType::RococoLocal),
|
||||
rococo::CORETIME_ROCOCO_DEVELOPMENT => Ok(CoretimeRuntimeType::RococoDevelopment),
|
||||
westend::CORETIME_WESTEND_LOCAL => Ok(CoretimeRuntimeType::WestendLocal),
|
||||
westend::CORETIME_WESTEND_DEVELOPMENT => Ok(CoretimeRuntimeType::WestendDevelopment),
|
||||
_ => Err(format!("Value '{}' is not configured yet", value)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<CoretimeRuntimeType> for &str {
|
||||
fn from(runtime_type: CoretimeRuntimeType) -> Self {
|
||||
match runtime_type {
|
||||
CoretimeRuntimeType::Rococo => rococo::CORETIME_ROCOCO,
|
||||
CoretimeRuntimeType::RococoLocal => rococo::CORETIME_ROCOCO_LOCAL,
|
||||
CoretimeRuntimeType::RococoDevelopment => rococo::CORETIME_ROCOCO_DEVELOPMENT,
|
||||
CoretimeRuntimeType::WestendLocal => westend::CORETIME_WESTEND_LOCAL,
|
||||
CoretimeRuntimeType::WestendDevelopment => westend::CORETIME_WESTEND_DEVELOPMENT,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<CoretimeRuntimeType> for ChainType {
|
||||
fn from(runtime_type: CoretimeRuntimeType) -> Self {
|
||||
match runtime_type {
|
||||
CoretimeRuntimeType::Rococo => ChainType::Live,
|
||||
CoretimeRuntimeType::RococoLocal | CoretimeRuntimeType::WestendLocal =>
|
||||
ChainType::Local,
|
||||
CoretimeRuntimeType::RococoDevelopment | CoretimeRuntimeType::WestendDevelopment =>
|
||||
ChainType::Development,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub const CORETIME_PARA_ID: ParaId = ParaId::new(1005);
|
||||
|
||||
impl CoretimeRuntimeType {
|
||||
pub const ID_PREFIX: &'static str = "coretime";
|
||||
|
||||
pub fn load_config(&self) -> Result<Box<dyn ChainSpec>, String> {
|
||||
match self {
|
||||
CoretimeRuntimeType::Rococo => Ok(Box::new(GenericChainSpec::from_json_bytes(
|
||||
&include_bytes!("../../../parachains/chain-specs/coretime-rococo.json")[..],
|
||||
)?)),
|
||||
CoretimeRuntimeType::RococoLocal =>
|
||||
Ok(Box::new(rococo::local_config(self, "rococo-local"))),
|
||||
CoretimeRuntimeType::RococoDevelopment =>
|
||||
Ok(Box::new(rococo::local_config(self, "rococo-dev"))),
|
||||
CoretimeRuntimeType::WestendLocal =>
|
||||
Ok(Box::new(westend::local_config(self, "westend-local"))),
|
||||
CoretimeRuntimeType::WestendDevelopment =>
|
||||
Ok(Box::new(westend::local_config(self, "westend-dev"))),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Generate the name directly from the ChainType
|
||||
pub fn chain_type_name(chain_type: &ChainType) -> Cow<str> {
|
||||
match chain_type {
|
||||
ChainType::Development => "Development",
|
||||
ChainType::Local => "Local",
|
||||
ChainType::Live => "Live",
|
||||
ChainType::Custom(name) => name,
|
||||
}
|
||||
.into()
|
||||
}
|
||||
|
||||
/// Sub-module for Rococo setup.
|
||||
pub mod rococo {
|
||||
use super::{chain_type_name, CoretimeRuntimeType, GenericChainSpec, ParaId};
|
||||
use crate::chain_spec::{
|
||||
get_account_id_from_seed, get_collator_keys_from_seed, Extensions, SAFE_XCM_VERSION,
|
||||
};
|
||||
use parachains_common::{AccountId, AuraId, Balance};
|
||||
use sp_core::sr25519;
|
||||
|
||||
pub(crate) const CORETIME_ROCOCO: &str = "coretime-rococo";
|
||||
pub(crate) const CORETIME_ROCOCO_LOCAL: &str = "coretime-rococo-local";
|
||||
pub(crate) const CORETIME_ROCOCO_DEVELOPMENT: &str = "coretime-rococo-dev";
|
||||
const CORETIME_ROCOCO_ED: Balance = parachains_common::rococo::currency::EXISTENTIAL_DEPOSIT;
|
||||
|
||||
pub fn local_config(runtime_type: &CoretimeRuntimeType, relay_chain: &str) -> GenericChainSpec {
|
||||
// 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());
|
||||
|
||||
let chain_type = runtime_type.clone().into();
|
||||
let chain_name = format!("Coretime Rococo {}", chain_type_name(&chain_type));
|
||||
let para_id = super::CORETIME_PARA_ID;
|
||||
|
||||
GenericChainSpec::builder(
|
||||
coretime_rococo_runtime::WASM_BINARY
|
||||
.expect("WASM binary was not built, please build it!"),
|
||||
Extensions { relay_chain: relay_chain.to_string(), para_id: para_id.into() },
|
||||
)
|
||||
.with_name(&chain_name)
|
||||
.with_id(runtime_type.clone().into())
|
||||
.with_chain_type(chain_type)
|
||||
.with_genesis_config_patch(genesis(
|
||||
// initial collators.
|
||||
vec![(
|
||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
||||
get_collator_keys_from_seed::<AuraId>("Alice"),
|
||||
)],
|
||||
vec![
|
||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Bob"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
|
||||
],
|
||||
para_id,
|
||||
))
|
||||
.with_properties(properties)
|
||||
.build()
|
||||
}
|
||||
|
||||
fn genesis(
|
||||
invulnerables: Vec<(AccountId, AuraId)>,
|
||||
endowed_accounts: Vec<AccountId>,
|
||||
id: ParaId,
|
||||
) -> serde_json::Value {
|
||||
serde_json::json!({
|
||||
"balances": {
|
||||
"balances": endowed_accounts.iter().cloned().map(|k| (k, CORETIME_ROCOCO_ED * 4096)).collect::<Vec<_>>(),
|
||||
},
|
||||
"parachainInfo": {
|
||||
"parachainId": id,
|
||||
},
|
||||
"collatorSelection": {
|
||||
"invulnerables": invulnerables.iter().cloned().map(|(acc, _)| acc).collect::<Vec<_>>(),
|
||||
"candidacyBond": CORETIME_ROCOCO_ED * 16,
|
||||
},
|
||||
"session": {
|
||||
"keys": invulnerables
|
||||
.into_iter()
|
||||
.map(|(acc, aura)| {
|
||||
(
|
||||
acc.clone(), // account id
|
||||
acc, // validator id
|
||||
coretime_rococo_runtime::SessionKeys { aura }, // session keys
|
||||
)
|
||||
})
|
||||
.collect::<Vec<_>>(),
|
||||
},
|
||||
"polkadotXcm": {
|
||||
"safeXcmVersion": Some(SAFE_XCM_VERSION),
|
||||
},
|
||||
"sudo": {
|
||||
"key": Some(get_account_id_from_seed::<sr25519::Public>("Alice")),
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/// Sub-module for Westend setup.
|
||||
pub mod westend {
|
||||
use super::{chain_type_name, CoretimeRuntimeType, GenericChainSpec, ParaId};
|
||||
use crate::chain_spec::{
|
||||
get_account_id_from_seed, get_collator_keys_from_seed, Extensions, SAFE_XCM_VERSION,
|
||||
};
|
||||
use parachains_common::{AccountId, AuraId, Balance};
|
||||
use sp_core::sr25519;
|
||||
|
||||
pub(crate) const CORETIME_WESTEND_LOCAL: &str = "coretime-westend-local";
|
||||
pub(crate) const CORETIME_WESTEND_DEVELOPMENT: &str = "coretime-westend-dev";
|
||||
const CORETIME_WESTEND_ED: Balance = parachains_common::westend::currency::EXISTENTIAL_DEPOSIT;
|
||||
|
||||
pub fn local_config(runtime_type: &CoretimeRuntimeType, relay_chain: &str) -> GenericChainSpec {
|
||||
// westend defaults
|
||||
let mut properties = sc_chain_spec::Properties::new();
|
||||
properties.insert("ss58Format".into(), 42.into());
|
||||
properties.insert("tokenSymbol".into(), "WND".into());
|
||||
properties.insert("tokenDecimals".into(), 12.into());
|
||||
|
||||
let chain_type = runtime_type.clone().into();
|
||||
let chain_name = format!("Coretime Westend {}", chain_type_name(&chain_type));
|
||||
let para_id = super::CORETIME_PARA_ID;
|
||||
|
||||
GenericChainSpec::builder(
|
||||
coretime_westend_runtime::WASM_BINARY
|
||||
.expect("WASM binary was not built, please build it!"),
|
||||
Extensions { relay_chain: relay_chain.to_string(), para_id: para_id.into() },
|
||||
)
|
||||
.with_name(&chain_name)
|
||||
.with_id(runtime_type.clone().into())
|
||||
.with_chain_type(chain_type)
|
||||
.with_genesis_config_patch(genesis(
|
||||
// initial collators.
|
||||
vec![(
|
||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
||||
get_collator_keys_from_seed::<AuraId>("Alice"),
|
||||
)],
|
||||
vec![
|
||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Bob"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Alice//stash"),
|
||||
get_account_id_from_seed::<sr25519::Public>("Bob//stash"),
|
||||
],
|
||||
para_id,
|
||||
))
|
||||
.with_properties(properties)
|
||||
.build()
|
||||
}
|
||||
|
||||
fn genesis(
|
||||
invulnerables: Vec<(AccountId, AuraId)>,
|
||||
endowed_accounts: Vec<AccountId>,
|
||||
id: ParaId,
|
||||
) -> serde_json::Value {
|
||||
serde_json::json!({
|
||||
"balances": {
|
||||
"balances": endowed_accounts.iter().cloned().map(|k| (k, CORETIME_WESTEND_ED * 4096)).collect::<Vec<_>>(),
|
||||
},
|
||||
"parachainInfo": {
|
||||
"parachainId": id,
|
||||
},
|
||||
"collatorSelection": {
|
||||
"invulnerables": invulnerables.iter().cloned().map(|(acc, _)| acc).collect::<Vec<_>>(),
|
||||
"candidacyBond": CORETIME_WESTEND_ED * 16,
|
||||
},
|
||||
"session": {
|
||||
"keys": invulnerables
|
||||
.into_iter()
|
||||
.map(|(acc, aura)| {
|
||||
(
|
||||
acc.clone(), // account id
|
||||
acc, // validator id
|
||||
coretime_westend_runtime::SessionKeys { aura }, // session keys
|
||||
)
|
||||
})
|
||||
.collect::<Vec<_>>(),
|
||||
},
|
||||
"polkadotXcm": {
|
||||
"safeXcmVersion": Some(SAFE_XCM_VERSION),
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,7 @@ pub mod asset_hubs;
|
||||
pub mod bridge_hubs;
|
||||
pub mod collectives;
|
||||
pub mod contracts;
|
||||
pub mod coretime;
|
||||
pub mod glutton;
|
||||
pub mod penpal;
|
||||
pub mod rococo_parachain;
|
||||
|
||||
@@ -55,6 +55,7 @@ enum Runtime {
|
||||
Glutton,
|
||||
GluttonWestend,
|
||||
BridgeHub(chain_spec::bridge_hubs::BridgeHubRuntimeType),
|
||||
Coretime(chain_spec::coretime::CoretimeRuntimeType),
|
||||
}
|
||||
|
||||
trait RuntimeResolver {
|
||||
@@ -113,6 +114,10 @@ fn runtime(id: &str) -> Runtime {
|
||||
id.parse::<chain_spec::bridge_hubs::BridgeHubRuntimeType>()
|
||||
.expect("Invalid value"),
|
||||
)
|
||||
} else if id.starts_with(chain_spec::coretime::CoretimeRuntimeType::ID_PREFIX) {
|
||||
Runtime::Coretime(
|
||||
id.parse::<chain_spec::coretime::CoretimeRuntimeType>().expect("Invalid value"),
|
||||
)
|
||||
} else if id.starts_with("glutton-westend") {
|
||||
Runtime::GluttonWestend
|
||||
} else if id.starts_with("glutton") {
|
||||
@@ -211,6 +216,15 @@ fn load_spec(id: &str) -> std::result::Result<Box<dyn ChainSpec>, String> {
|
||||
.expect("invalid value")
|
||||
.load_config()?,
|
||||
|
||||
// -- Coretime
|
||||
coretime_like_id
|
||||
if coretime_like_id
|
||||
.starts_with(chain_spec::coretime::CoretimeRuntimeType::ID_PREFIX) =>
|
||||
coretime_like_id
|
||||
.parse::<chain_spec::coretime::CoretimeRuntimeType>()
|
||||
.expect("invalid value")
|
||||
.load_config()?,
|
||||
|
||||
// -- Penpal
|
||||
"penpal-rococo" => Box::new(chain_spec::penpal::get_penpal_chain_spec(
|
||||
para_id.expect("Must specify parachain id"),
|
||||
@@ -378,7 +392,8 @@ macro_rules! construct_partials {
|
||||
Runtime::AssetHubWestend |
|
||||
Runtime::BridgeHub(_) |
|
||||
Runtime::CollectivesPolkadot |
|
||||
Runtime::CollectivesWestend => {
|
||||
Runtime::CollectivesWestend |
|
||||
Runtime::Coretime(_) => {
|
||||
let $partials = new_partial::<RuntimeApi, _>(
|
||||
&$config,
|
||||
crate::service::aura_build_import_queue::<_, AuraId>,
|
||||
@@ -424,12 +439,13 @@ macro_rules! construct_async_run {
|
||||
{ $( $code )* }.map(|v| (v, task_manager))
|
||||
})
|
||||
},
|
||||
Runtime::AssetHubWestend |
|
||||
Runtime::AssetHubRococo |
|
||||
Runtime::AssetHubKusama |
|
||||
Runtime::AssetHubRococo |
|
||||
Runtime::AssetHubWestend |
|
||||
Runtime::BridgeHub(_) |
|
||||
Runtime::CollectivesPolkadot |
|
||||
Runtime::CollectivesWestend |
|
||||
Runtime::BridgeHub(_) => {
|
||||
Runtime::Coretime(_) => {
|
||||
runner.async_run(|$config| {
|
||||
let $components = new_partial::<RuntimeApi, _>(
|
||||
&$config,
|
||||
@@ -596,31 +612,31 @@ pub fn run() -> Result<()> {
|
||||
// that both file paths exist, the node will exit, as the user must decide (by
|
||||
// deleting one path) the information that they want to use as their DB.
|
||||
let old_name = match config.chain_spec.id() {
|
||||
"asset-hub-polkadot" => Some("statemint"),
|
||||
"asset-hub-kusama" => Some("statemine"),
|
||||
"asset-hub-westend" => Some("westmint"),
|
||||
"asset-hub-rococo" => Some("rockmine"),
|
||||
_ => None,
|
||||
"asset-hub-polkadot" => Some("statemint"),
|
||||
"asset-hub-kusama" => Some("statemine"),
|
||||
"asset-hub-westend" => Some("westmint"),
|
||||
"asset-hub-rococo" => Some("rockmine"),
|
||||
_ => None,
|
||||
};
|
||||
|
||||
if let Some(old_name) = old_name {
|
||||
let new_path = config.base_path.config_dir(config.chain_spec.id());
|
||||
let old_path = config.base_path.config_dir(old_name);
|
||||
let new_path = config.base_path.config_dir(config.chain_spec.id());
|
||||
let old_path = config.base_path.config_dir(old_name);
|
||||
|
||||
if old_path.exists() && new_path.exists() {
|
||||
return Err(format!(
|
||||
if old_path.exists() && new_path.exists() {
|
||||
return Err(format!(
|
||||
"Found legacy {} path {} and new asset-hub path {}. Delete one path such that only one exists.",
|
||||
old_name, old_path.display(), new_path.display()
|
||||
).into())
|
||||
}
|
||||
}
|
||||
|
||||
if old_path.exists() {
|
||||
std::fs::rename(old_path.clone(), new_path.clone())?;
|
||||
if old_path.exists() {
|
||||
std::fs::rename(old_path.clone(), new_path.clone())?;
|
||||
info!(
|
||||
"Statemint renamed to Asset Hub. The filepath with associated data on disk has been renamed from {} to {}.",
|
||||
old_path.display(), new_path.display()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let hwbench = (!cli.no_hardware_benchmarks).then_some(
|
||||
@@ -729,6 +745,7 @@ 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::Polkadot =>
|
||||
crate::service::start_generic_aura_node::<
|
||||
@@ -764,6 +781,22 @@ pub fn run() -> Result<()> {
|
||||
.map(|r| r.0),
|
||||
}
|
||||
.map_err(Into::into),
|
||||
|
||||
Runtime::Coretime(coretime_runtime_type) => match coretime_runtime_type {
|
||||
chain_spec::coretime::CoretimeRuntimeType::Rococo |
|
||||
chain_spec::coretime::CoretimeRuntimeType::RococoLocal |
|
||||
chain_spec::coretime::CoretimeRuntimeType::RococoDevelopment |
|
||||
chain_spec::coretime::CoretimeRuntimeType::WestendLocal |
|
||||
chain_spec::coretime::CoretimeRuntimeType::WestendDevelopment =>
|
||||
crate::service::start_generic_aura_node::<
|
||||
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,
|
||||
|
||||
@@ -141,6 +141,30 @@ impl sc_executor::NativeExecutionDispatch for BridgeHubRococoRuntimeExecutor {
|
||||
}
|
||||
}
|
||||
|
||||
/// Native `CoretimeRococo` executor instance.
|
||||
pub struct CoretimeRococoRuntimeExecutor;
|
||||
impl sc_executor::NativeExecutionDispatch for CoretimeRococoRuntimeExecutor {
|
||||
type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;
|
||||
fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {
|
||||
coretime_rococo_runtime::api::dispatch(method, data)
|
||||
}
|
||||
fn native_version() -> sc_executor::NativeVersion {
|
||||
coretime_rococo_runtime::native_version()
|
||||
}
|
||||
}
|
||||
|
||||
/// Native `CoretimeWestend` executor instance.
|
||||
pub struct CoretimeWestendRuntimeExecutor;
|
||||
impl sc_executor::NativeExecutionDispatch for CoretimeWestendRuntimeExecutor {
|
||||
type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;
|
||||
fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {
|
||||
coretime_westend_runtime::api::dispatch(method, data)
|
||||
}
|
||||
fn native_version() -> sc_executor::NativeVersion {
|
||||
coretime_westend_runtime::native_version()
|
||||
}
|
||||
}
|
||||
|
||||
/// Native contracts executor instance.
|
||||
pub struct ContractsRococoRuntimeExecutor;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user