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

R4R: Fix signing info handling bugs & faulty slashing #2480

Merged
merged 23 commits into from
Oct 16, 2018

Conversation

cwgoes
Copy link
Contributor

@cwgoes cwgoes commented Oct 11, 2018

Closes #2372
Closes #1867

Addressing both issues at once is more efficient.

  • Signing info is now initialized when a validator is bonded, using the existing validator bond hook
  • Signing info array & counter are now reset when a validator is jailed, giving them a chance to sign blocks again afterwards without being immediately slashed

Nothing is reset if a validator leaves the bonded set as a result of any reason other than being slashed for downtime, so it shouldn't be possible to reset the counter without also incurring the penalties of being slashed & jailed.

We must iterate over SignedBlocksWindow store keys and delete them when a validator is slashed for downtime, but that's probably a relatively rare occurrence and incurs a real cost, so I don't think spam is too much of a concern.

Standard checklist:

  • 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 explorer

For Admin Use:

  • Added appropriate labels to PR (ex. wip, ready-for-review, docs)
  • Reviewers Assigned
  • Squashed all commits, uses message "Merge pull request #XYZ: [title]" (coding standards)

@cwgoes cwgoes changed the title WIP: Fix signing info handling bugs WIP: Fix signing info handling bugs & faulty slashing Oct 11, 2018
@codecov
Copy link

codecov bot commented Oct 11, 2018

Codecov Report

❗ No coverage uploaded for pull request base (develop@2803830). Click here to learn what that means.
The diff coverage is 83.67%.

@@            Coverage Diff            @@
##             develop   #2480   +/-   ##
=========================================
  Coverage           ?     60%           
=========================================
  Files              ?     151           
  Lines              ?    8844           
  Branches           ?       0           
=========================================
  Hits               ?    5307           
  Misses             ?    3167           
  Partials           ?     370

@cwgoes
Copy link
Contributor Author

cwgoes commented Oct 11, 2018

OK, this should basically do what we want, just need to make sure the jail duration is greater than the signed blocks window. Needs testcases & spec update.

@cwgoes cwgoes requested a review from zramsay as a code owner October 11, 2018 23:05
@cwgoes cwgoes changed the title WIP: Fix signing info handling bugs & faulty slashing R4R: Fix signing info handling bugs & faulty slashing Oct 12, 2018
@cwgoes
Copy link
Contributor Author

cwgoes commented Oct 12, 2018

cc @SLAMPER @HaoyangLiu want to review?

Copy link
Contributor

@hendrikhofstadt hendrikhofstadt left a comment

Choose a reason for hiding this comment

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

utACK however please note minimal change requests.

x/slashing/keeper_test.go Show resolved Hide resolved
}
minHeight := signInfo.StartHeight + k.SignedBlocksWindow(ctx)
if height > minHeight && signInfo.SignedBlocksCounter < k.MinSignedPerWindow(ctx) {
maxMissed := k.SignedBlocksWindow(ctx) - k.MinSignedPerWindow(ctx)
if height > minHeight && signInfo.MissedBlocksCounter > maxMissed {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we really want to keep this dependent on the StartHeight ?

That way a validator could unbond every SignedBlocksWindow-2 blocks and then rebond to avoid slashing since the StartHeight is reset now.

Copy link
Contributor Author

@cwgoes cwgoes Oct 14, 2018

Choose a reason for hiding this comment

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

Ah yes, of course, in the case when they aren't jailed at all.

I think I'll try the other strategy, deleting the array shouldn't be too expensive.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now we never reset the start height, and instead reset the counter & clear the array when the validator is slashed for downtime.

@cwgoes cwgoes changed the title R4R: Fix signing info handling bugs & faulty slashing WIP: Fix signing info handling bugs & faulty slashing Oct 14, 2018
x/slashing/keeper.go Outdated Show resolved Hide resolved
x/slashing/keeper.go Outdated Show resolved Hide resolved
@cwgoes cwgoes changed the title WIP: Fix signing info handling bugs & faulty slashing R4R: Fix signing info handling bugs & faulty slashing Oct 15, 2018
@cwgoes
Copy link
Contributor Author

cwgoes commented Oct 15, 2018

Ready for review again.

Copy link
Contributor

@rigelrozanski rigelrozanski left a comment

Choose a reason for hiding this comment

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

looks good! few lil comments

x/slashing/keeper.go Outdated Show resolved Hide resolved
x/slashing/keeper_test.go Show resolved Hide resolved
x/slashing/keeper_test.go Outdated Show resolved Hide resolved
x/slashing/keeper_test.go Outdated Show resolved Hide resolved
x/slashing/keeper_test.go Show resolved Hide resolved
@cwgoes
Copy link
Contributor Author

cwgoes commented Oct 15, 2018

Thanks @rigelrozanski - do you want to review this @jaekwon?

@cwgoes cwgoes merged commit 55f4f61 into develop Oct 16, 2018
@cwgoes cwgoes deleted the cwgoes/fix-signing-info-bugs branch October 16, 2018 18:21
@sunnya97 sunnya97 mentioned this pull request Oct 24, 2018
4 tasks
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.

4 participants