Documentation ¶
Overview ¶
Implementation of signature based binary consensus algorithm.
Index ¶
- func CreateAuxProofItems(idx types.ConsensusIndex, round types.ConsensusRound, allowSupportCoin bool, ...) []*deserialized.DeserializedItem
- func CreateCoinItems(idx types.ConsensusIndex, round types.ConsensusRound, bct cons.ConsTestItems, ...) []*deserialized.DeserializedItem
- type BinConsRnd1
- func (sc *BinConsRnd1) BroadcastCoin(coinMsg messages.MsgHeader, mainChannel channelinterface.MainChannel)
- func (sc *BinConsRnd1) CanSkipMvTimeout() bool
- func (sc *BinConsRnd1) CanStartNext() bool
- func (sc *BinConsRnd1) CheckRound(nmt int, t int, round types.ConsensusRound, ...) bool
- func (*BinConsRnd1) GenerateMessageState(gc *generalconfig.GeneralConfig) consinterface.MessageState
- func (*BinConsRnd1) GenerateNewItem(index types.ConsensusIndex, items *consinterface.ConsInterfaceItems, ...) consinterface.ConsItem
- func (sc *BinConsRnd1) GetBinDecided() (int, types.ConsensusRound)
- func (sc *BinConsRnd1) GetBinState(localOnly bool) ([]byte, error)
- func (*BinConsRnd1) GetBufferCount(hdr messages.MsgIDHeader, gc *generalconfig.GeneralConfig, ...) (int, int, messages.MsgID, error)
- func (sc *BinConsRnd1) GetCommitProof() []messages.MsgHeader
- func (sc *BinConsRnd1) GetConsType() types.ConsType
- func (sc *BinConsRnd1) GetDecision() (sig.Pub, []byte, types.ConsensusIndex, types.ConsensusIndex)
- func (sc *BinConsRnd1) GetHeader(emptyPub sig.Pub, gc *generalconfig.GeneralConfig, ...) (messages.MsgHeader, error)
- func (sc *BinConsRnd1) GetMVInitialRoundBroadcast(val types.BinVal) messages.InternalSignedMsgHeader
- func (sc *BinConsRnd1) GetNextInfo() (prevIdx types.ConsensusIndex, proposer sig.Pub, preDecision []byte, ...)
- func (sc *BinConsRnd1) GetProposalIndex() (prevIdx types.ConsensusIndex, ready bool)
- func (sc *BinConsRnd1) GetProposeHeaderID() messages.HeaderID
- func (sc *BinConsRnd1) GotProposal(hdr messages.MsgHeader, mainChannel channelinterface.MainChannel) error
- func (sc *BinConsRnd1) HasDecided() bool
- func (sc *BinConsRnd1) HasValidStarted() bool
- func (sc *BinConsRnd1) NeedsCompletionConcurrentProposals() types.ConsensusInt
- func (sc *BinConsRnd1) PrevHasBeenReset()
- func (sc *BinConsRnd1) ProcessMessage(deser *deserialized.DeserializedItem, isLocal bool, ...) (bool, bool)
- func (sc *BinConsRnd1) SetInitialState([]byte, storage.StoreInterface)
- func (sc *BinConsRnd1) SetNextConsItem(_ consinterface.ConsItem)
- func (sc *BinConsRnd1) ShouldCreatePartial(_ messages.HeaderID) bool
- func (sc *BinConsRnd1) Start(finishedLastRound bool)
- type Config
- func (Config) GetAllowSupportCoinTypes(gt cons.GetOptionType) []bool
- func (Config) GetCoinTypes(optionType cons.GetOptionType) []types.CoinType
- func (Config) GetIncludeProofsTypes(gt cons.GetOptionType) []bool
- func (Config) GetRotateCoordTypes(_ cons.GetOptionType) []bool
- func (Config) GetSigTypes(gt cons.GetOptionType) []types.SigType
- func (Config) GetStopOnCommitTypes(optionType cons.GetOptionType) []types.StopOnCommitType
- func (Config) GetUsePubIndexTypes(_ cons.GetOptionType) []bool
- type MessageState
- func (sms *MessageState) GenerateProofs(headerID messages.HeaderID, sigCount int, round types.ConsensusRound, ...) ([]*sig.MultipleSignedMessage, error)
- func (sms *MessageState) GetBinMsgState() bincons1.BinConsMessageStateInterface
- func (sms *MessageState) GetProofs(headerID messages.HeaderID, sigCount int, round types.ConsensusRound, ...) ([]*sig.MultipleSignedMessage, error)
- func (sms *MessageState) GetValidMessageCount(round types.ConsensusRound, mc *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, mc *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, allowSupportCoin bool, 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 CreateCoinItems ¶
func CreateCoinItems(idx types.ConsensusIndex, round types.ConsensusRound, bct cons.ConsTestItems, t *testing.T) []*deserialized.DeserializedItem
CreateCoinItems is used during unit tests to create a list of signed messages for a coin.
Types ¶
type BinConsRnd1 ¶
type BinConsRnd1 struct { cons.AbsConsItem Decided int // -1 if a value has not yet been decided, 0 if 0 was decided, 1 if 1 was decided IncludeProofs bool // true if messages should include signed values supporting the value in the message // contains filtered or unexported fields }
func (*BinConsRnd1) BroadcastCoin ¶
func (sc *BinConsRnd1) BroadcastCoin(coinMsg messages.MsgHeader, mainChannel channelinterface.MainChannel)
Broadcast a coin msg.
func (*BinConsRnd1) CanSkipMvTimeout ¶
func (sc *BinConsRnd1) CanSkipMvTimeout() bool
CanSkipMvTimeout returns true if the during the multivalue reduction the echo timeout can be skipped
func (*BinConsRnd1) CanStartNext ¶
func (sc *BinConsRnd1) CanStartNext() bool
CanStartNext should return true if it is safe to start the next consensus instance (if parallel instances are enabled)
func (*BinConsRnd1) CheckRound ¶
func (sc *BinConsRnd1) 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 and return true if it can.
func (*BinConsRnd1) GenerateMessageState ¶
func (*BinConsRnd1) GenerateMessageState(gc *generalconfig.GeneralConfig) consinterface.MessageState
GenerateMessageState generates a new message state object given the inputs.
func (*BinConsRnd1) GenerateNewItem ¶
func (*BinConsRnd1) 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 (*BinConsRnd1) GetBinDecided ¶
func (sc *BinConsRnd1) GetBinDecided() (int, types.ConsensusRound)
GetBinDecided returns -1 if not decided, or the decided value and the decided round.
func (*BinConsRnd1) GetBinState ¶
func (sc *BinConsRnd1) GetBinState(localOnly bool) ([]byte, error)
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 (*BinConsRnd1) GetBufferCount ¶
func (*BinConsRnd1) GetBufferCount(hdr messages.MsgIDHeader, gc *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 (*BinConsRnd1) GetCommitProof ¶
func (sc *BinConsRnd1) GetCommitProof() []messages.MsgHeader
GetCommitProof returns a signed message header that counts at the commit message for this consensus.
func (*BinConsRnd1) GetConsType ¶
func (sc *BinConsRnd1) GetConsType() types.ConsType
GetConsType returns the type of consensus this instance implements.
func (*BinConsRnd1) GetDecision ¶
func (sc *BinConsRnd1) GetDecision() (sig.Pub, []byte, types.ConsensusIndex, types.ConsensusIndex)
GetDecision returns the binary value decided as a single byte slice.
func (*BinConsRnd1) GetHeader ¶
func (sc *BinConsRnd1) GetHeader(emptyPub sig.Pub, gc *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 (*BinConsRnd1) GetMVInitialRoundBroadcast ¶
func (sc *BinConsRnd1) GetMVInitialRoundBroadcast(val types.BinVal) messages.InternalSignedMsgHeader
GetMVInitialRoundBroadcast returns the type of binary message that the multi-value reduction should broadcast for round 0.
func (*BinConsRnd1) GetNextInfo ¶
func (sc *BinConsRnd1) 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 (*BinConsRnd1) GetProposalIndex ¶
func (sc *BinConsRnd1) GetProposalIndex() (prevIdx types.ConsensusIndex, ready bool)
GetProposalIndex returns sc.Index - 1. It returns false until start is called.
func (*BinConsRnd1) GetProposeHeaderID ¶
func (sc *BinConsRnd1) GetProposeHeaderID() messages.HeaderID
GetProposeHeaderID returns the HeaderID messages.HdrBinPropose that will be input to GotProposal.
func (*BinConsRnd1) GotProposal ¶
func (sc *BinConsRnd1) GotProposal(hdr messages.MsgHeader, mainChannel channelinterface.MainChannel) error
GotProposal takes the proposal, creates a round 0 AuxProofMessage and broadcasts it.
func (*BinConsRnd1) HasDecided ¶
func (sc *BinConsRnd1) HasDecided() bool
HasDecided should return true if this consensus item has reached a decision.
func (*BinConsRnd1) HasValidStarted ¶
func (sc *BinConsRnd1) HasValidStarted() bool
HasReceivedProposal panics because BonCons has no proposals.
func (*BinConsRnd1) NeedsCompletionConcurrentProposals ¶
func (sc *BinConsRnd1) NeedsCompletionConcurrentProposals() types.ConsensusInt
NeedsConcurrent returns 1.
func (*BinConsRnd1) PrevHasBeenReset ¶
func (sc *BinConsRnd1) PrevHasBeenReset()
PrevHasBeenReset is called when the previous consensus index has been reset to a new index
func (*BinConsRnd1) ProcessMessage ¶
func (sc *BinConsRnd1) 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.
func (*BinConsRnd1) SetInitialState ¶
func (sc *BinConsRnd1) SetInitialState([]byte, storage.StoreInterface)
SetInitialState does noting for this algorithm.
func (*BinConsRnd1) SetNextConsItem ¶
func (sc *BinConsRnd1) 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 (*BinConsRnd1) ShouldCreatePartial ¶
func (sc *BinConsRnd1) ShouldCreatePartial(_ messages.HeaderID) bool
ShouldCreatePartial returns true if the message type should be sent as a partial message
func (*BinConsRnd1) Start ¶
func (sc *BinConsRnd1) Start(finishedLastRound bool)
Start allows GetProposalIndex to return true.
type Config ¶
type Config struct {
cons.StandardBinConfig
}
func (Config) GetAllowSupportCoinTypes ¶
func (Config) GetAllowSupportCoinTypes(gt cons.GetOptionType) []bool
GetAllowSupportCoinTypes returns the values for if the the consensus supports sending messages supporting the coin (for randomized binary consensus) or not or both.
func (Config) GetCoinTypes ¶
func (Config) GetCoinTypes(optionType cons.GetOptionType) []types.CoinType
GetCoinTypes returns the types of coins allowed.
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.
func (Config) GetRotateCoordTypes ¶
func (Config) GetRotateCoordTypes(_ cons.GetOptionType) []bool
GetRotateCoordTypes returns the values for if the consensus supports rotating coordinator or not or both.
func (Config) GetSigTypes ¶
func (Config) GetSigTypes(gt cons.GetOptionType) []types.SigType
GetSigTypes return the types of signatures supported by the consensus
func (Config) GetStopOnCommitTypes ¶
func (Config) GetStopOnCommitTypes(optionType cons.GetOptionType) []types.StopOnCommitType
GetStopOnCommitTypes returns the types to test when to terminate.
func (Config) GetUsePubIndexTypes ¶
func (Config) GetUsePubIndexTypes(_ cons.GetOptionType) []bool
GetUsePubIndex returns the values for if the consensus supports using pub index 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 }
BinConsRnd1MessageState implements BinConsMessageStateInterface. It stores the messages of BinConsRnd1.
func NewBinConsRnd1MessageState ¶
func NewBinConsRnd1MessageState(isMv bool, gc *generalconfig.GeneralConfig) *MessageState
NewBinConsRnd1MessageState generates a new BinConsRnd1MessageState 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() bincons1.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 containing the signatures received for binVal in round round.
func (*MessageState) GetValidMessageCount ¶
func (sms *MessageState) GetValidMessageCount(round types.ConsensusRound, mc *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 BinConsRnd1.
func (*MessageState) New ¶
func (sms *MessageState) New(idx types.ConsensusIndex) consinterface.MessageState
New creates a new empty BinConsRnd1MessageState object for the consensus index idx.
func (*MessageState) SentProposal ¶
func (sms *MessageState) SentProposal(round types.ConsensusRound, shouldSet bool, mc *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.