beacon

package
v0.1.0-rc3 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2023 License: GPL-3.0 Imports: 17 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.

func ValidatorIsFullExited added in v0.1.0

func ValidatorIsFullExited(validator *consensusApi.Validator) bool

ValidatorIsFullExited Whether the validator has completed the lifecycle of the exit

func ValidatorIsRequestExiting added in v0.1.0

func ValidatorIsRequestExiting(validator *consensusApi.Validator) bool

ValidatorIsRequestExiting Whether the validator request the exit

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, error)
}

BeaconBlocksProvider is the interface for providing beacon blocks.

type BeaconError

type BeaconError struct {
	Message string `json:"message"`
	Code    int    `json:"code"`
}

type BeaconService

type BeaconService struct {
	BaseUrl string
	Timeout time.Duration
}

func New

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

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) ValidatorSlashedAmount added in v0.1.0

func (b *BeaconService) ValidatorSlashedAmount(ctx context.Context, validator *consensusApi.Validator) (*big.Int, error)

ValidatorSlashedAmount 32ETh - ValidatorWithdrawAbleBalance

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