mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 12:57: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
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there are no shared indices, there is no validator to slash.
|
if !isDoubleVote(incomingAtt, att) {
|
||||||
if len(sliceutil.IntersectionUint64(att.AttestingIndices, []uint64{detectionResult.ValidatorIndex})) == 0 {
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if isDoubleVote(incomingAtt, att) {
|
// If there are no shared indices, there is no validator to slash.
|
||||||
doubleVotesDetected.Inc()
|
if !sliceutil.IsInUint64(detectionResult.ValidatorIndex, att.AttestingIndices) {
|
||||||
return ðpb.AttesterSlashing{
|
continue
|
||||||
Attestation_1: incomingAtt,
|
|
||||||
Attestation_2: att,
|
|
||||||
}, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
doubleVotesDetected.Inc()
|
||||||
|
return ðpb.AttesterSlashing{
|
||||||
|
Attestation_1: incomingAtt,
|
||||||
|
Attestation_2: att,
|
||||||
|
}, nil
|
||||||
}
|
}
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
@ -135,20 +136,25 @@ func (ds *Service) detectSurroundVotes(
|
|||||||
if att.Data == nil {
|
if att.Data == nil {
|
||||||
continue
|
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 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
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// Slashings must be submitted as the incoming attestation surrounding the saved attestation.
|
// Slashings must be submitted as the incoming attestation surrounding the saved attestation.
|
||||||
// So we swap the order if needed.
|
// So we swap the order if needed.
|
||||||
if isSurrounding(incomingAtt, att) {
|
if isSurround {
|
||||||
surroundingVotesDetected.Inc()
|
surroundingVotesDetected.Inc()
|
||||||
return ðpb.AttesterSlashing{
|
return ðpb.AttesterSlashing{
|
||||||
Attestation_1: incomingAtt,
|
Attestation_1: incomingAtt,
|
||||||
Attestation_2: att,
|
Attestation_2: att,
|
||||||
}, nil
|
}, nil
|
||||||
} else if isSurrounding(att, incomingAtt) {
|
} else if isSurrounded {
|
||||||
surroundedVotesDetected.Inc()
|
surroundedVotesDetected.Inc()
|
||||||
return ðpb.AttesterSlashing{
|
return ðpb.AttesterSlashing{
|
||||||
Attestation_1: att,
|
Attestation_1: att,
|
||||||
|
Loading…
Reference in New Issue
Block a user