beacon

package
v0.2.1-rc.1 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2022 License: GPL-3.0 Imports: 20 Imported by: 0

Documentation

Overview

Package beacon is a generated GoMock package.

Package beacon is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FetchValidatorsMetadata

func FetchValidatorsMetadata(bc Beacon, pubKeys [][]byte) (map[string]*ValidatorMetadata, error)

FetchValidatorsMetadata is fetching validators data from beacon

func UpdateValidatorsMetadata

func UpdateValidatorsMetadata(pubKeys [][]byte, collection ValidatorMetadataStorage, bc Beacon, onUpdated OnUpdated) error

UpdateValidatorsMetadata updates validator information for the given public keys

func UpdateValidatorsMetadataBatch

func UpdateValidatorsMetadataBatch(pubKeys [][]byte,
	queue queue.Queue,
	collection ValidatorMetadataStorage,
	bc Beacon,
	onUpdated OnUpdated,
	batchSize int)

UpdateValidatorsMetadataBatch updates the given public keys in batches

Types

type Beacon

type Beacon interface {
	KeyManager
	SigningUtil

	// GetDuties returns duties for the passed validators indices
	GetDuties(epoch spec.Epoch, validatorIndices []spec.ValidatorIndex) ([]*Duty, error)

	// GetValidatorData returns metadata (balance, index, status, more) for each pubkey from the node
	GetValidatorData(validatorPubKeys []spec.BLSPubKey) (map[spec.ValidatorIndex]*api.Validator, error)

	// GetAttestationData returns attestation data by the given slot and committee index
	GetAttestationData(slot spec.Slot, committeeIndex spec.CommitteeIndex) (*spec.AttestationData, error)

	// SubmitAttestation submit the attestation to the node
	SubmitAttestation(attestation *spec.Attestation) error

	// SubscribeToCommitteeSubnet subscribe committee to subnet (p2p topic)
	SubscribeToCommitteeSubnet(subscription []*api.BeaconCommitteeSubscription) error
}

Beacon represents the behavior of the beacon node connector

type Duty

type Duty struct {
	// Type is the duty type (attest, propose)
	Type message.RoleType
	// PubKey is the public key of the validator that should attest.
	PubKey spec.BLSPubKey
	// Slot is the slot in which the validator should attest.
	Slot spec.Slot
	// ValidatorIndex is the index of the validator that should attest.
	ValidatorIndex spec.ValidatorIndex
	// CommitteeIndex is the index of the committee in which the attesting validator has been placed.
	CommitteeIndex spec.CommitteeIndex
	// CommitteeLength is the length of the committee in which the attesting validator has been placed.
	CommitteeLength uint64
	// CommitteesAtSlot is the number of committees in the slot.
	CommitteesAtSlot uint64
	// ValidatorCommitteeIndex is the index of the validator in the list of validators in the committee.
	ValidatorCommitteeIndex uint64
}

Duty represent data regarding the duty type with the duty data

type DutyData

type DutyData struct {
	// Types that are valid to be assigned to Data:
	//	*InputValueAttestationData
	//	*InputValue_AggregationData
	//	*InputValue_BeaconBlock
	Data IsInputValueData `protobuf_oneof:"data"`
	// Types that are valid to be assigned to SignedData:
	//	*InputValueAttestation
	//	*InputValue_Aggregation
	//	*InputValue_Block
	SignedData IsInputValueSignedData `protobuf_oneof:"signed_data"`
}

DutyData represent unified duty types data

func (*DutyData) GetAttestation

func (m *DutyData) GetAttestation() *phase0.Attestation

GetAttestation return cast attestation input data

func (*DutyData) GetAttestationData

func (m *DutyData) GetAttestationData() *phase0.AttestationData

GetAttestationData return cast input data

func (*DutyData) GetData

func (m *DutyData) GetData() IsInputValueData

GetData returns input data

func (*DutyData) GetSignedData

func (m *DutyData) GetSignedData() IsInputValueSignedData

GetSignedData returns input data

type InputValueAttestation

type InputValueAttestation struct {
	Attestation *phase0.Attestation
}

InputValueAttestation implementing IsInputValueSignedData

type InputValueAttestationData

type InputValueAttestationData struct {
	AttestationData *phase0.AttestationData
}

