types

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

Documentation

Index

Constants

View Source
const (
	UseSignatures = iota
	NoSignatures
	ConsDependentSignatures
)
View Source
const (
	NonEncryptedChannels = iota
	EncryptedChannels
	ConsDepedentChannels
)

Variables

View Source
var AllCoins = append(StrongCoins, WeakCoins...) // append([]CoinType{NoCoinType}, append(StrongCoins, WeakCoins...)...)
View Source
var AllCollectBroadcast = []CollectBroadcastType{Full, Commit, EchoCommit}

AllMC is a list of all the possible member checker types.

View Source
var AllStopOnCommitTypes = []StopOnCommitType{Immediate, NextRound, SendProof}
View Source
var BasicSigTypes = []SigType{EC, ED, SCHNORR, BLS, QSAFE}
View Source
var BinaryProposerTypes = []StateMachineType{BinaryProposer}

BinaryProposerTypes are the StateMachineTypes that are valid to use with binary consensus

View Source
var BothOrders = []OrderingType{Total, Causal}
View Source
var CoinSigTypes = append(ThrshSigTypes, EDCOIN)
View Source
var EncryptChannelsSigTypes = []SigType{EC, ED, SCHNORR, EDCOIN, BLS, TBLS, TBLSDual, CoinDual}
View Source
var ErrAlreadyCombinedPartials = fmt.Errorf("has already combined partials")
View Source
var ErrAlreadyConsumedEcho = fmt.Errorf("already consumed echo")

causal

View Source
var ErrAlreadyReceivedMessage = fmt.Errorf("already received message")
View Source
var ErrClosingTime = fmt.Errorf("time to close")
View Source
var ErrCoinAlreadyProcessed = fmt.Errorf("coin already processed for this round")
View Source
var ErrCoinProofNotSupported = fmt.Errorf("coin proofs not supported by signature type")
View Source
var ErrConnAlreadyExists = fmt.Errorf("connection already exists")

csnet

View Source
var ErrConnDoesntExist = fmt.Errorf("connection doesn't exist")
View Source
var ErrConsAlreadyDecided = fmt.Errorf("consensus index already decided")
View Source
var ErrDecryptionFailed = fmt.Errorf("decryption failed")
View Source
var ErrDeserialize = fmt.Errorf("error deserialize")
View Source
var ErrDontForwardMessage = fmt.Errorf("message should not be forwarded")
View Source
var ErrDuplicatePartial = fmt.Errorf("duplicate partial")
View Source
var ErrDuplicateRemoteAncestors = fmt.Errorf("duplicate remote ancestors")
View Source
var ErrDuplicateRoundCoord = fmt.Errorf("dupliate round coordinator message")
View Source
var ErrEventAlreadyGC = fmt.Errorf("event already garbage collected")
View Source
var ErrEventExists = fmt.Errorf("event already exists")
View Source
var ErrHashIdxOutOfRange = fmt.Errorf("partial message hash index out of range")

partial Message

View Source
var ErrIncorrectNumPartials = fmt.Errorf("incorrect number of partials")
View Source
var ErrIndexTooNew = fmt.Errorf("index too far in future")
View Source
var ErrIndexTooOld = fmt.Errorf("index too old")
View Source
var ErrIntersectingBitIDs = fmt.Errorf("must not have intersecting bitIDs to merge sigs")
View Source
var ErrInvalidBinStateMsg = fmt.Errorf("invalid bin state msg")
View Source
var ErrInvalidBitID = fmt.Errorf("invalid BitID")

used by bls sig

View Source
var ErrInvalidBitIDEncoding = fmt.Errorf("invalid bitID encoding")
View Source
var ErrInvalidBitIDSub = fmt.Errorf("invalid BitID subtraction")
View Source
var ErrInvalidBuffSize = fmt.Errorf("invalid buffer size")
View Source
var ErrInvalidFormat = fmt.Errorf("string in invalid format")

channel

View Source
var ErrInvalidHash = fmt.Errorf("invalid Hash")
View Source
var ErrInvalidHashSize = fmt.Errorf("invalid input size")
View Source
var ErrInvalidHeader = fmt.Errorf("got an invalid msg header")
View Source
var ErrInvalidIndex = fmt.Errorf("index not in range")
View Source
var ErrInvalidKeySize = fmt.Errorf("invalid key size")

storage

