beacon

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: May 17, 2024 License: GPL-3.0 Imports: 9 Imported by: 57

Documentation

Index

Constants

View Source
const (
	ValidatorPubkeyLength int = 48
)
View Source
const (
	ValidatorSignatureLength int = 96
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AttestationInfo

type AttestationInfo struct {
	AggregationBits bitfield.Bitlist
	SlotIndex       uint64
	CommitteeIndex  uint64
}

type BeaconBlock

type BeaconBlock struct {
	Header               BeaconBlockHeader
	HasExecutionPayload  bool
	Attestations         []AttestationInfo
	FeeRecipient         common.Address
	ExecutionBlockNumber uint64
}

type BeaconBlockHeader added in v0.2.0

type BeaconBlockHeader struct {
	Slot          uint64
	ProposerIndex string
}

type BeaconHead

type BeaconHead struct {
	Epoch                  uint64
	FinalizedEpoch         uint64
	JustifiedEpoch         uint64
	PreviousJustifiedEpoch uint64
}

type ByteArray

type ByteArray []byte

Byte array type

func (ByteArray) MarshalJSON

func (b ByteArray) MarshalJSON() ([]byte, error)

func (*ByteArray) UnmarshalJSON

func (b *ByteArray) UnmarshalJSON(data []byte) error

type Committees added in v0.2.0

type Committees interface {
	// Index returns the index of the committee at the provided offset
	Index(int) uint64

	// Slot returns the slot of the committee at the provided offset
	Slot(int) uint64

	// Validators returns the list of validators of the committee at
	// the provided offset
	Validators(int) []string

	// Count returns the number of committees in the response
	Count() int

	// Release returns the reused validators slice buffer to the pool for
	// further reuse, and must be called when the user is done with this
	// committees instance
	Release()
}

Committees is an interface as an optimization- since committees responses are quite large, there's a decent cpu/memory improvement to removing the translation to an intermediate storage class.

Instead, the interface provides the access pattern that utilities want, and the underlying format is just the format of the Beacon Node response.

type Eth1Data

type Eth1Data struct {
	DepositRoot  common.Hash
	DepositCount uint64
	BlockHash    common.Hash
}

type Eth2Config

type Eth2Config struct {
	GenesisForkVersion           []byte
	GenesisValidatorsRoot        []byte
	GenesisEpoch                 uint64
	GenesisTime                  uint64
	SecondsPerSlot               uint64
	SlotsPerEpoch                uint64
	SecondsPerEpoch              uint64
	EpochsPerSyncCommitteePeriod uint64
}

type Eth2DepositContract

type Eth2DepositContract struct {
	ChainID uint64
	Address common.Address
}

type ExtendedDepositData

type ExtendedDepositData struct {
	PublicKey             ByteArray `json:"pubkey"`
	WithdrawalCredentials ByteArray `json:"withdrawal_credentials"`
	Amount                uint64    `json:"amount"`
	Signature             ByteArray `json:"signature"`
	DepositMessageRoot    ByteArray `json:"deposit_message_root"`
	DepositDataRoot       ByteArray `json:"deposit_data_root"`
	ForkVersion           ByteArray `json:"fork_version"`
	NetworkName           string    `json:"network_name"`
}

Extended deposit data beyond what is required in an actual deposit message to Beacon, emulating what the deposit CLI produces

type IBeaconClient

type IBeaconClient interface {
	GetSyncStatus(ctx context.Context) (SyncStatus, error)
	GetEth2Config(ctx context.Context) (Eth2Config, error)
	GetEth2DepositContract(ctx context.Context) (Eth2DepositContract, error)
	GetAttestations(ctx context.Context, blockId string) ([]AttestationInfo, bool, error)
	GetBeaconBlock(ctx context.Context, blockId string) (BeaconBlock, bool, error)
	GetBeaconBlockHeader(ctx context.Context, blockId string) (BeaconBlockHeader, bool, error)
	GetBeaconHead(ctx context.Context) (BeaconHead, error)
	GetValidatorStatusByIndex(ctx context.Context, index string, opts *ValidatorStatusOptions) (ValidatorStatus, error)
	GetValidatorStatus(ctx context.Context, pubkey ValidatorPubkey, opts *ValidatorStatusOptions) (ValidatorStatus, error)
	GetValidatorStatuses(ctx context.Context, pubkeys []ValidatorPubkey, opts *ValidatorStatusOptions) (map[ValidatorPubkey]ValidatorStatus, error)
	GetValidatorIndex(ctx context.Context, pubkey ValidatorPubkey) (string, error)
	GetValidatorSyncDuties(ctx context.Context, indices []string, epoch uint64) (map[string]bool, error)
	GetValidatorProposerDuties(ctx context.Context, indices []string, epoch uint64) (map[string]uint64, error)
	GetDomainData(ctx context.Context, domainType []byte, epoch uint64, useGenesisFork bool) ([]byte, error)
	ExitValidator(ctx context.Context, validatorIndex string, epoch uint64, signature ValidatorSignature) error
	Close(ctx context.Context) error
	GetEth1DataForEth2Block(ctx context.Context, blockId string) (Eth1Data, bool, error)
	GetCommitteesForEpoch(ctx context.Context, epoch *uint64) (Committees, error)
	ChangeWithdrawalCredentials(ctx context.Context, validatorIndex string, fromBlsPubkey ValidatorPubkey, toExecutionAddress common.Address, signature ValidatorSignature) error
}

Beacon Node interface

type SyncStatus

type SyncStatus struct {
	Syncing  bool
	Progress float64
}

API response types

type ValidatorKeystore

type ValidatorKeystore struct {
	Crypto  map[string]any  `json:"crypto"`
	Name    string          `json:"name,omitempty"` // Technically not part of the spec but Prysm needs it
	Version uint            `json:"version"`
	UUID    uuid.UUID       `json:"uuid"`
	Path    string          `json:"path"`
	Pubkey  ValidatorPubkey `json:"pubkey,omitempty"`
}

Encrypted validator keystore following the EIP-2335 standard (https://eips.ethereum.org/EIPS/eip-2335)

type ValidatorPubkey

type ValidatorPubkey [ValidatorPubkeyLength]byte

A validator's pubkey key

func HexToValidatorPubkey

func HexToValidatorPubkey(value string) (ValidatorPubkey, error)

Converts a hex-encoded validator pubkey (with an optional 0x prefix) to a validator pubkey.

func (ValidatorPubkey) Hex

func (v ValidatorPubkey) Hex() string

Gets the string representation of the pubkey without a 0x prefix.

func (ValidatorPubkey) HexWithPrefix

func (v ValidatorPubkey) HexWithPrefix() string

Gets the string representation of the pubkey with a 0x prefix.

func (ValidatorPubkey) MarshalJSON

func (v ValidatorPubkey) MarshalJSON() ([]byte, error)

Serializes the pubkey to JSON.

func (ValidatorPubkey) MarshalYAML

func (v ValidatorPubkey) MarshalYAML() ([]byte, error)

Serializes the pubkey to YAML.

func (ValidatorPubkey) String

func (v ValidatorPubkey) String() string

Gets the string representation of the pubkey without a 0x prefix.

func (*ValidatorPubkey) UnmarshalJSON

func (v *ValidatorPubkey) UnmarshalJSON(data []byte) error

Deserializes the pubkey from JSON.

func (*ValidatorPubkey) UnmarshalYAML

func (v *ValidatorPubkey) UnmarshalYAML(data []byte) error

Deserializes the pubkey from YAML.

type ValidatorSignature

type ValidatorSignature [ValidatorSignatureLength]byte

A signature produced by a validator's private key.

func HexToValidatorSignature

func HexToValidatorSignature(value string) (ValidatorSignature, error)

Converts a hex-encoded validator signature (with an optional 0x prefix) to a validator signature.

func (ValidatorSignature) Hex

func (v ValidatorSignature) Hex() string

Gets the string representation of the signature without a 0x prefix.

func (ValidatorSignature) HexWithPrefix

func (v ValidatorSignature) HexWithPrefix() string

Gets the string representation of the signature with a 0x prefix.

func (ValidatorSignature) MarshalJSON

func (v ValidatorSignature) MarshalJSON() ([]byte, error)

Serializes the signature to JSON.

func (ValidatorSignature) MarshalYAML

func (v ValidatorSignature) MarshalYAML() ([]byte, error)

Serializes the signature to YAML.

func (ValidatorSignature) String

func (v ValidatorSignature) String() string

Gets the string representation of the signature without a 0x prefix.

func (*ValidatorSignature) UnmarshalJSON

func (v *ValidatorSignature) UnmarshalJSON(data []byte) error

Deserializes the signature from JSON.

func (*ValidatorSignature) UnmarshalYAML

func (v *ValidatorSignature) UnmarshalYAML(data []byte) error

Deserializes the signature from YAML.

type ValidatorState

type ValidatorState string
const (
	ValidatorState_PendingInitialized ValidatorState = "pending_initialized"
	ValidatorState_PendingQueued      ValidatorState = "pending_queued"
	ValidatorState_ActiveOngoing      ValidatorState = "active_ongoing"
	ValidatorState_ActiveExiting      ValidatorState = "active_exiting"
	ValidatorState_ActiveSlashed      ValidatorState = "active_slashed"
	ValidatorState_ExitedUnslashed    ValidatorState = "exited_unslashed"
	ValidatorState_ExitedSlashed      ValidatorState = "exited_slashed"
	ValidatorState_WithdrawalPossible ValidatorState = "withdrawal_possible"
	ValidatorState_WithdrawalDone     ValidatorState = "withdrawal_done"
)

type ValidatorStatus

type ValidatorStatus struct {
	Pubkey                     ValidatorPubkey
	Index                      string
	WithdrawalCredentials      common.Hash
	Balance                    uint64
	Status                     ValidatorState
	EffectiveBalance           uint64
	Slashed                    bool
	ActivationEligibilityEpoch uint64
	ActivationEpoch            uint64
	ExitEpoch                  uint64
	WithdrawableEpoch          uint64
	Exists                     bool
}

type ValidatorStatusOptions

type ValidatorStatusOptions struct {
	Epoch *uint64
	Slot  *uint64
}

API request options

Directories

Path Synopsis
Code generated by fastssz.
Code generated by fastssz.

Jump to

Keyboard shortcuts

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