beacon

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 21, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConnectToBeaconNode

func ConnectToBeaconNode(ctx context.Context, address string, timeout time.Duration, allowInsecure bool) (eth2client.Service, error)

ConnectToBeaconNode connects to a beacon node at the given address.

Types

type BeaconBlock

type BeaconBlock struct {
	Version string `json:"version"`
	Data    struct {
		Message struct {
			Slot          string `json:"slot"`
			ProposerIndex string `json:"proposer_index"`
			ParentRoot    string `json:"parent_root"`
			StateRoot     string `json:"state_root"`
			Body          struct {
				RandaoReveal string `json:"randao_reveal"`
				Eth1Data     struct {
					DepositRoot  string `json:"deposit_root"`
					DepositCount string `json:"deposit_count"`
					BlockHash    string `json:"block_hash"`
				} `json:"eth1_data"`
				Graffiti          string        `json:"graffiti"`
				ProposerSlashings []interface{} `json:"proposer_slashings"`
				AttesterSlashings []interface{} `json:"attester_slashings"`
				Attestations      []struct {
					AggregationBits string `json:"aggregation_bits"`
					Data            struct {
						Slot            string `json:"slot"`
						Index           string `json:"index"`
						BeaconBlockRoot string `json:"beacon_block_root"`
						Source          struct {
							Epoch string `json:"epoch"`
							Root  string `json:"root"`
						} `json:"source"`
						Target struct {
							Epoch string `json:"epoch"`
							Root  string `json:"root"`
						} `json:"target"`
					} `json:"data"`
					Signature string `json:"signature"`
				} `json:"attestations"`
				Deposits       []interface{} `json:"deposits"`
				VoluntaryExits []interface{} `json:"voluntary_exits"`
				SyncAggregate  struct {
				} `json:"sync_aggregate"`
				ExecutionPayload *ExecutionPayload `json:"execution_payload"`
			} `json:"body"`
		} `json:"message"`
		Signature string `json:"signature"`
	} `json:"data"`
	ExecutionOptimistic bool `json:"execution_optimistic"`
	Finalized           bool `json:"finalized"`
}

type BeaconBlocksProvider

type BeaconBlocksProvider interface {
	// BeaconBlock provides the block header of a given block ID.
	BeaconBlock(ctx context.Context, blockID string) (*BeaconBlock, bool, error)

	ExecutionPayload(ctx context.Context, blockID string) (*ExecutionPayload, error)

	ExecutionBlock(ctx context.Context, blockID string) (*ExecutionBlock, error)

	HeadSlot(ctx context.Context) (*big.Int, error)
}

BeaconBlocksProvider is the interface for providing beacon blocks.

type BeaconProvider

type BeaconProvider interface {
	consensusClient.Service

	// Timeout returns the timeout of the client.
	Timeout() time.Duration
}

func New

func New(ctx context.Context, addr string, timeout time.Duration) (BeaconProvider, error)

type BeaconService

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

BeaconService is the service for providing consensus layer.

func (*BeaconService) Address

func (b *BeaconService) Address() string

Address provides the address for the connection.

func (*BeaconService) BeaconBlock

func (b *BeaconService) BeaconBlock(ctx context.Context, blockID string) (*BeaconBlock, bool, error)

func (*BeaconService) ExecutionBlock

func (b *BeaconService) ExecutionBlock(ctx context.Context, blockID string) (*ExecutionBlock, error)

func (*BeaconService) ExecutionPayload

func (b *BeaconService) ExecutionPayload(ctx context.Context, blockID string) (*ExecutionPayload, error)

func (*BeaconService) HeadSlot

func (b *BeaconService) HeadSlot(ctx context.Context) (*big.Int, error)

func (*BeaconService) Name

func (b *BeaconService) Name() string

Name provides the name of the service.

func (*BeaconService) Timeout

func (b *BeaconService) Timeout() time.Duration

Timeout provides the timeout for the connection.

func (*BeaconService) ValidatorsByPubKey

func (b *BeaconService) ValidatorsByPubKey(ctx context.Context, stateID string, validatorPubKeys []string) (map[string]*consensusApi.Validator, error)

type ExecutionBlock

type ExecutionBlock struct {
	ParentHash    string   `json:"parent_hash"`
	FeeRecipient  string   `json:"fee_recipient"`
	BlockNumber   *big.Int `json:"block_number"`
	GasLimit      *big.Int `json:"gas_limit"`
	GasUsed       *big.Int `json:"gas_used"`
	Timestamp     string   `json:"timestamp"`
	BaseFeePerGas *big.Int `json:"base_fee_per_gas"`
	BlockHash     string   `json:"block_hash"`
}

type ExecutionInfoProvider

type ExecutionInfoProvider interface {
	// ExecutionPayload provides the block's Execution info of a given block ID.
	ExecutionPayload(ctx context.Context, blockID string) (*ExecutionPayload, error)
}

ExecutionInfoProvider is the interface for get ExecutionPayload.

type ExecutionPayload

type ExecutionPayload struct {
	ParentHash    string        `json:"parent_hash"`
	FeeRecipient  string        `json:"fee_recipient"`
	StateRoot     string        `json:"state_root"`
	ReceiptsRoot  string        `json:"receipts_root"`
	LogsBloom     string        `json:"logs_bloom"`
	PrevRandao    string        `json:"prev_randao"`
	BlockNumber   string        `json:"block_number"`
	GasLimit      string        `json:"gas_limit"`
	GasUsed       string        `json:"gas_used"`
	Timestamp     string        `json:"timestamp"`
	ExtraData     string        `json:"extra_data"`
	BaseFeePerGas string        `json:"base_fee_per_gas"`
	BlockHash     string        `json:"block_hash"`
	Transactions  []interface{} `json:"transactions"`
}

type ValidatorsProvider

type ValidatorsProvider interface {
	ValidatorsByPubKey(ctx context.Context, stateID string, validatorPubKeys []string) (map[string]*consensusApi.Validator, error)
}

Jump to

Keyboard shortcuts

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