This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Description
slash does not respect allow_death check and can kill an account even it still have a positive ref count
|
fn slash( |
|
who: &T::AccountId, |
|
value: Self::Balance |
|
) -> (Self::NegativeImbalance, Self::Balance) { |
|
if value.is_zero() { return (NegativeImbalance::zero(), Zero::zero()) } |
|
|
|
Self::mutate_account(who, |account| { |
|
let free_slash = cmp::min(account.free, value); |
|
account.free -= free_slash; |
ref count is not checked when maybe_data is None
|
*maybe_value = maybe_data.map(|data| { |
|
let (nonce, refcount) = maybe_prefix.unwrap_or_default(); |
|
AccountInfo { nonce, refcount, data } |
|
}); |
|
(existed, maybe_value.is_some(), result) |
Should have some debugging warnings like
|
if account.refcount > 0 { |
|
debug::debug!( |
|
target: "system", |
|
"WARNING: Referenced account deleted. This is probably a bug." |
|
); |
|
} |