Documentation
¶
Overview ¶
Code generated by fastssz. DO NOT EDIT. Hash: 6732475e30a3885e05ad0c04dfd8b3ca58aae4ebd22fa32781bb39c9d2f307c2 Version: 0.1.3
Index ¶
- Constants
- Variables
- func ControllerIdToMessageID(identifier []byte) types.MessageID
- func CreateCommit(state *State, signer *types.OperatorSigner, root [32]byte) (*types.SignedSSVMessage, error)
- func CreatePrepare(state *State, signer *types.OperatorSigner, newRound Round, root [32]byte) (*types.SignedSSVMessage, error)
- func CreateProposal(state *State, signer *types.OperatorSigner, fullData []byte, ...) (*types.SignedSSVMessage, error)
- func CreateRoundChange(state *State, signer *types.OperatorSigner, newRound Round, ...) (*types.SignedSSVMessage, error)
- func HasPartialQuorum(share *types.CommitteeMember, msgs []*ProcessingMessage) bool
- func HasQuorum(share *types.CommitteeMember, msgs []*ProcessingMessage) bool
- func HashDataRoot(data []byte) ([32]byte, error)
- func IsDecidedMsg(committeeMember *types.CommitteeMember, msg *ProcessingMessage) (bool, error)
- func MarshalJustifications(msgs []*types.SignedSSVMessage) ([][]byte, error)
- func RoundRobinProposer(state *State, round Round) types.OperatorID
- func Sign(msg *Message, operatorID types.OperatorID, ...) (*types.SignedSSVMessage, error)
- func ValidateDecided(config IConfig, msg *ProcessingMessage, committeeMember *types.CommitteeMember) error
- type Config
- type Controller
- func (c *Controller) BaseMsgValidation(msg *ProcessingMessage) error
- func (c *Controller) Decode(data []byte) error
- func (c *Controller) Encode() ([]byte, error)
- func (c *Controller) GetConfig() IConfig
- func (c *Controller) GetIdentifier() []byte
- func (c *Controller) GetRoot() ([32]byte, error)
- func (c *Controller) InstanceForHeight(height Height) *Instance
- func (c *Controller) ProcessMsg(signedMessage *types.SignedSSVMessage) (*types.SignedSSVMessage, error)
- func (c *Controller) StartNewInstance(height Height, value []byte) error
- func (c *Controller) UponDecided(msg *ProcessingMessage) (*types.SignedSSVMessage, error)
- func (c *Controller) UponExistingInstanceMsg(msg *ProcessingMessage) (*types.SignedSSVMessage, error)
- type Height
- type IConfig
- type Instance
- func (i *Instance) BaseMsgValidation(msg *ProcessingMessage) error
- func (i *Instance) Broadcast(msg *types.SignedSSVMessage) error
- func (i *Instance) CanProcessMessages() bool
- func (i *Instance) Decode(data []byte) error
- func (i *Instance) Encode() ([]byte, error)
- func (i *Instance) ForceStop()
- func (i *Instance) GetConfig() IConfig
- func (i *Instance) GetHeight() Height
- func (i *Instance) GetRoot() ([32]byte, error)
- func (i *Instance) IsDecided() (bool, []byte)
- func (i *Instance) MarshalJSON() ([]byte, error)
- func (i *Instance) ProcessMsg(msg *ProcessingMessage) (decided bool, decidedValue []byte, aggregatedCommit *types.SignedSSVMessage, ...)
- func (i *Instance) Start(value []byte, height Height)
- func (i *Instance) UnmarshalJSON(data []byte) error
- func (i *Instance) UponCommit(msg *ProcessingMessage, commitMsgContainer *MsgContainer) (bool, []byte, *types.SignedSSVMessage, error)
- func (i *Instance) UponRoundTimeout() error
- type InstanceContainer
- type Message
- func (msg *Message) Decode(data []byte) error
- func (msg *Message) Encode() ([]byte, error)
- func (msg *Message) GetPrepareJustifications() ([]*types.SignedSSVMessage, error)
- func (msg *Message) GetRoot() ([32]byte, error)
- func (msg *Message) GetRoundChangeJustifications() ([]*types.SignedSSVMessage, error)
- func (m *Message) GetTree() (*ssz.Node, error)
- func (m *Message) HashTreeRoot() ([32]byte, error)
- func (m *Message) HashTreeRootWith(hh ssz.HashWalker) (err error)
- func (m *Message) MarshalSSZ() ([]byte, error)
- func (m *Message) MarshalSSZTo(buf []byte) (dst []byte, err error)
- func (msg *Message) RoundChangePrepared() bool
- func (m *Message) SizeSSZ() (size int)
- func (m *Message) UnmarshalSSZ(buf []byte) error
- func (msg *Message) Validate() error
- type MessageType
- type MsgContainer
- func (c *MsgContainer) AddFirstMsgForSignerAndRound(msg *ProcessingMessage) (bool, error)
- func (c *MsgContainer) AddMsg(msg *ProcessingMessage) error
- func (c *MsgContainer) AllMessages() []*ProcessingMessage
- func (c *MsgContainer) Decode(data []byte) error
- func (c *MsgContainer) Encode() ([]byte, error)
- func (c *MsgContainer) GetRoot() ([32]byte, error)
- func (c *MsgContainer) LongestUniqueSignersForRoundAndRoot(round Round, root [32]byte) ([]types.OperatorID, []*ProcessingMessage)
- func (c *MsgContainer) MessagesForRound(round Round) []*ProcessingMessage
- func (c *MsgContainer) MessagesForRoundAndRoot(round Round, root [32]byte) []*ProcessingMessage
- type Network
- type ProcessingMessage
- type ProposedValueCheckF
- type ProposerF
- type Round
- type State
- type Timer
Constants ¶
const ( NoRound Round = 0 // NoRound represents a nil/ zero round FirstRound Round = 1 // FirstRound value is the first round in any QBFT instance start FirstHeight Height = 0 )
Variables ¶
var ( QuickTimeoutThreshold = Round(8) QuickTimeout = 2 * time.Second SlowTimeout = 2 * time.Minute // CutoffRound which round the instance should stop its timer and progress no further CutoffRound = 12 // stop processing attestations after 8*2+120*3 = 6.2 min (~ 1 epoch) )
At the moment, these variables are useful for the node implementation TODO: It's usage should be updated in the PR https://github.com/ssvlabs/ssv-spec/pull/352
Functions ¶
func ControllerIdToMessageID ¶
func CreateCommit ¶
func CreateCommit(state *State, signer *types.OperatorSigner, root [32]byte) (*types.SignedSSVMessage, error)
CreateCommit * Commit(
signCommit( UnsignedCommit( |current.blockchain|, current.round, signHash(hashBlockForCommitSeal(proposedBlock), current.id), digest(proposedBlock)), current.id ) );
func CreatePrepare ¶
func CreatePrepare(state *State, signer *types.OperatorSigner, newRound Round, root [32]byte) (*types.SignedSSVMessage, error)
CreatePrepare * Prepare(
signPrepare( UnsignedPrepare( |current.blockchain|, newRound, digest(m.proposedBlock)), current.id ) );
func CreateProposal ¶
func CreateProposal(state *State, signer *types.OperatorSigner, fullData []byte, roundChanges, prepares []*ProcessingMessage) (*types.SignedSSVMessage, error)
CreateProposal *
Proposal( signProposal( UnsignedProposal( |current.blockchain|, newRound, digest(block)), current.id), block, extractSignedRoundChanges(roundChanges), extractSignedPrepares(prepares));
func CreateRoundChange ¶
func CreateRoundChange(state *State, signer *types.OperatorSigner, newRound Round, instanceStartValue []byte) (*types.SignedSSVMessage, error)
CreateRoundChange * RoundChange(
signRoundChange( UnsignedRoundChange( |current.blockchain|, newRound, digestOptionalBlock(current.lastPreparedBlock), current.lastPreparedRound), current.id), current.lastPreparedBlock, getRoundChangeJustification(current) )
func HasPartialQuorum ¶
func HasPartialQuorum(share *types.CommitteeMember, msgs []*ProcessingMessage) bool
HasPartialQuorum returns true if a unique set of signers has partial quorum
func HasQuorum ¶
func HasQuorum(share *types.CommitteeMember, msgs []*ProcessingMessage) bool
HasQuorum returns true if a unique set of signers has quorum
func HashDataRoot ¶
HashDataRoot hashes input data to root
func IsDecidedMsg ¶
func IsDecidedMsg(committeeMember *types.CommitteeMember, msg *ProcessingMessage) (bool, error)
IsDecidedMsg returns true if signed commit has all quorum sigs
func MarshalJustifications ¶
func MarshalJustifications(msgs []*types.SignedSSVMessage) ([][]byte, error)
func RoundRobinProposer ¶
func RoundRobinProposer(state *State, round Round) types.OperatorID
RoundRobinProposer returns the proposer for the round. Each new height starts with the first proposer and increments by 1 with each following round. Each new height has a different first round proposer which is +1 from the previous height. First height starts with index 0
func Sign ¶ added in v1.0.0
func Sign(msg *Message, operatorID types.OperatorID, operatorSigner *types.OperatorSigner) (*types.SignedSSVMessage, error)
func ValidateDecided ¶
func ValidateDecided( config IConfig, msg *ProcessingMessage, committeeMember *types.CommitteeMember, ) error
Types ¶
type Config ¶
type Config struct { Domain types.DomainType ValueCheckF ProposedValueCheckF ProposerF ProposerF Network Network Timer Timer CutOffRound Round }
func (*Config) GetCutOffRound ¶ added in v1.0.0
func (*Config) GetNetwork ¶
GetNetwork returns a p2p Network instance
func (*Config) GetProposerF ¶
GetProposerF returns func used to calculate proposer
func (*Config) GetSignatureDomainType ¶
func (c *Config) GetSignatureDomainType() types.DomainType
GetSignatureDomainType returns the Domain type used for signatures
func (*Config) GetValueCheckF ¶
func (c *Config) GetValueCheckF() ProposedValueCheckF
GetValueCheckF returns value check instance
type Controller ¶
type Controller struct { Identifier []byte Height Height // incremental Height for InstanceContainer // StoredInstances stores the last HistoricalInstanceCapacity in an array for message processing purposes. StoredInstances InstanceContainer CommitteeMember *types.CommitteeMember OperatorSigner *types.OperatorSigner `json:"-"` // contains filtered or unexported fields }
Controller is a QBFT coordinator responsible for starting and following the entire life cycle of multiple QBFT InstanceContainer
func NewController ¶
func NewController(identifier []byte, committeeMember *types.CommitteeMember, config IConfig, signer *types.OperatorSigner) *Controller
func (*Controller) BaseMsgValidation ¶
func (c *Controller) BaseMsgValidation(msg *ProcessingMessage) error
BaseMsgValidation returns error if msg is invalid (base validation)
func (*Controller) Decode ¶
func (c *Controller) Decode(data []byte) error
func (*Controller) GetConfig ¶
func (c *Controller) GetConfig() IConfig
func (*Controller) GetIdentifier ¶
func (c *Controller) GetIdentifier() []byte
GetIdentifier returns QBFT Identifier, used to identify messages
func (*Controller) GetRoot ¶
func (c *Controller) GetRoot() ([32]byte, error)
func (*Controller) InstanceForHeight ¶
func (c *Controller) InstanceForHeight(height Height) *Instance
func (*Controller) ProcessMsg ¶
func (c *Controller) ProcessMsg(signedMessage *types.SignedSSVMessage) (*types.SignedSSVMessage, error)
ProcessMsg processes a new msg, returns decided message or error
func (*Controller) StartNewInstance ¶
func (c *Controller) StartNewInstance(height Height, value []byte) error
StartNewInstance will start a new QBFT instance, if can't will return error
func (*Controller) UponDecided ¶
func (c *Controller) UponDecided(msg *ProcessingMessage) (*types.SignedSSVMessage, error)
UponDecided returns decided msg if decided, nil otherwise
func (*Controller) UponExistingInstanceMsg ¶
func (c *Controller) UponExistingInstanceMsg(msg *ProcessingMessage) (*types.SignedSSVMessage, error)
type IConfig ¶
type IConfig interface { // GetValueCheckF returns value check function GetValueCheckF() ProposedValueCheckF // GetProposerF returns func used to calculate proposer GetProposerF() ProposerF // GetNetwork returns a p2p Network instance GetNetwork() Network // GetTimer returns round timer GetTimer() Timer // GetCutOffRound returns the round that stops the instance GetCutOffRound() Round }
type Instance ¶
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 IConfig, committeeMember *types.CommitteeMember, identifier []byte, height Height, signer *types.OperatorSigner, ) *Instance
func (*Instance) BaseMsgValidation ¶
func (i *Instance) BaseMsgValidation(msg *ProcessingMessage) error
func (*Instance) CanProcessMessages ¶
CanProcessMessages will return true if instance can process messages
func (*Instance) MarshalJSON ¶
MarshalJSON is a custom JSON marshaller for Instance
func (*Instance) ProcessMsg ¶
func (i *Instance) ProcessMsg(msg *ProcessingMessage) (decided bool, decidedValue []byte, aggregatedCommit *types.SignedSSVMessage, err error)
ProcessMsg processes a new QBFT msg, returns non nil error on msg processing error
func (*Instance) UnmarshalJSON ¶
UnmarshalJSON is a custom JSON unmarshaller for Instance
func (*Instance) UponCommit ¶
func (i *Instance) UponCommit(msg *ProcessingMessage, commitMsgContainer *MsgContainer) (bool, []byte, *types.SignedSSVMessage, error)
UponCommit returns true if a quorum of commit messages was received. Assumes commit message is valid!
func (*Instance) UponRoundTimeout ¶
type InstanceContainer ¶
type InstanceContainer []*Instance
func (InstanceContainer) FindInstance ¶
func (i InstanceContainer) FindInstance(height Height) *Instance
type Message ¶
type Message struct { MsgType MessageType Height Height // QBFT instance Height Round Round // QBFT round for which the msg is for Identifier []byte `ssz-max:"56"` // instance Identifier this msg belongs to Root [32]byte `ssz-size:"32"` DataRound Round // The last round that obtained a Prepare quorum RoundChangeJustification [][]byte `ssz-max:"13,51852"` PrepareJustification [][]byte `ssz-max:"13,3700"` }
func DecodeMessage ¶ added in v1.0.0
Creates a Message object from bytes
func (*Message) GetPrepareJustifications ¶
func (msg *Message) GetPrepareJustifications() ([]*types.SignedSSVMessage, error)
func (*Message) GetRoundChangeJustifications ¶
func (msg *Message) GetRoundChangeJustifications() ([]*types.SignedSSVMessage, error)
func (*Message) HashTreeRoot ¶
HashTreeRoot ssz hashes the Message object
func (*Message) HashTreeRootWith ¶
func (m *Message) HashTreeRootWith(hh ssz.HashWalker) (err error)
HashTreeRootWith ssz hashes the Message object with a hasher
func (*Message) MarshalSSZ ¶
MarshalSSZ ssz marshals the Message object
func (*Message) MarshalSSZTo ¶
MarshalSSZTo ssz marshals the Message object to a target array
func (*Message) RoundChangePrepared ¶
RoundChangePrepared returns true if message is a RoundChange and prepared
func (*Message) UnmarshalSSZ ¶
UnmarshalSSZ ssz unmarshals the Message object
type MessageType ¶
type MessageType uint64
const ( ProposalMsgType MessageType = iota PrepareMsgType CommitMsgType RoundChangeMsgType )
type MsgContainer ¶
type MsgContainer struct {
Msgs map[Round][]*ProcessingMessage
}
func NewMsgContainer ¶
func NewMsgContainer() *MsgContainer
func (*MsgContainer) AddFirstMsgForSignerAndRound ¶
func (c *MsgContainer) AddFirstMsgForSignerAndRound(msg *ProcessingMessage) (bool, error)
AddFirstMsgForSignerAndRound will add the first msg for each signer for a specific round, consequent msgs will not be added
func (*MsgContainer) AddMsg ¶
func (c *MsgContainer) AddMsg(msg *ProcessingMessage) error
AddMsg will add any message regardless of signers
func (*MsgContainer) AllMessages ¶ added in v1.0.0
func (c *MsgContainer) AllMessages() []*ProcessingMessage
AllMessages returns all messages
func (*MsgContainer) Decode ¶
func (c *MsgContainer) Decode(data []byte) error
func (*MsgContainer) GetRoot ¶ added in v1.0.0
func (c *MsgContainer) GetRoot() ([32]byte, error)
func (*MsgContainer) LongestUniqueSignersForRoundAndRoot ¶
func (c *MsgContainer) LongestUniqueSignersForRoundAndRoot(round Round, root [32]byte) ([]types.OperatorID, []*ProcessingMessage)
LongestUniqueSignersForRoundAndRoot returns the longest set of unique signers and msgs for a specific round and value
func (*MsgContainer) MessagesForRound ¶
func (c *MsgContainer) MessagesForRound(round Round) []*ProcessingMessage
MessagesForRound returns all msgs for Height and round, empty slice otherwise
func (*MsgContainer) MessagesForRoundAndRoot ¶
func (c *MsgContainer) MessagesForRoundAndRoot(round Round, root [32]byte) []*ProcessingMessage
MessagesForRoundAndRoot returns all msgs for round and value, empty slice otherwise
type Network ¶
type Network interface { p2p.Broadcaster }
Network is the interface for networking across QBFT components
type ProcessingMessage ¶ added in v1.0.0
type ProcessingMessage struct { SignedMessage *types.SignedSSVMessage QBFTMessage *Message }
ProcessingMessage stores the network-exchanged signed message and the decoded SignedMessage.SSVMessage.Data (qbft message) The signed message is used at the qbft level since it's used for qbft justifications
func NewProcessingMessage ¶ added in v1.0.0
func NewProcessingMessage(signedMessage *types.SignedSSVMessage) (*ProcessingMessage, error)
NewProcessingMessage creates a ProcessingMessage with the decoded qbft message
func (*ProcessingMessage) Validate ¶ added in v1.0.0
func (msg *ProcessingMessage) Validate() error
Validate checks the signed message and qbft message validation
type ProposedValueCheckF ¶
type State ¶
type State struct { CommitteeMember *types.CommitteeMember ID []byte // instance Identifier Round Round Height Height LastPreparedRound Round LastPreparedValue []byte ProposalAcceptedForCurrentRound *ProcessingMessage Decided bool DecidedValue []byte ProposeContainer *MsgContainer PrepareContainer *MsgContainer CommitContainer *MsgContainer RoundChangeContainer *MsgContainer }