diff --git a/pallets/claims/src/lib.rs b/pallets/claims/src/lib.rs index 517b165f23..754aa691e3 100644 --- a/pallets/claims/src/lib.rs +++ b/pallets/claims/src/lib.rs @@ -119,8 +119,6 @@ pub use crate::traits::WeightInfo as PalletWeightInfo; // Re-export in crate namespace (for runtime construction) pub use pallet::*; -mod migration; - // ---------------------------------------------------------------------------- // Traits and types declaration // ---------------------------------------------------------------------------- @@ -278,23 +276,6 @@ pub mod pallet { // Pallet lifecycle hooks // ---------------------------------------------------------------------------- - #[pallet::hooks] - impl Hooks> for Pallet { - fn on_runtime_upgrade() -> frame_support::weights::Weight { - migration::root_hashes::migrate::() - } - - #[cfg(feature = "try-runtime")] - fn pre_upgrade() -> Result<(), &'static str> { - migration::root_hashes::pre_migrate::() - } - - #[cfg(feature = "try-runtime")] - fn post_upgrade() -> Result<(), &'static str> { - migration::root_hashes::post_migrate::() - } - } - // ------------------------------------------------------------------------ // Pallet errors // ------------------------------------------------------------------------ diff --git a/pallets/claims/src/migration.rs b/pallets/claims/src/migration.rs deleted file mode 100644 index 41f580378a..0000000000 --- a/pallets/claims/src/migration.rs +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright 2022 Parity Technologies (UK) Ltd. -// This file is part of Centrifuge (centrifuge.io) parachain. - -// Cumulus is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. - -// Cumulus is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. - -// You should have received a copy of the GNU General Public License -// along with Cumulus. If not, see . - -use super::*; -use frame_support::{log, traits::Get, weights::Weight, Blake2_128Concat}; - -#[frame_support::storage_alias] -pub type RootHashes = - StorageMap::Hash, bool>; - -pub mod root_hashes { - use super::*; - - #[cfg(feature = "try-runtime")] - pub fn pre_migrate() -> Result<(), &'static str> { - let count = RootHashes::::iter_values().count(); - ensure!(count != 0, "RootHashes storage items not found!"); - log::info!( - target: "runtime::claims::pre-migrate", - "Pre Migrate check passed with count {:?}", - count, - ); - Ok(()) - } - - pub fn migrate() -> Weight { - RootHashes::::remove_all(None); // All keys should be deleted - log::info!(target: "runtime::claims::migrate", "Done Migrating"); - T::DbWeight::get().reads_writes(1, 1) - } - - #[cfg(feature = "try-runtime")] - pub fn post_migrate() -> Result<(), &'static str> { - ensure!( - RootHashes::::iter_values().count() == 0, - "RootHashes storage should be empty!" - ); - log::info!(target: "runtime::claims::post-migrate", "Post Migrate check passed"); - Ok(()) - } -} - -#[cfg(test)] -mod test { - use super::*; - use crate::mock::{MockRuntime as T, TestExternalitiesBuilder}; - use frame_support::assert_ok; - use sp_core::H256; - - #[test] - fn should_kill_root_hashes() { - TestExternalitiesBuilder::default() - .build() - .execute_with(|| { - assert_eq!(RootHashes::::iter_values().count(), 0); - let root_hash: H256 = [1; 32].into(); - RootHashes::::insert(root_hash, true); - assert_eq!(RootHashes::::iter_values().count(), 1); - assert_ok!(root_hashes::pre_migrate::()); - root_hashes::migrate::(); - assert_eq!(RootHashes::::iter_values().count(), 0); - assert_eq!( - root_hashes::pre_migrate::(), - Err("RootHashes storage items not found!") - ); - }); - } -}