Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

pallet-balances: Decouple existential deposit and kill account #7563

Closed
xlc opened this issue Nov 20, 2020 · 1 comment
Closed

pallet-balances: Decouple existential deposit and kill account #7563

xlc opened this issue Nov 20, 2020 · 1 comment

Comments

@xlc
Copy link
Contributor

xlc commented Nov 20, 2020

The situation

Acala is using pallet-balances and orml-tokens at same time to handle tokens. pallet-balances is used to handle the native token ACA and orml-tokens is used to handle other tokens (e.g. aUSD, renBTC, DOT, etc).

We have implemented a solution to allow user to use any supported tokens (e.g. aUSD, renBTC, DOT) to pay for transaction fee. This means our users does not need to hold our native token ACA at all.

To prevent dust account, pallet-balances implements a way to wipe account data (balance & nonce & refcount) when account balances drops below existential deposit.

The problem

We may not want to wipe account data when the pallet-balances balance drops below existential deposit because the user may hold other tokens and therefore should not remove nonce.

However the current implementation of pallet-balances will always drop account data when balances drops below existential deposit.

We can prevent balances drops below existential deposit by increase ref count for accounts have orml-tokens balances but because it is totally possible for an account never have any ACA balances at all, those account cannot be killed. Decrease ref count to zero does nothing at current Substrate implementation.

The changes we need

There are few changes required to solve our problem and not introduce breaking changes to existing production chains

  • Add a hook to frame-system when ref count changes (or drop to zero)
    • This will allow us to trigger kill account when ref count drops to zero
  • Add a hook to pallet-balances when an account balances changes (or when changing existential deposit status)
    • A struct will be provided to have the existing behavior. i.e. prevent drop to zero if not allow death and kill account if drop to zero
    • We will make it inc/dec ref count for our chain

As a result, on Acala, an account cannot be killed as long as it holds any kind of tokens. When the balances for all tokens drops below existential deposit, then the account will be killed on last transfer.

@xlc
Copy link
Contributor Author

xlc commented Nov 20, 2020

Will be fixed by #7363

@xlc xlc closed this as completed Nov 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant