client

package
v5.2.0-rc.2 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2024 License: GPL-3.0 Imports: 84 Imported by: 0

Documentation

Overview

Package client represents a gRPC polling-based implementation of an Ethereum validator client.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ValidatorStatusesGaugeVec used to track validator statuses by public key and validator index.
	ValidatorStatusesGaugeVec = promauto.NewGaugeVec(
		prometheus.GaugeOpts{
			Namespace: "validator",
			Name:      "statuses",
			Help:      "validator statuses: 0 UNKNOWN, 1 DEPOSITED, 2 PENDING, 3 ACTIVE, 4 EXITING, 5 SLASHING, 6 EXITED",
		},
		[]string{
			"pubkey", "index",
		},
	)
	// ValidatorAggSuccessVec used to count successful aggregations.
	ValidatorAggSuccessVec = promauto.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: "validator",
			Name:      "successful_aggregations",
		},
		[]string{
			"pubkey",
		},
	)
	// ValidatorAggFailVec used to count failed aggregations.
	ValidatorAggFailVec = promauto.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: "validator",
			Name:      "failed_aggregations",
		},
		[]string{
			"pubkey",
		},
	)
	// ValidatorProposeSuccessVec used to count successful proposals.
	ValidatorProposeSuccessVec = promauto.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: "validator",
			Name:      "successful_proposals",
		},
		[]string{
			"pubkey",
		},
	)
	// ValidatorProposeFailVec used to count failed proposals.
	ValidatorProposeFailVec = promauto.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: "validator",
			Name:      "failed_proposals",
		},
		[]string{
			"pubkey",
		},
	)
	// ValidatorBalancesGaugeVec used to keep track of validator balances by public key.
	ValidatorBalancesGaugeVec = promauto.NewGaugeVec(
		prometheus.GaugeOpts{
			Namespace: "validator",
			Name:      "balance",
			Help:      "current validator balance.",
		},
		[]string{
			"pubkey",
		},
	)
	// ValidatorAttestedSlotsGaugeVec used to keep track of validator attested slots by public key.
	ValidatorAttestedSlotsGaugeVec = promauto.NewGaugeVec(
		prometheus.GaugeOpts{
			Namespace: "validator",
			Name:      "last_attested_slot",
			Help:      "Last attested slot.",
		},
		[]string{
			"pubkey",
		},
	)
	// ValidatorCorrectlyVotedSourceGaugeVec used to keep track of validator's accuracy on voting source by public key.
	ValidatorCorrectlyVotedSourceGaugeVec = promauto.NewGaugeVec(
		prometheus.GaugeOpts{
			Namespace: "validator",
			Name:      "correctly_voted_source",
			Help: "True if correctly voted source in last attestation. In Altair, this " +
				"value will be false if the attestation was not included within " +
				"integer_squareroot(SLOTS_PER_EPOCH) slots, even if it was a vote for the " +
				"correct source.",
		},
		[]string{
			"pubkey",
		},
	)
	// ValidatorCorrectlyVotedTargetGaugeVec used to keep track of validator's accuracy on voting target by public key.
	ValidatorCorrectlyVotedTargetGaugeVec = promauto.NewGaugeVec(
		prometheus.GaugeOpts{
			Namespace: "validator",
			Name:      "correctly_voted_target",
			Help: "True if correctly voted target in last attestation. In Altair, this " +
				"value will be false if the attestation was not included within " +
				"SLOTS_PER_EPOCH slots, even if it was a vote for the correct target.",
		},
		[]string{
			"pubkey",
		},
	)
	// ValidatorCorrectlyVotedHeadGaugeVec used to keep track of validator's accuracy on voting head by public key.
	ValidatorCorrectlyVotedHeadGaugeVec = promauto.NewGaugeVec(
		prometheus.GaugeOpts{
			Namespace: "validator",
			Name:      "correctly_voted_head",
			Help: "True if correctly voted head in last attestation. In Altair, this value " +
				"will be false if the attestation was not included in the next slot.",
		},
		[]string{
			"pubkey",
		},
	)
	// ValidatorAttestSuccessVec used to count successful attestations.
	ValidatorAttestSuccessVec = promauto.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: "validator",
			Name:      "successful_attestations",
		},
		[]string{
			"pubkey",
		},
	)
	// ValidatorAttestFailVec used to count failed attestations.
	ValidatorAttestFailVec = promauto.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: "validator",
			Name:      "failed_attestations",
		},
		[]string{
			"pubkey",
		},
	)
	// ValidatorNextAttestationSlotGaugeVec used to track validator statuses by public key.
	ValidatorNextAttestationSlotGaugeVec = promauto.NewGaugeVec(
		prometheus.GaugeOpts{
			Namespace: "validator",
			Name:      "next_attestation_slot",
			Help:      "validator next scheduled attestation slot",
		},
		[]string{
			"pubkey",
		},
	)
	// ValidatorNextProposalSlotGaugeVec used to track validator statuses by public key.
	ValidatorNextProposalSlotGaugeVec = promauto.NewGaugeVec(
		prometheus.GaugeOpts{
			Namespace: "validator",
			Name:      "next_proposal_slot",
			Help:      "validator next scheduled proposal slot",
		},
		[]string{
			"pubkey",
		},
	)
	// ValidatorInSyncCommitteeGaugeVec used to track whether validator is in the current sync committee.
	ValidatorInSyncCommitteeGaugeVec = promauto.NewGaugeVec(
		prometheus.GaugeOpts{
			Namespace: "validator",
			Name:      "in_sync_committee",
			Help:      "validator sync committee.New in Altair hard fork",
		},
		[]string{
			"pubkey",
		},
	)
	// ValidatorInNextSyncCommitteeGaugeVec used to track whether validator is in the next sync committee.
	ValidatorInNextSyncCommitteeGaugeVec = promauto.NewGaugeVec(
		prometheus.GaugeOpts{
			Namespace: "validator",
			Name:      "in_next_sync_committee",
			Help:      "validator next sync committee. New in Altair hard fork",
		},
		[]string{
			"pubkey",
		},
	)
	// ValidatorInactivityScoreGaugeVec used to track validator inactivity scores.
	ValidatorInactivityScoreGaugeVec = promauto.NewGaugeVec(
		prometheus.GaugeOpts{
			Namespace: "validator",
			Name:      "inactivity_score",
			Help:      "Validator inactivity score. 0 is optimum number. New in Altair hard fork",
		},
		[]string{
			"pubkey",
		},
	)
)
View Source
var (
	ErrBuilderValidatorRegistration = errors.New("Builder API validator registration unsuccessful")
	ErrValidatorsAllExited          = errors.New("All validators are exited, no more work to perform...")
)

