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

companion try-state #5907

Merged
merged 13 commits into from
Sep 1, 2022
345 changes: 175 additions & 170 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion runtime/kusama/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -243,15 +243,16 @@ try-runtime = [
"frame-system/try-runtime",
"pallet-authority-discovery/try-runtime",
"pallet-authorship/try-runtime",
"pallet-balances/try-runtime",
"pallet-bags-list/try-runtime",
"pallet-balances/try-runtime",
"pallet-bounties/try-runtime",
"pallet-child-bounties/try-runtime",
"pallet-transaction-payment/try-runtime",
"pallet-collective/try-runtime",
"pallet-elections-phragmen/try-runtime",
"pallet-election-provider-multi-phase/try-runtime",
"pallet-democracy/try-runtime",
"pallet-gilt/try-runtime",
"pallet-grandpa/try-runtime",
"pallet-identity/try-runtime",
"pallet-im-online/try-runtime",
Expand All @@ -273,6 +274,7 @@ try-runtime = [
"pallet-utility/try-runtime",
"pallet-vesting/try-runtime",
"pallet-babe/try-runtime",
"pallet-xcm/try-runtime",
"runtime-common/try-runtime",
]
# When enabled, the runtime API will not be build.
Expand Down
12 changes: 10 additions & 2 deletions runtime/kusama/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1882,8 +1882,16 @@ sp_api::impl_runtime_apis! {
let weight = Executive::try_runtime_upgrade().unwrap();
(weight, BlockWeights::get().max_block)
}
fn execute_block_no_check(block: Block) -> Weight {
Executive::execute_block_no_check(block)

fn execute_block(block: Block, state_root_check: bool, select: frame_try_runtime::TryStateSelect) -> Weight {
log::info!(
target: "runtime::kusama", "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")
}
}

Expand Down
4 changes: 3 additions & 1 deletion runtime/polkadot/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ try-runtime = [
"frame-executive/try-runtime",
"frame-try-runtime",
"frame-system/try-runtime",
"runtime-common/try-runtime",
"pallet-authority-discovery/try-runtime",
"pallet-authorship/try-runtime",
"pallet-balances/try-runtime",
Expand All @@ -243,6 +244,7 @@ try-runtime = [
"pallet-indices/try-runtime",
"pallet-membership/try-runtime",
"pallet-multisig/try-runtime",
"pallet-nomination-pools/try-runtime",
"pallet-offences/try-runtime",
"pallet-preimage/try-runtime",
"pallet-proxy/try-runtime",
Expand All @@ -255,7 +257,7 @@ try-runtime = [
"pallet-babe/try-runtime",
"pallet-vesting/try-runtime",
"pallet-utility/try-runtime",
"runtime-common/try-runtime",
"pallet-xcm/try-runtime",
]
# When enabled, the runtime API will not be build.
#
Expand Down
11 changes: 9 additions & 2 deletions runtime/polkadot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2002,8 +2002,15 @@ sp_api::impl_runtime_apis! {
(weight, BlockWeights::get().max_block)
}

fn execute_block_no_check(block: Block) -> Weight {
Executive::execute_block_no_check(block)
fn execute_block(block: Block, state_root_check: bool, select: frame_try_runtime::TryStateSelect) -> Weight {
log::info!(
target: "runtime::polkadot", "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")
}
}

Expand Down
7 changes: 4 additions & 3 deletions runtime/westend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,10 @@ try-runtime = [
"frame-executive/try-runtime",
"frame-system/try-runtime",
"frame-try-runtime",
"pallet-authorship/try-runtime",
"runtime-common/try-runtime",
"pallet-authority-discovery/try-runtime",
"pallet-authorship/try-runtime",
"pallet-balances/try-runtime",
"pallet-bags-list/try-runtime",
"pallet-transaction-payment/try-runtime",
"pallet-collective/try-runtime",
"pallet-elections-phragmen/try-runtime",
Expand All @@ -256,8 +256,9 @@ try-runtime = [
"pallet-treasury/try-runtime",
"pallet-utility/try-runtime",
"pallet-vesting/try-runtime",
"pallet-xcm/try-runtime",
"pallet-babe/try-runtime",
"runtime-common/try-runtime",
"pallet-bags-list/try-runtime",
]
# When enabled, the runtime API will not be build.
#
Expand Down
14 changes: 11 additions & 3 deletions runtime/westend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1587,13 +1587,21 @@ sp_api::impl_runtime_apis! {

#[cfg(feature = "try-runtime")]
impl frame_try_runtime::TryRuntime<Block> for Runtime {
fn on_runtime_upgrade() -> (frame_support::weights::Weight, frame_support::weights::Weight) {
fn on_runtime_upgrade() -> (Weight, Weight) {
log::info!("try-runtime::on_runtime_upgrade westend.");
let weight = Executive::try_runtime_upgrade().unwrap();
(weight, BlockWeights::get().max_block)
}
fn execute_block_no_check(block: Block) -> frame_support::weights::Weight {
Executive::execute_block_no_check(block)

fn execute_block(block: Block, state_root_check: bool, select: frame_try_runtime::TryStateSelect) -> Weight {
log::info!(
target: "runtime::westend", "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")
}
}

Expand Down
6 changes: 3 additions & 3 deletions utils/remote-ext-tests/bags-list/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ async fn main() {
(Runtime::Kusama, Command::SanityCheck) => {
use kusama_runtime::{Block, Runtime};
use kusama_runtime_constants::currency::UNITS;
sanity_check::execute::<Runtime, Block>(UNITS as u64, "KSM", options.uri.clone()).await;
try_state::execute::<Runtime, Block>(UNITS as u64, "KSM", options.uri.clone()).await;
},
(Runtime::Kusama, Command::Snapshot) => {
use kusama_runtime::{Block, Runtime};
Expand All @@ -107,7 +107,7 @@ async fn main() {
(Runtime::Westend, Command::SanityCheck) => {
use westend_runtime::{Block, Runtime};
use westend_runtime_constants::currency::UNITS;
sanity_check::execute::<Runtime, Block>(UNITS as u64, "WND", options.uri.clone()).await;
try_state::execute::<Runtime, Block>(UNITS as u64, "WND", options.uri.clone()).await;
},
(Runtime::Westend, Command::Snapshot) => {
use westend_runtime::{Block, Runtime};
Expand All @@ -128,7 +128,7 @@ async fn main() {
(Runtime::Polkadot, Command::SanityCheck) => {
use polkadot_runtime::{Block, Runtime};
use polkadot_runtime_constants::currency::UNITS;
sanity_check::execute::<Runtime, Block>(UNITS as u64, "DOT", options.uri.clone()).await;
try_state::execute::<Runtime, Block>(UNITS as u64, "DOT", options.uri.clone()).await;
},
(Runtime::Polkadot, Command::Snapshot) => {
use polkadot_runtime::{Block, Runtime};
Expand Down
1 change: 1 addition & 0 deletions xcm/pallet-xcm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,4 @@ std = [
runtime-benchmarks = [
"frame-system/runtime-benchmarks"
]
try-runtime = ["frame-support/try-runtime"]