-
Notifications
You must be signed in to change notification settings - Fork 86
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
BlockRewards: Fix how it handle ED for Staking currency. #1802
Conversation
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.
Not sure if possible, but I guess staking currency should have an ED
of 0 to avoid all this issues (and migrations each time we use a new reward system). Also for accounting, because now we have in centrifuge a total issuance of: 13,000,002,000,000,000,000
and I would say 2,000,000,000,000
is ED
<T::Tokens as Mutate<T::AccountId>>::mint_into( | ||
T::StakeCurrencyId::get(), | ||
who, | ||
T::StakeAmount::get().saturating_add(T::ExistentialDeposit::get()), |
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.
Here, we were using the CFG existential deposit instead of the one from StakeCurrencyId
@@ -81,6 +85,7 @@ where | |||
fn get(currency_id: &CurrencyId) -> Balance { | |||
match currency_id { | |||
CurrencyId::Native => T::ExistentialDeposit::get(), | |||
CurrencyId::Staking(StakingCurrency::BlockRewards) => T::ExistentialDeposit::get(), |
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.
Here we were assuming the ED
for StakingCurrency
was registered in the orml asset registry or, if not, it was 0
. But the value was always T::ExistentialDeposit::get()
which maps to 1 * MICRO_CFG
.
I maintain the same ED
to avoid issues counting the current staking currency issued, but maybe it should ideally contain another value
From some tests I'm doing, it seems possible. I'm not sure exactly what the problem we had was. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1802 +/- ##
=======================================
Coverage 48.53% 48.53%
=======================================
Files 167 167
Lines 13311 13314 +3
=======================================
+ Hits 6460 6462 +2
- Misses 6851 6852 +1 ☔ View full report in Codecov by Sentry. |
AFAIR the Polkadot v0.9.43 update introduced a required ED for all currencies. Beforehand, we did not require ED for any currency but native. Unfortunately, I don't remember whether relying on unit tests was sufficient here or whether the |
Mmm... IIRC, when we "discovered" that With some minor modifications, I've got all integration tests passing with |
13af112
to
b03d7d5
Compare
26db2ff
to
60c7b28
Compare
Can I have your approval on this @wischli @mustermeiszer @cdamian ? |
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.
Reapproving
Description
I guess this comes from the previous upgrade when balance/and currencies force
ExistentialDeposit
usage.Issue 1: We're using an
ED
denominated inCFG
for theStakingCurrency
. This is not critical if both currencies use the same denomination, but we should use the correctED
for Staking.Issue 2: Because
Staking
currencies were not in the asset registry. Fromorml_tokens
perspective, theED
is0
while fromblock-rewards
perspective it's1 * MICRO_CFG
. I guess this is not a problem for us right now, but it should be fixed to avoid future problems.