prysm-pulse/validator/slashing-protection/external.go
Raul Jordan df33ce3309
Remaining Slasher Beacon Node Changes (#9701)
* slasher beacon node changes

* remaining beacon node items

* moar changes

* gaz

* flag fix

* rem slashable

* builds

* imports

* fix up

* pruning faster test

* deepsource

* fix wrong item

* node node feature flags

* broken test

* preston review

* more preston comments

* comment

Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
2021-09-29 18:17:37 +00:00

36 lines
1.2 KiB
Go

package slashingprotection
import (
"context"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
)
// CheckBlockSafety for blocks before submitting them to the node.
func (s *Service) CheckBlockSafety(ctx context.Context, blockHeader *ethpb.SignedBeaconBlockHeader) bool {
ps, err := s.slasherClient.IsSlashableBlock(ctx, blockHeader)
if err != nil {
log.Errorf("External slashing block protection returned an error: %v", err)
return false
}
if ps != nil && len(ps.ProposerSlashings) != 0 {
log.Warn("External slashing proposal protection found the block to be slashable")
return false
}
return true
}
// CheckAttestationSafety for attestations before submitting them to the node.
func (s *Service) CheckAttestationSafety(ctx context.Context, attestation *ethpb.IndexedAttestation) bool {
as, err := s.slasherClient.IsSlashableAttestation(ctx, attestation)
if err != nil {
log.Errorf("External slashing attestation protection returned an error: %v", err)
return false
}
if as != nil && len(as.AttesterSlashings) != 0 {
log.Warnf("External slashing attestation protection found the attestation to be slashable: %v", as)
return false
}
return true
}