keyFetchPeriod is the frequency that we try to refetch validating keys in case no keys were fetched previously.

Functions

func ConstructDialOptions

func ConstructDialOptions(
	maxCallRecvMsgSize int,
	withCert string,
	grpcRetries uint,
	grpcRetryDelay time.Duration,
	extraOpts ...grpc.DialOption,
) []grpc.DialOption

ConstructDialOptions constructs a list of grpc dial options

func CreateSignedVoluntaryExit

func CreateSignedVoluntaryExit(
	ctx context.Context,
	validatorClient iface.ValidatorClient,
	signer iface.SigningFunc,
	pubKey []byte,
	epoch primitives.Epoch,
) (*ethpb.SignedVoluntaryExit, error)

func CurrentEpoch

func CurrentEpoch(genesisTime *timestamp.Timestamp) (primitives.Epoch, error)

func ProposeExit

func ProposeExit(
	ctx context.Context,
	validatorClient iface.ValidatorClient,
	signer iface.SigningFunc,
	pubKey []byte,
	epoch primitives.Epoch,
) error

ProposeExit performs a voluntary exit on a validator. The exit is signed by the validator before being sent to the beacon node for broadcasting.

func SubmitValidatorRegistrations

func SubmitValidatorRegistrations(
	ctx context.Context,
	validatorClient iface.ValidatorClient,
	signedRegs []*ethpb.SignedValidatorRegistrationV1,
	validatorRegsBatchSize int,
) error

