Skip to content
Open
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
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,11 @@ after the migration. [`OnRuntimeUpgrade::pre_upgrade`] returns a [`Vec<u8>`] tha
arbitrary encoded data (usually some pre-upgrade state) which will be passed to
[`OnRuntimeUpgrade::pre_upgrade`] after upgrading and used for post checking.

**Note on Multi-Block Migrations (MBM):** If the runtime uses MBMs, the standard
`pre_upgrade` and `post_upgrade` checks might be skipped by the executive. To
force these hooks to run synchronously for testing, use the `--disable-mbm-checks` flag.
`--checks` (default `pre-and-post`) selects the checks run after multi-block migrations (MBMs),
or around single-block migrations (SBMs) with `--disable-mbm-checks`. To select both phases
separately, use `--sbm-checks` and `--mbm-checks` instead, e.g.
`--sbm-checks=pre-and-post --mbm-checks=try-state`. `--mbm-checks=pre-and-post` runs the SBM
hooks again on the migrated state. The MBMs' own pre/post hooks always run.

### [`VersionedMigration`]

Expand Down
8 changes: 5 additions & 3 deletions cli/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,11 @@
//! arbitrary encoded data (usually some pre-upgrade state) which will be passed to
//! [`OnRuntimeUpgrade::pre_upgrade`] after upgrading and used for post checking.
//!
//! **Note on Multi-Block Migrations (MBM):** If the runtime uses MBMs, the standard
//! `pre_upgrade` and `post_upgrade` checks might be skipped by the executive. To
//! force these hooks to run synchronously for testing, use the `--disable-mbm-checks` flag.
//! `--checks` (default `pre-and-post`) selects the checks run after multi-block migrations (MBMs),
//! or around single-block migrations (SBMs) with `--disable-mbm-checks`. To select both phases
//! separately, use `--sbm-checks` and `--mbm-checks` instead, e.g.
//! `--sbm-checks=pre-and-post --mbm-checks=try-state`. `--mbm-checks=pre-and-post` runs the SBM
//! hooks again on the migrated state. The MBMs' own pre/post hooks always run.
//!
//! ### [`VersionedMigration`]
//!
Expand Down
34 changes: 32 additions & 2 deletions cli/tests/on_runtime_upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,36 @@ mod on_runtime_upgrade {
.await;
}

#[tokio::test]
async fn pre_upgrade_fail_sbm_checks_fails() {
run_test(
TestConfig::new("rococo-people", "people_rococo_runtime_pre_upgrade_fail")
.with_sub_command_args(&["--sbm-checks=pre-and-post", "--mbm-checks=none"]),
false,
)
.await;
}

#[tokio::test]
async fn pre_upgrade_fail_mbm_checks_fails() {
run_test(
TestConfig::new("rococo-people", "people_rococo_runtime_pre_upgrade_fail")
.with_sub_command_args(&["--sbm-checks=none", "--mbm-checks=pre-and-post"]),
false,
)
.await;
}

#[tokio::test]
async fn pre_upgrade_fail_sbm_and_mbm_checks_can_be_ignored() {
run_test(
TestConfig::new("rococo-people", "people_rococo_runtime_pre_upgrade_fail")
.with_sub_command_args(&["--sbm-checks=none", "--mbm-checks=none"]),
true,
)
.await;
}

