-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Slasher: Refactor and add tests #13589
Conversation
6ccfb60
to
b069820
Compare
b069820
to
d5b6de4
Compare
f0181f3
to
ec50e01
Compare
beacon-chain/slasher/chunks.go
Outdated
log.Errorf("No existing attestation record found for validator %d at target %d, while a surrounded vote was detected.", | ||
validatorIdx, maxTarget, | ||
) |
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.
Avoid templated log messages, it makes it harder to monitor / aggregate these.
Prefer using logrus fields https://pkg.go.dev/github.com/sirupsen/logrus#Logger.WithFields
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.
Fixed in this commit: bd02048
groupedByValidatorChunkIndexAtts := s.groupByValidatorChunkIndex(atts) | ||
log.WithField("numBatches", len(groupedByValidatorChunkIndexAtts)).Debug("Batching attestations by validator chunk index") | ||
groupsCount := len(groupedByValidatorChunkIndexAtts) | ||
batchDurations := make([]time.Duration, 0, len(groupedByValidatorChunkIndexAtts)) |
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.
batchDurations is only used to calculate the totalBatchDuration. Why not just accumulate / update totalBatchDuration and skip this slice allocation?
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.
Fixed in this commit: 7acbc4d
`avgBatchProcessingTime` is not displayed any more if not batch is processed.
So the default value is not any more considered as the absence of value.
Two tests were actually exactly the same.
Even if in this case the "happy" path means slashing.
It adds a few lines for callers, but it does not modify any more arguments and it does what it says: getting a chunk.
So testing will be easier.
Before this commit, there is two typse of `signing root`s floating around. - The first one is a real signing root, aka a hash tree root computed from an object root and a domain. This real signing root is the object ready to be signed. - The second one is a "false" signing root, which is actually just the hash tree root of an object. This object is either the `Data` field of an attestation, or the `Header` field of a block. Having 2 differents objects with the same name `signing root` is quite confusing. This commit renames wrongly named `signing root` objects.
So it's clear for the user that the created attestation wrapper has an empty signature.
By testing `processAttestations` instead of `processQueuedAttestations`, we get rid of a lot of tests fixtures, including the 200 ms sleep. The whole testing duration is shorter.
Some new failing tests are commented with a corresponding github issue.
Co-authored-by: Preston Van Loon <pvanloon@offchainlabs.com>
7acbc4d
to
2ffff9c
Compare
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 , thanks!
Please read this PR commit by commit.
What type of PR is this?
Other
What does this PR do? Why is it needed?
This PR does not add any functional change, but:
The last commit adds new tests, with some commented failing tests.
For each failing test, a ticket issue is linked.
A next PR will fix these tickets:
[]*ethpb.AttesterSlashing
are generated. #13592