mvcons3

package
v0.0.0-...-ff61ee7 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2020 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Overview

Implementation of multi-valued consensus in the likeness of PBFT.

Index

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

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

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

func (sc *MvCons3) CanStartNext() bool

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

ResetState resets the stored state for the current consensus index, and prepares for the new consensus index given by the input.

func (*MvCons3) GetBinState

func (sc *MvCons3) 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 (*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

func (sc *MvCons3) GetCommitProof() (proof []messages.MsgHeader)

GetCommitProof returns nil for MvCons3. It generates the proofs itself since it piggybacks rounds with consensus instances.

func (*MvCons3) GetConsType

func (sc *MvCons3) GetConsType() types.ConsType

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

func (sc *MvCons3) GetPrevCommitProof() (coordPub sig.Pub, proof []messages.MsgHeader)

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

func (sc *MvCons3) GetProposeHeaderID() messages.HeaderID

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

func (sc *MvCons3) HasDecided() bool

HasDecided should return true if this consensus item has reached a decision.

func (*MvCons3) HasValidStarted

func (sc *MvCons3) HasValidStarted() bool

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 (sc *MvCons3) PrintState() string

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

func (sc *MvCons3) ShouldCreatePartial(headerType messages.HeaderID) bool

ShouldCreatePartial returns true if the message type should be sent as a partial message

func (*MvCons3) Start

func (sc *MvCons3) Start(finishedLastRound bool)

Start allows GetProposalIndex to return true.

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

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

Jump to

Keyboard shortcuts

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