Skip to content

Commit

Permalink
Merge pull request #759 from Phala-Network/migration-spassignment
Browse files Browse the repository at this point in the history
stakepool: add migration to remove deprecated assgnments
  • Loading branch information
h4x3rotab authored Apr 29, 2022
2 parents 96e2eb4 + 3f6afed commit d6f39a4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pallets/phala/src/migrations/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,14 @@ pub mod v5 {
pub fn migrate<T>() -> Weight
where
T: fat::Config + mining::Config + mq::Config + registry::Config + stakepool::Config,
MiningBalanceOf<T>: balance_convert::FixedPointConvert,
MiningBalanceOf<T>: balance_convert::FixedPointConvert + sp_std::fmt::Display,
T: mining::pallet::Config<Currency = <T as stakepool::pallet::Config>::Currency>,
{
if get_versions::<T>() == EXPECTED_STORAGE_VERSION {
let mut weight: Weight = 0;
log::info!("Ᵽ migrating phala-pallets to v5");
weight += mining::migrations::trigger_unresp_fix::<T>();
weight += stakepool::Pallet::<T>::migration_remove_assignments();
log::info!("Ᵽ pallets migrated to v5");

StorageVersion::new(5).put::<fat::Pallet<T>>();
Expand Down
5 changes: 5 additions & 0 deletions pallets/phala/src/stakepool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1195,6 +1195,11 @@ pub mod pallet {
}
WithdrawalTimestamps::<T>::put(&t);
}

pub(crate) fn migration_remove_assignments() -> Weight {
let writes = WorkerAssignments::<T>::drain().count();
T::DbWeight::get().writes(writes as _)
}
}

impl<T: Config> mining::OnReward for Pallet<T>
Expand Down

0 comments on commit d6f39a4

Please sign in to comment.