SubmitValidatorRegistrations signs validator registration objects and submits it to the beacon node by batch of validatorRegsBatchSize size maximum. If at least one error occurs during a registration call to the beacon node, the last error is returned.

Types

type Config

type Config struct {
	Validator               iface.Validator
	DB                      db.Database
	Wallet                  *wallet.Wallet
	WalletInitializedFeed   *event.Feed
	GRPCMaxCallRecvMsgSize  int
	GRPCRetries             uint
	GRPCRetryDelay          time.Duration
	GRPCHeaders             []string
	BeaconNodeGRPCEndpoint  string
	BeaconNodeCert          string
	BeaconApiEndpoint       string
	BeaconApiTimeout        time.Duration
	Graffiti                string
	GraffitiStruct          *graffiti.Graffiti
	InteropKmConfig         *local.InteropKeymanagerConfig
	Web3SignerConfig        *remoteweb3signer.SetupConfig
	ProposerSettings        *proposer.Settings
	ValidatorsRegBatchSize  int
	UseWeb                  bool
	LogValidatorPerformance bool
	EmitAccountMetrics      bool
	Distributed             bool
}

Config for the validator service.

type ValidatorService

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

ValidatorService represents a service to manage the validator client routine.

func NewValidatorService

func NewValidatorService(ctx context.Context, cfg *Config) (*ValidatorService, error)

NewValidatorService creates a new validator service for the service registry.

func (*ValidatorService) DeleteGraffiti added in v5.0.2

func (v *ValidatorService) DeleteGraffiti(ctx context.Context, pubKey [fieldparams.BLSPubkeyLength]byte) error

func (*ValidatorService) Graffiti added in v5.1.0

func (v *ValidatorService) Graffiti(ctx context.Context, pubKey [fieldparams.BLSPubkeyLength]byte) ([]byte, error)

func (*ValidatorService) InteropKeysConfig

func (v *ValidatorService) InteropKeysConfig() *local.InteropKeymanagerConfig

InteropKeysConfig returns the useInteropKeys flag.

func (*ValidatorService) Keymanager

func (v *ValidatorService) Keymanager() (keymanager.IKeymanager, error)

Keymanager returns the underlying keymanager in the validator

func (*ValidatorService) ProposerSettings

func (v *ValidatorService) ProposerSettings() *proposer.Settings

ProposerSettings returns a deep copy of the underlying proposer settings in the validator

func (*ValidatorService) RemoteSignerConfig added in v5.0.4

func (v *ValidatorService) RemoteSignerConfig() *remoteweb3signer.SetupConfig

RemoteSignerConfig returns the web3signer configuration

func (*ValidatorService) SetGraffiti added in v5.0.2

func (v *ValidatorService) SetGraffiti(ctx context.Context, pubKey [fieldparams.BLSPubkeyLength]byte, graffiti []byte) error

func (*ValidatorService) SetProposerSettings

func (v *ValidatorService) SetProposerSettings(ctx context.Context, settings *proposer.Settings) error

SetProposerSettings sets the proposer settings on the validator service as well as the underlying validator

func (*ValidatorService) Start

func (v *ValidatorService) Start()

Start the validator service. Launches the main go routine for the validator client.

func (*ValidatorService) Status

func (v *ValidatorService) Status() error

Status of the validator service.

func (*ValidatorService) Stop

func (v *ValidatorService) Stop() error

Stop the validator service.

Directories

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

Jump to

Keyboard shortcuts

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