#[tokio::test]
async fn post_upgrade_fail_fails() {
run_test(
Expand Down Expand Up @@ -383,8 +413,8 @@ mod on_runtime_upgrade {
async fn mbm_fail_ignore_mbms() {
run_test(
TestConfig::new("rococo-people", "people_rococo_runtime_mbm_fails")
.with_sub_command_args(&["--disable-mbms-checks"]),
false,
.with_sub_command_args(&["--disable-mbm-checks"]),
true,
)
.await;
}
Expand Down
6 changes: 3 additions & 3 deletions core/src/commands/on_runtime_upgrade/mbms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ where
Level::Info,
&format!(
"🔬 Running Multi-Block-Migrations with checks: {:?}",
self.command.checks
self.command.multi_block_checks()
),
);

Expand All @@ -59,7 +59,7 @@ where
.await?;

if core_version::<Block, HostFns>(&ext, &executor)? < 5 {
return Err("Your runtime does not support Multi-Block-Migrations. Please disable the check with `--mbms false` or update your runtime.".into());
return Err("Your runtime does not support Multi-Block-Migrations. Please disable the check with `--disable-mbm-checks` or update your runtime.".into());
}

let inner_ext = Arc::new(Mutex::new(ext.inner_ext));
Expand Down Expand Up @@ -114,7 +114,7 @@ where
&mut Default::default(),
&executor,
"TryRuntime_on_runtime_upgrade",
self.command.checks.encode().as_ref(),
self.command.multi_block_checks().encode().as_ref(),
Default::default(), // TODO
None,
)?;
Expand Down
105 changes: 94 additions & 11 deletions core/src/commands/on_runtime_upgrade/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,29 @@
/// present).
/// - `try-state`: Perform the try-state checks.
///
/// Performing any checks will potentially invalidate the measured PoV/Weight.
/// Runs after MBMs, or around SBMs with --disable-mbm-checks. Performing any checks will
/// potentially invalidate the measured PoV/Weight.
// NOTE: The clap attributes make it backwards compatible with the previous `--checks` flag.
#[clap(long,
default_value = "pre-and-post",
default_missing_value = "all",
num_args = 0..=1,
conflicts_with_all = ["sbm_checks", "mbm_checks"],
verbatim_doc_comment
)]
pub checks: UpgradeCheckSelect,

/// Checks around single-block migrations, like --checks. Requires --mbm-checks unless
/// --disable-mbm-checks is set.
#[clap(long, default_missing_value = "all", num_args = 0..=1, requires = "mbm_checks")]
pub sbm_checks: Option<UpgradeCheckSelect>,

/// Checks after multi-block migrations finish, like --checks. Does not affect the MBMs' own
/// pre/post hooks. Requires --sbm-checks.
#[clap(long, default_missing_value = "all", num_args = 0..=1, requires = "sbm_checks",
conflicts_with = "disable_mbm_checks")]
pub mbm_checks: Option<UpgradeCheckSelect>,

/// Whether to disable weight warnings. Useful if a relay chain's runtime is being tested.
#[clap(long, default_value = "false", default_missing_value = "true")]
pub no_weight_warnings: bool,
Expand Down Expand Up @@ -104,21 +117,99 @@
pub blocktime: u64,
}

impl Command {
fn single_block_checks(&self) -> UpgradeCheckSelect {
match self.sbm_checks {
Some(checks) => checks,
None if self.disable_mbm_checks => self.checks,
None => UpgradeCheckSelect::None,
}
}

fn multi_block_checks(&self) -> UpgradeCheckSelect {
match (self.sbm_checks, self.mbm_checks) {
(_, Some(checks)) => checks,
(Some(_), None) => UpgradeCheckSelect::None,
(None, None) => self.checks,
}
}
}

