-
Notifications
You must be signed in to change notification settings - Fork 4
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 #379
Conversation
Coverage after merging tikaryan/oracle-module into master
Coverage Report
|
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.
In general, the codebase looks solid! Well done.
The most required thing there is better test coverage, especially unit tests for functions that contain math and are not so obvious.
Also, I didn't find docs for the parameters. It looks some of them (VoteThreshold
) are not even used at the moment. Others like RewardSpread
have dubious meaning (at the first glance). (some good examples: example1, example2)
There is an extra part related to spam prevention which I don't understand and it probably belongs to a separate PR.
Last thing, we need to ensure that this implementation matches the design (IRD or other spec), I think it would be cool if most heavy parts of the code would refer to such a document.
var ten = sdk.MustNewDecFromStr("10") | ||
|
||
// Keeper of the oracle store | ||
type Keeper struct { |
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.
I suggest designing Keepers exposed as interfaces. Makes testing much easier and in general increases modularity.
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.
type keeper struct {
and
type Keeper interface {
the latter lists all its keeper methods that this module exposes to other places like ABCI.
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.
It is done for consistency of the code base. But if required we can have a PR to change all keeper struct to the interface.
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.
No need for this one, it's fine. After migration to v0.46 or v0.47 the consistency will shift towards interfaces anyways.
6e1d841
to
6708df7
Compare
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.
Spotted one new thing.
All changes are good. Also, I rebased them on my PR - #382 so it's also ready to merge into this one. One note: The doc now refers to https://classic-docs.terra.money/docs/develop/module-specifications/spec-oracle.html#parameters which includes VoteThreshold parameter. But afaik that parameter is not used in our implementation. Yet, we need use it the same way. Actually, I think this flow may help us to avoid security issues with only one voter in a ballot. |
## 1. Overview 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. ## 2. Implementation details 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.
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.
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.
1. Overview
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.2. Implementation details
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.3. How to test/use
make test-unit
4. Checklist
6. Future Work (optional)