-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dust Account Detection Strategy? #101
Comments
In this case, the account should definitely be kept. For now, let's follow strict and safe strategy: Only Account.ring < existential_deposit and account.kton == 0 will get killed. For KTON, there is no existential_deposit, or the default existential_deposit is zero. |
Implement Will be solved in #307. Example: // support.rs
pub trait ExistentialCheck<AccountId, Balance> {
fn try_drop(who: &AccountId) -> (bool, Balance);
}
// kton.rs
impl<T: Trait<I>, I: Instance> ExistentialCheck<T::AccountId, T::Balance> for Module<T, I>
where
T::Balance: MaybeSerializeDeserialize + Debug,
{
fn try_drop(who: &T::AccountId) -> (bool, T::Balance) {
let dropped_kton = Self::total_balance(who);
let dropped = !dropped_kton.is_zero() && dropped_kton < T::ExistentialDeposit::get();
if dropped {
T::DustRemoval::on_unbalanced(NegativeImbalance::new(dropped_kton));
}
(dropped, dropped_kton)
}
}
// ring.rs
fn post_mutation(who: &T::AccountId, new: ActiveBalance<T::Balance>) -> Option<ActiveBalance<T::Balance>> {
let total = new.total();
if total < T::ExistentialDeposit::get() {
if !total.is_zero() {
let (dropped, dropped_kton) = T::ExistentialCheck::try_drop(who);
if dropped {
T::DustRemoval::on_unbalanced(NegativeImbalance::new(total));
Self::deposit_event(RawEvent::DustLost(who.clone(), total, dropped_kton));
}
}
None
} else {
Some(new)
}
} |
// ring.rs
fn post_mutation(who: &T::AccountId, new: ActiveBalance<T::Balance>) -> Option<ActiveBalance<T::Balance>> {
let total = new.total();
if total < T::ExistentialDeposit::get() {
let (dropped, dropped_kton) = T::ExistentialCheck::try_drop(who);
if dropped {
if !total.is_zero(){
T::DustRemoval::on_unbalanced(NegativeImbalance::new(total));
Self::deposit_event(RawEvent::DustLost(who.clone(), total, dropped_kton));
}
None
} else {
Some(new)
}
} else {
Some(new)
}
} |
Got killed?
The text was updated successfully, but these errors were encountered: