Skip to content

Commit

Permalink
Better Nil Check in Slasher (#5053)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
rauljordan committed Mar 9, 2020
1 parent b633dfe commit e77cf72
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions slasher/detection/detect.go
Expand Up @@ -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 {
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion slasher/detection/service.go
Expand Up @@ -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])
Expand Down

0 comments on commit e77cf72

Please sign in to comment.