Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Remove Polkadot & Kusama native runtime #7467

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ color-eyre = { version = "0.6.1", default-features = false }
tikv-jemallocator = "0.5.0"

# Crates in our workspace, defined as dependencies so we can pass them feature flags.
polkadot-cli = { path = "cli", features = [ "polkadot-native", "kusama-native", "westend-native", "rococo-native" ] }
polkadot-cli = { path = "cli", features = [ "westend-native", "rococo-native" ] }
polkadot-node-core-pvf = { path = "node/core/pvf" }
polkadot-node-core-pvf-prepare-worker = { path = "node/core/pvf/prepare-worker" }
polkadot-overseer = { path = "node/overseer" }
Expand Down
6 changes: 1 addition & 5 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,7 @@ fast-runtime = ["service/fast-runtime"]
pyroscope = ["pyro", "pyroscope_pprofrs"]
hostperfcheck = ["polkadot-performance-test"]

# Configure the native runtimes to use. Polkadot is enabled by default.
#
# Validators require the native runtime currently
polkadot-native = ["service/polkadot-native"]
kusama-native = ["service/kusama-native"]
# Configure the native runtimes to use.
westend-native = ["service/westend-native"]
rococo-native = ["service/rococo-native"]

Expand Down
95 changes: 18 additions & 77 deletions cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,11 @@ pub use polkadot_performance_test::PerfCheckError;
#[cfg(feature = "pyroscope")]
use pyroscope_pprofrs::{pprof_backend, PprofConfig};

impl From<String> for Error {
fn from(s: String) -> Self {
Self::Other(s)
}
}

type Result<T> = std::result::Result<T, Error>;

/// Millisecs per block is assumed to be the same for every relay chain.
const MILLISECS_PER_BLOCK: u64 = 6000;

