-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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: Ensure Tendermint Validator Update Invariants - Part II #2298
R4R: Ensure Tendermint Validator Update Invariants - Part II #2298
Conversation
Codecov Report
@@ Coverage Diff @@
## bez/2189-del-non-exist-val-bug #2298 +/- ##
=================================================================
Coverage ? 63.75%
=================================================================
Files ? 140
Lines ? 8652
Branches ? 0
=================================================================
Hits ? 5516
Misses ? 2756
Partials ? 380 |
@@ -482,10 +481,15 @@ func (k Keeper) UpdateBondedValidators( | |||
|
|||
// if we've reached jailed validators no further bonded validators exist | |||
if validator.Jailed { | |||
if validator.Status == sdk.Bonded { |
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.
Additional defensive coding 👍
@@ -494,13 +498,6 @@ func (k Keeper) UpdateBondedValidators( | |||
newValidatorBonded = true | |||
} | |||
|
|||
// increment the total number of bonded validators and potentially mark |
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.
Why did we delete these lines?
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.
if validator.Status != sdk.Bonded { // ... }
was done twice and the internal logic was essentially duplicated. I put it into a single conditional/block.
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.
👍
@@ -683,6 +679,8 @@ func (k Keeper) bondValidator(ctx sdk.Context, validator types.Validator) types. | |||
panic(fmt.Sprintf("should not already be bonded, validator: %v\n", validator)) | |||
} | |||
|
|||
validator.BondHeight = ctx.BlockHeight() |
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'm not sure this is right. The original intent was to copy the bondHeight
from the old validator in bondIncrement
if already bonded, else set it to the current block height. Can we figure out why that isn't happening first?
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.
@cwgoes the bond height never gets set for a validator that enters the set (temporarily) as a result of another leaving...at least in the case I saw.
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.
That would be the bug then, makes sense.
We just need to ensure that this doesn't break the existing logic - which it might not, but it does overlap I think.
Using |
@cwgoes I'll address most of your comments shortly, but maybe we should sync up -- perhaps I'm missing something. |
I'm not sure (replied re: sync up on Slack) - this fix might be OK but let's definitely read over the logic again, and I think we're at minimum duplicating a case that previously worked (in addition to the case that didn't). Setting the bond height in |
@cwgoes indeed, I agree we should have one place that does this -- However, when I tried this, it screwed up iteration in other methods such as See: |
@cwgoes getting pretty deep into trying to figure out another way to set bond height and still have valid iteration. I've come to the conclusion that in order to move setting the bond height, I think this is a safe approach for now. |
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.
Tested ACK
I think this PR is safe and does fix the immediate issue, but we should absolutely simplify this logic, #prelaunch.
See #2312. |
* Update statesync.bash * Update statesync.bash * Update statesync.bash Removed evmos comments, added a few other comments. Commented out go install --------- Co-authored-by: Milan Mulji <98309852+mmulji-ic@users.noreply.github.com>
During the debugging and implementation of #2238, another case of invalid Tendermint updates arose but with a different cause. I narrowed it down to what I believe was the trace of events. Can be generalized as such:
Given ValidatorA,
Keeper#UpdateValidator
is implemented, the bond height and intra counter will be updated (see: here). (bondHeight: 11, unbondingHeight: 10)bondHeight
is 10,Keeper#GetValidTendermintUpdates
believes it was previously bonded and as such sends an update to remove ValidatorA (unbonds/power zero). However, ValidatorA was never in the bonded set to begin with (removed at height 10).tl;dr when a previously unbonded validator goes from unbonded, to bonded, back to unbonded in the same block as a result of some other change (e.g. cliff validator losing enough power and then gaining it back), the previously unbonded validator never has it's bond height updated.
Not sure if implemented solution is the correct/best one, but I simply set the
bondHeight
inbondValidator
. Also, always setting thebondHeight
for an unbonded validator inKeeper#UpdateValidator
is a bit confusing to me. Why do we do this?closes: #2277
closes by proxy: #2189
ref: #2238, #2189
Targeted PR against correct branch (see CONTRIBUTING.md)
Linked to github-issue with discussion and accepted design OR link to spec that describes this work.
Wrote tests
Updated relevant documentation (
docs/
)Added entries in
PENDING.md
with issue #rereviewed
Files changed
in the github PR explorerFor Admin Use: