rpc

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2019 License: GPL-3.0 Imports: 47 Imported by: 0

Documentation

Overview

Package rpc defines the services that the beacon-chain uses to communicate via gRPC.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AttesterServer

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

AttesterServer defines a server implementation of the gRPC Attester service, providing RPC methods for validators acting as attesters to broadcast votes on beacon blocks.

func (*AttesterServer) RequestAttestation

func (as *AttesterServer) RequestAttestation(ctx context.Context, req *pb.AttestationRequest) (*ethpb.AttestationData, error)

RequestAttestation requests that the beacon node produce an IndexedAttestation, with a blank signature field, which the validator will then sign.

func (*AttesterServer) SubmitAttestation

func (as *AttesterServer) SubmitAttestation(ctx context.Context, att *ethpb.Attestation) (*pb.AttestResponse, error)

SubmitAttestation is a function called by an attester in a sharding validator to vote on a block via an attestation object as defined in the Ethereum Serenity specification.

type BeaconChainServer

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

BeaconChainServer defines a server implementation of the gRPC Beacon Chain service, providing RPC endpoints to access data relevant to the Ethereum 2.0 phase 0 beacon chain.

func (*BeaconChainServer) AttestationPool

func (bs *BeaconChainServer) AttestationPool(
	ctx context.Context, _ *ptypes.Empty,
) (*ethpb.AttestationPoolResponse, error)

AttestationPool retrieves pending attestations.

The server returns a list of attestations that have been seen but not yet processed. Pool attestations eventually expire as the slot advances, so an attestation missing from this request does not imply that it was included in a block. The attestation may have expired. Refer to the ethereum 2.0 specification for more details on how attestations are processed and when they are no longer valid. https://github.com/ethereum/eth2.0-specs/blob/dev/specs/core/0_beacon-chain.md#attestations

func (*BeaconChainServer) GetChainHead

func (bs *BeaconChainServer) GetChainHead(ctx context.Context, _ *ptypes.Empty) (*ethpb.ChainHead, error)

GetChainHead retrieves information about the head of the beacon chain from the view of the beacon chain node.

This includes the head block slot and root as well as information about the most recent finalized and justified slots.

func (*BeaconChainServer) GetValidatorActiveSetChanges

func (bs *BeaconChainServer) GetValidatorActiveSetChanges(
	ctx context.Context, req *ethpb.GetValidatorActiveSetChangesRequest,
) (*ethpb.ActiveSetChanges, error)

GetValidatorActiveSetChanges retrieves the active set changes for a given epoch.

This data includes any activations, voluntary exits, and involuntary ejections.

func (*BeaconChainServer) GetValidatorParticipation

GetValidatorParticipation retrieves the validator participation information for a given epoch, it returns the information about validator's participation rate in voting on the proof of stake rules based on their balance compared to the total active validator balance.

func (*BeaconChainServer) GetValidatorQueue

func (bs *BeaconChainServer) GetValidatorQueue(
	ctx context.Context, _ *ptypes.Empty,
) (*ethpb.ValidatorQueue, error)

GetValidatorQueue retrieves the current validator queue information.

func (*BeaconChainServer) GetValidators

func (bs *BeaconChainServer) GetValidators(
	ctx context.Context,
	req *ethpb.GetValidatorsRequest,
) (*ethpb.Validators, error)

GetValidators retrieves the current list of active validators with an optional historical epoch flag to to retrieve validator set in time.

func (*BeaconChainServer) ListAttestations

ListAttestations retrieves attestations by block root, slot, or epoch. Attestations are sorted by crosslink shard by default.

The server may return an empty list when no attestations match the given filter criteria. This RPC should not return NOT_FOUND. Only one filter criteria should be used.

func (*BeaconChainServer) ListBlocks

ListBlocks retrieves blocks by root, slot, or epoch.

The server may return multiple blocks in the case that a slot or epoch is provided as the filter criteria. The server may return an empty list when no blocks in their database match the filter criteria. This RPC should not return NOT_FOUND. Only one filter criteria should be used.

func (*BeaconChainServer) ListValidatorAssignments

ListValidatorAssignments retrieves the validator assignments for a given epoch, optional validator indices or public keys may be included to filter validator assignments.

func (*BeaconChainServer) ListValidatorBalances

ListValidatorBalances retrieves the validator balances for a given set of public keys. An optional Epoch parameter is provided to request historical validator balances from archived, persistent data.

type Config

type Config struct {
	Port                  string
	CertFlag              string
	KeyFlag               string
	BeaconDB              db.Database
	StateFeedListener     blockchain.ChainFeeds
	HeadFetcher           blockchain.HeadFetcher
	ForkFetcher           blockchain.ForkFetcher
	FinalizationFetcher   blockchain.FinalizationFetcher
	AttestationReceiver   blockchain.AttestationReceiver
	BlockReceiver         blockchain.BlockReceiver
	POWChainService       powchain.Chain
	ChainStartFetcher     powchain.ChainStartFetcher
	GenesisTimeFetcher    blockchain.GenesisTimeFetcher
	MockEth1Votes         bool
	OperationsHandler     operations.Handler
	AttestationsPool      operations.Pool
	SyncService           sync.Checker
	Broadcaster           p2p.Broadcaster
	DepositFetcher        depositcache.DepositFetcher
	PendingDepositFetcher depositcache.PendingDepositsFetcher
}

Config options for the beacon node RPC server.

type NodeServer

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

