-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
R4R use address instead of bond height / intratxcounter for deduplication #3055
Conversation
require.True(t, got.IsOK()) | ||
validatorUpdates, _ = stake.EndBlocker(ctx, sk) | ||
require.Equal(t, 2, len(validatorUpdates)) | ||
validator, _ = sk.GetValidator(ctx, addr) | ||
require.Equal(t, sdk.Bonded, validator.Status) | ||
newAmt = int64(102) | ||
newAmt = int64(103) |
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.
The only reason why it worked before with 102, after getting slashed down to 100.98, which is less than the alternative validator, is because of the bug where power key indices are getting trampled.
require.Equal(t, 0, len(keeper.ApplyAndReturnValidatorSetUpdates(ctx))) | ||
validators[0] = TestingUpdateValidator(keeper, ctx, validators[0], false) | ||
validators[1] = TestingUpdateValidator(keeper, ctx, validators[1], false) | ||
require.Equal(t, 2, len(keeper.ApplyAndReturnValidatorSetUpdates(ctx))) |
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.
Notice that by passing in false, the next line is more useful.
validators[0] = TestingUpdateValidator(keeper, ctx, validators[0]) | ||
validators[1] = TestingUpdateValidator(keeper, ctx, validators[1]) | ||
validators[0] = TestingUpdateValidator(keeper, ctx, validators[0], false) | ||
validators[1] = TestingUpdateValidator(keeper, ctx, validators[1], false) | ||
|
||
updates := keeper.ApplyAndReturnValidatorSetUpdates(ctx) | ||
require.Equal(t, 2, len(updates)) |
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.
Notice that before, ApplyAndReturnValidatorSetUpdates() shouldn't have returned anything at all. That it was returning 2 and the update orders were inverted is super weird. This addresses both issues.
keeper.SetValidator(ctx, validator) | ||
{ // Remove any existing power key for validator. |
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.
Before, none of the old power key entries were being removed. This properly cleans any old entries and also asserts a sanity check if there are more than 1 duplicate.
Codecov Report
@@ Coverage Diff @@
## develop #3055 +/- ##
===========================================
- Coverage 52.19% 52.18% -0.01%
===========================================
Files 136 136
Lines 9605 9613 +8
===========================================
+ Hits 5013 5017 +4
Misses 4261 4261
- Partials 331 335 +4 |
Merging this in early for sake of release. Lets still discuss here though. |
@jaekwon a good chunk of these quick/forceful merges fail linting just FYI. Might want to run that prior to merging. |
validator, found := keeper.GetValidator(ctx, validator.OperatorAddr) | ||
if !found { | ||
panic("validator expected but not found") | ||
if apply { |
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.
Could be a bit cleaner always creating ctx.CacheContext()
and calling write()
if apply
is true
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.
Code changes look OK. Address grinding incentives if validators have the same stake / bond height, but in most real networks that seems very unlikely to be a problem.
See: #2909 (comment)
Addresses #3049
Related to #3051 (better alternative)
This includes the (inverted) address of the validator in the power key.
This also completely removes the IntraTxCounter, simplifying the code.
Before, some of the tests were testing the bug condition, e.g. the tests were previously broken. This fixes everything AFAIK.
I'm confident enough about this PR that I believe strongly that we should merge this in for GoS.