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(oracle): Add more events on validator's performance #1755

Merged
merged 2 commits into from
Dec 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* [#1573](https://github.com/NibiruChain/nibiru/pull/1573) - feat(perp): Close markets and compute settlement price
* [#1705](https://github.com/NibiruChain/nibiru/pull/1705) - feat(perp): Add oracle pair to market object
* [#1718](https://github.com/NibiruChain/nibiru/pull/1718) - fix: fees does not require additional funds
* [#1755](https://github.com/NibiruChain/nibiru/pull/1755) - feat(oracle): Add more events on validator's performance

### Non-breaking/Compatible Improvements

Expand Down
22 changes: 22 additions & 0 deletions proto/nibiru/oracle/v1/event.proto
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,25 @@ message EventAggregatePrevote {
// transaction messages on behalf of the voting validator.
string feeder = 2;
}


message EventValidatorPerformance{
// Validator is the Bech32 address to which the vote will be credited.
string validator = 1;

// Tendermint consensus voting power
int64 voting_power = 2;

// RewardWeight: Weight of rewards the validator should receive in units of
// consensus power.
int64 reward_weight = 3;

// Number of valid votes for which the validator will be rewarded
int64 win_count = 4;

// Number of abstained votes for which there will be no reward or punishment
int64 abstain_count = 5;

// Number of invalid/punishable votes
int64 miss_count = 6;
}
12 changes: 12 additions & 0 deletions x/oracle/keeper/update_exchange_rates.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@ func (k Keeper) UpdateExchangeRates(ctx sdk.Context) types.ValidatorPerformances
params, _ := k.Params.Get(ctx)
k.clearVotesAndPrevotes(ctx, params.VotePeriod)
k.refreshWhitelist(ctx, params.Whitelist, whitelistedPairs)

for _, validatorPerformance := range validatorPerformances {
_ = ctx.EventManager().EmitTypedEvent(&types.EventValidatorPerformance{
Validator: validatorPerformance.ValAddress.String(),
VotingPower: validatorPerformance.Power,
RewardWeight: validatorPerformance.RewardWeight,
WinCount: validatorPerformance.WinCount,
AbstainCount: validatorPerformance.AbstainCount,
MissCount: validatorPerformance.MissCount,
})
}

return validatorPerformances
}

Expand Down
Loading
Loading