#[cfg(test)]
mod tests {

Check failure on line 139 in core/src/commands/on_runtime_upgrade/mod.rs

View workflow job for this annotation

GitHub Actions / clippy

items after a test module

error: items after a test module --> core/src/commands/on_runtime_upgrade/mod.rs:139:1 | 139 | mod tests { | ^^^^^^^^^ ... 199 | pub(crate) struct CheckOnRuntimeUpgrade<Block, HostFns> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ... 205 | / impl<Block: BlockT<Hash = H256> + DeserializeOwned, HostFns> CheckOnRuntimeUpgrade<Block, HostFns> 206 | | where 207 | | Block: BlockT + serde::de::DeserializeOwned, 208 | | <Block::Hash as FromStr>::Err: Debug, ... | 211 | | <NumberFor<Block> as FromStr>::Err: Debug, 212 | | HostFns: HostFunctions, | |___________________________^ ... 431 | enum WeightSafety { | ^^^^^^^^^^^^^^^^^ ... 437 | const DEFAULT_MAX_POV_SIZE: ByteSize = ByteSize::mb(5); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ... 440 | const DEFAULT_WARNING_THRESHOLD: f32 = 0.8; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ... 443 | / fn analyse_pov<H>(proof: StorageProof, pre_root: H::Out) -> WeightSafety 444 | | where 445 | | H: Hasher, | |______________^ ... 508 | fn analyse_ref_time(ref_time_results: RefTimeInfo) -> WeightSafety { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ... 531 | / fn collect_storage_changes_as_hex<Block: BlockT>( 532 | | overlayed_changes: &OverlayedChanges<HashingFor<Block>>, 533 | | ) -> BTreeMap<String, String> { | |_____________________________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.93.0/index.html#items_after_test_module = note: `-D clippy::items-after-test-module` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::items_after_test_module)]` = help: move the items to before the test module was defined
use clap::{error::ErrorKind, Parser};
use UpgradeCheckSelect::{All, PreAndPost, TryState};

use super::*;

fn parse(args: &[&str]) -> Result<Command, clap::Error> {
Command::try_parse_from(
["on-runtime-upgrade"]
.into_iter()
.chain(args.iter().copied())
.chain(["--blocktime=6000", "snap", "--path=unused.snap"]),
)
}

#[test]
fn check_selection() {
for (args, sbm, mbm) in [
(&[][..], UpgradeCheckSelect::None, PreAndPost),
(&["--checks"], UpgradeCheckSelect::None, All),
(&["--checks=all", "--disable-mbm-checks"], All, All),
(
&["--sbm-checks=pre-and-post", "--mbm-checks=try-state"],
PreAndPost,
TryState,
),
(
&["--sbm-checks", "--disable-mbm-checks"],
All,
UpgradeCheckSelect::None,
),
] {
let command = parse(args).unwrap();
assert_eq!(
(command.single_block_checks(), command.multi_block_checks()),
(sbm, mbm)
);
}
}

#[test]
fn invalid_check_selection() {
for (args, kind) in [
(&["--sbm-checks"][..], ErrorKind::MissingRequiredArgument),
(&["--mbm-checks"], ErrorKind::MissingRequiredArgument),
(
&["--checks", "--sbm-checks", "--mbm-checks"],
ErrorKind::ArgumentConflict,
),
(
&["--sbm-checks", "--mbm-checks", "--disable-mbm-checks"],
ErrorKind::ArgumentConflict,
),
] {
assert_eq!(parse(args).unwrap_err().kind(), kind, "{args:?}");
}
}
}

/// Convenience struct to hold all the generic args and where clauses.
pub(crate) struct CheckOnRuntimeUpgrade<Block, HostFns> {

Check failure on line 199 in core/src/commands/on_runtime_upgrade/mod.rs

View workflow job for this annotation

GitHub Actions / clippy

items after a test module

error: items after a test module --> core/src/commands/on_runtime_upgrade/mod.rs:139:1 | 139 | mod tests { | ^^^^^^^^^ ... 199 | pub(crate) struct CheckOnRuntimeUpgrade<Block, HostFns> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ... 205 | / impl<Block: BlockT<Hash = H256> + DeserializeOwned, HostFns> CheckOnRuntimeUpgrade<Block, HostFns> 206 | | where 207 | | Block: BlockT + serde::de::DeserializeOwned, 208 | | <Block::Hash as FromStr>::Err: Debug, ... | 211 | | <NumberFor<Block> as FromStr>::Err: Debug, 212 | | HostFns: HostFunctions, | |___________________________^ ... 431 | enum WeightSafety { | ^^^^^^^^^^^^^^^^^ ... 437 | const DEFAULT_MAX_POV_SIZE: ByteSize = ByteSize::mb(5); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ... 440 | const DEFAULT_WARNING_THRESHOLD: f32 = 0.8; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ... 443 | / fn analyse_pov<H>(proof: StorageProof, pre_root: H::Out) -> WeightSafety 444 | | where 445 | | H: Hasher, | |______________^ ... 508 | fn analyse_ref_time(ref_time_results: RefTimeInfo) -> WeightSafety { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ... 531 | / fn collect_storage_changes_as_hex<Block: BlockT>( 532 | | overlayed_changes: &OverlayedChanges<HashingFor<Block>>, 533 | | ) -> BTreeMap<String, String> { | |_____________________________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.93.0/index.html#items_after_test_module = note: `-D clippy::items-after-test-module` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::items_after_test_module)]` = help: move the items to before the test module was defined
pub shared: SharedParams,
pub command: Command,
pub _phantom: std::marker::PhantomData<(Block, HostFns)>,
}

impl<Block: BlockT<Hash = H256> + DeserializeOwned, HostFns> CheckOnRuntimeUpgrade<Block, HostFns>
where
Block: BlockT + serde::de::DeserializeOwned,
<Block::Hash as FromStr>::Err: Debug,
Block::Header: serde::de::DeserializeOwned,
NumberFor<Block>: FromStr,
<NumberFor<Block> as FromStr>::Err: Debug,
HostFns: HostFunctions,

Check failure on line 212 in core/src/commands/on_runtime_upgrade/mod.rs

View workflow job for this annotation

GitHub Actions / clippy

items after a test module

error: items after a test module --> core/src/commands/on_runtime_upgrade/mod.rs:139:1 | 139 | mod tests { | ^^^^^^^^^ ... 199 | pub(crate) struct CheckOnRuntimeUpgrade<Block, HostFns> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ... 205 | / impl<Block: BlockT<Hash = H256> + DeserializeOwned, HostFns> CheckOnRuntimeUpgrade<Block, HostFns> 206 | | where 207 | | Block: BlockT + serde::de::DeserializeOwned, 208 | | <Block::Hash as FromStr>::Err: Debug, ... | 211 | | <NumberFor<Block> as FromStr>::Err: Debug, 212 | | HostFns: HostFunctions, | |___________________________^ ... 431 | enum WeightSafety { | ^^^^^^^^^^^^^^^^^ ... 437 | const DEFAULT_MAX_POV_SIZE: ByteSize = ByteSize::mb(5); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ... 440 | const DEFAULT_WARNING_THRESHOLD: f32 = 0.8; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ... 443 | / fn analyse_pov<H>(proof: StorageProof, pre_root: H::Out) -> WeightSafety 444 | | where 445 | | H: Hasher, | |______________^ ... 508 | fn analyse_ref_time(ref_time_results: RefTimeInfo) -> WeightSafety { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ... 531 | / fn collect_storage_changes_as_hex<Block: BlockT>( 532 | | overlayed_changes: &OverlayedChanges<HashingFor<Block>>, 533 | | ) -> BTreeMap<String, String> { | |_____________________________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.93.0/index.html#items_after_test_module = note: `-D clippy::items-after-test-module` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::items_after_test_module)]` = help: move the items to before the test module was defined
{
// Runs the `on-runtime-upgrade` command.
pub async fn run(&self) -> sc_cli::Result<()> {
Expand All @@ -136,11 +227,7 @@
.to_ext::<Block, HostFns>(shared, &executor, None, runtime_checks)
.await?;

let sync_checks = if command.disable_mbm_checks {
command.checks
} else {
UpgradeCheckSelect::None
};
let sync_checks = command.single_block_checks();

// Run `TryRuntime_on_runtime_upgrade` with the given checks.
basti_log(
Expand Down Expand Up @@ -187,11 +274,7 @@
if !self.command.disable_idempotency_checks {
basti_log(
Level::Info,
format!(
"🔬 Running TryRuntime_on_runtime_upgrade again to check idempotency: {:?}",
self.command.checks
)
.as_str(),
"🔬 Running TryRuntime_on_runtime_upgrade again to check idempotency",
);
let executor = build_executor(&self.shared);

Expand Down Expand Up @@ -345,21 +428,21 @@
}
}

enum WeightSafety {

Check failure on line 431 in core/src/commands/on_runtime_upgrade/mod.rs

View workflow job for this annotation

GitHub Actions / clippy

items after a test module

error: items after a test module --> core/src/commands/on_runtime_upgrade/mod.rs:139:1 | 139 | mod tests { | ^^^^^^^^^ ... 199 | pub(crate) struct CheckOnRuntimeUpgrade<Block, HostFns> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ... 205 | / impl<Block: BlockT<Hash = H256> + DeserializeOwned, HostFns> CheckOnRuntimeUpgrade<Block, HostFns> 206 | | where 207 | | Block: BlockT + serde::de::DeserializeOwned, 208 | | <Block::Hash as FromStr>::Err: Debug, ... | 211 | | <NumberFor<Block> as FromStr>::Err: Debug, 212 | | HostFns: HostFunctions, | |___________________________^ ... 431 | enum WeightSafety { | ^^^^^^^^^^^^^^^^^ ... 437 | const DEFAULT_MAX_POV_SIZE: ByteSize = ByteSize::mb(5); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ... 440 | const DEFAULT_WARNING_THRESHOLD: f32 = 0.8; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ... 443 | / fn analyse_pov<H>(proof: StorageProof, pre_root: H::Out) -> WeightSafety 444 | | where 445 | | H: Hasher, | |______________^ ... 508 | fn analyse_ref_time(ref_time_results: RefTimeInfo) -> WeightSafety { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ... 531 | / fn collect_storage_changes_as_hex<Block: BlockT>( 532 | | overlayed_changes: &OverlayedChanges<HashingFor<Block>>, 533 | | ) -> BTreeMap<String, String> { | |_____________________________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.93.0/index.html#items_after_test_module = note: `-D clippy::items-after-test-module` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::items_after_test_module)]` = help: move the items to before the test module was defined
ProbablySafe,
PotentiallyUnsafe,
}

/// The default maximum PoV size in MB.
const DEFAULT_MAX_POV_SIZE: ByteSize = ByteSize::mb(5);

Check failure on line 437 in core/src/commands/on_runtime_upgrade/mod.rs

View workflow job for this annotation

GitHub Actions / clippy

items after a test module

error: items after a test module --> core/src/commands/on_runtime_upgrade/mod.rs:139:1 | 139 | mod tests { | ^^^^^^^^^ ... 199 | pub(crate) struct CheckOnRuntimeUpgrade<Block, HostFns> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ... 205 | / impl<Block: BlockT<Hash = H256> + DeserializeOwned, HostFns> CheckOnRuntimeUpgrade<Block, HostFns> 206 | | where 207 | | Block: BlockT + serde::de::DeserializeOwned, 208 | | <Block::Hash as FromStr>::Err: Debug, ... | 211 | | <NumberFor<Block> as FromStr>::Err: Debug, 212 | | HostFns: HostFunctions, | |___________________________^ ... 431 | enum WeightSafety { | ^^^^^^^^^^^^^^^^^ ... 437 | const DEFAULT_MAX_POV_SIZE: ByteSize = ByteSize::mb(5); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ... 440 | const DEFAULT_WARNING_THRESHOLD: f32 = 0.8; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ... 443 | / fn analyse_pov<H>(proof: StorageProof, pre_root: H::Out) -> WeightSafety 444 | | where 445 | | H: Hasher, | |______________^ ... 508 | fn analyse_ref_time(ref_time_results: RefTimeInfo) -> WeightSafety { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ... 531 | / fn collect_storage_changes_as_hex<Block: BlockT>( 532 | | overlayed_changes: &OverlayedChanges<HashingFor<Block>>, 533 | | ) -> BTreeMap<String, String> { | |_____________________________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.93.0/index.html#items_after_test_module = note: `-D clippy::items-after-test-module` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::items_after_test_module)]` = help: move the items to before the test module was defined

/// The fraction of the total available ref_time or pov size after which a warning should be logged.
const DEFAULT_WARNING_THRESHOLD: f32 = 0.8;

Check failure on line 440 in core/src/commands/on_runtime_upgrade/mod.rs

View workflow job for this annotation

GitHub Actions / clippy

items after a test module

error: items after a test module --> core/src/commands/on_runtime_upgrade/mod.rs:139:1 | 139 | mod tests { | ^^^^^^^^^ ... 199 | pub(crate) struct CheckOnRuntimeUpgrade<Block, HostFns> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ... 205 | / impl<Block: BlockT<Hash = H256> + DeserializeOwned, HostFns> CheckOnRuntimeUpgrade<Block, HostFns> 206 | | where 207 | | Block: BlockT + serde::de::DeserializeOwned, 208 | | <Block::Hash as FromStr>::Err: Debug, ... | 211 | | <NumberFor<Block> as FromStr>::Err: Debug, 212 | | HostFns: HostFunctions, | |___________________________^ ... 431 | enum WeightSafety { | ^^^^^^^^^^^^^^^^^ ... 437 | const DEFAULT_MAX_POV_SIZE: ByteSize = ByteSize::mb(5); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ... 440 | const DEFAULT_WARNING_THRESHOLD: f32 = 0.8; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ... 443 | / fn analyse_pov<H>(proof: StorageProof, pre_root: H::Out) -> WeightSafety 444 | | where 445 | | H: Hasher, | |______________^ ... 508 | fn analyse_ref_time(ref_time_results: RefTimeInfo) -> WeightSafety { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ... 531 | / fn collect_storage_changes_as_hex<Block: BlockT>( 532 | | overlayed_changes: &OverlayedChanges<HashingFor<Block>>, 533 | | ) -> BTreeMap<String, String> { | |_____________________________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.93.0/index.html#items_after_test_module = note: `-D clippy::items-after-test-module` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::items_after_test_module)]` = help: move the items to before the test module was defined

/// Analyse the given ref_times and return if there is a potential weight safety issue.
fn analyse_pov<H>(proof: StorageProof, pre_root: H::Out) -> WeightSafety
where
H: Hasher,

Check failure on line 445 in core/src/commands/on_runtime_upgrade/mod.rs

View workflow job for this annotation

GitHub Actions / clippy

items after a test module

error: items after a test module --> core/src/commands/on_runtime_upgrade/mod.rs:139:1 | 139 | mod tests { | ^^^^^^^^^ ... 199 | pub(crate) struct CheckOnRuntimeUpgrade<Block, HostFns> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ... 205 | / impl<Block: BlockT<Hash = H256> + DeserializeOwned, HostFns> CheckOnRuntimeUpgrade<Block, HostFns> 206 | | where 207 | | Block: BlockT + serde::de::DeserializeOwned, 208 | | <Block::Hash as FromStr>::Err: Debug, ... | 211 | | <NumberFor<Block> as FromStr>::Err: Debug, 212 | | HostFns: HostFunctions, | |___________________________^ ... 431 | enum WeightSafety { | ^^^^^^^^^^^^^^^^^ ... 437 | const DEFAULT_MAX_POV_SIZE: ByteSize = ByteSize::mb(5); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ... 440 | const DEFAULT_WARNING_THRESHOLD: f32 = 0.8; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ... 443 | / fn analyse_pov<H>(proof: StorageProof, pre_root: H::Out) -> WeightSafety 444 | | where 445 | | H: Hasher, | |______________^ ... 508 | fn analyse_ref_time(ref_time_results: RefTimeInfo) -> WeightSafety { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ... 531 | / fn collect_storage_changes_as_hex<Block: BlockT>( 532 | | overlayed_changes: &OverlayedChanges<HashingFor<Block>>, 533 | | ) -> BTreeMap<String, String> { | |_____________________________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.93.0/index.html#items_after_test_module = note: `-D clippy::items-after-test-module` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::items_after_test_module)]` = help: move the items to before the test module was defined
{
if proof.is_empty() {
log::info!(target: LOG_TARGET, "Empty PoV detected");
Expand Down Expand Up @@ -422,7 +505,7 @@
}

/// Analyse the given ref_times and return if there is a potential weight safety issue.
fn analyse_ref_time(ref_time_results: RefTimeInfo) -> WeightSafety {

Check failure on line 508 in core/src/commands/on_runtime_upgrade/mod.rs

View workflow job for this annotation

GitHub Actions / clippy

items after a test module

error: items after a test module --> core/src/commands/on_runtime_upgrade/mod.rs:139:1 | 139 | mod tests { | ^^^^^^^^^ ... 199 | pub(crate) struct CheckOnRuntimeUpgrade<Block, HostFns> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ... 205 | / impl<Block: BlockT<Hash = H256> + DeserializeOwned, HostFns> CheckOnRuntimeUpgrade<Block, HostFns> 206 | | where 207 | | Block: BlockT + serde::de::DeserializeOwned, 208 | | <Block::Hash as FromStr>::Err: Debug, ... | 211 | | <NumberFor<Block> as FromStr>::Err: Debug, 212 | | HostFns: HostFunctions, | |___________________________^ ... 431 | enum WeightSafety { | ^^^^^^^^^^^^^^^^^ ... 437 | const DEFAULT_MAX_POV_SIZE: ByteSize = ByteSize::mb(5); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ... 440 | const DEFAULT_WARNING_THRESHOLD: f32 = 0.8; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ... 443 | / fn analyse_pov<H>(proof: StorageProof, pre_root: H::Out) -> WeightSafety 444 | | where 445 | | H: Hasher, | |______________^ ... 508 | fn analyse_ref_time(ref_time_results: RefTimeInfo) -> WeightSafety { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ... 531 | / fn collect_storage_changes_as_hex<Block: BlockT>( 532 | | overlayed_changes: &OverlayedChanges<HashingFor<Block>>, 533 | | ) -> BTreeMap<String, String> { | |_____________________________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.93.0/index.html#items_after_test_module = note: `-D clippy::items-after-test-module` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::items_after_test_module)]` = help: move the items to before the test module was defined
let RefTimeInfo { used, max } = ref_time_results;
let (used, max) = (used.as_secs_f32(), max.as_secs_f32());
log::info!(
Expand All @@ -445,9 +528,9 @@
}
}

fn collect_storage_changes_as_hex<Block: BlockT>(
overlayed_changes: &OverlayedChanges<HashingFor<Block>>,
) -> BTreeMap<String, String> {

Check failure on line 533 in core/src/commands/on_runtime_upgrade/mod.rs

View workflow job for this annotation

GitHub Actions / clippy

items after a test module

error: items after a test module --> core/src/commands/on_runtime_upgrade/mod.rs:139:1 | 139 | mod tests { | ^^^^^^^^^ ... 199 | pub(crate) struct CheckOnRuntimeUpgrade<Block, HostFns> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ... 205 | / impl<Block: BlockT<Hash = H256> + DeserializeOwned, HostFns> CheckOnRuntimeUpgrade<Block, HostFns> 206 | | where 207 | | Block: BlockT + serde::de::DeserializeOwned, 208 | | <Block::Hash as FromStr>::Err: Debug, ... | 211 | | <NumberFor<Block> as FromStr>::Err: Debug, 212 | | HostFns: HostFunctions, | |___________________________^ ... 431 | enum WeightSafety { | ^^^^^^^^^^^^^^^^^ ... 437 | const DEFAULT_MAX_POV_SIZE: ByteSize = ByteSize::mb(5); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ... 440 | const DEFAULT_WARNING_THRESHOLD: f32 = 0.8; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ... 443 | / fn analyse_pov<H>(proof: StorageProof, pre_root: H::Out) -> WeightSafety 444 | | where 445 | | H: Hasher, | |______________^ ... 508 | fn analyse_ref_time(ref_time_results: RefTimeInfo) -> WeightSafety { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ... 531 | / fn collect_storage_changes_as_hex<Block: BlockT>( 532 | | overlayed_changes: &OverlayedChanges<HashingFor<Block>>, 533 | | ) -> BTreeMap<String, String> { | |_____________________________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.93.0/index.html#items_after_test_module = note: `-D clippy::items-after-test-module` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(clippy::items_after_test_module)]` = help: move the items to before the test module was defined
overlayed_changes
.changes()
.map(|(key, entry)| {
Expand Down
Loading