cons

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

Documentation

Overview

Package contains the main consensus implementations.

Index

Constants

This section is empty.

Variables

View Source
var AllTestConfig = OptionStruct{
	StopOnCommitTypes:      types.AllStopOnCommitTypes,
	OrderingTypes:          []types.OrderingType{types.Total, types.Causal},
	ByzTypes:               types.AllByzTypes,
	StateMachineTypes:      types.AllProposerTypes,
	SigTypes:               types.AllSigTypes,
	UsePubIndexTypes:       types.WithBothBool,
	IncludeProofsTypes:     types.WithBothBool,
	MemberCheckerTypes:     types.AllMC,
	RandMemberCheckerTypes: types.AllRandMemberTypes,
	RotateCoordTypes:       types.WithBothBool,
	AllowSupportCoinTypes:  types.WithBothBool,
	CollectBroadcast:       types.AllCollectBroadcast,
	AllowConcurrentTypes:   []types.ConsensusInt{0, 5},
	EncryptChannelsTypes:   types.WithBothBool,
	AllowNoSignaturesTypes: types.WithBothBool,
	CoinTypes:              types.AllCoins,
	UseFixedCoinPresets:    types.WithBothBool,
}

AllTestConfig contains all options.

View Source
var BasicTestConfigs = ReplaceNilFields(OptionStruct{
	StateMachineTypes:    []types.StateMachineType{types.CurrencyTxProposer},
	MemberCheckerTypes:   []types.MemberCheckerType{types.CurrentTrueMC},
	StopOnCommitTypes:    []types.StopOnCommitType{types.Immediate},
	CoinTypes:            []types.CoinType{types.NoCoinType, types.FlipCoinType},
	ByzTypes:             []types.ByzType{types.NonFaulty},
	IncludeProofsTypes:   types.WithFalse,
	EncryptChannelsTypes: types.WithFalse,
	UsePubIndexTypes:     types.WithTrue,
}, AllTestConfig)
View Source
var RandTermTotalOrderTest = ReplaceNilFields(OptionStruct{
	SigTypes:              types.ThrshSigTypes,
	UsePubIndexTypes:      types.WithTrue,
	IncludeProofsTypes:    types.WithBothBool,
	AllowSupportCoinTypes: types.WithBothBool,
}, StandardTotalOrderConfig)

RandTermTotalOrderTest creates tests for radomized termination consensus items.

View Source
var RndMemCheckTest = ReplaceNilFields(OptionStruct{
	MemberCheckerTypes:     []types.MemberCheckerType{types.TrueMC},
	RandMemberCheckerTypes: types.AllRandMemberTypes}, StandardTotalOrderConfig)
View Source
var RndTestByzConfigs = []types.TestOptions{
	{
		MaxRounds:          config.MaxRounds,
		NumTotalProcs:      config.ProcCount,
		NumByz:             config.ProcCount / 3,
		ByzType:            types.NonFaulty,
		ClearDiskOnRestart: false,
		NetworkType:        types.AllToAll,
		CheckDecisions:     true,
		UsePubIndex:        true,
		SigType:            types.EDCOIN,
	},
	{
		MaxRounds:          config.MaxRounds,
		NumTotalProcs:      config.ProcCount,
		NumByz:             config.ProcCount / 3,
		ByzType:            types.Mute,
		ClearDiskOnRestart: false,
		NetworkType:        types.AllToAll,
		CheckDecisions:     true,
		UsePubIndex:        true,
		SigType:            types.EDCOIN,
	},
	{
		MaxRounds:          config.MaxRounds,
		NumTotalProcs:      config.ProcCount,
		NumByz:             config.ProcCount / 3,
		ByzType:            types.Mute,
		ClearDiskOnRestart: false,
		NetworkType:        types.AllToAll,
		CheckDecisions:     true,
		RotateCord:         true,
		UsePubIndex:        true,
		SigType:            types.EDCOIN,
	},
	{
		MaxRounds:          config.MaxRounds,
		NumTotalProcs:      config.ProcCount,
		NumByz:             config.ProcCount / 3,
		ByzType:            types.BinaryFlip,
		ClearDiskOnRestart: false,
		NetworkType:        types.AllToAll,
		CheckDecisions:     true,
		UsePubIndex:        true,
		SigType:            types.EDCOIN,
	},
	{
		MaxRounds:          config.MaxRounds,
		NumTotalProcs:      config.ProcCount,
		NumByz:             config.ProcCount / 3,
		ByzType:            types.BinaryBoth,
		ClearDiskOnRestart: false,
		NetworkType:        types.AllToAll,
		CheckDecisions:     true,
		UsePubIndex:        true,
		SigType:            types.EDCOIN,
	},

	{
		MaxRounds:          config.MaxRounds,
		NumTotalProcs:      config.ProcCount,
		NumByz:             config.ProcCount / 3,
		ByzType:            types.BinaryBoth,
		ClearDiskOnRestart: false,
		NetworkType:        types.P2p,
		FanOut:             config.FanOut,
		CheckDecisions:     true,
		UsePubIndex:        true,
		SigType:            types.EDCOIN,
	},
	{
		MaxRounds:          config.MaxRounds,
		NumTotalProcs:      config.ProcCount,
		NumByz:             config.ProcCount / 3,
		ByzType:            types.BinaryBoth,
		ClearDiskOnRestart: false,
		NetworkType:        types.P2p,
		FanOut:             config.FanOut,
		CheckDecisions:     true,
		IncludeProofs:      true,
		UsePubIndex:        true,
		SigType:            types.EDCOIN,
	},
}

TestByzConfigs is a list of test configuarions using Byzantine nodes.

