open-runtime-module-library icon indicating copy to clipboard operation
open-runtime-module-library copied to clipboard

Account providers counter gets decremented on zero balance

Open vmarkushin opened this issue 3 years ago • 5 comments

According to this line, the providers count gets decremented if the account balance gets to zero. I haven't found similar logic in frame_balances, so the question is: why is it needed? What if I don't want any account to be removed if the balance reaches 0?

vmarkushin avatar Mar 29 '21 19:03 vmarkushin

It is required to prevent dust account. You can't keep account without balance. This is the corresponding logic in Substrate https://github.com/paritytech/substrate/blob/a2fdd15c047289426e6023f393ee9172d81cc0ff/frame/system/src/lib.rs#L1609

xlc avatar Mar 29 '21 20:03 xlc

@xlc this logic isn't related to balances, it's just related to providers count (if the number of providers gets 0, the account gets removed). Here is the balances logic: https://github.com/paritytech/substrate/blob/a2fdd15c047289426e6023f393ee9172d81cc0ff/frame/balances/src/lib.rs#L675 And as you can see, the zero check happens only when the balance gets below ExistencialDeposit. So if I have ExistencialDeposit = 0, my account should never be removed.

vmarkushin avatar Mar 30 '21 10:03 vmarkushin

And now you have dust account issue.

But we do plan to refactor all the ref count code with the recent changes https://github.com/AcalaNetwork/Acala/issues/784

xlc avatar Mar 30 '21 10:03 xlc

@xlc of course, but it will be intentional, that's why I set ExistencialDeposit to 0, to me It means that I want to keep all accounts, including dust accounts.

vmarkushin avatar Mar 30 '21 10:03 vmarkushin

ok. I will revisit this issue after we finished the refactor

xlc avatar Mar 30 '21 11:03 xlc