diff --git a/pallets/parachain-staking/src/lib.rs b/pallets/parachain-staking/src/lib.rs index bc8d333bed..6b9abd904d 100644 --- a/pallets/parachain-staking/src/lib.rs +++ b/pallets/parachain-staking/src/lib.rs @@ -142,17 +142,6 @@ pub mod pallet { pub total: Balance, } - #[derive(Encode, Decode, RuntimeDebug)] - /// DEPRECATED: This is the old storage schema. It is retained for purposes of storage migration - /// and should be removed in the future. - pub struct Collator { - pub id: AccountId, - pub bond: Balance, - pub nominators: OrderedSet>, - pub total: Balance, - pub state: CollatorStatus, - } - #[derive(Encode, Decode, RuntimeDebug)] /// Collator state with commission fee, bonded stake, and nominations pub struct Collator2 { @@ -439,31 +428,6 @@ pub mod pallet { } } - impl From> for Collator2 { - fn from(other: Collator) -> Collator2 { - // nominator set from Collator was bounded to max size of top_nominators - let mut top_nominators = other.nominators.0.clone(); - // order greatest to least - top_nominators.sort_unstable_by(|a, b| b.amount.cmp(&a.amount)); - Collator2 { - id: other.id, - bond: other.bond, - nominators: other - .nominators - .0 - .iter() - .map(|Bond { owner, .. }| owner.clone()) - .collect::>() - .into(), - top_nominators, - bottom_nominators: Vec::new(), - total_counted: other.total, - total_backing: other.total, - state: other.state, - } - } - } - impl From> for CollatorSnapshot { fn from(other: Collator2) -> CollatorSnapshot { CollatorSnapshot { @@ -764,33 +728,6 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet { - fn on_runtime_upgrade() -> Weight { - // migrate from Collator -> Collator2 - for (acc, collator_state) in CollatorState::::drain() { - let state: Collator2> = collator_state.into(); - >::insert(acc, state); - } - - // correct any incorrectly set `Total` - let old_total = Total::::get(); - let mut new_total: BalanceOf = 0u32.into(); - - for collator_state in CollatorState2::::iter_values() { - new_total += collator_state.total_backing; - } - - Total::::put(new_total); - - log::trace!( - target: "staking", - "Finished migrating storage.\nOld Total : {:?}\nNew Total : {:?}", - old_total, - new_total, - ); - - 300_000_000_000 // Three fifths of the max block weight - } - fn on_initialize(n: T::BlockNumber) -> Weight { let mut round = >::get(); if round.should_update(n) { @@ -852,18 +789,6 @@ pub mod pallet { OptionQuery, >; - #[pallet::storage] - #[pallet::getter(fn collator_state)] - /// DEPRECATED: This is the old storage item. It is retained for purposes of storage migration - /// and should be removed in the future. - type CollatorState = StorageMap< - _, - Twox64Concat, - T::AccountId, - Collator>, - OptionQuery, - >; - #[pallet::storage] #[pallet::getter(fn collator_state2)] /// Get collator state associated with an account if account is collating else None