View Source
var RndTestConfigs = []types.TestOptions{

	{
		MaxRounds:          config.MaxRounds,
		FailRounds:         0,
		NumFailProcs:       0,
		NumTotalProcs:      config.ProcCount,
		ClearDiskOnRestart: false,
		NetworkType:        types.AllToAll,
		CheckDecisions:     true,
		UsePubIndex:        true,
		SigType:            types.EDCOIN,
	},

	{
		MaxRounds:          config.MaxRounds,
		FailRounds:         0,
		NumFailProcs:       0,
		NumTotalProcs:      config.ProcCount,
		ClearDiskOnRestart: false,
		NetworkType:        types.AllToAll,
		CheckDecisions:     true,
		RotateCord:         true,
		UsePubIndex:        true,
		SigType:            types.EDCOIN,
	},
	{
		MaxRounds:          config.MaxRounds,
		AllowConcurrent:    5,
		FailRounds:         0,
		NumFailProcs:       0,
		NumTotalProcs:      config.ProcCount,
		ClearDiskOnRestart: false,
		NetworkType:        types.AllToAll,
		CheckDecisions:     true,
		UsePubIndex:        true,
		SigType:            types.EDCOIN,
	},
	{
		MaxRounds:          config.MaxRounds,
		FailRounds:         0,
		NumFailProcs:       0,
		NumTotalProcs:      config.ProcCount,
		ClearDiskOnRestart: false,
		NetworkType:        types.AllToAll,
		CheckDecisions:     true,
		IncludeProofs:      true,
		UsePubIndex:        true,
		SigType:            types.EDCOIN,
	},
	{
		MaxRounds:          config.MaxRounds,
		FailRounds:         0,
		NumFailProcs:       0,
		NumTotalProcs:      config.ProcCount,
		ClearDiskOnRestart: false,
		NetworkType:        types.AllToAll,
		CheckDecisions:     true,
		SigType:            types.TBLS,
		IncludeProofs:      true,
		UsePubIndex:        true,
		GenRandBytes:       true,
	},

	{

		MaxRounds:          10,
		FailRounds:         0,
		NumFailProcs:       0,
		NumTotalProcs:      config.ProcCount,
		ClearDiskOnRestart: false,
		NetworkType:        types.AllToAll,
		CheckDecisions:     true,
		MsgDropPercent:     10,
		UsePubIndex:        true,
		SigType:            types.EDCOIN,
	},
	{
		MaxRounds:          config.MaxRounds,
		FailRounds:         0,
		NumFailProcs:       0,
		NumTotalProcs:      config.ProcCount,
		ClearDiskOnRestart: false,
		NetworkType:        types.AllToAll,
		StorageType:        types.Memstorage,
		CheckDecisions:     true,
		UsePubIndex:        true,
		SigType:            types.EDCOIN,
	},
	{
		MaxRounds:          config.MaxRounds,
		FailRounds:         5,
		NumFailProcs:       config.ProcCount,
		NumTotalProcs:      config.ProcCount,
		ClearDiskOnRestart: false,
		NetworkType:        types.AllToAll,
		CheckDecisions:     true,
		UsePubIndex:        true,
		SigType:            types.EDCOIN,
	},
	{
		MaxRounds:          config.MaxRounds,
		FailRounds:         5,
		NumFailProcs:       5,
		NumTotalProcs:      config.ProcCount,
		ClearDiskOnRestart: false,
		NetworkType:        types.AllToAll,
		CheckDecisions:     true,
		UsePubIndex:        true,
		SigType:            types.EDCOIN,
	},
	{
		MaxRounds:          100,
		FailRounds:         5,
		NumFailProcs:       5,
		NumTotalProcs:      config.ProcCount,
		ClearDiskOnRestart: false,
		NetworkType:        types.AllToAll,
		CheckDecisions:     true,
		UsePubIndex:        true,
		SigType:            types.EDCOIN,
	},
	{
		MaxRounds:          config.MaxRounds,
		AllowConcurrent:    5,
		FailRounds:         5,
		NumFailProcs:       config.ProcCount / 3,
		NumTotalProcs:      config.ProcCount,
		ClearDiskOnRestart: false,
		NetworkType:        types.AllToAll,
		CheckDecisions:     true,
		UsePubIndex:        true,
		SigType:            types.EDCOIN,
	},
	{
		MaxRounds:          config.MaxRounds,
		FailRounds:         5,
		NumFailProcs:       config.ProcCount / 3,
		NumTotalProcs:      config.ProcCount,
		ClearDiskOnRestart: true,
		NetworkType:        types.AllToAll,
		CheckDecisions:     true,
		UsePubIndex:        true,
		SigType:            types.EDCOIN,
	},

	{
		MaxRounds:          config.MaxRounds,
		FailRounds:         5,
		NumFailProcs:       config.ProcCount,
		NumTotalProcs:      config.ProcCount,
		ClearDiskOnRestart: false,
		NetworkType:        types.AllToAll,
		CheckDecisions:     true,
		SigType:            types.TBLS,
		IncludeProofs:      true,
		UsePubIndex:        true,
	},
	{
		MaxRounds:          config.MaxRounds,
		FailRounds:         5,
		NumFailProcs:       config.ProcCount / 3,
		NumTotalProcs:      config.ProcCount,
		ClearDiskOnRestart: true,
		NetworkType:        types.AllToAll,
		CheckDecisions:     true,
		SigType:            types.TBLS,
		IncludeProofs:      true,
		UsePubIndex:        true,
	},

	{
		MaxRounds:          config.MaxRounds,
		FailRounds:         0,
		NumFailProcs:       0,
		NumTotalProcs:      config.ProcCount,
		ClearDiskOnRestart: false,
		NetworkType:        types.P2p,
		FanOut:             config.FanOut,
		CheckDecisions:     true,
		UsePubIndex:        true,
		SigType:            types.EDCOIN,
	},
	{
		MaxRounds:          config.MaxRounds,
		FailRounds:         0,
		NumFailProcs:       0,
		NumTotalProcs:      config.ProcCount,
		ClearDiskOnRestart: false,
		NetworkType:        types.P2p,
		FanOut:             config.FanOut,
		CheckDecisions:     true,
		UsePubIndex:        true,
		SigType:            types.EDCOIN,
	},
	{
		MaxRounds:          5,
		FailRounds:         0,
		NumFailProcs:       0,
		NumTotalProcs:      config.ProcCount,
		ClearDiskOnRestart: false,
		NetworkType:        types.P2p,
		FanOut:             config.FanOut,
		CheckDecisions:     true,
		MsgDropPercent:     10,
		UsePubIndex:        true,
		SigType:            types.EDCOIN,
	},
	{
		MaxRounds:          config.MaxRounds,
		FailRounds:         5,
		NumFailProcs:       config.ProcCount,
		NumTotalProcs:      config.ProcCount,
		ClearDiskOnRestart: false,
		NetworkType:        types.P2p,
		FanOut:             config.FanOut,
		CheckDecisions:     true,
		UsePubIndex:        true,
		SigType:            types.EDCOIN,
	},
	{
		MaxRounds:          config.MaxRounds,
		FailRounds:         5,
		NumFailProcs:       5,
		NumTotalProcs:      config.ProcCount,
		ClearDiskOnRestart: false,
		NetworkType:        types.P2p,
		FanOut:             config.FanOut,
		CheckDecisions:     true,
		UsePubIndex:        true,
		SigType:            types.EDCOIN,
	},
	{
		MaxRounds:          config.MaxRounds,
		FailRounds:         5,
		NumFailProcs:       config.ProcCount / 3,
		NumTotalProcs:      config.ProcCount,
		ClearDiskOnRestart: true,
		NetworkType:        types.P2p,
		FanOut:             config.FanOut,
		CheckDecisions:     true,
		UsePubIndex:        true,
		SigType:            types.EDCOIN,
	},
}

RndTestConfig is a list of different configurations that will be tested for randomized consensus.

View Source
var RndTestRandomConfigs = []types.TestOptions{
	{
		MaxRounds:          config.MaxRounds,
		FailRounds:         0,
		NumFailProcs:       0,
		NumTotalProcs:      config.ProcCount,
		ClearDiskOnRestart: false,
		FanOut:             config.FanOut,
		NetworkType:        types.Random,
		CheckDecisions:     true,
		SleepValidate:      true,
		UsePubIndex:        true,
		SigType:            types.EDCOIN,
	},
}

TestRandomConfigs is a list of test configurations for radomized network propagation.

SingleSMTest is the same as AllTestConfig with the state machine types replaced to one type.

View Source
var StandardTotalOrderConfig = OptionStruct{
	StopOnCommitTypes:      []types.StopOnCommitType{types.Immediate},
	OrderingTypes:          []types.OrderingType{types.Total},
	SigTypes:               []types.SigType{types.EC},
	StateMachineTypes:      []types.StateMachineType{types.CounterProposer},
	UsePubIndexTypes:       types.WithTrue,
	IncludeProofsTypes:     types.WithFalse,
	MemberCheckerTypes:     []types.MemberCheckerType{types.TrueMC},
	RandMemberCheckerTypes: []types.RndMemberType{types.NonRandom},
	RotateCoordTypes:       types.WithFalse,
	AllowSupportCoinTypes:  types.WithFalse,
	CollectBroadcast:       []types.CollectBroadcastType{types.Full},
	AllowConcurrentTypes:   []types.ConsensusInt{0},
	EncryptChannelsTypes:   types.WithTrue,
	AllowNoSignaturesTypes: types.WithFalse,
	CoinTypes:              []types.CoinType{types.NoCoinType},
	UseFixedCoinPresets:    types.WithFalse,
}

StandardTotalOrderConfig contains options for a normal total order test.

Functions

func BroadcastBinBoth

func BroadcastBinBoth(nextCoordPub sig.Pub,
	ci *consinterface.ConsInterfaceItems,
	msg messages.InternalSignedMsgHeader,
	signMessage bool,
	forwardFunc channelinterface.NewForwardFuncFilter,
	mainChannel channelinterface.MainChannel,
	gc *generalconfig.GeneralConfig,
	additionalMsgs ...messages.MsgHeader)

Broadcast two aux proof messages, one for 0 and one for 1.

func BroadcastBinFlip

func BroadcastBinFlip(nextCoordPub sig.Pub,
	ci *consinterface.ConsInterfaceItems,
	msg messages.InternalSignedMsgHeader,
	signMessage bool,
	forwardFunc channelinterface.NewForwardFuncFilter,
	mainChannel channelinterface.MainChannel,
	gc *generalconfig.GeneralConfig,
	additionalMsgs ...messages.MsgHeader)

Broadcast an aux proof message, but flip the binary value.

func BroadcastHalfHalf

func BroadcastHalfHalf(fixedBin bool, nextCoordPub sig.Pub,
	ci *consinterface.ConsInterfaceItems,
	msg messages.InternalSignedMsgHeader,
	signMessage bool,
	forwardFunc channelinterface.NewForwardFuncFilter,
	mainChannel channelinterface.MainChannel,
	gc *generalconfig.GeneralConfig,
	additionalMsgs ...messages.MsgHeader)

BroadcastHalfHalf broadcast different messages to the nodes.

func BroadcastHalfHalfFixedBin

func BroadcastHalfHalfFixedBin(nextCoordPub sig.Pub,
	ci *consinterface.ConsInterfaceItems,
	msg messages.InternalSignedMsgHeader,
	signMessage bool,
	forwardFunc channelinterface.NewForwardFuncFilter,
	mainChannel channelinterface.MainChannel,
	gc *generalconfig.GeneralConfig,
	additionalMsgs ...messages.MsgHeader)

func BroadcastHalfHalfNormal

func BroadcastHalfHalfNormal(nextCoordPub sig.Pub,
	ci *consinterface.ConsInterfaceItems,
	msg messages.InternalSignedMsgHeader,
	signMessage bool,
	forwardFunc channelinterface.NewForwardFuncFilter,
	mainChannel channelinterface.MainChannel,
	gc *generalconfig.GeneralConfig,
	additionalMsgs ...messages.MsgHeader)

