validator

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2022 License: GPL-3.0 Imports: 38 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCollection

func NewCollection(options CollectionOptions) validator.ICollection

NewCollection creates new share storage

func ReportValidatorStatus

func ReportValidatorStatus(pk string, meta *beacon.ValidatorMetadata, logger *zap.Logger)

ReportValidatorStatus reports the current status of validator

func SetOperatorPublicKeys

func SetOperatorPublicKeys(
	registryStorage registrystorage.OperatorsCollection,
	validatorRegistrationEvent *abiparser.ValidatorRegistrationEvent,
) error

SetOperatorPublicKeys extracts the operator public keys from the storage and fill the event

func ShareFromValidatorEvent

func ShareFromValidatorEvent(
	validatorRegistrationEvent abiparser.ValidatorRegistrationEvent,
	registryStorage registrystorage.OperatorsCollection,
	shareEncryptionKeyProvider ShareEncryptionKeyProvider,
	operatorPubKey string,
) (*beaconprotocol.Share, *bls.SecretKey, error)

ShareFromValidatorEvent takes the contract event data and creates the corresponding validator share. share could return nil in case operator key is not present/ different

func UpdateShareMetadata

func UpdateShareMetadata(share *beaconprotocol.Share, bc beaconprotocol.Beacon) (bool, error)

UpdateShareMetadata will update the given share object w/o involving storage, it will be called only when a new share is created

Types

type Collection

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

Collection struct

func (*Collection) CleanRegistryData

func (s *Collection) CleanRegistryData() error

CleanRegistryData clears all registry data

func (*Collection) DeleteValidatorShare

func (s *Collection) DeleteValidatorShare(key []byte) error

DeleteValidatorShare removes validator share by key

func (*Collection) GetAllValidatorShares

func (s *Collection) GetAllValidatorShares() ([]*beaconprotocol.Share, error)

GetAllValidatorShares returns all shares

func (*Collection) GetOperatorValidatorShares added in v0.3.0

func (s *Collection) GetOperatorValidatorShares(operatorPubKey string, enabled bool) ([]*beaconprotocol.Share, error)

GetOperatorValidatorShares returns all not liquidated validator shares belongs to operator

func (*Collection) GetValidatorShare

func (s *Collection) GetValidatorShare(key []byte) (*beaconprotocol.Share, bool, error)

GetValidatorShare by key

func (*Collection) GetValidatorSharesByOwnerAddress

func (s *Collection) GetValidatorSharesByOwnerAddress(ownerAddress string) ([]*beaconprotocol.Share, error)

GetValidatorSharesByOwnerAddress returns all validator shares belongs to owner address

func (*Collection) SaveValidatorShare

func (s *Collection) SaveValidatorShare(share *beaconprotocol.Share) error

SaveValidatorShare save validator share to db

func (*Collection) UpdateValidatorMetadata

func (s *Collection) UpdateValidatorMetadata(pk string, metadata *beaconprotocol.ValidatorMetadata) error

UpdateValidatorMetadata updates the metadata of the given validator

type CollectionOptions

type CollectionOptions struct {
	DB     basedb.IDb
	Logger *zap.Logger
}

CollectionOptions struct

type Controller

type Controller interface {
	ListenToEth1Events(feed *event.Feed)
	StartValidators()
	GetValidatorsIndices() []spec.ValidatorIndex
	GetValidator(pubKey string) (validator.IValidator, bool)
	UpdateValidatorMetaDataLoop()
	StartNetworkHandlers()
	Eth1EventHandler(ongoingSync bool) eth1.SyncEventHandler
	GetAllValidatorShares() ([]*beaconprotocol.Share, error)
	OnFork(forkVersion forksprotocol.ForkVersion) error
}

Controller represent the validators controller, it takes care of bootstrapping, updating and managing existing validators and their shares

func NewController

func NewController(options ControllerOptions) Controller

NewController creates a new validator controller instance

type ControllerOptions

type ControllerOptions struct {
	Context                    context.Context
	DB                         basedb.IDb
	Logger                     *zap.Logger
	SignatureCollectionTimeout time.Duration `` /* 152-byte string literal not displayed */
	MetadataUpdateInterval     time.Duration `` /* 127-byte string literal not displayed */
	HistorySyncRateLimit       time.Duration `yaml:"HistorySyncRateLimit" env:"HISTORY_SYNC_BACKOFF" env-default:"200ms" env-description:"Interval for updating metadata"`
	ETHNetwork                 beaconprotocol.Network
	Network                    network.P2PNetwork
	Beacon                     beaconprotocol.Beacon
	Shares                     []ShareOptions `yaml:"Shares"`
	ShareEncryptionKeyProvider ShareEncryptionKeyProvider
	CleanRegistryData          bool
	FullNode                   bool `` /* 155-byte string literal not displayed */
	KeyManager                 spectypes.KeyManager
	OperatorPubKey             string
	RegistryStorage            registrystorage.OperatorsCollection
	ForkVersion                forksprotocol.ForkVersion
	NewDecidedHandler          qbftcontroller.NewDecidedHandler
	DutyRoles                  []spectypes.BeaconRole

	// worker flags
	WorkersCount    int `` /* 131-byte string literal not displayed */
	QueueBufferSize int `yaml:"MsgWorkerBufferSize" env:"MSG_WORKER_BUFFER_SIZE" env-default:"1024" env-description:"Buffer size for message workers"`
}

ControllerOptions for creating a validator controller

type ICollection

type ICollection interface {
	eth1.RegistryStore

	SaveValidatorShare(share *beaconprotocol.Share) error
	GetValidatorShare(key []byte) (*beaconprotocol.Share, bool, error)
	GetAllValidatorShares() ([]*beaconprotocol.Share, error)
	GetOperatorValidatorShares(operatorPubKey string, enabled bool) ([]*beaconprotocol.Share, error)
	GetValidatorSharesByOwnerAddress(ownerAddress string) ([]*beaconprotocol.Share, error)
	DeleteValidatorShare(key []byte) error
}

ICollection interface for validator storage

type ShareEncryptionKeyProvider

type ShareEncryptionKeyProvider = func() (*rsa.PrivateKey, bool, error)

ShareEncryptionKeyProvider is a function that returns the operator private key

type ShareEventHandlerFunc

type ShareEventHandlerFunc func(share *beaconprotocol.Share)

ShareEventHandlerFunc is a function that handles event in an extended mode

type ShareOptions

type ShareOptions struct {
	NodeID       uint64         `yaml:"NodeID" env:"NodeID" env-description:"Local share node ID"`
	PublicKey    string         `yaml:"PublicKey" env:"LOCAL_NODE_ID" env-description:"Local validator public key"`
	ShareKey     string         `yaml:"ShareKey" env:"LOCAL_SHARE_KEY" env-description:"Local share key"`
	Committee    map[string]int `yaml:"Committee" env:"LOCAL_COMMITTEE" env-description:"Local validator committee array"`
	OwnerAddress string         `yaml:"OwnerAddress" env:"LOCAL_OWNER_ADDRESS" env-description:"Local validator owner address"`
	Operators    []string       `yaml:"Operators" env:"LOCAL_OPERATORS" env-description:"Local validator selected operators"`
	OperatorIds  []int          `yaml:"OperatorIds" env:"LOCAL_OPERATOR_IDS" env-description:"Local validator selected operator ids"`
}

ShareOptions - used to load validator share from config

func (*ShareOptions) ToShare

func (options *ShareOptions) ToShare() (*beacon.Share, error)

ToShare creates a Share instance from ShareOptions

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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