From 965592285c7b56bc69b7da14f4db7e2eb1e013e6 Mon Sep 17 00:00:00 2001 From: Minqi Wang Date: Sun, 29 Dec 2024 15:41:18 +0800 Subject: [PATCH] chore: fix --- .../runtime/litentry/src/migration/mod.rs | 75 +++++++++++-------- 1 file changed, 43 insertions(+), 32 deletions(-) diff --git a/parachain/runtime/litentry/src/migration/mod.rs b/parachain/runtime/litentry/src/migration/mod.rs index ce6bb6157a..f4d476005a 100644 --- a/parachain/runtime/litentry/src/migration/mod.rs +++ b/parachain/runtime/litentry/src/migration/mod.rs @@ -45,8 +45,9 @@ // In try-runtime, current implementation, the storage version is not checked, // Pallet version is used instead. -use super::{DeveloperCommittee, DeveloperCommitteeMembership}; -use frame_support::traits::{Get, OnRuntimeUpgrade, PalletInfoAccess, StorageVersion}; +use frame_support::traits::{ + Get, GetStorageVersion, OnRuntimeUpgrade, PalletInfoAccess, StorageVersion, +}; use frame_system::pallet_prelude::BlockNumberFor; use pallet_balances::InactiveIssuance; use pallet_scheduler::Agenda; @@ -113,13 +114,13 @@ pub struct RemoveSchedulerOldStorage(PhantomData); impl OnRuntimeUpgrade for RemoveSchedulerOldStorage where T: frame_system::Config + pallet_scheduler::Config, - BlockNumberFor: From, + BlockNumberFor: From, { #[cfg(feature = "try-runtime")] fn pre_upgrade() -> Result, &'static str> { log::info!("Pre check pallet scheduler storage only has two precise tasks leftover"); - let one: BlockNumberFor = 3067200u128.into(); - let two: BlockNumberFor = 2995200u128.into(); + let one: BlockNumberFor = 3067200u32.into(); + let two: BlockNumberFor = 2995200u32.into(); for (when, vec_schedule) in >::iter() { assert!(when == one || when == two, "Extra schedule exists"); } @@ -129,8 +130,8 @@ where fn on_runtime_upgrade() -> frame_support::weights::Weight { // Remove Scheduler Storage precisely of according block agenda only // TODO: Very Weak safety - let one: BlockNumberFor = 3067200u128.into(); - let two: BlockNumberFor = 2995200u128.into(); + let one: BlockNumberFor = 3067200u32.into(); + let two: BlockNumberFor = 2995200u32.into(); Agenda::::remove(one); Agenda::::remove(two); @@ -146,8 +147,8 @@ where #[cfg(feature = "try-runtime")] fn post_upgrade(_state: Vec) -> Result<(), &'static str> { - let one: BlockNumberFor = 3067200u128.into(); - let two: BlockNumberFor = 2995200u128.into(); + let one: BlockNumberFor = 3067200u32.into(); + let two: BlockNumberFor = 2995200u32.into(); for (when, vec_schedule) in >::iter() { assert!(when != one && when != two, "Old schedule still exists"); } @@ -159,10 +160,10 @@ where } const BALANCES_LOG_TARGET: &str = "runtime::balances"; -pub struct BalancesUpdateStorageVersionResetInactive(PhantomData<(T, I)>); -impl OnRuntimeUpgrade for BalancesUpdateStorageVersionResetInactive +pub struct BalancesUpdateStorageVersionResetInactive(PhantomData); +impl OnRuntimeUpgrade for BalancesUpdateStorageVersionResetInactive where - T: frame_system::Config + pallet_balances::Config, + T: frame_system::Config + pallet_balances::Config, { #[cfg(feature = "try-runtime")] fn pre_upgrade() -> Result, &'static str> { @@ -174,19 +175,19 @@ where } fn on_runtime_upgrade() -> frame_support::weights::Weight { - let on_chain_version = pallet_balances::Pallet::::on_chain_storage_version(); + let on_chain_version = pallet_balances::Pallet::::on_chain_storage_version(); if on_chain_version == 0 { // Remove the old `StorageVersion` type. frame_support::storage::unhashed::kill(&frame_support::storage::storage_prefix( - pallet_balances::Pallet::::name().as_bytes(), + pallet_balances::Pallet::::name().as_bytes(), "StorageVersion".as_bytes(), )); - InactiveIssuance::::kill(); + InactiveIssuance::::kill(); // Set storage version to `1`. - StorageVersion::new(1).put::>(); + StorageVersion::new(1).put::>(); log::info!(target: BALANCES_LOG_TARGET, "Storage to version 1"); T::DbWeight::get().reads_writes(1, 3) @@ -231,8 +232,6 @@ where "StorageVersion".as_bytes(), )); - InactiveIssuance::::kill(); - // Set storage version to `4`. StorageVersion::new(4).put::>(); @@ -263,26 +262,28 @@ where #[cfg(feature = "try-runtime")] fn pre_upgrade() -> Result, &'static str> { ensure!( - StorageVersion::get::() == 0, + StorageVersion::get::>() + == 0, "Already upgrade to some non-zero version" ); Ok(Vec::::new()) } fn on_runtime_upgrade() -> frame_support::weights::Weight { - let on_chain_version = DeveloperCommittee::on_chain_storage_version(); + let on_chain_version = + pallet_collective::Pallet::::on_chain_storage_version( + ); if on_chain_version == 0 { // Remove the old `StorageVersion` type. frame_support::storage::unhashed::kill(&frame_support::storage::storage_prefix( - DeveloperCommittee::name().as_bytes(), + pallet_collective::Pallet::::name().as_bytes(), "StorageVersion".as_bytes(), )); - InactiveIssuance::::kill(); - // Set storage version to `4`. - StorageVersion::new(4).put::(); + StorageVersion::new(4) + .put::>(); log::info!(target: DEVELOPER_COMMITTEE_LOG_TARGET, "Storage to version 4"); T::DbWeight::get().reads_writes(1, 3) @@ -297,7 +298,11 @@ where #[cfg(feature = "try-runtime")] fn post_upgrade(_state: Vec) -> Result<(), &'static str> { - ensure!(StorageVersion::get::() == 4, "Must upgrade"); + ensure!( + StorageVersion::get::>() + == 4, + "Must upgrade" + ); Ok(()) } } @@ -311,26 +316,28 @@ where #[cfg(feature = "try-runtime")] fn pre_upgrade() -> Result, &'static str> { ensure!( - StorageVersion::get::() == 0, + StorageVersion::get::>() + == 0, "Already upgrade to some non-zero version" ); Ok(Vec::::new()) } fn on_runtime_upgrade() -> frame_support::weights::Weight { - let on_chain_version = DeveloperCommitteeMembership::on_chain_storage_version(); + let on_chain_version = + pallet_membership::Pallet::::on_chain_storage_version( + ); if on_chain_version == 0 { // Remove the old `StorageVersion` type. frame_support::storage::unhashed::kill(&frame_support::storage::storage_prefix( - DeveloperCommitteeMembership::name().as_bytes(), + pallet_membership::Pallet::::name().as_bytes(), "StorageVersion".as_bytes(), )); - InactiveIssuance::::kill(); - // Set storage version to `4`. - StorageVersion::new(4).put::(); + StorageVersion::new(4) + .put::>(); log::info!(target: DEVELOPER_COMMITTEE_MEMBERSHIP_LOG_TARGET, "Storage to version 4"); T::DbWeight::get().reads_writes(1, 3) @@ -345,7 +352,11 @@ where #[cfg(feature = "try-runtime")] fn post_upgrade(_state: Vec) -> Result<(), &'static str> { - ensure!(StorageVersion::get::() == 4, "Must upgrade"); + ensure!( + StorageVersion::get::>() + == 4, + "Must upgrade" + ); Ok(()) } }