From 5a182a775c61abf860793e396f11b19f50c96eb1 Mon Sep 17 00:00:00 2001 From: Vadim Smirnov Date: Wed, 8 Nov 2023 02:55:33 +0800 Subject: [PATCH] set correct pallets storage version via migration --- runtime/vara/src/migrations.rs | 44 ++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-) diff --git a/runtime/vara/src/migrations.rs b/runtime/vara/src/migrations.rs index cd3fb87248b..27d46880c5b 100644 --- a/runtime/vara/src/migrations.rs +++ b/runtime/vara/src/migrations.rs @@ -16,7 +16,13 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . +use core::marker::PhantomData; + use crate::*; +use frame_support::{ + pallet_prelude::StorageVersion, + traits::{GetStorageVersion, OnRuntimeUpgrade}, +}; use sp_runtime::traits::Get; pub struct NominationPoolsMigrationV4OldPallet; @@ -26,15 +32,45 @@ impl Get for NominationPoolsMigrationV4OldPallet { } } +pub struct UpdatePalletsVersions(PhantomData); + +impl + OnRuntimeUpgrade for UpdatePalletsVersions +{ + fn on_runtime_upgrade() -> Weight { + // pallet_multisig + let onchain = pallet_multisig::Pallet::::on_chain_storage_version(); + if onchain == 0 { + log::info!("pallet_multisig onchain: {:?}", onchain); + StorageVersion::new(1).put::>(); + } + + let onchain = pallet_multisig::Pallet::::on_chain_storage_version(); + log::info!("pallet_multisig onchain: {:?}", onchain); + + // pallet_nomination_pools + let onchain = pallet_nomination_pools::Pallet::::on_chain_storage_version(); + if onchain == 0 { + log::info!("pallet_nomination_pools onchain: {:?}", onchain); + StorageVersion::new(5).put::>(); + } + + let onchain = pallet_nomination_pools::Pallet::::on_chain_storage_version(); + log::info!("pallet_nomination_pools onchain: {:?}", onchain); + + // pallet_bounties + StorageVersion::new(4).put::>(); + + Weight::zero() + } +} + /// All migrations that will run on the next runtime upgrade. /// /// Should be cleared after every release. pub type Migrations = ( // unreleased - pallet_nomination_pools::migration::v4::MigrateV3ToV5< - Runtime, - NominationPoolsMigrationV4OldPallet, - >, + UpdatePalletsVersions, pallet_offences::migration::v1::MigrateToV1, pallet_gear_program::migrations::MigrateToV3, );