diff --git a/frame/transaction-payment/src/lib.rs b/frame/transaction-payment/src/lib.rs index 83ff69428d..d7c960f77d 100644 --- a/frame/transaction-payment/src/lib.rs +++ b/frame/transaction-payment/src/lib.rs @@ -78,6 +78,8 @@ mod tests; mod payment; mod types; +pub mod migrations; + pub use pallet::*; pub use payment::*; pub use types::{FeeDetails, InclusionFee, RuntimeDispatchInfo}; diff --git a/frame/transaction-payment/src/migrations.rs b/frame/transaction-payment/src/migrations.rs new file mode 100644 index 0000000000..065604b2fb --- /dev/null +++ b/frame/transaction-payment/src/migrations.rs @@ -0,0 +1,22 @@ + + + +// temporary code to set the migration to V1 +pub mod v1 { + use super::*; + + /// Manually setting the version to V1 + pub struct ForceSetVersionToV2(sp_std::marker::PhantomData); + impl OnRuntimeUpgrade for ForceSetVersionToV2 { + fn on_runtime_upgrade() -> Weight { + + if StorageVersion::::get() == Releases::V1 { + StorageVersion::::put(Releases::V1Ancient); + } + + T::DbWeight::get().reads_writes(1, 1) + } + + } + +} \ No newline at end of file diff --git a/frame/vesting/src/migrations.rs b/frame/vesting/src/migrations.rs index 69bbc97296..ba627a5636 100644 --- a/frame/vesting/src/migrations.rs +++ b/frame/vesting/src/migrations.rs @@ -35,33 +35,18 @@ pub mod v1 { Ok(()) } - /// Migrate from single schedule to multi schedule storage. - /// WARNING: This migration will delete schedules if `MaxVestingSchedules < 1`. - pub fn migrate() -> Weight { - let mut reads_writes = 0; + /// Manually setting the version to V1 + pub struct ForceSetVersionToV1(sp_std::marker::PhantomData); + impl OnRuntimeUpgrade for ForceSetVersionToV1 { + fn on_runtime_upgrade() -> Weight { - Vesting::::translate::, T::BlockNumber>, _>( - |_key, vesting_info| { - reads_writes += 1; - let v: Option< - BoundedVec< - VestingInfo, T::BlockNumber>, - MaxVestingSchedulesGet, - >, - > = vec![vesting_info].try_into().ok(); - - if v.is_none() { - log::warn!( - target: "runtime::vesting", - "migration: Failed to move a vesting schedule into a BoundedVec" - ); - } - - v - }, - ); - - T::DbWeight::get().reads_writes(reads_writes, reads_writes) + if StorageVersion::::get() == Releases::V0 { + StorageVersion::::put(Releases::V1); + } + + T::DbWeight::get().reads_writes(1, 1) + } + } #[cfg(feature = "try-runtime")]