Skip to content
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

RefProvider #2495

Open
xlc opened this issue Mar 20, 2023 · 1 comment
Open

RefProvider #2495

xlc opened this issue Mar 20, 2023 · 1 comment

Comments

@xlc
Copy link
Member

xlc commented Mar 20, 2023

With paritytech/substrate#12951, reserved balance no longer add provider ref.

Update the module-support to add features to reserve balance and manage provider ref.

  • fn reserve(who: Account, id: ReserveId, amount: Balance)
    • reserve amount.max(ED)
    • inc provider for who
  • fn unreserve(who: Account, id: ReserveId, amount: Option)
    • amount = amount.unwrap_or(current_reserve_amount)
    • ensure remaining is zero or >= ED
    • if remaning == 0
      • dec provider for who

Review all pallets that uses reserve and replace the usage with this

This should be fully backward compatible

In future, we should be able to modify those two helpers to migrate to the fungible trait

@xlc xlc mentioned this issue Jun 18, 2023
@wangjj9219
Copy link
Member

Now, as long as the reserve_amount is not zero, even if free_balance is zero, the account will not be dusted.

But reserve operation may fail for provider/consumer:
if an account only free: 2*ED, reserved: 0, its provider,consumer: 1,0

reserve 2ED, the expected result is free: 0, reserved: 2*ED, will inc consumer first, then dec provider. dec provider will fail for ConsumerRemaining.

we can:
use wrapper reserve function, which do inc_provider before call reserve
use wrapper unreserve function , which do dec_provider after call unreserve and check

In this way, regardless of whether free_balance has ED or not,
before reserve step, additional provider additional was provided for dec. It seems a feasible solution, but for these account has reserved already, it should require more judgment to decide whether to inc provider or dec provider.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants