-
Notifications
You must be signed in to change notification settings - Fork 550
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
Polkadot v0.9.42 #2560
Polkadot v0.9.42 #2560
Conversation
we should do this to handle ref count #2495 and replace most of our reserves to RefProvider |
How to prevent Now we have come to a crossroads, should we use the current PR solution or do this: |
we also need to kill dust on account killed |
b82d76b
to
b3873af
Compare
pallet-balances breaking change
[email protected] uses new provider/consumers mechanism, there's breaking change: now pallet-balances Account supply provider based on its
free_balance
instead oftotal_balance
, and no-zeroreserved_balance
will as consumer.It will affect some case, if the ED of native token is 100:
if a account endowed by
200
(>ed) free_balance, its provider inc 1, the(provider, consumer)
is(1, 0)
. Then reserve its200
free_balance to reserved balance, according to new rules, consumer will inc 1, and free_balance changes to0
, it's below ED, provider will dec 1, However, due to consumer is 1, the provider cannot become 0. So the reserve operation will fail.For users, when they do some operations, their account generally has sufficient Native token, or has other tokens assets as providers. BUT some functions of Acala will use some escrow accounts, which are only used to store reserved ACA/KAR:
1. create NFT class
It will do:
now it will fail when reserve.
Solution
For create NFT class, transfer total deposit + ACA ED to class account. after reserve total deposit, free_balance is still >= ED (
provider, consumer
is1, 0
) .For mint nft and transfer nft, if the receiver's free_balance is <= ed, transfer ED to receiver.
2. deploy contract or call contract in EVM+
the situation is much more complicated:
provider, consumer
is1, 0
) before charge storage.delta
is positive,1.1
transfer
delta
from origin caller to contract account1.2
reserve
delta
amount free_balance to reserved_balancedelta
is negative,2.1.
repatriate_reserved
thedelta
reserved balance from contract account to origin callerHere are the results for each case:
a. deploy a new contract, the
delta
is positive and >= ED, it will succeed. before thereserve
operation ,provider, consumer
is2, 0
,1
is added byinc_provider
directly,1
is added by transfer operation. Afterreserve
operation,provider, consumer
is1, 1
b. call contract, the
delta
is positive and >= ED, it will succeed.provider, consumer
will change from1, 1
to2, 1
whentransfer
operation, afterreserve
operation, it becomes to1, 1
c. deploy a new contract or call contract ,
delta
is positive , but below ED. !!! It will fail !!! , due to theTokenError::BelowMinimum
error when transferdelta
to contract account. the latest impl fortransfer
not allowed receiver's free_balance is below ED after transfer, even if it's total balance is >= ED.d. call contract,
delta
is negative. Usually, the free balance of the origin caller is greater than ED, so here it will be successful.solution
We add
SystemAccountStore
to instead of the impl forStoredMap
ofSystem
, it regards existedframe_system::Account
also existspallet_balances::Account
, even if it's AccountData is default.so that
repatriate_reserved
can transfer reserved balance to initialized contract account, which is createdby inc_provider has default
AccountData
.Then use
repatriate_reserved
to instead of following operation:module-currencies refactor fungibles traits impl
In this pr module-currencies refactor the impl for fungibles traits:
In impl traits, each function should judge the asset_id, if it is erc20, it will be processed separately, if it is orml-tokens asset or native token, it will be passed to the corresponding function of Tokens and Balances respectively.
the fungibles in the substrate change the functions at the fund operation level to the default implementation(such as transfer, burn_from, mint_into...). module-currencies still overwrite these functions, it's necessary to compatible fungibles traits with ERC20. So, if use fungibles traits in code, should only use these overwrited impl functions.