Skip to content

Commit

Permalink
add try-runtime entirely (#749)
Browse files Browse the repository at this point in the history
  • Loading branch information
librelois authored Aug 29, 2021
1 parent 9ede6fc commit b5c914c
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 15 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

71 changes: 57 additions & 14 deletions node/cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<service::moonbase_runtime::Block, service::MoonbaseExecutor>(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::<service::moonriver_runtime::Block, service::MoonriverExecutor>(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::<service::moonbeam_runtime::Block, service::MoonbeamExecutor>(
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::<service::moonbase_runtime::Block, service::MoonbaseExecutor>(
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. \
Expand Down
1 change: 1 addition & 0 deletions pallets/author-mapping/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@ std = [
"frame-benchmarking/std",
]
runtime-benchmarks = ["frame-benchmarking"]
try-runtime = ["frame-support/try-runtime"]
1 change: 1 addition & 0 deletions pallets/ethereum-chain-id/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ std = [
"frame-support/std",
"frame-system/std",
]
try-runtime = ["frame-support/try-runtime"]
1 change: 1 addition & 0 deletions pallets/maintenance-mode/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ std = [
"frame-system/std",
"sp-runtime/std",
]
try-runtime = ["frame-support/try-runtime"]
1 change: 1 addition & 0 deletions pallets/parachain-staking/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ std = [
"sp-std/std",
]
runtime-benchmarks = ["frame-benchmarking"]
try-runtime = ["frame-support/try-runtime"]
9 changes: 8 additions & 1 deletion runtime/moonbase/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]
14 changes: 14 additions & 0 deletions runtime/moonriver/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down Expand Up @@ -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",
]

0 comments on commit b5c914c

Please sign in to comment.