-
Notifications
You must be signed in to change notification settings - Fork 374
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
chore: try-runtime variation check on new thresholds #1317
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.
Looks good, just a comment about Percentage
usage.
You can replace u32
with Percent::from_percent
, and get rid of the custom arithmetic.
impl< | ||
T: Config, | ||
TierThresholds: Get<[TierThreshold; 4]>, | ||
ThresholdVariationPercentage: Get<u32>, |
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.
Percent
would make more sense here (or Permill
, Perbill
).
That way you have guarantee that's it's not larger than 1 or 100%.
let lower_bound = old_amount | ||
.saturating_mul(100u32.saturating_sub(variation_percentage).into()) | ||
.saturating_div(100u32.into()); | ||
let upper_bound = old_amount | ||
.saturating_mul(100u32.saturating_add(variation_percentage).into()) | ||
.saturating_div(100u32.into()); |
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'd definitely suggest to use Percent
here.
I thought about it but I am expecting a variation of +108% for Tier 2 in Shibuya.. 🥲 2,282 SBY (new) vs 1,056 SVY (current). It is explained in PR bio:
The transformation of TVL amounts into dynamic percentages is not well suited to Shibuya; the percentages seem very low with the same calculation approach as for Astar and Shiden. I can readjust static tier percentages to match current threshold amounts and use |
I've read that it's You can keep the code as it is, it was more of a suggestion than req.for change. I'd opt for |
2faed81
to
9e239af
Compare
Minimum allowed line rate is |
Pull Request Summary
Adds
try-runtime
sanity checks to ensure new tier threshold amounts are within a given variation range as suggested in this comment. The allowed percentage can be customized using the ThresholdVariationPercentage parameter.Variations allowed by runtime:
The variation tolerated is significant on Shibuya given the static tier params percentages configured. However, I used the same calculation as Astar/Shiden: a percentage of the total Shibuya issuance when dApp Staking v3 was launched, so 147M $SBY. Here are the expected amounts when testing with
try-runtime
in thepost_upgrade
hook:Check list