Documentation ¶
Overview ¶
Implementation of multi-valued consensus in the likeness of PBFT.
Index ¶
- type MessageState
- func (sms *MessageState) GenerateProofs(sigCount int, _ types.ConsensusRound, _ types.BinVal, _ sig.Pub, ...) (messages.MsgHeader, error)
- func (sms *MessageState) GetValidMessageCount() (echoMsgCount int)
- func (sms *MessageState) GotMsg(hdrFunc consinterface.HeaderFunc, deser *deserialized.DeserializedItem, ...) ([]*deserialized.DeserializedItem, error)
- func (sms *MessageState) New(idx types.ConsensusIndex) consinterface.MessageState
- type MvCons3
- func (sc *MvCons3) CanStartNext() bool
- func (sc *MvCons3) Collect()
- func (*MvCons3) GenerateMessageState(gc *generalconfig.GeneralConfig) consinterface.MessageState
- func (*MvCons3) GenerateNewItem(index types.ConsensusIndex, items *consinterface.ConsInterfaceItems, ...) consinterface.ConsItem
- func (sc *MvCons3) GetBinState(localOnly bool) ([]byte, error)
- func (sc *MvCons3) GetBufferCount(hdr messages.MsgIDHeader, _ *generalconfig.GeneralConfig, ...) (int, int, messages.MsgID, error)
- func (sc *MvCons3) GetCommitProof() (proof []messages.MsgHeader)
- func (sc *MvCons3) GetConsType() types.ConsType
- func (sc *MvCons3) GetDecision() (sig.Pub, []byte, types.ConsensusIndex, types.ConsensusIndex)
- func (*MvCons3) GetHeader(emptyPub sig.Pub, gc *generalconfig.GeneralConfig, ...) (messages.MsgHeader, error)
- func (sc *MvCons3) GetNextInfo() (prevIdx types.ConsensusIndex, proposer sig.Pub, preDecision []byte, ...)
- func (sc *MvCons3) GetPrevCommitProof() (coordPub sig.Pub, proof []messages.MsgHeader)
- func (sc *MvCons3) GetProposalIndex() (prevIdx types.ConsensusIndex, ready bool)
- func (sc *MvCons3) GetProposeHeaderID() messages.HeaderID
- func (sc *MvCons3) GotProposal(hdr messages.MsgHeader, mainChannel channelinterface.MainChannel) error
- func (sc *MvCons3) HasDecided() bool
- func (sc *MvCons3) HasValidStarted() bool
- func (sc *MvCons3) NeedsCompletionConcurrentProposals() types.ConsensusInt
- func (sc *MvCons3) PrevHasBeenReset()
- func (sc *MvCons3) PrintState() string
- func (sc *MvCons3) ProcessMessage(deser *deserialized.DeserializedItem, isLocal bool, ...) (bool, bool)
- func (sc *MvCons3) SetInitialState(value []byte, _ storage.StoreInterface)
- func (sc *MvCons3) SetNextConsItem(next consinterface.ConsItem)
- func (sc *MvCons3) ShouldCreatePartial(headerType messages.HeaderID) bool
- func (sc *MvCons3) Start(finishedLastRound bool)
- type MvCons3Config
- func (MvCons3Config) GetAllowConcurrentTypes(gt cons.GetOptionType) []bool
- func (MvCons3Config) GetCollectBroadcast(cons.GetOptionType) []types.CollectBroadcastType
- func (MvCons3Config) GetMemberCheckerTypes(gt cons.GetOptionType) []types.MemberCheckerType
- func (MvCons3Config) GetOrderingTypes(gt cons.GetOptionType) []types.OrderingType
- func (MvCons3Config) GetSigTypes(gt cons.GetOptionType) []types.SigType
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MessageState ¶
type MessageState struct { *messagestate.SimpleMessageStateWrapper // the simple message state is used to track the actual messages // contains filtered or unexported fields }
MvCons3Message state stores the message of MvCons
func NewMvCons3MessageState ¶
func NewMvCons3MessageState(gc *generalconfig.GeneralConfig) *MessageState
NewMvCons3MessageState generates a new MvCons3MessageStateObject.
func (*MessageState) GenerateProofs ¶
func (sms *MessageState) GenerateProofs(sigCount int, _ types.ConsensusRound, _ types.BinVal, _ sig.Pub, mc *consinterface.MemCheckers) (messages.MsgHeader, error)
Generate proofs returns a signed message with signatures supporting the input values, it can be a MvEchoHashMessage.
func (*MessageState) GetValidMessageCount ¶
func (sms *MessageState) GetValidMessageCount() (echoMsgCount int)
GetValidMessage count returns the number of signed echo and commit messages 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 valid message types are (1) HdrMvInitSupport - the leaders proposal, here is ensures the message comes from the correct leader (2) HdrMvEcho - echo messages (4) HdrMvRequestRecover - unsigned message asking for the init message received for a given hash
func (*MessageState) New ¶
func (sms *MessageState) New(idx types.ConsensusIndex) consinterface.MessageState
New inits and returns a new MvCons3MessageState object for the given consensus index.
type MvCons3 ¶
type MvCons3 struct { cons.AbsConsItem cons.AbsMVRecover // contains filtered or unexported fields }
func (*MvCons3) CanStartNext ¶
CanStartNext returns true if the timer for this instance has passed, or a if a later instance has received at least n-t messages
func (*MvCons3) Collect ¶
func (sc *MvCons3) Collect()
Collect is called when the item is being garbage collected.
func (*MvCons3) GenerateMessageState ¶
func (*MvCons3) GenerateMessageState(gc *generalconfig.GeneralConfig) consinterface.MessageState
GenerateMessageState generates a new message state object given the inputs.
func (*MvCons3) GenerateNewItem ¶
func (*MvCons3) GenerateNewItem(index types.ConsensusIndex, items *consinterface.ConsInterfaceItems, mainChannel channelinterface.MainChannel, prevItem consinterface.ConsItem, broadcastFunc consinterface.ByzBroadcastFunc, gc *generalconfig.GeneralConfig) consinterface.ConsItem
ResetState resets the stored state for the current consensus index, and prepares for the new consensus index given by the input.
func (*MvCons3) 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 (*MvCons3) GetBufferCount ¶
func (sc *MvCons3) 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). The messages are: (1) HdrMvInitSupport returns 0, 0 if generalconfig.MvBroadcastInitForBufferForwarder is true (meaning don't forward the message)
otherwise returns 1, 1 (meaning forward the message right away)
(2) HdrMvEchoHash returns n-t, n for the thresholds.
func (*MvCons3) GetCommitProof ¶
GetCommitProof returns nil for MvCons3. It generates the proofs itself since it piggybacks rounds with consensus instances.
func (*MvCons3) GetConsType ¶
GetConsType returns the type of consensus this instance implements.
func (*MvCons3) GetDecision ¶
func (sc *MvCons3) GetDecision() (sig.Pub, []byte, types.ConsensusIndex, types.ConsensusIndex)
GetDecision should return the decided value of the consensus. It should only be called after HasDecided returns true. Proposer it the node that proposed the decision, prvIdx is the index of the decision that preceeded this decision (for MvCons3 this is the previous index that the decided proposal points to), futureDependent is the first larger index that this decision does not depend on (for MvCons3 this is at least the index that is supported by 3 steps of proposals + 2).
func (*MvCons3) GetHeader ¶
func (*MvCons3) 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). The valid headers are HdrMvInitSupport, HdrMvEchoHash, HdrMvCommit, HdrMvRequestRecover.
func (*MvCons3) GetNextInfo ¶
func (sc *MvCons3) GetNextInfo() (prevIdx types.ConsensusIndex, proposer sig.Pub, preDecision []byte, hasInfo bool)
GetNextInfo will be called after CanStartNext returns true. It is used to get information about how the state machine for this instance will be generated. prevIdx should be the index that this consensus index will follow (normally this is just idx - 1). preDecision is either nil or the value that will be decided if a non-nil value is decided. hasInfo returns true if the values for proposer and preDecision are ready. If false is returned then the next is started, but the current instance has no state machine created. This function is mainly used for MvCons3 since the order of state machines depends on depends on the execution of the consensus instances.
func (*MvCons3) GetPrevCommitProof ¶
GetPrevCommitProof returns a signed message header that counts at the commit message for the previous consensus. This should only be called after DoneKeep has been called on this instance.
func (*MvCons3) GetProposalIndex ¶
func (sc *MvCons3) GetProposalIndex() (prevIdx types.ConsensusIndex, ready bool)
GetProposalIndex returns sc.Index - 1. It returns false until start is called.
func (*MvCons3) GetProposeHeaderID ¶
GetProposeHeaderID returns the HeaderID messages.HdrMvPropose that will be input to GotProposal.
func (*MvCons3) GotProposal ¶
func (sc *MvCons3) GotProposal(hdr messages.MsgHeader, mainChannel channelinterface.MainChannel) error
GotProposal takes the proposal, and broadcasts it if it is the leader.
func (*MvCons3) HasDecided ¶
HasDecided should return true if this consensus item has reached a decision.
func (*MvCons3) HasValidStarted ¶
HasReceivedProposal returns true if the cons has received a valid proposal.
func (*MvCons3) NeedsCompletionConcurrentProposals ¶
func (sc *MvCons3) NeedsCompletionConcurrentProposals() types.ConsensusInt
NeedsConcurrent returns 4.
func (*MvCons3) PrevHasBeenReset ¶
func (sc *MvCons3) PrevHasBeenReset()
PrevHasBeenReset is called when the previous consensus index has been reset to a new index
func (*MvCons3) PrintState ¶
func (*MvCons3) ProcessMessage ¶
func (sc *MvCons3) ProcessMessage( deser *deserialized.DeserializedItem, isLocal bool, senderChan *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. The following are the valid message types: messages.HdrMvInitSupport is the leader proposal, once this is received an echo is sent containing the hash, and starts the echo timeoutout. messages.HdrMvInitTimeout the init timeout is started in GotProposal, if we don't receive a hash before the timeout, we support 0 in bin cons. messages.HdrMvEchoHash is the echo message, when these are received we run CheckEchoState. messages.HdrMvRequestRecover a node terminated bin cons with 1, but didn't get the init message, so if we have it we send it. messages.HdrMvRecoverTimeout if a node terminated bin cons with 1, but didn't get the init message this timeout is started, once it runs out, we ask other nodes to send the init message.
func (*MvCons3) SetInitialState ¶
func (sc *MvCons3) SetInitialState(value []byte, _ storage.StoreInterface)
SetInitialState sets the value that is supported by the inital index (1).
func (*MvCons3) SetNextConsItem ¶
func (sc *MvCons3) SetNextConsItem(next 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 (*MvCons3) ShouldCreatePartial ¶
ShouldCreatePartial returns true if the message type should be sent as a partial message
type MvCons3Config ¶
type MvCons3Config struct {
cons.StandardMvConfig
}
func (MvCons3Config) GetAllowConcurrentTypes ¶
func (MvCons3Config) GetAllowConcurrentTypes(gt cons.GetOptionType) []bool
GetAllowConcurrentTypes returns the values for if the consensus supports running concurrent consensus instances when using total ordering or not or both.
func (MvCons3Config) GetCollectBroadcast ¶
func (MvCons3Config) GetCollectBroadcast(cons.GetOptionType) []types.CollectBroadcastType
GetCollectBroadcast returns the values for if the consensus supports broadcasting the commit message directly to the leader.
func (MvCons3Config) GetMemberCheckerTypes ¶
func (MvCons3Config) GetMemberCheckerTypes(gt cons.GetOptionType) []types.MemberCheckerType
GetMemberCheckerTypes returns the types of member checkers valid for the consensus.
func (MvCons3Config) GetOrderingTypes ¶
func (MvCons3Config) GetOrderingTypes(gt cons.GetOptionType) []types.OrderingType
GetOrderingTypes returns the types of ordering supported by the consensus.
func (MvCons3Config) GetSigTypes ¶
func (MvCons3Config) GetSigTypes(gt cons.GetOptionType) []types.SigType
GetSigTypes return the types of signatures supported by the consensus