Documentation ¶
Index ¶
- Constants
- Variables
- func ReportIBFTStatus(pk string, finished, errorFound bool)
- type Controller
- func (c *Controller) ConsumeQueue(handler MessageHandler, interval time.Duration) error
- func (c *Controller) GetCurrentInstance() instance.Instancer
- func (c *Controller) GetHeight() specqbft.Height
- func (c *Controller) GetIBFTCommittee() map[spectypes.OperatorID]*beaconprotocol.Node
- func (c *Controller) GetIdentifier() []byte
- func (c *Controller) GetNodeMode() strategy.Mode
- func (c *Controller) Init() error
- func (c *Controller) MessageHandler(msg *spectypes.SSVMessage) error
- func (c *Controller) NextHeightNumber() (specqbft.Height, error)
- func (c *Controller) OnFork(forkVersion forksprotocol.ForkVersion) error
- func (c *Controller) PostConsensusDutyExecution(logger *zap.Logger, decidedValue []byte, signaturesCount int, ...) error
- func (c *Controller) ProcessChangeRound(msg *specqbft.SignedMessage) error
- func (c *Controller) ProcessLateCommitMsg(logger *zap.Logger, msg *specqbft.SignedMessage) (*specqbft.SignedMessage, error)
- func (c *Controller) ProcessMsg(msg *spectypes.SSVMessage) error
- func (c *Controller) ProcessPostConsensusMessage(msg *specssv.SignedPartialSignatureMessage) error
- func (c *Controller) SetCurrentInstance(instance instance.Instancer)
- func (c *Controller) StartInstance(opts instance.ControllerStartInstanceOptions, ...) (res *instance.Result, err error)
- func (c *Controller) StartQueueConsumer(handler MessageHandler)
- func (c *Controller) UponExistingInstanceMsg(logger *zap.Logger, msg *specqbft.SignedMessage) (bool, error)
- func (c *Controller) ValidateChangeRoundMsg(msg *specqbft.SignedMessage) error
- func (c *Controller) ValidateDecidedMsg(msg *specqbft.SignedMessage) error
- type Controllers
- type IController
- type MessageHandler
- type NewDecidedHandler
- type Options
- type SignatureState
- type TimerState
Constants ¶
const ( NotStarted uint32 = iota InitiatedHandlers SyncedChangeRound WaitingForPeers FoundPeers Ready Forking )
set of states for the controller
const ( StateSleep = iota StateRunning StateTimeout )
set of timer states.
Variables ¶
var ErrAlreadyRunning = errors.New("already running")
ErrAlreadyRunning is used to express that some process is already running, e.g. sync
Functions ¶
func ReportIBFTStatus ¶
ReportIBFTStatus reports the current iBFT status
Types ¶
type Controller ¶
type Controller struct { Ctx context.Context Logger *zap.Logger InstanceStorage qbftstorage.InstanceStore ChangeRoundStorage qbftstorage.ChangeRoundStore Network p2pprotocol.Network InstanceConfig *qbft.InstanceConfig Identifier []byte Fork forks.Fork Beacon beaconprotocol.Beacon KeyManager spectypes.KeyManager HigherReceivedMessages map[spectypes.OperatorID]specqbft.Height // lockers CurrentInstanceLock *sync.RWMutex // not locker interface in order to avoid casting to RWMutex ForkLock sync.Locker // signature SignatureState SignatureState // config SyncRateLimit time.Duration MinPeers int // state State uint32 // flags ReadMode bool Q msgqueue.MsgQueue DecidedFactory *factory.Factory DecidedStrategy strategy.Decided // contains filtered or unexported fields }
Controller implements IController interface
func (*Controller) ConsumeQueue ¶
func (c *Controller) ConsumeQueue(handler MessageHandler, interval time.Duration) error
ConsumeQueue consumes messages from the msgqueue.Queue of the controller it checks for current state
func (*Controller) GetCurrentInstance ¶ added in v0.3.0
func (c *Controller) GetCurrentInstance() instance.Instancer
GetCurrentInstance returns current instance if exist. if not, returns nil
func (*Controller) GetHeight ¶ added in v0.3.2
func (c *Controller) GetHeight() specqbft.Height
GetHeight return current ctrl height
func (*Controller) GetIBFTCommittee ¶
func (c *Controller) GetIBFTCommittee() map[spectypes.OperatorID]*beaconprotocol.Node
GetIBFTCommittee returns a map of the iBFT committee where the key is the member's id.
func (*Controller) GetIdentifier ¶
func (c *Controller) GetIdentifier() []byte
GetIdentifier returns ibft identifier made of public key and role (type)
func (*Controller) GetNodeMode ¶ added in v0.3.0
func (c *Controller) GetNodeMode() strategy.Mode
GetNodeMode return node type
func (*Controller) Init ¶
func (c *Controller) Init() error
Init sets all major processes of iBFT while blocking until completed. if init fails to sync
func (*Controller) MessageHandler ¶ added in v0.3.0
func (c *Controller) MessageHandler(msg *spectypes.SSVMessage) error
MessageHandler process message from queue,
func (*Controller) NextHeightNumber ¶ added in v0.3.2
func (c *Controller) NextHeightNumber() (specqbft.Height, error)
NextHeightNumber returns the previous decided instance seq number + 1 In case it's the first instance it returns 0
func (*Controller) OnFork ¶
func (c *Controller) OnFork(forkVersion forksprotocol.ForkVersion) error
OnFork called upon fork, it will make sure all decided messages were processed before clearing the entire msg queue. it also recreates the fork instance and decided strategy with the new fork version
func (*Controller) PostConsensusDutyExecution ¶
func (c *Controller) PostConsensusDutyExecution(logger *zap.Logger, decidedValue []byte, signaturesCount int, role spectypes.BeaconRole) error
PostConsensusDutyExecution signs the eth2 duty after iBFT came to consensus and start signature state
func (*Controller) ProcessChangeRound ¶ added in v0.3.0
func (c *Controller) ProcessChangeRound(msg *specqbft.SignedMessage) error
ProcessChangeRound check basic pipeline validation than check if height or round is higher than the last one. if so, update
func (*Controller) ProcessLateCommitMsg ¶
func (c *Controller) ProcessLateCommitMsg(logger *zap.Logger, msg *specqbft.SignedMessage) (*specqbft.SignedMessage, error)
ProcessLateCommitMsg tries to aggregate the late commit message to the corresponding decided message
func (*Controller) ProcessMsg ¶
func (c *Controller) ProcessMsg(msg *spectypes.SSVMessage) error
ProcessMsg takes an incoming message, and adds it to the message queue or handle it on read mode
func (*Controller) ProcessPostConsensusMessage ¶ added in v0.3.0
func (c *Controller) ProcessPostConsensusMessage(msg *specssv.SignedPartialSignatureMessage) error
ProcessPostConsensusMessage aggregates partial signature messages and broadcasting when quorum achieved
func (*Controller) SetCurrentInstance ¶ added in v0.3.2
func (c *Controller) SetCurrentInstance(instance instance.Instancer)
SetCurrentInstance set the current instance
func (*Controller) StartInstance ¶
func (c *Controller) StartInstance(opts instance.ControllerStartInstanceOptions, getInstance func(instance instance.Instancer)) (res *instance.Result, err error)
StartInstance - starts an ibft instance or returns error
func (*Controller) StartQueueConsumer ¶ added in v0.3.0
func (c *Controller) StartQueueConsumer(handler MessageHandler)
StartQueueConsumer start ConsumeQueue with handler
func (*Controller) UponExistingInstanceMsg ¶ added in v0.3.2
func (c *Controller) UponExistingInstanceMsg(logger *zap.Logger, msg *specqbft.SignedMessage) (bool, error)
UponExistingInstanceMsg run instance process flow. if no instance running, check if commit
func (*Controller) ValidateChangeRoundMsg ¶ added in v0.3.0
func (c *Controller) ValidateChangeRoundMsg(msg *specqbft.SignedMessage) error
ValidateChangeRoundMsg - validation for read mode change round msg validating - basic validation, signature, changeRound data
func (*Controller) ValidateDecidedMsg ¶
func (c *Controller) ValidateDecidedMsg(msg *specqbft.SignedMessage) error
ValidateDecidedMsg - the main decided msg pipeline
type Controllers ¶
type Controllers map[spectypes.BeaconRole]IController
Controllers represents a map of controllers by role.
func (Controllers) ControllerForIdentifier ¶
func (c Controllers) ControllerForIdentifier(identifier []byte) IController
ControllerForIdentifier returns a controller by its identifier.
type IController ¶
type IController interface { // Init should be called after creating an IController instance to init the instance, sync it, etc. Init() error // StartInstance starts a new instance by the given options StartInstance(opts instance.ControllerStartInstanceOptions, getInstance func(instance instance.Instancer)) (*instance.Result, error) // NextHeightNumber returns the previous decided instance seq number + 1 // In case it's the first instance it returns 0 NextHeightNumber() (specqbft.Height, error) // GetIBFTCommittee returns a map of the iBFT committee where the key is the member's id. GetIBFTCommittee() map[spectypes.OperatorID]*beaconprotocol.Node // GetIdentifier returns ibft identifier made of public key and role (type) GetIdentifier() []byte ProcessMsg(msg *spectypes.SSVMessage) error // ProcessPostConsensusMessage aggregates partial signature messages and broadcasting when quorum achieved ProcessPostConsensusMessage(msg *specssv.SignedPartialSignatureMessage) error // PostConsensusDutyExecution signs the eth2 duty after iBFT came to consensus and start signature state PostConsensusDutyExecution(logger *zap.Logger, decidedValue []byte, signaturesCount int, duty spectypes.BeaconRole) error // OnFork called when fork occur. OnFork(forkVersion forksprotocol.ForkVersion) error // GetCurrentInstance returns current instance if exist. if not, returns nil TODO for mapping, need to remove once duty runner implemented GetCurrentInstance() instance.Instancer }
IController represents behavior of the IController
type MessageHandler ¶
type MessageHandler func(msg *spectypes.SSVMessage) error
MessageHandler process the msg. return error if exist
type NewDecidedHandler ¶ added in v0.3.0
type NewDecidedHandler func(msg *specqbft.SignedMessage)
NewDecidedHandler handles newly saved decided messages. it will be called in a new goroutine to avoid concurrency issues
type Options ¶
type Options struct { Context context.Context Role spectypes.BeaconRole Identifier []byte Logger *zap.Logger Storage qbftstorage.QBFTStore Network p2pprotocol.Network InstanceConfig *qbft.InstanceConfig Version forksprotocol.ForkVersion Beacon beaconprotocol.Beacon KeyManager spectypes.KeyManager SyncRateLimit time.Duration SigTimeout time.Duration MinPeers int ReadMode bool FullNode bool NewDecidedHandler NewDecidedHandler }
Options is a set of options for the controller
type SignatureState ¶
type SignatureState struct { SignatureCollectionTimeout time.Duration // contains filtered or unexported fields }
SignatureState represents the signature state.