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

Validator Cliff Updates #1565

Merged
merged 10 commits into from
Jul 7, 2018
Merged

Validator Cliff Updates #1565

merged 10 commits into from
Jul 7, 2018

Conversation

rigelrozanski
Copy link
Contributor

@rigelrozanski rigelrozanski commented Jul 6, 2018

Updates to validator cliff logic:

  • cliff validator represent the validator on the top of the cliff
  • cliff validator only exists when there are a maximum number of validators reached, not does not persist after they have

supersedes #1530
Closes #1519

Fixes previously unknown issues around ordering of revoked validator set in power-rank

CHANGELOG

  • [x/stake] fix revoke bytes ordering (was putting revoked candidates at the top of the list)
  • [x/stake] bond count was counting revoked validators as bonded, fixed
  • Validator Cliff Updates #1565 - fix cliff validator persisting when validator set shrinks from max

  • Updated all relevant documentation in docs
  • Updated all code comments where relevant
  • Wrote tests
  • Updated CHANGELOG.md
  • Updated Gaia/Examples
  • Squashed all commits, uses message "Merge pull request #XYZ: [title]" (coding standards)
  • Added appropriate labels to PR (ex. wip, ready-for-review, docs)

@codecov
Copy link

codecov bot commented Jul 7, 2018

Codecov Report

Merging #1565 into develop will decrease coverage by 0.02%.
The diff coverage is 65%.

@@             Coverage Diff             @@
##           develop    #1565      +/-   ##
===========================================
- Coverage    64.09%   64.06%   -0.03%     
===========================================
  Files          122      122              
  Lines         6670     6674       +4     
===========================================
+ Hits          4275     4276       +1     
- Misses        2148     2150       +2     
- Partials       247      248       +1

Copy link
Contributor

@cwgoes cwgoes left a comment

Choose a reason for hiding this comment

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

Logic questions

@@ -303,6 +303,8 @@ func (k Keeper) UpdateBondedValidators(ctx sdk.Context,
// TODO benchmark if we should read the current power and not write if it's the same
if bondedValidatorsCount == int(maxValidators) { // is cliff validator
k.setCliffValidator(ctx, validator, k.GetPool(ctx))
} else {
k.clearCliffValidator(ctx)
Copy link
Contributor

Choose a reason for hiding this comment

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

Presumably we only need to clear the cliff validator if it was previously set (we had 100 validators) and it should be set no longer (we now have 99)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

correct - I'll add this check in here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

addressed

@@ -634,6 +634,7 @@ func TestGetTendermintUpdatesInserted(t *testing.T) {
require.Equal(t, validators[4].ABCIValidator(), updates[0])
}

//TODO why is this called NotValidatorCliff?
Copy link
Contributor

@cwgoes cwgoes Jul 7, 2018

Choose a reason for hiding this comment

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

No idea - per git blame, you wrote it. 😉

Looks like this tests the cliff validator logic (in the case when we do have a cliff validator) - maybe TestGetTendermintUpdatesWithCliffValidator?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

haha - I wrote that TODO at some unruly hour knowing I might forget about it... thanks! - yeah cool I like your suggested name

Copy link
Contributor Author

Choose a reason for hiding this comment

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

addressed

}

bondedValidatorsCount++
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, what if the validator is revoked - we should make sure it's unbonded, right? (not sure the logic on line 409 is right either)

Seems like we might try to bond a revoked validator and then panic

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OH THANKS - this is actually the error that I caught (aka the code change your seeing actually doesn't affect the functionality at all, surprise that the linter didn't catch this previously honestly) it just wasn't updated for the FULL case... updating now

Copy link
Contributor Author

Choose a reason for hiding this comment

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

in other words the fact that line was in an else at all is quite misleading

Copy link
Contributor Author

Choose a reason for hiding this comment

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

addressed

cwgoes
cwgoes previously approved these changes Jul 7, 2018
Copy link
Contributor

@cwgoes cwgoes left a comment

Choose a reason for hiding this comment

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

Tested ACK

Some of this logic can also benefit from clear switch-case a la #1584.

@cwgoes cwgoes merged commit 51a5021 into develop Jul 7, 2018
@cwgoes cwgoes deleted the rigel/a-validator-on-a-cliff branch July 7, 2018 00:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cliff validator persists with fewer than maximum validators
2 participants