Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Companion for: try-runtime::fast-forward #2100

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions parachain-template/node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,12 @@ pub fn run() -> Result<()> {
},
#[cfg(feature = "try-runtime")]
Some(Subcommand::TryRuntime(cmd)) => {
use parachain_template_runtime::MILLISECS_PER_BLOCK;
use sc_executor::{sp_wasm_interface::ExtendedHostFunctions, NativeExecutionDispatch};
use try_runtime_cli::block_building_info::timestamp_with_aura_info;

let runner = cli.create_runner(cmd)?;

use sc_executor::{sp_wasm_interface::ExtendedHostFunctions, NativeExecutionDispatch};
type HostFunctionsOf<E> = ExtendedHostFunctions<
sp_io::SubstrateHostFunctions,
<E as NativeExecutionDispatch>::ExtendHostFunctions,
Expand All @@ -243,8 +246,15 @@ pub fn run() -> Result<()> {
sc_service::TaskManager::new(runner.config().tokio_handle.clone(), *registry)
.map_err(|e| format!("Error: {:?}", e))?;

let info_provider = timestamp_with_aura_info(MILLISECS_PER_BLOCK);

runner.async_run(|_| {
Ok((cmd.run::<Block, HostFunctionsOf<ParachainNativeExecutor>>(), task_manager))
Ok((
cmd.run::<Block, HostFunctionsOf<ParachainNativeExecutor>, _>(Some(
info_provider,
)),
task_manager,
))
})
},
#[cfg(not(feature = "try-runtime"))]
Expand Down
69 changes: 42 additions & 27 deletions polkadot-parachain/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -704,73 +704,88 @@ pub fn run() -> Result<()> {
},
#[cfg(feature = "try-runtime")]
Some(Subcommand::TryRuntime(cmd)) => {
use sc_executor::{sp_wasm_interface::ExtendedHostFunctions, NativeExecutionDispatch};
use try_runtime_cli::block_building_info::timestamp_with_aura_info;

// grab the task manager.
let runner = cli.create_runner(cmd)?;
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))?;
use sc_executor::{sp_wasm_interface::ExtendedHostFunctions, NativeExecutionDispatch};
type HostFunctionsOf<E> = ExtendedHostFunctions<
sp_io::SubstrateHostFunctions,
<E as NativeExecutionDispatch>::ExtendHostFunctions,
>;

let info_provider = timestamp_with_aura_info(6000);

match runner.config().chain_spec.runtime() {
Runtime::Statemine => runner.async_run(|_| {
Ok((
cmd.run::<Block, HostFunctionsOf<StatemineRuntimeExecutor>>(),
cmd.run::<Block, HostFunctionsOf<StatemineRuntimeExecutor>, _>(Some(
info_provider,
)),
task_manager,
))
}),
Runtime::Westmint => runner.async_run(|_| {
Ok((cmd.run::<Block, HostFunctionsOf<WestmintRuntimeExecutor>>(), task_manager))
Ok((
cmd.run::<Block, HostFunctionsOf<WestmintRuntimeExecutor>, _>(Some(
info_provider,
)),
task_manager,
))
}),
Runtime::Statemint => runner.async_run(|_| {
Ok((
cmd.run::<Block, HostFunctionsOf<StatemintRuntimeExecutor>>(),
cmd.run::<Block, HostFunctionsOf<StatemintRuntimeExecutor>, _>(Some(
info_provider,
)),
task_manager,
))
}),
Runtime::CollectivesPolkadot | Runtime::CollectivesWestend =>
runner.async_run(|_| {
Ok((
cmd.run::<Block, HostFunctionsOf<CollectivesPolkadotRuntimeExecutor>>(),
cmd.run::<Block, HostFunctionsOf<CollectivesPolkadotRuntimeExecutor>, _>(Some(info_provider)),
task_manager,
))
}),
Runtime::BridgeHub(bridge_hub_runtime_type) => match bridge_hub_runtime_type {
chain_spec::bridge_hubs::BridgeHubRuntimeType::Polkadot |
chain_spec::bridge_hubs::BridgeHubRuntimeType::PolkadotLocal |
chain_spec::bridge_hubs::BridgeHubRuntimeType::PolkadotDevelopment => runner.async_run(|_| {
Ok((
cmd.run::<Block, HostFunctionsOf<BridgeHubPolkadotRuntimeExecutor>>(),
Runtime::BridgeHub(bridge_hub_runtime_type) =>
match bridge_hub_runtime_type {
chain_spec::bridge_hubs::BridgeHubRuntimeType::Polkadot |
chain_spec::bridge_hubs::BridgeHubRuntimeType::PolkadotLocal |
chain_spec::bridge_hubs::BridgeHubRuntimeType::PolkadotDevelopment =>
runner.async_run(|_| {
Ok((
cmd.run::<Block, HostFunctionsOf<BridgeHubPolkadotRuntimeExecutor>, _>(Some(info_provider)),
task_manager,
))
}),
chain_spec::bridge_hubs::BridgeHubRuntimeType::Kusama |
chain_spec::bridge_hubs::BridgeHubRuntimeType::KusamaLocal |
chain_spec::bridge_hubs::BridgeHubRuntimeType::KusamaDevelopment => runner.async_run(|_| {
Ok((
cmd.run::<Block, HostFunctionsOf<BridgeHubKusamaRuntimeExecutor>>(),
}),
chain_spec::bridge_hubs::BridgeHubRuntimeType::Kusama |
chain_spec::bridge_hubs::BridgeHubRuntimeType::KusamaLocal |
chain_spec::bridge_hubs::BridgeHubRuntimeType::KusamaDevelopment => runner.async_run(|_| {
Ok((
cmd.run::<Block, HostFunctionsOf<BridgeHubKusamaRuntimeExecutor>, _>(Some(info_provider)),
task_manager,
))
}),
chain_spec::bridge_hubs::BridgeHubRuntimeType::Rococo |
chain_spec::bridge_hubs::BridgeHubRuntimeType::RococoLocal |
chain_spec::bridge_hubs::BridgeHubRuntimeType::RococoDevelopment => runner.async_run(|_| {
Ok((
cmd.run::<Block, HostFunctionsOf<BridgeHubRococoRuntimeExecutor>>(),
}),
chain_spec::bridge_hubs::BridgeHubRuntimeType::Rococo |
chain_spec::bridge_hubs::BridgeHubRuntimeType::RococoLocal |
chain_spec::bridge_hubs::BridgeHubRuntimeType::RococoDevelopment => runner.async_run(|_| {
Ok((
cmd.run::<Block, HostFunctionsOf<BridgeHubRococoRuntimeExecutor>, _>(Some(info_provider)),
task_manager,
))
}),
_ => Err(format!(
}),
_ => Err(format!(
"Chain '{:?}' doesn't support try-runtime for bridge_hub_runtime_type: {:?}",
runner.config().chain_spec.runtime(),
bridge_hub_runtime_type
)
.into()),
},
.into()),
},
Runtime::Shell => runner.async_run(|_| {
Ok((
cmd.run::<Block, HostFunctionsOf<crate::service::ShellRuntimeExecutor>>(),
Expand Down