View Source
var ErrInvalidMsgSize = fmt.Errorf("invalid msg size")
View Source
var ErrInvalidPartialIndecies = fmt.Errorf("invalid partial msg indecies to reconstruct")
View Source
var ErrInvalidProposal = fmt.Errorf("invalid proposal")
View Source
var ErrInvalidPub = fmt.Errorf("inavlid pub")
View Source
var ErrInvalidPubIndex = fmt.Errorf("invalid pub index")
View Source
var ErrInvalidRemoteAncestor = fmt.Errorf("invalid remote ancestor")
View Source
var ErrInvalidRemoteAncestorCount = fmt.Errorf("invalid number of remote ancestors")
View Source
var ErrInvalidRound = fmt.Errorf("invalid round")

mvcons1

View Source
var ErrInvalidRoundCoord = fmt.Errorf("invalid round coordinator")
View Source
var ErrInvalidSessionID = fmt.Errorf("invalid session id")
View Source
var ErrInvalidSharedThresh = fmt.Errorf("invalid shared threshold setup object")
View Source
var ErrInvalidSig = fmt.Errorf("invalid sig")
View Source
var ErrInvalidSigCount = fmt.Errorf("invalid number of signatures")
View Source
var ErrInvalidSigEncoding = fmt.Errorf("invalid sig encoding")
View Source
var ErrInvalidSigType = fmt.Errorf("invalid sig type")

used by auth/sig

View Source
var ErrInvalidStage = fmt.Errorf("invalid message stage")
View Source
var ErrInvalidVRFProof = fmt.Errorf("invalid vrf proof")
View Source
var ErrInvalidVarint = fmt.Errorf("invalid var int")
View Source
var ErrMemCheckerNotReady = fmt.Errorf("memberchecker not ready")
View Source
var ErrMsgNotFound = fmt.Errorf("msg not found")
View Source
var ErrNilMsg = fmt.Errorf("nil msg")
View Source
var ErrNilPriv = fmt.Errorf("nil priv key")
View Source
var ErrNilProposal = fmt.Errorf("proposal must not be nil")
View Source
var ErrNilPub = fmt.Errorf("nil pub key")
View Source
var ErrNoEchoHash = fmt.Errorf("tried to get proofs for an echo message before sending the hash")
View Source
var ErrNoFixedCoord = fmt.Errorf("no fixed coord")
View Source
var ErrNoItems = fmt.Errorf("no more items to iterate")
View Source
var ErrNoNewSigs = fmt.Errorf("no new sigs")
View Source
var ErrNoProofs = fmt.Errorf("no proofs for round")

bincons1

View Source
var ErrNoPubBytes = fmt.Errorf("missing pub bytes")
View Source
var ErrNoRemovedCons = fmt.Errorf("no removed connections")
View Source
var ErrNoValidSigs = fmt.Errorf("no valid sigs")
View Source
var ErrNotEnoughBytes = fmt.Errorf("not enough bytes to read")
View Source
var ErrNotEnoughConnections = fmt.Errorf("not enough connections")
View Source
var ErrNotEnoughPartials = fmt.Errorf("not enough partial signatures")
View Source
var ErrNotEnoughSigs = fmt.Errorf("not enough sigs")
View Source
var ErrNotMember = fmt.Errorf("not a member")

member checker

View Source
var ErrNotOwner = fmt.Errorf("inputs owned by different pubs")
View Source
var ErrNotReceivedVRFProof = fmt.Errorf("have not received node's VRF proof")

when using random membership

View Source
var ErrParentNotFound = fmt.Errorf("parent index not found")
View Source
var ErrPrevIndexNotFound = fmt.Errorf("previous index not found")

graph

View Source
var ErrPubNotFound = fmt.Errorf("should register connection info before requesting")

ParticipantRegister

View Source
var ErrThresholdSigsNotSupported = fmt.Errorf("threshold signatures not supported")
View Source
var ErrTimeout = fmt.Errorf("timeout")
View Source
var ErrTooLargeBitID = fmt.Errorf("bitID too large")
View Source
var ErrTooManyAdditionalIndices = fmt.Errorf("message has too many additional indices")
View Source
var ErrUnsortedBitID = fmt.Errorf("bitID must be sorted")
View Source
var ErrWrongMemberChecker = fmt.Errorf("wrong member checker")
View Source
var ErrWrongMessageType = fmt.Errorf("tried to deserialize wrong message type")

msg

View Source
var HashIndexFuns = ConsensusIndexFuncs{
	ConsensusIDUnMarshaler: ConsensusHashUnmarshaler,
	ComputeConsensusID:     GenerateParentHash,
}
View Source
var IntIndexFuns = ConsensusIndexFuncs{
	ConsensusIDUnMarshaler: ConsensusIntUnmarshaler,
	ComputeConsensusID:     SingleComputeConsensusID,
}
View Source
var MultiSigTypes = []SigType{BLS}

