beacon

package
v4.0.0-...-ae7b6de Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2023 License: GPL-3.0 Imports: 62 Imported by: 0

Documentation

Overview

Package beacon defines a gRPC beacon service implementation, following the official API standards https://ethereum.github.io/beacon-apis/#/. This package includes the beacon and config endpoints.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BLSToExecutionChangesPoolResponse

type BLSToExecutionChangesPoolResponse struct {
	Data []*shared.SignedBLSToExecutionChange `json:"data"`
}

type BlockRootResponse

type BlockRootResponse struct {
	Data *struct {
		Root string `json:"root"`
	} `json:"data"`
	ExecutionOptimistic bool `json:"execution_optimistic"`
	Finalized           bool `json:"finalized"`
}

type DepositContractResponse

type DepositContractResponse struct {
	Data *struct {
		ChainId string `json:"chain_id"`
		Address string `json:"address"`
	} `json:"data"`
}

type FinalityCheckpoints

type FinalityCheckpoints struct {
	PreviousJustified *shared.Checkpoint `json:"previous_justified"`
	CurrentJustified  *shared.Checkpoint `json:"current_justified"`
	Finalized         *shared.Checkpoint `json:"finalized"`
}

type Genesis

type Genesis struct {
	GenesisTime           string `json:"genesis_time"`
	GenesisValidatorsRoot string `json:"genesis_validators_root"`
	GenesisForkVersion    string `json:"genesis_fork_version"`
}

type GetBlockAttestationsResponse

type GetBlockAttestationsResponse struct {
	ExecutionOptimistic bool                  `json:"execution_optimistic"`
	Finalized           bool                  `json:"finalized"`
	Data                []*shared.Attestation `json:"data"`
}

type GetBlockHeaderResponse

type GetBlockHeaderResponse struct {
	ExecutionOptimistic bool                                     `json:"execution_optimistic"`
	Finalized           bool                                     `json:"finalized"`
	Data                *shared.SignedBeaconBlockHeaderContainer `json:"data"`
}

type GetBlockHeadersResponse

type GetBlockHeadersResponse struct {
	Data                []*shared.SignedBeaconBlockHeaderContainer `json:"data"`
	ExecutionOptimistic bool                                       `json:"execution_optimistic"`
	Finalized           bool                                       `json:"finalized"`
}

type GetBlockResponse

type GetBlockResponse struct {
	Data *SignedBlock `json:"data"`
}

type GetBlockV2Response

type GetBlockV2Response struct {
	Version             string       `json:"version"`
	ExecutionOptimistic bool         `json:"execution_optimistic"`
	Finalized           bool         `json:"finalized"`
	Data                *SignedBlock `json:"data"`
}

type GetCommitteesResponse

type GetCommitteesResponse struct {
	Data                []*shared.Committee `json:"data"`
	ExecutionOptimistic bool                `json:"execution_optimistic"`
	Finalized           bool                `json:"finalized"`
}

type GetFinalityCheckpointsResponse

type GetFinalityCheckpointsResponse struct {
	ExecutionOptimistic bool                 `json:"execution_optimistic"`
	Finalized           bool                 `json:"finalized"`
	Data                *FinalityCheckpoints `json:"data"`
}

type GetGenesisResponse

type GetGenesisResponse struct {
	Data *Genesis `json:"data"`
}

type GetRandaoResponse

type GetRandaoResponse struct {
	ExecutionOptimistic bool    `json:"execution_optimistic"`
	Finalized           bool    `json:"finalized"`
	Data                *Randao `json:"data"`
}

type GetStateForkResponse

type GetStateForkResponse struct {
	Data                *shared.Fork `json:"data"`
	ExecutionOptimistic bool         `json:"execution_optimistic"`
	Finalized           bool         `json:"finalized"`
}

type GetStateRootResponse

type GetStateRootResponse struct {
	ExecutionOptimistic bool       `json:"execution_optimistic"`
	Finalized           bool       `json:"finalized"`
	Data                *StateRoot `json:"data"`
}

type GetSyncCommitteeResponse

type GetSyncCommitteeResponse struct {
	ExecutionOptimistic bool                     `json:"execution_optimistic"`
	Finalized           bool                     `json:"finalized"`
	Data                *SyncCommitteeValidators `json:"data"`
}

type GetValidatorBalancesResponse

type GetValidatorBalancesResponse struct {
	ExecutionOptimistic bool                `json:"execution_optimistic"`
	Finalized           bool                `json:"finalized"`
	Data                []*ValidatorBalance `json:"data"`
}

type GetValidatorResponse

type GetValidatorResponse struct {
	ExecutionOptimistic bool                `json:"execution_optimistic"`
	Finalized           bool                `json:"finalized"`
	Data                *ValidatorContainer `json:"data"`
}

type GetValidatorsResponse

type GetValidatorsResponse struct {
	ExecutionOptimistic bool                  `json:"execution_optimistic"`
	Finalized           bool                  `json:"finalized"`
	Data                []*ValidatorContainer `json:"data"`
}

type ListAttestationsResponse

type ListAttestationsResponse struct {
	Data []*shared.Attestation `json:"data"`
}

type ListVoluntaryExitsResponse

type ListVoluntaryExitsResponse struct {
	Data []*shared.SignedVoluntaryExit `json:"data"`
}

type Randao

type Randao struct {
	Randao string `json:"randao"`
}

type Server

type Server struct {
	BeaconDB                      db.ReadOnlyDatabase
	ChainInfoFetcher              blockchain.ChainInfoFetcher
	GenesisTimeFetcher            blockchain.TimeFetcher
	BlockReceiver                 blockchain.BlockReceiver
	BlockNotifier                 blockfeed.Notifier
	OperationNotifier             operation.Notifier
	Broadcaster                   p2p.Broadcaster
	AttestationsPool              attestations.Pool
	SlashingsPool                 slashings.PoolManager
	VoluntaryExitsPool            voluntaryexits.PoolManager
	StateGenService               stategen.StateManager
	Stater                        lookup.Stater
	Blocker                       lookup.Blocker
	HeadFetcher                   blockchain.HeadFetcher
	TimeFetcher                   blockchain.TimeFetcher
	OptimisticModeFetcher         blockchain.OptimisticModeFetcher
	V1Alpha1ValidatorServer       eth.BeaconNodeValidatorServer
	SyncChecker                   sync.Checker
	CanonicalHistory              *stategen.CanonicalHistory
	ExecutionPayloadReconstructor execution.PayloadReconstructor
	FinalizationFetcher           blockchain.FinalizationFetcher
	BLSChangesPool                blstoexec.PoolManager
	ForkchoiceFetcher             blockchain.ForkchoiceFetcher
	CoreService                   *core.Service
}

Server defines a server implementation of the gRPC Beacon Chain service, providing RPC endpoints to access data relevant to the Ethereum Beacon Chain.

func (*Server) GetBlindedBlock

func (s *Server) GetBlindedBlock(w http.ResponseWriter, r *http.Request)

GetBlindedBlock retrieves blinded block for given block id.

func (*Server) GetBlock

func (s *Server) GetBlock(w http.ResponseWriter, r *http.Request)

GetBlock retrieves block details for given block ID.

DEPRECATED: please use GetBlockV2 instead

func (*Server) GetBlockAttestations

func (s *Server) GetBlockAttestations(w http.ResponseWriter, r *http.Request)

GetBlockAttestations retrieves attestation included in requested block.

func (*Server) GetBlockHeader

func (s *Server) GetBlockHeader(w http.ResponseWriter, r *http.Request)

GetBlockHeader retrieves block header for given block id.

func (*Server) GetBlockHeaders

func (s *Server) GetBlockHeaders(w http.ResponseWriter, r *http.Request)

GetBlockHeaders retrieves block headers matching given query. By default it will fetch current head slot blocks.

func (*Server) GetBlockRoot

