Unverified Commit 2f5d4270 authored by Kian Paimani's avatar Kian Paimani Committed by GitHub
Browse files

Migration testing CLI (#2447)



* Template

* Midway..

* Make all 3 runtimes work

* Update node/service/Cargo.toml

* undo brach updates

* fix with latest version

* Update runtime/kusama/src/lib.rs
Co-authored-by: Shawn Tabrizi's avatarShawn Tabrizi <shawntabrizi@gmail.com>

* Update runtime/rococo/src/lib.rs
Co-authored-by: default avatarBastian Köcher <bkchr@users.noreply.github.com>

* Final nits

* Update runtime/kusama/src/lib.rs
Co-authored-by: thiolliere's avatarGuillaume Thiolliere <gui.thiolliere@gmail.com>
Co-authored-by: Shawn Tabrizi's avatarShawn Tabrizi <shawntabrizi@gmail.com>
Co-authored-by: default avatarBastian Köcher <bkchr@users.noreply.github.com>
Co-authored-by: thiolliere's avatarGuillaume Thiolliere <gui.thiolliere@gmail.com>
parent c66049dd
Pipeline #125597 canceled with stages
in 5 minutes and 42 seconds
......@@ -1778,6 +1778,18 @@ dependencies = [
"sp-api",
]
[[package]]
name = "frame-try-runtime"
version = "0.9.0"
source = "git+https://github.com/paritytech/substrate?branch=master#904495bc14eff5171fca5912247e772948439411"
dependencies = [
"frame-support",
"parity-scale-codec",
"sp-api",
"sp-runtime",
"sp-std",
]
[[package]]
name = "fs-swap"
version = "0.2.5"
......@@ -2634,6 +2646,7 @@ checksum = "489b9c612e60c766f751ab40fcb43cbb55a1e10bb44a9b4307ed510ca598cbd7"
dependencies = [
"failure",
"futures 0.1.29",
"hyper 0.12.35",
"jsonrpc-core",
"jsonrpc-pubsub",
"log",
......@@ -2775,6 +2788,7 @@ dependencies = [
"frame-system",
"frame-system-benchmarking",
"frame-system-rpc-runtime-api",
"frame-try-runtime",
"hex-literal",
"libsecp256k1",
"log",
......@@ -5137,6 +5151,7 @@ dependencies = [
"substrate-build-script-utils",
"thiserror",
"tracing-futures",
"try-runtime-cli",
"wasm-bindgen",
"wasm-bindgen-futures",
]
......@@ -5709,6 +5724,7 @@ dependencies = [
"frame-system",
"frame-system-benchmarking",
"frame-system-rpc-runtime-api",
"frame-try-runtime",
"hex-literal",
"libsecp256k1",
"log",
......@@ -6714,6 +6730,24 @@ dependencies = [
"winapi 0.3.9",
]
[[package]]
name = "remote-externalities"
version = "0.9.0"
source = "git+https://github.com/paritytech/substrate?branch=master#904495bc14eff5171fca5912247e772948439411"
dependencies = [
"bincode",
"env_logger 0.8.2",
"futures 0.1.29",
"hex-literal",
"jsonrpc-core-client",
"log",
"sc-rpc",
"sc-rpc-api",
"sp-core",
"sp-io",
"tokio 0.1.22",
]
[[package]]
name = "remove_dir_all"
version = "0.5.3"
......@@ -9834,6 +9868,28 @@ version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e604eb7b43c06650e854be16a2a03155743d3752dd1c943f6829e26b7a36e382"
[[package]]
name = "try-runtime-cli"
version = "0.9.0"
source = "git+https://github.com/paritytech/substrate?branch=master#904495bc14eff5171fca5912247e772948439411"
dependencies = [
"frame-try-runtime",
"log",
"parity-scale-codec",
"remote-externalities",
"sc-cli",
"sc-client-api",
"sc-executor",
"sc-service",
"sp-api",
"sp-blockchain",
"sp-core",
"sp-externalities",
"sp-runtime",
"sp-state-machine",
"structopt",
]
[[package]]
name = "twox-hash"
version = "1.5.0"
......@@ -10447,6 +10503,7 @@ dependencies = [
"frame-system",
"frame-system-benchmarking",
"frame-system-rpc-runtime-api",
"frame-try-runtime",
"hex-literal",
"libsecp256k1",
"log",
......
......@@ -92,6 +92,7 @@ panic = "unwind"
runtime-benchmarks=["cli/runtime-benchmarks"]
real-overseer=["cli/real-overseer"]
approval-checking=["real-overseer", "service/approval-checking"]
try-runtime = ["cli/try-runtime"]
# Configuration for building a .deb package - for use with `cargo-deb`
[package.metadata.deb]
......
......@@ -27,6 +27,7 @@ polkadot-parachain = { path = "../parachain", optional = true }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
tracing-futures = "0.2.4"
frame-benchmarking-cli = { git = "https://github.com/paritytech/substrate", branch = "master", optional = true }
try-runtime-cli = { git = "https://github.com/paritytech/substrate", branch = "master", optional = true }
sc-cli = { git = "https://github.com/paritytech/substrate", branch = "master", optional = true }
sc-service = { git = "https://github.com/paritytech/substrate", branch = "master", optional = true }
browser-utils = { package = "substrate-browser-utils", git = "https://github.com/paritytech/substrate", branch = "master", optional = true }
......@@ -47,6 +48,7 @@ cli = [
"sc-cli",
"sc-service",
"frame-benchmarking-cli",
"try-runtime-cli",
]
browser = [
"wasm-bindgen",
......@@ -58,3 +60,4 @@ runtime-benchmarks = [ "service/runtime-benchmarks" ]
trie-memory-tracker = [ "sp-trie/memory-tracker" ]
full-node = [ "service/full-node" ]
real-overseer = [ "service/real-overseer" ]
try-runtime = [ "service/try-runtime" ]
......@@ -46,13 +46,17 @@ pub enum Subcommand {
#[structopt(name = "validation-worker", setting = structopt::clap::AppSettings::Hidden)]
ValidationWorker(ValidationWorkerCommand),
/// The custom benchmark subcommmand benchmarking runtime pallets.
/// The custom benchmark subcommand benchmarking runtime pallets.
#[structopt(
name = "benchmark",
about = "Benchmark runtime pallets."
)]
Benchmark(frame_benchmarking_cli::BenchmarkCmd),
/// Testing subcommand for runtime testing and trying.
#[cfg(feature = "try-runtime")]
TryRuntime(try_runtime_cli::TryRuntimeCmd),
/// Key management cli utilities
Key(sc_cli::KeySubcommand),
}
......
......@@ -245,7 +245,7 @@ pub fn run() -> Result<()> {
Ok(runner.async_run(|mut config| {
let (client, backend, _, task_manager) = service::new_chain_ops(&mut config, None)?;
Ok((cmd.run(client, backend).map_err(Error::SubstrateCli),task_manager))
Ok((cmd.run(client, backend).map_err(Error::SubstrateCli), task_manager))
})?)
},
Some(Subcommand::ValidationWorker(cmd)) => {
......@@ -276,6 +276,31 @@ pub fn run() -> Result<()> {
})?)
},
Some(Subcommand::Key(cmd)) => Ok(cmd.run(&cli)?),
#[cfg(feature = "try-runtime")]
Some(Subcommand::TryRuntime(cmd)) => {
let runner = cli.create_runner(cmd)?;
let chain_spec = &runner.config().chain_spec;
set_default_ss58_version(chain_spec);
runner.async_run(|config| {
use sc_service::TaskManager;
let registry = config.prometheus_config.as_ref().map(|cfg| &cfg.registry);
let task_manager = TaskManager::new(
config.task_executor.clone(),
registry,
).map_err(|e| Error::SubstrateService(sc_service::Error::Prometheus(e)))?;
Ok((
cmd.run::<
service::kusama_runtime::Block,
service::KusamaExecutor,
>(config).map_err(Error::SubstrateCli),
task_manager
))
// NOTE: we fetch only the block number from the block type, the chance of disparity
// between kusama's and polkadot's block number is small enough to overlook this.
})
}
}?;
Ok(())
}
......@@ -117,6 +117,11 @@ runtime-benchmarks = [
"westend-runtime/runtime-benchmarks",
"rococo-runtime/runtime-benchmarks"
]
try-runtime = [
"polkadot-runtime/try-runtime",
"kusama-runtime/try-runtime",
"westend-runtime/try-runtime",
]
real-overseer = [
"polkadot-availability-bitfield-distribution",
......
......@@ -58,7 +58,7 @@ pallet-session = { git = "https://github.com/paritytech/substrate", branch = "ma
pallet-society = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
frame-support = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-staking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-staking-reward-curve = { package = "pallet-staking-reward-curve", git = "https://github.com/paritytech/substrate", branch = "master" }
pallet-staking-reward-curve = { git = "https://github.com/paritytech/substrate", branch = "master" }
frame-system = {git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
frame-system-rpc-runtime-api = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
pallet-timestamp = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
......@@ -68,6 +68,7 @@ pallet-utility = { git = "https://github.com/paritytech/substrate", branch = "ma
pallet-vesting = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true }
frame-try-runtime = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true }
pallet-offences-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true }
pallet-session-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true }
frame-system-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true }
......@@ -182,7 +183,10 @@ runtime-benchmarks = [
"frame-system-benchmarking",
"hex-literal",
]
try-runtime = [
"frame-executive/try-runtime",
"frame-try-runtime",
]
# When enabled, the runtime api will not be build.
#
# This is required by Cumulus to access certain types of the
......
......@@ -1067,7 +1067,6 @@ pub type Executive = frame_executive::Executive<
frame_system::ChainContext<Runtime>,
Runtime,
AllModules,
()
>;
/// The payload being signed in the transactions.
pub type SignedPayload = generic::SignedPayload<Call, SignedExtra>;
......@@ -1316,6 +1315,15 @@ sp_api::impl_runtime_apis! {
}
}
#[cfg(feature = "try-runtime")]
impl frame_try_runtime::TryRuntime<Block> for Runtime {
fn on_runtime_upgrade() -> Result<(Weight, Weight), sp_runtime::RuntimeString> {
frame_support::debug::RuntimeLogger::init();
let weight = Executive::try_runtime_upgrade()?;
Ok((weight, BlockWeights::get().max_block))
}
}
#[cfg(feature = "runtime-benchmarks")]
impl frame_benchmarking::Benchmark<Block> for Runtime {
fn dispatch_benchmark(
......
......@@ -66,6 +66,7 @@ pallet-vesting = { git = "https://github.com/paritytech/substrate", branch = "ma
pallet-utility = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true }
frame-try-runtime = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true }
frame-system-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true }
pallet-offences-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true }
pallet-session-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true }
......@@ -177,7 +178,10 @@ runtime-benchmarks = [
"frame-system-benchmarking",
"hex-literal",
]
try-runtime = [
"frame-executive/try-runtime",
"frame-try-runtime",
]
# When enabled, the runtime api will not be build.
#
# This is required by Cumulus to access certain types of the
......
......@@ -1311,6 +1311,15 @@ sp_api::impl_runtime_apis! {
}
}
#[cfg(feature = "try-runtime")]
impl frame_try_runtime::TryRuntime<Block> for Runtime {
fn on_runtime_upgrade() -> Result<(Weight, Weight), sp_runtime::RuntimeString> {
frame_support::debug::RuntimeLogger::init();
let weight = Executive::try_runtime_upgrade()?;
Ok((weight, BlockWeights::get().max_block))
}
}
#[cfg(feature = "runtime-benchmarks")]
impl frame_benchmarking::Benchmark<Block> for Runtime {
fn dispatch_benchmark(
......
......@@ -67,6 +67,7 @@ pallet-utility = { git = "https://github.com/paritytech/substrate", branch = "ma
pallet-vesting = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false }
frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true }
frame-try-runtime = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true }
frame-system-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true }
pallet-offences-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true }
pallet-session-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master", default-features = false, optional = true }
......@@ -179,7 +180,10 @@ runtime-benchmarks = [
"frame-system-benchmarking",
"hex-literal",
]
try-runtime = [
"frame-executive/try-runtime",
"frame-try-runtime",
]
# When enabled, the runtime api will not be build.
#
# This is required by Cumulus to access certain types of the
......
......@@ -774,7 +774,6 @@ pub type Executive = frame_executive::Executive<
frame_system::ChainContext<Runtime>,
Runtime,
AllModules,
()
>;
/// The payload being signed in transactions.
pub type SignedPayload = generic::SignedPayload<Call, SignedExtra>;
......@@ -1031,6 +1030,15 @@ sp_api::impl_runtime_apis! {
}
}
#[cfg(feature = "try-runtime")]
impl frame_try_runtime::TryRuntime<Block> for Runtime {
fn on_runtime_upgrade() -> Result<(Weight, Weight), sp_runtime::RuntimeString> {
frame_support::debug::RuntimeLogger::init();
let weight = Executive::try_runtime_upgrade()?;
Ok((weight, BlockWeights::get().max_block))
}
}
#[cfg(feature = "runtime-benchmarks")]
impl frame_benchmarking::Benchmark<Block> for Runtime {
fn dispatch_benchmark(
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment