mvcons1

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: 18 Imported by: 0

Documentation

Overview

Implementation of multi-valued consensus reduction to BinCons1.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetConf

func GetConf() cons.ConfigOptions

Types

type MessageState

type MessageState struct {
	*messagestate.SimpleMessageStateWrapper // the simple message state is used to track the actual messages
	bincons1.BinConsMessageStateInterface   // the binary consensus messages
	// contains filtered or unexported fields
}

MvCons1Message state stores the message of MvCons, including that of the binary consesnsus that it reduces to.

func NewMvCons1MessageState

func NewMvCons1MessageState(gc *generalconfig.GeneralConfig) *MessageState

NewMvCons1MessageState generates a new MvCons1MessageStateObject.

func (*MessageState) GenerateProofs

func (sms *MessageState) GenerateProofs(hdrID messages.HeaderID, sigCount int, round types.ConsensusRound, binVal types.BinVal,
	pub sig.Pub, mc *consinterface.MemCheckers) ([]*sig.MultipleSignedMessage, error)

Generate proofs returns a signed message with signatures supporting the input values, it can be a MvEchoMessage if round == 2 && binVal == 1 otherwise it is a AuxProof message

func (*MessageState) GetBinConsMsgState

func (sms *MessageState) GetBinConsMsgState() bincons1.BinConsMessageStateInterface

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) HdrMvInit - the leaders proposal, here is ensures the message comes from the correct leader (2) HdrMvEcho - echo messages (3) HdrMvRequestRecover - unsigned message asking for the init message received for a given hash (4) -- Any messages to the binary consensus

func (*MessageState) New

New inits and returns a new MvCons1MessageState object for the given consensus index.

type MvBinCons1Config

type MvBinCons1Config struct {
	cons.StandardMvConfig
}

func (MvBinCons1Config) GetStopOnCommitTypes

func (MvBinCons1Config) GetStopOnCommitTypes(optionType cons.GetOptionType) []types.StopOnCommitType

GetStopOnCommitTypes returns the types to test when to terminate.

type MvBinConsRnd1Config

type MvBinConsRnd1Config struct {
	cons.StandardMvConfig
}

func (MvBinConsRnd1Config) GetAllowSupportCoinTypes

func (MvBinConsRnd1Config) 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 (MvBinConsRnd1Config) GetCoinTypes

func (MvBinConsRnd1Config) GetCoinTypes(optionType cons.GetOptionType) []types.CoinType

GetCoinTypes returns the types of coins allowed.

func (MvBinConsRnd1Config) GetSigTypes

GetSigTypes return the types of signatures supported by the consensus

func (MvBinConsRnd1Config) GetStopOnCommitTypes

func (MvBinConsRnd1Config) GetStopOnCommitTypes(optionType cons.GetOptionType) []types.StopOnCommitType

GetStopOnCommitTypes returns the types to test when to terminate.

func (MvBinConsRnd1Config) GetUsePubIndexTypes

func (MvBinConsRnd1Config) GetUsePubIndexTypes(gt cons.GetOptionType) []bool

GetUsePubIndex returns the values for if the consensus supports using pub index or not or both.

type MvBinConsRnd2Config

type MvBinConsRnd2Config struct {
	cons.StandardMvConfig
}

func (MvBinConsRnd2Config) GetAllowNoSignatures

func (MvBinConsRnd2Config) GetAllowNoSignatures(gt cons.GetOptionType) []bool

GetAllowNoSignatures returns true if the consensus can run without signatures

func (MvBinConsRnd2Config) GetCoinTypes

func (MvBinConsRnd2Config) GetCoinTypes(optionType cons.GetOptionType) []types.CoinType

GetCoinTypes returns the types of coins allowed.

func (MvBinConsRnd2Config) GetCollectBroadcast

GetCollectBroadcast returns the values for if the consensus supports broadcasting the commit message directly to the leader. // TODO for mvbincons2

func (MvBinConsRnd2Config) GetRotateCoordTypes

func (MvBinConsRnd2Config) GetRotateCoordTypes(_ cons.GetOptionType) []bool

GetRotateCoordTypes returns the values for if the consensus supports rotating coordinator or not or both.

func (MvBinConsRnd2Config) GetSigTypes

GetSigTypes return the types of signatures supported by the consensus

func (MvBinConsRnd2Config) GetStopOnCommitTypes

func (MvBinConsRnd2Config) GetStopOnCommitTypes(optionType cons.GetOptionType) []types.StopOnCommitType

GetStopOnCommitTypes returns the types to test when to terminate.

func (MvBinConsRnd2Config) GetUsePubIndexTypes

