difftreelog
feat sapphire runtime
in: master
5 files changed
node/cli/Cargo.tomldiffbeforeafterboth--- a/node/cli/Cargo.toml
+++ b/node/cli/Cargo.toml
@@ -335,3 +335,7 @@
'quartz-runtime?/try-runtime',
'opal-runtime?/try-runtime',
]
+sapphire-runtime = [
+ 'opal-runtime',
+ 'opal-runtime/become-sapphire',
+]
node/cli/src/chain_spec.rsdiffbeforeafterboth--- a/node/cli/src/chain_spec.rs
+++ b/node/cli/src/chain_spec.rs
@@ -66,7 +66,7 @@
}
#[cfg(not(feature = "unique-runtime"))]
-/// PARA_ID for Opal/Quartz
+/// PARA_ID for Opal/Sapphire/Quartz
const PARA_ID: u32 = 2095;
#[cfg(feature = "unique-runtime")]
@@ -89,7 +89,11 @@
return RuntimeId::Quartz;
}
- if self.id().starts_with("opal") || self.id() == "dev" || self.id() == "local_testnet" {
+ if self.id().starts_with("opal")
+ || self.id().starts_with("sapphire")
+ || self.id() == "dev"
+ || self.id() == "local_testnet"
+ {
return RuntimeId::Opal;
}
node/cli/src/cli.rsdiffbeforeafterboth1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617use crate::chain_spec;18use std::{path::PathBuf, env};19use clap::Parser;2021const NODE_NAME_ENV: &str = "UNIQUE_NODE_NAME";2223/// Sub-commands supported by the collator.24#[derive(Debug, Parser)]25pub enum Subcommand {26 /// Export the genesis state of the parachain.27 ExportGenesisState(cumulus_client_cli::ExportGenesisStateCommand),2829 /// Export the genesis wasm of the parachain.30 ExportGenesisWasm(cumulus_client_cli::ExportGenesisWasmCommand),3132 /// Build a chain specification.33 BuildSpec(sc_cli::BuildSpecCmd),3435 /// Validate blocks.36 CheckBlock(sc_cli::CheckBlockCmd),3738 /// Export blocks.39 ExportBlocks(sc_cli::ExportBlocksCmd),4041 /// Export the state of a given block into a chain spec.42 ExportState(sc_cli::ExportStateCmd),4344 /// Import blocks.45 ImportBlocks(sc_cli::ImportBlocksCmd),4647 /// Remove the whole chain.48 PurgeChain(cumulus_client_cli::PurgeChainCmd),4950 /// Revert the chain to a previous state.51 Revert(sc_cli::RevertCmd),5253 /// The custom benchmark subcommmand benchmarking runtime pallets.54 #[clap(subcommand)]55 #[cfg(feature = "runtime-benchmarks")]56 Benchmark(frame_benchmarking_cli::BenchmarkCmd),5758 /// Try runtime59 TryRuntime(try_runtime_cli::TryRuntimeCmd),60}6162#[derive(Debug, Parser)]63#[clap(args_conflicts_with_subcommands = true, subcommand_negates_reqs = true)]64pub struct Cli {65 #[structopt(subcommand)]66 pub subcommand: Option<Subcommand>,6768 #[structopt(flatten)]69 pub run: cumulus_client_cli::RunCmd,7071 /// When running the node in the `--dev` mode and72 /// there is no transaction in the transaction pool,73 /// an empty block will be sealed automatically74 /// after the `--idle-autoseal-interval` milliseconds.75 ///76 /// The default interval is 500 milliseconds77 #[structopt(default_value = "500", long)]78 pub idle_autoseal_interval: u64,7980 /// Disable automatic hardware benchmarks.81 ///82 /// By default these benchmarks are automatically ran at startup and measure83 /// the CPU speed, the memory bandwidth and the disk speed.84 ///85 /// The results are then printed out in the logs, and also sent as part of86 /// telemetry, if telemetry is enabled.87 #[clap(long)]88 pub no_hardware_benchmarks: bool,8990 /// Relaychain arguments91 #[structopt(raw = true)]92 pub relaychain_args: Vec<String>,93}9495impl Cli {96 pub fn node_name() -> String {97 match env::var(NODE_NAME_ENV).ok() {98 Some(name) => name,99 None => {100 if cfg!(feature = "unique-runtime") {101 "Unique"102 } else if cfg!(feature = "quartz-runtime") {103 "Quartz"104 } else {105 "Opal"106 }107 }108 .into(),109 }110 }111}112113#[derive(Debug)]114pub struct RelayChainCli {115 /// The actual relay chain cli object.116 pub base: polkadot_cli::RunCmd,117118 /// Optional chain id that should be passed to the relay chain.119 pub chain_id: Option<String>,120121 /// The base path that should be used by the relay chain.122 pub base_path: Option<PathBuf>,123}124125impl RelayChainCli {126 /// Parse the relay chain CLI parameters using the para chain `Configuration`.127 pub fn new<'a>(128 para_config: &sc_service::Configuration,129 relay_chain_args: impl Iterator<Item = &'a String>,130 ) -> Self {131 let extension = chain_spec::Extensions::try_get(&*para_config.chain_spec);132 let chain_id = extension.map(|e| e.relay_chain.clone());133 let base_path = para_config134 .base_path135 .as_ref()136 .map(|x| x.path().join("polkadot"));137 Self {138 base_path,139 chain_id,140 base: polkadot_cli::RunCmd::parse_from(relay_chain_args),141 }142 }143}1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617use crate::chain_spec;18use std::{path::PathBuf, env};19use clap::Parser;2021const NODE_NAME_ENV: &str = "UNIQUE_NODE_NAME";2223/// Sub-commands supported by the collator.24#[derive(Debug, Parser)]25pub enum Subcommand {26 /// Export the genesis state of the parachain.27 ExportGenesisState(cumulus_client_cli::ExportGenesisStateCommand),2829 /// Export the genesis wasm of the parachain.30 ExportGenesisWasm(cumulus_client_cli::ExportGenesisWasmCommand),3132 /// Build a chain specification.33 BuildSpec(sc_cli::BuildSpecCmd),3435 /// Validate blocks.36 CheckBlock(sc_cli::CheckBlockCmd),3738 /// Export blocks.39 ExportBlocks(sc_cli::ExportBlocksCmd),4041 /// Export the state of a given block into a chain spec.42 ExportState(sc_cli::ExportStateCmd),4344 /// Import blocks.45 ImportBlocks(sc_cli::ImportBlocksCmd),4647 /// Remove the whole chain.48 PurgeChain(cumulus_client_cli::PurgeChainCmd),4950 /// Revert the chain to a previous state.51 Revert(sc_cli::RevertCmd),5253 /// The custom benchmark subcommmand benchmarking runtime pallets.54 #[clap(subcommand)]55 #[cfg(feature = "runtime-benchmarks")]56 Benchmark(frame_benchmarking_cli::BenchmarkCmd),5758 /// Try runtime59 TryRuntime(try_runtime_cli::TryRuntimeCmd),60}6162#[derive(Debug, Parser)]63#[clap(args_conflicts_with_subcommands = true, subcommand_negates_reqs = true)]64pub struct Cli {65 #[structopt(subcommand)]66 pub subcommand: Option<Subcommand>,6768 #[structopt(flatten)]69 pub run: cumulus_client_cli::RunCmd,7071 /// When running the node in the `--dev` mode and72 /// there is no transaction in the transaction pool,73 /// an empty block will be sealed automatically74 /// after the `--idle-autoseal-interval` milliseconds.75 ///76 /// The default interval is 500 milliseconds77 #[structopt(default_value = "500", long)]78 pub idle_autoseal_interval: u64,7980 /// Disable automatic hardware benchmarks.81 ///82 /// By default these benchmarks are automatically ran at startup and measure83 /// the CPU speed, the memory bandwidth and the disk speed.84 ///85 /// The results are then printed out in the logs, and also sent as part of86 /// telemetry, if telemetry is enabled.87 #[clap(long)]88 pub no_hardware_benchmarks: bool,8990 /// Relaychain arguments91 #[structopt(raw = true)]92 pub relaychain_args: Vec<String>,93}9495impl Cli {96 pub fn node_name() -> String {97 match env::var(NODE_NAME_ENV).ok() {98 Some(name) => name,99 None => {100 if cfg!(feature = "unique-runtime") {101 "Unique"102 } else if cfg!(feature = "quartz-runtime") {103 "Quartz"104 } else if cfg!(feature = "sapphire-runtime") {105 "Sapphire"106 } else {107 "Opal"108 }109 }110 .into(),111 }112 }113}114115#[derive(Debug)]116pub struct RelayChainCli {117 /// The actual relay chain cli object.118 pub base: polkadot_cli::RunCmd,119120 /// Optional chain id that should be passed to the relay chain.121 pub chain_id: Option<String>,122123 /// The base path that should be used by the relay chain.124 pub base_path: Option<PathBuf>,125}126127impl RelayChainCli {128 /// Parse the relay chain CLI parameters using the para chain `Configuration`.129 pub fn new<'a>(130 para_config: &sc_service::Configuration,131 relay_chain_args: impl Iterator<Item = &'a String>,132 ) -> Self {133 let extension = chain_spec::Extensions::try_get(&*para_config.chain_spec);134 let chain_id = extension.map(|e| e.relay_chain.clone());135 let base_path = para_config136 .base_path137 .as_ref()138 .map(|x| x.path().join("polkadot"));139 Self {140 base_path,141 chain_id,142 base: polkadot_cli::RunCmd::parse_from(relay_chain_args),143 }144 }145}runtime/opal/Cargo.tomldiffbeforeafterboth--- a/runtime/opal/Cargo.toml
+++ b/runtime/opal/Cargo.toml
@@ -181,6 +181,7 @@
'foreign-assets',
'pallet-test-utils',
]
+become-sapphire = []
refungible = []
scheduler = []
runtime/opal/src/lib.rsdiffbeforeafterboth--- a/runtime/opal/src/lib.rs
+++ b/runtime/opal/src/lib.rs
@@ -42,7 +42,14 @@
pub use runtime_common::*;
+#[cfg(feature = "become-sapphire")]
+pub const RUNTIME_NAME: &str = "sapphire";
+#[cfg(feature = "become-sapphire")]
+pub const TOKEN_SYMBOL: &str = "QTZ";
+
+#[cfg(not(feature = "become-sapphire"))]
pub const RUNTIME_NAME: &str = "opal";
+#[cfg(not(feature = "become-sapphire"))]
pub const TOKEN_SYMBOL: &str = "OPL";
/// This runtime version.
@@ -59,7 +66,16 @@
parameter_types! {
pub const Version: RuntimeVersion = VERSION;
- pub const SS58Prefix: u8 = 42;
+}
+#[cfg(feature = "become-sapphire")]
+parameter_types! {
+ pub const SS58Prefix: u16 = 8883;
+ pub const ChainId: u64 = 8883;
+}
+
+#[cfg(not(feature = "become-sapphire"))]
+parameter_types! {
+ pub const SS58Prefix: u16 = 42;
pub const ChainId: u64 = 8882;
}