validator

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2023 License: GPL-3.0 Imports: 46 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ByOperatorID added in v0.4.0

func ByOperatorID(operatorID spectypes.OperatorID) func(share *types.SSVShare) bool

ByOperatorID filters by operator ID.

func ByOwnerAddress added in v0.4.0

func ByOwnerAddress(ownerAddress string) func(share *types.SSVShare) bool

ByOwnerAddress filters by owner address.

func LoadLocalEvents added in v0.4.0

func LoadLocalEvents(logger *zap.Logger, handler eth1.SyncEventHandler, path string) error

func NotLiquidated added in v0.4.0

func NotLiquidated() func(share *types.SSVShare) bool

NotLiquidated filters not liquidated and by operator public key.

func NotLiquidatedAndByOperatorPubKey added in v0.4.0

func NotLiquidatedAndByOperatorPubKey(operatorPubKey string) func(share *types.SSVShare) bool

NotLiquidatedAndByOperatorPubKey filters not liquidated and by operator public key.

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 SetupRunners added in v0.4.0

func SetupRunners(ctx context.Context, logger *zap.Logger, options validator.Options) runner.DutyRunners

SetupRunners initializes duty runners for the given validator

func ShareFromValidatorEvent

func ShareFromValidatorEvent(
	validatorRegistrationEvent abiparser.ValidatorRegistrationEvent,
	registryStorage registrystorage.OperatorsCollection,
	shareEncryptionKeyProvider ShareEncryptionKeyProvider,
	operatorPubKey string,
) (*types.SSVShare, *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 *types.SSVShare, 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() ([]*types.SSVShare, error)

GetAllValidatorShares returns all shares

func (*Collection) GetFilteredValidatorShares added in v0.4.0

func (s *Collection) GetFilteredValidatorShares(filter func(share *types.SSVShare) bool) ([]*types.SSVShare, error)

GetFilteredValidatorShares returns shares by a filter.

func (*Collection) GetValidatorShare

func (s *Collection) GetValidatorShare(key []byte) (*types.SSVShare, bool, error)

GetValidatorShare by key

func (*Collection) SaveValidatorShare

func (s *Collection) SaveValidatorShare(share *types.SSVShare) 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() []phase0.ValidatorIndex
	GetValidator(pubKey string) (*validator.Validator, bool)
	UpdateValidatorMetaDataLoop()
	StartNetworkHandlers()
	Eth1EventHandler(ongoingSync bool) eth1.SyncEventHandler
	GetAllValidatorShares() ([]*types.SSVShare, error)
	// GetValidatorStats returns stats of validators, including the following:
	//  - the amount of validators in the network
	//  - the amount of active validators (i.e. not slashed or existed)
	//  - the amount of validators assigned to this operator
	GetValidatorStats() (uint64, uint64, uint64, 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"`
	MinPeers                   int           `yaml:"MinimumPeers" env:"MINIMUM_PEERS" env-default:"2" env-description:"The required minimum peers for sync"`
	ETHNetwork                 beaconprotocol.Network
	Network                    network.P2PNetwork
	Beacon                     beaconprotocol.Beacon
	ShareEncryptionKeyProvider ShareEncryptionKeyProvider
	CleanRegistryData          bool
	FullNode                   bool `yaml:"FullNode" env:"FULLNODE" env-default:"false" env-description:"Save decided history rather than just highest messages"`
	Exporter                   bool `yaml:"Exporter" env:"EXPORTER" env-default:"false" env-description:""`
	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 *types.SSVShare) error
	GetValidatorShare(key []byte) (*types.SSVShare, bool, error)
	GetAllValidatorShares() ([]*types.SSVShare, error)
	GetFilteredValidatorShares(f func(share *types.SSVShare) bool) ([]*types.SSVShare, error)
	DeleteValidatorShare(key []byte) error
}

ICollection interface for validator storage

func NewCollection

func NewCollection(options CollectionOptions) ICollection

NewCollection creates new share 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 *types.SSVShare)

ShareEventHandlerFunc is a function that handles event in an extended mode

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