From 83e8fe42215e9812672d2cc9647e8d3d3df47a00 Mon Sep 17 00:00:00 2001 From: Dmitry Sinyavin Date: Mon, 13 Feb 2023 21:07:28 +0100 Subject: [PATCH] Remove migration (again!) --- .../parachains/src/session_info/migration.rs | 68 +------------------ runtime/rococo/src/lib.rs | 1 - runtime/westend/src/lib.rs | 1 - 3 files changed, 1 insertion(+), 69 deletions(-) diff --git a/runtime/parachains/src/session_info/migration.rs b/runtime/parachains/src/session_info/migration.rs index 00212e409034..c0ec1e5915bd 100644 --- a/runtime/parachains/src/session_info/migration.rs +++ b/runtime/parachains/src/session_info/migration.rs @@ -19,70 +19,4 @@ use frame_support::traits::StorageVersion; /// The current storage version. -pub const STORAGE_VERSION: StorageVersion = StorageVersion::new(2); - -pub mod v2 { - use super::STORAGE_VERSION; - #[cfg(feature = "try-runtime")] - use crate::session_info::Vec; - use crate::{session_info, session_info::Pallet, shared}; - use frame_support::{ - pallet_prelude::Weight, - traits::{OnRuntimeUpgrade, StorageVersion}, - }; - use frame_system::Config; - use primitives::vstaging::ExecutorParams; - use sp_core::Get; - - const LOG_TARGET: &'static str = "runtime::session_info::migration::v2"; - - pub struct MigrateToV2(sp_std::marker::PhantomData); - impl OnRuntimeUpgrade for MigrateToV2 { - fn on_runtime_upgrade() -> Weight { - // Bootstrap session executor params with the default ones if no parameters for the - // current session are in storage. `ExecutorParams::default()` is supposed to generate - // EXACTLY the same set of parameters the previous implementation used in a hard-coded - // form. This supposed to only run once, when upgrading from pre-parametrized executor - // code. - let db_weight = T::DbWeight::get(); - let mut weight = db_weight.reads(1); - if StorageVersion::get::>() == 1 { - log::info!(target: LOG_TARGET, "Upgrading storage v1 -> v2"); - let first_session = >::earliest_stored_session(); - let current_session = >::session_index(); - - for session_index in first_session..=current_session { - session_info::pallet::SessionExecutorParams::::insert( - &session_index, - ExecutorParams::default(), - ); - } - - STORAGE_VERSION.put::>(); - weight += db_weight.reads_writes(2, (current_session - first_session + 2) as u64); - } else { - log::warn!(target: LOG_TARGET, "Can only upgrade from version 1"); - } - weight - } - - #[cfg(feature = "try-runtime")] - fn pre_upgrade() -> Result, &'static str> { - log::info!(target: LOG_TARGET, "Performing pre-upgrade checks"); - assert_eq!(StorageVersion::get::>(), 1); - let session_index = >::session_index(); - assert!(Pallet::::session_executor_params(session_index).is_none()); - Ok(Default::default()) - } - - #[cfg(feature = "try-runtime")] - fn post_upgrade(_: Vec) -> Result<(), &'static str> { - log::info!(target: LOG_TARGET, "Performing post-upgrade checks"); - assert_eq!(StorageVersion::get::>(), 2); - let session_index = >::session_index(); - let executor_params = Pallet::::session_executor_params(session_index); - assert_eq!(executor_params, Some(ExecutorParams::default())); - Ok(()) - } - } -} +pub const STORAGE_VERSION: StorageVersion = StorageVersion::new(1); diff --git a/runtime/rococo/src/lib.rs b/runtime/rococo/src/lib.rs index 4c9d231a1b1a..cc268df94efd 100644 --- a/runtime/rococo/src/lib.rs +++ b/runtime/rococo/src/lib.rs @@ -1491,7 +1491,6 @@ pub type Migrations = ( // "Use 2D weights in XCM v3" pallet_xcm::migration::v1::MigrateToV1, parachains_ump::migration::v1::MigrateToV1, - parachains_session_info::migration::v2::MigrateToV2, // Remove stale entries in the set id -> session index storage map (after // this release they will be properly pruned after the bonding duration has // elapsed) diff --git a/runtime/westend/src/lib.rs b/runtime/westend/src/lib.rs index 6ef3e6ba834a..80f79898ae00 100644 --- a/runtime/westend/src/lib.rs +++ b/runtime/westend/src/lib.rs @@ -1247,7 +1247,6 @@ pub type Migrations = ( // "Use 2D weights in XCM v3" pallet_xcm::migration::v1::MigrateToV1, parachains_ump::migration::v1::MigrateToV1, - parachains_session_info::migration::v2::MigrateToV2, // Remove stale entries in the set id -> session index storage map (after // this release they will be properly pruned after the bonding duration has // elapsed)