func (MvBinConsRnd2Config) GetUsePubIndexTypes(_ cons.GetOptionType) []bool

GetUsePubIndex returns the values for if the consensus supports using pub index or not or both.

type MvCons1

type MvCons1 struct {
	cons.AbsConsItem
	cons.AbsMVRecover
	// contains filtered or unexported fields
}

MvCons1 is a simple leader-based multi-value to binary consensus reduction using BinCons1. If the binary consensus terminates with 0 a null value is decided, otherwise the leaders proposal is decided. Assuming the leader is correct and the timeout configured correctly, termination happens in 3 message setps. (1) an init message broadcast from the leader (2) an all to all echo message containing the hash of the init (3) a aux proof message for round 1 of the binary consensus, allowing 1 to be decided in the binary consensus. If this does not happen, nodes start supporting 0 after a timeout and 0 may be decided. TODO generate the proofs from here for round 2, est 1 for bin cons (which would be n-t echos)

func (*MvCons1) CanStartNext

func (sc *MvCons1) CanStartNext() bool

CanStartNext should return true if it is safe to start the next consensus instance (if parallel instances are enabled)

func (*MvCons1) Collect

func (sc *MvCons1) Collect()

Collect is called when the item is being garbage collected.

func (*MvCons1) GenerateMessageState

func (*MvCons1) GenerateMessageState(
	gc *generalconfig.GeneralConfig) consinterface.MessageState

GenerateMessageState generates a new message state object given the inputs.

func (*MvCons1) GenerateNewItem

GenerateNewItem creates a new cons item.

func (*MvCons1) GetBinState

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

func (sc *MvCons1) 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). The messages are: (1) HdrMvInit 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) HdrMvEcho returns n-t, n for the thresholds. (3) otherwise bincons.GetBufferCount is checked

func (*MvCons1) GetCommitProof

func (sc *MvCons1) GetCommitProof() []messages.MsgHeader

GetCommitProof returns a signed message header that counts at the commit message for this consensus.

func (*MvCons1) GetConsType

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

GetConsType returns the type of consensus this instance implements.

func (*MvCons1) GetDecision

func (sc *MvCons1) GetDecision() (sig.Pub, []byte, types.ConsensusIndex, types.ConsensusIndex)

GetDecision returns the decided value as a byte slice, or nil if a nil value was decided

func (*MvCons1) GetHeader

func (*MvCons1) 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 HdrMvInit, HdrMvEcho, HdrMvRequestRecover, or any from the binary consensus.

func (*MvCons1) GetNextInfo

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

func (sc *MvCons1) GetProposalIndex() (prevIdx types.ConsensusIndex, ready bool)

GetProposalIndex returns sc.Index - 1. It returns false until start is called.

func (*MvCons1) GetProposeHeaderID

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

GetProposeHeaderID returns the HeaderID messages.HdrMvPropose that will be input to GotProposal.

func (*MvCons1) GotProposal

func (sc *MvCons1) GotProposal(hdr messages.MsgHeader,
	mainChannel channelinterface.MainChannel) error

GotProposal takes the proposal, creates a round 0 AuxProofMessage and broadcasts it.

func (*MvCons1) HasDecided

func (sc *MvCons1) HasDecided() bool

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

func (*MvCons1) HasValidStarted

func (sc *MvCons1) HasValidStarted() bool

HasReceivedProposal returns true if the cons has received a valid proposal.

func (*MvCons1) NeedsCompletionConcurrentProposals

func (sc *MvCons1) NeedsCompletionConcurrentProposals() types.ConsensusInt

NeedsConcurrent returns 1.

func (*MvCons1) PrevHasBeenReset

func (sc *MvCons1) PrevHasBeenReset()

PrevHasBeenReset is called when the previous consensus index has been reset to a new index

func (*MvCons1) ProcessMessage

func (sc *MvCons1) 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.HdrMvInit 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.HdrMvEcho is the echo message, when these are received we run CheckEchoState. messages.HdrMvEchoTimeout once the echo timeout runs out, without receiving n-t equal echo messages, we support 0 in bin cons. 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 mesage this timeout is started, once it runs out, we ask other nodes to send the init message. messages.HdrAuxProof messages are passed to the binray cons object.

func (*MvCons1) SetInitialState

func (sc *MvCons1) SetInitialState([]byte, storage.StoreInterface)

SetInitialState does noting for this algorithm.

func (*MvCons1) SetNextConsItem

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

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

func (*MvCons1) Start

func (sc *MvCons1) Start(finishedLastRound bool)

Start allows GetProposalIndex to return true.

Jump to

Keyboard shortcuts

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