2021-03-11 11:57:41 +00:00
|
|
|
package iface
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"errors"
|
|
|
|
"time"
|
|
|
|
|
2023-03-17 18:52:56 +00:00
|
|
|
fieldparams "github.com/prysmaticlabs/prysm/v4/config/fieldparams"
|
|
|
|
validatorserviceconfig "github.com/prysmaticlabs/prysm/v4/config/validator/service"
|
|
|
|
"github.com/prysmaticlabs/prysm/v4/consensus-types/primitives"
|
|
|
|
"github.com/prysmaticlabs/prysm/v4/crypto/bls"
|
|
|
|
ethpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1"
|
|
|
|
validatorpb "github.com/prysmaticlabs/prysm/v4/proto/prysm/v1alpha1/validator-client"
|
|
|
|
"github.com/prysmaticlabs/prysm/v4/validator/keymanager"
|
2021-03-11 11:57:41 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// ErrConnectionIssue represents a connection problem.
|
|
|
|
var ErrConnectionIssue = errors.New("could not connect")
|
|
|
|
|
|
|
|
// ValidatorRole defines the validator role.
|
|
|
|
type ValidatorRole int8
|
|
|
|
|
|
|
|
const (
|
|
|
|
// RoleUnknown means that the role of the validator cannot be determined.
|
|
|
|
RoleUnknown ValidatorRole = iota
|
|
|
|
// RoleAttester means that the validator should submit an attestation.
|
|
|
|
RoleAttester
|
2021-05-13 06:29:14 +00:00
|
|
|
// RoleProposer means that the validator should propose a block.
|
2021-03-11 11:57:41 +00:00
|
|
|
RoleProposer
|
2021-05-13 06:29:14 +00:00
|
|
|
// RoleAggregator means that the validator should submit an aggregation and proof.
|
2021-03-11 11:57:41 +00:00
|
|
|
RoleAggregator
|
2021-09-07 18:43:50 +00:00
|
|
|
// RoleSyncCommittee means that the validator should submit a sync committee message.
|
|
|
|
RoleSyncCommittee
|
|
|
|
// RoleSyncCommitteeAggregator means the valiator should aggregate sync committee messages and submit a sync committee contribution.
|
|
|
|
RoleSyncCommitteeAggregator
|
2021-03-11 11:57:41 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// Validator interface defines the primary methods of a validator client.
|
|
|
|
type Validator interface {
|
|
|
|
Done()
|
|
|
|
WaitForChainStart(ctx context.Context) error
|
|
|
|
WaitForSync(ctx context.Context) error
|
2022-01-06 17:33:08 +00:00
|
|
|
WaitForActivation(ctx context.Context, accountsChangedChan chan [][fieldparams.BLSPubkeyLength]byte) error
|
2023-01-26 14:40:12 +00:00
|
|
|
CanonicalHeadSlot(ctx context.Context) (primitives.Slot, error)
|
|
|
|
NextSlot() <-chan primitives.Slot
|
|
|
|
SlotDeadline(slot primitives.Slot) time.Time
|
|
|
|
LogValidatorGainsAndLosses(ctx context.Context, slot primitives.Slot) error
|
|
|
|
UpdateDuties(ctx context.Context, slot primitives.Slot) error
|
|
|
|
RolesAt(ctx context.Context, slot primitives.Slot) (map[[fieldparams.BLSPubkeyLength]byte][]ValidatorRole, error) // validator pubKey -> roles
|
|
|
|
SubmitAttestation(ctx context.Context, slot primitives.Slot, pubKey [fieldparams.BLSPubkeyLength]byte)
|
|
|
|
ProposeBlock(ctx context.Context, slot primitives.Slot, pubKey [fieldparams.BLSPubkeyLength]byte)
|
|
|
|
SubmitAggregateAndProof(ctx context.Context, slot primitives.Slot, pubKey [fieldparams.BLSPubkeyLength]byte)
|
|
|
|
SubmitSyncCommitteeMessage(ctx context.Context, slot primitives.Slot, pubKey [fieldparams.BLSPubkeyLength]byte)
|
|
|
|
SubmitSignedContributionAndProof(ctx context.Context, slot primitives.Slot, pubKey [fieldparams.BLSPubkeyLength]byte)
|
2021-03-11 11:57:41 +00:00
|
|
|
LogAttestationsSubmitted()
|
2022-06-27 23:01:24 +00:00
|
|
|
LogSyncCommitteeMessagesSubmitted()
|
2023-01-26 14:40:12 +00:00
|
|
|
UpdateDomainDataCaches(ctx context.Context, slot primitives.Slot)
|
2022-01-31 16:44:17 +00:00
|
|
|
WaitForKeymanagerInitialization(ctx context.Context) error
|
2021-03-11 11:57:41 +00:00
|
|
|
AllValidatorsAreExited(ctx context.Context) (bool, error)
|
2022-01-31 16:44:17 +00:00
|
|
|
Keymanager() (keymanager.IKeymanager, error)
|
2021-03-11 11:57:41 +00:00
|
|
|
ReceiveBlocks(ctx context.Context, connectionErrorChannel chan<- error)
|
2022-12-19 21:12:09 +00:00
|
|
|
HandleKeyReload(ctx context.Context, currentKeys [][fieldparams.BLSPubkeyLength]byte) (bool, error)
|
2021-07-02 04:11:09 +00:00
|
|
|
CheckDoppelGanger(ctx context.Context) error
|
2023-03-14 04:52:56 +00:00
|
|
|
PushProposerSettings(ctx context.Context, km keymanager.IKeymanager, deadline time.Time) error
|
2022-07-12 04:19:49 +00:00
|
|
|
SignValidatorRegistrationRequest(ctx context.Context, signer SigningFunc, newValidatorRegistration *ethpb.ValidatorRegistrationV1) (*ethpb.SignedValidatorRegistrationV1, error)
|
2022-10-04 17:05:46 +00:00
|
|
|
ProposerSettings() *validatorserviceconfig.ProposerSettings
|
|
|
|
SetProposerSettings(*validatorserviceconfig.ProposerSettings)
|
2021-03-11 11:57:41 +00:00
|
|
|
}
|
2022-07-12 04:19:49 +00:00
|
|
|
|
|
|
|
// SigningFunc interface defines a type for the a function that signs a message
|
|
|
|
type SigningFunc func(context.Context, *validatorpb.SignRequest) (bls.Signature, error)
|