func (s *Server) GetBlockRoot(w http.ResponseWriter, r *http.Request)

GetBlockRoot retrieves the root of a block.

func (*Server) GetBlockV2

func (s *Server) GetBlockV2(w http.ResponseWriter, r *http.Request)

GetBlockV2 retrieves block details for given block ID.

func (*Server) GetCommittees

func (s *Server) GetCommittees(w http.ResponseWriter, r *http.Request)

GetCommittees retrieves the committees for the given state at the given epoch. If the requested slot and index are defined, only those committees are returned.

func (*Server) GetDepositContract

func (*Server) GetDepositContract(w http.ResponseWriter, r *http.Request)

GetDepositContract retrieves deposit contract address and genesis fork version.

func (*Server) GetFinalityCheckpoints

func (s *Server) GetFinalityCheckpoints(w http.ResponseWriter, r *http.Request)

GetFinalityCheckpoints returns finality checkpoints for state with given 'stateId'. In case finality is not yet achieved, checkpoint should return epoch 0 and ZERO_HASH as root.

func (*Server) GetForkSchedule

func (_ *Server) GetForkSchedule(ctx context.Context, _ *emptypb.Empty) (*ethpb.ForkScheduleResponse, error)

GetForkSchedule retrieve all scheduled upcoming forks this node is aware of.

func (*Server) GetGenesis

func (s *Server) GetGenesis(w http.ResponseWriter, r *http.Request)

GetGenesis retrieves details of the chain's genesis which can be used to identify chain.

func (*Server) GetRandao

func (s *Server) GetRandao(w http.ResponseWriter, r *http.Request)

GetRandao fetches the RANDAO mix for the requested epoch from the state identified by state_id. If an epoch is not specified then the RANDAO mix for the state's current epoch will be returned. By adjusting the state_id parameter you can query for any historic value of the RANDAO mix. Ordinarily states from the same epoch will mutate the RANDAO mix for that epoch as blocks are applied.

func (*Server) GetSpec

func (_ *Server) GetSpec(ctx context.Context, _ *emptypb.Empty) (*ethpb.SpecResponse, error)

GetSpec retrieves specification configuration (without Phase 1 params) used on this node. Specification params list Values are returned with following format: - any value starting with 0x in the spec is returned as a hex string. - all other values are returned as number.

func (*Server) GetStateFork

func (s *Server) GetStateFork(w http.ResponseWriter, r *http.Request)

GetStateFork returns Fork object for state with given 'stateId'.

func (*Server) GetStateRoot

func (s *Server) GetStateRoot(w http.ResponseWriter, r *http.Request)

GetStateRoot calculates HashTreeRoot for state with given 'stateId'. If stateId is root, same value will be returned.

func (*Server) GetSyncCommittees

func (s *Server) GetSyncCommittees(w http.ResponseWriter, r *http.Request)

GetSyncCommittees retrieves the sync committees for the given epoch. If the epoch is not passed in, then the sync committees for the epoch of the state will be obtained.

func (*Server) GetValidator

func (s *Server) GetValidator(w http.ResponseWriter, r *http.Request)

GetValidator returns a validator specified by state and id or public key along with status and balance.

func (*Server) GetValidatorBalances

func (bs *Server) GetValidatorBalances(w http.ResponseWriter, r *http.Request)

GetValidatorBalances returns a filterable list of validator balances.

func (*Server) GetValidators

func (s *Server) GetValidators(w http.ResponseWriter, r *http.Request)

GetValidators returns filterable list of validators with their balance, status and index.

func (*Server) GetWeakSubjectivity

func (bs *Server) GetWeakSubjectivity(ctx context.Context, _ *empty.Empty) (*ethpbv1.WeakSubjectivityResponse, error)

GetWeakSubjectivity computes the starting epoch of the current weak subjectivity period, and then also determines the best block root and state root to use for a Checkpoint Sync starting from that point. DEPRECATED: GetWeakSubjectivity endpoint will no longer be supported

