beacon

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2021 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FetchValidatorsMetadata added in v0.0.20

func FetchValidatorsMetadata(bc Beacon, pubKeys [][]byte) (map[string]*ValidatorMetadata, error)

FetchValidatorsMetadata is fetching validators data from beacon

func UpdateValidatorsMetadata added in v0.0.20

func UpdateValidatorsMetadata(pubKeys [][]byte, collection ValidatorMetadataStorage, bc Beacon, onUpdated OnUpdated) error

UpdateValidatorsMetadata updates validator information for the given public keys

func UpdateValidatorsMetadataBatch added in v0.1.2

func UpdateValidatorsMetadataBatch(pubKeys [][]byte,
	queue tasks.Queue,
	collection ValidatorMetadataStorage,
	bc Beacon,
	onUpdated OnUpdated,
	batchSize int)

UpdateValidatorsMetadataBatch updates the given public keys in batches

Types

type Beacon

type Beacon interface {
	KeyManager
	SigningUtil

	// ExtendIndexMap extanding the pubkeys map of the client (in order to prevent redundant call to fetch pubkeys from node)
	ExtendIndexMap(index spec.ValidatorIndex, pubKey spec.BLSPubKey)

	// GetDuties returns duties for the passed validators indices
	GetDuties(epoch spec.Epoch, validatorIndices []spec.ValidatorIndex) ([]*Duty, error)

	// GetValidatorData returns metadata (balance, index, status, more) for each pubkey from the node
	GetValidatorData(validatorPubKeys []spec.BLSPubKey) (map[spec.ValidatorIndex]*api.Validator, error)

	// GetAttestationData returns attestation data by the given slot and committee index
	GetAttestationData(slot spec.Slot, committeeIndex spec.CommitteeIndex) (*spec.AttestationData, error)

	// SubmitAttestation submit the attestation to the node
	SubmitAttestation(attestation *spec.Attestation) error

	// SubscribeToCommitteeSubnet subscribe committee to subnet (p2p topic)
	SubscribeToCommitteeSubnet(subscription []*api.BeaconCommitteeSubscription) error
}

Beacon represents the behavior of the beacon node connector

func NewMockBeacon added in v0.0.20

func NewMockBeacon(dutiesResults map[uint64][]*Duty, validatorsData map[spec.BLSPubKey]*v1.Validator) Beacon

NewMockBeacon creates a new mock implementation of beacon client

type Duty added in v0.0.7

type Duty struct {
	// Type is the duty type (attest, propose)
	Type RoleType
	// PubKey is the public key of the validator that should attest.
	PubKey spec.BLSPubKey
	// Slot is the slot in which the validator should attest.
	Slot spec.Slot
	// ValidatorIndex is the index of the validator that should attest.
	ValidatorIndex spec.ValidatorIndex
	// CommitteeIndex is the index of the committee in which the attesting validator has been placed.
	CommitteeIndex spec.CommitteeIndex
	// CommitteeLength is the length of the committee in which the attesting validator has been placed.
	CommitteeLength uint64
	// CommitteesAtSlot is the number of committees in the slot.
	CommitteesAtSlot uint64
	// ValidatorCommitteeIndex is the index of the validator in the list of validators in the committee.
	ValidatorCommitteeIndex uint64
}

Duty represent data regarding the duty type with the duty data

type DutyData added in v0.0.7

type DutyData struct {
	// Types that are valid to be assigned to Data:
	//	*InputValueAttestationData
	//	*InputValue_AggregationData
	//	*InputValue_BeaconBlock
	Data IsInputValueData `protobuf_oneof:"data"`
	// Types that are valid to be assigned to SignedData:
	//	*InputValueAttestation
	//	*InputValue_Aggregation
	//	*InputValue_Block
	SignedData IsInputValueSignedData `protobuf_oneof:"signed_data"`
}

DutyData represent unified duty types data

func (*DutyData) GetAttestation added in v0.0.7

func (m *DutyData) GetAttestation() *phase0.Attestation

GetAttestation return cast attestation input data

func (*DutyData) GetAttestationData added in v0.0.7

func (m *DutyData) GetAttestationData() *phase0.AttestationData

GetAttestationData return cast input data

func (*DutyData) GetData added in v0.0.7

func (m *DutyData) GetData() IsInputValueData

GetData returns input data

func (*DutyData) GetSignedData added in v0.0.7

