mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-24 04:17:18 +00:00
84916672c6
* 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>
74 lines
2.1 KiB
Go
74 lines
2.1 KiB
Go
package mock
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/prysmaticlabs/prysm/config/params"
|
|
types "github.com/prysmaticlabs/prysm/consensus-types/primitives"
|
|
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
|
)
|
|
|
|
type MockSlashingChecker struct {
|
|
AttesterSlashingFound bool
|
|
ProposerSlashingFound bool
|
|
HighestAtts map[types.ValidatorIndex]*ethpb.HighestAttestation
|
|
}
|
|
|
|
func (s *MockSlashingChecker) HighestAttestations(
|
|
_ context.Context, indices []types.ValidatorIndex,
|
|
) ([]*ethpb.HighestAttestation, error) {
|
|
atts := make([]*ethpb.HighestAttestation, 0, len(indices))
|
|
for _, valIdx := range indices {
|
|
att, ok := s.HighestAtts[valIdx]
|
|
if !ok {
|
|
continue
|
|
}
|
|
atts = append(atts, att)
|
|
}
|
|
return atts, nil
|
|
}
|
|
|
|
func (s *MockSlashingChecker) IsSlashableBlock(_ context.Context, _ *ethpb.SignedBeaconBlockHeader) (*ethpb.ProposerSlashing, error) {
|
|
if s.ProposerSlashingFound {
|
|
return ðpb.ProposerSlashing{
|
|
Header_1: ðpb.SignedBeaconBlockHeader{
|
|
Header: ðpb.BeaconBlockHeader{
|
|
Slot: 0,
|
|
ProposerIndex: 0,
|
|
ParentRoot: params.BeaconConfig().ZeroHash[:],
|
|
StateRoot: params.BeaconConfig().ZeroHash[:],
|
|
BodyRoot: params.BeaconConfig().ZeroHash[:],
|
|
},
|
|
Signature: params.BeaconConfig().EmptySignature[:],
|
|
},
|
|
Header_2: ðpb.SignedBeaconBlockHeader{
|
|
Header: ðpb.BeaconBlockHeader{
|
|
Slot: 0,
|
|
ProposerIndex: 0,
|
|
ParentRoot: params.BeaconConfig().ZeroHash[:],
|
|
StateRoot: params.BeaconConfig().ZeroHash[:],
|
|
BodyRoot: params.BeaconConfig().ZeroHash[:],
|
|
},
|
|
Signature: params.BeaconConfig().EmptySignature[:],
|
|
},
|
|
}, nil
|
|
}
|
|
return nil, nil
|
|
}
|
|
|
|
func (s *MockSlashingChecker) IsSlashableAttestation(_ context.Context, _ *ethpb.IndexedAttestation) ([]*ethpb.AttesterSlashing, error) {
|
|
if s.AttesterSlashingFound {
|
|
return []*ethpb.AttesterSlashing{
|
|
{
|
|
Attestation_1: ðpb.IndexedAttestation{
|
|
Data: ðpb.AttestationData{},
|
|
},
|
|
Attestation_2: ðpb.IndexedAttestation{
|
|
Data: ðpb.AttestationData{},
|
|
},
|
|
},
|
|
}, nil
|
|
}
|
|
return nil, nil
|
|
}
|