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.rsdiffbeforeafterboth49use codec::Encode;49use codec::Encode;50use cumulus_primitives_core::ParaId;50use cumulus_primitives_core::ParaId;51use cumulus_client_service::genesis::generate_genesis_block;51use cumulus_client_service::genesis::generate_genesis_block;52use std::{future::Future, pin::Pin};52use log::info;53use log::info;53use polkadot_parachain::primitives::AccountIdConversion;54use polkadot_parachain::primitives::AccountIdConversion;54use sc_cli::{55use sc_cli::{413 Some(Subcommand::Benchmark(..)) => {414 Some(Subcommand::Benchmark(..)) => {414 Err("benchmarking is only available with unique runtime enabled".into())415 Err("benchmarking is only available with unique runtime enabled".into())415 }416 }417 Some(Subcommand::TryRuntime(cmd)) => {418 if cfg!(feature = "try-runtime") {419 let runner = cli.create_runner(cmd)?;420421 // grab the task manager.422 let registry = &runner423 .config()424 .prometheus_config425 .as_ref()426 .map(|cfg| &cfg.registry);427 let task_manager =428 sc_service::TaskManager::new(runner.config().tokio_handle.clone(), *registry)429 .map_err(|e| format!("Error: {:?}", e))?;430431 runner.async_run(|config| -> Result<(Pin<Box<dyn Future<Output = _>>>, _)> {432 Ok((433 match config.chain_spec.runtime_id() {434 #[cfg(feature = "unique-runtime")]435 RuntimeId::Unique => Box::pin(cmd.run::<Block, UniqueRuntimeExecutor>(config)),436437 #[cfg(feature = "quartz-runtime")]438 RuntimeId::Quartz => Box::pin(cmd.run::<Block, QuartzRuntimeExecutor>(config)),439440 RuntimeId::Opal => {441 Box::pin(cmd.run::<Block, OpalRuntimeExecutor>(config))442 }443 RuntimeId::Unknown(chain) => return Err(no_runtime_err!(chain).into()),444 },445 task_manager,446 ))447 })448 } else {449 Err("Try-runtime must be enabled by `--features try-runtime`.".into())450 }451 }416 None => {452 None => {417 let runner = cli.create_runner(&cli.run.normalize())?;453 let runner = cli.create_runner(&cli.run.normalize())?;418 let collator_options = cli.run.collator_options();454 let collator_options = cli.run.collator_options();runtime/common/src/runtime_apis.rsdiffbeforeafterboth--- a/runtime/common/src/runtime_apis.rs
+++ b/runtime/common/src/runtime_apis.rs
@@ -425,6 +425,19 @@
Ok(batches)
}
}
+
+ #[cfg(feature = "try-runtime")]
+ impl frame_try_runtime::TryRuntime<Block> for Runtime {
+ fn on_runtime_upgrade() -> (Weight, Weight) {
+ log::info!("try-runtime::on_runtime_upgrade unique-chain.");
+ let weight = Executive::try_runtime_upgrade().unwrap();
+ (weight, RuntimeBlockWeights::get().max_block)
+ }
+
+ fn execute_block_no_check(block: Block) -> Weight {
+ Executive::execute_block_no_check(block)
+ }
+ }
}
}
}
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",