NodeServer defines a server implementation of the gRPC Node service, providing RPC endpoints for verifying a beacon node's sync status, genesis and version information, and services the node implements and runs.

func (*NodeServer) GetGenesis

func (ns *NodeServer) GetGenesis(ctx context.Context, _ *ptypes.Empty) (*ethpb.Genesis, error)

GetGenesis fetches genesis chain information of Ethereum 2.0.

func (*NodeServer) GetSyncStatus

func (ns *NodeServer) GetSyncStatus(ctx context.Context, _ *ptypes.Empty) (*ethpb.SyncStatus, error)

GetSyncStatus checks the current network sync status of the node.

func (*NodeServer) GetVersion

func (ns *NodeServer) GetVersion(ctx context.Context, _ *ptypes.Empty) (*ethpb.Version, error)

GetVersion checks the version information of the beacon node.

func (*NodeServer) ListImplementedServices

func (ns *NodeServer) ListImplementedServices(ctx context.Context, _ *ptypes.Empty) (*ethpb.ImplementedServices, error)

ListImplementedServices lists the services implemented and enabled by this node.

Any service not present in this list may return UNIMPLEMENTED or PERMISSION_DENIED. The server may also support fetching services by grpc reflection.

type ProposerServer

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

ProposerServer defines a server implementation of the gRPC Proposer service, providing RPC endpoints for computing state transitions and state roots, proposing beacon blocks to a beacon node, and more.

func (*ProposerServer) ProposeBlock

func (ps *ProposerServer) ProposeBlock(ctx context.Context, blk *ethpb.BeaconBlock) (*pb.ProposeResponse, error)

ProposeBlock is called by a proposer during its assigned slot to create a block in an attempt to get it processed by the beacon node as the canonical head.

func (*ProposerServer) RequestBlock

func (ps *ProposerServer) RequestBlock(ctx context.Context, req *pb.BlockRequest) (*ethpb.BeaconBlock, error)

RequestBlock is called by a proposer during its assigned slot to request a block to sign by passing in the slot and the signed randao reveal of the slot.

type Service

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

Service defining an RPC server for a beacon node.

func NewService

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

NewService instantiates a new RPC service instance that will be registered into a running beacon node.

func (*Service) Start

func (s *Service) Start()

Start the gRPC server.

func (*Service) Status

func (s *Service) Status() error

Status returns nil or credentialError

func (*Service) Stop

func (s *Service) Stop() error

Stop the service.

type ValidatorServer

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

ValidatorServer defines a server implementation of the gRPC Validator service, providing RPC endpoints for obtaining validator assignments per epoch, the slots and shards in which particular validators need to perform their responsibilities, and more.

func (*ValidatorServer) CanonicalHead

func (vs *ValidatorServer) CanonicalHead(ctx context.Context, req *ptypes.Empty) (*ethpb.BeaconBlock, error)

CanonicalHead of the current beacon chain. This method is requested on-demand by a validator when it is their time to propose or attest.

func (*ValidatorServer) CommitteeAssignment

func (vs *ValidatorServer) CommitteeAssignment(ctx context.Context, req *pb.AssignmentRequest) (*pb.AssignmentResponse, error)

CommitteeAssignment returns the committee assignment response from a given validator public key. The committee assignment response contains the following fields for the current and previous epoch:

1.) The list of validators in the committee.
2.) The shard to which the committee is assigned.
3.) The slot at which the committee is assigned.
4.) The bool signaling if the validator is expected to propose a block at the assigned slot.

func (*ValidatorServer) DomainData

func (vs *ValidatorServer) DomainData(ctx context.Context, request *pb.DomainRequest) (*pb.DomainResponse, error)

DomainData fetches the current domain version information from the beacon state.

func (*ValidatorServer) ExitedValidators

ExitedValidators queries validator statuses for a give list of validators and returns a filtered list of validator keys that are exited.

func (*ValidatorServer) ValidatorIndex

ValidatorIndex is called by a validator to get its index location in the beacon state.

func (*ValidatorServer) ValidatorPerformance

ValidatorPerformance reports the validator's latest balance along with other important metrics on rewards and penalties throughout its lifecycle in the beacon chain.

func (*ValidatorServer) ValidatorStatus

ValidatorStatus returns the validator status of the current epoch. The status response can be one of the following:

PENDING_ACTIVE - validator is waiting to get activated.
ACTIVE - validator is active.
INITIATED_EXIT - validator has initiated an an exit request.
WITHDRAWABLE - validator's deposit can be withdrawn after lock up period.
EXITED - validator has exited, means the deposit has been withdrawn.
EXITED_SLASHED - validator was forcefully exited due to slashing.

func (*ValidatorServer) WaitForActivation

WaitForActivation checks if a validator public key exists in the active validator registry of the current beacon state, if not, then it creates a stream which listens for canonical states which contain the validator with the public key as an active validator record.

func (*ValidatorServer) WaitForChainStart

func (vs *ValidatorServer) WaitForChainStart(req *ptypes.Empty, stream pb.ValidatorService_WaitForChainStartServer) error

WaitForChainStart queries the logs of the Deposit Contract in order to verify the beacon chain has started its runtime and validators begin their responsibilities. If it has not, it then subscribes to an event stream triggered by the powchain service whenever the ChainStart log does occur in the Deposit Contract on ETH 1.0.

Directories

Path Synopsis
Package internal is a generated GoMock package.
Package internal is a generated GoMock package.

Jump to

Keyboard shortcuts

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