Integrate try-runtime into cumulus (#793)

* almost integrate

* revert branch changes

* remove extra deps

* some review comments'

* Fix a bunch of stuff

* Update parachain-template/node/Cargo.toml

Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>

* Fix

* Fix

* fix benchmark

* fmt

* Remove wrong bench test

Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>
This commit is contained in:
Kian Paimani
2021-12-02 14:00:54 +01:00
committed by GitHub
parent ca81203b83
commit e70f7fd016
23 changed files with 189 additions and 10 deletions
+3
View File
@@ -21,6 +21,7 @@ path = "src/main.rs"
[features]
runtime-benchmarks = ["parachain-template-runtime/runtime-benchmarks"]
try-runtime = [ "parachain-template-runtime/try-runtime" ]
[dependencies]
derive_more = "0.99.2"
@@ -39,6 +40,7 @@ parachain-template-runtime = { path = "../runtime" }
# Substrate Dependencies
frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "master" }
frame-benchmarking-cli = { git = "https://github.com/paritytech/substrate", branch = "master" }
try-runtime-cli = { git = "https://github.com/paritytech/substrate", branch = "master" }
pallet-transaction-payment-rpc = { git = "https://github.com/paritytech/substrate", branch = "master" }
@@ -92,3 +94,4 @@ polkadot-cli = { git = "https://github.com/paritytech/polkadot", branch = "maste
polkadot-parachain = { git = "https://github.com/paritytech/polkadot", branch = "master" }
polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch = "master" }
polkadot-service = { git = "https://github.com/paritytech/polkadot", branch = "master" }
+3
View File
@@ -37,6 +37,9 @@ pub enum Subcommand {
/// The custom benchmark subcommmand benchmarking runtime pallets.
#[structopt(name = "benchmark", about = "Benchmark runtime pallets.")]
Benchmark(frame_benchmarking_cli::BenchmarkCmd),
/// Try some testing command against a specified runtime state.
TryRuntime(try_runtime_cli::TryRuntimeCmd),
}
/// Command for exporting the genesis state of the parachain
+20 -1
View File
@@ -13,7 +13,10 @@ use sc_cli::{
ChainSpec, CliConfiguration, DefaultConfigurationValues, ImportParams, KeystoreParams,
NetworkParams, Result, RuntimeVersion, SharedParams, SubstrateCli,
};
use sc_service::config::{BasePath, PrometheusConfig};
use sc_service::{
config::{BasePath, PrometheusConfig},
TaskManager,
};
use sp_core::hexdisplay::HexDisplay;
use sp_runtime::traits::Block as BlockT;
use std::{io::Write, net::SocketAddr};
@@ -237,6 +240,22 @@ pub fn run() -> Result<()> {
You can enable it with `--features runtime-benchmarks`."
.into())
},
Some(Subcommand::TryRuntime(cmd)) =>
if cfg!(feature = "try-runtime") {
let runner = cli.create_runner(cmd)?;
// grab the task manager.
let registry = &runner.config().prometheus_config.as_ref().map(|cfg| &cfg.registry);
let task_manager =
TaskManager::new(runner.config().tokio_handle.clone(), *registry)
.map_err(|e| format!("Error: {:?}", e))?;
runner.async_run(|config| {
Ok((cmd.run::<Block, TemplateRuntimeExecutor>(config), task_manager))
})
} else {
Err("Try-runtime must be enabled by `--features try-runtime`.".into())
},
None => {
let runner = cli.create_runner(&cli.run.normalize())?;