diff --git a/crates/humanode-runtime/src/storage_version_initializer.rs b/crates/humanode-runtime/src/storage_version_initializer.rs index cb029ff59..544356e2e 100644 --- a/crates/humanode-runtime/src/storage_version_initializer.rs +++ b/crates/humanode-runtime/src/storage_version_initializer.rs @@ -1,14 +1,10 @@ use core::marker::PhantomData; -#[cfg(feature = "try-runtime")] -use frame_support::{ensure, sp_runtime::TryRuntimeError}; use frame_support::{ log::info, traits::{Get, GetStorageVersion, OnRuntimeUpgrade, PalletInfoAccess, StorageVersion}, weights::Weight, }; -#[cfg(feature = "try-runtime")] -use sp_std::vec::Vec; /// Pallet storage version initializer. pub struct StorageVersionInitializer(PhantomData<(P, R)>); @@ -51,14 +47,16 @@ where } #[cfg(feature = "try-runtime")] - fn pre_upgrade() -> Result, TryRuntimeError> { + fn pre_upgrade() -> Result, frame_support::sp_runtime::TryRuntimeError> { // Do nothing. - Ok(Vec::new()) + Ok(sp_std::vec::Vec::new()) } #[cfg(feature = "try-runtime")] - fn post_upgrade(_state: Vec) -> Result<(), TryRuntimeError> { - ensure!( + fn post_upgrade( + _state: sp_std::vec::Vec, + ) -> Result<(), frame_support::sp_runtime::TryRuntimeError> { + frame_support::ensure!( P::on_chain_storage_version() == P::current_storage_version(), "the current storage version and onchain storage version should be the same" ); diff --git a/crates/pallet-balanced-currency-swap-bridges-initializer/src/lib.rs b/crates/pallet-balanced-currency-swap-bridges-initializer/src/lib.rs index ec67377cc..e0239519e 100644 --- a/crates/pallet-balanced-currency-swap-bridges-initializer/src/lib.rs +++ b/crates/pallet-balanced-currency-swap-bridges-initializer/src/lib.rs @@ -14,8 +14,6 @@ use frame_support::{ }; pub use pallet::*; use sp_std::cmp::Ordering; -#[cfg(feature = "try-runtime")] -use sp_std::vec::Vec; pub use weights::*; pub mod weights; @@ -47,8 +45,6 @@ pub const CURRENT_BRIDGES_INITIALIZER_VERSION: u16 = 1; #[allow(clippy::missing_docs_in_private_items)] #[frame_support::pallet] pub mod pallet { - #[cfg(feature = "try-runtime")] - use frame_support::sp_runtime::TryRuntimeError; use frame_support::{pallet_prelude::*, sp_runtime::traits::MaybeDisplay}; use frame_system::pallet_prelude::*; use sp_std::fmt::Debug; @@ -149,12 +145,15 @@ pub mod pallet { } #[cfg(feature = "try-runtime")] - fn pre_upgrade() -> Result, TryRuntimeError> { + fn pre_upgrade() -> Result, frame_support::sp_runtime::TryRuntimeError> + { upgrade_init::pre_upgrade() } #[cfg(feature = "try-runtime")] - fn post_upgrade(state: Vec) -> Result<(), TryRuntimeError> { + fn post_upgrade( + state: sp_std::vec::Vec, + ) -> Result<(), frame_support::sp_runtime::TryRuntimeError> { upgrade_init::post_upgrade::(state) } } diff --git a/crates/pallet-balanced-currency-swap-bridges-initializer/src/upgrade_init.rs b/crates/pallet-balanced-currency-swap-bridges-initializer/src/upgrade_init.rs index c7d17d690..277fb732f 100644 --- a/crates/pallet-balanced-currency-swap-bridges-initializer/src/upgrade_init.rs +++ b/crates/pallet-balanced-currency-swap-bridges-initializer/src/upgrade_init.rs @@ -1,10 +1,6 @@ //! Initialization of the bridge pot accounts on runtime upgrade. -#[cfg(feature = "try-runtime")] -use frame_support::sp_runtime::TryRuntimeError; use frame_support::{log, pallet_prelude::*}; -#[cfg(feature = "try-runtime")] -use sp_std::vec::Vec; use crate::{ Config, LastForceRebalanceAskCounter, LastInitializerVersion, Pallet, @@ -40,22 +36,26 @@ pub fn on_runtime_upgrade() -> Weight { /// /// Panics if anything goes wrong. #[cfg(feature = "try-runtime")] -pub fn pre_upgrade() -> Result, TryRuntimeError> { +pub fn pre_upgrade() -> Result, frame_support::sp_runtime::TryRuntimeError> { // Do nothing. - Ok(Vec::new()) + Ok(sp_std::vec::Vec::new()) } /// Check the state after the bridges initialization. /// /// Panics if anything goes wrong. #[cfg(feature = "try-runtime")] -pub fn post_upgrade(_state: Vec) -> Result<(), TryRuntimeError> { +pub fn post_upgrade( + _state: sp_std::vec::Vec, +) -> Result<(), frame_support::sp_runtime::TryRuntimeError> { use frame_support::{storage_root, StateVersion}; let storage_root_before = storage_root(StateVersion::V1); if !Pallet::::is_balanced()? { - return Err(TryRuntimeError::Other("currencies are not balanced")); + return Err(frame_support::sp_runtime::TryRuntimeError::Other( + "currencies are not balanced", + )); } ensure!( diff --git a/crates/pallet-dummy-precompiles-code/src/lib.rs b/crates/pallet-dummy-precompiles-code/src/lib.rs index a69a084b2..42e7ef9b8 100644 --- a/crates/pallet-dummy-precompiles-code/src/lib.rs +++ b/crates/pallet-dummy-precompiles-code/src/lib.rs @@ -32,8 +32,6 @@ pub const DUMMY_CODE: &[u8] = &[0x5F, 0x5F, 0xFD]; #[allow(clippy::missing_docs_in_private_items)] #[frame_support::pallet] pub mod pallet { - #[cfg(feature = "try-runtime")] - use frame_support::sp_runtime::TryRuntimeError; use frame_support::{pallet_prelude::*, sp_std::vec::Vec}; use frame_system::pallet_prelude::*; @@ -103,15 +101,13 @@ pub mod pallet { } #[cfg(feature = "try-runtime")] - fn pre_upgrade() -> Result, TryRuntimeError> { + fn pre_upgrade() -> Result, frame_support::sp_runtime::TryRuntimeError> { // Do nothing. Ok(Vec::new()) } #[cfg(feature = "try-runtime")] - fn post_upgrade(_state: Vec) -> Result<(), TryRuntimeError> { - use sp_std::vec::Vec; - + fn post_upgrade(_state: Vec) -> Result<(), frame_support::sp_runtime::TryRuntimeError> { let mut not_created_precompiles = Vec::new(); for precompile_address in &T::PrecompilesAddresses::get() { @@ -122,7 +118,7 @@ pub mod pallet { } if !not_created_precompiles.is_empty() { - return Err(TryRuntimeError::Other( + return Err(frame_support::sp_runtime::TryRuntimeError::Other( "precompiles not created properly: {:not_created_precompiles}", )); } diff --git a/crates/pallet-erc20-support/src/lib.rs b/crates/pallet-erc20-support/src/lib.rs index a42adb7e5..d0772ed14 100644 --- a/crates/pallet-erc20-support/src/lib.rs +++ b/crates/pallet-erc20-support/src/lib.rs @@ -46,11 +46,6 @@ type BalanceOf = <>::Currency as Currency pub mod pallet { use frame_support::{pallet_prelude::*, sp_runtime::traits::MaybeDisplay, sp_std::fmt::Debug}; - #[cfg(feature = "try-runtime")] - use frame_support::{ - sp_runtime::TryRuntimeError, - sp_std::{vec, vec::Vec}, - }; use frame_system::pallet_prelude::*; use super::*; @@ -123,12 +118,16 @@ pub mod pallet { } #[cfg(feature = "try-runtime")] - fn pre_upgrade() -> Result, TryRuntimeError> { - Ok(vec![]) + fn pre_upgrade( + ) -> Result, frame_support::sp_runtime::TryRuntimeError> + { + Ok(frame_support::sp_std::vec![]) } #[cfg(feature = "try-runtime")] - fn post_upgrade(_state: Vec) -> Result<(), TryRuntimeError> { + fn post_upgrade( + _state: frame_support::sp_std::vec::Vec, + ) -> Result<(), frame_support::sp_runtime::TryRuntimeError> { ensure!( >::on_chain_storage_version() == >::current_storage_version(), diff --git a/crates/pallet-humanode-session/src/lib.rs b/crates/pallet-humanode-session/src/lib.rs index 987d6ea75..ce9313d00 100644 --- a/crates/pallet-humanode-session/src/lib.rs +++ b/crates/pallet-humanode-session/src/lib.rs @@ -34,8 +34,6 @@ pub mod pallet { use frame_support::pallet_prelude::*; use frame_system::pallet_prelude::*; use sp_runtime::BoundedBTreeSet; - #[cfg(feature = "try-runtime")] - use sp_runtime::TryRuntimeError; use super::*; @@ -170,12 +168,12 @@ pub mod pallet { } #[cfg(feature = "try-runtime")] - fn pre_upgrade() -> Result, TryRuntimeError> { + fn pre_upgrade() -> Result, frame_support::sp_runtime::TryRuntimeError> { Ok(migrations::v1::pre_migrate::()) } #[cfg(feature = "try-runtime")] - fn post_upgrade(state: Vec) -> Result<(), TryRuntimeError> { + fn post_upgrade(state: Vec) -> Result<(), frame_support::sp_runtime::TryRuntimeError> { migrations::v1::post_migrate::(state); Ok(()) }