MultivalueProposerTypes are the StateMachineTypes that are valid to use with multivalue consensus

View Source
var MultivalueProposerTypesNoCurrency = []StateMachineType{BytesProposer, CounterProposer,
	CounterTxProposer}

MultivalueProposerTypesNoCurrency is the same as MultivalueProposerTypes except without CurrencyTxProposer

View Source
var NetworkProtocolTypes = []NetworkProtocolType{UDP, TCP}

NetworkProtocolTypes lists all the posilbe network protocol type

View Source
var ThrshSigTypes = []SigType{TBLS, TBLSDual, CoinDual}
View Source
var TotalOrderProposerTypes = append(BinaryProposerTypes, MultivalueProposerTypes...)
View Source
var VRFSigTypes = []SigType{EC, BLS}
View Source
var WeakCoins = []CoinType{LocalCoinType}
View Source
var WithBothBool = []bool{true, false}
View Source
var WithFalse = []bool{false}

Functions

func AllowsGetRandBytes

func AllowsGetRandBytes(smType StateMachineType) bool

func CheckStrongCoin

func CheckStrongCoin(coinType CoinType) bool

func ComputeNumRounds

func ComputeNumRounds(to TestOptions) uint64

ComputeNumRounds returns the number of consensus instances to run for the given state machine type.

func GetHashLen

func GetHashLen() int

func GetNewHash

func GetNewHash() hash.Hash

func GetOneThirdBottom

func GetOneThirdBottom(n int) int

func MarshalBinaryHelper

func MarshalBinaryHelper(item EncodeInterface) (data []byte, err error)

func TOConsToDisk

func TOConsToDisk(folderPath string, to TestOptionsCons) error

ToToDisk stores the test options to disk in folderPath, using TestID as the file name.

func TOToDisk

func TOToDisk(folderPath string, to TestOptions) error

ToToDisk stores the test options to disk in folderPath, using TestID as the file name.

func UnmarshalBinaryHelper

func UnmarshalBinaryHelper(item EncodeInterface, data []byte) error

func UseTp1CoinThresh

func UseTp1CoinThresh(to TestOptions) bool

Types

type AllowsCoin

type AllowsCoin int
const (
	NoCoin AllowsCoin = iota
	StrongCoin
	WeakCoin
)

func (AllowsCoin) String

func (ac AllowsCoin) String() string

type BasicEncodeInterface

type BasicEncodeInterface interface {
	Encode(writer io.Writer) (n int, err error)
	Decode(reader io.Reader) (n int, err error)
}

type BinVal

type BinVal byte

BinVal is a binary value stored as a byte, any value not 0 other than 2 is considered 1 2 means Coin which is used in the randomized consensus.

const (
	Coin    BinVal = 2
	BothBin BinVal = 2
)

type BitIDType

type BitIDType int
const (
	BitIDUvarint BitIDType = iota
	BitIDSlice
	BitIDP
	BitIDChoose
	BitIDMulti
	BitIDBasic
	BitIDSingle
)

func (BitIDType) String

func (bt BitIDType) String() string

type BoolSetting

type BoolSetting []bool
var WithTrue BoolSetting = []bool{true}

type BufferForwardType

type BufferForwardType int

BufferForwardType is the type of forwarding being done when using a peer to peer network

const (
	NoBufferForward        BufferForwardType = iota // No buffer forwarding
	FixedBufferForward                              // Messages are forwarded after a fixed timeout
	ThresholdBufferForward                          // Messages are forwared after reaching certain thresholds
)

func (BufferForwardType) String

func (ct BufferForwardType) String() string

type ByzType

type ByzType int

ByzType describe what type of "Byzantine" (what a silly name) behaviour a node should exhibit (if any).

const (
	// TODO more Byzantine types.
	NonFaulty        ByzType = iota // A node acts correctly.
	Mute                            // A node does not send any messages.
	BinaryBoth                      // A node sends messages for both 1 and 0 in binary consensus.
	BinaryFlip                      // A node sends the opposite of what it should in binary consensus.
	HalfHalfNormal                  // Send different values to half the nodes
	HalfHalfFixedBin                // Send different values to half the nodes, always using the fixed binary values
)

func (ByzType) String

func (bt ByzType) String() string

String returns the Byzantine type as a human readable string.

type CoinType

