Skip to content

Commit 5df6047

Browse files
authored
simplify migrate_locks_to_freezes_batch migration function (#3517)
1 parent 570f126 commit 5df6047

File tree

1 file changed

+3
-20
lines changed
  • pallets/parachain-staking/src

1 file changed

+3
-20
lines changed

pallets/parachain-staking/src/lib.rs

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ pub mod pallet {
8282
};
8383
use crate::{set::BoundedOrderedSet, traits::*, types::*, InflationInfo, Range, WeightInfo};
8484
use crate::{AutoCompoundConfig, AutoCompoundDelegations};
85-
use frame_support::dispatch::{DispatchResultWithPostInfo, Pays, PostDispatchInfo};
85+
use frame_support::dispatch::{DispatchResultWithPostInfo, Pays};
8686
use frame_support::pallet_prelude::*;
8787
use frame_support::traits::{
8888
fungible::{Balanced, Inspect, Mutate, MutateFreeze},
@@ -1449,19 +1449,11 @@ pub mod pallet {
14491449

14501450
let total_accounts = accounts.len() as u32;
14511451
let mut successful_migrations = 0u32;
1452-
let mut delegators = 0u32;
1453-
let mut candidates = 0u32;
14541452

14551453
for (account, is_collator) in accounts.iter() {
14561454
if Self::check_and_migrate_lock(account, *is_collator) {
14571455
successful_migrations = successful_migrations.saturating_add(1);
14581456
}
1459-
1460-
if *is_collator {
1461-
candidates = candidates.saturating_add(1);
1462-
} else {
1463-
delegators = delegators.saturating_add(1);
1464-
}
14651457
}
14661458

14671459
// Calculate success rate
@@ -1471,24 +1463,15 @@ pub mod pallet {
14711463
Percent::zero()
14721464
};
14731465

1474-
// Calculate actual weight consumed
1475-
let actual_weight = if candidates > 0 {
1476-
T::WeightInfo::migrate_locks_to_freezes_batch(total_accounts)
1477-
} else {
1478-
Weight::zero()
1479-
};
1480-
14811466
// Apply refund if 50% or more successful using Percent comparison
14821467
let pays_fee = if success_rate >= Percent::from_percent(50) {
14831468
Pays::No
14841469
} else {
14851470
Pays::Yes
14861471
};
14871472

1488-
Ok(PostDispatchInfo {
1489-
actual_weight: Some(actual_weight),
1490-
pays_fee,
1491-
})
1473+
// Returning `actual_weight` as `None` stands for the worst case static weight.
1474+
Ok(pays_fee.into())
14921475
}
14931476
}
14941477

0 commit comments

Comments
 (0)