prysm-pulse/beacon-chain/rpc/prysm/v1alpha1/slasher/attestations.go
Raul Jordan 84916672c6
Remove Eth2-Types Dependency in Prysm (#10578)
* replace eth2 types

* replace protos

* regen proto

* replace

* gaz

* deps

* amend

* regen proto

* mod

* gaz

* gaz

* ensure build

* ssz

* add dep

* no more eth2 types

* no more eth2

* remg

* all builds

* buidl

* tidy

* clean

* fmt

* val serv

* gaz

Co-authored-by: Preston Van Loon <preston@prysmaticlabs.com>
2022-04-29 10:32:11 -04:00

44 lines
1.5 KiB
Go

package slasher
import (
"context"
types "github.com/prysmaticlabs/prysm/consensus-types/primitives"
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
// IsSlashableAttestation returns an attester slashing if an input
// attestation is found to be slashable.
func (s *Server) IsSlashableAttestation(
ctx context.Context, req *ethpb.IndexedAttestation,
) (*ethpb.AttesterSlashingResponse, error) {
attesterSlashings, err := s.SlashingChecker.IsSlashableAttestation(ctx, req)
if err != nil {
return nil, status.Errorf(codes.Internal, "Could not determine if attestation is slashable: %v", err)
}
if len(attesterSlashings) > 0 {
return &ethpb.AttesterSlashingResponse{
AttesterSlashings: attesterSlashings,
}, nil
}
return &ethpb.AttesterSlashingResponse{}, nil
}
// HighestAttestations returns the highest source and target epochs attested for
// validator indices that have been observed by slasher.
func (s *Server) HighestAttestations(
ctx context.Context, req *ethpb.HighestAttestationRequest,
) (*ethpb.HighestAttestationResponse, error) {
valIndices := make([]types.ValidatorIndex, len(req.ValidatorIndices))
for i, valIdx := range req.ValidatorIndices {
valIndices[i] = types.ValidatorIndex(valIdx)
}
atts, err := s.SlashingChecker.HighestAttestations(ctx, valIndices)
if err != nil {
return nil, status.Errorf(codes.Internal, "Could not get highest attestations: %v", err)
}
return &ethpb.HighestAttestationResponse{Attestations: atts}, nil
}