diff --git a/Cargo.lock b/Cargo.lock index 256de785ce..3dbe8522a7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5423,6 +5423,7 @@ dependencies = [ "frame-system", "frame-system-benchmarking", "frame-system-rpc-runtime-api", + "frame-try-runtime", "hex", "log", "max-encoded-len", diff --git a/node/cli/src/command.rs b/node/cli/src/command.rs index 6540842dc9..99352e5c1b 100644 --- a/node/cli/src/command.rs +++ b/node/cli/src/command.rs @@ -415,20 +415,63 @@ pub fn run() -> Result<()> { #[cfg(feature = "try-runtime")] Some(Subcommand::TryRuntime(cmd)) => { let runner = cli.create_runner(cmd)?; - runner.async_run(|config| { - // we don't need any of the components of new_partial, just a runtime, or a task - // manager to do `async_run`. - let registry = config.prometheus_config.as_ref().map(|cfg| &cfg.registry); - let task_manager = - sc_service::TaskManager::new(config.task_executor.clone(), registry) - .map_err(|e| sc_cli::Error::Service(sc_service::Error::Prometheus(e)))?; - - // TODO: support all runtimes - Ok(( - cmd.run::(config), - task_manager, - )) - }) + let chain_spec = &runner.config().chain_spec; + match chain_spec { + #[cfg(feature = "moonriver-native")] + spec if spec.is_moonriver() => { + runner.async_run(|config| { + let registry = config.prometheus_config.as_ref().map(|cfg| &cfg.registry); + let task_manager = + sc_service::TaskManager::new(config.task_executor.clone(), registry) + .map_err(|e| { + sc_cli::Error::Service(sc_service::Error::Prometheus(e)) + })?; + + Ok(( + cmd.run::(config), + task_manager, + )) + }) + } + #[cfg(feature = "moonbeam-native")] + spec if spec.is_moonbeam() => runner.async_run(|config| { + let registry = config.prometheus_config.as_ref().map(|cfg| &cfg.registry); + let task_manager = + sc_service::TaskManager::new(config.task_executor.clone(), registry) + .map_err(|e| { + sc_cli::Error::Service(sc_service::Error::Prometheus(e)) + })?; + + Ok(( + cmd.run::( + config, + ), + task_manager, + )) + }), + #[cfg(feature = "moonbase-native")] + _ => { + runner.async_run(|config| { + // we don't need any of the components of new_partial, just a runtime, or a task + // manager to do `async_run`. + let registry = config.prometheus_config.as_ref().map(|cfg| &cfg.registry); + let task_manager = + sc_service::TaskManager::new(config.task_executor.clone(), registry) + .map_err(|e| { + sc_cli::Error::Service(sc_service::Error::Prometheus(e)) + })?; + + Ok(( + cmd.run::( + config, + ), + task_manager, + )) + }) + } + #[cfg(not(feature = "moonbase-native"))] + _ => panic!("invalid chain spec"), + } } #[cfg(not(feature = "try-runtime"))] Some(Subcommand::TryRuntime) => Err("TryRuntime wasn't enabled when building the node. \ diff --git a/pallets/author-mapping/Cargo.toml b/pallets/author-mapping/Cargo.toml index 1708de1830..3d809bb1bd 100644 --- a/pallets/author-mapping/Cargo.toml +++ b/pallets/author-mapping/Cargo.toml @@ -35,3 +35,4 @@ std = [ "frame-benchmarking/std", ] runtime-benchmarks = ["frame-benchmarking"] +try-runtime = ["frame-support/try-runtime"] diff --git a/pallets/ethereum-chain-id/Cargo.toml b/pallets/ethereum-chain-id/Cargo.toml index 1c47fdfd32..5942b67f61 100644 --- a/pallets/ethereum-chain-id/Cargo.toml +++ b/pallets/ethereum-chain-id/Cargo.toml @@ -19,3 +19,4 @@ std = [ "frame-support/std", "frame-system/std", ] +try-runtime = ["frame-support/try-runtime"] diff --git a/pallets/maintenance-mode/Cargo.toml b/pallets/maintenance-mode/Cargo.toml index 659c8c0ebc..5f15ade4b8 100644 --- a/pallets/maintenance-mode/Cargo.toml +++ b/pallets/maintenance-mode/Cargo.toml @@ -23,3 +23,4 @@ std = [ "frame-system/std", "sp-runtime/std", ] +try-runtime = ["frame-support/try-runtime"] diff --git a/pallets/parachain-staking/Cargo.toml b/pallets/parachain-staking/Cargo.toml index 18c506c474..41e0bcfe63 100644 --- a/pallets/parachain-staking/Cargo.toml +++ b/pallets/parachain-staking/Cargo.toml @@ -36,3 +36,4 @@ std = [ "sp-std/std", ] runtime-benchmarks = ["frame-benchmarking"] +try-runtime = ["frame-support/try-runtime"] diff --git a/runtime/moonbase/Cargo.toml b/runtime/moonbase/Cargo.toml index 0f480090af..f08471a5d3 100644 --- a/runtime/moonbase/Cargo.toml +++ b/runtime/moonbase/Cargo.toml @@ -187,7 +187,14 @@ runtime-benchmarks = [ "pallet-crowdloan-rewards/runtime-benchmarks", ] try-runtime = [ - "frame-executive/try-runtime", "frame-try-runtime", + "frame-executive/try-runtime", "frame-system/try-runtime", + "pallet-collective/try-runtime", + "parachain-staking/try-runtime", + "pallet-balances/try-runtime", + "pallet-timestamp/try-runtime", + "pallet-society/try-runtime", + "pallet-author-mapping/try-runtime", + #"pallet-crowdloan-rewards/try-runtime", ] diff --git a/runtime/moonriver/Cargo.toml b/runtime/moonriver/Cargo.toml index cf3eaed8d2..0df2769b3b 100644 --- a/runtime/moonriver/Cargo.toml +++ b/runtime/moonriver/Cargo.toml @@ -87,6 +87,8 @@ cumulus-primitives-timestamp = { git = "https://github.com/purestake/cumulus", d frame-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.8", optional = true } frame-system-benchmarking = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.8", optional = true } +frame-try-runtime = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.8", optional = true } + [dev-dependencies] cumulus-test-relay-sproof-builder = { git = "https://github.com/purestake/cumulus", default-features = false, branch = "joshy-np098" } cumulus-primitives-parachain-inherent = { git = "https://github.com/purestake/cumulus", default-features = false, branch = "joshy-np098" } @@ -181,3 +183,15 @@ runtime-benchmarks = [ "pallet-author-mapping/runtime-benchmarks", "pallet-crowdloan-rewards/runtime-benchmarks", ] +try-runtime = [ + "frame-try-runtime", + "frame-executive/try-runtime", + "frame-system/try-runtime", + "pallet-collective/try-runtime", + "parachain-staking/try-runtime", + "pallet-balances/try-runtime", + "pallet-timestamp/try-runtime", + "pallet-society/try-runtime", + "pallet-author-mapping/try-runtime", + #"pallet-crowdloan-rewards/try-runtime", +]