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: Add oracle module #392

Merged
merged 6 commits into from
Apr 14, 2023
Merged

feat: Add oracle module #392

merged 6 commits into from
Apr 14, 2023

Commits on Apr 14, 2023

  1. feat: Add oracle module (#379)

    Adds the oracle module in the `x` folder. Oracle module is responsible for:
    - Tally all the votes sent by the validators through the `oracle-feeder` within the voting period and calculate the median.
    
    - Select the validators who have voted within the reasonable spread.
    
    -  Distribute the reward to the selected validators from the reward pool.
    
    - Slash the validator whose vote rate is less than the `minValidPerWindow`.
    
    - Funds for the reward pool will be transferred through the `fund-reward-pool` command.
    
    - Reward pool can be queried through the `reward-pool-balance` command.
    
    At the last block of the voting period, the votes of all the valid validators will be tallied and the median will be calculated. Validators who have voted within the reasonable spread will be rewarded.
    The reward will be decided based on the reward band and their voting power and the validator who has voted less than the minimum valid vote per window will be slashed(jailed).
    The reward will be distributed from the reward pool account controlled by the oracle module and the funds to the reward pool can be transferred through the `fund-reward-pool` command from any address.
    akaladarshi authored and ajeet97 committed Apr 14, 2023
    Configuration menu
    Copy the full SHA
    7cd5e89 View commit details
    Browse the repository at this point in the history
  2. Oracle module testing improvs (#382)

    1. Overview
    
    This PR improves the keeper test suite layout. It separates helper functions into x/oracle/testutil package, which can be reused (that's a canonical way to do it), also cleanups the test setup stage that runs before each step.
    
    I moved a chunk of logic from ABCI handler into keeper to make it testable (the Tally and related ballot logic).
    
    Also, implemented a unit test that checks slashing, that improves test coverage for now.
    
    2. Implementation details
    
    Rationale for this is to have better test organisation and coverage. There is also to demonstrate a way how to test slashing.
    xlab authored and ajeet97 committed Apr 14, 2023
    Configuration menu
    Copy the full SHA
    4ea7a5b View commit details
    Browse the repository at this point in the history
  3. Filter out the votes below the vote threshold (#384)

    1. Overview
    
    - Filter out the exchange rates which have votes below the vote threshold `< 50%`.
    
    - Remove the `ValidatorsPowerStoreIterator` and instead use `GetBondedValidatorsByPower`.
    
    - Refactor.
    ---------
    
    Co-authored-by: Max Kupriianov <max@kc.vc>
    2 people authored and ajeet97 committed Apr 14, 2023
    Configuration menu
    Copy the full SHA
    4900fae View commit details
    Browse the repository at this point in the history
  4. feat: update oracle exchange rate query (#387)

    1. Overview
    
    Update oracle exchange_rate response to return the exchange rate of an asset in string.
    
    Separate exchange_rate and all_exchange_rates queries.
    
    2. Implementation details
    
    Created two separate oracle queries exchange_rate, and all_exchange_rates.
    exchange_rate: Takes the asset symbol as a request and returns its exchange in string.
    all_exchange_rates: Doesn't take any request and returns exchange rates of all the assets stored on chain in sdk.DecCoins
    akaladarshi authored and ajeet97 committed Apr 14, 2023
    Configuration menu
    Copy the full SHA
    58ed1c2 View commit details
    Browse the repository at this point in the history
  5. test: Add more tests for oracle module (#389)

    1. Overview
    
     Add more tests in x/types.
    
     Change v.BaseDenom to v.SymbolDenom in tally.go. Since we are using symbol everywhere.
    akaladarshi authored and ajeet97 committed Apr 14, 2023
    Configuration menu
    Copy the full SHA
    c479c0a View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    636ed0e View commit details
    Browse the repository at this point in the history