type CoinType int
const (
	NoCoinType          CoinType = iota
	KnownCoinType                // predefined coins (predictable random)
	FlipCoinType                 // predefined coins, flips from 1 to 0
	LocalCoinType                // each process chooses a random local coin
	StrongCoin1Type              // a strong coin implemented by an n-t (or t+1) threshold signature
	StrongCoin1EchoType          // StrongCoin1 with an extra message step (allows use of t+1 coin)
	StrongCoin2Type              // a strong coin implemented by an n-t (or t+1) threshold random coin (cachin'05)
	StrongCoin2EchoType          // StrongCoin2 with an extra message step (allows use of t+1 coin)
)

func (CoinType) String

func (ct CoinType) String() string

type CollectBroadcastType

type CollectBroadcastType int
const (
	Full       CollectBroadcastType = iota // Normal broadcast.
	Commit                                 // Send commit to next coordinator instead of all to all broadcast.
	EchoCommit                             // Send echo and commit to coordinator instead of all to all broadcast.
)

func (CollectBroadcastType) String

func (cbt CollectBroadcastType) String() string

type ComputeConsensusID

type ComputeConsensusID func(idx ConsensusID, additionalIndices []ConsensusID) (ConsensusIndex, error)

type ConsType

type ConsType int

ConsType tells what type of consensus is being used for the experiment.

const (
	BinCons1Type      ConsType = iota // Binary consensus
	BinConsRnd1Type                   // Randomized binary consensus
	BinConsRnd2Type                   // Randomized binary consensus no signatures needed
	BinConsRnd3Type                   // Randomized binary consensus weak coin
	BinConsRnd4Type                   // Randomized binary consensus weak coin no signatures needed
	BinConsRnd5Type                   // Randomized binary consensus combination of BinConsRnd1 and BinConsRnd3
	BinConsRnd6Type                   // Randomized binary consensus combination of BinConsRnd2 and BinConsRnd4
	MvBinCons1Type                    // Multivalue reduction to binary consensus BinCons1
	MvBinConsRnd1Type                 // Multivalue reduction to binary consensus BinConsRnd1
	MvBinConsRnd2Type                 // Multivalue reduction to binary consensus BinConsRnd2
	MvCons2Type                       // Multivalue PBFT like
	MvCons3Type                       // Multivalue HotStuff like
	RbBcast1Type                      // Reliable broadcast like
	RbBcast2Type                      // Reliable broadcast
	MvCons4Type                       // Multivalue Hashgraph like
	SimpleConsType                    // Nodes broadcast their id and public key and wait to recieve this from all other nodes, just for testing.
	MockTestConsType                  // Test object
)

func (ConsType) String

func (ct ConsType) String() string

String returns the consensus type in a human readable format.

type ConsensusHash

type ConsensusHash HashStr

ConsensusHash represents a consensus instance as a hash string.

var InitIndexHash ConsensusHash = "fix this"

IsInitIndex is TODO

func (ConsensusHash) IsInitIndex

func (cs ConsensusHash) IsInitIndex() bool

func (ConsensusHash) MarshalBinary

func (cs ConsensusHash) MarshalBinary() (data []byte, err error)

MarshalBinary casts the hash as bytes.

func (ConsensusHash) Validate

func (cs ConsensusHash) Validate(LocalMessageType) error

Validate returns nil.

type ConsensusID

type ConsensusID interface {
	encoding.BinaryMarshaler                 // To encode the id.
	Validate(isLocal LocalMessageType) error // Returns an error if the id is invalid. IsLocal should be true if the id comes from a local message.
	IsInitIndex() bool                       // Returns true if the index is the initial index.
}

ConsensusID represents a unique identifier for the consensus index. It is either a uint64 or a hash.

func ConsensusHashUnmarshaler

func ConsensusHashUnmarshaler(data []byte) (c ConsensusID, n int, err error)

ConsensusHashUnmarshaler unmarshals the hash by checking bounds and casting as a string.

func ConsensusIntUnmarshaler

func ConsensusIntUnmarshaler(data []byte) (c ConsensusID, n int, err error)

ConsensusIntUnmarshaler unmarshals a ConsensusInt.

type ConsensusIDUnMarshaler

type ConsensusIDUnMarshaler func(data []byte) (c ConsensusID, n int, err error)

ConsensusIDUnMarshaler is used to unmarshal a consensus id from bytes data. It returns the id, and the number of bytes read, or an error.

type ConsensusIndex

