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

Commit

Permalink
Fix try-runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
Guantong committed Feb 3, 2023
1 parent e76813d commit abd93a0
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 73 deletions.
43 changes: 19 additions & 24 deletions Cargo.lock

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

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ sp-debug-derive = { git = "/~https://github.com/darwinia-network/substrate", branc
frame-support-procedural-tools-derive = { git = "/~https://github.com/darwinia-network/substrate", branch="polkadot-v0.9.36" }
sc-utils = { git = "/~https://github.com/darwinia-network/substrate", branch="polkadot-v0.9.36" }
substrate-prometheus-endpoint = { git = "/~https://github.com/darwinia-network/substrate", branch="polkadot-v0.9.36" }
sp-serializer = { git = "/~https://github.com/darwinia-network/substrate", branch="polkadot-v0.9.36" }
frame-support-procedural-tools = { git = "/~https://github.com/darwinia-network/substrate", branch="polkadot-v0.9.36" }
sp-runtime-interface-proc-macro = { git = "/~https://github.com/darwinia-network/substrate", branch="polkadot-v0.9.36" }
sp-api-proc-macro = { git = "/~https://github.com/darwinia-network/substrate", branch="polkadot-v0.9.36" }
Expand Down
6 changes: 3 additions & 3 deletions node/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -517,15 +517,15 @@ pub fn run() -> Result<()> {
.map_err(|e| format!("Error: {:?}", e))?;

if chain_spec.is_crab() {
runner.async_run(|config| {
runner.async_run(|_| {
Ok((cmd.run::<Block, HostFunctionsOf<CrabRuntimeExecutor>>(), task_manager))
})
} else if chain_spec.is_pangolin() {
runner.async_run(|config| {
runner.async_run(|_| {
Ok((cmd.run::<Block, HostFunctionsOf<PangolinRuntimeExecutor>>(), task_manager))
})
} else {
runner.async_run(|config| {
runner.async_run(|_| {
Ok((cmd.run::<Block, HostFunctionsOf<DarwiniaRuntimeExecutor>>(), task_manager))
})
}
Expand Down
1 change: 1 addition & 0 deletions runtime/crab/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ try-runtime = [
"pallet-fee-market/try-runtime",

# frontier
"fp-self-contained/try-runtime",
"pallet-ethereum/try-runtime",
"pallet-evm/try-runtime",

Expand Down
26 changes: 11 additions & 15 deletions runtime/crab/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -602,30 +602,26 @@ sp_api::impl_runtime_apis! {

#[cfg(feature = "try-runtime")]
impl frame_try_runtime::TryRuntime<Block> for Runtime {
fn on_runtime_upgrade() -> (Weight, Weight) {
fn on_runtime_upgrade(checks: bool) -> (Weight, Weight) {
// substrate
use frame_support::log;

log::info!("try-runtime::on_runtime_upgrade");

let weight = Executive::try_runtime_upgrade().unwrap();
let weight = Executive::try_runtime_upgrade(checks).unwrap();

(weight, RuntimeBlockWeights::get().max_block)
}

fn execute_block(block: Block, state_root_check: bool, select: frame_try_runtime::TryStateSelect) -> Weight {
// substrate
use frame_support::log;

log::info!(
"try-runtime: executing block #{} ({:?}) / root checks: {:?} / sanity-checks: {:?}",
block.header.number,
block.header.hash(),
state_root_check,
select,
);

Executive::try_execute_block(block, state_root_check, select).expect("try_execute_block failed")
fn execute_block(
block: Block,
state_root_check: bool,
signature_check: bool,
select: frame_try_runtime::TryStateSelect,
) -> Weight {
// NOTE: intentional unwrap: we don't want to propagate the error backwards, and want to
// have a backtrace here.
Executive::try_execute_block(block, state_root_check, signature_check, select).unwrap()
}
}
}
Expand Down
1 change: 1 addition & 0 deletions runtime/darwinia/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ try-runtime = [
"pallet-fee-market/try-runtime",

# frontier
"fp-self-contained/try-runtime",
"pallet-ethereum/try-runtime",
"pallet-evm/try-runtime",

Expand Down
26 changes: 11 additions & 15 deletions runtime/darwinia/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -603,30 +603,26 @@ sp_api::impl_runtime_apis! {

#[cfg(feature = "try-runtime")]
impl frame_try_runtime::TryRuntime<Block> for Runtime {
fn on_runtime_upgrade() -> (Weight, Weight) {
fn on_runtime_upgrade(checks: bool) -> (Weight, Weight) {
// substrate
use frame_support::log;

log::info!("try-runtime::on_runtime_upgrade");

let weight = Executive::try_runtime_upgrade().unwrap();
let weight = Executive::try_runtime_upgrade(checks).unwrap();

(weight, RuntimeBlockWeights::get().max_block)
}

fn execute_block(block: Block, state_root_check: bool, select: frame_try_runtime::TryStateSelect) -> Weight {
// substrate
use frame_support::log;

log::info!(
"try-runtime: executing block #{} ({:?}) / root checks: {:?} / sanity-checks: {:?}",
block.header.number,
block.header.hash(),
state_root_check,
select,
);

Executive::try_execute_block(block, state_root_check, select).expect("try_execute_block failed")
fn execute_block(
block: Block,
state_root_check: bool,
signature_check: bool,
select: frame_try_runtime::TryStateSelect,
) -> Weight {
// NOTE: intentional unwrap: we don't want to propagate the error backwards, and want to
// have a backtrace here.
Executive::try_execute_block(block, state_root_check, signature_check, select).unwrap()
}
}
}
Expand Down
1 change: 1 addition & 0 deletions runtime/pangolin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ try-runtime = [
"pallet-fee-market/try-runtime",

# frontier
"fp-self-contained/try-runtime",
"pallet-ethereum/try-runtime",
"pallet-evm/try-runtime",

Expand Down
26 changes: 11 additions & 15 deletions runtime/pangolin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -582,30 +582,26 @@ sp_api::impl_runtime_apis! {

#[cfg(feature = "try-runtime")]
impl frame_try_runtime::TryRuntime<Block> for Runtime {
fn on_runtime_upgrade() -> (Weight, Weight) {
fn on_runtime_upgrade(checks: bool) -> (Weight, Weight) {
// substrate
use frame_support::log;

log::info!("try-runtime::on_runtime_upgrade");

let weight = Executive::try_runtime_upgrade().unwrap();
let weight = Executive::try_runtime_upgrade(checks).unwrap();

(weight, RuntimeBlockWeights::get().max_block)
}

fn execute_block(block: Block, state_root_check: bool, select: frame_try_runtime::TryStateSelect) -> Weight {
// substrate
use frame_support::log;

log::info!(
"try-runtime: executing block #{} ({:?}) / root checks: {:?} / sanity-checks: {:?}",
block.header.number,
block.header.hash(),
state_root_check,
select,
);

Executive::try_execute_block(block, state_root_check, select).expect("try_execute_block failed")
fn execute_block(
block: Block,
state_root_check: bool,
signature_check: bool,
select: frame_try_runtime::TryStateSelect,
) -> Weight {
// NOTE: intentional unwrap: we don't want to propagate the error backwards, and want to
// have a backtrace here.
Executive::try_execute_block(block, state_root_check, signature_check, select).unwrap()
}
}
}
Expand Down

0 comments on commit abd93a0

Please sign in to comment.