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

Commit 391a5d8

Browse files
kianenigmabkchr
andauthored
companion for try-runtime revamp (#1997)
* companion for try-rutnime revamp * Fixes Co-authored-by: Bastian Köcher <[email protected]>
1 parent babf73b commit 391a5d8

File tree

13 files changed

+408
-391
lines changed

13 files changed

+408
-391
lines changed

Cargo.lock

Lines changed: 265 additions & 255 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

parachain-template/node/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ sp-consensus-aura = { git = "https://github.com/paritytech/substrate", branch =
4545
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
4646
sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "master" }
4747
sp-offchain = { git = "https://github.com/paritytech/substrate", branch = "master" }
48+
sp-io = { git = "https://github.com/paritytech/substrate", branch = "master" }
4849
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master" }
4950
sp-session = { git = "https://github.com/paritytech/substrate", branch = "master" }
5051
sp-timestamp = { git = "https://github.com/paritytech/substrate", branch = "master" }

parachain-template/node/src/command.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,14 +231,20 @@ pub fn run() -> Result<()> {
231231
Some(Subcommand::TryRuntime(cmd)) => {
232232
let runner = cli.create_runner(cmd)?;
233233

234+
use sc_executor::{sp_wasm_interface::ExtendedHostFunctions, NativeExecutionDispatch};
235+
type HostFunctionsOf<E> = ExtendedHostFunctions<
236+
sp_io::SubstrateHostFunctions,
237+
<E as NativeExecutionDispatch>::ExtendHostFunctions,
238+
>;
239+
234240
// grab the task manager.
235241
let registry = &runner.config().prometheus_config.as_ref().map(|cfg| &cfg.registry);
236242
let task_manager =
237243
sc_service::TaskManager::new(runner.config().tokio_handle.clone(), *registry)
238244
.map_err(|e| format!("Error: {:?}", e))?;
239245

240-
runner.async_run(|config| {
241-
Ok((cmd.run::<Block, ParachainNativeExecutor>(config), task_manager))
246+
runner.async_run(|_| {
247+
Ok((cmd.run::<Block, HostFunctionsOf<ParachainNativeExecutor>>(), task_manager))
242248
})
243249
},
244250
#[cfg(not(feature = "try-runtime"))]

parachain-template/runtime/src/lib.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -632,21 +632,20 @@ impl_runtime_apis! {
632632

633633
#[cfg(feature = "try-runtime")]
634634
impl frame_try_runtime::TryRuntime<Block> for Runtime {
635-
fn on_runtime_upgrade() -> (Weight, Weight) {
636-
log::info!("try-runtime::on_runtime_upgrade parachain-template.");
637-
let weight = Executive::try_runtime_upgrade().unwrap();
635+
fn on_runtime_upgrade(checks: bool) -> (Weight, Weight) {
636+
let weight = Executive::try_runtime_upgrade(checks).unwrap();
638637
(weight, RuntimeBlockWeights::get().max_block)
639638
}
640639

641-
fn execute_block(block: Block, state_root_check: bool, select: frame_try_runtime::TryStateSelect) -> Weight {
642-
log::info!(
643-
target: "runtime::parachain-template", "try-runtime: executing block #{} ({:?}) / root checks: {:?} / sanity-checks: {:?}",
644-
block.header.number,
645-
block.header.hash(),
646-
state_root_check,
647-
select,
648-
);
649-
Executive::try_execute_block(block, state_root_check, select).expect("try_execute_block failed")
640+
fn execute_block(
641+
block: Block,
642+
state_root_check: bool,
643+
signature_check: bool,
644+
select: frame_try_runtime::TryStateSelect,
645+
) -> Weight {
646+
// NOTE: intentional unwrap: we don't want to propagate the error backwards, and want to
647+
// have a backtrace here.
648+
Executive::try_execute_block(block, state_root_check, signature_check, select).unwrap()
650649
}
651650
}
652651

parachains/runtimes/assets/statemine/src/lib.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -803,21 +803,20 @@ impl_runtime_apis! {
803803

804804
#[cfg(feature = "try-runtime")]
805805
impl frame_try_runtime::TryRuntime<Block> for Runtime {
806-
fn on_runtime_upgrade() -> (Weight, Weight) {
807-
log::info!("try-runtime::on_runtime_upgrade statemine.");
808-
let weight = Executive::try_runtime_upgrade().unwrap();
806+
fn on_runtime_upgrade(checks: bool) -> (Weight, Weight) {
807+
let weight = Executive::try_runtime_upgrade(checks).unwrap();
809808
(weight, RuntimeBlockWeights::get().max_block)
810809
}
811810

812-
fn execute_block(block: Block, state_root_check: bool, select: frame_try_runtime::TryStateSelect) -> Weight {
813-
log::info!(
814-
target: "runtime::statemine", "try-runtime: executing block #{} ({:?}) / root checks: {:?} / sanity-checks: {:?}",
815-
block.header.number,
816-
block.header.hash(),
817-
state_root_check,
818-
select,
819-
);
820-
Executive::try_execute_block(block, state_root_check, select).expect("try_execute_block failed")
811+
fn execute_block(
812+
block: Block,
813+
state_root_check: bool,
814+
signature_check: bool,
815+
select: frame_try_runtime::TryStateSelect,
816+
) -> Weight {
817+
// NOTE: intentional unwrap: we don't want to propagate the error backwards, and want to
818+
// have a backtrace here.
819+
Executive::try_execute_block(block, state_root_check, signature_check, select).unwrap()
821820
}
822821
}
823822

parachains/runtimes/assets/statemint/src/lib.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -816,21 +816,20 @@ impl_runtime_apis! {
816816

817817
#[cfg(feature = "try-runtime")]
818818
impl frame_try_runtime::TryRuntime<Block> for Runtime {
819-
fn on_runtime_upgrade() -> (Weight, Weight) {
820-
log::info!("try-runtime::on_runtime_upgrade statemint.");
821-
let weight = Executive::try_runtime_upgrade().unwrap();
819+
fn on_runtime_upgrade(checks: bool) -> (Weight, Weight) {
820+
let weight = Executive::try_runtime_upgrade(checks).unwrap();
822821
(weight, RuntimeBlockWeights::get().max_block)
823822
}
824823

825-
fn execute_block(block: Block, state_root_check: bool, select: frame_try_runtime::TryStateSelect) -> Weight {
826-
log::info!(
827-
target: "runtime::statemint", "try-runtime: executing block #{} ({:?}) / root checks: {:?} / sanity-checks: {:?}",
828-
block.header.number,
829-
block.header.hash(),
830-
state_root_check,
831-
select,
832-
);
833-
Executive::try_execute_block(block, state_root_check, select).expect("try_execute_block failed")
824+
fn execute_block(
825+
block: Block,
826+
state_root_check: bool,
827+
signature_check: bool,
828+
select: frame_try_runtime::TryStateSelect,
829+
) -> Weight {
830+
// NOTE: intentional unwrap: we don't want to propagate the error backwards, and want to
831+
// have a backtrace here.
832+
Executive::try_execute_block(block, state_root_check, signature_check, select).unwrap()
834833
}
835834
}
836835

parachains/runtimes/assets/westmint/src/lib.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -776,21 +776,20 @@ impl_runtime_apis! {
776776

777777
#[cfg(feature = "try-runtime")]
778778
impl frame_try_runtime::TryRuntime<Block> for Runtime {
779-
fn on_runtime_upgrade() -> (Weight, Weight) {
780-
log::info!("try-runtime::on_runtime_upgrade westmint.");
781-
let weight = Executive::try_runtime_upgrade().unwrap();
779+
fn on_runtime_upgrade(checks: bool) -> (Weight, Weight) {
780+
let weight = Executive::try_runtime_upgrade(checks).unwrap();
782781
(weight, RuntimeBlockWeights::get().max_block)
783782
}
784783

785-
fn execute_block(block: Block, state_root_check: bool, select: frame_try_runtime::TryStateSelect) -> Weight {
786-
log::info!(
787-
target: "runtime::westmint", "try-runtime: executing block #{} ({:?}) / root checks: {:?} / sanity-checks: {:?}",
788-
block.header.number,
789-
block.header.hash(),
790-
state_root_check,
791-
select,
792-
);
793-
Executive::try_execute_block(block, state_root_check, select).expect("try_execute_block failed")
784+
fn execute_block(
785+
block: Block,
786+
state_root_check: bool,
787+
signature_check: bool,
788+
select: frame_try_runtime::TryStateSelect,
789+
) -> Weight {
790+
// NOTE: intentional unwrap: we don't want to propagate the error backwards, and want to
791+
// have a backtrace here.
792+
Executive::try_execute_block(block, state_root_check, signature_check, select).unwrap()
794793
}
795794
}
796795

parachains/runtimes/bridge-hubs/bridge-hub-kusama/src/lib.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -551,21 +551,20 @@ impl_runtime_apis! {
551551

552552
#[cfg(feature = "try-runtime")]
553553
impl frame_try_runtime::TryRuntime<Block> for Runtime {
554-
fn on_runtime_upgrade() -> (Weight, Weight) {
555-
log::info!("try-runtime::on_runtime_upgrade bridge-hub-kusama.");
556-
let weight = Executive::try_runtime_upgrade().unwrap();
554+
fn on_runtime_upgrade(checks: bool) -> (Weight, Weight) {
555+
let weight = Executive::try_runtime_upgrade(checks).unwrap();
557556
(weight, RuntimeBlockWeights::get().max_block)
558557
}
559558

560-
fn execute_block(block: Block, state_root_check: bool, select: frame_try_runtime::TryStateSelect) -> Weight {
561-
log::info!(
562-
target: "runtime::bridge-hub-kusama", "try-runtime: executing block #{} ({:?}) / root checks: {:?} / sanity-checks: {:?}",
563-
block.header.number,
564-
block.header.hash(),
565-
state_root_check,
566-
select,
567-
);
568-
Executive::try_execute_block(block, state_root_check, select).expect("try_execute_block failed")
559+
fn execute_block(
560+
block: Block,
561+
state_root_check: bool,
562+
signature_check: bool,
563+
select: frame_try_runtime::TryStateSelect,
564+
) -> Weight {
565+
// NOTE: intentional unwrap: we don't want to propagate the error backwards, and want to
566+
// have a backtrace here.
567+
Executive::try_execute_block(block, state_root_check, signature_check, select).unwrap()
569568
}
570569
}
571570

parachains/runtimes/bridge-hubs/bridge-hub-rococo/src/lib.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -580,21 +580,20 @@ impl_runtime_apis! {
580580

581581
#[cfg(feature = "try-runtime")]
582582
impl frame_try_runtime::TryRuntime<Block> for Runtime {
583-
fn on_runtime_upgrade() -> (Weight, Weight) {
584-
log::info!("try-runtime::on_runtime_upgrade bridge-hub-rococo.");
585-
let weight = Executive::try_runtime_upgrade().unwrap();
583+
fn on_runtime_upgrade(checks: bool) -> (Weight, Weight) {
584+
let weight = Executive::try_runtime_upgrade(checks).unwrap();
586585
(weight, RuntimeBlockWeights::get().max_block)
587586
}
588587

589-
fn execute_block(block: Block, state_root_check: bool, select: frame_try_runtime::TryStateSelect) -> Weight {
590-
log::info!(
591-
target: "runtime::bridge-hub-rococo", "try-runtime: executing block #{} ({:?}) / root checks: {:?} / sanity-checks: {:?}",
592-
block.header.number,
593-
block.header.hash(),
594-
state_root_check,
595-
select,
596-
);
597-
Executive::try_execute_block(block, state_root_check, select).expect("try_execute_block failed")
588+
fn execute_block(
589+
block: Block,
590+
state_root_check: bool,
591+
signature_check: bool,
592+
select: frame_try_runtime::TryStateSelect,
593+
) -> Weight {
594+
// NOTE: intentional unwrap: we don't want to propagate the error backwards, and want to
595+
// have a backtrace here.
596+
Executive::try_execute_block(block, state_root_check, signature_check, select).unwrap()
598597
}
599598
}
600599

parachains/runtimes/collectives/collectives-polkadot/src/lib.rs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -715,21 +715,20 @@ impl_runtime_apis! {
715715

716716
#[cfg(feature = "try-runtime")]
717717
impl frame_try_runtime::TryRuntime<Block> for Runtime {
718-
fn on_runtime_upgrade() -> (Weight, Weight) {
719-
log::info!("try-runtime::on_runtime_upgrade collectives-polkadot.");
720-
let weight = Executive::try_runtime_upgrade().unwrap();
718+
fn on_runtime_upgrade(checks: bool) -> (Weight, Weight) {
719+
let weight = Executive::try_runtime_upgrade(checks).unwrap();
721720
(weight, RuntimeBlockWeights::get().max_block)
722721
}
723722

724-
fn execute_block(block: Block, state_root_check: bool, select: frame_try_runtime::TryStateSelect) -> Weight {
725-
log::info!(
726-
target: "runtime::collectives-polkadot", "try-runtime: executing block #{} ({:?}) / root checks: {:?} / sanity-checks: {:?}",
727-
block.header.number,
728-
block.header.hash(),
729-
state_root_check,
730-
select,
731-
);
732-
Executive::try_execute_block(block, state_root_check, select).expect("try_execute_block failed")
723+
fn execute_block(
724+
block: Block,
725+
state_root_check: bool,
726+
signature_check: bool,
727+
select: frame_try_runtime::TryStateSelect,
728+
) -> Weight {
729+
// NOTE: intentional unwrap: we don't want to propagate the error backwards, and want to
730+
// have a backtrace here.
731+
Executive::try_execute_block(block, state_root_check, signature_check, select).unwrap()
733732
}
734733
}
735734

0 commit comments

Comments
 (0)