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
Change span representation to a struct in Slasher #4981
Conversation
@@ -23,7 +19,7 @@ var _ = iface.SpanDetector(&SpanDetector{}) | |||
// spans from validators and attestation data roots. | |||
type SpanDetector struct { | |||
// Slice of epochs for valindex => min-max span + double vote filter | |||
spans []map[uint64][3]uint16 | |||
spans []map[uint64]types.Span |
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 using a reference since the actual struct nearly the same size as the pointer would be, just an extra bool. There are also no nested/dynamic types. Size is static.
If this should be changed let me know.
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.
Partial review .didn't look at tests yet. Will look at it all in few hours
}, nil | ||
} | ||
} | ||
|
||
if sp := s.spans[targetEpoch%numSpans]; sp != nil { | ||
filterNum := sp[validatorIdx][2] | ||
if filterNum == 0 { | ||
// Check if the validator has attested for this epoch or not. |
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.
We also need to check if it's the same dataroot in order to decide if its double. Doing it in another PR?
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.
Yeah, that will be handled by detection. This just makes sure the attestation triggers a hard DB check.
} | ||
filterNum = binary.LittleEndian.Uint16(attFilter) | ||
|
||
// Set the bloom filter back into the span for the epoch. |
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.
It's not a bloom filter any more
Codecov Report
@@ Coverage Diff @@
## master #4981 +/- ##
========================================
Coverage ? 3.99%
========================================
Files ? 71
Lines ? 6258
Branches ? 0
========================================
Hits ? 250
Misses ? 5988
Partials ? 20 |
SlashableEpoch: targetEpoch, | ||
}, nil | ||
} | ||
return &types.DetectionResult{ |
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.
seems strange to return double vote when it is not verified
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.
This is just for the detection, it lets the detection service to do a hard check, which we always need to do anyways for checking double votes.
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.
Using 2 bytes of the signature isn't safe enough to just compare the receiving attestation with it IMO, db checks are really quick with this strategy.
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.
thats 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.
lgtm
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.
please change to reference
… into slasher-change-filter
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.
lgtm
lets merge it and i will use this struct in my spanner db
Part of #4836
This PR changes the
[3]uint16
of the spanner to aChanges include making a distinct field for the bytes to be stored, and changing the bloom filter to a [2]byte, that can later be used to append to the target epoch for searching the DB for the slashable attestation.
By storing part of the DB key in the spanner, we can retrieve the attestation we need to find faster. Will plugin to detection through another PR.