From 3f6afedfac59c346ad75b4423d1869b4c9f78687 Mon Sep 17 00:00:00 2001 From: h4x3rotab Date: Fri, 29 Apr 2022 10:28:06 +0000 Subject: [PATCH] stakepool: add migration to remove deprecated assgnments --- pallets/phala/src/migrations/mod.rs | 4 +++- pallets/phala/src/stakepool.rs | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/pallets/phala/src/migrations/mod.rs b/pallets/phala/src/migrations/mod.rs index 69ac9afe98..4cd630d722 100644 --- a/pallets/phala/src/migrations/mod.rs +++ b/pallets/phala/src/migrations/mod.rs @@ -148,12 +148,14 @@ pub mod v5 { pub fn migrate() -> Weight where T: fat::Config + mining::Config + mq::Config + registry::Config + stakepool::Config, - MiningBalanceOf: balance_convert::FixedPointConvert, + MiningBalanceOf: balance_convert::FixedPointConvert + sp_std::fmt::Display, + T: mining::pallet::Config::Currency>, { if get_versions::() == EXPECTED_STORAGE_VERSION { let mut weight: Weight = 0; log::info!("Ᵽ migrating phala-pallets to v5"); weight += mining::migrations::trigger_unresp_fix::(); + weight += stakepool::Pallet::::migration_remove_assignments(); log::info!("Ᵽ pallets migrated to v5"); StorageVersion::new(5).put::>(); diff --git a/pallets/phala/src/stakepool.rs b/pallets/phala/src/stakepool.rs index 1f4b46b47f..1775696aa1 100644 --- a/pallets/phala/src/stakepool.rs +++ b/pallets/phala/src/stakepool.rs @@ -1195,6 +1195,11 @@ pub mod pallet { } WithdrawalTimestamps::::put(&t); } + + pub(crate) fn migration_remove_assignments() -> Weight { + let writes = WorkerAssignments::::drain().count(); + T::DbWeight::get().writes(writes as _) + } } impl mining::OnReward for Pallet