Skip to content

Commit

Permalink
Remove Polkadot & Kusama native runtime (#1304)
Browse files Browse the repository at this point in the history
This pull request removes the Polkadot and Kusama native runtime from
the polkadot node. This brings some implications with it:

There are no more kusama/polkadot-dev chain specs available. We will
need to write some tooling in the fellowship repo to provide them
easily.

The try-runtime job for polkadot & kusama is not available anymore as we
don't have the dev chain specs anymore.

Certain benchmarking commands will also not work until we migrate them
to use a runtime api.

Some crates in utils are still depending on the polkadot/kusama native
runtime that will also need to be fixed.

Port of: paritytech/polkadot#7467
  • Loading branch information
bkchr committed Sep 19, 2023
1 parent 122086d commit 6079b6d
Show file tree
Hide file tree
Showing 19 changed files with 193 additions and 1,056 deletions.
14 changes: 2 additions & 12 deletions .gitlab/pipeline/short-benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

# run short-benchmarks for relay chain runtimes from polkadot

short-benchmark-polkadot: &short-bench
short-benchmark-westend: &short-bench
stage: short-benchmarks
extends:
- .docker-env
Expand All @@ -14,22 +14,12 @@ short-benchmark-polkadot: &short-bench
- job: build-short-benchmark
artifacts: true
variables:
RUNTIME: polkadot
RUNTIME: westend
tags:
- benchmark
script:
- ./artifacts/polkadot benchmark pallet --chain $RUNTIME-dev --pallet "*" --extrinsic "*" --steps 2 --repeat 1

short-benchmark-kusama:
<<: *short-bench
variables:
RUNTIME: kusama

short-benchmark-westend:
<<: *short-bench
variables:
RUNTIME: westend

# run short-benchmarks for system parachain runtimes from cumulus

.short-benchmark-cumulus: &short-bench-cumulus
Expand Down
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.

6 changes: 1 addition & 5 deletions polkadot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,7 @@ color-eyre = { version = "0.6.1", default-features = false }
tikv-jemallocator = { version = "0.5.0", optional = true }

# Crates in our workspace, defined as dependencies so we can pass them feature flags.
polkadot-cli = { path = "cli", features = [
"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 polkadot/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,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
47 changes: 9 additions & 38 deletions polkadot/cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,6 @@ 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>;

fn get_exec_name() -> Option<String> {
Expand Down Expand Up @@ -92,29 +86,20 @@ 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()?),
"dev" | "rococo-dev" => Box::new(service::chain_spec::rococo_development_config()?),
#[cfg(feature = "rococo-native")]
"rococo-local" => Box::new(service::chain_spec::rococo_local_testnet_config()?),
#[cfg(feature = "rococo-native")]
"rococo-staging" => Box::new(service::chain_spec::rococo_staging_testnet_config()?),
#[cfg(not(feature = "rococo-native"))]
name if name.starts_with("rococo-") && !name.ends_with(".json") =>
name if name.starts_with("rococo-") && !name.ends_with(".json") || name == "dev" =>
Err(format!("`{}` only supported with `rococo-native` feature enabled.", name))?,
"westend" => Box::new(service::chain_spec::westend_config()?),
#[cfg(feature = "westend-native")]
Expand Down Expand Up @@ -146,7 +131,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 @@ -158,7 +143,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 @@ -182,17 +167,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 @@ -471,8 +445,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 @@ -508,11 +481,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
6 changes: 6 additions & 0 deletions polkadot/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 polkadot/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
21 changes: 1 addition & 20 deletions polkadot/node/service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,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 = { package = "staging-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 @@ -183,11 +178,7 @@ full-node = [
"polkadot-statement-distribution",
]

# 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" ]

Expand All @@ -196,15 +187,12 @@ runtime-benchmarks = [
"frame-benchmarking/runtime-benchmarks",
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"kusama-runtime?/runtime-benchmarks",
"pallet-babe/runtime-benchmarks",
"pallet-im-online/runtime-benchmarks",
"pallet-staking/runtime-benchmarks",
"polkadot-parachain-primitives/runtime-benchmarks",
"polkadot-primitives/runtime-benchmarks",
"polkadot-runtime-common/runtime-benchmarks",
"polkadot-runtime-parachains/runtime-benchmarks",
"polkadot-runtime?/runtime-benchmarks",
"polkadot-test-client/runtime-benchmarks",
"rococo-runtime?/runtime-benchmarks",
"sc-client-db/runtime-benchmarks",
Expand All @@ -215,30 +203,23 @@ runtime-benchmarks = [
try-runtime = [
"frame-support/try-runtime",
"frame-system/try-runtime",
"kusama-runtime?/try-runtime",
"pallet-babe/try-runtime",
"pallet-im-online/try-runtime",
"pallet-staking/try-runtime",
"pallet-transaction-payment/try-runtime",
"polkadot-runtime-common/try-runtime",
"polkadot-runtime-parachains/try-runtime",
"polkadot-runtime?/try-runtime",
"rococo-runtime?/try-runtime",
"sp-runtime/try-runtime",
"westend-runtime?/try-runtime",
]
fast-runtime = [
"kusama-runtime?/fast-runtime",
"polkadot-runtime?/fast-runtime",
"rococo-runtime?/fast-runtime",
"westend-runtime?/fast-runtime",
]

malus = [ "full-node" ]
runtime-metrics = [
"kusama-runtime?/runtime-metrics",
"polkadot-runtime-parachains/runtime-metrics",
"polkadot-runtime?/runtime-metrics",
"rococo-runtime?/runtime-metrics",
"westend-runtime?/runtime-metrics",
]
Expand Down
Loading

0 comments on commit 6079b6d

Please sign in to comment.