-
Notifications
You must be signed in to change notification settings - Fork 817
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
handle oracle overflow and rounding to zero for extreme values with cross rates #1983
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1983 +/- ##
==========================================
- Coverage 61.64% 61.50% -0.15%
==========================================
Files 365 263 -102
Lines 26178 24339 -1839
==========================================
- Hits 16138 14970 -1168
+ Misses 8967 8256 -711
- Partials 1073 1113 +40
|
x/oracle/abci.go
Outdated
@@ -66,6 +66,10 @@ func MidBlocker(ctx sdk.Context, k keeper.Keeper) { | |||
voteMapRD := ballotRD.ToMap() | |||
|
|||
exchangeRateRD := ballotRD.WeightedMedianWithAssertion() | |||
// handle case where exchange rate is 0 | |||
if exchangeRateRD.IsZero() { | |||
// TODO: do stuff |
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.
do we actually want to do things?
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.
yeah I realized this one can't actually be zero because votes submitted with a zero value are modified to have the vote power set to 0, so the only way to get 0 exchange rates is for really small number divided by really large number which is with the cross rates calculations.
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.
^ just wasn't sure of that empty branch, but otherwise lgtm
6048916
to
5324d78
Compare
Describe your changes and provide context
This fixes issues that can occur in the most extreme circumstances where extreme values used for cross rates can cause issues during oracle ballot calculations.
Testing performed to validate your change
Unit test + docker cluster testing