func BroadcastMute

func BroadcastMute(nextCoordPub sig.Pub,
	ci *consinterface.ConsInterfaceItems,
	msg messages.InternalSignedMsgHeader,
	signMessage bool,
	forwardFunc channelinterface.NewForwardFuncFilter,
	mainChannel channelinterface.MainChannel,
	gc *generalconfig.GeneralConfig,
	additionalMsgs ...messages.MsgHeader)

Broadcast an aux proof message, but dont actually send it.

func BroadcastMuteExceptInit

func BroadcastMuteExceptInit(nextCoordPub sig.Pub,
	ci *consinterface.ConsInterfaceItems,
	msg messages.InternalSignedMsgHeader,
	signMessage bool,
	forwardFunc channelinterface.NewForwardFuncFilter,
	mainChannel channelinterface.MainChannel,
	gc *generalconfig.GeneralConfig,
	additionalMsgs ...messages.MsgHeader)

BroadcastMuteExceptInit only broadcasts init messages

func CheckCausalDecisions

func CheckCausalDecisions(decidedRoots []*utils.StringNode, orderedDecisions [][]byte, pi consinterface.CausalStateMachineInterface,
	to types.TestOptions) (errors []error)

func CheckDecisions

func CheckDecisions(decidedValues [][][]byte, pi consinterface.StateMachineInterface,
	to types.TestOptions) (outOforderErrors, errors []error)

CheckDecisions checks if the decided values are valid. (1) Checks that all processes decided the same value. (2) Checks with the state machine that the decided values are valid.

func CheckIncludeEchoProofs

func CheckIncludeEchoProofs(round types.ConsensusRound, ci *consinterface.ConsInterfaceItems,
	configIncludeProofs bool, gc *generalconfig.GeneralConfig) (includeProofs bool, sendToCoord sig.Pub)

CheckIncludeEchoProofs checks what kind of collect broadcast (see types.CollectBroadcast) should be done for the message. This should be used for "commit" type messages, i.e. of the init->echo->commit message pattern. If gc.CollectBroadcast is types.EchoCommit or configIncludeProofs is true then proofs of validity should be included with the message. If the value returned in sendToCoord is non-nil the the message should only be sent to the coordinator (see types.Commit and types.EchoCommit).

func CheckSpecialKeys

CheckSpecialKeys creates a special member checker for the given configuration. Threshold keys generate a ThrshSigMemChecker. Multisignature keys generate a MultiSigMemChecker. Otherwise a NoSpecialMembers object is returned.

func DoConsBroadcast

DoConsBroadcast broadcasts a message for the given inputs. If nxtCordPub is not nil (the next coordinator public key), the message is only sent to that node (see types.CollectBroadcast). If the msg is nil then just the proofs will be sent. If gc has partial messages enabled for the message type the message will be sent as pieces.

func GenLocalRand

func GenLocalRand(to types.TestOptions, key [32]byte) *rand.Rand

GenLocalRand returns a Rand object using key and config.CsID if rand member type is set to LocalRandMember.

func GenRandKey

func GenRandKey() (ret [32]byte)

GenRandKey returns 32 random bytes.

func GenTBLSDualDSSThresh

func GenTBLSDualDSSThresh(to types.TestOptions) (blsSharedPrimary, blsSharedSecondary *bls.BlsShared)

func GenTBLSDualThreshPriv

func GenTBLSDualThreshPriv(i sig.PubKeyIndex, blsSharedPrimary, blsSharedSecondary *bls.BlsShared,
	to types.TestOptions) sig.Priv

func GenTBLSDualThreshPrivNonMember

func GenTBLSDualThreshPrivNonMember(i sig.PubKeyIndex, blsSharedPrimary, blsSharedSecondary *bls.BlsShared,
	to types.TestOptions) sig.Priv

func GenerateCausalStateMachine

func GenerateCausalStateMachine(to types.TestOptions, priv sig.Priv, proposer sig.Pub,
	extraParticipantInfo [][]byte, pid int64, testProc channelinterface.MainChannel,
	finishedChan chan channelinterface.ChannelCloseType, memberCheckerState consinterface.ConsStateInterface,
	generalConfig *generalconfig.GeneralConfig, basicInit bool) (ret consinterface.CausalStateMachineInterface)

GenerateCausalStateMachine creates a state machine object given the by the test configuration.

func GenerateExtraParticipantRegisterState

func GenerateExtraParticipantRegisterState(to types.TestOptions, priv sig.Priv, pid int64) (ret []byte)

GenerateExtraParticipantRegisterState is called before the participant is registered, generating any additional test state.

func GenerateForwardChecker

func GenerateForwardChecker(t assert.TestingT, pub sig.Pub, pubKeys sig.PubList, to types.TestOptions,
	generalConfig *generalconfig.GeneralConfig, parRegs ...network.PregInterface) consinterface.ForwardChecker

GenerateForwardChecker creates a forward checker object given by the test configuration.

func GenerateMainChannel

func GenerateMainChannel(t assert.TestingT, to types.TestOptions,
	initItem consinterface.ConsItem,
	gc *generalconfig.GeneralConfig,
	updateConInfo func(channelinterface.NetNodeInfo),
	stats stats.NwStatsInterface, extraParRegInfo []byte,
	parRegs ...network.PregInterface) (ret channelinterface.MainChannel, retConInfo []channelinterface.NetNodeInfo)

func GenerateParticipantRegisters

func GenerateParticipantRegisters(to types.TestOptions) (ret []network.PregInterface)

func GenerateStateMachine

func GenerateStateMachine(to types.TestOptions, priv sig.Priv,
	extraParticipantInfo [][]byte, pid int64, testProc channelinterface.MainChannel,
	finishedChan chan channelinterface.ChannelCloseType, newPubFunc func() sig.Pub, newSigFunc func() sig.Sig,
	generalConfig *generalconfig.GeneralConfig, basicInit bool) (ret consinterface.StateMachineInterface)

GenerateStateMachine creates a state machine object given the by the test configuration.

func GetBaseSMType

func GetBaseSMType(consType types.ConsType, order types.OrderingType, consConfigs ConfigOptions,
	to types.TestOptions) types.StateMachineType

func GetCausalDecisions

func GetCausalDecisions(state consinterface.ConsStateInterface) (
	rootNode *utils.StringNode, orderedDecisions [][]byte)

func GetConnectionPubs

func GetConnectionPubs(t assert.TestingT, pstr sig.PubKeyStr, pubKeys []sig.Pub, parReg network.PregInterface) []sig.Pub

func GetCoordPubCollectBroadcastEcho

func GetCoordPubCollectBroadcastEcho(round types.ConsensusRound, ci *consinterface.ConsInterfaceItems,
	gc *generalconfig.GeneralConfig) sig.Pub

GetCoordPubCollectBroadcastEcho is used to check if an echo message should be broadcast to all nodes, or just to the next coordinator (see types.CollectBroadcast) for the CURRENT round/instance of consensus. It returns a the expected coordinator of round if gc.CollectBroadcast is types.EchoCommit, it returns nil otherwise.

func GetCoordPubCollectBroadcastEnd

func GetCoordPubCollectBroadcastEnd(round types.ConsensusRound, ci *consinterface.ConsInterfaceItems,
	gc *generalconfig.GeneralConfig) sig.Pub

GetCoordPubCollectBroadcastEnd is used to check if an message should be broadcast to all nodes, or just to the next coordinator (see types.CollectBroadcast) at the very end of consensus. It returns a the expected coordinator of round if gc.CollectBroadcast is not types.Full, it returns nil otherwise.

func GetDecisions

func GetDecisions(to types.TestOptions, consItem consinterface.ConsItem, ds storage.StoreInterface) (res [][]byte)

GetDecisions returns the list of decided values for a given consensus item and storage.

func GetMvMsgRound

func GetMvMsgRound(deser *deserialized.DeserializedItem) (round types.ConsensusRound)

GetMvMsgRound is a helper method to the the round from either a MvInitMessage, PartialMessage, MvCommitMessage, MvEchoMessage

func GetMvTimeout

func GetMvTimeout(round types.ConsensusRound, t int, gc *generalconfig.GeneralConfig) time.Duration

Get the timeout for the mv consensus round. The timeout for the first t rounds is 0. After this, it increases by 1 millisecond each round. TODO need to tune this for each network setup.

func GetMvVRFTimeout

func GetMvVRFTimeout(round types.ConsensusRound, t int, gc *generalconfig.GeneralConfig) time.Duration

GetMvVRFTimeout is the same as GetMvTimeout, except uses the VRF configured timeout value

func GetNextCoordPubCollectBroadcast