func (*Server) ListAttestations

func (s *Server) ListAttestations(w http.ResponseWriter, r *http.Request)

ListAttestations retrieves attestations known by the node but not necessarily incorporated into any block. Allows filtering by committee index or slot.

func (*Server) ListBLSToExecutionChanges

func (s *Server) ListBLSToExecutionChanges(w http.ResponseWriter, r *http.Request)

ListBLSToExecutionChanges retrieves BLS to execution changes known by the node but not necessarily incorporated into any block

func (*Server) ListPoolAttesterSlashings

func (bs *Server) ListPoolAttesterSlashings(ctx context.Context, _ *emptypb.Empty) (*ethpbv1.AttesterSlashingsPoolResponse, error)

ListPoolAttesterSlashings retrieves attester slashings known by the node but not necessarily incorporated into any block.

func (*Server) ListPoolProposerSlashings

func (bs *Server) ListPoolProposerSlashings(ctx context.Context, _ *emptypb.Empty) (*ethpbv1.ProposerSlashingPoolResponse, error)

ListPoolProposerSlashings retrieves proposer slashings known by the node but not necessarily incorporated into any block.

func (*Server) ListVoluntaryExits

func (s *Server) ListVoluntaryExits(w http.ResponseWriter, r *http.Request)

ListVoluntaryExits retrieves voluntary exits known by the node but not necessarily incorporated into any block.

func (*Server) PublishBlindedBlock

func (s *Server) PublishBlindedBlock(w http.ResponseWriter, r *http.Request)

PublishBlindedBlock instructs the beacon node to use the components of the `SignedBlindedBeaconBlock` to construct and publish a SignedBeaconBlock by swapping out the transactions_root for the corresponding full list of `transactions`. The beacon node should broadcast a newly constructed SignedBeaconBlock to the beacon network, to be included in the beacon chain. The beacon node is not required to validate the signed BeaconBlock, and a successful response (20X) only indicates that the broadcast has been successful. The beacon node is expected to integrate the new block into its state, and therefore validate the block internally, however blocks which fail the validation are still broadcast but a different status code is returned (202). Pre-Bellatrix, this endpoint will accept a SignedBeaconBlock. After Deneb, this additionally instructs the beacon node to broadcast all given signed blobs.

func (*Server) PublishBlindedBlockV2

func (s *Server) PublishBlindedBlockV2(w http.ResponseWriter, r *http.Request)

PublishBlindedBlockV2 instructs the beacon node to use the components of the `SignedBlindedBeaconBlock` to construct and publish a `SignedBeaconBlock` by swapping out the `transactions_root` for the corresponding full list of `transactions`. The beacon node should broadcast a newly constructed `SignedBeaconBlock` to the beacon network, to be included in the beacon chain. The beacon node is not required to validate the signed `BeaconBlock`, and a successful response (20X) only indicates that the broadcast has been successful. The beacon node is expected to integrate the new block into its state, and therefore validate the block internally, however blocks which fail the validation are still broadcast but a different status code is returned (202). Pre-Bellatrix, this endpoint will accept a `SignedBeaconBlock`. After Deneb, this additionally instructs the beacon node to broadcast all given signed blobs. The broadcast behaviour may be adjusted via the `broadcast_validation` query parameter.

func (*Server) PublishBlock

func (s *Server) PublishBlock(w http.ResponseWriter, r *http.Request)

PublishBlock instructs the beacon node to broadcast a newly signed beacon block to the beacon network, to be included in the beacon chain. A success response (20x) indicates that the block passed gossip validation and was successfully broadcast onto the network. The beacon node is also expected to integrate the block into state, but may broadcast it before doing so, so as to aid timely delivery of the block. Should the block fail full validation, a separate success response code (202) is used to indicate that the block was successfully broadcast but failed integration. After Deneb, this additionally instructs the beacon node to broadcast all given signed blobs.

func (*Server) PublishBlockV2

func (s *Server) PublishBlockV2(w http.ResponseWriter, r *http.Request)

