mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 12:57:18 +00:00
7076a1ec4a
* Delete disable state lock and init sync verbose flags * Delete disable slashing broadcast * Remove disable wait for sync, noise, eth1 cache, static subnet * Remove enable broadcast recovery attemp and make it as default * Remove disable head update on per attestation * Revert disable att braodcast discovery attempt * gazelle * Fixed an anti pattern * Add enableAttBroadcastDiscoveryAttempts back * Add back WaitForSync * Remove extra lines * Use DisableDynamicCommitteeSubnets path per @prestonvanloon feedback Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
58 lines
2.0 KiB
Go
58 lines
2.0 KiB
Go
package beacon
|
|
|
|
import (
|
|
"context"
|
|
|
|
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
|
"github.com/prysmaticlabs/prysm/shared/sliceutil"
|
|
"google.golang.org/grpc/codes"
|
|
"google.golang.org/grpc/status"
|
|
)
|
|
|
|
// SubmitProposerSlashing receives a proposer slashing object via
|
|
// RPC and injects it into the beacon node's operations pool.
|
|
// Submission into this pool does not guarantee inclusion into a beacon block.
|
|
func (bs *Server) SubmitProposerSlashing(
|
|
ctx context.Context,
|
|
req *ethpb.ProposerSlashing,
|
|
) (*ethpb.SubmitSlashingResponse, error) {
|
|
beaconState, err := bs.HeadFetcher.HeadState(ctx)
|
|
if err != nil {
|
|
return nil, status.Errorf(codes.Internal, "Could not retrieve head state: %v", err)
|
|
}
|
|
if err := bs.SlashingsPool.InsertProposerSlashing(ctx, beaconState, req); err != nil {
|
|
return nil, status.Errorf(codes.Internal, "Could not insert proposer slashing into pool: %v", err)
|
|
}
|
|
if err := bs.Broadcaster.Broadcast(ctx, req); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return ðpb.SubmitSlashingResponse{
|
|
SlashedIndices: []uint64{req.Header_1.Header.ProposerIndex},
|
|
}, nil
|
|
}
|
|
|
|
// SubmitAttesterSlashing receives an attester slashing object via
|
|
// RPC and injects it into the beacon node's operations pool.
|
|
// Submission into this pool does not guarantee inclusion into a beacon block.
|
|
func (bs *Server) SubmitAttesterSlashing(
|
|
ctx context.Context,
|
|
req *ethpb.AttesterSlashing,
|
|
) (*ethpb.SubmitSlashingResponse, error) {
|
|
beaconState, err := bs.HeadFetcher.HeadState(ctx)
|
|
if err != nil {
|
|
return nil, status.Errorf(codes.Internal, "Could not retrieve head state: %v", err)
|
|
}
|
|
if err := bs.SlashingsPool.InsertAttesterSlashing(ctx, beaconState, req); err != nil {
|
|
return nil, status.Errorf(codes.Internal, "Could not insert attester slashing into pool: %v", err)
|
|
}
|
|
if err := bs.Broadcaster.Broadcast(ctx, req); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
slashedIndices := sliceutil.IntersectionUint64(req.Attestation_1.AttestingIndices, req.Attestation_2.AttestingIndices)
|
|
return ðpb.SubmitSlashingResponse{
|
|
SlashedIndices: slashedIndices,
|
|
}, nil
|
|
}
|