func GetNextCoordPubCollectBroadcast(round types.ConsensusRound, ci *consinterface.ConsInterfaceItems,
	gc *generalconfig.GeneralConfig) sig.Pub

GetNextCoordPubCollectBroadcast is used to check if a message should be broadcast to all nodes, or just to the next coordinator (see types.CollectBroadcast) for the NEXT round/instance of consensus. It returns a the expected coordinator of round if gc.CollectBroadcast is not types.Full (also see types.Commit, types.EchoCommit), it returns nil if gc.CollectBroadcast is full.

func GetParticipants

func GetParticipants(t assert.TestingT, to types.TestOptions, parReg network.PregInterface) (
	allParticipants []*network.ParticipantInfo)

func GetStatsString

func GetStatsString(to types.TestOptions, statsList []stats.MergedStats, saveToDisk bool,
	resultsFolder string) string

GetStatsString returns a human readable string of the statisitcs from a tests.

func GetStoreType

func GetStoreType(to types.TestOptions) (storeType storage.ConsensusIDType)

func GetTBLSThresh

func GetTBLSThresh(to types.TestOptions) int

func GetTimeout

func GetTimeout(round types.ConsensusRound, t int) time.Duration

Get the timeout for the round. The timeout for the first t rounds is 0. After this, it increases by 1 millisecond each round. TODO need to tune this for each network setup.

func MakeKey

func MakeKey(i sig.PubKeyIndex, to types.TestOptions) (p sig.Priv, err error)

MakeKey generates a private key for the given configuration.

func MakeKeys

func MakeKeys(to types.TestOptions) ([]sig.Priv, []sig.Pub)

MakeKeys generates a list of private and public keys for the configuration. The slices are sorted by the public key.

func MakeMemberChecker

func MakeMemberChecker(to types.TestOptions, randKey [32]byte, priv sig.Priv, pubKeys []sig.Pub,
	shared *consinterface.Shared,
	gc *generalconfig.GeneralConfig) (memberChecker consinterface.MemberChecker)

MakeMemberChecker generates a member checker for the given configuration initialized with pubKeys.

func MakePrivBlsS

func MakePrivBlsS(to types.TestOptions, thrsh int, idx sig.PubKeyIndex, blsShared *bls.BlsShared) (p sig.Priv, err error)

MakePrivBlsS create a private threshold key given that a BlsShared object has already been created.

func MakeUnusedKey

func MakeUnusedKey(i sig.PubKeyIndex, to types.TestOptions) (p sig.Priv, err error)

MakeUnusedKey generates a private key for a test. The key should not be used directly, instead used an input to functions to that only use the new functions of the interfaces to generate new key objects.

func MergeSigsForTest

func MergeSigsForTest(items []*deserialized.DeserializedItem)

MergeSigsForTest is used by certain unit tests to collect a set of singatures in a single message.

func OpenTestStore

func OpenTestStore(bufferSize int, st types.StorageType, idType storage.ConsensusIDType, i int, fileName string, shouldClear bool) storage.StoreInterface

OpenTestStore opens the storage object given the test configuration, this could be an in-memory store or an on-disk store.

func PartialBroadcastFunc

PartialBroadcastFunc is a helper function that broadcasts a partial message.

func RegisterOtherNodes

func RegisterOtherNodes(t assert.TestingT, to types.TestOptions, testProc channelinterface.MainChannel,
	genPub func(sig.PubKeyBytes) sig.Pub, parRegs ...network.PregInterface)

func RunBasicTests

func RunBasicTests(to types.TestOptions, consType types.ConsType, initItem consinterface.ConsItem,
	consConfigs ConfigOptions, toRun []int, t *testing.T)

RunConsType runs a test for the given configuration and inputs.

func RunByzTests

func RunByzTests(to types.TestOptions, consType types.ConsType, initItem consinterface.ConsItem,
	consConfigs ConfigOptions, toRun []int, t *testing.T)

func RunConsType

func RunConsType(initItem consinterface.ConsItem,
	broadcastFunc consinterface.ByzBroadcastFunc,
	options ConfigOptions,
	to types.TestOptions,
	t assert.TestingT)

RunConsType runs a test for the given configuration and inputs.

func RunFailureTests

func RunFailureTests(to types.TestOptions, consType types.ConsType, initItem consinterface.ConsItem,
	consConfigs ConfigOptions, toRun []int, t *testing.T)

RunConsType runs a test for the given configuration and inputs.

func RunMainLoop

func RunMainLoop(state ConsStateInterface, mc channelinterface.MainChannel)

RunMainLoop is the loop where the consensus operates. Messages are taken from the netowrk, then processesed sequentially by ConsState.

func RunMemstoreTest

func RunMemstoreTest(to types.TestOptions, consType types.ConsType, initItem consinterface.ConsItem,
	consConfigs ConfigOptions, toRun []int, t *testing.T)

func RunMsgDropTest

func RunMsgDropTest(to types.TestOptions, consType types.ConsType, initItem consinterface.ConsItem,
	consConfigs ConfigOptions, toRun []int, t *testing.T)

func RunMultiSigTests

func RunMultiSigTests(to types.TestOptions, consType types.ConsType, initItem consinterface.ConsItem,
	consConfigs ConfigOptions, toRun []int, t *testing.T)

RunConsType runs a test for the given configuration and inputs.

func RunP2pNwTests

func RunP2pNwTests(to types.TestOptions, consType types.ConsType, initItem consinterface.ConsItem,
	consConfigs ConfigOptions, toRun []int, t *testing.T)

RunConsType runs a test for the given configuration and inputs.

func RunRandMCTests

func RunRandMCTests(to types.TestOptions, consType types.ConsType, initItem consinterface.ConsItem,
	consConfigs ConfigOptions, runLocalRand bool, toRun []int, t *testing.T)

func SetConfigOptions

func SetConfigOptions(to types.TestOptions)

SetConfigOptions must be called at the beginning of every test to set configuration options.

func SetInitIndex

func SetInitIndex(initSM consinterface.CausalStateMachineInterface)

func SetTestConfigOptions

func SetTestConfigOptions(to *types.TestOptions, fistCall bool)

TODO clean this stuff up

func UpdateStorageAfterFail

func UpdateStorageAfterFail(to types.TestOptions, ds storage.StoreInterface)

func VerifyCausalDecisions

func VerifyCausalDecisions(to types.TestOptions, retExtraParRegInfo [][]byte,
	privKey sig.Priv, generalConfig *generalconfig.GeneralConfig, roots []*utils.StringNode,
	orderedDecisions [][]byte)

func VerifyDecisions

func VerifyDecisions(to types.TestOptions, retExtraParRegInfo [][]byte, consType types.ConsType,
	privKey sig.Priv, generalConfig *generalconfig.GeneralConfig, decs [][][]byte) consinterface.StateMachineInterface

func WaitConnections

func WaitConnections(t assert.TestingT, to types.TestOptions, testProc channelinterface.MainChannel, numCons []int)

Types

type AbsConsItem

type AbsConsItem struct {
	*generalconfig.GeneralConfig
	Index      types.ConsensusIndex // The index of this consensus
	PreHeaders []messages.MsgHeader // Headers to be appended to the beginning of all consensus messages for this specific consensus instance.

	CommitProof   []messages.MsgHeader // Proof of committal from last consensus round
	ConsItems     *consinterface.ConsInterfaceItems
	PrevItem      consinterface.ConsItem
	NextItem      consinterface.ConsItem
	Started       bool
	NeedsProposal bool
	BroadcastFunc consinterface.ByzBroadcastFunc
	GotProposal   bool
	MainChannel   channelinterface.MainChannel
	Decided       bool
	// contains filtered or unexported fields
}

AbsConsItem implements some of the methods from the consinterface.ConsItem interface and can be used as an abstract class for a ConsItem implementation.

func GenerateAbsState

GenerateAbsState should be called within consinterface.GenerateNewIem, it sets up the inital headers.

func (*AbsConsItem) AbsGotProposal

func (sc *AbsConsItem) AbsGotProposal()

func (*AbsConsItem) AbsStart

func (sc *AbsConsItem) AbsStart()

Start should be called once the consensus instance has started.

func (*AbsConsItem) AddPreHeader

func (sc *AbsConsItem) AddPreHeader(header messages.MsgHeader)

AddPreHeader appends a header that will be attached to all messages sent by this consensus item.

func (*AbsConsItem) Broadcast

func (sc *AbsConsItem) Broadcast(nxtCoordPub sig.Pub, auxMsg messages.InternalSignedMsgHeader,
	signMessage bool, forwardFunc channelinterface.NewForwardFuncFilter,
	mainChannel channelinterface.MainChannel, additionalMsgs ...messages.MsgHeader)

Broadcast a message. If nextCoordPub is nil the message will only be sent to that node, otherwise it will be sent as normal (nextCoordPub is used when CollectBroadcast is true in test options).

