-
Notifications
You must be signed in to change notification settings - Fork 85
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
Currencies: ED consistent between tokens and assets #1596
Conversation
CurrencyId::Native => T::ExistentialDeposit::get(), | ||
currency_id => orml_asset_registry::Pallet::<T>::metadata(currency_id) | ||
.map(|metadata| metadata.existential_deposit) | ||
.unwrap_or_default(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Default will be 0. given that we have some currencies that have internal usage as, should we maybe consider having some other default here instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Such internal currencies will have a representation in the asset_registry
? If not, yes, we can add a default other than 0 for them
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, I think we do not register internal currencies. E.g.: staking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, looking into it, they already have them 0
ED, but after f34cbde from @NunoAlexandre they should have some value != 0 and such value is not in the asset_registry
, so yes, we should add something different than default there (although this would not be mandatory for this PR using polkadot 0.9.38)
I'm still not sure what value they should have or how to set this from CurrencyEDs
type (supposing in could happen with different currencies with different EDs).
Also, I still do not understand why polkadot 0.9.43 forces us to have some ED even for internal currencies as the stacking one.
cc @wischli
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lemunozm yeah we need a special arm case for the Stacking Currencies. Those are internal so we should be safe hardcoding here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. If all of you agree, I propose to merge this PR as it it, because ED is 0 at this point in our main
branch, and later in polkadot-v0.9.43
adding the corresponding value there (in a hardcode way as Nuno said) depending on what we chose for them (that I understand it's still not decided)
runtime/common/src/lib.rs
Outdated
@@ -37,6 +43,22 @@ macro_rules! production_or_benchmark { | |||
}}; | |||
} | |||
|
|||
pub struct CurrencyEDs<T>(PhantomData<T>); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit but this is not getting existential depositS (plural)
pub struct CurrencyEDs<T>(PhantomData<T>); | |
pub struct CurrencyED<T>(PhantomData<T>); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure not? The own associated name in orml_tokens
contains S
too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A currency has one associated existential deposit, not multiple. In orml_tokens
it is plural because it's called ExistentialDeposits
(i.e, the struct that handles all the existential deposits so it's less incorrect). This struct we are adding here is "Currency Existential Deposits" which, again, is semantically incorrect. In any case, even if orml_tokens
named it CurrencyEDs
, we shouldn't propagate bad naming.
This is a nit and not a blocker at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think if you see it as:
- Thing that given a currency it returns a ED, then
CurrencyED
- Thing that stores all EDs for each currency. You see it as a whole, then
CurrencyEDs
It reminds me to Haskell partial applications 😄:
Thing -> CurrencyID -> Balance
-> Receives 2 parameters and returns a valueThing -> (CurrencyID -> Balance)
-> Receives 1 parameter and returns a function that receives 1 parameter and returns a value.
And actually both things are the same, because the parenthesis is optional. So I would say that it depends of the PoV of such parenthesis 🤣. But yeah, I can update it. I have no strong opinion from my side.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
b753e58
to
96fc2a6
Compare
This modification makes a lot of integration tests fail. I'll try to fix them, and once done, probably rebasing or cherry-picking these commits will fix a lot of your issues @NunoAlexandre from the migration |
dd393c7
to
f19d085
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wischli regarding the issue.
Using an example the test increase_invest_order()
(I think almost the rest of the test failing follows the same pattern). Run it:
cargo test -p runtime-integration-tests increase_invest_order
I'm block in a point where the Tokens::transfer()
done inside the pallet_investment::Pallet::update_invest_order()
flow fails because the account is below ED
.
I do not know why, because the currency is AUSD and the account is the investor, and the account should be funded at that point.
Below I go though intermediate fixes until reach the commented issue:
(AccountId::from(ALICE), AUSD_CURRENCY_ID, AUSD_ED), | ||
(AccountId::from(BOB), AUSD_CURRENCY_ID, AUSD_ED), | ||
(AccountId::from(ALICE), USDT_CURRENCY_ID, USDT_ED), | ||
(AccountId::from(BOB), USDT_CURRENCY_ID, USDT_ED), | ||
(AccountId::from(ALICE), GLMR_CURRENCY_ID, GLMR_ED), | ||
(AccountId::from(BOB), GLMR_CURRENCY_ID, GLMR_ED), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initial state with ED
for all currencies in accounts used if foreign-investment
let sending_domain_locator = Domain::convert(DEFAULT_DOMAIN_ADDRESS_MOONBEAM.domain()); | ||
Tokens::mint_into(AUSD_CURRENCY_ID, &sending_domain_locator, AUSD_ED).unwrap(); | ||
Tokens::mint_into(AUSD_CURRENCY_ID, &investor, AUSD_ED).unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add ED
for the sending domain account and for the investor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UPDATE: I've also added AUSD_ED
to the pool_account, but the ExistentialDeposit
error still appears.
* tests: fix FI * tests: fix LP transfer non tranche
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Thanks again @wischli for your help on this 🙌🏻 |
Description
omrl_tokens
stores a0
Existential Deposit (ED) forCurrencyID
.orml_asset_registry
allows the registry of an asset by aCurrencyID
with some EDAlthough semantically both relations must be the same, we do not have such a relation in the code, having different values for the same
CurrencyID
in different places: slack thread.This PR unify them looking to the correct set value by the asset registry each time an ED is required.
Could increase a bit the Weight of some calls