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) GetIBFTCommittee() map[message.OperatorID]*beaconprotocol.Node
- func (c *Controller) GetIdentifier() []byte
- func (c *Controller) Init() error
- func (c *Controller) NextSeqNumber() (message.Height, error)
- func (c *Controller) OnFork(forkVersion forksprotocol.ForkVersion) error
- func (c *Controller) PostConsensusDutyExecution(logger *zap.Logger, height message.Height, decidedValue []byte, ...) error
- func (c *Controller) ProcessChangeRound(msg *message.SignedMessage) error
- func (c *Controller) ProcessLateCommitMsg(logger *zap.Logger, msg *message.SignedMessage) (*message.SignedMessage, error)
- func (c *Controller) ProcessMsg(msg *message.SSVMessage) error
- func (c *Controller) ProcessSignatureMessage(msg *message.SignedPostConsensusMessage) error
- func (c *Controller) StartInstance(opts instance.ControllerStartInstanceOptions) (res *instance.Result, err error)
- func (c *Controller) ValidateChangeRoundMsg(msg *message.SignedMessage) error
- func (c *Controller) ValidateDecidedMsg(msg *message.SignedMessage) error
- type Controllers
- type IController
- type MessageHandler
- type NewDecidedHandler
- type Options
- type SignatureState
- type TimerState
Constants ¶
const ( NotStarted uint32 = iota InitiatedHandlers 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 { Identifier message.Identifier // contains filtered or unexported fields }
Controller implements Controller 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) GetIBFTCommittee ¶
func (c *Controller) GetIBFTCommittee() map[message.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) Init ¶
func (c *Controller) Init() error
Init sets all major processes of iBFT while blocking until completed. if init fails to sync
func (*Controller) NextSeqNumber ¶
func (c *Controller) NextSeqNumber() (message.Height, error)
NextSeqNumber 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, height message.Height, decidedValue []byte, signaturesCount int, duty *beaconprotocol.Duty) 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 *message.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 *message.SignedMessage) (*message.SignedMessage, error)
ProcessLateCommitMsg tries to aggregate the late commit message to the corresponding decided message
func (*Controller) ProcessMsg ¶
func (c *Controller) ProcessMsg(msg *message.SSVMessage) error
ProcessMsg takes an incoming message, and adds it to the message queue or handle it on read mode
func (*Controller) ProcessSignatureMessage ¶
func (c *Controller) ProcessSignatureMessage(msg *message.SignedPostConsensusMessage) error
ProcessSignatureMessage aggregate signature messages and broadcasting when quorum achieved
func (*Controller) StartInstance ¶
func (c *Controller) StartInstance(opts instance.ControllerStartInstanceOptions) (res *instance.Result, err error)
StartInstance - starts an ibft instance or returns error
func (*Controller) ValidateChangeRoundMsg ¶ added in v0.3.0
func (c *Controller) ValidateChangeRoundMsg(msg *message.SignedMessage) error
ValidateChangeRoundMsg - validation for read mode change round msg validating - basic validation, signature, changeRound data
func (*Controller) ValidateDecidedMsg ¶
func (c *Controller) ValidateDecidedMsg(msg *message.SignedMessage) error
ValidateDecidedMsg - the main decided msg pipeline
type Controllers ¶
type Controllers map[message.RoleType]IController
Controllers represents a map of controllers by role.
func (Controllers) ControllerForIdentifier ¶
func (c Controllers) ControllerForIdentifier(identifier message.Identifier) 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) (*instance.Result, error) // NextSeqNumber returns the previous decided instance seq number + 1 // In case it's the first instance it returns 0 NextSeqNumber() (message.Height, error) // GetIBFTCommittee returns a map of the iBFT committee where the key is the member's id. GetIBFTCommittee() map[message.OperatorID]*beaconprotocol.Node // GetIdentifier returns ibft identifier made of public key and role (type) GetIdentifier() []byte ProcessMsg(msg *message.SSVMessage) error // ProcessSignatureMessage aggregate signature messages and broadcasting when quorum achieved ProcessSignatureMessage(msg *message.SignedPostConsensusMessage) error // PostConsensusDutyExecution signs the eth2 duty after iBFT came to consensus and start signature state PostConsensusDutyExecution(logger *zap.Logger, height message.Height, decidedValue []byte, signaturesCount int, duty *beaconprotocol.Duty) error // OnFork called when fork occur. OnFork(forkVersion forksprotocol.ForkVersion) error }
IController represents behavior of the IController
type MessageHandler ¶
type MessageHandler func(msg *message.SSVMessage) error
MessageHandler process the msg. return error if exist
type NewDecidedHandler ¶ added in v0.3.0
type NewDecidedHandler func(msg *message.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 message.RoleType Identifier message.Identifier Logger *zap.Logger Storage qbftstorage.QBFTStore Network p2pprotocol.Network InstanceConfig *qbft.InstanceConfig Version forksprotocol.ForkVersion Beacon beaconprotocol.Beacon Signer beaconprotocol.Signer SyncRateLimit time.Duration SigTimeout time.Duration 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.