mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 04:47:18 +00:00
17169e5a2d
* slasher grpc client * do not export * slasher on a different package * fix featureconfig * change to rough time * revert roughtime * remove extra comma * revert order change * goimports * fix comments and tests * fix package name * revert reorder * comment for start * service * fix visibility * external slasher validator protection implementation * gaz * fix comment * add comments * nishant feedback * raul feedback * preston feedback * fix flags * fix imports * fix imports * port 4002 * added tests * fix log * fix imports * fix imports name * raul feedback * gaz * terence comment * change name * runtime fixes * add flag check Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
34 lines
1.1 KiB
Go
34 lines
1.1 KiB
Go
package slashingprotection
|
|
|
|
import (
|
|
"context"
|
|
|
|
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
|
log "github.com/sirupsen/logrus"
|
|
)
|
|
|
|
// VerifyBlock implements the slashing protection for block proposals.
|
|
func (s *Service) VerifyBlock(ctx context.Context, blockHeader *ethpb.SignedBeaconBlockHeader) bool {
|
|
ps, err := s.slasherClient.IsSlashableBlock(ctx, blockHeader)
|
|
if err != nil {
|
|
log.Warnf("External slashing block protection returned an error: %v", err)
|
|
}
|
|
if ps != nil && ps.ProposerSlashing != nil {
|
|
return false
|
|
}
|
|
return true
|
|
}
|
|
|
|
// VerifyAttestation implements the slashing protection for attestations.
|
|
func (s *Service) VerifyAttestation(ctx context.Context, attestation *ethpb.IndexedAttestation) bool {
|
|
as, err := s.slasherClient.IsSlashableAttestation(ctx, attestation)
|
|
if err != nil {
|
|
log.Warnf("External slashing attestation protection returned an error: %v", err)
|
|
}
|
|
if as != nil && as.AttesterSlashing != nil {
|
|
log.Warnf("External slashing attestation protection found the attestation to be slashable: %v", as)
|
|
return false
|
|
}
|
|
return true
|
|
}
|