func (*AbsConsItem) CheckMemberLocal

func (sc *AbsConsItem) CheckMemberLocal() bool

CheckMemberLocal checks if the node is a member of the consensus.

func (*AbsConsItem) CheckMemberLocalMsg

func (sc *AbsConsItem) CheckMemberLocalMsg(hdr messages.InternalSignedMsgHeader) bool

CheckMemberLocalMsg checks if the local node is a member of the consensus for this message type

func (*AbsConsItem) Collect

func (sc *AbsConsItem) Collect()

func (*AbsConsItem) ComputeDecidedValue

func (sc *AbsConsItem) ComputeDecidedValue(state []byte, decision []byte) []byte

ComputeDecidedValue returns decision.

func (*AbsConsItem) ForwardOldIndices

func (sc *AbsConsItem) ForwardOldIndices() bool

ForwardOldIndices returns false.

func (*AbsConsItem) GetConsInterfaceItems

func (sc *AbsConsItem) GetConsInterfaceItems() *consinterface.ConsInterfaceItems

GetConsInterfaceItems returns the ConsInterfaceItems for this consesnsus instance.

func (*AbsConsItem) GetCustomRecoverMsg

func (sc *AbsConsItem) GetCustomRecoverMsg(createEmpty bool) messages.MsgHeader

GetCustomRecoverMsg is called when there is no progress after a timeout. It returns a NoProgress message.

func (*AbsConsItem) GetGeneralConfig

func (sc *AbsConsItem) GetGeneralConfig() *generalconfig.GeneralConfig

func (*AbsConsItem) GetIndex

func (sc *AbsConsItem) GetIndex() types.ConsensusIndex

GetIndex returns the consensus index of the item.

func (*AbsConsItem) GetPreHeader

func (sc *AbsConsItem) GetPreHeader() []messages.MsgHeader

GetPreHeader returns the header that is attached to all messages sent by this consensus item.

func (*AbsConsItem) GetPrevCommitProof

