beacon

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2022 License: GPL-3.0 Imports: 22 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 {
	SigningUtil

	// GetDuties returns duties for the passed validators indices
	GetDuties(epoch spec.Epoch, validatorIndices []spec.ValidatorIndex) ([]*spectypes.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 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 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 spec.Slot, committeeIndex spec.CommitteeIndex) (*spec.AttestationData, error)

GetAttestationData mocks base method

func (*MockBeacon) GetDomain

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

GetDomain mocks base method

func (*MockBeacon) GetDuties

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

GetDuties mocks base method

func (*MockBeacon) GetValidatorData

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

GetValidatorData mocks base method

func (*MockBeacon) RemoveShare

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

RemoveShare mocks base method

func (*MockBeacon) SignAttestation

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

SignAttestation mocks base method

func (*MockBeacon) SignRoot added in v0.3.0

func (m *MockBeacon) SignRoot(data spectypes.Root, sigType spectypes.SignatureType, pk []byte) (spectypes.Signature, error)

SignRoot mocks base method

func (*MockBeacon) SubmitAttestation

func (m *MockBeacon) SubmitAttestation(attestation *spec.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) RemoveShare added in v0.3.0

func (mr *MockBeaconMockRecorder) RemoveShare(pubKey interface{}) *gomock.Call

RemoveShare indicates an expected call of RemoveShare

func (*MockBeaconMockRecorder) SignAttestation

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

SignAttestation indicates an expected call of SignAttestation

func (*MockBeaconMockRecorder) SignRoot added in v0.3.0

func (mr *MockBeaconMockRecorder) SignRoot(data, sigType, pk interface{}) *gomock.Call

SignRoot indicates an expected call of SignRoot

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) RemoveShare added in v0.3.0

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

RemoveShare mocks base method

func (*MockKeyManager) SignAttestation

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

SignAttestation mocks base method

func (*MockKeyManager) SignRoot added in v0.3.0

func (m *MockKeyManager) SignRoot(data spectypes.Root, sigType spectypes.SignatureType, pk []byte) (spectypes.Signature, error)

SignRoot 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) RemoveShare added in v0.3.0

func (mr *MockKeyManagerMockRecorder) RemoveShare(pubKey interface{}) *gomock.Call

RemoveShare indicates an expected call of RemoveShare

func (*MockKeyManagerMockRecorder) SignAttestation

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

SignAttestation indicates an expected call of SignAttestation

func (*MockKeyManagerMockRecorder) SignRoot added in v0.3.0

func (mr *MockKeyManagerMockRecorder) SignRoot(data, sigType, pk interface{}) *gomock.Call

SignRoot indicates an expected call of SignRoot

type MockSigner

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

MockSigner is a mock of KeyManager 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 *spec.AttestationData, duty *spectypes.Duty, pk []byte) (*spec.Attestation, []byte, error)

SignAttestation mocks base method

func (*MockSigner) SignRoot added in v0.3.0

func (m *MockSigner) SignRoot(data spectypes.Root, sigType spectypes.SignatureType, pk []byte) (spectypes.Signature, error)

SignRoot 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) SignRoot added in v0.3.0

func (mr *MockSignerMockRecorder) SignRoot(data, sigType, pk interface{}) *gomock.Call

SignRoot indicates an expected call of SignRoot

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 *spec.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       spectypes.OperatorID
	PublicKey    *bls.PublicKey
	Committee    map[spectypes.OperatorID]*Node
	Metadata     *ValidatorMetadata // pointer in order to support nil
	OwnerAddress string
	Operators    [][]byte
	OperatorIds  []uint64
	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) HasPartialQuorum added in v0.3.2

func (s *Share) HasPartialQuorum(cnt int) bool

HasPartialQuorum returns true if at least f+1 items present (cnt is the number of items). It assumes nothing about those items, not their type or structure. https://github.com/ConsenSys/qbft-formal-spec-and-verification/blob/main/dafny/spec/L1/node_auxiliary_functions.dfy#L244

func (*Share) HasQuorum added in v0.3.2

func (s *Share) HasQuorum(cnt int) bool

HasQuorum returns true if at least 2f+1 items are present (cnt is the number of items). It assumes nothing about those items, not their type or structure https://github.com/ConsenSys/qbft-formal-spec-and-verification/blob/main/dafny/spec/L1/node_auxiliary_functions.dfy#L259

func (*Share) HashOperators

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

HashOperators hash all Operators keys key

func (*Share) IsOperatorIDShare added in v0.3.3

func (s *Share) IsOperatorIDShare(operatorID uint64) bool

IsOperatorIDShare checks whether the share belongs to operator ID

func (*Share) IsOperatorShare

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

IsOperatorShare checks whether the share belongs to operator TODO: probably we need to use IsOperatorIDShare instead of IsOperatorShare everywhere

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 []spectypes.OperatorID) (map[spectypes.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) SetOperatorIds added in v0.3.0

func (s *Share) SetOperatorIds(opIds []uint32)

SetOperatorIds set Operator ids

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 *specqbft.SignedMessage) error

VerifySignedMessage returns true of signed message verifies against pks

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