InputValueAttestationData implementing IsInputValueData

type IsInputValueData

type IsInputValueData interface {
	// contains filtered or unexported methods
}

IsInputValueData interface representing input data

type IsInputValueSignedData

type IsInputValueSignedData interface {
	// contains filtered or unexported methods
}

IsInputValueSignedData interface representing input signed data

type KeyManager

type KeyManager interface {
	Signer
	// AddShare saves a share key
	AddShare(shareKey *bls.SecretKey) error
	// RemoveShare removes a share key
	RemoveShare(pubKey string) error
}

KeyManager is an interface responsible for all key manager functions

type MockBeacon

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

MockBeacon is a mock of Beacon interface

func NewMockBeacon

func NewMockBeacon(ctrl *gomock.Controller) *MockBeacon

NewMockBeacon creates a new mock instance

func (*MockBeacon) AddShare

func (m *MockBeacon) AddShare(shareKey *bls.SecretKey) error

AddShare mocks base method

func (*MockBeacon) ComputeSigningRoot

func (m *MockBeacon) ComputeSigningRoot(object interface{}, domain []byte) ([32]byte, error)

ComputeSigningRoot mocks base method

func (*MockBeacon) EXPECT

func (m *MockBeacon) EXPECT() *MockBeaconMockRecorder

EXPECT returns an object that allows the caller to indicate expected use

func (*MockBeacon) GetAttestationData

func (m *MockBeacon) GetAttestationData(slot phase0.Slot, committeeIndex phase0.CommitteeIndex) (*phase0.AttestationData, error)

GetAttestationData mocks base method

func (*MockBeacon) GetDomain

func (m *MockBeacon) GetDomain(data *phase0.AttestationData) ([]byte, error)

GetDomain mocks base method

func (*MockBeacon) GetDuties

func (m *MockBeacon) GetDuties(epoch phase0.Epoch, validatorIndices []phase0.ValidatorIndex) ([]*Duty, error)

GetDuties mocks base method

func (*MockBeacon) GetValidatorData

func (m *MockBeacon) GetValidatorData(validatorPubKeys []phase0.BLSPubKey) (map[phase0.ValidatorIndex]*v1.Validator, error)

GetValidatorData mocks base method

func (*MockBeacon) RemoveShare

func (m *MockBeacon) RemoveShare(pubKey string) error

func (*MockBeacon) SignAttestation

func (m *MockBeacon) SignAttestation(data *phase0.AttestationData, duty *Duty, pk []byte) (*phase0.Attestation, []byte, error)

SignAttestation mocks base method

func (*MockBeacon) SignIBFTMessage

func (m *MockBeacon) SignIBFTMessage(message *message.ConsensusMessage, pk []byte, forkVersion string) ([]byte, error)

SignIBFTMessage mocks base method

func (*MockBeacon) SubmitAttestation

func (m *MockBeacon) SubmitAttestation(attestation *phase0.Attestation) error

SubmitAttestation mocks base method

func (*MockBeacon) SubscribeToCommitteeSubnet

func (m *MockBeacon) SubscribeToCommitteeSubnet(subscription []*v1.BeaconCommitteeSubscription) error

SubscribeToCommitteeSubnet mocks base method

type MockBeaconMockRecorder

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

MockBeaconMockRecorder is the mock recorder for MockBeacon

func (*MockBeaconMockRecorder) AddShare

func (mr *MockBeaconMockRecorder) AddShare(shareKey interface{}) *gomock.Call

AddShare indicates an expected call of AddShare

func (*MockBeaconMockRecorder) ComputeSigningRoot

func (mr *MockBeaconMockRecorder) ComputeSigningRoot(object, domain interface{}) *gomock.Call

ComputeSigningRoot indicates an expected call of ComputeSigningRoot

func (*MockBeaconMockRecorder) GetAttestationData

func (mr *MockBeaconMockRecorder) GetAttestationData(slot, committeeIndex interface{}) *gomock.Call

GetAttestationData indicates an expected call of GetAttestationData

func (*MockBeaconMockRecorder) GetDomain

func (mr *MockBeaconMockRecorder) GetDomain(data interface{}) *gomock.Call

GetDomain indicates an expected call of GetDomain

func (*MockBeaconMockRecorder) GetDuties

