ibft

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2021 License: GPL-3.0 Imports: 25 Imported by: 0

README

SSV - IBFT



Blox IBFT implementation
Codebase Structure
How to start SSV environment locally?

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IBFT

type IBFT interface {
	// Init should be called after creating an IBFT instance to init the instance, sync it, etc.
	Init()

	// StartInstance starts a new instance by the given options
	StartInstance(opts StartOptions) (bool, int, []byte)

	// NextSeqNumber returns the previous decided instance seq number + 1
	// In case it's the first instance it returns 0
	NextSeqNumber() (uint64, error)

	// GetIBFTCommittee returns a map of the iBFT committee where the key is the member's id.
	GetIBFTCommittee() map[uint64]*proto.Node
}

IBFT represents behavior of the IBFT

func New

func New(
	logger *zap.Logger,
	storage collections.Iibft,
	network network.Network,
	queue *msgqueue.MessageQueue,
	instanceConfig *proto.InstanceConfig,
	ValidatorShare *storage.Share,
) IBFT

New is the constructor of IBFT

type Instance

type Instance struct {
	//Me               *proto.Node
	ValidatorShare *storage.Share
	State          *proto.State

	ValueCheck     valcheck.ValueCheck
	LeaderSelector leader.Selector
	Config         *proto.InstanceConfig

	Logger *zap.Logger

	// messages
	MsgQueue            *msgqueue.MessageQueue
	PrePrepareMessages  msgcont.MessageContainer
	PrepareMessages     msgcont.MessageContainer
	CommitMessages      msgcont.MessageContainer
	ChangeRoundMessages msgcont.MessageContainer
	// contains filtered or unexported fields
}

Instance defines the instance attributes

func NewInstance

func NewInstance(opts InstanceOptions) *Instance

NewInstance is the constructor of Instance

func (*Instance) BumpRound

func (i *Instance) BumpRound(round uint64)

BumpRound is used to set round in the instance's MsgQueue - the message broker

func (*Instance) CommittedAggregatedMsg

func (i *Instance) CommittedAggregatedMsg() (*proto.SignedMessage, error)

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

func (*Instance) GetStageChan

func (i *Instance) GetStageChan() chan proto.RoundState

GetStageChan returns a RoundState channel added to the stateChangesChans array

func (*Instance) IsLeader

func (i *Instance) IsLeader() bool

IsLeader checks and return true for round leader, false otherwise

func (*Instance) IsStopped

func (i *Instance) IsStopped() bool

IsStopped returns true if msg stopped, false if not

func (*Instance) JustifyPrePrepare

func (i *Instance) JustifyPrePrepare(round uint64) (bool, error)

JustifyPrePrepare implements: predicate JustifyPrePrepare(hPRE-PREPARE, λi, round, valuei)

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 uint64) (bool, error)

JustifyRoundChange see below

func (*Instance) PreparedAggregatedMsg

func (i *Instance) PreparedAggregatedMsg() (*proto.SignedMessage, error)

PreparedAggregatedMsg returns a signed message for the state's prepared value with the max known signatures

func (*Instance) ProcessMessage

func (i *Instance) ProcessMessage() (processedMsg bool, err error)

ProcessMessage pulls messages from the queue to be processed sequentially

func (*Instance) RoundLeader

func (i *Instance) RoundLeader(round uint64) uint64

RoundLeader checks the round leader

func (*Instance) SetStage

func (i *Instance) SetStage(stage proto.RoundState)

SetStage set the State's round State and pushed the new State into the State channel

func (*Instance) SignAndBroadcast

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

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

func (*Instance) Stage

func (i *Instance) Stage() proto.RoundState

Stage returns the instance message state

func (*Instance) Start

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

Start implements the Algorithm 1 IBFT 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) StartEventLoop

func (i *Instance) StartEventLoop()

StartEventLoop - starts the main event loop for the instance. Events are messages our timer that change the behaviour of the instance upon triggering them

func (*Instance) StartMessagePipeline

func (i *Instance) StartMessagePipeline()

StartMessagePipeline - the iBFT instance is message driven with an 'upon' logic. each message type has it's own pipeline of checks and actions, called by the networker implementation. Internal chan monitor if the instance reached decision or if a round change is required.

func (*Instance) Stop

func (i *Instance) Stop()

Stop will trigger a stop for the entire instance

func (*Instance) ThisRoundLeader

func (i *Instance) ThisRoundLeader() uint64

ThisRoundLeader returns the round leader

func (*Instance) UponPrePrepareMsg

func (i *Instance) UponPrePrepareMsg() pipeline.Pipeline

UponPrePrepareMsg Algorithm 2 IBFT 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 InstanceOptions

type InstanceOptions struct {
	Logger         *zap.Logger
	ValidatorShare *storage.Share
	//Me             *proto.Node
	Network        network.Network
	Queue          *msgqueue.MessageQueue
	ValueCheck     valcheck.ValueCheck
	LeaderSelector leader.Selector
	Config         *proto.InstanceConfig
	Lambda         []byte
	SeqNumber      uint64
}

InstanceOptions defines option attributes for the Instance

type StartOptions

type StartOptions struct {
	Logger         *zap.Logger
	ValueCheck     valcheck.ValueCheck
	PrevInstance   []byte
	Identifier     []byte
	SeqNumber      uint64
	Value          []byte
	Duty           *ethpb.DutiesResponse_Duty
	ValidatorShare storage.Share
}

StartOptions defines type for IBFT instance options

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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