Documentation
¶
Overview ¶
Package beacon provides a client for interacting with the standard Eth Beacon Node API. Interactive swagger documentation for the API is available here: https://ethereum.github.io/beacon-APIs/
Index ¶
- Constants
- func RenderGetBlockPath(id StateOrBlockId) string
- func RenderGetStatePath(id StateOrBlockId) string
- type Client
- func (c *Client) GetBLStoExecutionChanges(ctx context.Context) (*structs.BLSToExecutionChangesPoolResponse, error)
- func (c *Client) GetBlock(ctx context.Context, blockId StateOrBlockId) ([]byte, error)
- func (c *Client) GetBlockRoot(ctx context.Context, blockId StateOrBlockId) ([32]byte, error)
- func (c *Client) GetConfigSpec(ctx context.Context) (*structs.GetSpecResponse, error)
- func (c *Client) GetFork(ctx context.Context, stateId StateOrBlockId) (*ethpb.Fork, error)
- func (c *Client) GetForkSchedule(ctx context.Context) (forks.OrderedSchedule, error)
- func (c *Client) GetNodeVersion(ctx context.Context) (*NodeVersion, error)
- func (c *Client) GetState(ctx context.Context, stateId StateOrBlockId) ([]byte, error)
- func (c *Client) GetWeakSubjectivity(ctx context.Context) (*WeakSubjectivityData, error)
- func (c *Client) SubmitChangeBLStoExecution(ctx context.Context, request []*structs.SignedBLSToExecutionChange) error
- type NodeHealthTracker
- type NodeVersion
- type StateOrBlockId
- type WeakSubjectivityData
Constants ¶
const ( GetNodeVersionPath = "/eth/v1/node/version" GetWeakSubjectivityPath = "/prysm/v1/beacon/weak_subjectivity" )
Variables ¶
This section is empty.
Functions ¶
func RenderGetBlockPath ¶ added in v5.3.0
func RenderGetBlockPath(id StateOrBlockId) string
RenderGetBlockPath formats a block id into a path for the GetBlock API endpoint.
func RenderGetStatePath ¶ added in v5.3.0
func RenderGetStatePath(id StateOrBlockId) string
RenderGetStatePath formats a state id into a path for the GetState API endpoint.
Types ¶
type Client ¶
Client provides a collection of helper methods for calling the Eth Beacon Node API endpoints.
func NewClient ¶
NewClient returns a new Client that includes functions for rest calls to Beacon API.
func (*Client) GetBLStoExecutionChanges ¶
func (c *Client) GetBLStoExecutionChanges(ctx context.Context) (*structs.BLSToExecutionChangesPoolResponse, error)
GetBLStoExecutionChanges gets all the set withdrawal messages in the node's operation pool. Returns a struct representation of json response.
func (*Client) GetBlock ¶
GetBlock retrieves the SignedBeaconBlock for the given block id. Block identifier can be one of: "head" (canonical head in node's view), "genesis", "finalized", <slot>, <hex encoded blockRoot with 0x prefix>. Variables of type StateOrBlockId are exported by this package for the named identifiers. The return value contains the ssz-encoded bytes.
func (*Client) GetBlockRoot ¶
GetBlockRoot retrieves the hash_tree_root of the BeaconBlock for the given block id. Block identifier can be one of: "head" (canonical head in node's view), "genesis", "finalized", <slot>, <hex encoded blockRoot with 0x prefix>. Variables of type StateOrBlockId are exported by this package for the named identifiers.
func (*Client) GetConfigSpec ¶
GetConfigSpec retrieve the current configs of the network used by the beacon node.
func (*Client) GetFork ¶
GetFork queries the Beacon Node API for the Fork from the state identified by stateId. Block identifier can be one of: "head" (canonical head in node's view), "genesis", "finalized", <slot>, <hex encoded blockRoot with 0x prefix>. Variables of type StateOrBlockId are exported by this package for the named identifiers.
func (*Client) GetForkSchedule ¶
GetForkSchedule retrieve all forks, past present and future, of which this node is aware.
func (*Client) GetNodeVersion ¶
func (c *Client) GetNodeVersion(ctx context.Context) (*NodeVersion, error)
GetNodeVersion requests that the beacon node identify information about its implementation in a format similar to a HTTP User-Agent field. ex: Lighthouse/v0.1.5 (Linux x86_64)
func (*Client) GetState ¶
GetState retrieves the BeaconState for the given state id. State identifier can be one of: "head" (canonical head in node's view), "genesis", "finalized", <slot>, <hex encoded stateRoot with 0x prefix>. Variables of type StateOrBlockId are exported by this package for the named identifiers. The return value contains the ssz-encoded bytes.
func (*Client) GetWeakSubjectivity ¶
func (c *Client) GetWeakSubjectivity(ctx context.Context) (*WeakSubjectivityData, error)
GetWeakSubjectivity calls a proposed API endpoint that is unique to prysm This api method does the following: - computes weak subjectivity epoch - finds the highest non-skipped block preceding the epoch - returns the htr of the found block and returns this + the value of state_root from the block
func (*Client) SubmitChangeBLStoExecution ¶
func (c *Client) SubmitChangeBLStoExecution(ctx context.Context, request []*structs.SignedBLSToExecutionChange) error
SubmitChangeBLStoExecution calls a beacon API endpoint to set the withdrawal addresses based on the given signed messages. If the API responds with something other than OK there will be failure messages associated to the corresponding request message.
type NodeHealthTracker ¶ added in v5.0.2
func NewNodeHealthTracker ¶ added in v5.0.2
func NewNodeHealthTracker(node iface.HealthNode) *NodeHealthTracker
func (*NodeHealthTracker) CheckHealth ¶ added in v5.0.2
func (n *NodeHealthTracker) CheckHealth(ctx context.Context) bool
func (*NodeHealthTracker) HealthUpdates ¶ added in v5.0.2
func (n *NodeHealthTracker) HealthUpdates() <-chan bool
HealthUpdates provides a read-only channel for health updates.
func (*NodeHealthTracker) IsHealthy ¶ added in v5.0.2
func (n *NodeHealthTracker) IsHealthy() bool
type NodeVersion ¶
type NodeVersion struct {
// contains filtered or unexported fields
}
func (*NodeVersion) SetImplementation ¶ added in v5.3.0
func (nv *NodeVersion) SetImplementation(impl string)
type StateOrBlockId ¶
type StateOrBlockId string
StateOrBlockId represents the block_id / state_id parameters that several of the Eth Beacon API methods accept. StateOrBlockId constants are defined for named identifiers, and helper methods are provided for slot and root identifiers. Example text from the Eth Beacon Node API documentation:
"Block identifier can be one of: "head" (canonical head in node's view), "genesis", "finalized", <slot>, <hex encoded blockRoot with 0x prefix>."
const ( IdGenesis StateOrBlockId = "genesis" IdHead StateOrBlockId = "head" IdFinalized StateOrBlockId = "finalized" )
func IdFromRoot ¶
func IdFromRoot(r [32]byte) StateOrBlockId
IdFromRoot encodes a block root in the format expected by the API in places where a root can be used to identify a BeaconState or SignedBeaconBlock.
func IdFromSlot ¶
func IdFromSlot(s primitives.Slot) StateOrBlockId
IdFromSlot encodes a Slot in the format expected by the API in places where a slot can be used to identify a BeaconState or SignedBeaconBlock.
type WeakSubjectivityData ¶
type WeakSubjectivityData struct { BlockRoot [32]byte StateRoot [32]byte Epoch primitives.Epoch }
WeakSubjectivityData represents the state root, block root and epoch of the BeaconState + ReadOnlySignedBeaconBlock that falls at the beginning of the current weak subjectivity period. These values can be used to construct a weak subjectivity checkpoint beacon node flag to be used for validation.
func (*WeakSubjectivityData) CheckpointString ¶
func (wsd *WeakSubjectivityData) CheckpointString() string
CheckpointString returns the standard string representation of a Checkpoint. The format is a hex-encoded block root, followed by the epoch of the block, separated by a colon. For example: "0x1c35540cac127315fabb6bf29181f2ae0de1a3fc909d2e76ba771e61312cc49a:74888"