instance

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2022 License: GPL-3.0 Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateState added in v0.3.2

func GenerateState(opts *Options) *qbft.State

GenerateState return generated state

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
	Height 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
	State          *qbft.State

	LeaderSelector leader.Selector
	Config         *qbft.InstanceConfig

	Logger *zap.Logger

	SsvSigner spectypes.SSVSigner

	// messages
	ContainersMap map[specqbft.MessageType]msgcont.MessageContainer
	// 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 commit msg validation 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) GenerateChangeRoundMessage added in v0.3.2

func (i *Instance) GenerateChangeRoundMessage() (*specqbft.Message, error)

GenerateChangeRoundMessage return change round msg

func (*Instance) GenerateCommitMessage added in v0.3.2

func (i *Instance) GenerateCommitMessage(value []byte) (*specqbft.Message, error)

GenerateCommitMessage returns commit msg

func (*Instance) GeneratePrepareMessage added in v0.3.2

func (i *Instance) GeneratePrepareMessage(value []byte) (*specqbft.Message, error)

GeneratePrepareMessage returns prepare msg

func (*Instance) GenerateProposalMessage added in v0.3.2

func (i *Instance) GenerateProposalMessage(proposalMsg *specqbft.ProposalData) (specqbft.Message, error)

GenerateProposalMessage returns proposal 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) GetState added in v0.3.2

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

GetState returns instance state

func (*Instance) HighestPrepared

func (i *Instance) HighestPrepared(round specqbft.Round) (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) HighestRoundTimeoutSeconds added in v0.3.2

func (i *Instance) HighestRoundTimeoutSeconds() time.Duration

HighestRoundTimeoutSeconds implements Instancer

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

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

JustifyRoundChange see below TODO: consider removing

func (*Instance) PrepareMsgPipeline

func (i *Instance) PrepareMsgPipeline() pipelines.SignedMessagePipeline

PrepareMsgPipeline is the main prepare msg pipeline

func (*Instance) PrepareMsgValidationPipeline added in v0.3.2

func (i *Instance) PrepareMsgValidationPipeline() pipelines.SignedMessagePipeline

PrepareMsgValidationPipeline is the prepare msg validation 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) ProposalMsgPipeline added in v0.3.2

func (i *Instance) ProposalMsgPipeline() pipelines.SignedMessagePipeline

ProposalMsgPipeline is the main proposal msg pipeline

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 ← ⊥
inputValue i ← value
if leader(hi, ri) = pi then
	broadcast ⟨PROPOSAL, λ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) 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) UponProposalMsg added in v0.3.2

func (i *Instance) UponProposalMsg() pipelines.SignedMessagePipeline

UponProposalMsg Algorithm 2 IBFTController pseudocode for process pi: normal case operation upon receiving a valid ⟨PROPOSAL, λi, ri, value⟩ message m from leader(λi, round) such that:

JustifyProposal(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()
	GetState() *qbft.State
	Containers() map[specqbft.MessageType]msgcont.MessageContainer
	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
	HighestRoundTimeoutSeconds() time.Duration
}

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