func (sc *AbsConsItem) GetPrevCommitProof() (cordPub 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. cordPub is nil here, but should be overwritten with the expected public key of the coordinator of the current round if the consensus supports collect broadcast

func (*AbsConsItem) GetRecoverMsgType

func (sc *AbsConsItem) GetRecoverMsgType() messages.HeaderID

GetRecoverMsgType returns the HeaderID of the recovery messages used by this consensus.

func (*AbsConsItem) HasStarted

func (sc *AbsConsItem) HasStarted() bool

HasStarted returns true if Start has ben called

func (*AbsConsItem) ProcessCustomRecoveryMessage

func (sc *AbsConsItem) ProcessCustomRecoveryMessage(item *deserialized.DeserializedItem,
	senderChan *channelinterface.SendRecvChannel)

ProcessCustomRecoveryMessage panics as this consensus does not use a custom recovery message (the recovery uses the default functions in the consensus state objects).

func (*AbsConsItem) SetCommitProof

func (sc *AbsConsItem) SetCommitProof(prf []messages.MsgHeader)

SetCommitProof takes the value returned from GetCommitProof of the previous consensus instance once it has decided. The consensus can then use this as needed.

func (*AbsConsItem) SetDecided

func (sc *AbsConsItem) SetDecided()

SetDecided should be called by the consensus implementation when a value is decided.

type AbsMVRecover

type AbsMVRecover struct {
	// contains filtered or unexported fields
}

func (*AbsMVRecover) BroadcastRequestRecover

func (sc *AbsMVRecover) BroadcastRequestRecover(preHeaders []messages.MsgHeader, hash []byte, forwardChecker consinterface.ForwardChecker,
	mainChannel channelinterface.MainChannel, items *consinterface.ConsInterfaceItems)

broadcastRequest broadcasts a message requesting the init message

func (*AbsMVRecover) GotRequestRecover

func (sc *AbsMVRecover) GotRequestRecover(validatedInitHashes map[types.HashStr]*deserialized.DeserializedItem,
	deser *deserialized.DeserializedItem, initHeaders []messages.MsgHeader, senderChan *channelinterface.SendRecvChannel,
	items *consinterface.ConsInterfaceItems)

func (*AbsMVRecover) InitAbsMVRecover

func (abs *AbsMVRecover) InitAbsMVRecover(index types.ConsensusIndex, gc *generalconfig.GeneralConfig)

func (*AbsMVRecover) SendRecover

func (sc *AbsMVRecover) SendRecover(validatedInitHashes map[types.HashStr]*deserialized.DeserializedItem,
	initHeaders []messages.MsgHeader, items *consinterface.ConsInterfaceItems)

sendRecover sends the init message to anyone who has send a RequestRecover message

func (*AbsMVRecover) StartRecoverTimeout

func (sc *AbsMVRecover) StartRecoverTimeout(index types.ConsensusIndex, channel channelinterface.MainChannel,
	mc *consinterface.MemCheckers)

func (*AbsMVRecover) StopRecoverTimeout

func (sc *AbsMVRecover) StopRecoverTimeout()

type BinConsInterface

type BinConsInterface interface {
	consinterface.ConsItem
	// CheckRound checks for the given round if enough messages have been received to progress to the next round
	// and return true if it can.
	CheckRound(nmt int, t int, round types.ConsensusRound,
		mainChannel channelinterface.MainChannel) bool
	// CanSkipMvTimeout returns true if the during the multivalue reduction the echo timeout can be skipped
	CanSkipMvTimeout() bool
	// GetBinDecided returns -1 if not decided, or the decided value, and the round decided.
	GetBinDecided() (int, types.ConsensusRound)
	// GetMVInitialRoundBroadcast returns the type of binary message that the multi-value reduction should broadcast for the initial round.
	GetMVInitialRoundBroadcast(val types.BinVal) messages.InternalSignedMsgHeader
}

BinConsInterface is an interface for sending binary consensus messages. Multivalue to binary consensus reductions may use it.

type CausalConsState

type CausalConsState struct {
	// contains filtered or unexported fields
}

ConsState runs and stores the details of the consensus, running the main loop. It runs all the generic code not specific to any consensus algorithm.

func NewCausalConsState

func NewCausalConsState(initIitem consinterface.ConsItem,
	generalConfig *config2.GeneralConfig,
	memberCheckerState *consinterface.CausalConsInterfaceState,
	store storage.StoreInterface,
	initStateMachine consinterface.CausalStateMachineInterface,
	mainChannel channelinterface.MainChannel) *CausalConsState

NetConsState initializes and returns a new consensus state object.

func (*CausalConsState) Collect

func (sc *CausalConsState) Collect()

Collect is called when the item is being garbage collected.

func (*CausalConsState) GetCausalDecisions

func (cs *CausalConsState) GetCausalDecisions() (root *utils.StringNode, orderedDecisions [][]byte)

GetCausalDecisions returns the decided values in causal order tree.

func (*CausalConsState) ProcessLocalMessage

func (cs *CausalConsState) ProcessLocalMessage(rcvMsg *channelinterface.RcvMsg)

ProcessLocalMessage should be called when a message sent from the local node is ready to be processed.

func (*CausalConsState) ProcessMessage

func (cs *CausalConsState) ProcessMessage(rcvMsg *channelinterface.RcvMsg) (returnMsg [][]byte, returnErrs []error)

ProcessMessage should be called when a message sent from an external node is ready to be processed. It returns a list of messages to be sent back to the sender of the original message (if any).

func (*CausalConsState) SMStats

func (cs *CausalConsState) SMStats() consinterface.SMStats

SMStats returns the stats object of the state machine.

func (*CausalConsState) SMStatsString

func (cs *CausalConsState) SMStatsString(testDuration time.Duration) string

SMStatsString returns the statistics of the state machine.

func (*CausalConsState) Start

func (cs *CausalConsState) Start()

type ConfigIter

type ConfigIter struct {
	// contains filtered or unexported fields
}

ConfigIter is an iterates over all combinations (exponential) of an OptionStruct starting from a base testOptions. It implements TestOpIterator. Why did I make this???

func (*ConfigIter) Next

func (ci *ConfigIter) Next() (itm types.TestOptions, hasNext bool)

Next returns the next test options, and if any more remain.

type ConfigOptions

type ConfigOptions interface {

	// GetIsMV returns true if the consensus is multi-value or false if binary.
	GetIsMV() bool
	// RequiresStaticMembership returns true if this consensus doesn't allow changing membership.
	RequiresStaticMembership() bool

	// GetStopOnCommitTypes returns the types to test when to terminate.
	GetStopOnCommitTypes(optionType GetOptionType) []types.StopOnCommitType
	// GetCoinTypes returns the types of coins allowed.
	GetCoinTypes(optionType GetOptionType) []types.CoinType
	// GetByzTypes returns the fault types to test.
	GetByzTypes(optionType GetOptionType) []types.ByzType
	// GetStateMachineTypes returns the types of state machines to test.
	GetStateMachineTypes(GetOptionType) []types.StateMachineType
	// GetOrderingTypes returns the types of ordering supported by the consensus.
	GetOrderingTypes(GetOptionType) []types.OrderingType
	// GetStateMachineTypes  returns the types of state machines supported by the consensus
	GetSigTypes(GetOptionType) []types.SigType
	// GetUsePubIndex returns the values for if the consensus supports using pub index or not or both.
	GetUsePubIndexTypes(GetOptionType) []bool
	// GetIncludeProofTypes returns the values for if the consensus supports including proofs or not or both.
	GetIncludeProofsTypes(GetOptionType) []bool
	// GetMemberCheckerTypes returns the types of member checkers valid for the consensus.
	GetMemberCheckerTypes(GetOptionType) []types.MemberCheckerType
	// GetRandMemberCheckerTypes returns the types of random member checkers supported by the consensus
	GetRandMemberCheckerTypes(GetOptionType) []types.RndMemberType
	// GetUseMultiSigTypes() []bool
	// GetRotateCoordTypes returns the values for if the consensus supports rotating coordinator or not or both.
	GetRotateCoordTypes(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.
	GetAllowSupportCoinTypes(GetOptionType) []bool
	// GetAllowConcurrentTypes returns the values for if the consensus supports running concurrent consensus instances
	// when using total ordering or not or both.
	GetAllowConcurrentTypes(GetOptionType) []bool
	// GetCollectBroadcast returns the values for if the consensus supports broadcasting the commit message
	// directly to the leader.
	GetCollectBroadcast(GetOptionType) []types.CollectBroadcastType
	// GetBroadcastFunc returns the broadcast function for the given byzantine type
	GetBroadcastFunc(types.ByzType) consinterface.ByzBroadcastFunc
	// GetAllowNoSignatures returns true if the consensus can run without signatures
	GetAllowNoSignatures(GetOptionType) []bool
	// GetAllowsNonMembers returns true if there can be replicas that are not members of the consensus.
	GetAllowsNonMembers() bool
}

ConfigOptions is an interface that returns the set of valid configurations for a given consensus implementation. Each consensus implementation should create an implementation of this interface so tests can be run on the valid configs.

type ConsInitState

type ConsInitState struct {
	IncludeProofs bool // If true messages should include a list of current signautures received for that message.

	// These will only be set when running tests.
	Id uint32 // The id of the node.
	N  uint32 // The number of nodes participating.
}

ConsInitSate is used as an input to the consensus initalization, and provoides extra configuration details.

type ConsState

type ConsState struct {
	// contains filtered or unexported fields
}

ConsState runs and stores the details of the consensus, running the main loop. It runs all the generic code not specific to any consensus algorithm.

func NewConsState

func NewConsState(initIitem consinterface.ConsItem,
	generalConfig *generalconfig.GeneralConfig,
	memberCheckerState *consinterface.ConsInterfaceState,
	store storage.StoreInterface,
	maxInstances types.ConsensusInt,
	allowConcurrent types.ConsensusInt,
	initStateMachine consinterface.StateMachineInterface, mainChannel channelinterface.MainChannel) *ConsState

NetConsState initializes and returns a new consensus state object.

func (*ConsState) Collect

func (cs *ConsState) Collect()

Collect is called when the process is terminating.

func (*ConsState) ProcessLocalMessage

func (cs *ConsState) ProcessLocalMessage(rcvMsg *channelinterface.RcvMsg)

ProcessLocalMessage should be called when a message sent from the local node is ready to be processed.

func (*ConsState) ProcessMessage

func (cs *ConsState) ProcessMessage(rcvMsg *channelinterface.RcvMsg) (returnMsg [][]byte, returnErrs []error)

ProcessMessage should be called when a message sent from an external node is ready to be processed. It returns a list of messages to be sent back to the sender of the original message (if any).

func (*ConsState) SMStats

func (cs *ConsState) SMStats() consinterface.SMStats

SMStats returns the stats object of the state machine.

func (*ConsState) SMStatsString

func (cs *ConsState) SMStatsString(testDuration time.Duration) string

SMStatsString prints the statistics of the state machine.

func (*ConsState) Start

func (cs *ConsState) Start()

type ConsStateInterface

type ConsStateInterface interface {
	Start()
	// ProcessMessage should be called when a message sent from an external node is ready to be processed.
	// It returns a list of messages to be sent back to the sender of the original message (if any).
	ProcessMessage(rcvMsg *channelinterface.RcvMsg) (returnMsg [][]byte, returnErrs []error)

	// ProcessLocalMessage should be called when a message sent from the local node is ready to be processed.
	ProcessLocalMessage(rcvMsg *channelinterface.RcvMsg)

	// SMStatsString prints the statistics of the state machine.
	SMStatsString(testDuration time.Duration) string
	// SMStats returns the stats object of the state machine.
	SMStats() consinterface.SMStats

	// Collect is called when the process is terminating
	Collect()
}

func GenerateConsState

func GenerateConsState(t assert.TestingT, to types.TestOptions, priv sig.Priv, randKey [32]byte, proposer sig.Pub,
	pubKeys sig.PubList, i int, initItem consinterface.ConsItem, ds storage.StoreInterface, stats stats.StatsInterface,
	retExtraParRegInfo [][]byte, testProc channelinterface.MainChannel, finishedChan chan channelinterface.ChannelCloseType,
	generalConfig *generalconfig.GeneralConfig, broadcastFunc consinterface.ByzBroadcastFunc, shared *consinterface.Shared,
	isFailure bool, parRegs ...network.PregInterface) (ret ConsStateInterface, memberCheckerState consinterface.ConsStateInterface)

type ConsTestItems

type ConsTestItems struct {
	PrivKeys []sig.Priv // the private keys used in the test
	PubKeys  []sig.Pub  // the public keys used in the test
}

ConsTestItems are used as input to certain unit tests.

type DeserSortVRF

type DeserSortVRF []*deserialized.DeserializedItem

DeserSortVRF must only contain sig.MultiSignedMessages with a single signature. They will be sorted by the signature's VRFID. This is used by cons who need to decide which leader message to echo when their timeout has run out when random member selection is enabled.

func CheckForwardProposal

func CheckForwardProposal(deser *deserialized.DeserializedItem,
	hashStr types.HashStr, decisionHash types.HashStr, sortedInitHashesIn DeserSortVRF,
	items *consinterface.ConsInterfaceItems) (sortedInitHashes DeserSortVRF, shouldForward bool)

CheckForwardProposal is called by multivalue consensus. It keeps track of sorted proposals by their VRFs and says the forward the ones with the minimum VRFs seen so far.

func (DeserSortVRF) Len

func (a DeserSortVRF) Len() int

func (DeserSortVRF) Less

func (a DeserSortVRF) Less(i, j int) bool

func (DeserSortVRF) Swap

func (a DeserSortVRF) Swap(i, j int)

type GetOptionType

type GetOptionType int
const (
	AllOptions GetOptionType = iota
	MinOptions
)

type OptionStruct

type OptionStruct struct {
	StopOnCommitTypes      []types.StopOnCommitType
	OrderingTypes          []types.OrderingType
	ByzTypes               []types.ByzType
	StateMachineTypes      []types.StateMachineType
	SigTypes               []types.SigType
	UsePubIndexTypes       []bool
	IncludeProofsTypes     []bool
	MemberCheckerTypes     []types.MemberCheckerType
	RandMemberCheckerTypes []types.RndMemberType
	RotateCoordTypes       []bool
	AllowSupportCoinTypes  []bool
	AllowConcurrentTypes   []types.ConsensusInt
	CollectBroadcast       []types.CollectBroadcastType
	EncryptChannelsTypes   []bool
	AllowNoSignaturesTypes []bool
	CoinTypes              []types.CoinType
	UseFixedCoinPresets    []bool
}

OptionStruct represents a set of options represented by the functions of ConfigOptions.

func ReplaceNilFields

func ReplaceNilFields(os, other OptionStruct) OptionStruct

ReplaceNilFields replaces the nil fields of os with those of other.

func (OptionStruct) ComputeMaxConfigs

func (os OptionStruct) ComputeMaxConfigs() int

ComputeMaxConfigs returns the number of possible combinations of the fields of os.

type SimpleCons

type SimpleCons struct {
	AbsConsItem
	// contains filtered or unexported fields
}

SimpleCons is just for testing the consensus functionality. Each round each node sends a single SimpleConsMessage containing its public key, the instance is complete when a node has received the SimpleConsMessage from all nodes.

func (*SimpleCons) AllowsOutOfOrderProposals

func (*SimpleCons) AllowsOutOfOrderProposals() bool

AllowsOutOfOrderProposals returns false.

func (*SimpleCons) CanStartNext

func (sc *SimpleCons) CanStartNext() bool

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

func (*SimpleCons) Collect

func (sc *SimpleCons) Collect()

Collect is called when the item is being garbage collected.

func (*SimpleCons) GenerateMessageState

GenerateMessageState generates a new message state object given the inputs.

func (*SimpleCons) GenerateNewItem

GenerateNewItem creates a new simple cons item.

func (*SimpleCons) GetBinState

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

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.HdrSimpleCons, which returns 1, 1 for the thresholds, meaning to forward it as soon as you see it, since each message is unique from each process.

func (*SimpleCons) GetCommitProof

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

GetCommitProof returns nil as SimpleCons has no proofs.

func (*SimpleCons) GetConsType

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

GetConsType returns the type of consensus this instance implements.

func (*SimpleCons) GetDecision

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

GetDecision returns the decided value which is []byte(fmt.Sprintf("simpleCons%v", sc.Index)).

func (SimpleCons) GetHeader

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.HdrSimpleCons are valid headerIDs.

func (*SimpleCons) GetNextInfo

func (sc *SimpleCons) GetNextInfo() (prevIdx types.ConsensusIndex, proposer sig.Pub, preDecision []byte, canStartNext 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 (*SimpleCons) GetProposalIndex

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

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

func (*SimpleCons) GetProposeHeaderID

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

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

func (*SimpleCons) GotProposal

func (sc *SimpleCons) GotProposal(_ messages.MsgHeader, mainChannel channelinterface.MainChannel) error

GotProposal takes the proposal, creates a SimpleConsMessage and broadcasts it.

func (*SimpleCons) HasDecided

func (sc *SimpleCons) HasDecided() bool

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

func (*SimpleCons) HasValidStarted

func (sc *SimpleCons) HasValidStarted() bool

HasReceivedProposal panics because SimpleCons has no proposals.

func (*SimpleCons) NeedsCompletionConcurrentProposals

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

NeedsConcurrent returns 1.

func (*SimpleCons) PrevHasBeenReset

func (sc *SimpleCons) PrevHasBeenReset()

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

func (*SimpleCons) ProcessMessage

func (sc *SimpleCons) ProcessMessage(
	deser *deserialized.DeserializedItem,
	isLocal bool,
	senderChan *channelinterface.SendRecvChannel) (bool, bool)

func (sc *SimpleCons) Broadcast(nxtCoordPub sig.Pub, auxMsg messages.InternalSignedMsgHeader,

	forwardFunc channelinterface.NewForwardFuncFilter,
	mainChannel channelinterface.MainChannel, additionalMsgs ...messages.MsgHeader) {

	DoConsBroadcast(nxtCoordPub, auxMsg, !sc.GeneralConfig.NoSignatures, additionalMsgs, forwardFunc,
		sc.ConsItems, mainChannel, sc.GeneralConfig)
}

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. 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 tracks from which nodes we have received the SimpleConsMessage so far, and once n are recieved, the "consensus" is finished.

func (*SimpleCons) SetInitialState

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

SetInitialState does noting for this algorithm.

func (*SimpleCons) SetNextConsItem

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

func (sc *SimpleCons) ShouldCreatePartial(messages.HeaderID) bool

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

func (*SimpleCons) Start

func (sc *SimpleCons) Start(finishedLastRound bool)

Start allows GetProposalIndex to return true.

type SimpleConsConfig

type SimpleConsConfig struct{}

func (SimpleConsConfig) GetAllowConcurrentTypes

func (SimpleConsConfig) GetAllowConcurrentTypes(gt GetOptionType) []bool

GetAllowConcurrentTypes returns the values for if the consensus supports running concurrent consensus instances when using total ordering or not or both.

func (SimpleConsConfig) GetAllowNoSignatures

func (SimpleConsConfig) GetAllowNoSignatures(GetOptionType) []bool

GetAllowNoSignatures returns true if the consensus can run without signatures

func (SimpleConsConfig) GetAllowSupportCoinTypes

func (SimpleConsConfig) GetAllowSupportCoinTypes(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 (SimpleConsConfig) GetAllowsNonMembers

func (SimpleConsConfig) GetAllowsNonMembers() bool

GetAllowsNonMembers returns true if there can be replicas that are not members of the consensus.

func (SimpleConsConfig) GetBroadcastFunc

GetBroadcastFunc returns the broadcast function for the given byzantine type

func (SimpleConsConfig) GetByzTypes

GetByzTypes returns the fault types to test.

func (SimpleConsConfig) GetCoinTypes

func (SimpleConsConfig) GetCoinTypes(GetOptionType) []types.CoinType

GetCoinTypes returns the types of coins allowed.

func (SimpleConsConfig) GetCollectBroadcast

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

func (SimpleConsConfig) GetIncludeProofsTypes

func (SimpleConsConfig) GetIncludeProofsTypes(GetOptionType) []bool

GetIncludeProofTypes returns the values for if the consensus supports including proofs or not or both.

func (SimpleConsConfig) GetIsMV

func (SimpleConsConfig) GetIsMV() bool

GetIsMV returns false.

func (SimpleConsConfig) GetMemberCheckerTypes

func (SimpleConsConfig) GetMemberCheckerTypes(gt GetOptionType) []types.MemberCheckerType

GetMemberCheckerTypes returns the types of member checkers valid for the consensus.

func (SimpleConsConfig) GetOrderingTypes

func (SimpleConsConfig) GetOrderingTypes(GetOptionType) []types.OrderingType

GetOrderingTypes returns the types of ordering supported by the consensus.

func (SimpleConsConfig) GetRandMemberCheckerTypes

func (SimpleConsConfig) GetRandMemberCheckerTypes(GetOptionType) []types.RndMemberType

GetRandMemberCheckerTypes returns the types of random member checkers supported by the consensus

func (SimpleConsConfig) GetRotateCoordTypes

func (SimpleConsConfig) GetRotateCoordTypes(GetOptionType) []bool

GetUseMultiSigTypes() []bool GetRotateCoordTypes returns the values for if the consensus supports rotating coordinator or not or both.

func (SimpleConsConfig) GetSigTypes

func (SimpleConsConfig) GetSigTypes(gt GetOptionType) []types.SigType

GetSigTypes return the types of signatures supported by the consensus

func (SimpleConsConfig) GetStateMachineTypes

func (SimpleConsConfig) GetStateMachineTypes(GetOptionType) []types.StateMachineType

GetStateMachineTypes returns the types of state machines to test.

func (SimpleConsConfig) GetStopOnCommitTypes

func (SimpleConsConfig) GetStopOnCommitTypes(GetOptionType) []types.StopOnCommitType

GetStopOnCommitTypes returns the types to test when to terminate.

func (SimpleConsConfig) GetUsePubIndexTypes

func (SimpleConsConfig) GetUsePubIndexTypes(gt GetOptionType) []bool

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

func (SimpleConsConfig) RequiresStaticMembership

func (SimpleConsConfig) RequiresStaticMembership() bool

RequiresStaticMembership returns true if this consensus doesn't allow changing membership.

type SingleIter

type SingleIter struct {
	// contains filtered or unexported fields
}

SingleIter starts with a base test options, then iterates through each field of the test configs, changing one value then going back to the original test options. I.e. if the number of elements in all the slices of testConfigs is 10, then 10 tests are run.

func (*SingleIter) Next

func (ci *SingleIter) Next() (itm types.TestOptions, hasNext bool)

Next returns the next test options, and if any more remain.

type StandardBinConfig

type StandardBinConfig struct{}

func (StandardBinConfig) GetAllowConcurrentTypes

func (StandardBinConfig) GetAllowConcurrentTypes(gt GetOptionType) []bool

GetAllowConcurrentTypes returns the values for if the consensus supports running concurrent consensus instances when using total ordering or not or both.

func (StandardBinConfig) GetAllowNoSignatures

func (StandardBinConfig) GetAllowNoSignatures(GetOptionType) []bool

GetAllowNoSignatures returns true if the consensus can run without signatures

func (StandardBinConfig) GetAllowSupportCoinTypes

func (StandardBinConfig) GetAllowSupportCoinTypes(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 (StandardBinConfig) GetAllowsNonMembers

func (StandardBinConfig) GetAllowsNonMembers() bool

GetAllowsNonMembers returns true if there can be replicas that are not members of the consensus.

func (StandardBinConfig) GetBroadcastFunc

GetBroadcastFunc returns the broadcast function for the given byzantine type

func (StandardBinConfig) GetByzTypes

GetByzTypes returns the fault types to test.

func (StandardBinConfig) GetCoinTypes

GetCoinTypes returns the types of coins allowed.

func (StandardBinConfig) GetCollectBroadcast

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

func (StandardBinConfig) GetIncludeProofsTypes

func (StandardBinConfig) GetIncludeProofsTypes(gt GetOptionType) []bool

GetIncludeProofTypes returns the values for if the consensus supports including proofs or not or both.

func (StandardBinConfig) GetIsMV

func (StandardBinConfig) GetIsMV() bool

GetIsMV returns false.

func (StandardBinConfig) GetMemberCheckerTypes

func (StandardBinConfig) GetMemberCheckerTypes(gt GetOptionType) []types.MemberCheckerType

GetMemberCheckerTypes returns the types of member checkers valid for the consensus.

func (StandardBinConfig) GetOrderingTypes

func (StandardBinConfig) GetOrderingTypes(gt GetOptionType) []types.OrderingType

GetOrderingTypes returns the types of ordering supported by the consensus.

func (StandardBinConfig) GetRandMemberCheckerTypes

func (StandardBinConfig) GetRandMemberCheckerTypes(GetOptionType) []types.RndMemberType

GetRandMemberCheckerTypes returns the types of random member checkers supported by the consensus

func (StandardBinConfig) GetRotateCoordTypes

func (StandardBinConfig) GetRotateCoordTypes(gt GetOptionType) []bool

GetUseMultiSigTypes() []bool GetRotateCoordTypes returns the values for if the consensus supports rotating coordinator or not or both.

func (StandardBinConfig) GetSigTypes

func (StandardBinConfig) GetSigTypes(gt GetOptionType) []types.SigType

GetSigTypes return the types of signatures supported by the consensus

func (StandardBinConfig) GetStateMachineTypes

func (StandardBinConfig) GetStateMachineTypes(GetOptionType) []types.StateMachineType

GetStateMachineTypes returns the types of state machines to test.

func (StandardBinConfig) GetStopOnCommitTypes

func (StandardBinConfig) GetStopOnCommitTypes(optionType GetOptionType) []types.StopOnCommitType

GetStopOnCommitTypes returns the types to test when to terminate.

func (StandardBinConfig) GetUsePubIndexTypes

func (StandardBinConfig) GetUsePubIndexTypes(gt GetOptionType) []bool

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

func (StandardBinConfig) RequiresStaticMembership

func (StandardBinConfig) RequiresStaticMembership() bool

RequiresStaticMembership returns true if this consensus doesn't allow changing membership.

type StandardMvConfig

type StandardMvConfig struct{}

func (StandardMvConfig) GetAllowConcurrentTypes

func (StandardMvConfig) GetAllowConcurrentTypes(gt GetOptionType) []bool

GetAllowConcurrentTypes returns the values for if the consensus supports running concurrent consensus instances when using total ordering or not or both.

func (StandardMvConfig) GetAllowNoSignatures

func (StandardMvConfig) GetAllowNoSignatures(GetOptionType) []bool

GetAllowNoSignatures returns true if the consensus can run without signatures

func (StandardMvConfig) GetAllowSupportCoinTypes

func (StandardMvConfig) GetAllowSupportCoinTypes(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 (StandardMvConfig) GetAllowsNonMembers

func (StandardMvConfig) GetAllowsNonMembers() bool

GetAllowsNonMembers returns true if there can be replicas that are not members of the consensus.

func (StandardMvConfig) GetBroadcastFunc

GetBroadcastFunc returns the broadcast function for the given byzantine type

func (StandardMvConfig) GetByzTypes

GetByzTypes returns the fault types to test.

func (StandardMvConfig) GetCoinTypes

func (StandardMvConfig) GetCoinTypes(GetOptionType) []types.CoinType

GetCoinTypes returns the types of coins allowed.

func (StandardMvConfig) GetCollectBroadcast

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

func (StandardMvConfig) GetIncludeProofsTypes

func (StandardMvConfig) GetIncludeProofsTypes(gt GetOptionType) []bool

GetIncludeProofTypes returns the values for if the consensus supports including proofs or not or both.

func (StandardMvConfig) GetIsMV

func (StandardMvConfig) GetIsMV() bool

GetIsMV returns true.

func (StandardMvConfig) GetMemberCheckerTypes

func (StandardMvConfig) GetMemberCheckerTypes(gt GetOptionType) []types.MemberCheckerType

GetMemberCheckerTypes returns the types of member checkers valid for the consensus.

func (StandardMvConfig) GetOrderingTypes

func (StandardMvConfig) GetOrderingTypes(gt GetOptionType) []types.OrderingType

GetOrderingTypes returns the types of ordering supported by the consensus.

func (StandardMvConfig) GetRandMemberCheckerTypes

func (StandardMvConfig) GetRandMemberCheckerTypes(gt GetOptionType) []types.RndMemberType

GetRandMemberCheckerTypes returns the types of random member checkers supported by the consensus

func (StandardMvConfig) GetRotateCoordTypes

func (StandardMvConfig) GetRotateCoordTypes(gt GetOptionType) []bool

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

func (StandardMvConfig) GetSigTypes

func (StandardMvConfig) GetSigTypes(gt GetOptionType) []types.SigType

GetSigTypes return the types of signatures supported by the consensus

func (StandardMvConfig) GetStateMachineTypes

func (StandardMvConfig) GetStateMachineTypes(GetOptionType) []types.StateMachineType

GetStateMachineTypes returns the types of state machines to test.

func (StandardMvConfig) GetStopOnCommitTypes

func (StandardMvConfig) GetStopOnCommitTypes(GetOptionType) []types.StopOnCommitType

GetStopOnCommitTypes returns the types to test when to terminate.

func (StandardMvConfig) GetUsePubIndexTypes

func (StandardMvConfig) GetUsePubIndexTypes(gt GetOptionType) []bool

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

func (StandardMvConfig) RequiresStaticMembership

func (StandardMvConfig) RequiresStaticMembership() bool

RequiresStaticMembership returns true if this consensus doesn't allow changing membership.

type TestOptIter

type TestOptIter struct {
	// contains filtered or unexported fields
}

TestOptIter implements an iterator that only returns TestOptions that are valid for a given config options. It implements TestOpIterator.

func NewTestOptIter

func NewTestOptIter(opt GetOptionType, consConfigs ConfigOptions,
	toIter TestOptionIterator) (*TestOptIter, error)

NewTestOptIter takes as input a TestOptIterator, and a consensus config options. It creates an iterator that iterates toIter, but only returns the TestOptions that are valid for the config options. It implements TestOpIterator.

func (*TestOptIter) Next

func (toi *TestOptIter) Next() (to types.TestOptions, hasNext bool)

Next returns the next test options, and if any more remain.

type TestOptionIterator

type TestOptionIterator interface {
	// Next returns the next test options, and if any more remain.
	Next() (itm types.TestOptions, hasNext bool)
}

TestOptionIterator is an interface for iterating TestOptions.

func NewAllConfigIter

func NewAllConfigIter(testConfigs OptionStruct, to types.TestOptions) TestOptionIterator

NewAllConfigIter creates an iterator starting at to, then going through all combinations of testConfigs.

func NewSingleIter

func NewSingleIter(testConfigs OptionStruct, to types.TestOptions) TestOptionIterator

NewSingleIter returns a iterator through the testConfigs with to used as the base config. It implements TestOpIterator.

type TimeoutState

type TimeoutState int

TimeoutState is used to store the current state of a local timeout. Within the consensus timeouts act a messages sent to the local process, that are processed in the main consensus loop after the timeout expires.

const (
	TimeoutNotSent TimeoutState = iota // The timeout has not been started.
	TimeoutSent                        // The timeout has started but not passed.
	TimeoutPassed                      // The timeout has passed.
)

Directories

Path Synopsis
Implementation of signature based binary consensus algorithm.
Implementation of signature based binary consensus algorithm.
Implementation of signature based binary consensus algorithm.
Implementation of signature based binary consensus algorithm.
Implementation of non-signature based binary consensus algorithm.
Implementation of non-signature based binary consensus algorithm.
Implementation of signature based binary consensus algorithm.
Implementation of signature based binary consensus algorithm.
Implementation of signature based binary consensus algorithm.
Implementation of signature based binary consensus algorithm.
Implementation of signature based binary consensus algorithm.
Implementation of signature based binary consensus algorithm.
Implementation of signature based binary consensus algorithm.
Implementation of signature based binary consensus algorithm.
Implementation of multi-valued consensus reduction to BinCons1.
Implementation of multi-valued consensus reduction to BinCons1.
Implementation of multi-valued consensus in the likeness of PBFT.
Implementation of multi-valued consensus in the likeness of PBFT.
Implementation of multi-valued consensus in the likeness of PBFT.
Implementation of multi-valued consensus in the likeness of PBFT.
Implementation of multi-valued consensus in the likeness of PBFT.
Implementation of multi-valued consensus in the likeness of PBFT.

Jump to

Keyboard shortcuts

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