Fix: stash account reaped when ledger.active == ED (#8170)

* do not reap account when active == ed

* add tests + refactor
This commit is contained in:
Guillaume Thiolliere
2021-02-22 17:46:45 +01:00
committed by GitHub
parent b2f393945a
commit 115dcd81dc
4 changed files with 42 additions and 5 deletions
+2 -2
View File
@@ -1638,7 +1638,7 @@ decl_module! {
ledger = ledger.consolidate_unlocked(current_era)
}
let post_info_weight = if ledger.unlocking.is_empty() && ledger.active <= T::Currency::minimum_balance() {
let post_info_weight = if ledger.unlocking.is_empty() && ledger.active < T::Currency::minimum_balance() {
// This account must have called `unbond()` with some value that caused the active
// portion to fall below existential deposit + will have no more unlocking chunks
// left. We can now safely remove all staking-related information.
@@ -3080,7 +3080,7 @@ impl<T: Config> Module<T> {
/// Assumes storage is upgraded before calling.
///
/// This is called:
/// - after a `withdraw_unbond()` call that frees all of a stash's bonded balance.
/// - after a `withdraw_unbonded()` call that frees all of a stash's bonded balance.
/// - through `reap_stash()` if the balance has fallen to zero (through slashing).
fn kill_stash(stash: &T::AccountId, num_slashing_spans: u32) -> DispatchResult {
let controller = <Bonded<T>>::get(stash).ok_or(Error::<T>::NotStash)?;