PublishBlockV2 instructs the beacon node to broadcast a newly signed beacon block to the beacon network, to be included in the beacon chain. A success response (20x) indicates that the block passed gossip validation and was successfully broadcast onto the network. The beacon node is also expected to integrate the block into the state, but may broadcast it before doing so, so as to aid timely delivery of the block. Should the block fail full validation, a separate success response code (202) is used to indicate that the block was successfully broadcast but failed integration. After Deneb, this additionally instructs the beacon node to broadcast all given signed blobs. The broadcast behaviour may be adjusted via the `broadcast_validation` query parameter.

func (*Server) SubmitAttestations

func (s *Server) SubmitAttestations(w http.ResponseWriter, r *http.Request)

SubmitAttestations submits an attestation object to node. If the attestation passes all validation constraints, node MUST publish the attestation on an appropriate subnet.

func (*Server) SubmitAttesterSlashing

func (bs *Server) SubmitAttesterSlashing(ctx context.Context, req *ethpbv1.AttesterSlashing) (*emptypb.Empty, error)

SubmitAttesterSlashing submits AttesterSlashing object to node's pool and if passes validation node MUST broadcast it to network.

func (*Server) SubmitBLSToExecutionChanges

func (s *Server) SubmitBLSToExecutionChanges(w http.ResponseWriter, r *http.Request)

SubmitBLSToExecutionChanges submits said object to the node's pool if it passes validation the node must broadcast it to the network.

func (*Server) SubmitProposerSlashing

func (bs *Server) SubmitProposerSlashing(ctx context.Context, req *ethpbv1.ProposerSlashing) (*emptypb.Empty, error)

SubmitProposerSlashing submits AttesterSlashing object to node's pool and if passes validation node MUST broadcast it to network.

func (*Server) SubmitSyncCommitteeSignatures

func (s *Server) SubmitSyncCommitteeSignatures(w http.ResponseWriter, r *http.Request)

SubmitSyncCommitteeSignatures submits sync committee signature objects to the node.

func (*Server) SubmitVoluntaryExit

func (s *Server) SubmitVoluntaryExit(w http.ResponseWriter, r *http.Request)

SubmitVoluntaryExit submits a SignedVoluntaryExit object to node's pool and if passes validation node MUST broadcast it to network.

type SignedBlock

type SignedBlock struct {
	Message   json.RawMessage `json:"message"` // represents the block values based on the version
	Signature string          `json:"signature"`
}

type StateRoot

type StateRoot struct {
	Root string `json:"root"`
}

type SubmitAttestationsRequest

type SubmitAttestationsRequest struct {
	Data []*shared.Attestation `json:"data"`
}

type SubmitSyncCommitteeSignaturesRequest

type SubmitSyncCommitteeSignaturesRequest struct {
	Data []*shared.SyncCommitteeMessage `json:"data"`
}

type SyncCommitteeValidators

type SyncCommitteeValidators struct {
	Validators          []string   `json:"validators"`
	ValidatorAggregates [][]string `json:"validator_aggregates"`
}

type Validator

type Validator struct {
	Pubkey                     string `json:"pubkey"`
	WithdrawalCredentials      string `json:"withdrawal_credentials"`
	EffectiveBalance           string `json:"effective_balance"`
	Slashed                    bool   `json:"slashed"`
	ActivationEligibilityEpoch string `json:"activation_eligibility_epoch"`
	ActivationEpoch            string `json:"activation_epoch"`
	ExitEpoch                  string `json:"exit_epoch"`
	WithdrawableEpoch          string `json:"withdrawable_epoch"`
}

type ValidatorBalance

type ValidatorBalance struct {
	Index   string `json:"index"`
	Balance string `json:"balance"`
}

type ValidatorContainer

type ValidatorContainer struct {
	Index     string     `json:"index"`
	Balance   string     `json:"balance"`
	Status    string     `json:"status"`
	Validator *Validator `json:"validator"`
}

Jump to

Keyboard shortcuts

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