instance

package
v0.3.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UpdateChangeRoundMessage added in v0.3.0

func UpdateChangeRoundMessage(logger *zap.Logger, changeRoundStorage qbftstorage.ChangeRoundStore, msg *specqbft.SignedMessage) error

UpdateChangeRoundMessage if round for specific signer is higher than local msg

Types

type ControllerStartInstanceOptions

type ControllerStartInstanceOptions struct {
	Logger    *zap.Logger
	SeqNumber specqbft.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 {
	ValidatorShare *beaconprotocol.Share

	LeaderSelector leader.Selector
	Config         *qbft.InstanceConfig

	Logger *zap.Logger
	// contains filtered or unexported fields
}

Instance defines the instance attributes

func (*Instance) BroadcastChangeRound

func (i *Instance) BroadcastChangeRound() error

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

CommittedAggregatedMsg returns a signed message for the state's committed value with the max known signatures

func (*Instance) Containers added in v0.3.0

Containers returns map of containers

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

ForceDecide will attempt to decide the instance with provided decided signed msg.

func (*Instance) GetCommittedAggSSVMessage

func (i *Instance) GetCommittedAggSSVMessage() (spectypes.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 specqbft.Round) (notPrepared bool, highestPrepared *specqbft.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) Init

func (i *Instance) Init()

Init must be called before start can be

func (*Instance) IsLeader

func (i *Instance) IsLeader() bool

IsLeader checks and return true for round leader, false otherwise

func (*Instance) JustifyPrePrepare

func (i *Instance) JustifyPrePrepare(round uint64, preparedValue []byte) error

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

func (i *Instance) JustifyRoundChange(round specqbft.Round) error

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

func (i *Instance) RoundLeader(round specqbft.Round) uint64

RoundLeader checks the round leader

func (*Instance) SignAndBroadcast

func (i *Instance) SignAndBroadcast(msg *specqbft.Message) error

SignAndBroadcast checks and adds the signed message to the appropriate round state type

func (*Instance) Start

func (i *Instance) Start(inputValue []byte) error

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) State

func (i *Instance) State() *qbft.State

State returns instance state

func (*Instance) Stop

func (i *Instance) Stop()

Stop will trigger a stopped for the entire instance

func (*Instance) Stopped

func (i *Instance) Stopped() bool

Stopped is stopping queue work

func (*Instance) ThisRoundLeader

func (i *Instance) ThisRoundLeader() uint64

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
	Containers() map[specqbft.MessageType]msgcont.MessageContainer
	ForceDecide(msg *specqbft.SignedMessage)
	GetStageChan() chan qbft.RoundState
	CommittedAggregatedMsg() (*specqbft.SignedMessage, error)
	GetCommittedAggSSVMessage() (spectypes.SSVMessage, error)
	ProcessMsg(msg *specqbft.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

func NewInstance(opts *Options) Instancer

NewInstance is the constructor of Instance

func NewInstanceWithState

func NewInstanceWithState(state *qbft.State) Instancer

NewInstanceWithState used for testing, not PROD!

type Options

type Options struct {
	Logger         *zap.Logger
	ValidatorShare *beaconprotocol.Share
	Network        protcolp2p.Network
	LeaderSelector leader.Selector
	Config         *qbft.InstanceConfig
	Identifier     []byte
	Height         specqbft.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
	SSVSigner        spectypes.SSVSigner
	ChangeRoundStore qbftstorage.ChangeRoundStore
}

Options defines option attributes for the Instance

type Result

type Result struct {
	Decided bool
	Msg     *specqbft.SignedMessage
}

Result is a struct holding the result of a single iBFT instance

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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