Documentation ¶
Overview ¶
Implementation of signature based binary consensus algorithm.
Index ¶
- func CreateAuxProofItems(idx types.ConsensusIndex, round types.ConsensusRound, binVal types.BinVal, ...) []*deserialized.DeserializedItem
- func GetBinConsCommitProof(headerID messages.HeaderID, sc cons.BinConsInterface, ...) []messages.MsgHeader
- type BinCons1
- func (sc *BinCons1) CanSkipMvTimeout() bool
- func (sc *BinCons1) CanStartNext() bool
- func (sc *BinCons1) CheckRound(nmt int, t int, round types.ConsensusRound, ...) bool
- func (sc *BinCons1) Collect()
- func (*BinCons1) GenerateMessageState(gc *generalconfig.GeneralConfig) consinterface.MessageState
- func (*BinCons1) GenerateNewItem(index types.ConsensusIndex, items *consinterface.ConsInterfaceItems, ...) consinterface.ConsItem
- func (sc *BinCons1) GetBinDecided() (int, types.ConsensusRound)
- func (sc *BinCons1) GetBinState(localOnly bool) ([]byte, error)
- func (*BinCons1) GetBufferCount(hdr messages.MsgIDHeader, _ *generalconfig.GeneralConfig, ...) (int, int, messages.MsgID, error)
- func (sc *BinCons1) GetCommitProof() []messages.MsgHeader
- func (sc *BinCons1) GetConsType() types.ConsType
- func (sc *BinCons1) GetDecision() (sig.Pub, []byte, types.ConsensusIndex, types.ConsensusIndex)
- func (*BinCons1) GetHeader(emptyPub sig.Pub, _ *generalconfig.GeneralConfig, headerType messages.HeaderID) (messages.MsgHeader, error)
- func (sc *BinCons1) GetMVInitialRoundBroadcast(val types.BinVal) messages.InternalSignedMsgHeader
- func (sc *BinCons1) GetNextInfo() (prevIdx types.ConsensusIndex, proposer sig.Pub, preDecision []byte, ...)
- func (sc *BinCons1) GetProposalIndex() (prevIdx types.ConsensusIndex, ready bool)
- func (sc *BinCons1) GetProposeHeaderID() messages.HeaderID
- func (sc *BinCons1) GotProposal(hdr messages.MsgHeader, mainChannel channelinterface.MainChannel) error
- func (sc *BinCons1) HasDecided() bool
- func (sc *BinCons1) HasValidStarted() bool
- func (sc *BinCons1) NeedsCompletionConcurrentProposals() types.ConsensusInt
- func (sc *BinCons1) PrevHasBeenReset()
- func (sc *BinCons1) ProcessMessage(deser *deserialized.DeserializedItem, isLocal bool, ...) (bool, bool)
- func (sc *BinCons1) SetInitialState([]byte, storage.StoreInterface)
- func (sc *BinCons1) SetNextConsItem(_ consinterface.ConsItem)
- func (sc *BinCons1) ShouldCreatePartial(_ messages.HeaderID) bool
- func (sc *BinCons1) Start(finishedLastRound bool)
- type BinConsMessageStateInterface
- type Config
- type MessageState
- func (sms *MessageState) GenerateProofs(headerID messages.HeaderID, sigCount int, round types.ConsensusRound, ...) ([]*sig.MultipleSignedMessage, error)
- func (sms *MessageState) GetBinMsgState() BinConsMessageStateInterface
- func (sms *MessageState) GetProofs(headerID messages.HeaderID, sigCount int, round types.ConsensusRound, ...) ([]*sig.MultipleSignedMessage, error)
- func (sms *MessageState) GetValidMessageCount(round types.ConsensusRound, _ *consinterface.MemCheckers) int
- func (sms *MessageState) GotMsg(hdrFunc consinterface.HeaderFunc, deser *deserialized.DeserializedItem, ...) ([]*deserialized.DeserializedItem, error)
- func (sms *MessageState) Lock()
- func (sms *MessageState) New(idx types.ConsensusIndex) consinterface.MessageState
- func (sms *MessageState) SentProposal(round types.ConsensusRound, shouldSet bool, _ *consinterface.MemCheckers) bool
- func (sms *MessageState) SetMv0Valid()
- func (sms *MessageState) SetMv1Valid(_ *consinterface.MemCheckers)
- func (sms *MessageState) SetSimpleMessageStateWrapper(sm *messagestate.SimpleMessageStateWrapper)
- func (sms *MessageState) Unlock()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateAuxProofItems ¶
func CreateAuxProofItems(idx types.ConsensusIndex, round types.ConsensusRound, binVal types.BinVal, bct cons.ConsTestItems, t *testing.T) []*deserialized.DeserializedItem
CreateAuxProofItems is used during unit tests to create a list of signed message supporting a binvalue and round.
func GetBinConsCommitProof ¶
func GetBinConsCommitProof(headerID messages.HeaderID, sc cons.BinConsInterface, binMsgState BinConsMessageStateInterface, shouldLock bool, mc *consinterface.MemCheckers) []messages.MsgHeader
Types ¶
type BinCons1 ¶
type BinCons1 struct { cons.AbsConsItem Decided int // -1 if a value has not yet been decided, 0 if 0 was decided, 1 if 1 was decided SkipTimeoutRound types.ConsensusRound // will not wait for timeouts up to this round IncludeProofs bool // true if messages should include signed values supporting the value in the message // contains filtered or unexported fields }
func (*BinCons1) CanSkipMvTimeout ¶
CanSkipMvTimeout returns true if the during the multivalue reduction the echo timeout can be skipped
func (*BinCons1) CanStartNext ¶
CanStartNext should return true if it is safe to start the next consensus instance (if parallel instances are enabled)
func (*BinCons1) CheckRound ¶
func (sc *BinCons1) CheckRound(nmt int, t int, round types.ConsensusRound, mainChannel channelinterface.MainChannel) bool
CheckRound checks for the given round if enough messages have been received to progress to the next round.
func (*BinCons1) Collect ¶
func (sc *BinCons1) Collect()
Collect is called when the item is being garbage collected.
func (*BinCons1) GenerateMessageState ¶
func (*BinCons1) GenerateMessageState(gc *generalconfig.GeneralConfig) consinterface.MessageState
GenerateMessageState generates a new message state object given the inputs.
func (*BinCons1) GenerateNewItem ¶
func (*BinCons1) GenerateNewItem(index types.ConsensusIndex, items *consinterface.ConsInterfaceItems, mainChannel channelinterface.MainChannel, prevItem consinterface.ConsItem, broadcastFunc consinterface.ByzBroadcastFunc, gc *generalconfig.GeneralConfig) consinterface.ConsItem
GenerateNewItem creates a new bin cons item.
func (*BinCons1) GetBinDecided ¶
func (sc *BinCons1) GetBinDecided() (int, types.ConsensusRound)
GetBinDecided returns -1 if not decided, or the decided value and the decided round
func (*BinCons1) GetBinState ¶
GetBinState returns the entire state of the consensus as a string of bytes using MessageState.GetMsgState() as the list of all messages, with a messagetypes.ConsBinStateMessage header appended to the beginning).
func (*BinCons1) GetBufferCount ¶
func (*BinCons1) GetBufferCount(hdr messages.MsgIDHeader, _ *generalconfig.GeneralConfig, memberChecker *consinterface.MemCheckers) (int, int, messages.MsgID, error)
GetBufferCount checks a MessageID and returns the thresholds for which it should be forwarded using the BufferForwarder (see forwardchecker.ForwardChecker interface). Here the only message type is messages.HdrAuxProof, it returns n-t, n for the thresholds.
func (*BinCons1) GetCommitProof ¶
GetCommitProof returns a signed message header that counts at the commit message for this consensus.
func (*BinCons1) GetConsType ¶
GetConsType returns the type of consensus this instance implements.
func (*BinCons1) GetDecision ¶
func (sc *BinCons1) GetDecision() (sig.Pub, []byte, types.ConsensusIndex, types.ConsensusIndex)
GetDecision returns the binary value decided as a single byte slice.
func (*BinCons1) GetHeader ¶
func (*BinCons1) GetHeader(emptyPub sig.Pub, _ *generalconfig.GeneralConfig, headerType messages.HeaderID) ( messages.MsgHeader, error)
GetHeader return blank message header for the HeaderID, this object will be used to deserialize a message into itself (see consinterface.DeserializeMessage). Here only messages.HdrAuxProof are valid headerIDs.
func (*BinCons1) GetMVInitialRoundBroadcast ¶
func (sc *BinCons1) GetMVInitialRoundBroadcast(val types.BinVal) messages.InternalSignedMsgHeader
GetMVInitialRoundBroadcast returns the type of binary message that the multi-value reduction should broadcast for round 0.
func (*BinCons1) GetNextInfo ¶
func (sc *BinCons1) GetNextInfo() (prevIdx types.ConsensusIndex, proposer sig.Pub, preDecision []byte, hasNextInfo bool)
GetNextInfo will be called after CanStartNext returns true. It returns sc.Index - 1, nil. If false is returned then the next is started, but the current instance has no state machine created.
func (*BinCons1) GetProposalIndex ¶
func (sc *BinCons1) GetProposalIndex() (prevIdx types.ConsensusIndex, ready bool)
GetProposalIndex returns sc.Index - 1. It returns false until start is called.
func (*BinCons1) GetProposeHeaderID ¶
GetProposeHeaderID returns the HeaderID messages.HdrBinPropose that will be input to GotProposal.
func (*BinCons1) GotProposal ¶
func (sc *BinCons1) GotProposal(hdr messages.MsgHeader, mainChannel channelinterface.MainChannel) error
GotProposal takes the proposal, creates a round 0 AuxProofMessage and broadcasts it.
func (*BinCons1) HasDecided ¶
HasDecided should return true if this consensus item has reached a decision.
func (*BinCons1) HasValidStarted ¶
HasReceivedProposal panics because BonCons has no proposals.
func (*BinCons1) NeedsCompletionConcurrentProposals ¶
func (sc *BinCons1) NeedsCompletionConcurrentProposals() types.ConsensusInt
NeedsConcurrent returns 1.
func (*BinCons1) PrevHasBeenReset ¶
func (sc *BinCons1) PrevHasBeenReset()
PrevHasBeenReset is called when the previous consensus index has been reset to a new index
func (*BinCons1) ProcessMessage ¶
func (sc *BinCons1) ProcessMessage( deser *deserialized.DeserializedItem, isLocal bool, _ *channelinterface.SendRecvChannel) (bool, bool)
ProcessMessage is called on every message once it has been checked that it is a valid message (using the static method ConsItem.DerserializeMessage), that it comes from a member of the consensus and that it is not a duplicate message (using the MemberChecker and MessageState objects). This function processes the message and update the state of the consensus. For this consensus implementation messageState must be an instance of BinConsMessageStateInterface. It returns true in first position if made progress towards decision, or false if already decided, and return true in second position if the message should be forwarded. It processes AuxProofTimeout messages and AuxProof messages, moving through the rounds of consensus until a decision.
func (*BinCons1) SetInitialState ¶
func (sc *BinCons1) SetInitialState([]byte, storage.StoreInterface)
SetInitialState does noting for this algorithm.
func (*BinCons1) SetNextConsItem ¶
func (sc *BinCons1) SetNextConsItem(_ consinterface.ConsItem)
SetNextConsItem gives a pointer to the next consensus item at the next consensus instance, it is called when the next instance is created
func (*BinCons1) ShouldCreatePartial ¶
ShouldCreatePartial returns true if the message type should be sent as a partial message
type BinConsMessageStateInterface ¶
type BinConsMessageStateInterface interface { Lock() Unlock() // GetBinMsgState returns the base bin message state. GetBinMsgState() BinConsMessageStateInterface // GenerateProofs generates an auxProofMessage containing signatures supporting binVal and round. GenerateProofs(headerID messages.HeaderID, sigCount int, round types.ConsensusRound, binVal types.BinVal, pub sig.Pub, mc *consinterface.MemCheckers) ([]*sig.MultipleSignedMessage, error) // GetProofs generates an AuxProofMessage containing the signatures received for binVal in round round. GetProofs(headerID messages.HeaderID, sigCount int, round types.ConsensusRound, binVal types.BinVal, pub sig.Pub, mc *consinterface.MemCheckers) ([]*sig.MultipleSignedMessage, error) // See consinterface.MessageState.New New(idx types.ConsensusIndex) consinterface.MessageState // See as consinterface.MessageState.GotMsg GotMsg(hdrFunc consinterface.HeaderFunc, deser *deserialized.DeserializedItem, gc *generalconfig.GeneralConfig, mc *consinterface.MemCheckers) ([]*deserialized.DeserializedItem, error) // SetMv0Valid is called by the multivalue reduction MvCons1, when 0 becomes valid for round 1 SetMv0Valid() // SetMv1Valid is called by the multivalue reduction MvCons1, when 1 becomes valid for round 1 SetMv1Valid(mc *consinterface.MemCheckers) // sentProposal returns true if a proposal has been sent for round+1 (i.e. the following round) // if shouldSet is true, then sets to having sent the proposal for that round to true SentProposal(round types.ConsensusRound, shouldSet bool, mc *consinterface.MemCheckers) bool // SetSimpleMessageStateWrapper sets the simple message state object, this is used by the multivale reduction MvCons1 since they share the // same simple message state. SetSimpleMessageStateWrapper(sm *messagestate.SimpleMessageStateWrapper) // GetValidMessage count returns the number of signed AuxProofMessages received from different processes in round round. GetValidMessageCount(round types.ConsensusRound, mc *consinterface.MemCheckers) int }
BinConsMessageStateInterface extends the messagestate.MessageState interface with some addition operations for the storage of messages specific to BinCons1. Note that operations can be called from multiple threads. The public methods are concurrency safe, the others should be synchronized as needed.
type Config ¶
type Config struct {
cons.StandardBinConfig
}
func (Config) GetIncludeProofsTypes ¶
func (Config) GetIncludeProofsTypes(gt cons.GetOptionType) []bool
GetIncludeProofTypes returns the values for if the consensus supports including proofs or not or both.
type MessageState ¶
type MessageState struct { *messagestate.SimpleMessageStateWrapper // the simple message state is used to track the actual messages // contains filtered or unexported fields }
BinCons1MessageState implements BinConsMessageStateInterface. It stores the messages of BinCons1.
func NewBinCons1MessageState ¶
func NewBinCons1MessageState(isMv bool, gc *generalconfig.GeneralConfig) *MessageState
NewBinCons1MessageState generates a new BinCons1MessageState object.
func (*MessageState) GenerateProofs ¶
func (sms *MessageState) GenerateProofs(headerID messages.HeaderID, sigCount int, round types.ConsensusRound, binVal types.BinVal, pub sig.Pub, mc *consinterface.MemCheckers) ([]*sig.MultipleSignedMessage, error)
generateProofs generates an auxProofMessage containing signatures supporting binVal and round.
func (*MessageState) GetBinMsgState ¶
func (sms *MessageState) GetBinMsgState() BinConsMessageStateInterface
GetBinMsgState returns the base bin message state.
func (*MessageState) GetProofs ¶
func (sms *MessageState) GetProofs(headerID messages.HeaderID, sigCount int, round types.ConsensusRound, binVal types.BinVal, _ sig.Pub, mc *consinterface.MemCheckers) ([]*sig.MultipleSignedMessage, error)
GetProofs generates an AuxProofMessage continaining the signatures received for binVal in round round.
func (*MessageState) GetValidMessageCount ¶
func (sms *MessageState) GetValidMessageCount(round types.ConsensusRound, _ *consinterface.MemCheckers) int
GetValidMessage count returns the number of signed AuxProofMessages received from different processes in round round.
func (*MessageState) GotMsg ¶
func (sms *MessageState) GotMsg(hdrFunc consinterface.HeaderFunc, deser *deserialized.DeserializedItem, gc *generalconfig.GeneralConfig, mc *consinterface.MemCheckers) ([]*deserialized.DeserializedItem, error)
GotMessage takes a deserialized message and the member checker for the current consensus index. If the message contains no new valid signatures then an error is returned. The value newTotalSigCount is the new number of signatures for the specific message, the value newMsgIDSigCount is the number of signatures for the MsgID of the message (see messages.MsgID). The message must be an AuxProofMessage, since that is the only valid message type for BinCons1.
func (*MessageState) New ¶
func (sms *MessageState) New(idx types.ConsensusIndex) consinterface.MessageState
New creates a new empty BinCons1MessageState object for the consensus index idx.
func (*MessageState) SentProposal ¶
func (sms *MessageState) SentProposal(round types.ConsensusRound, shouldSet bool, _ *consinterface.MemCheckers) bool
sentProposal returns true if a proposal has been sent for round+1 (i.e. the following round) if shouldSet is true, then sets to having sent the proposal for that round to true
func (*MessageState) SetMv0Valid ¶
func (sms *MessageState) SetMv0Valid()
SetMv0Valid is called by the multivalue reduction MvCons1, when 0 becomes valid for round 1
func (*MessageState) SetMv1Valid ¶
func (sms *MessageState) SetMv1Valid(_ *consinterface.MemCheckers)
SetMv1Valid is called by the multivalue reduction MvCons1, when 1 becomes valid for round 1
func (*MessageState) SetSimpleMessageStateWrapper ¶
func (sms *MessageState) SetSimpleMessageStateWrapper(sm *messagestate.SimpleMessageStateWrapper)
SetSimpleMessageStateWrapper sets the simple message state object, this is used by the multivale reduction MvCons1 since they share the same simple message state.