beaconclient

package
v1.3.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 16, 2021 License: GPL-3.0 Imports: 33 Imported by: 15

Documentation

Overview

Package beaconclient defines a service that interacts with a beacon node via a gRPC client to listen for streamed blocks, attestations, and to submit proposer/attester slashings to the node in case they are detected.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ChainFetcher

type ChainFetcher interface {
	ChainHead(ctx context.Context) (*ethpb.ChainHead, error)
}

ChainFetcher defines a struct which can retrieve chain information from a beacon node such as the latest chain head.

type Config

type Config struct {
	BeaconProvider        string
	BeaconCert            string
	SlasherDB             db.Database
	ProposerSlashingsFeed *event.Feed
	AttesterSlashingsFeed *event.Feed
	BeaconClient          ethpb.BeaconChainClient
	NodeClient            ethpb.NodeClient
}

Config options for the beaconclient service.

type Notifier

type Notifier interface {
	BlockFeed() *event.Feed
	AttestationFeed() *event.Feed
	ClientReadyFeed() *event.Feed
}

Notifier defines a struct which exposes event feeds regarding beacon blocks, attestations, and more information received from a beacon node.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service struct for the beaconclient service of the slasher.

func NewService added in v1.0.0

func NewService(ctx context.Context, cfg *Config) (*Service, error)

NewService instantiation.

func (*Service) AttestationFeed

func (s *Service) AttestationFeed() *event.Feed

AttestationFeed returns a feed other services in slasher can subscribe to attestations received via the beacon node through gRPC.

func (*Service) BlockFeed

func (s *Service) BlockFeed() *event.Feed

BlockFeed returns a feed other services in slasher can subscribe to blocks received via the beacon node through gRPC.

func (*Service) ChainHead

func (s *Service) ChainHead(
	ctx context.Context,
) (*ethpb.ChainHead, error)

ChainHead requests the latest beacon chain head from a beacon node via gRPC.

func (*Service) ClientReadyFeed

func (s *Service) ClientReadyFeed() *event.Feed

ClientReadyFeed returns a feed other services in slasher can subscribe to to indicate when the gRPC connection is ready.

func (*Service) FindOrGetPublicKeys added in v0.3.10

func (s *Service) FindOrGetPublicKeys(
	ctx context.Context,
	validatorIndices []types.ValidatorIndex,
) (map[types.ValidatorIndex][]byte, error)

FindOrGetPublicKeys gets public keys from cache or request validators public keys from a beacon node via gRPC.

func (*Service) GenesisValidatorsRoot added in v1.0.0

func (s *Service) GenesisValidatorsRoot(
	ctx context.Context,
) ([]byte, error)

GenesisValidatorsRoot requests or fetch from memory the beacon chain genesis validators root via gRPC.

func (*Service) ReceiveAttestations added in v1.0.0

func (s *Service) ReceiveAttestations(ctx context.Context)

ReceiveAttestations starts a gRPC client stream listener to obtain attestations from the beacon node. Upon receiving an attestation, the service broadcasts it to a feed for other services in slasher to subscribe to.

func (*Service) ReceiveBlocks added in v1.0.0

func (s *Service) ReceiveBlocks(ctx context.Context)

ReceiveBlocks starts a gRPC client stream listener to obtain blocks from the beacon node. Upon receiving a block, the service broadcasts it to a feed for other services in slasher to subscribe to.

func (*Service) RequestHistoricalAttestations

func (s *Service) RequestHistoricalAttestations(
	ctx context.Context,
	epoch types.Epoch,
) ([]*ethpb.IndexedAttestation, error)

RequestHistoricalAttestations requests all indexed attestations for a given epoch from a beacon node via gRPC.

func (*Service) Start

func (s *Service) Start()

Start the main runtime of the beaconclient service, initializing a gRPC client connection with a beacon node, listening for streamed blocks/attestations, and submitting slashing operations after they are detected by other services in the slasher.

func (*Service) Status

func (s *Service) Status() error

Status returns an error if there exists a gRPC connection error in the service.

func (*Service) Stop

func (s *Service) Stop() error

Stop the beacon client service by closing the gRPC connection.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL