From a502db99fba01684078719fb1337c21b5096e3e6 Mon Sep 17 00:00:00 2001 From: arunjot12 Date: Thu, 14 Nov 2024 14:52:34 +0530 Subject: [PATCH] fix:removed the ununsed storage --- frame/reward/src/lib.rs | 14 -------------- frame/reward/src/migration.rs | 21 +-------------------- 2 files changed, 1 insertion(+), 34 deletions(-) diff --git a/frame/reward/src/lib.rs b/frame/reward/src/lib.rs index 0be56c62..36c0a608 100644 --- a/frame/reward/src/lib.rs +++ b/frame/reward/src/lib.rs @@ -96,14 +96,6 @@ pub mod pallet { type WeightInfo: WeightInfo; } - // #[pallet::hooks] - // impl Hooks> for Pallet { - // fn on_runtime_upgrade() -> frame_support::weights::Weight { - // migrate_to_v1::() - // } - - // } - /// The era reward which are distributed among the validator and nominator #[pallet::storage] #[pallet::getter(fn total_rewards)] @@ -122,12 +114,6 @@ pub mod pallet { pub type ValidatorRewardAccounts = StorageMap<_, Blake2_128Concat, T::AccountId, T::Balance, ValueQuery>; - /// Specifics regarding the rewards distributed within the designated era of the nominator - #[pallet::storage] - #[pallet::getter(fn nominator_reward_accounts)] - pub type NominatorRewardAccounts = - StorageMap<_, Blake2_128Concat, T::AccountId, T::Balance, ValueQuery>; - /// Storage that tracks the rewards earned by nominators for each validator #[pallet::storage] #[pallet::getter(fn nominator_earning_accounts)] diff --git a/frame/reward/src/migration.rs b/frame/reward/src/migration.rs index 6ba339ec..872f05bf 100644 --- a/frame/reward/src/migration.rs +++ b/frame/reward/src/migration.rs @@ -23,24 +23,7 @@ pub mod v1 { ); if onchain_version == 0 { - let mut count = 0; - for (nominator_id, balance) in NominatorRewardAccounts::::iter() { - if let Some(nominations) = - pallet_staking::Nominators::::get(nominator_id.clone()) - { - if let Some(validator) = nominations.targets.first() { - NominatorEarningsAccount::::mutate( - validator, - nominator_id.clone(), - |earlier_reward| { - *earlier_reward += balance; - }, - ) - } - NominatorRewardAccounts::::remove(nominator_id.clone()); - } - count += 1; - } + let count = 0; StorageVersion::new(1).put::>(); log!(Level::Info, "reward v1 applied successfully"); T::DbWeight::get().reads_writes((count as u64) + 1, (count as u64) + 1) @@ -61,8 +44,6 @@ pub mod v1 { let prev_count_old_storage: u32 = Decode::decode(&mut prev_count.as_slice()).expect( "the state parameter should be something that was generated by pre_upgrade", ); - let post_count_old_storage = NominatorRewardAccounts::::iter().count() as u32; - ensure!(post_count_old_storage == 0, "count should be 0 in NominatorRewardAccounts"); // compare old storage key length (NominatorRewardAccounts) and new storage key length // (NominatorEarningsAccount)