Better Nil Check in Slasher (#5053)

* rem slasher proto
* Merge branch 'master' of github.com:prysmaticlabs/prysm
* Merge branch 'master' of github.com:prysmaticlabs/prysm
* Merge branch 'master' of github.com:prysmaticlabs/prysm
* Merge branch 'master' of github.com:prysmaticlabs/prysm
* Merge branch 'master' of github.com:prysmaticlabs/prysm
* Merge branch 'master' of github.com:prysmaticlabs/prysm
* Merge branch 'master' of github.com:prysmaticlabs/prysm
* Merge branch 'master' of github.com:prysmaticlabs/prysm
* some nil checks in slasher
This commit is contained in:
Raul Jordan
2020-03-09 16:21:39 -05:00
committed by GitHub
parent b633dfe880
commit e77cf724b8
2 changed files with 5 additions and 3 deletions

View File

@@ -26,7 +26,7 @@ func (ds *Service) detectAttesterSlashings(
return nil, nil
}
var slashings []*ethpb.AttesterSlashing
var slashings []*ethpb.AttesterSlashing
for _, result := range results {
var slashing *ethpb.AttesterSlashing
switch result.Kind {
@@ -41,7 +41,9 @@ func (ds *Service) detectAttesterSlashings(
return nil, errors.Wrap(err, "could not detect surround votes on attestation")
}
}
slashings = append(slashings, slashing)
if slashing != nil {
slashings = append(slashings, slashing)
}
}
return slashings, nil

View File

@@ -152,7 +152,7 @@ func (ds *Service) submitAttesterSlashings(ctx context.Context, slashings []*eth
}
for i := 0; i < len(slashings); i++ {
slash := slashings[i]
if slash.Attestation_1 != nil && slash.Attestation_2 != nil {
if slash != nil && slash.Attestation_1 != nil && slash.Attestation_2 != nil {
slashableIndices := sliceutil.IntersectionUint64(slashings[i].Attestation_1.AttestingIndices, slashings[i].Attestation_2.AttestingIndices)
slashedIndices = append(slashedIndices, slashableIndices...)
ds.attesterSlashingsFeed.Send(slashings[i])