type ConsensusIndex struct {
	Index             ConsensusID
	FirstIndex        ConsensusID
	AdditionalIndices []ConsensusID
	UnmarshalFunc     ConsensusIndexFuncs
}

func GenerateParentHash

func GenerateParentHash(idx ConsensusID, addIds []ConsensusID) (ConsensusIndex, error)

GenerateParentHash is used for causal ordering to compute the parent hash.

func SingleComputeConsensusID

func SingleComputeConsensusID(idx ConsensusID, additionalIndices []ConsensusID) (cid ConsensusIndex, err error)

SingleComputeConsensusID is used for total order messages where only a single consensus id is used per instance.

func SingleComputeConsensusIDShort

func SingleComputeConsensusIDShort(idx ConsensusInt) ConsensusIndex

func (ConsensusIndex) ShallowCopy

func (ca ConsensusIndex) ShallowCopy() ConsensusIndex

type ConsensusIndexFuncs

type ConsensusIndexFuncs struct {
	ConsensusIDUnMarshaler
	ComputeConsensusID
}
var NilIndexFuns ConsensusIndexFuncs

type ConsensusInt

type ConsensusInt uint64

ConsensusInt is the index of consensus instance as a uint64.

func (ConsensusInt) IsInitIndex

func (ci ConsensusInt) IsInitIndex() bool

IsInitIndex returns if ci == 1

func (ConsensusInt) MarshalBinary

func (ci ConsensusInt) MarshalBinary() (data []byte, err error)

MarshalBinary encodes the index using config.Encoding.PutUint64

func (ConsensusInt) Validate

func (ci ConsensusInt) Validate(isLocal LocalMessageType) error

Validate returns true if the index is > 0, if local it always return true.

type ConsensusRound

type ConsensusRound uint32

ConsensusRound is the round of consensus for a given index

type DoneType

type DoneType int // When a decided interface is kept or discarded.
const (
	NotDone   DoneType = iota // The consensus instance has not finished.
	DoneClear                 // The consensus instance predecision will be discarded.
	DoneKeep                  // The consensus instance predecision will be kept.
)

func (DoneType) String

func (dt DoneType) String() string

type EncryptChannelsType

type EncryptChannelsType int

func (EncryptChannelsType) String

func (ect EncryptChannelsType) String() string

type HashBytes

type HashBytes []byte

HashBytes is a hash as a byte slice

func DecodeHash

func DecodeHash(reader io.Reader) (hb HashBytes, n int, err error)

DecodeHash reads a hash from the reader, returning a error if it could not read a valid hash size.

func GetHash

func GetHash(v []byte) HashBytes

func GetZeroBytesHashLength

func GetZeroBytesHashLength() HashBytes

GetZeroBytesHashLength returns a byte slice of 0s the length of a hash The slice returned should not be edited.

func (HashBytes) Encode

func (hb HashBytes) Encode(writer io.Writer) (n int, err error)

Encode the hash into the writer.

func (HashBytes) GetSignedHash

func (hb HashBytes) GetSignedHash() HashBytes

GetSignedHash is a helper function

func (HashBytes) Validate

func (hb HashBytes) Validate() error

Validate returns an error if the hash is the wrong length.

type HashStr

type HashStr string

HashStr is a hash a a string

func (HashStr) MarshalBinary

func (v HashStr) MarshalBinary() (data []byte, err error)

MarshalBinary encodes returns the encoded hash.

type IsMember

type IsMember int

IsMember is set when the node knows if it is a member or not

const (
	PossibleMember IsMember = iota
	NonMemberNode
	MemberNode
)

type LocalMessageType

type LocalMessageType int
const (
	NonLocalMessage LocalMessageType = iota
	LocalMessage
	LoadedFromDiskMessage
)

type MemberCheckerType

type MemberCheckerType int

MemberCheckerType describes what type of member checker is being used.

const (
	CurrentTrueMC MemberCheckerType = iota // Static membership, but membership checking only becomes available once the previous consensus instance terminates (for testing).
	TrueMC                                 // Static membership.
	LaterMC                                // Static membership, but may change, resulting in the undecided instances to be restarted (used for MvCons3)
	BinRotateMC                            // Rotates one index through the list of members each time 0 is decided.
	CurrencyMC                             // To be used with SimpleCurrencyTxProposer state machine
)

func (MemberCheckerType) String

func (mc MemberCheckerType) String() string

String returns the human readable representation of the member chekcer type.

type MvCons4BcastType

type MvCons4BcastType int

MvCons4BcastType is the type of message broadcast used by MvCons4.