func (m *DutyData) GetSignedData() IsInputValueSignedData

GetSignedData returns input data

type InputValueAttestation added in v0.0.7

type InputValueAttestation struct {
	Attestation *phase0.Attestation
}

InputValueAttestation implementing IsInputValueSignedData

type InputValueAttestationData added in v0.0.7

type InputValueAttestationData struct {
	AttestationData *phase0.AttestationData
}

InputValueAttestationData implementing IsInputValueData

type IsInputValueData added in v0.0.7

type IsInputValueData interface {
	// contains filtered or unexported methods
}

IsInputValueData interface representing input data

type IsInputValueSignedData added in v0.0.7

type IsInputValueSignedData interface {
	// contains filtered or unexported methods
}

IsInputValueSignedData interface representing input signed data

type KeyManager added in v0.1.4

type KeyManager interface {
	Signer
	// AddShare saves a share key
	AddShare(shareKey *bls.SecretKey) error
}

KeyManager is an interface responsible for all key manager functions

type OnUpdated added in v0.0.20

type OnUpdated func(pk string, meta *ValidatorMetadata)

OnUpdated represents a function to be called once validator's metadata was updated

type Options added in v0.0.7

type Options struct {
	Context        context.Context
	Logger         *zap.Logger
	Network        string `yaml:"Network" env:"NETWORK" env-default:"prater"`
	BeaconNodeAddr string `yaml:"BeaconNodeAddr" env:"BEACON_NODE_ADDR" env-required:"true"`
	Graffiti       []byte
	DB             basedb.IDb
}

Options for controller struct creation

type RoleType added in v0.0.7

type RoleType int

RoleType type of the validator role for a specific duty

const (
	RoleTypeUnknown RoleType = iota
	RoleTypeAttester
	RoleTypeAggregator
	RoleTypeProposer
)

List of roles

func (RoleType) String added in v0.0.7

func (r RoleType) String() string

String returns name of the role

type Signer added in v0.1.4

type Signer interface {
	// SignIBFTMessage signs a network iBFT msg
	SignIBFTMessage(message *proto.Message, pk []byte) ([]byte, error)
	// SignAttestation signs the given attestation
	SignAttestation(data *spec.AttestationData, duty *Duty, pk []byte) (*spec.Attestation, []byte, error)
}

Signer is an interface responsible for all signing operations

type SigningUtil added in v0.1.4

type SigningUtil interface {
	GetDomain(data *spec.AttestationData) ([]byte, error)
	ComputeSigningRoot(object interface{}, domain []byte) ([32]byte, error)
}

SigningUtil is an interface for beacon node signing specific methods

type ValidatorMetadata added in v0.0.20

type ValidatorMetadata struct {
	Balance spec.Gwei           `json:"balance"`
	Status  v1.ValidatorState   `json:"status"`
	Index   spec.ValidatorIndex `json:"index"` // pointer in order to support nil
}

ValidatorMetadata represents validator metdata from beacon

func (*ValidatorMetadata) Activated added in v0.0.20

func (m *ValidatorMetadata) Activated() bool

Activated returns true if the validator is not unknown. It might be pending activation or active

func (*ValidatorMetadata) Equals added in v0.1.2

func (m *ValidatorMetadata) Equals(other *ValidatorMetadata) bool

Equals returns true if the given metadata is equal to current

func (*ValidatorMetadata) Exiting added in v0.0.20

func (m *ValidatorMetadata) Exiting() bool

Exiting returns true if the validator is existing or exited

func (*ValidatorMetadata) Pending added in v0.1.3

func (m *ValidatorMetadata) Pending() bool

Pending returns true if the validator is pending

func (*ValidatorMetadata) Slashed added in v0.0.20

func (m *ValidatorMetadata) Slashed() bool

Slashed returns true if the validator is existing or exited due to slashing

type ValidatorMetadataStorage added in v0.0.20

type ValidatorMetadataStorage interface {
	UpdateValidatorMetadata(pk string, metadata *ValidatorMetadata) error
}

ValidatorMetadataStorage interface for validator metadata

func NewMockValidatorMetadataStorage added in v0.0.20

func NewMockValidatorMetadataStorage() ValidatorMetadataStorage

NewMockValidatorMetadataStorage creates a new mock implementation of ValidatorMetadataStorage

Directories

Path Synopsis
ekm

Jump to

Keyboard shortcuts

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