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

fix(oracle)!: count vote omission as abstain for less slashing + more stability #1565

Merged
merged 27 commits into from
Oct 10, 2023

Conversation

Unique-Divine
Copy link
Member

@Unique-Divine Unique-Divine commented Sep 5, 2023

  • changelog
  • fix(oracle): miss outside reward band but not on abstain
  • fix(oracle): #wip checkpoint for omit == abstain

Description

What does this PR do?

Purpose

Why is this PR important?

@codecov
Copy link

codecov bot commented Sep 5, 2023

Codecov Report

Merging #1565 (d1467ff) into master (ef307eb) will increase coverage by 0.02%.
Report is 1 commits behind head on master.
The diff coverage is 82.92%.

❗ Current head d1467ff differs from pull request most recent head af92024. Consider uploading reports for the commit af92024 to get more accurate results

@@            Coverage Diff             @@
##           master    #1565      +/-   ##
==========================================
+ Coverage   74.49%   74.52%   +0.02%     
==========================================
  Files         175      177       +2     
  Lines       14567    14651      +84     
==========================================
+ Hits        10852    10918      +66     
- Misses       3097     3112      +15     
- Partials      618      621       +3     
Files Coverage Δ
wasmbinding/bindings/query.go 100.00% <100.00%> (ø)
wasmbinding/exec_perp.go 90.74% <100.00%> (ø)
wasmbinding/querier.go 84.25% <100.00%> (ø)
x/oracle/keeper/reward.go 80.70% <100.00%> (ø)
x/oracle/keeper/test_utils.go 96.56% <100.00%> (ø)
x/oracle/keeper/update_exchange_rates.go 93.97% <100.00%> (+0.46%) ⬆️
x/perp/v2/keeper/amm.go 92.10% <100.00%> (+0.92%) ⬆️
x/perp/v2/keeper/calc.go 94.54% <100.00%> (ø)
x/perp/v2/keeper/grpc_query.go 70.07% <100.00%> (ø)
x/perp/v2/keeper/keeper.go 96.55% <100.00%> (+4.12%) ⬆️
... and 13 more

... and 1 file with indirect coverage changes

@Unique-Divine Unique-Divine marked this pull request as ready for review September 6, 2023 19:27
@Unique-Divine Unique-Divine requested a review from a team as a code owner September 6, 2023 19:27
@k-yang
Copy link
Member

k-yang commented Sep 6, 2023

Overall I don't think we should make this change because it changes the economic incentives for validators to participate in the decentralized oracle. It allows validators to be lazy and not participate at all, without any slashing risk. I think we want validators to run the pricefeeder infrastructure always.

In regular PoS, if you don't vote for a block, it's counted as a miss that counts towards your slashing.

If the concern is about network stability, I think we should analyze what went wrong with the smaller slashing window and higher min_valid_pct instead of immediately making this change.

x/oracle/keeper/test_utils.go Outdated Show resolved Hide resolved
x/oracle/keeper/slash_test.go Outdated Show resolved Hide resolved
@NibiruChain NibiruChain deleted a comment from sonarcloud bot Sep 27, 2023
allowedMissPct := sdk.OneDec().Sub(minValidPerWindow)
allowedMissPeriods := allowedMissPct.MulInt64(votePeriodsPerWindow).
TruncateInt64()
t.Logf("For %v blocks, valoper0 does not vote, while 1 and 2 do.", allowedMissPeriods)
Copy link
Member

Choose a reason for hiding this comment

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

I think you're conflating blocks with vote periods here. One vote period is many blocks (by default 30 on testnet), so if the goal is to vote once every vote period, we have to skip the block number by 30 in each iteration.

However, this test doesn't really test validator slashing, only that the MissCounter doesn't increment. The slashing happens in the abci EndBlocker which is in another test.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, the name is wrong because it used to be a test about slashing that had abstain votes. Since that doesn't cause slashing, the test is no longer about that either. Will need to repurpose it

x/oracle/keeper/test_utils.go Outdated Show resolved Hide resolved
// consensus power.
RewardWeight int64
WinCount int64 // Number of valid votes for which the validator will be rewarded
AbstainCount int64 // Number of abstained votes for which there will be no reward or punishment
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we're using AbstainCount usefully anywhere. Let's just get rid of it?

Copy link
Member Author

@Unique-Divine Unique-Divine Sep 27, 2023

Choose a reason for hiding this comment

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

There's a ticket open (from Ruslan, I think) to add an event for this and emit more info about the validator stats. The goal after some initial review of the changes in this PR is to add that in as well


k.MissCounters.Insert(ctx, validatorPerformance.ValAddress, k.MissCounters.GetOr(ctx, validatorPerformance.ValAddress, 0)+1)
k.Logger(ctx).Info("vote miss", "validator", validatorPerformance.ValAddress.String())
func (k Keeper) registerAbstainsByOmission(
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we need this function. The return type of UpdateExchangeRates isn't used anywhere so we don't need to do anything after rewarding validators and updating miss counters.

ballots types.ExchangeRateBallots,
rewardBand sdk.Dec,
validatorPerformances types.ValidatorPerformances,
) (sdk.Dec, types.ValidatorPerformances) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a bad idea, to have a return only used for tests. The function already mentions that it mutates the validator perfomances, returning it is confusing.

@Unique-Divine Unique-Divine marked this pull request as draft September 28, 2023 11:36
@k-yang k-yang marked this pull request as ready for review October 10, 2023 21:32
@k-yang k-yang enabled auto-merge (squash) October 10, 2023 21:33
@k-yang k-yang disabled auto-merge October 10, 2023 21:34
@k-yang k-yang enabled auto-merge (squash) October 10, 2023 21:38
@k-yang k-yang merged commit 7cc73b4 into master Oct 10, 2023
14 checks passed
@k-yang k-yang deleted the realu/oracle-miss branch October 10, 2023 21:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants