feat: Update oracle endblocker for historic pricing#1580
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1580 +/- ##
==========================================
- Coverage 55.09% 54.05% -1.05%
==========================================
Files 68 71 +3
Lines 6835 7150 +315
==========================================
+ Hits 3766 3865 +99
- Misses 2787 2988 +201
- Partials 282 297 +15
|
robert-zaremba
left a comment
There was a problem hiding this comment.
- endblocker tests should be extended to cover new functionality
- Median computation should be correctly benchmarked (with right amount of data, eg: 20 tokens, with full amount of prices).
- need to validate the stamp price usage.
|
Could we use the experimental flag instead of commenting out the code? And then the test can set the experimental flag. |
| if experimental { | ||
| // Stamp rate every stamp period if asset is set to have historic stats tracked | ||
| if isPeriodLastBlock(ctx, params.StampPeriod) && params.HistoricAcceptList.Contains(ballotDenom.Denom) { | ||
| k.AddHistoricPrice(ctx, ballotDenom.Denom, exchangeRate) |
Check warning
Code scanning / CodeQL
Panic in BeginBock or EndBlock consensus methods
| if experimental { | ||
| // Stamp rate every stamp period if asset is set to have historic stats tracked | ||
| if isPeriodLastBlock(ctx, params.StampPeriod) && params.HistoricAcceptList.Contains(ballotDenom.Denom) { | ||
| k.AddHistoricPrice(ctx, ballotDenom.Denom, exchangeRate) |
Check warning
Code scanning / CodeQL
Panic in BeginBock or EndBlock consensus methods
| // Stamp rate every stamp period if asset is set to have historic stats tracked | ||
| if isPeriodLastBlock(ctx, params.StampPeriod) && params.HistoricAcceptList.Contains(ballotDenom.Denom) { | ||
| k.AddHistoricPrice(ctx, ballotDenom.Denom, exchangeRate) | ||
| } |
Check warning
Code scanning / CodeQL
Panic in BeginBock or EndBlock consensus methods
|
|
||
| // Set median price every median period if asset is set to have historic stats tracked | ||
| if isPeriodLastBlock(ctx, params.MedianPeriod) && params.HistoricAcceptList.Contains(ballotDenom.Denom) { | ||
| k.CalcAndSetMedian(ctx, ballotDenom.Denom) |
Check warning
Code scanning / CodeQL
Panic in BeginBock or EndBlock consensus methods
|
|
||
| // Set median price every median period if asset is set to have historic stats tracked | ||
| if isPeriodLastBlock(ctx, params.MedianPeriod) && params.HistoricAcceptList.Contains(ballotDenom.Denom) { | ||
| k.CalcAndSetMedian(ctx, ballotDenom.Denom) |
Check warning
Code scanning / CodeQL
Panic in BeginBock or EndBlock consensus methods
| // Set median price every median period if asset is set to have historic stats tracked | ||
| if isPeriodLastBlock(ctx, params.MedianPeriod) && params.HistoricAcceptList.Contains(ballotDenom.Denom) { | ||
| k.CalcAndSetMedian(ctx, ballotDenom.Denom) | ||
| } |
Check warning
Code scanning / CodeQL
Panic in BeginBock or EndBlock consensus methods
| for _, v := range params.HistoricAcceptList { | ||
| k.DeleteHistoricPrice(ctx, v.String(), pruneBlock) | ||
| } | ||
| } |
Check warning
Code scanning / CodeQL
Panic in BeginBock or EndBlock consensus methods
zarazan
left a comment
There was a problem hiding this comment.
Couple comments, looks great!
|
|
||
| if isPeriodLastBlock(ctx, params.MedianPeriod) && experimental { | ||
| k.ClearMedians(ctx) | ||
| k.ClearMedianDeviations(ctx) |
Check warning
Code scanning / CodeQL
Panic in BeginBock or EndBlock consensus methods
| if isPeriodLastBlock(ctx, params.MedianPeriod) && experimental { | ||
| k.ClearMedians(ctx) | ||
| k.ClearMedianDeviations(ctx) | ||
| } |
Check warning
Code scanning / CodeQL
Panic in BeginBock or EndBlock consensus methods
| k.ClearMedians(ctx) | ||
| k.ClearMedianDeviations(ctx) | ||
| } | ||
|
|
Check warning
Code scanning / CodeQL
Panic in BeginBock or EndBlock consensus methods
zarazan
left a comment
There was a problem hiding this comment.
Love it, thanks for adding that test!
robert-zaremba
left a comment
There was a problem hiding this comment.
The functionality looks wrong. I think we wanted to have a rolling median. Let's confirm in Slack. Blocking for the moment.
Description
closes: #1542
Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
!to the type prefix if API or client breaking changeCHANGELOG.mdReviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
I have...