func (mr *MockBeaconMockRecorder) GetDuties(epoch, validatorIndices interface{}) *gomock.Call

GetDuties indicates an expected call of GetDuties

func (*MockBeaconMockRecorder) GetValidatorData

func (mr *MockBeaconMockRecorder) GetValidatorData(validatorPubKeys interface{}) *gomock.Call

GetValidatorData indicates an expected call of GetValidatorData

func (*MockBeaconMockRecorder) SignAttestation

func (mr *MockBeaconMockRecorder) SignAttestation(data, duty, pk interface{}) *gomock.Call

SignAttestation indicates an expected call of SignAttestation

func (*MockBeaconMockRecorder) SignIBFTMessage

func (mr *MockBeaconMockRecorder) SignIBFTMessage(message, pk interface{}) *gomock.Call

SignIBFTMessage indicates an expected call of SignIBFTMessage

func (*MockBeaconMockRecorder) SubmitAttestation

func (mr *MockBeaconMockRecorder) SubmitAttestation(attestation interface{}) *gomock.Call

SubmitAttestation indicates an expected call of SubmitAttestation

func (*MockBeaconMockRecorder) SubscribeToCommitteeSubnet

func (mr *MockBeaconMockRecorder) SubscribeToCommitteeSubnet(subscription interface{}) *gomock.Call

SubscribeToCommitteeSubnet indicates an expected call of SubscribeToCommitteeSubnet

type MockKeyManager

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

MockKeyManager is a mock of KeyManager interface

func NewMockKeyManager

func NewMockKeyManager(ctrl *gomock.Controller) *MockKeyManager

NewMockKeyManager creates a new mock instance

func (*MockKeyManager) AddShare

func (m *MockKeyManager) AddShare(shareKey *bls.SecretKey) error

AddShare mocks base method

func (*MockKeyManager) EXPECT

EXPECT returns an object that allows the caller to indicate expected use

func (*MockKeyManager) SignAttestation

func (m *MockKeyManager) SignAttestation(data *phase0.AttestationData, duty *Duty, pk []byte) (*phase0.Attestation, []byte, error)

SignAttestation mocks base method

func (*MockKeyManager) SignIBFTMessage

func (m *MockKeyManager) SignIBFTMessage(message *message.ConsensusMessage, pk []byte, forkVersion string) ([]byte, error)

SignIBFTMessage mocks base method

type MockKeyManagerMockRecorder

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

MockKeyManagerMockRecorder is the mock recorder for MockKeyManager

func (*MockKeyManagerMockRecorder) AddShare

func (mr *MockKeyManagerMockRecorder) AddShare(shareKey interface{}) *gomock.Call

AddShare indicates an expected call of AddShare

func (*MockKeyManagerMockRecorder) SignAttestation

func (mr *MockKeyManagerMockRecorder) SignAttestation(data, duty, pk interface{}) *gomock.Call

SignAttestation indicates an expected call of SignAttestation

func (*MockKeyManagerMockRecorder) SignIBFTMessage

func (mr *MockKeyManagerMockRecorder) SignIBFTMessage(message, pk interface{}) *gomock.Call

SignIBFTMessage indicates an expected call of SignIBFTMessage

type MockSigner

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

MockSigner is a mock of Signer interface

func NewMockSigner

func NewMockSigner(ctrl *gomock.Controller) *MockSigner

NewMockSigner creates a new mock instance

func (*MockSigner) EXPECT

func (m *MockSigner) EXPECT() *MockSignerMockRecorder

EXPECT returns an object that allows the caller to indicate expected use

func (*MockSigner) SignAttestation

func (m *MockSigner) SignAttestation(data *phase0.AttestationData, duty *Duty, pk []byte) (*phase0.Attestation, []byte, error)

SignAttestation mocks base method

func (*MockSigner) SignIBFTMessage

func (m *MockSigner) SignIBFTMessage(message *message.ConsensusMessage, pk []byte, forkVersion string) ([]byte, error)

SignIBFTMessage mocks base method

type MockSignerMockRecorder

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

MockSignerMockRecorder is the mock recorder for MockSigner

func (*MockSignerMockRecorder) SignAttestation

func (mr *MockSignerMockRecorder) SignAttestation(data, duty, pk interface{}) *gomock.Call

SignAttestation indicates an expected call of SignAttestation

