mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-25 01:17:57 +00:00
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:
@@ -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" }
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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())?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user