const (
	Normal  MvCons4BcastType = iota // wait for n-t event before creating a new one at each index
	Direct                          // create new events when you receive a new event
	Indices                         // first send your current indices to another node then is replies with any newer events and creates an event
)

func (MvCons4BcastType) String

func (mv MvCons4BcastType) String() string

type NetworkPropagationType

type NetworkPropagationType int

NetworkPropagationType defines how messages are propagated throughout the network.

const (
	AllToAll         NetworkPropagationType = iota // Every node broadcasts its messages to every other node.
	P2p                                            // Each node is connected to a fixed set of neighbords to which it sends and fowards messages.
	Random                                         // Each time a node sends or forwards a message it choises a random set of nodes.
	RequestForwarder                               // Forward only to those who have requested to get messages.
)

func (NetworkPropagationType) String

func (ct NetworkPropagationType) String() string

String returns the network type as a readable string.

type NetworkProtocolType

type NetworkProtocolType int

NetworkProtocolType defines the internet protocol nodes use for communication. Currently supports UDP and TCP (see issue https://github.com/tcrain/cons/issues/13 for UDP).

const (
	UDP NetworkProtocolType = iota // Nodes communicate using UDP
	TCP                            // Nodes communicate using TCP
)

func (NetworkProtocolType) String

func (ct NetworkProtocolType) String() string

String returns the network protocol type as a readable string.

type OrderingType

type OrderingType int

OrderingType is the way consensus items are order.

const (
	Total  OrderingType = iota // Consensus items are ordered totally
	Causal                     // Consensus items are ordered causally.
)

func GetOrderForSM

func GetOrderForSM(smt StateMachineType) OrderingType

func (OrderingType) String

func (pt OrderingType) String() string

String returns the partial message type as a readable string.

type ParentConsensusHash

type ParentConsensusHash ConsensusHash

ParentConsensusHash represents multiple hashes (for causal). This is the ordered list of hashes that this consensus will consume. The order matters, i.e. each order is unique, but a consensus can only echo once for each consumption of an output. The first item in the list determines the member/forward checkers state. All the items in the list must be owned by the same public key.

type PartialMessageType

type PartialMessageType int

PartialMessageType represents the type of partial messaging being used.

const (
	NoPartialMessages   PartialMessageType = iota // No partial messaging is used
	FullPartialMessages                           // Messages are broken up into even pieces based on the fan out size
)

func (PartialMessageType) String

func (pt PartialMessageType) String() string

String returns the partial message type as a readable string.

type RndMemberType

type RndMemberType int
const (
	NonRandom       RndMemberType = iota // Members are decided non randomly.
	VRFPerCons                           // Members are selected based on their VRF for each consensus.
	VRFPerMessage                        // Members are selected based on their VRF for each message type.
	KnownPerCons                         // Members are selected randomly, but known publically.
	LocalRandMember                      // Members are chosen locally at random
)

func (RndMemberType) String

func (rmt RndMemberType) String() string

type SigType

type SigType int

SigType defines the type of signatures used

const (
	EC SigType = iota
	ED
	SCHNORR
	EDCOIN
	BLS
	TBLS
	TBLSDual
	CoinDual
	QSAFE
)

func (SigType) String

func (ct SigType) String() string

type SignType

type SignType int
const (
	NormalSignature SignType = iota
	SecondarySignature
	CoinProof
)

type SortConsIndex

type SortConsIndex []ConsensusInt

func (SortConsIndex) Len

func (a SortConsIndex) Len() int

func (SortConsIndex) Less

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

func (SortConsIndex) Sort

func (a SortConsIndex) Sort()

func (SortConsIndex) Swap

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

type SortedHashBytes

type SortedHashBytes []HashBytes

func (SortedHashBytes) Len

func (a SortedHashBytes) Len() int

func (SortedHashBytes) Less

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

func (SortedHashBytes) Swap

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

type StateMachineType

type StateMachineType int

StateMachineType represents the object implemeting the StateMachineInterface for the application run by the consensus nodes

const (
	BinaryProposer        StateMachineType = iota // BinCons1ProposalInfo object
	BytesProposer                                 // MvCons1ProposalInfo object
	CounterProposer                               // CounterProposalInfo object
	TestProposer                                  // SimpleProposalInfo object
	CounterTxProposer                             // SimpleTxProposer
	CurrencyTxProposer                            // SimpleCurrencyTxProposer object
	CausalCounterProposer                         // CausalCounterProposalInfo object
	DirectAssetProposer                           // AssetProposer using DirectAsset
	ValueAssetProposer                            // AssetProposer using ValueAsset
)

func (StateMachineType) IsBinStateMachineType

func (smt StateMachineType) IsBinStateMachineType() bool

func (StateMachineType) IsMvStateMachineType

func (smt StateMachineType) IsMvStateMachineType() bool

func (StateMachineType) String

func (smt StateMachineType) String() string

type StopOnCommitType

type StopOnCommitType int
const (
	Immediate StopOnCommitType = iota // Terminate as soon as a value is decided.
	SendProof                         // Terminate after sending a proof of termination.
	NextRound                         // Terminate in the round where which all must have deiced.
)

func (StopOnCommitType) String

func (sc StopOnCommitType) String() string

type StorageType

type StorageType int

StorageType is the type of storage to use, either on disk or in memory.

const (
	Diskstorage StorageType = iota // Store decided values to disk.
	Memstorage                     // Store decided values in memory.
)

func (StorageType) String

func (st StorageType) String() string

String returns the human readable string of the storage type.

type TestOptions

type TestOptions struct {
	UseFixedSeed          bool                   // If true then use a fix seed to generate proposals/coin
	OrderingType          OrderingType           // Total order or causal order
	FailRounds            uint64                 // The round faulty processes will crash
	FailDuration          uint64                 // How long to sleep before restarting a failure in milliseconds
	MaxRounds             uint64                 // The number of consensus instances run by the test
	NumFailProcs          int                    // The number of faulty processes
	NumTotalProcs         int                    // The total number of processes
	NumNonMembers         int                    // How many of the processes are just listening/forwarding, but are not allowed to participate in consensus
	StorageType           StorageType            // The type of storage to use
	ClearDiskOnRestart    bool                   // If when faulty processes crash they should also lose their disk storage
	NetworkType           NetworkPropagationType // The network type to use (all to all or gossip)
	FanOut                int                    // How many neighbors a process has (when not using an all to all network)
	ConnectionType        NetworkProtocolType    // The connection type being used (UDP/TCP)
	ByzType               ByzType                // The behaviour of the byzantine processes
	NumByz                int                    // The number of byzantine processes
	CheckDecisions        bool                   // Check all processes have decided the same values at the end of the test
	MsgDropPercent        int                    // Percentage of messages to be artificially dropped by the network
	IncludeProofs         bool                   // Include signatures as part of messages that prove you are sending a valid message (see protocol description)
	SigType               SigType                // The type of signature to use
	UsePubIndex           bool                   // Identify processes just by their index in the list of pub keys (otherwise use the whole pub key as the id)
	SleepValidate         bool                   // If true we dont validate sigs, just sleep
	SleepCrypto           bool                   // If true all signature based crypto is done using sleeps
	MCType                MemberCheckerType      // if TestMemberCheckers is false, then test a specific type
	BufferForwardType     BufferForwardType      // Buffer several messages before forwarding them (in a gossip network)
	UseMultisig           bool                   // Use multi-signautres
	BlsMultiNew           bool                   // Use the new type of BLS multi-signatures (see https://crypto.stanford.edu/~dabo/pubs/papers/BLSmultisig.html)
	MemCheckerBitIDType   BitIDType              // If using multi-sigs the type of bit ID to use in the member checker
	SigBitIDType          BitIDType              // If using multi-sigs the type of bit ID to use with the signatures
	StateMachineType      StateMachineType       // The application being implemented by the state machines
	PartialMessageType    PartialMessageType     // The type of partial messsages to use during broadcasts
	AllowConcurrent       uint64                 // Number of concurrent consensus indecies to allow to run.
	LocalRandMemberChange uint64                 // On consensus index mod this value, the local rand member checker will change.
	RotateCord            bool                   // If true then the coordinator will rotate each consensus index, if supported by the member checker.
	AllowSupportCoin      bool                   // True if AuxProofMessages can support the coin directly instead of a bin value.
	ConsType              ConsType               // The type of the consensus being used for the test.
	// UseFullBinaryState will (if true) keep the consensus state as the list of all valid messages received appended together,
	// if false stores only different messages with all the signatures at the end
	UseFullBinaryState    bool
	StorageBuffer         int                  // byte size of buffer for writing to disk
	IncludeCurrentSigs    bool                 // When forwarding a message (for non all-to-all networks) will include all sigs received so far
	CPUProfile            bool                 // If true will profile CPU usage
	MemProfile            bool                 // If true will profile mem usage
	NumMsgProcessThreads  int                  // Number of threads that will process messages
	MvProposalSizeBytes   int                  // Size of proposals when using MvCons1ProposalInfo to propose random bytes
	BinConsPercentOnes    int                  // When using binary consensus number of proposals that will be 1 vs 0 (randomly chosen) for testing
	CollectBroadcast      CollectBroadcastType // If true, when sending the commit message, will send it to the leader
	StopOnCommit          StopOnCommitType     // If true then the consensus will not execute rounds after deciding (the eventual message propagation will ensure termination)
	ByzStartIndex         uint64               // Index to start faulty behaviour
	TestID                uint64               // unique identifier for the test
	AdditionalP2PNetworks int                  // Generate additional P2P connection networks, used when sending the same message type multiple times when using buffer forwarder
	EncryptChannels       bool                 // True if network channels should be encrypted using nacl secretbox
	NoSignatures          bool                 // Use encrypted channels for message authentification instead of signatures
	CoinType              CoinType             // The type of coin being used
	UseFixedCoinPresets   bool                 // If true then will use predefined coins for the initial rounds of randomized consensus
	SharePubsRPC          bool                 // If true then during RPC tests nodes on the same machine will share public key objects for external nodes

	WarmUpInstances             int // Number of consensus instances to run before recording results
	KeepPast                    int // Number of previously decided consensus instances to keep in memory
	ForwardTimeout              int // milliseconds 	// for msg forwarder when you dont receive enough messages to foward a buffer automatically
	RandForwardTimeout          int // amount of time to randomly add to Forward timeout
	ProgressTimeout             int // milliseconds, if no progress in this time, let neighbors know
	MvConsTimeout               int // millseconds timeout when taking an action in the MV consensus algorithms
	MvConsVRFTimeout            int // millseconds timeout for waiting for a proposal when VRFs are enabled (only used by MVCons3)
	MvConsRequestRecoverTimeout int // millseconds timeout before requesting the full proposal after delivering the hash

	NodeChoiceVRFRelaxation int           // Additional chance to chose a node as a member when using VRF.
	CoordChoiceVRF          int           // Chance of each node being chosen as a coordinator when using VRF.
	GenRandBytes            bool          // If true the state machine shouldn generate random bytes each decision.
	RndMemberCount          int           // Only works if GenRandBytes is ture. This chooses RndMemberCount members to randomly decide which nodes will participate, if 0 random selection is not used.
	RndMemberType           RndMemberType // Type of random membeship selection, RndMemberCount must be > 0 for this.
	UseRandCoord            bool          // If true round coordinators will be chosen using VRFs note, that these are only calculated from within the existing random members
	// so the coordinator relaxation may need to be higher
	MvCons4BcastType MvCons4BcastType // the type of message broadcast used by MvCons4
}

TestOptions are given as input to consensus tests to describe the test behaviour

func GetTestOptions

func GetTestOptions(optionsPath string) (to TestOptions, err error)

GetTestOptions generates a types.TestOptions object from a json formatted file.

func (TestOptions) AllowsOutOfOrderProposals

func (to TestOptions) AllowsOutOfOrderProposals(consType ConsType) bool

AllowsOutOfOrderProposals should return true if proposals might not see the state of the previous commited when they are made.

func (TestOptions) AllowsRandMembers

func (to TestOptions) AllowsRandMembers(checkerType MemberCheckerType) bool

func (TestOptions) CheckValid

func (to TestOptions) CheckValid(consType ConsType, isMv bool) (newTo TestOptions, err error)

CheckValid returns an error if the generalconfig in invalid

func (TestOptions) FieldDiff

func (to TestOptions) FieldDiff(other TestOptions) (ret []string)

FieldDiff returns a list of the fields that differ between the test options.

func (TestOptions) SanitizeTO

func (to TestOptions) SanitizeTO() (newTO TestOptions)

SanitizeTO will clean certain parts of the test configuration, so that it is valid. Should only be used during benchmarks when using the same config for multiple node counts.

func (TestOptions) String

func (to TestOptions) String() string

func (TestOptions) StringDiff

func (to TestOptions) StringDiff(other TestOptions) string

StringDiff returns a human readable string of the differences between the test options.

func (TestOptions) UsesVRFs

func (to TestOptions) UsesVRFs() bool

UsesVRFs returns true if this test configuration uses VRFs.

type TestOptionsCons

type TestOptionsCons struct {
	TestOptions
	ConsTypes []ConsType
}

type UseSignaturesType

type UseSignaturesType int

func (UseSignaturesType) String

func (ust UseSignaturesType) String() string

Jump to

Keyboard shortcuts

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