mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-24 20:37:17 +00:00
4e28192541
* Proposer RPC: helpers to get exits and slashings * add test Co-authored-by: Nishant Das <nishdas93@gmail.com>
35 lines
1.4 KiB
Go
35 lines
1.4 KiB
Go
package validator
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/prysmaticlabs/prysm/v3/beacon-chain/core/blocks"
|
|
v "github.com/prysmaticlabs/prysm/v3/beacon-chain/core/validators"
|
|
"github.com/prysmaticlabs/prysm/v3/beacon-chain/state"
|
|
ethpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
|
|
)
|
|
|
|
func (vs *Server) getSlashings(ctx context.Context, head state.BeaconState) ([]*ethpb.ProposerSlashing, []*ethpb.AttesterSlashing) {
|
|
proposerSlashings := vs.SlashingsPool.PendingProposerSlashings(ctx, head, false /*noLimit*/)
|
|
validProposerSlashings := make([]*ethpb.ProposerSlashing, 0, len(proposerSlashings))
|
|
for _, slashing := range proposerSlashings {
|
|
_, err := blocks.ProcessProposerSlashing(ctx, head, slashing, v.SlashValidator)
|
|
if err != nil {
|
|
log.WithError(err).Warn("Could not validate proposer slashing for block inclusion")
|
|
continue
|
|
}
|
|
validProposerSlashings = append(validProposerSlashings, slashing)
|
|
}
|
|
attSlashings := vs.SlashingsPool.PendingAttesterSlashings(ctx, head, false /*noLimit*/)
|
|
validAttSlashings := make([]*ethpb.AttesterSlashing, 0, len(attSlashings))
|
|
for _, slashing := range attSlashings {
|
|
_, err := blocks.ProcessAttesterSlashing(ctx, head, slashing, v.SlashValidator)
|
|
if err != nil {
|
|
log.WithError(err).Warn("Could not validate attester slashing for block inclusion")
|
|
continue
|
|
}
|
|
validAttSlashings = append(validAttSlashings, slashing)
|
|
}
|
|
return validProposerSlashings, validAttSlashings
|
|
}
|