controller

package
v0.2.1-rc.6 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2022 License: GPL-3.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NotStarted uint32 = iota
	InitiatedHandlers
	WaitingForPeers
	FoundPeers
	Ready
	Forking
)

set of states for the controller

View Source
const (
	StateSleep = iota
	StateRunning
	StateTimeout
)

set of timer states.

Variables

View Source
var ErrAlreadyRunning = errors.New("already running")

ErrAlreadyRunning is used to express that some process is already running, e.g. sync

Functions

func ReportIBFTStatus

func ReportIBFTStatus(pk string, finished, errorFound bool)

ReportIBFTStatus reports the current iBFT status

Types

type Controller

type Controller struct {
	ValidatorShare *beaconprotocol.Share
	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

func New

func New(opts Options) IController

New is the constructor of Controller

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
	ValidatorShare    *beaconprotocol.Share
	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.

type TimerState

type TimerState int

TimerState is the state of the timer.

Directories

Path Synopsis
v0
v1

Jump to

Keyboard shortcuts

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