Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions internal/adapters/beacon/beacon.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,21 +257,32 @@ func (b *beaconAttestantClient) GetValidatorsLiveness(ctx context.Context, epoch
return livenessMap, nil
}

// GetSlashedValidators retrieves the indices of slashed validators. In the justified state.
// GetSlashedValidators retrieves the indices of slashed validators in the justified state.
func (b *beaconAttestantClient) GetSlashedValidators(ctx context.Context, indices []domain.ValidatorIndex) ([]domain.ValidatorIndex, error) {
if len(indices) == 0 {
// No validators to check; return immediately. Nice to have
return nil, nil
}

// Convert domain.ValidatorIndex to phase0.ValidatorIndex
beaconIndices := make([]phase0.ValidatorIndex, len(indices))
for i, idx := range indices {
beaconIndices[i] = phase0.ValidatorIndex(idx)
}

slashed, err := b.client.Validators(ctx, &api.ValidatorsOpts{
State: "justified",
// Only get validators in slashed states
ValidatorStates: []v1.ValidatorState{
v1.ValidatorStateActiveSlashed,
v1.ValidatorStateExitedSlashed,
},
Indices: make([]phase0.ValidatorIndex, len(indices)),
Indices: beaconIndices,
})

if err != nil {
return nil, err
}

slashedIndices := make([]domain.ValidatorIndex, 0, len(slashed.Data))
for _, v := range slashed.Data {
slashedIndices = append(slashedIndices, domain.ValidatorIndex(v.Index))
Expand Down