Skip to content
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

feat: historacle avg prices #1725

Merged
merged 17 commits into from
Jan 24, 2023
Merged

feat: historacle avg prices #1725

merged 17 commits into from
Jan 24, 2023

Conversation

robert-zaremba
Copy link
Member

@robert-zaremba robert-zaremba commented Jan 19, 2023

Closes: #1722

Description

  • Avg Historacle implementation with integration into end blocker
  • Proof of concept to break keepers down into smaller pieces, which doesn't depend on context
  • started to use https://pkg.go.dev/gotest.tools
  • new layout of doing test suites with gotest.tools:
    • using a struct to describe a fixture
    • using methods for test scenarios: group test cases for a function under test
    • test cases with traditional "table tests"
    • putting it together into a standard go test function.

I'm thinking about moving the AvgKeeper to a separate package, eg: leverage/keeper/avgk

  • we won't have "suite", and instead use normal test functions with for test scenarios

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...

  • included the correct type prefix in the PR title
  • added ! to the type prefix if API or client breaking change
  • added appropriate labels to the PR
  • targeted the correct branch (see PR Targeting)
  • provided a link to the relevant issue or specification
  • added a changelog entry to CHANGELOG.md
  • included comments for documenting Go code
  • updated the relevant documentation or specification
  • reviewed "Files changed" and left comments if necessary
  • confirmed all CI checks have passed

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...

  • confirmed the correct type prefix in the PR title
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic
  • reviewed API design and naming
  • reviewed documentation is accurate
  • reviewed tests and test coverage
  • manually tested (if applicable)

x/oracle/abci.go Fixed Show fixed Hide fixed
@codecov-commenter
Copy link

codecov-commenter commented Jan 19, 2023

Codecov Report

Merging #1725 (de6054b) into main (3b9f545) will decrease coverage by 0.01%.
The diff coverage is 66.44%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1725      +/-   ##
==========================================
- Coverage   57.49%   57.48%   -0.01%     
==========================================
  Files          76       77       +1     
  Lines        7935     8030      +95     
==========================================
+ Hits         4562     4616      +54     
- Misses       3024     3063      +39     
- Partials      349      351       +2     
Impacted Files Coverage Δ
x/oracle/keeper/params.go 80.39% <ø> (ø)
x/oracle/types/keys.go 90.47% <0.00%> (-9.53%) ⬇️
x/oracle/keeper/historic_avg.go 59.55% <59.55%> (ø)
x/oracle/abci.go 78.35% <77.96%> (-2.71%) ⬇️
x/oracle/keeper/historic_price.go 60.89% <100.00%> (+0.44%) ⬆️

for _, v := range k.StakingKeeper.GetBondedValidatorsByPower(ctx) {
addr := v.GetOperator()
validatorClaimMap[addr.String()] = types.NewClaim(v.GetConsensusPower(powerReduction), 0, 0, addr)
if err := CalcPrices(ctx, params, k); err != nil {

Check warning

Code scanning / CodeQL

Panic in BeginBock or EndBlock consensus methods

Possible panics in BeginBock- or EndBlock-related consensus methods could cause a chain halt
@robert-zaremba robert-zaremba marked this pull request as ready for review January 19, 2023 23:51
@robert-zaremba robert-zaremba requested review from a team as code owners January 19, 2023 23:51
// Slash oracle providers who missed voting over the threshold and
// reset miss counters of all validators at the last block of slash window
if k.IsPeriodLastBlock(ctx, params.SlashWindow) {
k.SlashAndResetMissCounters(ctx)

Check warning

Code scanning / CodeQL

Panic in BeginBock or EndBlock consensus methods

Possible panics in BeginBock- or EndBlock-related consensus methods could cause a chain halt

k.ClearExchangeRates(ctx)
k.PruneAllPrices(ctx)

Check warning

Code scanning / CodeQL

Panic in BeginBock or EndBlock consensus methods

Possible panics in BeginBock- or EndBlock-related consensus methods could cause a chain halt
@robert-zaremba
Copy link
Member Author

I've added a sample test using "gotest.tools/v3/assert".
More tests will come in a separate PR.

Copy link
Collaborator

@gsk967 gsk967 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

IBC Quota: Use Historacle Avg prices
4 participants