fn get_exec_name() -> Option<String> {
std::env::current_exe()
.ok()
Expand Down Expand Up @@ -91,20 +88,11 @@ impl SubstrateCli for Cli {
};
Ok(match id {
"kusama" => Box::new(service::chain_spec::kusama_config()?),
#[cfg(feature = "kusama-native")]
"kusama-dev" => Box::new(service::chain_spec::kusama_development_config()?),
#[cfg(feature = "kusama-native")]
"kusama-local" => Box::new(service::chain_spec::kusama_local_testnet_config()?),
#[cfg(feature = "kusama-native")]
"kusama-staging" => Box::new(service::chain_spec::kusama_staging_testnet_config()?),
#[cfg(not(feature = "kusama-native"))]
name if name.starts_with("kusama-") && !name.ends_with(".json") =>
Err(format!("`{}` only supported with `kusama-native` feature enabled.", name))?,
Err(format!("`{name}` is not supported anymore as the kusama native runtime no longer part of the node."))?,
"polkadot" => Box::new(service::chain_spec::polkadot_config()?),
#[cfg(feature = "polkadot-native")]
"polkadot-dev" | "dev" => Box::new(service::chain_spec::polkadot_development_config()?),
#[cfg(feature = "polkadot-native")]
"polkadot-local" => Box::new(service::chain_spec::polkadot_local_testnet_config()?),
name if name.starts_with("polkadot-") && !name.ends_with(".json") =>
Err(format!("`{name}` is not supported anymore as the polkadot native runtime no longer part of the node."))?,
"rococo" => Box::new(service::chain_spec::rococo_config()?),
#[cfg(feature = "rococo-native")]
"rococo-dev" => Box::new(service::chain_spec::rococo_development_config()?),
Expand Down Expand Up @@ -145,7 +133,7 @@ impl SubstrateCli for Cli {
path => {
let path = std::path::PathBuf::from(path);

let chain_spec = Box::new(service::PolkadotChainSpec::from_json_file(path.clone())?)
let chain_spec = Box::new(service::GenericChainSpec::from_json_file(path.clone())?)
as Box<dyn service::ChainSpec>;

// When `force_*` is given or the file name starts with the name of one of the known
Expand All @@ -157,7 +145,7 @@ impl SubstrateCli for Cli {
{
Box::new(service::RococoChainSpec::from_json_file(path)?)
} else if self.run.force_kusama || chain_spec.is_kusama() {
Box::new(service::KusamaChainSpec::from_json_file(path)?)
Box::new(service::GenericChainSpec::from_json_file(path)?)
} else if self.run.force_westend || chain_spec.is_westend() {
Box::new(service::WestendChainSpec::from_json_file(path)?)
} else {
Expand All @@ -181,17 +169,6 @@ fn set_default_ss58_version(spec: &Box<dyn service::ChainSpec>) {
sp_core::crypto::set_default_ss58_version(ss58_version);
}

const DEV_ONLY_ERROR_PATTERN: &'static str =
"can only use subcommand with --chain [polkadot-dev, kusama-dev, westend-dev, rococo-dev, wococo-dev], got ";

fn ensure_dev(spec: &Box<dyn service::ChainSpec>) -> std::result::Result<(), String> {
if spec.is_dev() {
Ok(())
} else {
Err(format!("{}{}", DEV_ONLY_ERROR_PATTERN, spec.id()))
}
}

/// Runs performance checks.
/// Should only be used in release build since the check would take too much time otherwise.
fn host_perf_check() -> Result<()> {
Expand Down Expand Up @@ -455,8 +432,7 @@ pub fn run() -> Result<()> {
cmd.run(client.clone()).map_err(Error::SubstrateCli)
}),
// These commands are very similar and can be handled in nearly the same way.
BenchmarkCmd::Extrinsic(_) | BenchmarkCmd::Overhead(_) => {
ensure_dev(chain_spec).map_err(Error::Other)?;
BenchmarkCmd::Extrinsic(_) | BenchmarkCmd::Overhead(_) =>
runner.sync_run(|mut config| {
let (client, _, _, _) = service::new_chain_ops(&mut config, None)?;
let header = client.header(client.info().genesis_hash).unwrap().unwrap();
Expand Down Expand Up @@ -492,11 +468,9 @@ pub fn run() -> Result<()> {
.map_err(Error::SubstrateCli),
_ => unreachable!("Ensured by the outside match; qed"),
}
})
},
}),
BenchmarkCmd::Pallet(cmd) => {
set_default_ss58_version(chain_spec);
ensure_dev(chain_spec).map_err(Error::Other)?;

if cfg!(feature = "runtime-benchmarks") {
runner.sync_run(|config| {
Expand Down Expand Up @@ -543,48 +517,15 @@ pub fn run() -> Result<()> {
let task_manager = TaskManager::new(runner.config().tokio_handle.clone(), *registry)
.map_err(|e| Error::SubstrateService(sc_service::Error::Prometheus(e)))?;

ensure_dev(chain_spec).map_err(Error::Other)?;

#[cfg(feature = "kusama-native")]
if chain_spec.is_kusama() {
return runner.async_run(|_| {
Ok((
cmd.run::<service::kusama_runtime::Block, sp_io::SubstrateHostFunctions, _>(
Some(timestamp_with_babe_info(service::kusama_runtime_constants::time::MILLISECS_PER_BLOCK))
)
.map_err(Error::SubstrateCli),
task_manager,
))
})
}

#[cfg(feature = "westend-native")]
if chain_spec.is_westend() {
return runner.async_run(|_| {
Ok((
cmd.run::<service::westend_runtime::Block, sp_io::SubstrateHostFunctions, _>(
Some(timestamp_with_babe_info(service::westend_runtime_constants::time::MILLISECS_PER_BLOCK))
)
.map_err(Error::SubstrateCli),
task_manager,
))
})
}
// else we assume it is polkadot.
#[cfg(feature = "polkadot-native")]
{
return runner.async_run(|_| {
Ok((
cmd.run::<service::polkadot_runtime::Block, sp_io::SubstrateHostFunctions, _>(
Some(timestamp_with_babe_info(service::polkadot_runtime_constants::time::MILLISECS_PER_BLOCK))
)
.map_err(Error::SubstrateCli),
task_manager,
runner.async_run(|_| {
Ok((
cmd.run::<service::Block, sp_io::SubstrateHostFunctions, _>(Some(
timestamp_with_babe_info(MILLISECS_PER_BLOCK),
))
})
}
#[cfg(not(feature = "polkadot-native"))]
panic!("No runtime feature (polkadot, kusama, westend, rococo) is enabled")
.map_err(Error::SubstrateCli),
task_manager,
))
})
},
#[cfg(not(feature = "try-runtime"))]
Some(Subcommand::TryRuntime) => Err(Error::Other(
Expand Down
6 changes: 6 additions & 0 deletions cli/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,9 @@ pub enum Error {
#[error("This subcommand is only available when compiled with `{feature}`")]
FeatureNotEnabled { feature: &'static str },
}

impl From<String> for Error {
fn from(s: String) -> Self {
Self::Other(s)
}
}
2 changes: 1 addition & 1 deletion node/malus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ path = "../../src/bin/prepare-worker.rs"
doc = false

[dependencies]
polkadot-cli = { path = "../../cli", features = [ "malus", "rococo-native", "kusama-native", "westend-native", "polkadot-native" ] }
polkadot-cli = { path = "../../cli", features = [ "malus", "rococo-native", "westend-native" ] }
polkadot-node-subsystem = { path = "../subsystem" }
polkadot-node-subsystem-util = { path = "../subsystem-util" }
polkadot-node-subsystem-types = { path = "../subsystem-types" }
Expand Down
19 changes: 1 addition & 18 deletions node/service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,12 @@ polkadot-node-subsystem-util = { path = "../subsystem-util" }
polkadot-node-subsystem-types = { path = "../subsystem-types" }
polkadot-runtime-parachains = { path = "../../runtime/parachains" }
polkadot-node-network-protocol = { path = "../network/protocol" }
polkadot-runtime-common = { path = "../../runtime/common" }

# Polkadot Runtime Constants
polkadot-runtime-constants = { path = "../../runtime/polkadot/constants", optional = true }
kusama-runtime-constants = { path = "../../runtime/kusama/constants", optional = true }
rococo-runtime-constants = { path = "../../runtime/rococo/constants", optional = true }
westend-runtime-constants = { path = "../../runtime/westend/constants", optional = true }

# Polkadot Runtimes
polkadot-runtime = { path = "../../runtime/polkadot", optional = true }
kusama-runtime = { path = "../../runtime/kusama", optional = true }
westend-runtime = { path = "../../runtime/westend", optional = true }
rococo-runtime = { path = "../../runtime/rococo", optional = true }

Expand Down Expand Up @@ -184,31 +179,21 @@ full-node = [
"parity-db",
]

# Configure the native runtimes to use. Polkadot is enabled by default.
#
# Validators require the native runtime currently
polkadot-native = [ "polkadot-runtime", "polkadot-runtime-constants" ]
kusama-native = [ "kusama-runtime", "kusama-runtime-constants" ]
# Configure the native runtimes to use.
westend-native = [ "westend-runtime", "westend-runtime-constants" ]
rococo-native = [ "rococo-runtime", "rococo-runtime-constants" ]

runtime-benchmarks = [
"polkadot-runtime?/runtime-benchmarks",
"kusama-runtime?/runtime-benchmarks",
"westend-runtime?/runtime-benchmarks",
"rococo-runtime?/runtime-benchmarks",

"service/runtime-benchmarks",
]
try-runtime = [
"polkadot-runtime?/try-runtime",
"kusama-runtime?/try-runtime",
"westend-runtime?/try-runtime",
"rococo-runtime?/try-runtime",
]
fast-runtime = [
"polkadot-runtime?/fast-runtime",
"kusama-runtime?/fast-runtime",
"westend-runtime?/fast-runtime",
"rococo-runtime?/fast-runtime",
]
Expand All @@ -217,7 +202,5 @@ malus = ["full-node"]
runtime-metrics = [
"rococo-runtime?/runtime-metrics",
"westend-runtime?/runtime-metrics",
"kusama-runtime?/runtime-metrics",
"polkadot-runtime?/runtime-metrics",
"polkadot-runtime-parachains/runtime-metrics"
]
Loading