-
Notifications
You must be signed in to change notification settings - Fork 161
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
feat: Update oracle endblocker for historic # #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
|
if isPeriodLastBlock(ctx, params.PrunePeriod) { | ||
pruneBlock := uint64(ctx.BlockHeight()) - params.PrunePeriod | ||
for _, v := range params.AcceptList { | ||
k.DeleteHistoricPrice(ctx, v.String(), pruneBlock) |
Check warning
Code scanning / CodeQL
Panic in BeginBock or EndBlock consensus methods
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.
- 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) { |
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) { |
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
} | ||
|
||
// 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) { |
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) { |
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
k.SlashAndResetMissCounters(ctx) | ||
} | ||
|
||
// Prune historic prices every prune period | ||
if isPeriodLastBlock(ctx, params.PrunePeriod) && experimental { |
Check warning
Code scanning / CodeQL
Panic in BeginBock or EndBlock consensus methods
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.
Couple comments, looks great!
|
||
k.ClearExchangeRates(ctx) | ||
|
||
if isPeriodLastBlock(ctx, params.MedianPeriod) && experimental { |
Check warning
Code scanning / CodeQL
Panic in BeginBock or EndBlock consensus methods
|
||
k.ClearExchangeRates(ctx) | ||
|
||
if isPeriodLastBlock(ctx, params.MedianPeriod) && experimental { | ||
k.ClearMedians(ctx) |
Check warning
Code scanning / CodeQL
Panic in BeginBock or EndBlock consensus methods
|
||
k.ClearExchangeRates(ctx) | ||
|
||
if isPeriodLastBlock(ctx, params.MedianPeriod) && experimental { | ||
k.ClearMedians(ctx) | ||
k.ClearMedianDeviations(ctx) |
Check warning
Code scanning / CodeQL
Panic in BeginBock or EndBlock consensus methods
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.
Love it, thanks for adding that test!
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.
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.md
Reviewers 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...