func (*MockSignerMockRecorder) SignIBFTMessage

func (mr *MockSignerMockRecorder) SignIBFTMessage(message, pk interface{}) *gomock.Call

SignIBFTMessage indicates an expected call of SignIBFTMessage

type MockSigningUtil

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

MockSigningUtil is a mock of SigningUtil interface

func NewMockSigningUtil

func NewMockSigningUtil(ctrl *gomock.Controller) *MockSigningUtil

NewMockSigningUtil creates a new mock instance

func (*MockSigningUtil) ComputeSigningRoot

func (m *MockSigningUtil) ComputeSigningRoot(object interface{}, domain []byte) ([32]byte, error)

ComputeSigningRoot mocks base method

func (*MockSigningUtil) EXPECT

EXPECT returns an object that allows the caller to indicate expected use

func (*MockSigningUtil) GetDomain

func (m *MockSigningUtil) GetDomain(data *phase0.AttestationData) ([]byte, error)

GetDomain mocks base method

type MockSigningUtilMockRecorder

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

MockSigningUtilMockRecorder is the mock recorder for MockSigningUtil

func (*MockSigningUtilMockRecorder) ComputeSigningRoot

func (mr *MockSigningUtilMockRecorder) ComputeSigningRoot(object, domain interface{}) *gomock.Call

ComputeSigningRoot indicates an expected call of ComputeSigningRoot

func (*MockSigningUtilMockRecorder) GetDomain

func (mr *MockSigningUtilMockRecorder) GetDomain(data interface{}) *gomock.Call

GetDomain indicates an expected call of GetDomain

type MockValidatorMetadataStorage

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

MockValidatorMetadataStorage is a mock of ValidatorMetadataStorage interface

func NewMockValidatorMetadataStorage

func NewMockValidatorMetadataStorage(ctrl *gomock.Controller) *MockValidatorMetadataStorage

NewMockValidatorMetadataStorage creates a new mock instance

func (*MockValidatorMetadataStorage) EXPECT

EXPECT returns an object that allows the caller to indicate expected use

func (*MockValidatorMetadataStorage) UpdateValidatorMetadata

func (m *MockValidatorMetadataStorage) UpdateValidatorMetadata(pk string, metadata *ValidatorMetadata) error

UpdateValidatorMetadata mocks base method

type MockValidatorMetadataStorageMockRecorder

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

MockValidatorMetadataStorageMockRecorder is the mock recorder for MockValidatorMetadataStorage

func (*MockValidatorMetadataStorageMockRecorder) UpdateValidatorMetadata

func (mr *MockValidatorMetadataStorageMockRecorder) UpdateValidatorMetadata(pk, metadata interface{}) *gomock.Call

UpdateValidatorMetadata indicates an expected call of UpdateValidatorMetadata

type Network

type Network struct {
	core.Network
}

Network is a beacon chain network.

func NewNetwork

func NewNetwork(net core.Network) Network

NewNetwork creates a new beacon chain network.

func (*Network) GetSlotStartTime

func (n *Network) GetSlotStartTime(slot uint64) time.Time

GetSlotStartTime returns the start time for the given slot

type Node

type Node struct {
	IbftID uint64
	Pk     []byte
}

Node represent committee member info

type OnUpdated

type OnUpdated func(pk string, meta *ValidatorMetadata)

OnUpdated represents a function to be called once validator's metadata was updated

type Options

type Options struct {
	Context        context.Context
	Logger         *zap.Logger
	Network        string `yaml:"Network" env:"NETWORK" env-default:"prater"`
	BeaconNodeAddr string `yaml:"BeaconNodeAddr" env:"BEACON_NODE_ADDR" env-required:"true"`
	Graffiti       []byte
	DB             basedb.IDb
}

Options for controller struct creation

type PubKeys

type PubKeys []*bls.PublicKey

PubKeys defines the type for public keys object representation

func (PubKeys) Aggregate

func (keys PubKeys) Aggregate() bls.PublicKey

Aggregate iterates over public keys and adds them to the bls PublicKey

type Share

type Share struct {
	NodeID       message.OperatorID
	PublicKey    *bls.PublicKey
	Committee    map[message.OperatorID]*Node
	Metadata     *ValidatorMetadata // pointer in order to support nil
	OwnerAddress string
	Operators    [][]byte
	Liquidated   bool
}

