mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 04:47:18 +00:00
Move cheaper operations earlier into code path (#5835)
Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
This commit is contained in:
parent
578703fa05
commit
ca7e057ca7
@ -97,19 +97,20 @@ func (ds *Service) detectDoubleVote(
|
||||
continue
|
||||
}
|
||||
|
||||
// If there are no shared indices, there is no validator to slash.
|
||||
if len(sliceutil.IntersectionUint64(att.AttestingIndices, []uint64{detectionResult.ValidatorIndex})) == 0 {
|
||||
if !isDoubleVote(incomingAtt, att) {
|
||||
continue
|
||||
}
|
||||
|
||||
if isDoubleVote(incomingAtt, att) {
|
||||
doubleVotesDetected.Inc()
|
||||
return ðpb.AttesterSlashing{
|
||||
Attestation_1: incomingAtt,
|
||||
Attestation_2: att,
|
||||
}, nil
|
||||
// If there are no shared indices, there is no validator to slash.
|
||||
if !sliceutil.IsInUint64(detectionResult.ValidatorIndex, att.AttestingIndices) {
|
||||
continue
|
||||
}
|
||||
|
||||
doubleVotesDetected.Inc()
|
||||
return ðpb.AttesterSlashing{
|
||||
Attestation_1: incomingAtt,
|
||||
Attestation_2: att,
|
||||
}, nil
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
@ -135,20 +136,25 @@ func (ds *Service) detectSurroundVotes(
|
||||
if att.Data == nil {
|
||||
continue
|
||||
}
|
||||
isSurround := isSurrounding(incomingAtt, att)
|
||||
isSurrounded := isSurrounding(att, incomingAtt)
|
||||
if !isSurround && !isSurrounded {
|
||||
continue
|
||||
}
|
||||
// If there are no shared indices, there is no validator to slash.
|
||||
if len(sliceutil.IntersectionUint64(att.AttestingIndices, []uint64{detectionResult.ValidatorIndex})) == 0 {
|
||||
if !sliceutil.IsInUint64(detectionResult.ValidatorIndex, att.AttestingIndices) {
|
||||
continue
|
||||
}
|
||||
|
||||
// Slashings must be submitted as the incoming attestation surrounding the saved attestation.
|
||||
// So we swap the order if needed.
|
||||
if isSurrounding(incomingAtt, att) {
|
||||
if isSurround {
|
||||
surroundingVotesDetected.Inc()
|
||||
return ðpb.AttesterSlashing{
|
||||
Attestation_1: incomingAtt,
|
||||
Attestation_2: att,
|
||||
}, nil
|
||||
} else if isSurrounding(att, incomingAtt) {
|
||||
} else if isSurrounded {
|
||||
surroundedVotesDetected.Inc()
|
||||
return ðpb.AttesterSlashing{
|
||||
Attestation_1: att,
|
||||
|
Loading…
Reference in New Issue
Block a user