Documentation ¶
Overview ¶
Package client represents a gRPC polling-based implementation of an eth2 validator client.
Index ¶
- Variables
- func ConstructDialOptions(maxCallRecvMsgSize int, withCert string, grpcHeaders []string, ...) []grpc.DialOption
- func ProposeExit(ctx context.Context, validatorClient ethpb.BeaconNodeValidatorClient, ...) error
- type Config
- type FakeValidator
- func (fv *FakeValidator) BalancesByPubkeys(_ context.Context) map[[48]byte]uint64
- func (fv *FakeValidator) CanonicalHeadSlot(_ context.Context) (uint64, error)
- func (fv *FakeValidator) Done()
- func (fv *FakeValidator) IndicesToPubkeys(_ context.Context) map[uint64][48]byte
- func (fv *FakeValidator) LogAttestationsSubmitted()
- func (fv *FakeValidator) LogValidatorGainsAndLosses(_ context.Context, _ uint64) error
- func (fv *FakeValidator) NextSlot() <-chan uint64
- func (fv *FakeValidator) ProposeBlock(_ context.Context, slot uint64, _ [48]byte)
- func (fv *FakeValidator) PubkeysToIndices(_ context.Context) map[[48]byte]uint64
- func (fv *FakeValidator) PubkeysToStatuses(_ context.Context) map[[48]byte]ethpb.ValidatorStatus
- func (fv *FakeValidator) RolesAt(_ context.Context, slot uint64) (map[[48]byte][]ValidatorRole, error)
- func (fv *FakeValidator) SaveProtections(_ context.Context) error
- func (fv *FakeValidator) SlasherReady(_ context.Context) error
- func (fv *FakeValidator) SlotDeadline(_ uint64) time.Time
- func (fv *FakeValidator) SubmitAggregateAndProof(_ context.Context, _ uint64, _ [48]byte)
- func (fv *FakeValidator) SubmitAttestation(_ context.Context, slot uint64, _ [48]byte)
- func (fv *FakeValidator) UpdateDomainDataCaches(context.Context, uint64)
- func (fv *FakeValidator) UpdateDuties(_ context.Context, slot uint64) error
- func (fv *FakeValidator) UpdateProtections(_ context.Context, _ uint64) error
- func (fv *FakeValidator) WaitForActivation(_ context.Context) error
- func (fv *FakeValidator) WaitForChainStart(_ context.Context) error
- func (fv *FakeValidator) WaitForSync(_ context.Context) error
- func (fv *FakeValidator) WaitForSynced(_ context.Context) error
- func (fv *FakeValidator) WaitForWalletInitialization(_ context.Context) error
- type GenesisFetcher
- type SyncChecker
- type Validator
- type ValidatorRole
- type ValidatorService
Constants ¶
This section is empty.
Variables ¶
var ( // ValidatorStatusesGaugeVec used to track validator statuses by public key. 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", }, ) // 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", }, ) // ValidatorProposeFailVecSlasher used to count failed proposals by slashing protection. ValidatorProposeFailVecSlasher = promauto.NewCounterVec( prometheus.CounterOpts{ Name: "validator_proposals_rejected_total", Help: "Count the block proposals rejected by slashing protection.", }, []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", }, ) // 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", }, ) // ValidatorAttestFailVecSlasher used to count failed attestations by slashing protection. ValidatorAttestFailVecSlasher = promauto.NewCounterVec( prometheus.CounterOpts{ Name: "validator_attestations_rejected_total", Help: "Count the attestations rejected by slashing protection.", }, []string{ "pubkey", }, ) )
Functions ¶
func ConstructDialOptions ¶ added in v1.0.0
func ConstructDialOptions( maxCallRecvMsgSize int, withCert string, grpcHeaders []string, grpcRetries uint, grpcRetryDelay time.Duration, extraOpts ...grpc.DialOption, ) []grpc.DialOption
ConstructDialOptions constructs a list of grpc dial options
func ProposeExit ¶ added in v1.0.0
func ProposeExit( ctx context.Context, validatorClient ethpb.BeaconNodeValidatorClient, nodeClient ethpb.NodeClient, signer signingFunc, pubKey []byte, ) 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.
Types ¶
type Config ¶
type Config struct { UseWeb bool LogValidatorBalances bool EmitAccountMetrics bool WalletInitializedFeed *event.Feed GrpcRetriesFlag uint GrpcRetryDelay time.Duration GrpcMaxCallRecvMsgSizeFlag int Protector slashingprotection.Protector Endpoint string Validator Validator ValDB db.Database KeyManager keymanager.IKeymanager GraffitiFlag string CertFlag string DataDir string GrpcHeadersFlag string }
Config for the validator service.
type FakeValidator ¶ added in v1.0.0
type FakeValidator struct { DoneCalled bool WaitForWalletInitializationCalled bool WaitForActivationCalled bool WaitForChainStartCalled bool WaitForSyncCalled bool WaitForSyncedCalled bool SlasherReadyCalled bool NextSlotCalled bool CanonicalHeadSlotCalled bool UpdateDutiesCalled bool UpdateProtectionsCalled bool RoleAtCalled bool AttestToBlockHeadCalled bool ProposeBlockCalled bool LogValidatorGainsAndLossesCalled bool SaveProtectionsCalled bool SlotDeadlineCalled bool ProposeBlockArg1 uint64 AttestToBlockHeadArg1 uint64 RoleAtArg1 uint64 UpdateDutiesArg1 uint64 NextSlotRet <-chan uint64 PublicKey string UpdateDutiesRet error RolesAtRet []ValidatorRole Balances map[[48]byte]uint64 IndexToPubkeyMap map[uint64][48]byte PubkeyToIndexMap map[[48]byte]uint64 PubkeysToStatusesMap map[[48]byte]ethpb.ValidatorStatus }
FakeValidator for mocking.
func (*FakeValidator) BalancesByPubkeys ¶ added in v1.0.0
func (fv *FakeValidator) BalancesByPubkeys(_ context.Context) map[[48]byte]uint64
BalancesByPubkeys for mocking.
func (*FakeValidator) CanonicalHeadSlot ¶ added in v1.0.0
func (fv *FakeValidator) CanonicalHeadSlot(_ context.Context) (uint64, error)
CanonicalHeadSlot for mocking.
func (*FakeValidator) IndicesToPubkeys ¶ added in v1.0.0
func (fv *FakeValidator) IndicesToPubkeys(_ context.Context) map[uint64][48]byte
IndicesToPubkeys for mocking.
func (*FakeValidator) LogAttestationsSubmitted ¶ added in v1.0.0
func (fv *FakeValidator) LogAttestationsSubmitted()
LogAttestationsSubmitted for mocking.
func (*FakeValidator) LogValidatorGainsAndLosses ¶ added in v1.0.0
func (fv *FakeValidator) LogValidatorGainsAndLosses(_ context.Context, _ uint64) error
LogValidatorGainsAndLosses for mocking.
func (*FakeValidator) NextSlot ¶ added in v1.0.0
func (fv *FakeValidator) NextSlot() <-chan uint64
NextSlot for mocking.
func (*FakeValidator) ProposeBlock ¶ added in v1.0.0
func (fv *FakeValidator) ProposeBlock(_ context.Context, slot uint64, _ [48]byte)
ProposeBlock for mocking.
func (*FakeValidator) PubkeysToIndices ¶ added in v1.0.0
func (fv *FakeValidator) PubkeysToIndices(_ context.Context) map[[48]byte]uint64
PubkeysToIndices for mocking.
func (*FakeValidator) PubkeysToStatuses ¶ added in v1.0.0
func (fv *FakeValidator) PubkeysToStatuses(_ context.Context) map[[48]byte]ethpb.ValidatorStatus
PubkeysToStatuses for mocking.
func (*FakeValidator) RolesAt ¶ added in v1.0.0
func (fv *FakeValidator) RolesAt(_ context.Context, slot uint64) (map[[48]byte][]ValidatorRole, error)
RolesAt for mocking.
func (*FakeValidator) SaveProtections ¶
func (fv *FakeValidator) SaveProtections(_ context.Context) error
SaveProtections for mocking.
func (*FakeValidator) SlasherReady ¶ added in v1.0.0
func (fv *FakeValidator) SlasherReady(_ context.Context) error
SlasherReady for mocking.
func (*FakeValidator) SlotDeadline ¶ added in v1.0.0
func (fv *FakeValidator) SlotDeadline(_ uint64) time.Time
SlotDeadline for mocking.
func (*FakeValidator) SubmitAggregateAndProof ¶ added in v1.0.0
func (fv *FakeValidator) SubmitAggregateAndProof(_ context.Context, _ uint64, _ [48]byte)
SubmitAggregateAndProof for mocking.
func (*FakeValidator) SubmitAttestation ¶ added in v1.0.0
func (fv *FakeValidator) SubmitAttestation(_ context.Context, slot uint64, _ [48]byte)
SubmitAttestation for mocking.
func (*FakeValidator) UpdateDomainDataCaches ¶ added in v1.0.0
func (fv *FakeValidator) UpdateDomainDataCaches(context.Context, uint64)
UpdateDomainDataCaches for mocking.
func (*FakeValidator) UpdateDuties ¶ added in v1.0.0
func (fv *FakeValidator) UpdateDuties(_ context.Context, slot uint64) error
UpdateDuties for mocking.
func (*FakeValidator) UpdateProtections ¶ added in v1.0.0
func (fv *FakeValidator) UpdateProtections(_ context.Context, _ uint64) error
UpdateProtections for mocking.
func (*FakeValidator) WaitForActivation ¶ added in v1.0.0
func (fv *FakeValidator) WaitForActivation(_ context.Context) error
WaitForActivation for mocking.
func (*FakeValidator) WaitForChainStart ¶ added in v1.0.0
func (fv *FakeValidator) WaitForChainStart(_ context.Context) error
WaitForChainStart for mocking.
func (*FakeValidator) WaitForSync ¶ added in v1.0.0
func (fv *FakeValidator) WaitForSync(_ context.Context) error
WaitForSync for mocking.
func (*FakeValidator) WaitForSynced ¶
func (fv *FakeValidator) WaitForSynced(_ context.Context) error
WaitForSynced for mocking.
func (*FakeValidator) WaitForWalletInitialization ¶ added in v1.0.0
func (fv *FakeValidator) WaitForWalletInitialization(_ context.Context) error
WaitForWalletInitialization for mocking.
type GenesisFetcher ¶ added in v1.0.0
GenesisFetcher can retrieve genesis information such as the genesis time and the validator deposit contract address.
type SyncChecker ¶ added in v1.0.0
SyncChecker is able to determine if a beacon node is currently going through chain synchronization.
type Validator ¶
type Validator interface { Done() WaitForChainStart(ctx context.Context) error WaitForSync(ctx context.Context) error WaitForSynced(ctx context.Context) error WaitForActivation(ctx context.Context) error SlasherReady(ctx context.Context) error CanonicalHeadSlot(ctx context.Context) (uint64, error) NextSlot() <-chan uint64 SlotDeadline(slot uint64) time.Time LogValidatorGainsAndLosses(ctx context.Context, slot uint64) error UpdateDuties(ctx context.Context, slot uint64) error UpdateProtections(ctx context.Context, slot uint64) error RolesAt(ctx context.Context, slot uint64) (map[[48]byte][]ValidatorRole, error) // validator pubKey -> roles SubmitAttestation(ctx context.Context, slot uint64, pubKey [48]byte) ProposeBlock(ctx context.Context, slot uint64, pubKey [48]byte) SubmitAggregateAndProof(ctx context.Context, slot uint64, pubKey [48]byte) LogAttestationsSubmitted() SaveProtections(ctx context.Context) error UpdateDomainDataCaches(ctx context.Context, slot uint64) WaitForWalletInitialization(ctx context.Context) error }
Validator interface defines the primary methods of a validator client.
type ValidatorRole ¶ added in v1.0.0
type ValidatorRole int8
ValidatorRole defines the validator role.
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) GenesisInfo ¶ added in v1.0.0
GenesisInfo queries the beacon node for the chain genesis info containing the genesis time along with the validator deposit contract address.
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.