mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 05:51:02 +00:00
Glutton Parachain (#2294)
* Glutton Parachain * implement collator stuff * add glutton * implement missing api calls * small changes * use shell-runtime as starting point * update docs * Glutton chain configurations * successfully build * add local chain config * chain spec * update Cargo.lock * Update parachains/runtimes/glutton/glutton-kusama/src/lib.rs Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> * Update parachains/runtimes/glutton/glutton-kusama/src/lib.rs Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> * Update parachains/runtimes/glutton/glutton-kusama/src/lib.rs Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> * Update parachains/runtimes/glutton/glutton-kusama/src/lib.rs Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> * explicit indices * update para_id * irrelevant docs * update glutton.json * para_id as cli argument * expect * merge * update * fixes * xcm-builder/runtime-benchmarks added * benchmarks enabled * add glutton to bench scripts + nitpick * remove local bootnode * ".git/.scripts/commands/fmt/fmt.sh" * make clippy happy * fix clippy * fix chain_spec * fix chain_spec 2 * fix chain_spec 3 * ".git/.scripts/commands/bench/bench.sh" pallet glutton-kusama-dev-1300 glutton pallet_glutton * Update polkadot-parachain/src/chain_spec/glutton.rs Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> * Update parachains/runtimes/glutton/glutton-kusama/src/lib.rs Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> --------- Co-authored-by: joe petrowski <25483142+joepetrowski@users.noreply.github.com> Co-authored-by: NachoPal <ignacio.palacios.santos@gmail.com> Co-authored-by: command-bot <>
This commit is contained in:
@@ -23,6 +23,7 @@ serde_json = "1.0.96"
|
||||
# Local
|
||||
rococo-parachain-runtime = { path = "../parachains/runtimes/testing/rococo-parachain" }
|
||||
shell-runtime = { path = "../parachains/runtimes/starters/shell" }
|
||||
glutton-runtime = { path = "../parachains/runtimes/glutton/glutton-kusama" }
|
||||
seedling-runtime = { path = "../parachains/runtimes/starters/seedling" }
|
||||
statemint-runtime = { path = "../parachains/runtimes/assets/statemint" }
|
||||
statemine-runtime = { path = "../parachains/runtimes/assets/statemine" }
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
// 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::Extensions;
|
||||
use cumulus_primitives_core::ParaId;
|
||||
use sc_service::ChainType;
|
||||
|
||||
/// Specialized `ChainSpec` for the Glutton parachain runtime.
|
||||
pub type GluttonChainSpec =
|
||||
sc_service::GenericChainSpec<glutton_runtime::GenesisConfig, Extensions>;
|
||||
|
||||
pub fn glutton_development_config(para_id: ParaId) -> GluttonChainSpec {
|
||||
GluttonChainSpec::from_genesis(
|
||||
// Name
|
||||
"Glutton Development",
|
||||
// ID
|
||||
"glutton_dev",
|
||||
ChainType::Local,
|
||||
move || glutton_genesis(para_id),
|
||||
Vec::new(),
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
Extensions { relay_chain: "kusama-dev".into(), para_id: para_id.into() },
|
||||
)
|
||||
}
|
||||
|
||||
pub fn glutton_local_config(para_id: ParaId) -> GluttonChainSpec {
|
||||
GluttonChainSpec::from_genesis(
|
||||
// Name
|
||||
"Glutton Local",
|
||||
// ID
|
||||
"glutton_local",
|
||||
ChainType::Local,
|
||||
move || glutton_genesis(para_id),
|
||||
Vec::new(),
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
None,
|
||||
Extensions { relay_chain: "kusama-local".into(), para_id: para_id.into() },
|
||||
)
|
||||
}
|
||||
|
||||
pub fn glutton_config(para_id: ParaId) -> GluttonChainSpec {
|
||||
let mut properties = sc_chain_spec::Properties::new();
|
||||
properties.insert("ss58Format".into(), 2.into());
|
||||
|
||||
GluttonChainSpec::from_genesis(
|
||||
// Name
|
||||
format!("Glutton {}", para_id).as_str(),
|
||||
// ID
|
||||
format!("glutton_kusama_{}", para_id).as_str(),
|
||||
ChainType::Live,
|
||||
move || glutton_genesis(para_id),
|
||||
Vec::new(),
|
||||
None,
|
||||
// Protocol ID
|
||||
Some(format!("glutton_kusama_{}", para_id).as_str()),
|
||||
None,
|
||||
Some(properties),
|
||||
Extensions { relay_chain: "kusama".into(), para_id: para_id.into() },
|
||||
)
|
||||
}
|
||||
|
||||
fn glutton_genesis(parachain_id: ParaId) -> glutton_runtime::GenesisConfig {
|
||||
glutton_runtime::GenesisConfig {
|
||||
system: glutton_runtime::SystemConfig {
|
||||
code: glutton_runtime::WASM_BINARY
|
||||
.expect("WASM binary was not build, please build it!")
|
||||
.to_vec(),
|
||||
},
|
||||
parachain_info: glutton_runtime::ParachainInfoConfig { parachain_id },
|
||||
parachain_system: Default::default(),
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,7 @@ use sp_runtime::traits::{IdentifyAccount, Verify};
|
||||
pub mod bridge_hubs;
|
||||
pub mod collectives;
|
||||
pub mod contracts;
|
||||
pub mod glutton;
|
||||
pub mod penpal;
|
||||
pub mod rococo_parachain;
|
||||
pub mod seedling;
|
||||
|
||||
@@ -19,7 +19,7 @@ use crate::{
|
||||
cli::{Cli, RelayChainCli, Subcommand},
|
||||
service::{
|
||||
new_partial, Block, BridgeHubKusamaRuntimeExecutor, BridgeHubPolkadotRuntimeExecutor,
|
||||
BridgeHubRococoRuntimeExecutor, CollectivesPolkadotRuntimeExecutor,
|
||||
BridgeHubRococoRuntimeExecutor, CollectivesPolkadotRuntimeExecutor, GluttonRuntimeExecutor,
|
||||
StatemineRuntimeExecutor, StatemintRuntimeExecutor, WestmintRuntimeExecutor,
|
||||
},
|
||||
};
|
||||
@@ -54,6 +54,7 @@ enum Runtime {
|
||||
ContractsRococo,
|
||||
CollectivesPolkadot,
|
||||
CollectivesWestend,
|
||||
Glutton,
|
||||
BridgeHub(chain_spec::bridge_hubs::BridgeHubRuntimeType),
|
||||
}
|
||||
|
||||
@@ -111,6 +112,8 @@ fn runtime(id: &str) -> Runtime {
|
||||
id.parse::<chain_spec::bridge_hubs::BridgeHubRuntimeType>()
|
||||
.expect("Invalid value"),
|
||||
)
|
||||
} else if id.starts_with("glutton") {
|
||||
Runtime::Glutton
|
||||
} else {
|
||||
log::warn!("No specific runtime was recognized for ChainSpec's id: '{}', so Runtime::default() will be used", id);
|
||||
Runtime::default()
|
||||
@@ -214,6 +217,18 @@ fn load_spec(id: &str) -> std::result::Result<Box<dyn ChainSpec>, String> {
|
||||
"polkadot-local",
|
||||
)),
|
||||
|
||||
// -- Glutton
|
||||
"glutton-kusama-dev" => Box::new(chain_spec::glutton::glutton_development_config(
|
||||
para_id.expect("Must specify parachain id"),
|
||||
)),
|
||||
"glutton-kusama-local" => Box::new(chain_spec::glutton::glutton_local_config(
|
||||
para_id.expect("Must specify parachain id"),
|
||||
)),
|
||||
// the chain spec as used for generating the upgrade genesis values
|
||||
"glutton-kusama-genesis" => Box::new(chain_spec::glutton::glutton_config(
|
||||
para_id.expect("Must specify parachain id"),
|
||||
)),
|
||||
|
||||
// -- Fallback (generic chainspec)
|
||||
"" => {
|
||||
log::warn!("No ChainSpec.id specified, so using default one, based on rococo-parachain runtime");
|
||||
@@ -243,6 +258,8 @@ fn load_spec(id: &str) -> std::result::Result<Box<dyn ChainSpec>, String> {
|
||||
bridge_hub_runtime_type.chain_spec_from_json_file(path)?,
|
||||
Runtime::Penpal(_para_id) =>
|
||||
Box::new(chain_spec::penpal::PenpalChainSpec::from_json_file(path)?),
|
||||
Runtime::Glutton =>
|
||||
Box::new(chain_spec::glutton::GluttonChainSpec::from_json_file(path)?),
|
||||
Runtime::Default => Box::new(
|
||||
chain_spec::rococo_parachain::RococoParachainChainSpec::from_json_file(path)?,
|
||||
),
|
||||
@@ -258,12 +275,25 @@ fn extract_parachain_id(id: &str) -> (&str, &str, Option<ParaId>) {
|
||||
const KUSAMA_TEST_PARA_PREFIX: &str = "penpal-kusama-";
|
||||
const POLKADOT_TEST_PARA_PREFIX: &str = "penpal-polkadot-";
|
||||
|
||||
const GLUTTON_PARA_DEV_PREFIX: &str = "glutton-kusama-dev-";
|
||||
const GLUTTON_PARA_LOCAL_PREFIX: &str = "glutton-kusama-local-";
|
||||
const GLUTTON_PARA_GENESIS_PREFIX: &str = "glutton-kusama-genesis-";
|
||||
|
||||
let (norm_id, orig_id, para) = if let Some(suffix) = id.strip_prefix(KUSAMA_TEST_PARA_PREFIX) {
|
||||
let para_id: u32 = suffix.parse().expect("Invalid parachain-id suffix");
|
||||
(&id[..KUSAMA_TEST_PARA_PREFIX.len() - 1], id, Some(para_id))
|
||||
} else if let Some(suffix) = id.strip_prefix(POLKADOT_TEST_PARA_PREFIX) {
|
||||
let para_id: u32 = suffix.parse().expect("Invalid parachain-id suffix");
|
||||
(&id[..POLKADOT_TEST_PARA_PREFIX.len() - 1], id, Some(para_id))
|
||||
} else if let Some(suffix) = id.strip_prefix(GLUTTON_PARA_DEV_PREFIX) {
|
||||
let para_id: u32 = suffix.parse().expect("Invalid parachain-id suffix");
|
||||
(&id[..GLUTTON_PARA_DEV_PREFIX.len() - 1], id, Some(para_id))
|
||||
} else if let Some(suffix) = id.strip_prefix(GLUTTON_PARA_LOCAL_PREFIX) {
|
||||
let para_id: u32 = suffix.parse().expect("Invalid parachain-id suffix");
|
||||
(&id[..GLUTTON_PARA_LOCAL_PREFIX.len() - 1], id, Some(para_id))
|
||||
} else if let Some(suffix) = id.strip_prefix(GLUTTON_PARA_GENESIS_PREFIX) {
|
||||
let para_id: u32 = suffix.parse().expect("Invalid parachain-id suffix");
|
||||
(&id[..GLUTTON_PARA_GENESIS_PREFIX.len() - 1], id, Some(para_id))
|
||||
} else {
|
||||
(id, id, None)
|
||||
};
|
||||
@@ -319,6 +349,7 @@ impl SubstrateCli for Cli {
|
||||
Runtime::BridgeHub(bridge_hub_runtime_type) =>
|
||||
bridge_hub_runtime_type.runtime_version(),
|
||||
Runtime::Penpal(_) => &penpal_runtime::VERSION,
|
||||
Runtime::Glutton => &glutton_runtime::VERSION,
|
||||
Runtime::Default => &rococo_parachain_runtime::VERSION,
|
||||
}
|
||||
}
|
||||
@@ -553,6 +584,16 @@ macro_rules! construct_async_run {
|
||||
let task_manager = $components.task_manager;
|
||||
{ $( $code )* }.map(|v| (v, task_manager))
|
||||
})
|
||||
},
|
||||
Runtime::Glutton => {
|
||||
runner.async_run(|$config| {
|
||||
let $components = new_partial::<glutton_runtime::RuntimeApi, _>(
|
||||
&$config,
|
||||
crate::service::shell_build_import_queue,
|
||||
)?;
|
||||
let task_manager = $components.task_manager;
|
||||
{ $( $code )* }.map(|v| (v, task_manager))
|
||||
})
|
||||
}
|
||||
}
|
||||
}}
|
||||
@@ -659,7 +700,9 @@ pub fn run() -> Result<()> {
|
||||
bridge_hub_runtime_type
|
||||
)
|
||||
.into()),
|
||||
}
|
||||
},
|
||||
Runtime::Glutton =>
|
||||
cmd.run::<Block, GluttonRuntimeExecutor>(config),
|
||||
_ => Err(format!(
|
||||
"Chain '{:?}' doesn't support benchmarking",
|
||||
config.chain_spec.runtime()
|
||||
@@ -796,6 +839,12 @@ pub fn run() -> Result<()> {
|
||||
task_manager,
|
||||
))
|
||||
}),
|
||||
Runtime::Glutton => runner.async_run(|_| {
|
||||
Ok((
|
||||
cmd.run::<Block, HostFunctionsOf<crate::service::GluttonRuntimeExecutor>, _>(Some(info_provider)),
|
||||
task_manager,
|
||||
))
|
||||
}),
|
||||
_ => Err("Chain doesn't support try-runtime".into()),
|
||||
}
|
||||
},
|
||||
@@ -963,6 +1012,17 @@ pub fn run() -> Result<()> {
|
||||
.await
|
||||
.map(|r| r.0)
|
||||
.map_err(Into::into),
|
||||
Runtime::Glutton =>
|
||||
crate::service::start_shell_node::<glutton_runtime::RuntimeApi>(
|
||||
config,
|
||||
polkadot_config,
|
||||
collator_options,
|
||||
id,
|
||||
hwbench,
|
||||
)
|
||||
.await
|
||||
.map(|r| r.0)
|
||||
.map_err(Into::into),
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
@@ -206,6 +206,21 @@ impl sc_executor::NativeExecutionDispatch for ContractsRococoRuntimeExecutor {
|
||||
}
|
||||
}
|
||||
|
||||
/// Native Glutton executor instance.
|
||||
pub struct GluttonRuntimeExecutor;
|
||||
|
||||
impl sc_executor::NativeExecutionDispatch for GluttonRuntimeExecutor {
|
||||
type ExtendHostFunctions = frame_benchmarking::benchmarking::HostFunctions;
|
||||
|
||||
fn dispatch(method: &str, data: &[u8]) -> Option<Vec<u8>> {
|
||||
shell_runtime::api::dispatch(method, data)
|
||||
}
|
||||
|
||||
fn native_version() -> sc_executor::NativeVersion {
|
||||
shell_runtime::native_version()
|
||||
}
|
||||
}
|
||||
|
||||
/// Starts a `ServiceBuilder` for a full service.
|
||||
///
|
||||
/// Use this macro if you don't actually need the full service, but just the builder in order to
|
||||
|
||||
Reference in New Issue
Block a user