git.delta.rocks / unique-network / refs/commits / c35f6c8d35c5

difftreelog

feat try-runtime subcommand

Yaroslav Bolyukin2022-04-07parent: #8da8a84.patch.diff
in: master

7 files changed

modifiednode/cli/Cargo.tomldiffbeforeafterboth
22git = "https://github.com/paritytech/substrate"22git = "https://github.com/paritytech/substrate"
23branch = "polkadot-v0.9.20"23branch = "polkadot-v0.9.20"
24
25[dependencies.try-runtime-cli]
26git = 'https://github.com/paritytech/substrate.git'
27branch = 'polkadot-v0.9.17'
2428
25[dependencies.pallet-transaction-payment-rpc]29[dependencies.pallet-transaction-payment-rpc]
26git = "https://github.com/paritytech/substrate"30git = "https://github.com/paritytech/substrate"
318 'unique-runtime/runtime-benchmarks',322 'unique-runtime/runtime-benchmarks',
319 'polkadot-service/runtime-benchmarks',323 'polkadot-service/runtime-benchmarks',
320]324]
325try-runtime = []
321326
modifiednode/cli/src/cli.rsdiffbeforeafterboth
56 #[clap(subcommand)]56 #[clap(subcommand)]
57 Benchmark(frame_benchmarking_cli::BenchmarkCmd),57 Benchmark(frame_benchmarking_cli::BenchmarkCmd),
58
59 /// Try runtime
60 TryRuntime(try_runtime_cli::TryRuntimeCmd),
58}61}
5962
60/// Command for exporting the genesis state of the parachain63/// Command for exporting the genesis state of the parachain
modifiednode/cli/src/command.rsdiffbeforeafterboth
49use 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)?;
420
421 // grab the task manager.
422 let registry = &runner
423 .config()
424 .prometheus_config
425 .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))?;
430
431 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)),
436
437 #[cfg(feature = "quartz-runtime")]
438 RuntimeId::Quartz => Box::pin(cmd.run::<Block, QuartzRuntimeExecutor>(config)),
439
440 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();
modifiedruntime/common/src/runtime_apis.rsdiffbeforeafterboth
426 }426 }
427 }427 }
428
429 #[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 }
436
437 fn execute_block_no_check(block: Block) -> Weight {
438 Executive::execute_block_no_check(block)
439 }
440 }
428 }441 }
429 }442 }
430}443}
modifiedruntime/opal/Cargo.tomldiffbeforeafterboth
38 'sp-runtime/runtime-benchmarks',38 'sp-runtime/runtime-benchmarks',
39 'xcm-builder/runtime-benchmarks',39 'xcm-builder/runtime-benchmarks',
40]40]
41try-runtime = [
42 'frame-try-runtime',
43 'frame-executive/try-runtime',
44 'frame-system/try-runtime',
45]
41std = [46std = [
42 'codec/std',47 'codec/std',
43 'cumulus-pallet-aura-ext/std',48 'cumulus-pallet-aura-ext/std',
46 'cumulus-pallet-xcmp-queue/std',51 'cumulus-pallet-xcmp-queue/std',
47 'cumulus-primitives-core/std',52 'cumulus-primitives-core/std',
48 'cumulus-primitives-utility/std',53 'cumulus-primitives-utility/std',
54 'frame-try-runtime/std',
49 'frame-executive/std',55 'frame-executive/std',
50 'frame-support/std',56 'frame-support/std',
51 'frame-system/std',57 'frame-system/std',
121optional = true127optional = true
122branch = "polkadot-v0.9.20"128branch = "polkadot-v0.9.20"
129
130[dependencies.frame-try-runtime]
131default-features = false
132git = 'https://github.com/paritytech/substrate.git'
133optional = true
134branch = 'polkadot-v0.9.17'
123135
124[dependencies.frame-executive]136[dependencies.frame-executive]
125default-features = false137default-features = false
375# local dependencies387# local dependencies
376388
377[dependencies]389[dependencies]
390log = { version = "0.4.16", default-features = false }
378unique-runtime-common = { path = "../common", default-features = false }391unique-runtime-common = { path = "../common", default-features = false }
379scale-info = { version = "2.0.1", default-features = false, features = [392scale-info = { version = "2.0.1", default-features = false, features = [
380 "derive",393 "derive",
modifiedruntime/quartz/Cargo.tomldiffbeforeafterboth
38 'sp-runtime/runtime-benchmarks',38 'sp-runtime/runtime-benchmarks',
39 'xcm-builder/runtime-benchmarks',39 'xcm-builder/runtime-benchmarks',
40]40]
41try-runtime = [
42 'frame-try-runtime',
43 'frame-executive/try-runtime',
44 'frame-system/try-runtime',
45]
41std = [46std = [
42 'codec/std',47 'codec/std',
43 'cumulus-pallet-aura-ext/std',48 'cumulus-pallet-aura-ext/std',
46 'cumulus-pallet-xcmp-queue/std',51 'cumulus-pallet-xcmp-queue/std',
47 'cumulus-primitives-core/std',52 'cumulus-primitives-core/std',
48 'cumulus-primitives-utility/std',53 'cumulus-primitives-utility/std',
54 'frame-try-runtime/std',
49 'frame-executive/std',55 'frame-executive/std',
50 'frame-support/std',56 'frame-support/std',
51 'frame-system/std',57 'frame-system/std',
121optional = true127optional = true
122branch = "polkadot-v0.9.20"128branch = "polkadot-v0.9.20"
129
130[dependencies.frame-try-runtime]
131default-features = false
132git = 'https://github.com/paritytech/substrate.git'
133optional = true
134branch = 'polkadot-v0.9.17'
123135
124[dependencies.frame-executive]136[dependencies.frame-executive]
125default-features = false137default-features = false
375# local dependencies387# local dependencies
376388
377[dependencies]389[dependencies]
390log = { version = "0.4.16", default-features = false }
378unique-runtime-common = { path = "../common", default-features = false }391unique-runtime-common = { path = "../common", default-features = false }
379scale-info = { version = "2.0.1", default-features = false, features = [392scale-info = { version = "2.0.1", default-features = false, features = [
380 "derive",393 "derive",
modifiedruntime/unique/Cargo.tomldiffbeforeafterboth
38 'sp-runtime/runtime-benchmarks',38 'sp-runtime/runtime-benchmarks',
39 'xcm-builder/runtime-benchmarks',39 'xcm-builder/runtime-benchmarks',
40]40]
41try-runtime = [
42 'frame-try-runtime',
43 'frame-executive/try-runtime',
44 'frame-system/try-runtime',
45]
41std = [46std = [
42 'codec/std',47 'codec/std',
43 'cumulus-pallet-aura-ext/std',48 'cumulus-pallet-aura-ext/std',
46 'cumulus-pallet-xcmp-queue/std',51 'cumulus-pallet-xcmp-queue/std',
47 'cumulus-primitives-core/std',52 'cumulus-primitives-core/std',
48 'cumulus-primitives-utility/std',53 'cumulus-primitives-utility/std',
54 'frame-try-runtime/std',
49 'frame-executive/std',55 'frame-executive/std',
50 'frame-support/std',56 'frame-support/std',
51 'frame-system/std',57 'frame-system/std',
121optional = true127optional = true
122branch = "polkadot-v0.9.20"128branch = "polkadot-v0.9.20"
129
130[dependencies.frame-try-runtime]
131default-features = false
132git = 'https://github.com/paritytech/substrate.git'
133optional = true
134branch = 'polkadot-v0.9.17'
123135
124[dependencies.frame-executive]136[dependencies.frame-executive]
125default-features = false137default-features = false
375# local dependencies387# local dependencies
376388
377[dependencies]389[dependencies]
390log = { version = "0.4.16", default-features = false }
378unique-runtime-common = { path = "../common", default-features = false }391unique-runtime-common = { path = "../common", default-features = false }
379scale-info = { version = "2.0.1", default-features = false, features = [392scale-info = { version = "2.0.1", default-features = false, features = [
380 "derive",393 "derive",