instance

package
v1.3.3 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CutoffRound = 15 // stop processing instances after 8*2+120*6 = 14.2 min (~ 2 epochs)

Functions

func BaseCommitValidation

func BaseCommitValidation(
	config qbft.IConfig,
	signedCommit *specqbft.SignedMessage,
	height specqbft.Height,
	operators []*spectypes.Operator,
) error

func Compact added in v0.4.7

func Compact(state *specqbft.State, decidedMessage *specqbft.SignedMessage)

Compact trims the given qbft.State down to the minimum required for consensus to proceed.

Compact always discards message from previous rounds. Compact discards all non-commit messages, only if the given state is decided.

This helps reduce the state's memory footprint.

func CompactCopy added in v0.4.7

func CompactCopy(state *specqbft.State, decidedMessage *specqbft.SignedMessage) *specqbft.State

CompactCopy returns a compacted copy of the given qbft.State. CompactCopy is guaranteed to not modify the given state, but the returned state may be modified when the given state is modified.

TODO: this is a temporary solution to not break spec-tests. Revert this once spec is aligned.

See Compact for more details.

func CreateCommit

func CreateCommit(state *specqbft.State, config qbft.IConfig, root [32]byte) (*specqbft.SignedMessage, error)

CreateCommit * Commit(

signCommit(
    UnsignedCommit(
        |current.blockchain|,
        current.round,
        signHash(hashBlockForCommitSeal(proposedBlock), current.id),
        digest(proposedBlock)),
        current.id
    )
);

func CreatePrepare

func CreatePrepare(state *specqbft.State, config qbft.IConfig, newRound specqbft.Round, root [32]byte) (*specqbft.SignedMessage, error)

CreatePrepare * Prepare(

    signPrepare(
        UnsignedPrepare(
            |current.blockchain|,
            newRound,
            digest(m.proposedBlock)),
        current.id
        )
);

func CreateProposal

func CreateProposal(state *specqbft.State, config qbft.IConfig, fullData []byte, roundChanges, prepares []*specqbft.SignedMessage) (*specqbft.SignedMessage, error)

CreateProposal *

	Proposal(
                      signProposal(
                          UnsignedProposal(
                              |current.blockchain|,
                              newRound,
                              digest(block)),
                          current.id),
                      block,
                      extractSignedRoundChanges(roundChanges),
                      extractSignedPrepares(prepares));

func CreateRoundChange

func CreateRoundChange(state *specqbft.State, config qbft.IConfig, newRound specqbft.Round, instanceStartValue []byte) (*specqbft.SignedMessage, error)

CreateRoundChange * RoundChange(

    signRoundChange(
        UnsignedRoundChange(
            |current.blockchain|,
            newRound,
            digestOptionalBlock(current.lastPreparedBlock),
            current.lastPreparedRound),
    current.id),
    current.lastPreparedBlock,
    getRoundChangeJustification(current)
)

func IsProposalJustification added in v1.1.0

func IsProposalJustification(
	config qbft.IConfig,
	share *ssvtypes.SSVShare,
	roundChangeMsgs []*specqbft.SignedMessage,
	prepareMsgs []*specqbft.SignedMessage,
	height specqbft.Height,
	round specqbft.Round,
	fullData []byte,
) error

Types

type Instance

type Instance struct {
	State *specqbft.State

	StartValue []byte
	// contains filtered or unexported fields
}

Instance is a single QBFT instance that starts with a Start call (including a value). Every new msg the ProcessMsg function needs to be called

func NewInstance

func NewInstance(
	config qbft.IConfig,
	share *spectypes.Share,
	identifier []byte,
	height specqbft.Height,
) *Instance

func (*Instance) BaseMsgValidation

func (i *Instance) BaseMsgValidation(msg *specqbft.SignedMessage) error

func (*Instance) Broadcast

func (i *Instance) Broadcast(logger *zap.Logger, msg *specqbft.SignedMessage) error

func (*Instance) CanProcessMessages added in v1.1.0

func (i *Instance) CanProcessMessages() bool

CanProcessMessages will return true if instance can process messages

func (*Instance) Decode

func (i *Instance) Decode(data []byte) error

Decode implementation

func (*Instance) Encode

func (i *Instance) Encode() ([]byte, error)

Encode implementation

func (*Instance) ForceStop added in v1.1.0

func (i *Instance) ForceStop()

func (*Instance) GetConfig

func (i *Instance) GetConfig() qbft.IConfig

GetConfig returns the instance config

func (*Instance) GetHeight

func (i *Instance) GetHeight() specqbft.Height

GetHeight interface implementation

func (*Instance) GetRoot

func (i *Instance) GetRoot() ([32]byte, error)

GetRoot returns the state's deterministic root

func (*Instance) IsDecided

func (i *Instance) IsDecided() (bool, []byte)

IsDecided interface implementation

func (*Instance) MarshalJSON added in v1.1.0

func (i *Instance) MarshalJSON() ([]byte, error)

MarshalJSON is a custom JSON marshaller for Instance

func (*Instance) ProcessMsg

func (i *Instance) ProcessMsg(logger *zap.Logger, msg *specqbft.SignedMessage) (decided bool, decidedValue []byte, aggregatedCommit *specqbft.SignedMessage, err error)

ProcessMsg processes a new QBFT msg, returns non nil error on msg processing error

func (*Instance) SetConfig

func (i *Instance) SetConfig(config qbft.IConfig)

SetConfig returns the instance config

func (*Instance) Start

func (i *Instance) Start(logger *zap.Logger, value []byte, height specqbft.Height)

Start is an interface implementation

func (*Instance) UnmarshalJSON added in v1.1.0

func (i *Instance) UnmarshalJSON(data []byte) error

UnmarshalJSON is a custom JSON unmarshaller for Instance

func (*Instance) UponCommit

func (i *Instance) UponCommit(logger *zap.Logger, signedCommit *specqbft.SignedMessage, commitMsgContainer *specqbft.MsgContainer) (bool, []byte, *specqbft.SignedMessage, error)

UponCommit returns true if a quorum of commit messages was received. Assumes commit message is valid!

func (*Instance) UponRoundTimeout

func (i *Instance) UponRoundTimeout(logger *zap.Logger) error

Jump to

Keyboard shortcuts

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