difftreelog
feat try-runtime subcommand
in: master
7 files changed
node/cli/Cargo.tomldiffbeforeafterboth--- a/node/cli/Cargo.toml
+++ b/node/cli/Cargo.toml
@@ -22,6 +22,10 @@
git = "https://github.com/paritytech/substrate"
branch = "polkadot-v0.9.20"
+[dependencies.try-runtime-cli]
+git = 'https://github.com/paritytech/substrate.git'
+branch = 'polkadot-v0.9.17'
+
[dependencies.pallet-transaction-payment-rpc]
git = "https://github.com/paritytech/substrate"
branch = "polkadot-v0.9.20"
@@ -318,3 +322,4 @@
'unique-runtime/runtime-benchmarks',
'polkadot-service/runtime-benchmarks',
]
+try-runtime = []
node/cli/src/cli.rsdiffbeforeafterboth--- a/node/cli/src/cli.rs
+++ b/node/cli/src/cli.rs
@@ -55,6 +55,9 @@
/// The custom benchmark subcommmand benchmarking runtime pallets.
#[clap(subcommand)]
Benchmark(frame_benchmarking_cli::BenchmarkCmd),
+
+ /// Try runtime
+ TryRuntime(try_runtime_cli::TryRuntimeCmd),
}
/// Command for exporting the genesis state of the parachain
node/cli/src/command.rsdiffbeforeafterboth--- a/node/cli/src/command.rs
+++ b/node/cli/src/command.rs
@@ -49,6 +49,7 @@
use codec::Encode;
use cumulus_primitives_core::ParaId;
use cumulus_client_service::genesis::generate_genesis_block;
+use std::{future::Future, pin::Pin};
use log::info;
use polkadot_parachain::primitives::AccountIdConversion;
use sc_cli::{
@@ -413,6 +414,41 @@
Some(Subcommand::Benchmark(..)) => {
Err("benchmarking is only available with unique runtime enabled".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 =
+ sc_service::TaskManager::new(runner.config().tokio_handle.clone(), *registry)
+ .map_err(|e| format!("Error: {:?}", e))?;
+
+ runner.async_run(|config| -> Result<(Pin<Box<dyn Future<Output = _>>>, _)> {
+ Ok((
+ match config.chain_spec.runtime_id() {
+ #[cfg(feature = "unique-runtime")]
+ RuntimeId::Unique => Box::pin(cmd.run::<Block, UniqueRuntimeExecutor>(config)),
+
+ #[cfg(feature = "quartz-runtime")]
+ RuntimeId::Quartz => Box::pin(cmd.run::<Block, QuartzRuntimeExecutor>(config)),
+
+ RuntimeId::Opal => {
+ Box::pin(cmd.run::<Block, OpalRuntimeExecutor>(config))
+ }
+ RuntimeId::Unknown(chain) => return Err(no_runtime_err!(chain).into()),
+ },
+ task_manager,
+ ))
+ })
+ } else {
+ Err("Try-runtime must be enabled by `--features try-runtime`.".into())
+ }
+ }
None => {
let runner = cli.create_runner(&cli.run.normalize())?;
let collator_options = cli.run.collator_options();
runtime/common/src/runtime_apis.rsdiffbeforeafterboth426 }426 }427 }427 }428429 #[cfg(feature = "try-runtime")]430 impl frame_try_runtime::TryRuntime<Block> for Runtime {431 fn on_runtime_upgrade() -> (Weight, Weight) {432 log::info!("try-runtime::on_runtime_upgrade unique-chain.");433 let weight = Executive::try_runtime_upgrade().unwrap();434 (weight, RuntimeBlockWeights::get().max_block)435 }436437 fn execute_block_no_check(block: Block) -> Weight {438 Executive::execute_block_no_check(block)439 }440 }428 }441 }429 }442 }430}443}runtime/opal/Cargo.tomldiffbeforeafterboth--- a/runtime/opal/Cargo.toml
+++ b/runtime/opal/Cargo.toml
@@ -38,6 +38,11 @@
'sp-runtime/runtime-benchmarks',
'xcm-builder/runtime-benchmarks',
]
+try-runtime = [
+ 'frame-try-runtime',
+ 'frame-executive/try-runtime',
+ 'frame-system/try-runtime',
+]
std = [
'codec/std',
'cumulus-pallet-aura-ext/std',
@@ -46,6 +51,7 @@
'cumulus-pallet-xcmp-queue/std',
'cumulus-primitives-core/std',
'cumulus-primitives-utility/std',
+ 'frame-try-runtime/std',
'frame-executive/std',
'frame-support/std',
'frame-system/std',
@@ -121,6 +127,12 @@
optional = true
branch = "polkadot-v0.9.20"
+[dependencies.frame-try-runtime]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+optional = true
+branch = 'polkadot-v0.9.17'
+
[dependencies.frame-executive]
default-features = false
git = "https://github.com/paritytech/substrate"
@@ -375,6 +387,7 @@
# local dependencies
[dependencies]
+log = { version = "0.4.16", default-features = false }
unique-runtime-common = { path = "../common", default-features = false }
scale-info = { version = "2.0.1", default-features = false, features = [
"derive",
runtime/quartz/Cargo.tomldiffbeforeafterboth--- a/runtime/quartz/Cargo.toml
+++ b/runtime/quartz/Cargo.toml
@@ -38,6 +38,11 @@
'sp-runtime/runtime-benchmarks',
'xcm-builder/runtime-benchmarks',
]
+try-runtime = [
+ 'frame-try-runtime',
+ 'frame-executive/try-runtime',
+ 'frame-system/try-runtime',
+]
std = [
'codec/std',
'cumulus-pallet-aura-ext/std',
@@ -46,6 +51,7 @@
'cumulus-pallet-xcmp-queue/std',
'cumulus-primitives-core/std',
'cumulus-primitives-utility/std',
+ 'frame-try-runtime/std',
'frame-executive/std',
'frame-support/std',
'frame-system/std',
@@ -121,6 +127,12 @@
optional = true
branch = "polkadot-v0.9.20"
+[dependencies.frame-try-runtime]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+optional = true
+branch = 'polkadot-v0.9.17'
+
[dependencies.frame-executive]
default-features = false
git = "https://github.com/paritytech/substrate"
@@ -375,6 +387,7 @@
# local dependencies
[dependencies]
+log = { version = "0.4.16", default-features = false }
unique-runtime-common = { path = "../common", default-features = false }
scale-info = { version = "2.0.1", default-features = false, features = [
"derive",
runtime/unique/Cargo.tomldiffbeforeafterboth--- a/runtime/unique/Cargo.toml
+++ b/runtime/unique/Cargo.toml
@@ -38,6 +38,11 @@
'sp-runtime/runtime-benchmarks',
'xcm-builder/runtime-benchmarks',
]
+try-runtime = [
+ 'frame-try-runtime',
+ 'frame-executive/try-runtime',
+ 'frame-system/try-runtime',
+]
std = [
'codec/std',
'cumulus-pallet-aura-ext/std',
@@ -46,6 +51,7 @@
'cumulus-pallet-xcmp-queue/std',
'cumulus-primitives-core/std',
'cumulus-primitives-utility/std',
+ 'frame-try-runtime/std',
'frame-executive/std',
'frame-support/std',
'frame-system/std',
@@ -121,6 +127,12 @@
optional = true
branch = "polkadot-v0.9.20"
+[dependencies.frame-try-runtime]
+default-features = false
+git = 'https://github.com/paritytech/substrate.git'
+optional = true
+branch = 'polkadot-v0.9.17'
+
[dependencies.frame-executive]
default-features = false
git = "https://github.com/paritytech/substrate"
@@ -375,6 +387,7 @@
# local dependencies
[dependencies]
+log = { version = "0.4.16", default-features = false }
unique-runtime-common = { path = "../common", default-features = false }
scale-info = { version = "2.0.1", default-features = false, features = [
"derive",