Documentation ¶
Index ¶
- type ControllerStartInstanceOptions
- type Instance
- func (i *Instance) BroadcastChangeRound() error
- func (i *Instance) BumpRound()
- func (i *Instance) ChangeRoundMsgPipeline() pipelines.SignedMessagePipeline
- func (i *Instance) ChangeRoundMsgValidationPipeline() pipelines.SignedMessagePipeline
- func (i *Instance) ChangeRoundPartialQuorumMsgPipeline() pipelines.SignedMessagePipeline
- func (i *Instance) CommitMsgPipeline() pipelines.SignedMessagePipeline
- func (i *Instance) CommitMsgValidationPipeline() pipelines.SignedMessagePipeline
- func (i *Instance) CommittedAggregatedMsg() (*message.SignedMessage, error)
- func (i *Instance) DecidedMsgPipeline() pipelines.SignedMessagePipeline
- func (i *Instance) ForceDecide(msg *message.SignedMessage)
- func (i *Instance) GetCommittedAggSSVMessage() (message.SSVMessage, error)
- func (i *Instance) GetStageChan() chan qbft.RoundState
- func (i *Instance) HighestPrepared(round message.Round) (notPrepared bool, highestPrepared *message.RoundChangeData, err error)
- func (i *Instance) Init()
- func (i *Instance) IsLeader() bool
- func (i *Instance) JustifyPrePrepare(round uint64, preparedValue []byte) error
- func (i *Instance) JustifyRoundChange(round message.Round) error
- func (i *Instance) PrePrepareMsgPipeline() pipelines.SignedMessagePipeline
- func (i *Instance) PrepareMsgPipeline() pipelines.SignedMessagePipeline
- func (i *Instance) PreparedAggregatedMsg() (*message.SignedMessage, error)
- func (i *Instance) ProcessMsg(msg *message.SignedMessage) (bool, error)
- func (i *Instance) ProcessStageChange(stage qbft.RoundState)
- func (i *Instance) ResetRoundTimer()
- func (i *Instance) RoundLeader(round message.Round) uint64
- func (i *Instance) SignAndBroadcast(msg *message.ConsensusMessage) error
- func (i *Instance) Start(inputValue []byte) error
- func (i *Instance) State() *qbft.State
- func (i *Instance) Stop()
- func (i *Instance) Stopped() bool
- func (i *Instance) ThisRoundLeader() uint64
- func (i *Instance) UponPrePrepareMsg() pipelines.SignedMessagePipeline
- type Instancer
- type Options
- type Result
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ControllerStartInstanceOptions ¶
type ControllerStartInstanceOptions struct { Logger *zap.Logger SeqNumber message.Height Value []byte // RequireMinPeers flag to require minimum peers before starting an instance // useful for tests where we want (sometimes) to avoid networking RequireMinPeers bool }
ControllerStartInstanceOptions defines type for Controller instance options
type Instance ¶
type Instance struct { LeaderSelector leader.Selector Config *qbft.InstanceConfig Logger *zap.Logger // messages PrePrepareMessages msgcont.MessageContainer PrepareMessages msgcont.MessageContainer CommitMessages msgcont.MessageContainer ChangeRoundMessages msgcont.MessageContainer // contains filtered or unexported fields }
Instance defines the instance attributes
func (*Instance) BroadcastChangeRound ¶
BroadcastChangeRound will broadcast a change round message.
func (*Instance) BumpRound ¶
func (i *Instance) BumpRound()
BumpRound is used to set bump round by 1
func (*Instance) ChangeRoundMsgPipeline ¶
func (i *Instance) ChangeRoundMsgPipeline() pipelines.SignedMessagePipeline
ChangeRoundMsgPipeline - the main change round msg pipeline
func (*Instance) ChangeRoundMsgValidationPipeline ¶
func (i *Instance) ChangeRoundMsgValidationPipeline() pipelines.SignedMessagePipeline
ChangeRoundMsgValidationPipeline - the main change round msg validation pipeline
func (*Instance) ChangeRoundPartialQuorumMsgPipeline ¶
func (i *Instance) ChangeRoundPartialQuorumMsgPipeline() pipelines.SignedMessagePipeline
ChangeRoundPartialQuorumMsgPipeline returns the pipeline which handles partial change ronud quorum
func (*Instance) CommitMsgPipeline ¶
func (i *Instance) CommitMsgPipeline() pipelines.SignedMessagePipeline
CommitMsgPipeline - the main commit msg pipeline
func (*Instance) CommitMsgValidationPipeline ¶
func (i *Instance) CommitMsgValidationPipeline() pipelines.SignedMessagePipeline
CommitMsgValidationPipeline is the main commit msg pipeline
func (*Instance) CommittedAggregatedMsg ¶
func (i *Instance) CommittedAggregatedMsg() (*message.SignedMessage, error)
CommittedAggregatedMsg returns a signed message for the state's committed value with the max known signatures
func (*Instance) DecidedMsgPipeline ¶
func (i *Instance) DecidedMsgPipeline() pipelines.SignedMessagePipeline
DecidedMsgPipeline is the main pipeline for decided msgs
func (*Instance) ForceDecide ¶
func (i *Instance) ForceDecide(msg *message.SignedMessage)
ForceDecide will attempt to decide the instance with provided decided signed msg.
func (*Instance) GetCommittedAggSSVMessage ¶
func (i *Instance) GetCommittedAggSSVMessage() (message.SSVMessage, error)
GetCommittedAggSSVMessage returns ssv msg with message.SSVDecidedMsgType and the agg commit signed msg
func (*Instance) GetStageChan ¶
func (i *Instance) GetStageChan() chan qbft.RoundState
GetStageChan returns a RoundState channel added to the stateChangesChans array
func (*Instance) HighestPrepared ¶
func (i *Instance) HighestPrepared(round message.Round) (notPrepared bool, highestPrepared *message.RoundChangeData, err error)
HighestPrepared is slightly changed to also include a returned flag to indicate if all change round messages have prj = ⊥ ∧ pvj = ⊥
func (*Instance) JustifyPrePrepare ¶
JustifyPrePrepare implements: predicate JustifyPrePrepare(hPRE-PREPARE, λi, round, value)
return round = 1 ∨ received a quorum Qrc of valid <ROUND-CHANGE, λi, round, prj , pvj> messages such that: ∀ <ROUND-CHANGE, λi, round, prj , pvj> ∈ Qrc : prj = ⊥ ∧ prj = ⊥ ∨ received a quorum of valid <PREPARE, λi, pr, value> messages such that: (pr, value) = HighestPrepared(Qrc)
func (*Instance) JustifyRoundChange ¶
JustifyRoundChange see below
func (*Instance) PrePrepareMsgPipeline ¶
func (i *Instance) PrePrepareMsgPipeline() pipelines.SignedMessagePipeline
PrePrepareMsgPipeline is the main pre-prepare msg pipeline
func (*Instance) PrepareMsgPipeline ¶
func (i *Instance) PrepareMsgPipeline() pipelines.SignedMessagePipeline
PrepareMsgPipeline is the main prepare msg pipeline
func (*Instance) PreparedAggregatedMsg ¶
func (i *Instance) PreparedAggregatedMsg() (*message.SignedMessage, error)
PreparedAggregatedMsg returns a signed message for the state's prepared value with the max known signatures
func (*Instance) ProcessMsg ¶
func (i *Instance) ProcessMsg(msg *message.SignedMessage) (bool, error)
ProcessMsg will process the message
func (*Instance) ProcessStageChange ¶
func (i *Instance) ProcessStageChange(stage qbft.RoundState)
ProcessStageChange set the state's round state and pushed the new state into the state channel
func (*Instance) ResetRoundTimer ¶
func (i *Instance) ResetRoundTimer()
ResetRoundTimer ... * "Timer:
In addition to the state variables, each correct process pi also maintains a timer represented by timeri, which is used to trigger a round change when the algorithm does not sufficiently progress. The timer can be in one of two states: running or expired. When set to running, it is also set a time t(ri), which is an exponential function of the round number ri, after which the state changes to expired." ResetRoundTimer will reset the current timer (including stopping the previous one)
func (*Instance) RoundLeader ¶
RoundLeader checks the round leader
func (*Instance) SignAndBroadcast ¶
func (i *Instance) SignAndBroadcast(msg *message.ConsensusMessage) error
SignAndBroadcast checks and adds the signed message to the appropriate round state type
func (*Instance) Start ¶
Start implements the Algorithm 1 IBFTController pseudocode for process pi: constants, state variables, and ancillary procedures procedure Start(λ, value)
λi ← λ ri ← 1 pri ← ⊥ pvi ← ⊥ inputV aluei ← value if leader(hi, ri) = pi then broadcast ⟨PRE-PREPARE, λi, ri, inputV aluei⟩ message set timer to running and expire after t(ri)
func (*Instance) Stop ¶
func (i *Instance) Stop()
Stop will trigger a stopped for the entire instance
func (*Instance) ThisRoundLeader ¶
ThisRoundLeader returns the round leader
func (*Instance) UponPrePrepareMsg ¶
func (i *Instance) UponPrePrepareMsg() pipelines.SignedMessagePipeline
UponPrePrepareMsg Algorithm 2 IBFTController pseudocode for process pi: normal case operation upon receiving a valid ⟨PRE-PREPARE, λi, ri, value⟩ message m from leader(λi, round) such that:
JustifyPrePrepare(m) do set timer i to running and expire after t(ri) broadcast ⟨PREPARE, λi, ri, value⟩
type Instancer ¶
type Instancer interface { validation.Pipelines Init() Start(inputValue []byte) error Stop() State() *qbft.State ForceDecide(msg *message.SignedMessage) GetStageChan() chan qbft.RoundState CommittedAggregatedMsg() (*message.SignedMessage, error) GetCommittedAggSSVMessage() (message.SSVMessage, error) ProcessMsg(msg *message.SignedMessage) (bool, error) ResetRoundTimer() // TODO temp solution for race condition with message process BroadcastChangeRound() error // TODO temp solution for race condition with message process }
Instancer represents an iBFT instance (a single sequence number)
func NewInstance ¶
NewInstance is the constructor of Instance
func NewInstanceWithState ¶
NewInstanceWithState used for testing, not PROD!
type Options ¶
type Options struct { Logger *zap.Logger Network protcolp2p.Network LeaderSelector leader.Selector Config *qbft.InstanceConfig Identifier message.Identifier Height message.Height // RequireMinPeers flag to require minimum peers before starting an instance // useful for tests where we want (sometimes) to avoid networking RequireMinPeers bool // Fork sets the current fork to apply on instance Fork forks.Fork Signer beaconprotocol.Signer ChangeRoundStore qbftstorage.ChangeRoundStore }
Options defines option attributes for the Instance
type Result ¶
type Result struct { Decided bool Msg *message.SignedMessage }
Result is a struct holding the result of a single iBFT instance