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

Improve Slashing Protection for V1, More Tests and Observability #7934

Merged
merged 3 commits into from
Nov 24, 2020

Conversation

rauljordan
Copy link
Contributor

What type of PR is this?

Bug fix

What does this PR do? Why is it needed?

Slashing protection, in current master, lives with some really serious problems. Although most of these issues are patched in #7848, that PR needs time to be tested in pre-production environments before making into the master branch due to how radical it is and how much it changes. Unfortunately, we still have some bugs today in detecting surround votes, which we have observed today in our internal infrastructure. The issues are with respect to false positives, meaning that local slashing protection detects certain attestations as slashable which are not. Moreover, we do not have enough logs available to help us understand the problem. This PR adds the following changes:

  • Add a Debug log containing all attestation details in case local slashing protection detects a surround vote or double vote, same for beacon blocks
  • Add more informative logic about why the offense detected is a surround vote or double vote
  • Refactor our logic which checks whether something is a surround vote or not, ensuring we have full unit tests for all possible permutations of surround votes
  • Ensure we do not have dangerous variable shadowing the underlying method which marks all epochs up to a certain target epoch as attested
  • Add comprehensive tests to ensure we are within the weak subjectivity period when checking slashable attestations
  • Add better error handling

@rauljordan rauljordan requested a review from a team as a code owner November 24, 2020 00:19
@@ -7,6 +7,8 @@ import (

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Review carefully

@@ -2,6 +2,7 @@ package client

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Look at all these tests!

@@ -127,6 +127,49 @@ func (hd EncHistoryData) SetTargetData(ctx context.Context, target uint64, histo
return hd, nil
}

// MarkAllAsAttestedSinceLatestWrittenEpoch returns an attesting history with specified target+epoch pairs
// since the latest written epoch up to the incoming attestation's target epoch as attested for.
func MarkAllAsAttestedSinceLatestWrittenEpoch(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same logic as before, just changed to remove variable shadowing risk

func markAttestationForTargetEpoch(ctx context.Context, history kv.EncHistoryData, sourceEpoch, targetEpoch uint64, signingRoot [32]byte) kv.EncHistoryData {

@rauljordan rauljordan self-assigned this Nov 24, 2020
@rauljordan rauljordan added Priority: Critical Highest, immediate priority item Ready For Review A pull request ready for code review release-target Security Security Related Issues labels Nov 24, 2020
@rauljordan rauljordan merged commit 2cb8146 into master Nov 24, 2020
@rauljordan rauljordan deleted the slashing-protection-info branch November 24, 2020 01:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: Critical Highest, immediate priority item Ready For Review A pull request ready for code review Security Security Related Issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants