mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-22 14:55:41 +00:00
Remove Polkadot & Kusama native runtime (#1304)
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: https://github.com/paritytech/polkadot/pull/7467
This commit is contained in:
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
# run short-benchmarks for relay chain runtimes from polkadot
|
# run short-benchmarks for relay chain runtimes from polkadot
|
||||||
|
|
||||||
short-benchmark-polkadot: &short-bench
|
short-benchmark-westend: &short-bench
|
||||||
stage: short-benchmarks
|
stage: short-benchmarks
|
||||||
extends:
|
extends:
|
||||||
- .docker-env
|
- .docker-env
|
||||||
@@ -14,22 +14,12 @@ short-benchmark-polkadot: &short-bench
|
|||||||
- job: build-short-benchmark
|
- job: build-short-benchmark
|
||||||
artifacts: true
|
artifacts: true
|
||||||
variables:
|
variables:
|
||||||
RUNTIME: polkadot
|
RUNTIME: westend
|
||||||
tags:
|
tags:
|
||||||
- benchmark
|
- benchmark
|
||||||
script:
|
script:
|
||||||
- ./artifacts/polkadot benchmark pallet --chain $RUNTIME-dev --pallet "*" --extrinsic "*" --steps 2 --repeat 1
|
- ./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
|
# run short-benchmarks for system parachain runtimes from cumulus
|
||||||
|
|
||||||
.short-benchmark-cumulus: &short-bench-cumulus
|
.short-benchmark-cumulus: &short-bench-cumulus
|
||||||
|
|||||||
Generated
-5
@@ -12779,7 +12779,6 @@ dependencies = [
|
|||||||
"futures",
|
"futures",
|
||||||
"hex-literal",
|
"hex-literal",
|
||||||
"is_executable",
|
"is_executable",
|
||||||
"kusama-runtime-constants",
|
|
||||||
"kvdb",
|
"kvdb",
|
||||||
"kvdb-rocksdb",
|
"kvdb-rocksdb",
|
||||||
"log",
|
"log",
|
||||||
@@ -12825,9 +12824,6 @@ dependencies = [
|
|||||||
"polkadot-parachain-primitives",
|
"polkadot-parachain-primitives",
|
||||||
"polkadot-primitives",
|
"polkadot-primitives",
|
||||||
"polkadot-rpc",
|
"polkadot-rpc",
|
||||||
"polkadot-runtime",
|
|
||||||
"polkadot-runtime-common",
|
|
||||||
"polkadot-runtime-constants",
|
|
||||||
"polkadot-runtime-parachains",
|
"polkadot-runtime-parachains",
|
||||||
"polkadot-statement-distribution",
|
"polkadot-statement-distribution",
|
||||||
"polkadot-test-client",
|
"polkadot-test-client",
|
||||||
@@ -12883,7 +12879,6 @@ dependencies = [
|
|||||||
"sp-transaction-pool",
|
"sp-transaction-pool",
|
||||||
"sp-version",
|
"sp-version",
|
||||||
"sp-weights",
|
"sp-weights",
|
||||||
"staging-kusama-runtime",
|
|
||||||
"substrate-prometheus-endpoint",
|
"substrate-prometheus-endpoint",
|
||||||
"tempfile",
|
"tempfile",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
|
|||||||
+1
-5
@@ -26,11 +26,7 @@ color-eyre = { version = "0.6.1", default-features = false }
|
|||||||
tikv-jemallocator = { version = "0.5.0", optional = true }
|
tikv-jemallocator = { version = "0.5.0", optional = true }
|
||||||
|
|
||||||
# Crates in our workspace, defined as dependencies so we can pass them feature flags.
|
# Crates in our workspace, defined as dependencies so we can pass them feature flags.
|
||||||
polkadot-cli = { path = "cli", features = [
|
polkadot-cli = { path = "cli", features = [ "westend-native", "rococo-native" ] }
|
||||||
"kusama-native",
|
|
||||||
"westend-native",
|
|
||||||
"rococo-native",
|
|
||||||
] }
|
|
||||||
polkadot-node-core-pvf = { path = "node/core/pvf" }
|
polkadot-node-core-pvf = { path = "node/core/pvf" }
|
||||||
polkadot-node-core-pvf-prepare-worker = { path = "node/core/pvf/prepare-worker" }
|
polkadot-node-core-pvf-prepare-worker = { path = "node/core/pvf/prepare-worker" }
|
||||||
polkadot-overseer = { path = "node/overseer" }
|
polkadot-overseer = { path = "node/overseer" }
|
||||||
|
|||||||
@@ -67,11 +67,7 @@ fast-runtime = [ "service/fast-runtime" ]
|
|||||||
pyroscope = [ "pyro", "pyroscope_pprofrs" ]
|
pyroscope = [ "pyro", "pyroscope_pprofrs" ]
|
||||||
hostperfcheck = [ "polkadot-performance-test" ]
|
hostperfcheck = [ "polkadot-performance-test" ]
|
||||||
|
|
||||||
# Configure the native runtimes to use. Polkadot is enabled by default.
|
# Configure the native runtimes to use.
|
||||||
#
|
|
||||||
# Validators require the native runtime currently
|
|
||||||
polkadot-native = [ "service/polkadot-native" ]
|
|
||||||
kusama-native = [ "service/kusama-native" ]
|
|
||||||
westend-native = [ "service/westend-native" ]
|
westend-native = [ "service/westend-native" ]
|
||||||
rococo-native = [ "service/rococo-native" ]
|
rococo-native = [ "service/rococo-native" ]
|
||||||
|
|
||||||
|
|||||||
@@ -34,12 +34,6 @@ pub use polkadot_performance_test::PerfCheckError;
|
|||||||
#[cfg(feature = "pyroscope")]
|
#[cfg(feature = "pyroscope")]
|
||||||
use pyroscope_pprofrs::{pprof_backend, PprofConfig};
|
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>;
|
type Result<T> = std::result::Result<T, Error>;
|
||||||
|
|
||||||
fn get_exec_name() -> Option<String> {
|
fn get_exec_name() -> Option<String> {
|
||||||
@@ -92,29 +86,20 @@ impl SubstrateCli for Cli {
|
|||||||
};
|
};
|
||||||
Ok(match id {
|
Ok(match id {
|
||||||
"kusama" => Box::new(service::chain_spec::kusama_config()?),
|
"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") =>
|
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()?),
|
"polkadot" => Box::new(service::chain_spec::polkadot_config()?),
|
||||||
#[cfg(feature = "polkadot-native")]
|
name if name.starts_with("polkadot-") && !name.ends_with(".json") =>
|
||||||
"polkadot-dev" | "dev" => Box::new(service::chain_spec::polkadot_development_config()?),
|
Err(format!("`{name}` is not supported anymore as the polkadot native runtime no longer part of the node."))?,
|
||||||
#[cfg(feature = "polkadot-native")]
|
|
||||||
"polkadot-local" => Box::new(service::chain_spec::polkadot_local_testnet_config()?),
|
|
||||||
"rococo" => Box::new(service::chain_spec::rococo_config()?),
|
"rococo" => Box::new(service::chain_spec::rococo_config()?),
|
||||||
#[cfg(feature = "rococo-native")]
|
#[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")]
|
#[cfg(feature = "rococo-native")]
|
||||||
"rococo-local" => Box::new(service::chain_spec::rococo_local_testnet_config()?),
|
"rococo-local" => Box::new(service::chain_spec::rococo_local_testnet_config()?),
|
||||||
#[cfg(feature = "rococo-native")]
|
#[cfg(feature = "rococo-native")]
|
||||||
"rococo-staging" => Box::new(service::chain_spec::rococo_staging_testnet_config()?),
|
"rococo-staging" => Box::new(service::chain_spec::rococo_staging_testnet_config()?),
|
||||||
#[cfg(not(feature = "rococo-native"))]
|
#[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))?,
|
Err(format!("`{}` only supported with `rococo-native` feature enabled.", name))?,
|
||||||
"westend" => Box::new(service::chain_spec::westend_config()?),
|
"westend" => Box::new(service::chain_spec::westend_config()?),
|
||||||
#[cfg(feature = "westend-native")]
|
#[cfg(feature = "westend-native")]
|
||||||
@@ -146,7 +131,7 @@ impl SubstrateCli for Cli {
|
|||||||
path => {
|
path => {
|
||||||
let path = std::path::PathBuf::from(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>;
|
as Box<dyn service::ChainSpec>;
|
||||||
|
|
||||||
// When `force_*` is given or the file name starts with the name of one of the known
|
// When `force_*` is given or the file name starts with the name of one of the known
|
||||||
@@ -158,7 +143,7 @@ impl SubstrateCli for Cli {
|
|||||||
{
|
{
|
||||||
Box::new(service::RococoChainSpec::from_json_file(path)?)
|
Box::new(service::RococoChainSpec::from_json_file(path)?)
|
||||||
} else if self.run.force_kusama || chain_spec.is_kusama() {
|
} 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() {
|
} else if self.run.force_westend || chain_spec.is_westend() {
|
||||||
Box::new(service::WestendChainSpec::from_json_file(path)?)
|
Box::new(service::WestendChainSpec::from_json_file(path)?)
|
||||||
} else {
|
} else {
|
||||||
@@ -182,17 +167,6 @@ fn set_default_ss58_version(spec: &Box<dyn service::ChainSpec>) {
|
|||||||
sp_core::crypto::set_default_ss58_version(ss58_version);
|
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.
|
/// Runs performance checks.
|
||||||
/// Should only be used in release build since the check would take too much time otherwise.
|
/// Should only be used in release build since the check would take too much time otherwise.
|
||||||
fn host_perf_check() -> Result<()> {
|
fn host_perf_check() -> Result<()> {
|
||||||
@@ -471,8 +445,7 @@ pub fn run() -> Result<()> {
|
|||||||
cmd.run(client.clone()).map_err(Error::SubstrateCli)
|
cmd.run(client.clone()).map_err(Error::SubstrateCli)
|
||||||
}),
|
}),
|
||||||
// These commands are very similar and can be handled in nearly the same way.
|
// These commands are very similar and can be handled in nearly the same way.
|
||||||
BenchmarkCmd::Extrinsic(_) | BenchmarkCmd::Overhead(_) => {
|
BenchmarkCmd::Extrinsic(_) | BenchmarkCmd::Overhead(_) =>
|
||||||
ensure_dev(chain_spec).map_err(Error::Other)?;
|
|
||||||
runner.sync_run(|mut config| {
|
runner.sync_run(|mut config| {
|
||||||
let (client, _, _, _) = service::new_chain_ops(&mut config, None)?;
|
let (client, _, _, _) = service::new_chain_ops(&mut config, None)?;
|
||||||
let header = client.header(client.info().genesis_hash).unwrap().unwrap();
|
let header = client.header(client.info().genesis_hash).unwrap().unwrap();
|
||||||
@@ -508,11 +481,9 @@ pub fn run() -> Result<()> {
|
|||||||
.map_err(Error::SubstrateCli),
|
.map_err(Error::SubstrateCli),
|
||||||
_ => unreachable!("Ensured by the outside match; qed"),
|
_ => unreachable!("Ensured by the outside match; qed"),
|
||||||
}
|
}
|
||||||
})
|
}),
|
||||||
},
|
|
||||||
BenchmarkCmd::Pallet(cmd) => {
|
BenchmarkCmd::Pallet(cmd) => {
|
||||||
set_default_ss58_version(chain_spec);
|
set_default_ss58_version(chain_spec);
|
||||||
ensure_dev(chain_spec).map_err(Error::Other)?;
|
|
||||||
|
|
||||||
if cfg!(feature = "runtime-benchmarks") {
|
if cfg!(feature = "runtime-benchmarks") {
|
||||||
runner.sync_run(|config| {
|
runner.sync_run(|config| {
|
||||||
|
|||||||
@@ -58,3 +58,9 @@ pub enum Error {
|
|||||||
#[error("This subcommand is only available when compiled with `{feature}`")]
|
#[error("This subcommand is only available when compiled with `{feature}`")]
|
||||||
FeatureNotEnabled { feature: &'static str },
|
FeatureNotEnabled { feature: &'static str },
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<String> for Error {
|
||||||
|
fn from(s: String) -> Self {
|
||||||
|
Self::Other(s)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ path = "../../src/bin/prepare-worker.rs"
|
|||||||
doc = false
|
doc = false
|
||||||
|
|
||||||
[dependencies]
|
[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 = { path = "../subsystem" }
|
||||||
polkadot-node-subsystem-util = { path = "../subsystem-util" }
|
polkadot-node-subsystem-util = { path = "../subsystem-util" }
|
||||||
polkadot-node-subsystem-types = { path = "../subsystem-types" }
|
polkadot-node-subsystem-types = { path = "../subsystem-types" }
|
||||||
|
|||||||
@@ -103,17 +103,12 @@ polkadot-node-subsystem-util = { path = "../subsystem-util" }
|
|||||||
polkadot-node-subsystem-types = { path = "../subsystem-types" }
|
polkadot-node-subsystem-types = { path = "../subsystem-types" }
|
||||||
polkadot-runtime-parachains = { path = "../../runtime/parachains" }
|
polkadot-runtime-parachains = { path = "../../runtime/parachains" }
|
||||||
polkadot-node-network-protocol = { path = "../network/protocol" }
|
polkadot-node-network-protocol = { path = "../network/protocol" }
|
||||||
polkadot-runtime-common = { path = "../../runtime/common" }
|
|
||||||
|
|
||||||
# Polkadot Runtime Constants
|
# 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 }
|
rococo-runtime-constants = { path = "../../runtime/rococo/constants", optional = true }
|
||||||
westend-runtime-constants = { path = "../../runtime/westend/constants", optional = true }
|
westend-runtime-constants = { path = "../../runtime/westend/constants", optional = true }
|
||||||
|
|
||||||
# Polkadot Runtimes
|
# 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 }
|
westend-runtime = { path = "../../runtime/westend", optional = true }
|
||||||
rococo-runtime = { path = "../../runtime/rococo", optional = true }
|
rococo-runtime = { path = "../../runtime/rococo", optional = true }
|
||||||
|
|
||||||
@@ -183,11 +178,7 @@ full-node = [
|
|||||||
"polkadot-statement-distribution",
|
"polkadot-statement-distribution",
|
||||||
]
|
]
|
||||||
|
|
||||||
# Configure the native runtimes to use. Polkadot is enabled by default.
|
# Configure the native runtimes to use.
|
||||||
#
|
|
||||||
# Validators require the native runtime currently
|
|
||||||
polkadot-native = [ "polkadot-runtime", "polkadot-runtime-constants" ]
|
|
||||||
kusama-native = [ "kusama-runtime", "kusama-runtime-constants" ]
|
|
||||||
westend-native = [ "westend-runtime", "westend-runtime-constants" ]
|
westend-native = [ "westend-runtime", "westend-runtime-constants" ]
|
||||||
rococo-native = [ "rococo-runtime", "rococo-runtime-constants" ]
|
rococo-native = [ "rococo-runtime", "rococo-runtime-constants" ]
|
||||||
|
|
||||||
@@ -196,15 +187,12 @@ runtime-benchmarks = [
|
|||||||
"frame-benchmarking/runtime-benchmarks",
|
"frame-benchmarking/runtime-benchmarks",
|
||||||
"frame-support/runtime-benchmarks",
|
"frame-support/runtime-benchmarks",
|
||||||
"frame-system/runtime-benchmarks",
|
"frame-system/runtime-benchmarks",
|
||||||
"kusama-runtime?/runtime-benchmarks",
|
|
||||||
"pallet-babe/runtime-benchmarks",
|
"pallet-babe/runtime-benchmarks",
|
||||||
"pallet-im-online/runtime-benchmarks",
|
"pallet-im-online/runtime-benchmarks",
|
||||||
"pallet-staking/runtime-benchmarks",
|
"pallet-staking/runtime-benchmarks",
|
||||||
"polkadot-parachain-primitives/runtime-benchmarks",
|
"polkadot-parachain-primitives/runtime-benchmarks",
|
||||||
"polkadot-primitives/runtime-benchmarks",
|
"polkadot-primitives/runtime-benchmarks",
|
||||||
"polkadot-runtime-common/runtime-benchmarks",
|
|
||||||
"polkadot-runtime-parachains/runtime-benchmarks",
|
"polkadot-runtime-parachains/runtime-benchmarks",
|
||||||
"polkadot-runtime?/runtime-benchmarks",
|
|
||||||
"polkadot-test-client/runtime-benchmarks",
|
"polkadot-test-client/runtime-benchmarks",
|
||||||
"rococo-runtime?/runtime-benchmarks",
|
"rococo-runtime?/runtime-benchmarks",
|
||||||
"sc-client-db/runtime-benchmarks",
|
"sc-client-db/runtime-benchmarks",
|
||||||
@@ -215,30 +203,23 @@ runtime-benchmarks = [
|
|||||||
try-runtime = [
|
try-runtime = [
|
||||||
"frame-support/try-runtime",
|
"frame-support/try-runtime",
|
||||||
"frame-system/try-runtime",
|
"frame-system/try-runtime",
|
||||||
"kusama-runtime?/try-runtime",
|
|
||||||
"pallet-babe/try-runtime",
|
"pallet-babe/try-runtime",
|
||||||
"pallet-im-online/try-runtime",
|
"pallet-im-online/try-runtime",
|
||||||
"pallet-staking/try-runtime",
|
"pallet-staking/try-runtime",
|
||||||
"pallet-transaction-payment/try-runtime",
|
"pallet-transaction-payment/try-runtime",
|
||||||
"polkadot-runtime-common/try-runtime",
|
|
||||||
"polkadot-runtime-parachains/try-runtime",
|
"polkadot-runtime-parachains/try-runtime",
|
||||||
"polkadot-runtime?/try-runtime",
|
|
||||||
"rococo-runtime?/try-runtime",
|
"rococo-runtime?/try-runtime",
|
||||||
"sp-runtime/try-runtime",
|
"sp-runtime/try-runtime",
|
||||||
"westend-runtime?/try-runtime",
|
"westend-runtime?/try-runtime",
|
||||||
]
|
]
|
||||||
fast-runtime = [
|
fast-runtime = [
|
||||||
"kusama-runtime?/fast-runtime",
|
|
||||||
"polkadot-runtime?/fast-runtime",
|
|
||||||
"rococo-runtime?/fast-runtime",
|
"rococo-runtime?/fast-runtime",
|
||||||
"westend-runtime?/fast-runtime",
|
"westend-runtime?/fast-runtime",
|
||||||
]
|
]
|
||||||
|
|
||||||
malus = [ "full-node" ]
|
malus = [ "full-node" ]
|
||||||
runtime-metrics = [
|
runtime-metrics = [
|
||||||
"kusama-runtime?/runtime-metrics",
|
|
||||||
"polkadot-runtime-parachains/runtime-metrics",
|
"polkadot-runtime-parachains/runtime-metrics",
|
||||||
"polkadot-runtime?/runtime-metrics",
|
|
||||||
"rococo-runtime?/runtime-metrics",
|
"rococo-runtime?/runtime-metrics",
|
||||||
"westend-runtime?/runtime-metrics",
|
"westend-runtime?/runtime-metrics",
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -34,36 +34,8 @@ macro_rules! identify_chain {
|
|||||||
$generic_code:expr $(,)*
|
$generic_code:expr $(,)*
|
||||||
) => {
|
) => {
|
||||||
match $chain {
|
match $chain {
|
||||||
Chain::Polkadot => {
|
Chain::Polkadot => Err("Polkadot runtimes are currently not supported"),
|
||||||
#[cfg(feature = "polkadot-native")]
|
Chain::Kusama => Err("Kusama runtimes are currently not supported"),
|
||||||
{
|
|
||||||
use polkadot_runtime as runtime;
|
|
||||||
|
|
||||||
let call = $generic_code;
|
|
||||||
|
|
||||||
Ok(polkadot_sign_call(call, $nonce, $current_block, $period, $genesis, $signer))
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(not(feature = "polkadot-native"))]
|
|
||||||
{
|
|
||||||
Err("`polkadot-native` feature not enabled")
|
|
||||||
}
|
|
||||||
},
|
|
||||||
Chain::Kusama => {
|
|
||||||
#[cfg(feature = "kusama-native")]
|
|
||||||
{
|
|
||||||
use kusama_runtime as runtime;
|
|
||||||
|
|
||||||
let call = $generic_code;
|
|
||||||
|
|
||||||
Ok(kusama_sign_call(call, $nonce, $current_block, $period, $genesis, $signer))
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(not(feature = "kusama-native"))]
|
|
||||||
{
|
|
||||||
Err("`kusama-native` feature not enabled")
|
|
||||||
}
|
|
||||||
},
|
|
||||||
Chain::Rococo => {
|
Chain::Rococo => {
|
||||||
#[cfg(feature = "rococo-native")]
|
#[cfg(feature = "rococo-native")]
|
||||||
{
|
{
|
||||||
@@ -91,16 +63,18 @@ macro_rules! identify_chain {
|
|||||||
|
|
||||||
#[cfg(not(feature = "westend-native"))]
|
#[cfg(not(feature = "westend-native"))]
|
||||||
{
|
{
|
||||||
let _ = $nonce;
|
|
||||||
let _ = $current_block;
|
|
||||||
let _ = $period;
|
|
||||||
let _ = $genesis;
|
|
||||||
let _ = $signer;
|
|
||||||
|
|
||||||
Err("`westend-native` feature not enabled")
|
Err("`westend-native` feature not enabled")
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Chain::Unknown => Err("Unknown chain"),
|
Chain::Unknown => {
|
||||||
|
let _ = $nonce;
|
||||||
|
let _ = $current_block;
|
||||||
|
let _ = $period;
|
||||||
|
let _ = $genesis;
|
||||||
|
let _ = $signer;
|
||||||
|
|
||||||
|
Err("Unknown chain")
|
||||||
|
},
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -130,10 +104,8 @@ impl frame_benchmarking_cli::ExtrinsicBuilder for RemarkBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn build(&self, nonce: u32) -> std::result::Result<OpaqueExtrinsic, &'static str> {
|
fn build(&self, nonce: u32) -> std::result::Result<OpaqueExtrinsic, &'static str> {
|
||||||
let period = polkadot_runtime_common::BlockHashCount::get()
|
// We apply the extrinsic directly, so let's take some random period.
|
||||||
.checked_next_power_of_two()
|
let period = 128;
|
||||||
.map(|c| c / 2)
|
|
||||||
.unwrap_or(2) as u64;
|
|
||||||
let genesis = self.client.usage_info().chain.best_hash;
|
let genesis = self.client.usage_info().chain.best_hash;
|
||||||
let signer = Sr25519Keyring::Bob.pair();
|
let signer = Sr25519Keyring::Bob.pair();
|
||||||
let current_block = 0;
|
let current_block = 0;
|
||||||
@@ -181,10 +153,8 @@ impl frame_benchmarking_cli::ExtrinsicBuilder for TransferKeepAliveBuilder {
|
|||||||
|
|
||||||
fn build(&self, nonce: u32) -> std::result::Result<OpaqueExtrinsic, &'static str> {
|
fn build(&self, nonce: u32) -> std::result::Result<OpaqueExtrinsic, &'static str> {
|
||||||
let signer = Sr25519Keyring::Bob.pair();
|
let signer = Sr25519Keyring::Bob.pair();
|
||||||
let period = polkadot_runtime_common::BlockHashCount::get()
|
// We apply the extrinsic directly, so let's take some random period.
|
||||||
.checked_next_power_of_two()
|
let period = 128;
|
||||||
.map(|c| c / 2)
|
|
||||||
.unwrap_or(2) as u64;
|
|
||||||
let genesis = self.client.usage_info().chain.best_hash;
|
let genesis = self.client.usage_info().chain.best_hash;
|
||||||
let current_block = 0;
|
let current_block = 0;
|
||||||
let _dest = self.dest.clone();
|
let _dest = self.dest.clone();
|
||||||
@@ -206,60 +176,6 @@ impl frame_benchmarking_cli::ExtrinsicBuilder for TransferKeepAliveBuilder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "polkadot-native")]
|
|
||||||
fn polkadot_sign_call(
|
|
||||||
call: polkadot_runtime::RuntimeCall,
|
|
||||||
nonce: u32,
|
|
||||||
current_block: u64,
|
|
||||||
period: u64,
|
|
||||||
genesis: sp_core::H256,
|
|
||||||
acc: sp_core::sr25519::Pair,
|
|
||||||
) -> OpaqueExtrinsic {
|
|
||||||
use codec::Encode;
|
|
||||||
use polkadot_runtime as runtime;
|
|
||||||
use sp_core::Pair;
|
|
||||||
|
|
||||||
let extra: runtime::SignedExtra = (
|
|
||||||
frame_system::CheckNonZeroSender::<runtime::Runtime>::new(),
|
|
||||||
frame_system::CheckSpecVersion::<runtime::Runtime>::new(),
|
|
||||||
frame_system::CheckTxVersion::<runtime::Runtime>::new(),
|
|
||||||
frame_system::CheckGenesis::<runtime::Runtime>::new(),
|
|
||||||
frame_system::CheckMortality::<runtime::Runtime>::from(sp_runtime::generic::Era::mortal(
|
|
||||||
period,
|
|
||||||
current_block,
|
|
||||||
)),
|
|
||||||
frame_system::CheckNonce::<runtime::Runtime>::from(nonce),
|
|
||||||
frame_system::CheckWeight::<runtime::Runtime>::new(),
|
|
||||||
pallet_transaction_payment::ChargeTransactionPayment::<runtime::Runtime>::from(0),
|
|
||||||
polkadot_runtime_common::claims::PrevalidateAttests::<runtime::Runtime>::new(),
|
|
||||||
);
|
|
||||||
|
|
||||||
let payload = runtime::SignedPayload::from_raw(
|
|
||||||
call.clone(),
|
|
||||||
extra.clone(),
|
|
||||||
(
|
|
||||||
(),
|
|
||||||
runtime::VERSION.spec_version,
|
|
||||||
runtime::VERSION.transaction_version,
|
|
||||||
genesis,
|
|
||||||
genesis,
|
|
||||||
(),
|
|
||||||
(),
|
|
||||||
(),
|
|
||||||
(),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
let signature = payload.using_encoded(|p| acc.sign(p));
|
|
||||||
runtime::UncheckedExtrinsic::new_signed(
|
|
||||||
call,
|
|
||||||
sp_runtime::AccountId32::from(acc.public()).into(),
|
|
||||||
polkadot_core_primitives::Signature::Sr25519(signature.clone()),
|
|
||||||
extra,
|
|
||||||
)
|
|
||||||
.into()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "westend-native")]
|
#[cfg(feature = "westend-native")]
|
||||||
fn westend_sign_call(
|
fn westend_sign_call(
|
||||||
call: westend_runtime::RuntimeCall,
|
call: westend_runtime::RuntimeCall,
|
||||||
@@ -312,58 +228,6 @@ fn westend_sign_call(
|
|||||||
.into()
|
.into()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "kusama-native")]
|
|
||||||
fn kusama_sign_call(
|
|
||||||
call: kusama_runtime::RuntimeCall,
|
|
||||||
nonce: u32,
|
|
||||||
current_block: u64,
|
|
||||||
period: u64,
|
|
||||||
genesis: sp_core::H256,
|
|
||||||
acc: sp_core::sr25519::Pair,
|
|
||||||
) -> OpaqueExtrinsic {
|
|
||||||
use codec::Encode;
|
|
||||||
use kusama_runtime as runtime;
|
|
||||||
use sp_core::Pair;
|
|
||||||
|
|
||||||
let extra: runtime::SignedExtra = (
|
|
||||||
frame_system::CheckNonZeroSender::<runtime::Runtime>::new(),
|
|
||||||
frame_system::CheckSpecVersion::<runtime::Runtime>::new(),
|
|
||||||
frame_system::CheckTxVersion::<runtime::Runtime>::new(),
|
|
||||||
frame_system::CheckGenesis::<runtime::Runtime>::new(),
|
|
||||||
frame_system::CheckMortality::<runtime::Runtime>::from(sp_runtime::generic::Era::mortal(
|
|
||||||
period,
|
|
||||||
current_block,
|
|
||||||
)),
|
|
||||||
frame_system::CheckNonce::<runtime::Runtime>::from(nonce),
|
|
||||||
frame_system::CheckWeight::<runtime::Runtime>::new(),
|
|
||||||
pallet_transaction_payment::ChargeTransactionPayment::<runtime::Runtime>::from(0),
|
|
||||||
);
|
|
||||||
|
|
||||||
let payload = runtime::SignedPayload::from_raw(
|
|
||||||
call.clone(),
|
|
||||||
extra.clone(),
|
|
||||||
(
|
|
||||||
(),
|
|
||||||
runtime::VERSION.spec_version,
|
|
||||||
runtime::VERSION.transaction_version,
|
|
||||||
genesis,
|
|
||||||
genesis,
|
|
||||||
(),
|
|
||||||
(),
|
|
||||||
(),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
let signature = payload.using_encoded(|p| acc.sign(p));
|
|
||||||
runtime::UncheckedExtrinsic::new_signed(
|
|
||||||
call,
|
|
||||||
sp_runtime::AccountId32::from(acc.public()).into(),
|
|
||||||
polkadot_core_primitives::Signature::Sr25519(signature.clone()),
|
|
||||||
extra,
|
|
||||||
)
|
|
||||||
.into()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "rococo-native")]
|
#[cfg(feature = "rococo-native")]
|
||||||
fn rococo_sign_call(
|
fn rococo_sign_call(
|
||||||
call: rococo_runtime::RuntimeCall,
|
call: rococo_runtime::RuntimeCall,
|
||||||
|
|||||||
@@ -18,22 +18,10 @@
|
|||||||
|
|
||||||
use beefy_primitives::ecdsa_crypto::AuthorityId as BeefyId;
|
use beefy_primitives::ecdsa_crypto::AuthorityId as BeefyId;
|
||||||
use grandpa::AuthorityId as GrandpaId;
|
use grandpa::AuthorityId as GrandpaId;
|
||||||
#[cfg(feature = "kusama-native")]
|
|
||||||
use kusama_runtime as kusama;
|
|
||||||
#[cfg(feature = "kusama-native")]
|
|
||||||
use kusama_runtime_constants::currency::UNITS as KSM;
|
|
||||||
use pallet_im_online::sr25519::AuthorityId as ImOnlineId;
|
use pallet_im_online::sr25519::AuthorityId as ImOnlineId;
|
||||||
#[cfg(any(
|
#[cfg(feature = "westend-native")]
|
||||||
feature = "polkadot-native",
|
|
||||||
feature = "kusama-native",
|
|
||||||
feature = "westend-native",
|
|
||||||
))]
|
|
||||||
use pallet_staking::Forcing;
|
use pallet_staking::Forcing;
|
||||||
use polkadot_primitives::{AccountId, AccountPublic, AssignmentId, ValidatorId};
|
use polkadot_primitives::{AccountId, AccountPublic, AssignmentId, ValidatorId};
|
||||||
#[cfg(feature = "polkadot-native")]
|
|
||||||
use polkadot_runtime as polkadot;
|
|
||||||
#[cfg(feature = "polkadot-native")]
|
|
||||||
use polkadot_runtime_constants::currency::UNITS as DOT;
|
|
||||||
use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId;
|
use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId;
|
||||||
use sp_consensus_babe::AuthorityId as BabeId;
|
use sp_consensus_babe::AuthorityId as BabeId;
|
||||||
|
|
||||||
@@ -42,48 +30,27 @@ use rococo_runtime as rococo;
|
|||||||
#[cfg(feature = "rococo-native")]
|
#[cfg(feature = "rococo-native")]
|
||||||
use rococo_runtime_constants::currency::UNITS as ROC;
|
use rococo_runtime_constants::currency::UNITS as ROC;
|
||||||
use sc_chain_spec::ChainSpecExtension;
|
use sc_chain_spec::ChainSpecExtension;
|
||||||
#[cfg(any(
|
#[cfg(any(feature = "westend-native", feature = "rococo-native"))]
|
||||||
feature = "polkadot-native",
|
|
||||||
feature = "kusama-native",
|
|
||||||
feature = "westend-native",
|
|
||||||
feature = "rococo-native"
|
|
||||||
))]
|
|
||||||
use sc_chain_spec::ChainType;
|
use sc_chain_spec::ChainType;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use sp_core::{sr25519, Pair, Public};
|
use sp_core::{sr25519, Pair, Public};
|
||||||
use sp_runtime::traits::IdentifyAccount;
|
use sp_runtime::traits::IdentifyAccount;
|
||||||
#[cfg(any(
|
#[cfg(feature = "westend-native")]
|
||||||
feature = "polkadot-native",
|
|
||||||
feature = "kusama-native",
|
|
||||||
feature = "westend-native",
|
|
||||||
))]
|
|
||||||
use sp_runtime::Perbill;
|
use sp_runtime::Perbill;
|
||||||
#[cfg(any(
|
#[cfg(any(feature = "westend-native", feature = "rococo-native"))]
|
||||||
feature = "polkadot-native",
|
|
||||||
feature = "kusama-native",
|
|
||||||
feature = "westend-native",
|
|
||||||
feature = "rococo-native"
|
|
||||||
))]
|
|
||||||
use telemetry::TelemetryEndpoints;
|
use telemetry::TelemetryEndpoints;
|
||||||
#[cfg(feature = "westend-native")]
|
#[cfg(feature = "westend-native")]
|
||||||
use westend_runtime as westend;
|
use westend_runtime as westend;
|
||||||
#[cfg(feature = "westend-native")]
|
#[cfg(feature = "westend-native")]
|
||||||
use westend_runtime_constants::currency::UNITS as WND;
|
use westend_runtime_constants::currency::UNITS as WND;
|
||||||
|
|
||||||
#[cfg(feature = "kusama-native")]
|
|
||||||
const KUSAMA_STAGING_TELEMETRY_URL: &str = "wss://telemetry.polkadot.io/submit/";
|
|
||||||
#[cfg(feature = "westend-native")]
|
#[cfg(feature = "westend-native")]
|
||||||
const WESTEND_STAGING_TELEMETRY_URL: &str = "wss://telemetry.polkadot.io/submit/";
|
const WESTEND_STAGING_TELEMETRY_URL: &str = "wss://telemetry.polkadot.io/submit/";
|
||||||
#[cfg(feature = "rococo-native")]
|
#[cfg(feature = "rococo-native")]
|
||||||
const ROCOCO_STAGING_TELEMETRY_URL: &str = "wss://telemetry.polkadot.io/submit/";
|
const ROCOCO_STAGING_TELEMETRY_URL: &str = "wss://telemetry.polkadot.io/submit/";
|
||||||
#[cfg(feature = "rococo-native")]
|
#[cfg(feature = "rococo-native")]
|
||||||
const VERSI_STAGING_TELEMETRY_URL: &str = "wss://telemetry.polkadot.io/submit/";
|
const VERSI_STAGING_TELEMETRY_URL: &str = "wss://telemetry.polkadot.io/submit/";
|
||||||
#[cfg(any(
|
#[cfg(any(feature = "westend-native", feature = "rococo-native"))]
|
||||||
feature = "polkadot-native",
|
|
||||||
feature = "kusama-native",
|
|
||||||
feature = "westend-native",
|
|
||||||
feature = "rococo-native"
|
|
||||||
))]
|
|
||||||
const DEFAULT_PROTOCOL_ID: &str = "dot";
|
const DEFAULT_PROTOCOL_ID: &str = "dot";
|
||||||
|
|
||||||
/// Node `ChainSpec` extensions.
|
/// Node `ChainSpec` extensions.
|
||||||
@@ -103,25 +70,8 @@ pub struct Extensions {
|
|||||||
pub light_sync_state: sc_sync_state_rpc::LightSyncStateExtension,
|
pub light_sync_state: sc_sync_state_rpc::LightSyncStateExtension,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The `ChainSpec` parameterized for the polkadot runtime.
|
// Generic chain spec, in case when we don't have the native runtime.
|
||||||
#[cfg(feature = "polkadot-native")]
|
pub type GenericChainSpec = service::GenericChainSpec<(), Extensions>;
|
||||||
pub type PolkadotChainSpec = service::GenericChainSpec<polkadot::RuntimeGenesisConfig, Extensions>;
|
|
||||||
|
|
||||||
// Dummy chain spec, in case when we don't have the native runtime.
|
|
||||||
pub type DummyChainSpec = service::GenericChainSpec<(), Extensions>;
|
|
||||||
|
|
||||||
// Dummy chain spec, but that is fine when we don't have the native runtime.
|
|
||||||
#[cfg(not(feature = "polkadot-native"))]
|
|
||||||
pub type PolkadotChainSpec = DummyChainSpec;
|
|
||||||
|
|
||||||
/// The `ChainSpec` parameterized for the kusama runtime.
|
|
||||||
#[cfg(feature = "kusama-native")]
|
|
||||||
pub type KusamaChainSpec = service::GenericChainSpec<kusama::RuntimeGenesisConfig, Extensions>;
|
|
||||||
|
|
||||||
/// The `ChainSpec` parameterized for the kusama runtime.
|
|
||||||
// Dummy chain spec, but that is fine when we don't have the native runtime.
|
|
||||||
#[cfg(not(feature = "kusama-native"))]
|
|
||||||
pub type KusamaChainSpec = DummyChainSpec;
|
|
||||||
|
|
||||||
/// The `ChainSpec` parameterized for the westend runtime.
|
/// The `ChainSpec` parameterized for the westend runtime.
|
||||||
#[cfg(feature = "westend-native")]
|
#[cfg(feature = "westend-native")]
|
||||||
@@ -130,7 +80,7 @@ pub type WestendChainSpec = service::GenericChainSpec<westend::RuntimeGenesisCon
|
|||||||
/// The `ChainSpec` parameterized for the westend runtime.
|
/// The `ChainSpec` parameterized for the westend runtime.
|
||||||
// Dummy chain spec, but that is fine when we don't have the native runtime.
|
// Dummy chain spec, but that is fine when we don't have the native runtime.
|
||||||
#[cfg(not(feature = "westend-native"))]
|
#[cfg(not(feature = "westend-native"))]
|
||||||
pub type WestendChainSpec = DummyChainSpec;
|
pub type WestendChainSpec = GenericChainSpec;
|
||||||
|
|
||||||
/// The `ChainSpec` parameterized for the rococo runtime.
|
/// The `ChainSpec` parameterized for the rococo runtime.
|
||||||
#[cfg(feature = "rococo-native")]
|
#[cfg(feature = "rococo-native")]
|
||||||
@@ -144,7 +94,7 @@ pub type VersiChainSpec = RococoChainSpec;
|
|||||||
/// The `ChainSpec` parameterized for the rococo runtime.
|
/// The `ChainSpec` parameterized for the rococo runtime.
|
||||||
// Dummy chain spec, but that is fine when we don't have the native runtime.
|
// Dummy chain spec, but that is fine when we don't have the native runtime.
|
||||||
#[cfg(not(feature = "rococo-native"))]
|
#[cfg(not(feature = "rococo-native"))]
|
||||||
pub type RococoChainSpec = DummyChainSpec;
|
pub type RococoChainSpec = GenericChainSpec;
|
||||||
|
|
||||||
/// Extension for the Rococo genesis config to support a custom changes to the genesis state.
|
/// Extension for the Rococo genesis config to support a custom changes to the genesis state.
|
||||||
#[derive(serde::Serialize, serde::Deserialize)]
|
#[derive(serde::Serialize, serde::Deserialize)]
|
||||||
@@ -170,12 +120,12 @@ impl sp_runtime::BuildStorage for RococoGenesisExt {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn polkadot_config() -> Result<PolkadotChainSpec, String> {
|
pub fn polkadot_config() -> Result<GenericChainSpec, String> {
|
||||||
PolkadotChainSpec::from_json_bytes(&include_bytes!("../chain-specs/polkadot.json")[..])
|
GenericChainSpec::from_json_bytes(&include_bytes!("../chain-specs/polkadot.json")[..])
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn kusama_config() -> Result<KusamaChainSpec, String> {
|
pub fn kusama_config() -> Result<GenericChainSpec, String> {
|
||||||
KusamaChainSpec::from_json_bytes(&include_bytes!("../chain-specs/kusama.json")[..])
|
GenericChainSpec::from_json_bytes(&include_bytes!("../chain-specs/kusama.json")[..])
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn westend_config() -> Result<WestendChainSpec, String> {
|
pub fn westend_config() -> Result<WestendChainSpec, String> {
|
||||||
@@ -192,12 +142,7 @@ pub fn wococo_config() -> Result<RococoChainSpec, String> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// The default parachains host configuration.
|
/// The default parachains host configuration.
|
||||||
#[cfg(any(
|
#[cfg(any(feature = "rococo-native", feature = "westend-native",))]
|
||||||
feature = "rococo-native",
|
|
||||||
feature = "kusama-native",
|
|
||||||
feature = "westend-native",
|
|
||||||
feature = "polkadot-native"
|
|
||||||
))]
|
|
||||||
fn default_parachains_host_configuration(
|
fn default_parachains_host_configuration(
|
||||||
) -> polkadot_runtime_parachains::configuration::HostConfiguration<polkadot_primitives::BlockNumber>
|
) -> polkadot_runtime_parachains::configuration::HostConfiguration<polkadot_primitives::BlockNumber>
|
||||||
{
|
{
|
||||||
@@ -236,57 +181,12 @@ fn default_parachains_host_configuration(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(
|
#[cfg(any(feature = "rococo-native", feature = "westend-native",))]
|
||||||
feature = "rococo-native",
|
|
||||||
feature = "kusama-native",
|
|
||||||
feature = "westend-native",
|
|
||||||
feature = "polkadot-native"
|
|
||||||
))]
|
|
||||||
#[test]
|
#[test]
|
||||||
fn default_parachains_host_configuration_is_consistent() {
|
fn default_parachains_host_configuration_is_consistent() {
|
||||||
default_parachains_host_configuration().panic_if_not_consistent();
|
default_parachains_host_configuration().panic_if_not_consistent();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "polkadot-native")]
|
|
||||||
fn polkadot_session_keys(
|
|
||||||
babe: BabeId,
|
|
||||||
grandpa: GrandpaId,
|
|
||||||
im_online: ImOnlineId,
|
|
||||||
para_validator: ValidatorId,
|
|
||||||
para_assignment: AssignmentId,
|
|
||||||
authority_discovery: AuthorityDiscoveryId,
|
|
||||||
) -> polkadot::SessionKeys {
|
|
||||||
polkadot::SessionKeys {
|
|
||||||
babe,
|
|
||||||
grandpa,
|
|
||||||
im_online,
|
|
||||||
para_validator,
|
|
||||||
para_assignment,
|
|
||||||
authority_discovery,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "kusama-native")]
|
|
||||||
fn kusama_session_keys(
|
|
||||||
babe: BabeId,
|
|
||||||
grandpa: GrandpaId,
|
|
||||||
im_online: ImOnlineId,
|
|
||||||
para_validator: ValidatorId,
|
|
||||||
para_assignment: AssignmentId,
|
|
||||||
authority_discovery: AuthorityDiscoveryId,
|
|
||||||
beefy: BeefyId,
|
|
||||||
) -> kusama::SessionKeys {
|
|
||||||
kusama::SessionKeys {
|
|
||||||
babe,
|
|
||||||
grandpa,
|
|
||||||
im_online,
|
|
||||||
para_validator,
|
|
||||||
para_assignment,
|
|
||||||
authority_discovery,
|
|
||||||
beefy,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "westend-native")]
|
#[cfg(feature = "westend-native")]
|
||||||
fn westend_session_keys(
|
fn westend_session_keys(
|
||||||
babe: BabeId,
|
babe: BabeId,
|
||||||
@@ -539,214 +439,6 @@ fn westend_staging_testnet_config_genesis(wasm_binary: &[u8]) -> westend::Runtim
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "kusama-native")]
|
|
||||||
fn kusama_staging_testnet_config_genesis(wasm_binary: &[u8]) -> kusama::RuntimeGenesisConfig {
|
|
||||||
use hex_literal::hex;
|
|
||||||
use sp_core::crypto::UncheckedInto;
|
|
||||||
|
|
||||||
// Following keys are used in genesis config for development chains.
|
|
||||||
// DO NOT use them in production chains as the secret seed is public.
|
|
||||||
//
|
|
||||||
// SECRET_SEED="explain impose opinion genius bar parrot erupt panther surround best expire
|
|
||||||
// album" subkey inspect -n kusama "$SECRET_SEED"
|
|
||||||
let endowed_accounts = vec![
|
|
||||||
// FLN5cfhF7VCGJYefjPQJR2V6WwbfRmb9ozTwLAzBNeQQG6y
|
|
||||||
hex!["7a0fe424217ed176da7abf12e08198db0d0949298e1372c80a1930cb6dc21d3e"].into(),
|
|
||||||
];
|
|
||||||
|
|
||||||
// SECRET=$SECRET_SEED ./scripts/prepare-test-net.sh 4
|
|
||||||
let initial_authorities: Vec<(
|
|
||||||
AccountId,
|
|
||||||
AccountId,
|
|
||||||
BabeId,
|
|
||||||
GrandpaId,
|
|
||||||
ImOnlineId,
|
|
||||||
ValidatorId,
|
|
||||||
AssignmentId,
|
|
||||||
AuthorityDiscoveryId,
|
|
||||||
BeefyId,
|
|
||||||
)> = vec![
|
|
||||||
(
|
|
||||||
//5D5EsvSJf3KR3WHeZNG8rETdW6homig1cGHezspFt1P4o7sL
|
|
||||||
hex!["2ca4a9582244a3356a0d96e59d71f7e4d12aa88bca6d46f360ef11f6487cab1f"].into(),
|
|
||||||
//5Ev6RixvmK62UQE2PW19MPdLsYT4Nomwj85HKPdbnRECbDYh
|
|
||||||
hex!["7e237806f642b7f45f70ec45fbc41034516c8e5561bae2a62cd287129e1d0712"].into(),
|
|
||||||
//5GbjzK1uYVo6v1SaYhTeK3dbYy2GN9X4K5iwRkHEQ9eLS3We
|
|
||||||
hex!["c89cb7afc47ec0b5aac5824e5338a62959c92978167d3f841491836746e70b3d"]
|
|
||||||
.unchecked_into(),
|
|
||||||
//5GFz3YFW8QzEUsWhRjJzvDP7e5X5tPf5U12vUw32R8oJVgqb
|
|
||||||
hex!["b98b200021a608148f9817aeb553596b6968a5aa61b6d320c522f520ecc9cf9c"]
|
|
||||||
.unchecked_into(),
|
|
||||||
//5GzaFD8YsqnP5FYe5ijA9M4LQvzU9TPJmnBGdpuoqEvR1gQC
|
|
||||||
hex!["da0690438c0dd7a9aa26e03c9f1deaa58ba2b88d0bec0954b06478632164a401"]
|
|
||||||
.unchecked_into(),
|
|
||||||
//5CkZPtNy61PtbJpLqnjNFmbi1qukGkFdqFr5GKduSEthJ1cd
|
|
||||||
hex!["1e6554d35f6f17a37176c71801426204d6df400a1869114e4f00564b35d31150"]
|
|
||||||
.unchecked_into(),
|
|
||||||
//5CodnwweaYA1zB4QhdP4YVYFWnuZHY6W7zkN1NCRqJ9wZhap
|
|
||||||
hex!["20bddf09b1d0a2d93bafeb87fe19eb5bd59950c174f23a141a6d99736a5e700d"]
|
|
||||||
.unchecked_into(),
|
|
||||||
//5E7TSvNAP6QeJNeckdvYvADpHsx7v6aHXtGoQv5R2N1V3hEB
|
|
||||||
hex!["5a91b2546f1aac1c388eb0739c83e42d9972884d74360200ce32b7595bc65a04"]
|
|
||||||
.unchecked_into(),
|
|
||||||
//5GsoKeoM2HmjXPsdCua4oPu3Ms1Jgu4HbSnB81Lisa2tBFZp
|
|
||||||
hex!["02fd1e7e8455ab888ad054bbec7bc19409e6b1a5bb0300feefc6b58e60efae7e85"]
|
|
||||||
.unchecked_into(),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
//5HMtKQuL2GQ7YvLBTh3vqFJEpkZW19sQh2X2mcUzAwBAe885
|
|
||||||
hex!["ea478deab0ebfbeab7342febc236a9f1af5129ca0083fa25e6b0cf6a998d8354"].into(),
|
|
||||||
//5EFD5pLC3w5NFEcmQ6rGw9dUZ6fTSjWJemsvJZuaj7Qmq2WT
|
|
||||||
hex!["607b4e88129804eca8cd6fa26cbe2dd36667130e2a061050b08d9015871f4263"].into(),
|
|
||||||
//5DFztsnvC9hN85j5AP116atcnzFhAxnbzPodEp1AsYq1LYXu
|
|
||||||
hex!["34d949c39fae5801ba328ac6d0ddc76e469b7d5a4372a4a0d94f6aad6f9c1600"]
|
|
||||||
.unchecked_into(),
|
|
||||||
//5EZJNJ4j1eEEwCWusg7nYsZxTYBwoTH2drszxRqgMBTgNxMW
|
|
||||||
hex!["6e47830dcfc1f2b53a1b5db3f76702fc2760c1cc119119aceb00a57ec6658465"]
|
|
||||||
.unchecked_into(),
|
|
||||||
//5Dts3SrgDQMY9XCzKeQrxYSTh5MphPek994qkDCDk5c4neeF
|
|
||||||
hex!["50f6ef6326cd61ac500f167493e435f1204ce1d66ad18024bc5810d09673785e"]
|
|
||||||
.unchecked_into(),
|
|
||||||
//5DMKT99825TvA8F1yCQvE1ZcKTqg8T8Ad1KEjN6EuVpz4E6w
|
|
||||||
hex!["38e7fb2f6a1dcec73d93b07a0dc7cff1f9a9cc32cde8eb1e6ea1782f5316b431"]
|
|
||||||
.unchecked_into(),
|
|
||||||
//5EestuSehdMsWsBZ1hXCVo5YQiYiTPJwtV281x5fjUVtaqtP
|
|
||||||
hex!["72889a7b6ada28c3bd05a5a7298437f01d6d3270559768d16275efaf11864c0a"]
|
|
||||||
.unchecked_into(),
|
|
||||||
//5FNd5EabUbcReXEPwY9aASJMwSqyiic9w1Qt23YxNXj3dzbi
|
|
||||||
hex!["925f03f6211c68377987b0f78cd02aa882ad1fa9cc00c01fe6ce68e14c23340d"]
|
|
||||||
.unchecked_into(),
|
|
||||||
//5DxhuqfovpooTn8yH7WJGFjYw3pQxSEN9y9kvYUiGguHAj9D
|
|
||||||
hex!["030e77039e470ccdec7fe23dbc41c66f1c187ec8345e8919d3dc1250d975c3ce82"]
|
|
||||||
.unchecked_into(),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
//5DAiYTKQ5KxwLncfNoTAH58dXBk2oDcQxtAXyDwMdKGLpGeY
|
|
||||||
hex!["30d203d942c1d056245b51e466a50b684f172a37c1cdde678f5346a0b3dbcd52"].into(),
|
|
||||||
//5Dq778qqNiAsjdF4qLVdkSBR8SftJKU35nyeBnkztRgniVhV
|
|
||||||
hex!["4e194bbafeec45647b2679e6b615b2a879d2e74fe706921930509ab3c9dbb22d"].into(),
|
|
||||||
//5E6iENoE1tXJUd7PkopQ8uqejg6xhPpqAnsVjS3hAQHWK1tm
|
|
||||||
hex!["5a0037b6bfc5e879ba5ef480ac29c59a12873854159686899082f41950ffd472"]
|
|
||||||
.unchecked_into(),
|
|
||||||
//5F8Dtgoc5dCaLAGYtaDqQUDg91fPQUynd497Fvhor8SYMdXp
|
|
||||||
hex!["87638aef8ab75db093150a6677c0919292ff66fc17f9f006a71fd0618415e164"]
|
|
||||||
.unchecked_into(),
|
|
||||||
//5EKsYx6Wj1Qg7LLc12U2YRjRUFmHa4Q3rNSoGZaP1ofS54km
|
|
||||||
hex!["6409c85a1125fa456b9dc6e85408a6d931aa8e04f48511c87fc147d1c103e902"]
|
|
||||||
.unchecked_into(),
|
|
||||||
//5H3UQy1NhCUUq3getmSEG8R1capY7Uy8JtKJz68UABmD9UxS
|
|
||||||
hex!["dc3cab0f94fa974cba826984f23dd4dc77ade20f25d935af5f07b85518da8044"]
|
|
||||||
.unchecked_into(),
|
|
||||||
//5DstCjokShCt9NppNnAcjg2nS4M5PKY3etn2BoFkZzMhQJ3w
|
|
||||||
hex!["50379866eb62e5c8aac31133efc4a1723e964a8e30c93c3ce2e7758bd03eb776"]
|
|
||||||
.unchecked_into(),
|
|
||||||
//5E4SCbSqUWKC4NVRCkMkJEnXCaVRiNQbSHL4upRB1ffd1Mk1
|
|
||||||
hex!["5843c339c39d2c308bfb1841cd10beecfa157580492db05b66db8553e8d6512c"]
|
|
||||||
.unchecked_into(),
|
|
||||||
//5HNoMQ1PL3m7eBhp24FZxZUBtz4eh3AiwWq8i8jXLCRpJHsu
|
|
||||||
hex!["03c81d4e72cbdb96a7e6aad76830ae783b0b4650dc19703dde96866d8894dc921f"]
|
|
||||||
.unchecked_into(),
|
|
||||||
),
|
|
||||||
(
|
|
||||||
//5FNnjg8hXcPVLKASA69bPbooatacxcWNqkQAyXZfFiXi7T8r
|
|
||||||
hex!["927f8b12a0fa7185077353d9f6b4fe6bc6cd9682bd498642fa3801280909711a"].into(),
|
|
||||||
//5GipjBdL3rbex9qyxMinZpJYQbobbwk1ctbZp6B2mh3H25c6
|
|
||||||
hex!["ce03638cd1e8496793b0540ba23370034511ea5d08837deb17f6c4d905b8d017"].into(),
|
|
||||||
//5GByn4uRpwmPe4i4MA4PjTQ8HXuycdue8HMWDhZ7vbU4WR9R
|
|
||||||
hex!["b67d3ed42ab1fcf3fcd7dee99bd6963bc22058ee22bcfddddb776492e85bd76e"]
|
|
||||||
.unchecked_into(),
|
|
||||||
//5GnZZ1rs7RE1jwPiyw1kts4JqaxnML5SdsWMuHV9TqCcuPWj
|
|
||||||
hex!["d0dd492b1a33d2f06a9aa7213e1aaa41d8820a6b56e95cd2462129b446574014"]
|
|
||||||
.unchecked_into(),
|
|
||||||
//5GKEKSAa3gbitHhvu5gm4f7q942azCVGDNhrw3hnsGPEMzyg
|
|
||||||
hex!["bc04e9764e23330b9f4e6922aa6437f87f3dd17b8590825e824724ae89d4ac51"]
|
|
||||||
.unchecked_into(),
|
|
||||||
//5H6QLnsfU7sAQ5ZACs9bPivsn9CXrqqwxhq4KKyoquZb5mVW
|
|
||||||
hex!["de78b26966c08357d66f7f56e7dcac7e4beb16aa0b74939290a42b3f5949bc36"]
|
|
||||||
.unchecked_into(),
|
|
||||||
//5FUUeYiAvFfXfB5yZLNkis2ZDy9T3CBLBPC6SwXFriGEjH5f
|
|
||||||
hex!["96d61fe92a50a79944ea93e3afc0a95a328773878e774cf8c8fbe8eba81cd95c"]
|
|
||||||
.unchecked_into(),
|
|
||||||
//5DLkWtgJahWG99cMcQxtftW9W14oduySyQi6hdhav7w3BiKq
|
|
||||||
hex!["38791c68ee472b94105c66cf150387979c49175062a687d1a1509119cfdc9e0c"]
|
|
||||||
.unchecked_into(),
|
|
||||||
//5Cjm1c3Jwt5jp6AaN2XfnncgZcswAmyfJn1buHEUaPauXAKK
|
|
||||||
hex!["025185a88886008267d27797fc74e34241e3aa8da767fafc9dd3ae5a59546802bb"]
|
|
||||||
.unchecked_into(),
|
|
||||||
),
|
|
||||||
];
|
|
||||||
|
|
||||||
const ENDOWMENT: u128 = 1_000_000 * KSM;
|
|
||||||
const STASH: u128 = 100 * KSM;
|
|
||||||
|
|
||||||
kusama::RuntimeGenesisConfig {
|
|
||||||
system: kusama::SystemConfig { code: wasm_binary.to_vec(), ..Default::default() },
|
|
||||||
balances: kusama::BalancesConfig {
|
|
||||||
balances: endowed_accounts
|
|
||||||
.iter()
|
|
||||||
.map(|k: &AccountId| (k.clone(), ENDOWMENT))
|
|
||||||
.chain(initial_authorities.iter().map(|x| (x.0.clone(), STASH)))
|
|
||||||
.collect(),
|
|
||||||
},
|
|
||||||
beefy: Default::default(),
|
|
||||||
indices: kusama::IndicesConfig { indices: vec![] },
|
|
||||||
session: kusama::SessionConfig {
|
|
||||||
keys: initial_authorities
|
|
||||||
.iter()
|
|
||||||
.map(|x| {
|
|
||||||
(
|
|
||||||
x.0.clone(),
|
|
||||||
x.0.clone(),
|
|
||||||
kusama_session_keys(
|
|
||||||
x.2.clone(),
|
|
||||||
x.3.clone(),
|
|
||||||
x.4.clone(),
|
|
||||||
x.5.clone(),
|
|
||||||
x.6.clone(),
|
|
||||||
x.7.clone(),
|
|
||||||
x.8.clone(),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
})
|
|
||||||
.collect::<Vec<_>>(),
|
|
||||||
},
|
|
||||||
staking: kusama::StakingConfig {
|
|
||||||
validator_count: 50,
|
|
||||||
minimum_validator_count: 4,
|
|
||||||
stakers: initial_authorities
|
|
||||||
.iter()
|
|
||||||
.map(|x| (x.0.clone(), x.0.clone(), STASH, kusama::StakerStatus::Validator))
|
|
||||||
.collect(),
|
|
||||||
invulnerables: initial_authorities.iter().map(|x| x.0.clone()).collect(),
|
|
||||||
force_era: Forcing::ForceNone,
|
|
||||||
slash_reward_fraction: Perbill::from_percent(10),
|
|
||||||
..Default::default()
|
|
||||||
},
|
|
||||||
babe: kusama::BabeConfig {
|
|
||||||
authorities: Default::default(),
|
|
||||||
epoch_config: Some(kusama::BABE_GENESIS_EPOCH_CONFIG),
|
|
||||||
..Default::default()
|
|
||||||
},
|
|
||||||
grandpa: Default::default(),
|
|
||||||
im_online: Default::default(),
|
|
||||||
authority_discovery: kusama::AuthorityDiscoveryConfig {
|
|
||||||
keys: vec![],
|
|
||||||
..Default::default()
|
|
||||||
},
|
|
||||||
claims: kusama::ClaimsConfig { claims: vec![], vesting: vec![] },
|
|
||||||
vesting: kusama::VestingConfig { vesting: vec![] },
|
|
||||||
treasury: Default::default(),
|
|
||||||
hrmp: Default::default(),
|
|
||||||
configuration: kusama::ConfigurationConfig {
|
|
||||||
config: default_parachains_host_configuration(),
|
|
||||||
},
|
|
||||||
paras: Default::default(),
|
|
||||||
xcm_pallet: Default::default(),
|
|
||||||
nomination_pools: Default::default(),
|
|
||||||
nis_counterpart_balances: Default::default(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "rococo-native")]
|
#[cfg(feature = "rococo-native")]
|
||||||
fn rococo_staging_testnet_config_genesis(
|
fn rococo_staging_testnet_config_genesis(
|
||||||
wasm_binary: &[u8],
|
wasm_binary: &[u8],
|
||||||
@@ -1062,39 +754,6 @@ fn rococo_staging_testnet_config_genesis(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the properties for the [`PolkadotChainSpec`].
|
|
||||||
pub fn polkadot_chain_spec_properties() -> serde_json::map::Map<String, serde_json::Value> {
|
|
||||||
serde_json::json!({
|
|
||||||
"tokenDecimals": 10,
|
|
||||||
})
|
|
||||||
.as_object()
|
|
||||||
.expect("Map given; qed")
|
|
||||||
.clone()
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Staging testnet config.
|
|
||||||
#[cfg(feature = "kusama-native")]
|
|
||||||
pub fn kusama_staging_testnet_config() -> Result<KusamaChainSpec, String> {
|
|
||||||
let wasm_binary = kusama::WASM_BINARY.ok_or("Kusama development wasm not available")?;
|
|
||||||
let boot_nodes = vec![];
|
|
||||||
|
|
||||||
Ok(KusamaChainSpec::from_genesis(
|
|
||||||
"Kusama Staging Testnet",
|
|
||||||
"kusama_staging_testnet",
|
|
||||||
ChainType::Live,
|
|
||||||
move || kusama_staging_testnet_config_genesis(wasm_binary),
|
|
||||||
boot_nodes,
|
|
||||||
Some(
|
|
||||||
TelemetryEndpoints::new(vec![(KUSAMA_STAGING_TELEMETRY_URL.to_string(), 0)])
|
|
||||||
.expect("Kusama Staging telemetry url is valid; qed"),
|
|
||||||
),
|
|
||||||
Some(DEFAULT_PROTOCOL_ID),
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
Default::default(),
|
|
||||||
))
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Westend staging testnet config.
|
/// Westend staging testnet config.
|
||||||
#[cfg(feature = "westend-native")]
|
#[cfg(feature = "westend-native")]
|
||||||
pub fn westend_staging_testnet_config() -> Result<WestendChainSpec, String> {
|
pub fn westend_staging_testnet_config() -> Result<WestendChainSpec, String> {
|
||||||
@@ -1239,12 +898,7 @@ pub fn get_authority_keys_from_seed_no_beefy(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(
|
#[cfg(any(feature = "westend-native", feature = "rococo-native"))]
|
||||||
feature = "polkadot-native",
|
|
||||||
feature = "kusama-native",
|
|
||||||
feature = "westend-native",
|
|
||||||
feature = "rococo-native"
|
|
||||||
))]
|
|
||||||
fn testnet_accounts() -> Vec<AccountId> {
|
fn testnet_accounts() -> Vec<AccountId> {
|
||||||
vec![
|
vec![
|
||||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
||||||
@@ -1262,176 +916,6 @@ fn testnet_accounts() -> Vec<AccountId> {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Helper function to create polkadot `RuntimeGenesisConfig` for testing
|
|
||||||
#[cfg(feature = "polkadot-native")]
|
|
||||||
pub fn polkadot_testnet_genesis(
|
|
||||||
wasm_binary: &[u8],
|
|
||||||
initial_authorities: Vec<(
|
|
||||||
AccountId,
|
|
||||||
AccountId,
|
|
||||||
BabeId,
|
|
||||||
GrandpaId,
|
|
||||||
ImOnlineId,
|
|
||||||
ValidatorId,
|
|
||||||
AssignmentId,
|
|
||||||
AuthorityDiscoveryId,
|
|
||||||
)>,
|
|
||||||
_root_key: AccountId,
|
|
||||||
endowed_accounts: Option<Vec<AccountId>>,
|
|
||||||
) -> polkadot::RuntimeGenesisConfig {
|
|
||||||
let endowed_accounts: Vec<AccountId> = endowed_accounts.unwrap_or_else(testnet_accounts);
|
|
||||||
|
|
||||||
const ENDOWMENT: u128 = 1_000_000 * DOT;
|
|
||||||
const STASH: u128 = 100 * DOT;
|
|
||||||
|
|
||||||
polkadot::RuntimeGenesisConfig {
|
|
||||||
system: polkadot::SystemConfig { code: wasm_binary.to_vec(), ..Default::default() },
|
|
||||||
indices: polkadot::IndicesConfig { indices: vec![] },
|
|
||||||
balances: polkadot::BalancesConfig {
|
|
||||||
balances: endowed_accounts.iter().map(|k| (k.clone(), ENDOWMENT)).collect(),
|
|
||||||
},
|
|
||||||
session: polkadot::SessionConfig {
|
|
||||||
keys: initial_authorities
|
|
||||||
.iter()
|
|
||||||
.map(|x| {
|
|
||||||
(
|
|
||||||
x.0.clone(),
|
|
||||||
x.0.clone(),
|
|
||||||
polkadot_session_keys(
|
|
||||||
x.2.clone(),
|
|
||||||
x.3.clone(),
|
|
||||||
x.4.clone(),
|
|
||||||
x.5.clone(),
|
|
||||||
x.6.clone(),
|
|
||||||
x.7.clone(),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
})
|
|
||||||
.collect::<Vec<_>>(),
|
|
||||||
},
|
|
||||||
staking: polkadot::StakingConfig {
|
|
||||||
minimum_validator_count: 1,
|
|
||||||
validator_count: initial_authorities.len() as u32,
|
|
||||||
stakers: initial_authorities
|
|
||||||
.iter()
|
|
||||||
.map(|x| (x.0.clone(), x.0.clone(), STASH, polkadot::StakerStatus::Validator))
|
|
||||||
.collect(),
|
|
||||||
invulnerables: initial_authorities.iter().map(|x| x.0.clone()).collect(),
|
|
||||||
force_era: Forcing::NotForcing,
|
|
||||||
slash_reward_fraction: Perbill::from_percent(10),
|
|
||||||
..Default::default()
|
|
||||||
},
|
|
||||||
babe: polkadot::BabeConfig {
|
|
||||||
authorities: Default::default(),
|
|
||||||
epoch_config: Some(polkadot::BABE_GENESIS_EPOCH_CONFIG),
|
|
||||||
..Default::default()
|
|
||||||
},
|
|
||||||
grandpa: Default::default(),
|
|
||||||
im_online: Default::default(),
|
|
||||||
authority_discovery: polkadot::AuthorityDiscoveryConfig {
|
|
||||||
keys: vec![],
|
|
||||||
..Default::default()
|
|
||||||
},
|
|
||||||
claims: polkadot::ClaimsConfig { claims: vec![], vesting: vec![] },
|
|
||||||
vesting: polkadot::VestingConfig { vesting: vec![] },
|
|
||||||
treasury: Default::default(),
|
|
||||||
hrmp: Default::default(),
|
|
||||||
configuration: polkadot::ConfigurationConfig {
|
|
||||||
config: default_parachains_host_configuration(),
|
|
||||||
},
|
|
||||||
paras: Default::default(),
|
|
||||||
xcm_pallet: Default::default(),
|
|
||||||
nomination_pools: Default::default(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Helper function to create kusama `RuntimeGenesisConfig` for testing
|
|
||||||
#[cfg(feature = "kusama-native")]
|
|
||||||
pub fn kusama_testnet_genesis(
|
|
||||||
wasm_binary: &[u8],
|
|
||||||
initial_authorities: Vec<(
|
|
||||||
AccountId,
|
|
||||||
AccountId,
|
|
||||||
BabeId,
|
|
||||||
GrandpaId,
|
|
||||||
ImOnlineId,
|
|
||||||
ValidatorId,
|
|
||||||
AssignmentId,
|
|
||||||
AuthorityDiscoveryId,
|
|
||||||
BeefyId,
|
|
||||||
)>,
|
|
||||||
_root_key: AccountId,
|
|
||||||
endowed_accounts: Option<Vec<AccountId>>,
|
|
||||||
) -> kusama::RuntimeGenesisConfig {
|
|
||||||
let endowed_accounts: Vec<AccountId> = endowed_accounts.unwrap_or_else(testnet_accounts);
|
|
||||||
|
|
||||||
const ENDOWMENT: u128 = 1_000_000 * KSM;
|
|
||||||
const STASH: u128 = 100 * KSM;
|
|
||||||
|
|
||||||
kusama::RuntimeGenesisConfig {
|
|
||||||
system: kusama::SystemConfig { code: wasm_binary.to_vec(), ..Default::default() },
|
|
||||||
indices: kusama::IndicesConfig { indices: vec![] },
|
|
||||||
balances: kusama::BalancesConfig {
|
|
||||||
balances: endowed_accounts.iter().map(|k| (k.clone(), ENDOWMENT)).collect(),
|
|
||||||
},
|
|
||||||
beefy: Default::default(),
|
|
||||||
session: kusama::SessionConfig {
|
|
||||||
keys: initial_authorities
|
|
||||||
.iter()
|
|
||||||
.map(|x| {
|
|
||||||
(
|
|
||||||
x.0.clone(),
|
|
||||||
x.0.clone(),
|
|
||||||
kusama_session_keys(
|
|
||||||
x.2.clone(),
|
|
||||||
x.3.clone(),
|
|
||||||
x.4.clone(),
|
|
||||||
x.5.clone(),
|
|
||||||
x.6.clone(),
|
|
||||||
x.7.clone(),
|
|
||||||
x.8.clone(),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
})
|
|
||||||
.collect::<Vec<_>>(),
|
|
||||||
},
|
|
||||||
staking: kusama::StakingConfig {
|
|
||||||
minimum_validator_count: 1,
|
|
||||||
validator_count: initial_authorities.len() as u32,
|
|
||||||
stakers: initial_authorities
|
|
||||||
.iter()
|
|
||||||
.map(|x| (x.0.clone(), x.0.clone(), STASH, kusama::StakerStatus::Validator))
|
|
||||||
.collect(),
|
|
||||||
invulnerables: initial_authorities.iter().map(|x| x.0.clone()).collect(),
|
|
||||||
force_era: Forcing::NotForcing,
|
|
||||||
slash_reward_fraction: Perbill::from_percent(10),
|
|
||||||
..Default::default()
|
|
||||||
},
|
|
||||||
babe: kusama::BabeConfig {
|
|
||||||
authorities: Default::default(),
|
|
||||||
epoch_config: Some(kusama::BABE_GENESIS_EPOCH_CONFIG),
|
|
||||||
..Default::default()
|
|
||||||
},
|
|
||||||
grandpa: Default::default(),
|
|
||||||
im_online: Default::default(),
|
|
||||||
authority_discovery: kusama::AuthorityDiscoveryConfig {
|
|
||||||
keys: vec![],
|
|
||||||
..Default::default()
|
|
||||||
},
|
|
||||||
claims: kusama::ClaimsConfig { claims: vec![], vesting: vec![] },
|
|
||||||
vesting: kusama::VestingConfig { vesting: vec![] },
|
|
||||||
treasury: Default::default(),
|
|
||||||
hrmp: Default::default(),
|
|
||||||
configuration: kusama::ConfigurationConfig {
|
|
||||||
config: default_parachains_host_configuration(),
|
|
||||||
},
|
|
||||||
paras: Default::default(),
|
|
||||||
xcm_pallet: Default::default(),
|
|
||||||
nomination_pools: Default::default(),
|
|
||||||
nis_counterpart_balances: Default::default(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Helper function to create westend `RuntimeGenesisConfig` for testing
|
/// Helper function to create westend `RuntimeGenesisConfig` for testing
|
||||||
#[cfg(feature = "westend-native")]
|
#[cfg(feature = "westend-native")]
|
||||||
pub fn westend_testnet_genesis(
|
pub fn westend_testnet_genesis(
|
||||||
@@ -1612,26 +1096,6 @@ pub fn rococo_testnet_genesis(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "polkadot-native")]
|
|
||||||
fn polkadot_development_config_genesis(wasm_binary: &[u8]) -> polkadot::RuntimeGenesisConfig {
|
|
||||||
polkadot_testnet_genesis(
|
|
||||||
wasm_binary,
|
|
||||||
vec![get_authority_keys_from_seed_no_beefy("Alice")],
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
|
||||||
None,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "kusama-native")]
|
|
||||||
fn kusama_development_config_genesis(wasm_binary: &[u8]) -> kusama::RuntimeGenesisConfig {
|
|
||||||
kusama_testnet_genesis(
|
|
||||||
wasm_binary,
|
|
||||||
vec![get_authority_keys_from_seed("Alice")],
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
|
||||||
None,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "westend-native")]
|
#[cfg(feature = "westend-native")]
|
||||||
fn westend_development_config_genesis(wasm_binary: &[u8]) -> westend::RuntimeGenesisConfig {
|
fn westend_development_config_genesis(wasm_binary: &[u8]) -> westend::RuntimeGenesisConfig {
|
||||||
westend_testnet_genesis(
|
westend_testnet_genesis(
|
||||||
@@ -1652,44 +1116,6 @@ fn rococo_development_config_genesis(wasm_binary: &[u8]) -> rococo_runtime::Runt
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Polkadot development config (single validator Alice)
|
|
||||||
#[cfg(feature = "polkadot-native")]
|
|
||||||
pub fn polkadot_development_config() -> Result<PolkadotChainSpec, String> {
|
|
||||||
let wasm_binary = polkadot::WASM_BINARY.ok_or("Polkadot development wasm not available")?;
|
|
||||||
|
|
||||||
Ok(PolkadotChainSpec::from_genesis(
|
|
||||||
"Development",
|
|
||||||
"polkadot_dev",
|
|
||||||
ChainType::Development,
|
|
||||||
move || polkadot_development_config_genesis(wasm_binary),
|
|
||||||
vec![],
|
|
||||||
None,
|
|
||||||
Some(DEFAULT_PROTOCOL_ID),
|
|
||||||
None,
|
|
||||||
Some(polkadot_chain_spec_properties()),
|
|
||||||
Default::default(),
|
|
||||||
))
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Kusama development config (single validator Alice)
|
|
||||||
#[cfg(feature = "kusama-native")]
|
|
||||||
pub fn kusama_development_config() -> Result<KusamaChainSpec, String> {
|
|
||||||
let wasm_binary = kusama::WASM_BINARY.ok_or("Kusama development wasm not available")?;
|
|
||||||
|
|
||||||
Ok(KusamaChainSpec::from_genesis(
|
|
||||||
"Development",
|
|
||||||
"kusama_dev",
|
|
||||||
ChainType::Development,
|
|
||||||
move || kusama_development_config_genesis(wasm_binary),
|
|
||||||
vec![],
|
|
||||||
None,
|
|
||||||
Some(DEFAULT_PROTOCOL_ID),
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
Default::default(),
|
|
||||||
))
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Westend development config (single validator Alice)
|
/// Westend development config (single validator Alice)
|
||||||
#[cfg(feature = "westend-native")]
|
#[cfg(feature = "westend-native")]
|
||||||
pub fn westend_development_config() -> Result<WestendChainSpec, String> {
|
pub fn westend_development_config() -> Result<WestendChainSpec, String> {
|
||||||
@@ -1779,67 +1205,6 @@ pub fn wococo_development_config() -> Result<RococoChainSpec, String> {
|
|||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "polkadot-native")]
|
|
||||||
fn polkadot_local_testnet_genesis(wasm_binary: &[u8]) -> polkadot::RuntimeGenesisConfig {
|
|
||||||
polkadot_testnet_genesis(
|
|
||||||
wasm_binary,
|
|
||||||
vec![
|
|
||||||
get_authority_keys_from_seed_no_beefy("Alice"),
|
|
||||||
get_authority_keys_from_seed_no_beefy("Bob"),
|
|
||||||
],
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
|
||||||
None,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Polkadot local testnet config (multivalidator Alice + Bob)
|
|
||||||
#[cfg(feature = "polkadot-native")]
|
|
||||||
pub fn polkadot_local_testnet_config() -> Result<PolkadotChainSpec, String> {
|
|
||||||
let wasm_binary = polkadot::WASM_BINARY.ok_or("Polkadot development wasm not available")?;
|
|
||||||
|
|
||||||
Ok(PolkadotChainSpec::from_genesis(
|
|
||||||
"Local Testnet",
|
|
||||||
"local_testnet",
|
|
||||||
ChainType::Local,
|
|
||||||
move || polkadot_local_testnet_genesis(wasm_binary),
|
|
||||||
vec![],
|
|
||||||
None,
|
|
||||||
Some(DEFAULT_PROTOCOL_ID),
|
|
||||||
None,
|
|
||||||
Some(polkadot_chain_spec_properties()),
|
|
||||||
Default::default(),
|
|
||||||
))
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "kusama-native")]
|
|
||||||
fn kusama_local_testnet_genesis(wasm_binary: &[u8]) -> kusama::RuntimeGenesisConfig {
|
|
||||||
kusama_testnet_genesis(
|
|
||||||
wasm_binary,
|
|
||||||
vec![get_authority_keys_from_seed("Alice"), get_authority_keys_from_seed("Bob")],
|
|
||||||
get_account_id_from_seed::<sr25519::Public>("Alice"),
|
|
||||||
None,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Kusama local testnet config (multivalidator Alice + Bob)
|
|
||||||
#[cfg(feature = "kusama-native")]
|
|
||||||
pub fn kusama_local_testnet_config() -> Result<KusamaChainSpec, String> {
|
|
||||||
let wasm_binary = kusama::WASM_BINARY.ok_or("Kusama development wasm not available")?;
|
|
||||||
|
|
||||||
Ok(KusamaChainSpec::from_genesis(
|
|
||||||
"Kusama Local Testnet",
|
|
||||||
"kusama_local_testnet",
|
|
||||||
ChainType::Local,
|
|
||||||
move || kusama_local_testnet_genesis(wasm_binary),
|
|
||||||
vec![],
|
|
||||||
None,
|
|
||||||
Some(DEFAULT_PROTOCOL_ID),
|
|
||||||
None,
|
|
||||||
None,
|
|
||||||
Default::default(),
|
|
||||||
))
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(feature = "westend-native")]
|
#[cfg(feature = "westend-native")]
|
||||||
fn westend_local_testnet_genesis(wasm_binary: &[u8]) -> westend::RuntimeGenesisConfig {
|
fn westend_local_testnet_genesis(wasm_binary: &[u8]) -> westend::RuntimeGenesisConfig {
|
||||||
westend_testnet_genesis(
|
westend_testnet_genesis(
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ use telemetry::TelemetryWorker;
|
|||||||
#[cfg(feature = "full-node")]
|
#[cfg(feature = "full-node")]
|
||||||
use telemetry::{Telemetry, TelemetryWorkerHandle};
|
use telemetry::{Telemetry, TelemetryWorkerHandle};
|
||||||
|
|
||||||
pub use chain_spec::{KusamaChainSpec, PolkadotChainSpec, RococoChainSpec, WestendChainSpec};
|
pub use chain_spec::{GenericChainSpec, RococoChainSpec, WestendChainSpec};
|
||||||
pub use consensus_common::{Proposal, SelectChain};
|
pub use consensus_common::{Proposal, SelectChain};
|
||||||
use frame_benchmarking_cli::SUBSTRATE_REFERENCE_HARDWARE;
|
use frame_benchmarking_cli::SUBSTRATE_REFERENCE_HARDWARE;
|
||||||
use mmr_gadget::MmrGadget;
|
use mmr_gadget::MmrGadget;
|
||||||
@@ -104,10 +104,6 @@ pub use sp_runtime::{
|
|||||||
traits::{self as runtime_traits, BlakeTwo256, Block as BlockT, Header as HeaderT, NumberFor},
|
traits::{self as runtime_traits, BlakeTwo256, Block as BlockT, Header as HeaderT, NumberFor},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(feature = "kusama-native")]
|
|
||||||
pub use {kusama_runtime, kusama_runtime_constants};
|
|
||||||
#[cfg(feature = "polkadot-native")]
|
|
||||||
pub use {polkadot_runtime, polkadot_runtime_constants};
|
|
||||||
#[cfg(feature = "rococo-native")]
|
#[cfg(feature = "rococo-native")]
|
||||||
pub use {rococo_runtime, rococo_runtime_constants};
|
pub use {rococo_runtime, rococo_runtime_constants};
|
||||||
#[cfg(feature = "westend-native")]
|
#[cfg(feature = "westend-native")]
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ futures = "0.3.21"
|
|||||||
hex = "0.4.3"
|
hex = "0.4.3"
|
||||||
gum = { package = "tracing-gum", path = "../../gum" }
|
gum = { package = "tracing-gum", path = "../../gum" }
|
||||||
rand = "0.8.5"
|
rand = "0.8.5"
|
||||||
|
serde_json = "1.0.106"
|
||||||
tempfile = "3.2.0"
|
tempfile = "3.2.0"
|
||||||
tokio = "1.24.2"
|
tokio = "1.24.2"
|
||||||
|
|
||||||
|
|||||||
@@ -20,9 +20,7 @@ use babe_primitives::AuthorityId as BabeId;
|
|||||||
use grandpa::AuthorityId as GrandpaId;
|
use grandpa::AuthorityId as GrandpaId;
|
||||||
use pallet_staking::Forcing;
|
use pallet_staking::Forcing;
|
||||||
use polkadot_primitives::{AccountId, AssignmentId, ValidatorId, MAX_CODE_SIZE, MAX_POV_SIZE};
|
use polkadot_primitives::{AccountId, AssignmentId, ValidatorId, MAX_CODE_SIZE, MAX_POV_SIZE};
|
||||||
use polkadot_service::chain_spec::{
|
use polkadot_service::chain_spec::{get_account_id_from_seed, get_from_seed, Extensions};
|
||||||
get_account_id_from_seed, get_from_seed, polkadot_chain_spec_properties, Extensions,
|
|
||||||
};
|
|
||||||
use polkadot_test_runtime::BABE_GENESIS_EPOCH_CONFIG;
|
use polkadot_test_runtime::BABE_GENESIS_EPOCH_CONFIG;
|
||||||
use sc_chain_spec::{ChainSpec, ChainType};
|
use sc_chain_spec::{ChainSpec, ChainType};
|
||||||
use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId;
|
use sp_authority_discovery::AuthorityId as AuthorityDiscoveryId;
|
||||||
@@ -36,6 +34,16 @@ const DEFAULT_PROTOCOL_ID: &str = "dot";
|
|||||||
pub type PolkadotChainSpec =
|
pub type PolkadotChainSpec =
|
||||||
sc_service::GenericChainSpec<polkadot_test_runtime::RuntimeGenesisConfig, Extensions>;
|
sc_service::GenericChainSpec<polkadot_test_runtime::RuntimeGenesisConfig, Extensions>;
|
||||||
|
|
||||||
|
/// Returns the properties for the [`PolkadotChainSpec`].
|
||||||
|
pub fn polkadot_chain_spec_properties() -> serde_json::map::Map<String, serde_json::Value> {
|
||||||
|
serde_json::json!({
|
||||||
|
"tokenDecimals": 10,
|
||||||
|
})
|
||||||
|
.as_object()
|
||||||
|
.expect("Map given; qed")
|
||||||
|
.clone()
|
||||||
|
}
|
||||||
|
|
||||||
/// Local testnet config (multivalidator Alice + Bob)
|
/// Local testnet config (multivalidator Alice + Bob)
|
||||||
pub fn polkadot_local_testnet_config() -> PolkadotChainSpec {
|
pub fn polkadot_local_testnet_config() -> PolkadotChainSpec {
|
||||||
PolkadotChainSpec::from_genesis(
|
PolkadotChainSpec::from_genesis(
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
#![cfg(unix)]
|
#![cfg(unix)]
|
||||||
|
|
||||||
use assert_cmd::cargo::cargo_bin;
|
use assert_cmd::cargo::cargo_bin;
|
||||||
|
use common::run_with_timeout;
|
||||||
use nix::{
|
use nix::{
|
||||||
sys::signal::{kill, Signal::SIGINT},
|
sys::signal::{kill, Signal::SIGINT},
|
||||||
unistd::Pid,
|
unistd::Pid,
|
||||||
@@ -32,25 +33,28 @@ use tempfile::tempdir;
|
|||||||
|
|
||||||
pub mod common;
|
pub mod common;
|
||||||
|
|
||||||
static RUNTIMES: [&str; 4] = ["polkadot", "kusama", "westend", "rococo"];
|
static RUNTIMES: &[&str] = &["westend", "rococo"];
|
||||||
|
|
||||||
/// `benchmark block` works for all dev runtimes using the wasm executor.
|
/// `benchmark block` works for all dev runtimes using the wasm executor.
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn benchmark_block_works() {
|
async fn benchmark_block_works() {
|
||||||
for runtime in RUNTIMES {
|
for runtime in RUNTIMES {
|
||||||
let tmp_dir = tempdir().expect("could not create a temp dir");
|
run_with_timeout(Duration::from_secs(10 * 60), async move {
|
||||||
let base_path = tmp_dir.path();
|
let tmp_dir = tempdir().expect("could not create a temp dir");
|
||||||
let runtime = format!("{}-dev", runtime);
|
let base_path = tmp_dir.path();
|
||||||
|
let runtime = format!("{}-dev", runtime);
|
||||||
|
|
||||||
// Build a chain with a single block.
|
// Build a chain with a single block.
|
||||||
build_chain(&runtime, base_path).await.unwrap();
|
build_chain(&runtime, base_path).await;
|
||||||
// Benchmark the one block.
|
// Benchmark the one block.
|
||||||
benchmark_block(&runtime, base_path, 1).unwrap();
|
benchmark_block(&runtime, base_path, 1).unwrap();
|
||||||
|
})
|
||||||
|
.await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Builds a chain with one block for the given runtime and base path.
|
/// Builds a chain with one block for the given runtime and base path.
|
||||||
async fn build_chain(runtime: &str, base_path: &Path) -> Result<(), String> {
|
async fn build_chain(runtime: &str, base_path: &Path) {
|
||||||
let mut cmd = Command::new(cargo_bin("polkadot"))
|
let mut cmd = Command::new(cargo_bin("polkadot"))
|
||||||
.stdout(process::Stdio::piped())
|
.stdout(process::Stdio::piped())
|
||||||
.stderr(process::Stdio::piped())
|
.stderr(process::Stdio::piped())
|
||||||
@@ -64,13 +68,10 @@ async fn build_chain(runtime: &str, base_path: &Path) -> Result<(), String> {
|
|||||||
let (ws_url, _) = common::find_ws_url_from_output(cmd.stderr.take().unwrap());
|
let (ws_url, _) = common::find_ws_url_from_output(cmd.stderr.take().unwrap());
|
||||||
|
|
||||||
// Wait for the chain to produce one block.
|
// Wait for the chain to produce one block.
|
||||||
let ok = common::wait_n_finalized_blocks(1, Duration::from_secs(60), &ws_url).await;
|
common::wait_n_finalized_blocks(1, &ws_url).await;
|
||||||
// Send SIGINT to node.
|
// Send SIGINT to node.
|
||||||
kill(Pid::from_raw(cmd.id().try_into().unwrap()), SIGINT).unwrap();
|
kill(Pid::from_raw(cmd.id().try_into().unwrap()), SIGINT).unwrap();
|
||||||
// Wait for the node to handle it and exit.
|
assert!(cmd.wait().unwrap().success());
|
||||||
assert!(common::wait_for(&mut cmd, 30).map(|x| x.success()).unwrap_or_default());
|
|
||||||
|
|
||||||
ok.map_err(|e| format!("Node did not build the chain: {:?}", e))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Benchmarks the given block with the wasm executor.
|
/// Benchmarks the given block with the wasm executor.
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
use assert_cmd::cargo::cargo_bin;
|
use assert_cmd::cargo::cargo_bin;
|
||||||
use std::{process::Command, result::Result};
|
use std::{process::Command, result::Result};
|
||||||
|
|
||||||
static RUNTIMES: [&str; 4] = ["polkadot", "kusama", "westend", "rococo"];
|
static RUNTIMES: &[&str] = &["westend", "rococo"];
|
||||||
|
|
||||||
static EXTRINSICS: [(&str, &str); 2] = [("system", "remark"), ("balances", "transfer_keep_alive")];
|
static EXTRINSICS: [(&str, &str); 2] = [("system", "remark"), ("balances", "transfer_keep_alive")];
|
||||||
|
|
||||||
|
|||||||
@@ -18,26 +18,26 @@ use assert_cmd::cargo::cargo_bin;
|
|||||||
use std::{process::Command, result::Result};
|
use std::{process::Command, result::Result};
|
||||||
use tempfile::tempdir;
|
use tempfile::tempdir;
|
||||||
|
|
||||||
static RUNTIMES: [&str; 4] = ["polkadot", "kusama", "westend", "rococo"];
|
static RUNTIMES: &[&str] = &["westend", "rococo"];
|
||||||
|
|
||||||
/// `benchmark overhead` works for all dev runtimes.
|
/// `benchmark overhead` works for all dev runtimes.
|
||||||
#[test]
|
#[test]
|
||||||
fn benchmark_overhead_works() {
|
fn benchmark_overhead_works() {
|
||||||
for runtime in RUNTIMES {
|
for runtime in RUNTIMES {
|
||||||
let runtime = format!("{}-dev", runtime);
|
let runtime = format!("{}-dev", runtime);
|
||||||
assert!(benchmark_overhead(runtime).is_ok());
|
assert!(benchmark_overhead(&runtime).is_ok());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `benchmark overhead` rejects all non-dev runtimes.
|
/// `benchmark overhead` rejects all non-dev runtimes.
|
||||||
#[test]
|
#[test]
|
||||||
fn benchmark_overhead_rejects_non_dev_runtimes() {
|
fn benchmark_overhead_rejects_non_dev_runtimes() {
|
||||||
for runtime in RUNTIMES {
|
for runtime in RUNTIMES.into_iter() {
|
||||||
assert!(benchmark_overhead(runtime.into()).is_err());
|
assert!(benchmark_overhead(runtime).is_err());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn benchmark_overhead(runtime: String) -> Result<(), String> {
|
fn benchmark_overhead(runtime: &str) -> Result<(), String> {
|
||||||
let tmp_dir = tempdir().expect("could not create a temp dir");
|
let tmp_dir = tempdir().expect("could not create a temp dir");
|
||||||
let base_path = tmp_dir.path();
|
let base_path = tmp_dir.path();
|
||||||
|
|
||||||
|
|||||||
@@ -16,49 +16,25 @@
|
|||||||
|
|
||||||
use polkadot_core_primitives::{Block, Hash, Header};
|
use polkadot_core_primitives::{Block, Hash, Header};
|
||||||
use std::{
|
use std::{
|
||||||
|
future::Future,
|
||||||
io::{BufRead, BufReader, Read},
|
io::{BufRead, BufReader, Read},
|
||||||
process::{Child, ExitStatus},
|
|
||||||
thread,
|
|
||||||
time::Duration,
|
time::Duration,
|
||||||
};
|
};
|
||||||
use substrate_rpc_client::{ws_client, ChainApi};
|
use substrate_rpc_client::{ws_client, ChainApi};
|
||||||
use tokio::time::timeout;
|
|
||||||
|
|
||||||
/// Wait for the given `child` the given amount of `secs`.
|
/// Run the given `future` and panic if the `timeout` is hit.
|
||||||
///
|
pub async fn run_with_timeout(timeout: Duration, future: impl Future<Output = ()>) {
|
||||||
/// Returns the `Some(exit status)` or `None` if the process did not finish in the given time.
|
tokio::time::timeout(timeout, future).await.expect("Hit timeout");
|
||||||
pub fn wait_for(child: &mut Child, secs: usize) -> Option<ExitStatus> {
|
|
||||||
for _ in 0..secs {
|
|
||||||
match child.try_wait().unwrap() {
|
|
||||||
Some(status) => return Some(status),
|
|
||||||
None => thread::sleep(Duration::from_secs(1)),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
eprintln!("Took to long to exit. Killing...");
|
|
||||||
let _ = child.kill();
|
|
||||||
child.wait().unwrap();
|
|
||||||
|
|
||||||
None
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Wait for at least `n` blocks to be finalized within the specified time.
|
|
||||||
pub async fn wait_n_finalized_blocks(
|
|
||||||
n: usize,
|
|
||||||
timeout_duration: Duration,
|
|
||||||
url: &str,
|
|
||||||
) -> Result<(), tokio::time::error::Elapsed> {
|
|
||||||
timeout(timeout_duration, wait_n_finalized_blocks_from(n, url)).await
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Wait for at least `n` blocks to be finalized from a specified node.
|
/// Wait for at least `n` blocks to be finalized from a specified node.
|
||||||
async fn wait_n_finalized_blocks_from(n: usize, url: &str) {
|
pub async fn wait_n_finalized_blocks(n: usize, url: &str) {
|
||||||
let mut built_blocks = std::collections::HashSet::new();
|
let mut built_blocks = std::collections::HashSet::new();
|
||||||
let mut interval = tokio::time::interval(Duration::from_secs(6));
|
let mut interval = tokio::time::interval(Duration::from_secs(6));
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
let rpc = match ws_client(url).await {
|
let Ok(rpc) = ws_client(url).await else {
|
||||||
Ok(rpc_service) => rpc_service,
|
continue;
|
||||||
Err(_) => continue,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Ok(block) = ChainApi::<(), Hash, Header, Block>::finalized_head(&rpc).await {
|
if let Ok(block) = ChainApi::<(), Hash, Header, Block>::finalized_head(&rpc).await {
|
||||||
@@ -67,6 +43,7 @@ async fn wait_n_finalized_blocks_from(n: usize, url: &str) {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
interval.tick().await;
|
interval.tick().await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,14 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
|
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#![cfg(unix)]
|
||||||
|
|
||||||
use assert_cmd::cargo::cargo_bin;
|
use assert_cmd::cargo::cargo_bin;
|
||||||
|
use common::run_with_timeout;
|
||||||
|
use nix::{
|
||||||
|
sys::signal::{kill, Signal::SIGINT},
|
||||||
|
unistd::Pid,
|
||||||
|
};
|
||||||
use std::{
|
use std::{
|
||||||
process::{self, Command},
|
process::{self, Command},
|
||||||
time::Duration,
|
time::Duration,
|
||||||
@@ -24,105 +31,95 @@ use tempfile::tempdir;
|
|||||||
pub mod common;
|
pub mod common;
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
#[cfg(unix)]
|
|
||||||
async fn purge_chain_rocksdb_works() {
|
async fn purge_chain_rocksdb_works() {
|
||||||
use nix::{
|
run_with_timeout(Duration::from_secs(10 * 60), async move {
|
||||||
sys::signal::{kill, Signal::SIGINT},
|
let tmpdir = tempdir().expect("could not create temp dir");
|
||||||
unistd::Pid,
|
|
||||||
};
|
|
||||||
|
|
||||||
let tmpdir = tempdir().expect("could not create temp dir");
|
let mut cmd = Command::new(cargo_bin("polkadot"))
|
||||||
|
.stdout(process::Stdio::piped())
|
||||||
|
.stderr(process::Stdio::piped())
|
||||||
|
.args(["--dev", "-d"])
|
||||||
|
.arg(tmpdir.path())
|
||||||
|
.arg("--port")
|
||||||
|
.arg("33034")
|
||||||
|
.arg("--no-hardware-benchmarks")
|
||||||
|
.spawn()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
let mut cmd = Command::new(cargo_bin("polkadot"))
|
let (ws_url, _) = common::find_ws_url_from_output(cmd.stderr.take().unwrap());
|
||||||
.stdout(process::Stdio::piped())
|
|
||||||
.stderr(process::Stdio::piped())
|
|
||||||
.args(["--dev", "-d"])
|
|
||||||
.arg(tmpdir.path())
|
|
||||||
.arg("--port")
|
|
||||||
.arg("33034")
|
|
||||||
.arg("--no-hardware-benchmarks")
|
|
||||||
.spawn()
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let (ws_url, _) = common::find_ws_url_from_output(cmd.stderr.take().unwrap());
|
// Let it produce 1 block.
|
||||||
|
common::wait_n_finalized_blocks(1, &ws_url).await;
|
||||||
|
|
||||||
// Let it produce 1 block.
|
// Send SIGINT to node.
|
||||||
common::wait_n_finalized_blocks(1, Duration::from_secs(60), &ws_url)
|
kill(Pid::from_raw(cmd.id().try_into().unwrap()), SIGINT).unwrap();
|
||||||
.await
|
// Wait for the node to handle it and exit.
|
||||||
.unwrap();
|
assert!(cmd.wait().unwrap().success());
|
||||||
|
assert!(tmpdir.path().join("chains/rococo_dev").exists());
|
||||||
|
assert!(tmpdir.path().join("chains/rococo_dev/db/full").exists());
|
||||||
|
assert!(tmpdir.path().join("chains/rococo_dev/db/full/parachains").exists());
|
||||||
|
|
||||||
// Send SIGINT to node.
|
// Purge chain
|
||||||
kill(Pid::from_raw(cmd.id().try_into().unwrap()), SIGINT).unwrap();
|
let status = Command::new(cargo_bin("polkadot"))
|
||||||
// Wait for the node to handle it and exit.
|
.args(["purge-chain", "--dev", "-d"])
|
||||||
assert!(common::wait_for(&mut cmd, 30).map(|x| x.success()).unwrap_or_default());
|
.arg(tmpdir.path())
|
||||||
assert!(tmpdir.path().join("chains/polkadot_dev").exists());
|
.arg("-y")
|
||||||
assert!(tmpdir.path().join("chains/polkadot_dev/db/full").exists());
|
.status()
|
||||||
assert!(tmpdir.path().join("chains/polkadot_dev/db/full/parachains").exists());
|
.unwrap();
|
||||||
|
assert!(status.success());
|
||||||
|
|
||||||
// Purge chain
|
// Make sure that the chain folder exists, but `db/full` is deleted.
|
||||||
let status = Command::new(cargo_bin("polkadot"))
|
assert!(tmpdir.path().join("chains/rococo_dev").exists());
|
||||||
.args(["purge-chain", "--dev", "-d"])
|
assert!(!tmpdir.path().join("chains/rococo_dev/db/full").exists());
|
||||||
.arg(tmpdir.path())
|
})
|
||||||
.arg("-y")
|
.await;
|
||||||
.status()
|
|
||||||
.unwrap();
|
|
||||||
assert!(status.success());
|
|
||||||
|
|
||||||
// Make sure that the chain folder exists, but `db/full` is deleted.
|
|
||||||
assert!(tmpdir.path().join("chains/polkadot_dev").exists());
|
|
||||||
assert!(!tmpdir.path().join("chains/polkadot_dev/db/full").exists());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
#[cfg(unix)]
|
|
||||||
async fn purge_chain_paritydb_works() {
|
async fn purge_chain_paritydb_works() {
|
||||||
use nix::{
|
run_with_timeout(Duration::from_secs(10 * 60), async move {
|
||||||
sys::signal::{kill, Signal::SIGINT},
|
let tmpdir = tempdir().expect("could not create temp dir");
|
||||||
unistd::Pid,
|
|
||||||
};
|
|
||||||
|
|
||||||
let tmpdir = tempdir().expect("could not create temp dir");
|
let mut cmd = Command::new(cargo_bin("polkadot"))
|
||||||
|
.stdout(process::Stdio::piped())
|
||||||
|
.stderr(process::Stdio::piped())
|
||||||
|
.args(["--dev", "-d"])
|
||||||
|
.arg(tmpdir.path())
|
||||||
|
.arg("--database")
|
||||||
|
.arg("paritydb-experimental")
|
||||||
|
.arg("--no-hardware-benchmarks")
|
||||||
|
.spawn()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
let mut cmd = Command::new(cargo_bin("polkadot"))
|
let (ws_url, _) = common::find_ws_url_from_output(cmd.stderr.take().unwrap());
|
||||||
.stdout(process::Stdio::piped())
|
|
||||||
.stderr(process::Stdio::piped())
|
|
||||||
.args(["--dev", "-d"])
|
|
||||||
.arg(tmpdir.path())
|
|
||||||
.arg("--database")
|
|
||||||
.arg("paritydb-experimental")
|
|
||||||
.arg("--no-hardware-benchmarks")
|
|
||||||
.spawn()
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let (ws_url, _) = common::find_ws_url_from_output(cmd.stderr.take().unwrap());
|
// Let it produce 1 block.
|
||||||
|
common::wait_n_finalized_blocks(1, &ws_url).await;
|
||||||
|
|
||||||
// Let it produce 1 block.
|
// Send SIGINT to node.
|
||||||
common::wait_n_finalized_blocks(1, Duration::from_secs(60), &ws_url)
|
kill(Pid::from_raw(cmd.id().try_into().unwrap()), SIGINT).unwrap();
|
||||||
.await
|
// Wait for the node to handle it and exit.
|
||||||
.unwrap();
|
assert!(cmd.wait().unwrap().success());
|
||||||
|
assert!(tmpdir.path().join("chains/rococo_dev").exists());
|
||||||
|
assert!(tmpdir.path().join("chains/rococo_dev/paritydb/full").exists());
|
||||||
|
assert!(tmpdir.path().join("chains/rococo_dev/paritydb/parachains").exists());
|
||||||
|
|
||||||
// Send SIGINT to node.
|
// Purge chain
|
||||||
kill(Pid::from_raw(cmd.id().try_into().unwrap()), SIGINT).unwrap();
|
let status = Command::new(cargo_bin("polkadot"))
|
||||||
// Wait for the node to handle it and exit.
|
.args(["purge-chain", "--dev", "-d"])
|
||||||
assert!(common::wait_for(&mut cmd, 30).map(|x| x.success()).unwrap_or_default());
|
.arg(tmpdir.path())
|
||||||
assert!(tmpdir.path().join("chains/polkadot_dev").exists());
|
.arg("--database")
|
||||||
assert!(tmpdir.path().join("chains/polkadot_dev/paritydb/full").exists());
|
.arg("paritydb-experimental")
|
||||||
assert!(tmpdir.path().join("chains/polkadot_dev/paritydb/parachains").exists());
|
.arg("-y")
|
||||||
|
.status()
|
||||||
|
.unwrap();
|
||||||
|
assert!(status.success());
|
||||||
|
|
||||||
// Purge chain
|
// Make sure that the chain folder exists, but `db/full` is deleted.
|
||||||
let status = Command::new(cargo_bin("polkadot"))
|
assert!(tmpdir.path().join("chains/rococo_dev").exists());
|
||||||
.args(["purge-chain", "--dev", "-d"])
|
assert!(!tmpdir.path().join("chains/rococo_dev/paritydb/full").exists());
|
||||||
.arg(tmpdir.path())
|
// Parachains removal requires calling "purge-chain --parachains".
|
||||||
.arg("--database")
|
assert!(tmpdir.path().join("chains/rococo_dev/paritydb/parachains").exists());
|
||||||
.arg("paritydb-experimental")
|
})
|
||||||
.arg("-y")
|
.await;
|
||||||
.status()
|
|
||||||
.unwrap();
|
|
||||||
assert!(status.success());
|
|
||||||
|
|
||||||
// Make sure that the chain folder exists, but `db/full` is deleted.
|
|
||||||
assert!(tmpdir.path().join("chains/polkadot_dev").exists());
|
|
||||||
assert!(!tmpdir.path().join("chains/polkadot_dev/paritydb/full").exists());
|
|
||||||
// Parachains removal requires calling "purge-chain --parachains".
|
|
||||||
assert!(tmpdir.path().join("chains/polkadot_dev/paritydb/parachains").exists());
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,10 +15,7 @@
|
|||||||
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
|
// along with Substrate. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
use assert_cmd::cargo::cargo_bin;
|
use assert_cmd::cargo::cargo_bin;
|
||||||
use std::{
|
use std::process::{self, Command};
|
||||||
process::{self, Command},
|
|
||||||
time::Duration,
|
|
||||||
};
|
|
||||||
use tempfile::tempdir;
|
use tempfile::tempdir;
|
||||||
|
|
||||||
pub mod common;
|
pub mod common;
|
||||||
@@ -49,17 +46,13 @@ async fn running_the_node_works_and_can_be_interrupted() {
|
|||||||
let (ws_url, _) = common::find_ws_url_from_output(cmd.stderr.take().unwrap());
|
let (ws_url, _) = common::find_ws_url_from_output(cmd.stderr.take().unwrap());
|
||||||
|
|
||||||
// Let it produce three blocks.
|
// Let it produce three blocks.
|
||||||
common::wait_n_finalized_blocks(3, Duration::from_secs(60), &ws_url)
|
common::wait_n_finalized_blocks(3, &ws_url).await;
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
assert!(cmd.try_wait().unwrap().is_none(), "the process should still be running");
|
assert!(cmd.try_wait().unwrap().is_none(), "the process should still be running");
|
||||||
kill(Pid::from_raw(cmd.id().try_into().unwrap()), signal).unwrap();
|
kill(Pid::from_raw(cmd.id().try_into().unwrap()), signal).unwrap();
|
||||||
assert_eq!(
|
assert!(
|
||||||
common::wait_for(&mut cmd, 30).map(|x| x.success()),
|
cmd.wait().unwrap().success(),
|
||||||
Some(true),
|
"the process must exit gracefully after signal {signal}",
|
||||||
"the process must exit gracefully after signal {}",
|
|
||||||
signal,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user