Share storage model

func (*Share) CommitteeSize

func (s *Share) CommitteeSize() int

CommitteeSize returns the IBFT committee size

func (*Share) Deserialize

func (s *Share) Deserialize(key []byte, val []byte) (*Share, error)

Deserialize key/value to Share model

func (*Share) HasMetadata

func (s *Share) HasMetadata() bool

HasMetadata returns true if the validator metadata was fetched

func (*Share) HashOperators

func (s *Share) HashOperators() []string

HashOperators hash all Operators keys key

func (*Share) IsOperatorShare

func (s *Share) IsOperatorShare(operatorPubKey string) bool

IsOperatorShare checks whether the share belongs to operator

func (*Share) OperatorReady

func (s *Share) OperatorReady() bool

OperatorReady returns true if all operator relevant data (node id, secret share, etc.) is present

func (*Share) OperatorSharePubKey

func (s *Share) OperatorSharePubKey() (*bls.PublicKey, error)

OperatorSharePubKey returns the operator's public key based on the node id

func (*Share) PartialThresholdSize

func (s *Share) PartialThresholdSize() int

PartialThresholdSize returns the minimum IBFT committee members that needs to sign for a partial quorum (F+1)

func (*Share) PubKeysByID

func (s *Share) PubKeysByID(ids []message.OperatorID) (map[message.OperatorID]*bls.PublicKey, error)

PubKeysByID returns the public keys with the associated ids

func (*Share) Serialize

func (s *Share) Serialize() ([]byte, error)

Serialize share to []byte

func (*Share) SetOperators

func (s *Share) SetOperators(ops [][]byte)

SetOperators set Operators public keys

func (*Share) ThresholdSize

func (s *Share) ThresholdSize() int

ThresholdSize returns the minimum IBFT committee members that needs to sign for a quorum (2F+1)

func (*Share) VerifySignedMessage

func (s *Share) VerifySignedMessage(msg *message.SignedMessage, forkVersion string) error

VerifySignedMessage returns true of signed message verifies against pks

type Signer

type Signer interface {
	// SignIBFTMessage signs a network iBFT msg
	SignIBFTMessage(message *message.ConsensusMessage, pk []byte, forkVersion string) ([]byte, error)
	// SignAttestation signs the given attestation
	SignAttestation(data *spec.AttestationData, duty *Duty, pk []byte) (*spec.Attestation, []byte, error)
}

Signer is an interface responsible for all signing operations

type SigningUtil

type SigningUtil interface {
	GetDomain(data *spec.AttestationData) ([]byte, error)
	ComputeSigningRoot(object interface{}, domain []byte) ([32]byte, error)
}

SigningUtil is an interface for beacon node signing specific methods

type ValidatorMetadata

type ValidatorMetadata struct {
	Balance spec.Gwei           `json:"balance"`
	Status  v1.ValidatorState   `json:"status"`
	Index   spec.ValidatorIndex `json:"index"` // pointer in order to support nil
}

ValidatorMetadata represents validator metdata from beacon

func (*ValidatorMetadata) Activated

func (m *ValidatorMetadata) Activated() bool

Activated returns true if the validator is not unknown. It might be pending activation or active

func (*ValidatorMetadata) Equals

func (m *ValidatorMetadata) Equals(other *ValidatorMetadata) bool

Equals returns true if the given metadata is equal to current

func (*ValidatorMetadata) Exiting

func (m *ValidatorMetadata) Exiting() bool

Exiting returns true if the validator is existing or exited

func (*ValidatorMetadata) IsActive

func (m *ValidatorMetadata) IsActive() bool

IsActive returns true if the validator is currently active. Cant be other state

func (*ValidatorMetadata) Pending

func (m *ValidatorMetadata) Pending() bool

Pending returns true if the validator is pending

func (*ValidatorMetadata) Slashed

func (m *ValidatorMetadata) Slashed() bool

Slashed returns true if the validator is existing or exited due to slashing

type ValidatorMetadataStorage

type ValidatorMetadataStorage interface {
	UpdateValidatorMetadata(pk string, metadata *ValidatorMetadata) error
}

ValidatorMetadataStorage interface for validator metadata

Jump to

Keyboard shortcuts

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