Documentation ¶
Index ¶
- Constants
- Variables
- func AllowsGetRandBytes(smType StateMachineType) bool
- func CheckStrongCoin(coinType CoinType) bool
- func ComputeNumRounds(to TestOptions) uint64
- func GetHashLen() int
- func GetNewHash() hash.Hash
- func GetOneThirdBottom(n int) int
- func MarshalBinaryHelper(item EncodeInterface) (data []byte, err error)
- func TOConsToDisk(folderPath string, to TestOptionsCons) error
- func TOToDisk(folderPath string, to TestOptions) error
- func UnmarshalBinaryHelper(item EncodeInterface, data []byte) error
- func UseTp1CoinThresh(to TestOptions) bool
- type AllowsCoin
- type BasicEncodeInterface
- type BinVal
- type BitIDType
- type BoolSetting
- type BufferForwardType
- type ByzType
- type CoinType
- type CollectBroadcastType
- type ComputeConsensusID
- type ConsType
- type ConsensusHash
- type ConsensusID
- type ConsensusIDUnMarshaler
- type ConsensusIndex
- type ConsensusIndexFuncs
- type ConsensusInt
- type ConsensusRound
- type DoneType
- type EncodeInterface
- type EncryptChannelsType
- type HashBytes
- type HashStr
- type IsMember
- type LocalMessageType
- type MemberCheckerType
- type MvCons4BcastType
- type NetworkPropagationType
- type NetworkProtocolType
- type OrderingType
- type ParentConsensusHash
- type PartialMessageType
- type RndMemberType
- type SigType
- type SignType
- type SortConsIndex
- type SortedHashBytes
- type StateMachineType
- type StopOnCommitType
- type StorageType
- type TestOptions
- func (to TestOptions) AllowsOutOfOrderProposals(consType ConsType) bool
- func (to TestOptions) AllowsRandMembers(checkerType MemberCheckerType) bool
- func (to TestOptions) CheckValid(consType ConsType, isMv bool) (newTo TestOptions, err error)
- func (to TestOptions) FieldDiff(other TestOptions) (ret []string)
- func (to TestOptions) SanitizeTO() (newTO TestOptions)
- func (to TestOptions) String() string
- func (to TestOptions) StringDiff(other TestOptions) string
- func (to TestOptions) UsesVRFs() bool
- type TestOptionsCons
- type UseSignaturesType
Constants ¶
const ( UseSignatures = iota NoSignatures ConsDependentSignatures )
const ( NonEncryptedChannels = iota EncryptedChannels ConsDepedentChannels )
Variables ¶
var AllByzTypes = []ByzType{NonFaulty, Mute, BinaryBoth, BinaryFlip, HalfHalfNormal, HalfHalfFixedBin}
var AllCoins = append(StrongCoins, WeakCoins...) // append([]CoinType{NoCoinType}, append(StrongCoins, WeakCoins...)...)
var AllCollectBroadcast = []CollectBroadcastType{Full, Commit, EchoCommit}
var AllMC = []MemberCheckerType{TrueMC, CurrentTrueMC, LaterMC, BinRotateMC, CurrencyMC}
AllMC is a list of all the possible member checker types.
var AllProposerTypes = append(TotalOrderProposerTypes, CausalProposerTypes...)
var AllRandMemberTypes = []RndMemberType{NonRandom, VRFPerCons, VRFPerMessage, KnownPerCons, LocalRandMember}
var AllSigTypes = []SigType{EC, ED, SCHNORR, EDCOIN, BLS, TBLS, TBLSDual, CoinDual, QSAFE}
var AllStopOnCommitTypes = []StopOnCommitType{Immediate, NextRound, SendProof}
var BinaryProposerTypes = []StateMachineType{BinaryProposer}
BinaryProposerTypes are the StateMachineTypes that are valid to use with binary consensus
var BothOrders = []OrderingType{Total, Causal}
var CausalProposerTypes = []StateMachineType{ValueAssetProposer, DirectAssetProposer, CausalCounterProposer}
var CoinSigTypes = append(ThrshSigTypes, EDCOIN)
var EncryptChannelsSigTypes = []SigType{EC, ED, SCHNORR, EDCOIN, BLS, TBLS, TBLSDual, CoinDual}
var ErrAlreadyCombinedPartials = fmt.Errorf("has already combined partials")
var ErrAlreadyConsumedEcho = fmt.Errorf("already consumed echo")
causal
var ErrAlreadyReceivedMessage = fmt.Errorf("already received message")
var ErrClosingTime = fmt.Errorf("time to close")
var ErrCoinAlreadyProcessed = fmt.Errorf("coin already processed for this round")
var ErrCoinProofNotSupported = fmt.Errorf("coin proofs not supported by signature type")
var ErrConnAlreadyExists = fmt.Errorf("connection already exists")
csnet
var ErrConnDoesntExist = fmt.Errorf("connection doesn't exist")
var ErrConsAlreadyDecided = fmt.Errorf("consensus index already decided")
var ErrDecryptionFailed = fmt.Errorf("decryption failed")
var ErrDeserialize = fmt.Errorf("error deserialize")
var ErrDontForwardMessage = fmt.Errorf("message should not be forwarded")
var ErrDuplicatePartial = fmt.Errorf("duplicate partial")
var ErrDuplicateRemoteAncestors = fmt.Errorf("duplicate remote ancestors")
var ErrDuplicateRoundCoord = fmt.Errorf("dupliate round coordinator message")
var ErrEventAlreadyGC = fmt.Errorf("event already garbage collected")
var ErrEventExists = fmt.Errorf("event already exists")
var ErrHashIdxOutOfRange = fmt.Errorf("partial message hash index out of range")
partial Message
var ErrIncorrectNumPartials = fmt.Errorf("incorrect number of partials")
var ErrIndexTooNew = fmt.Errorf("index too far in future")
var ErrIndexTooOld = fmt.Errorf("index too old")
var ErrIntersectingBitIDs = fmt.Errorf("must not have intersecting bitIDs to merge sigs")
var ErrInvalidBinStateMsg = fmt.Errorf("invalid bin state msg")
var ErrInvalidBitID = fmt.Errorf("invalid BitID")
used by bls sig
var ErrInvalidBitIDEncoding = fmt.Errorf("invalid bitID encoding")
var ErrInvalidBitIDSub = fmt.Errorf("invalid BitID subtraction")
var ErrInvalidBuffSize = fmt.Errorf("invalid buffer size")
var ErrInvalidFormat = fmt.Errorf("string in invalid format")
channel
var ErrInvalidHash = fmt.Errorf("invalid Hash")
var ErrInvalidHashSize = fmt.Errorf("invalid input size")
var ErrInvalidHeader = fmt.Errorf("got an invalid msg header")
var ErrInvalidIndex = fmt.Errorf("index not in range")
var ErrInvalidKeySize = fmt.Errorf("invalid key size")
storage
var ErrInvalidMsgSize = fmt.Errorf("invalid msg size")
var ErrInvalidPartialIndecies = fmt.Errorf("invalid partial msg indecies to reconstruct")
var ErrInvalidProposal = fmt.Errorf("invalid proposal")
var ErrInvalidPub = fmt.Errorf("inavlid pub")
var ErrInvalidPubIndex = fmt.Errorf("invalid pub index")
var ErrInvalidRemoteAncestor = fmt.Errorf("invalid remote ancestor")
var ErrInvalidRemoteAncestorCount = fmt.Errorf("invalid number of remote ancestors")
var ErrInvalidRound = fmt.Errorf("invalid round")
mvcons1
var ErrInvalidRoundCoord = fmt.Errorf("invalid round coordinator")
var ErrInvalidSessionID = fmt.Errorf("invalid session id")
var ErrInvalidSig = fmt.Errorf("invalid sig")
var ErrInvalidSigCount = fmt.Errorf("invalid number of signatures")
var ErrInvalidSigEncoding = fmt.Errorf("invalid sig encoding")
var ErrInvalidSigType = fmt.Errorf("invalid sig type")
used by auth/sig
var ErrInvalidStage = fmt.Errorf("invalid message stage")
var ErrInvalidVRFProof = fmt.Errorf("invalid vrf proof")
var ErrInvalidVarint = fmt.Errorf("invalid var int")
var ErrMemCheckerNotReady = fmt.Errorf("memberchecker not ready")
var ErrMsgNotFound = fmt.Errorf("msg not found")
var ErrNilMsg = fmt.Errorf("nil msg")
var ErrNilPriv = fmt.Errorf("nil priv key")
var ErrNilProposal = fmt.Errorf("proposal must not be nil")
var ErrNilPub = fmt.Errorf("nil pub key")
var ErrNoEchoHash = fmt.Errorf("tried to get proofs for an echo message before sending the hash")
var ErrNoFixedCoord = fmt.Errorf("no fixed coord")
var ErrNoItems = fmt.Errorf("no more items to iterate")
var ErrNoNewSigs = fmt.Errorf("no new sigs")
var ErrNoProofs = fmt.Errorf("no proofs for round")
bincons1
var ErrNoPubBytes = fmt.Errorf("missing pub bytes")
var ErrNoRemovedCons = fmt.Errorf("no removed connections")
var ErrNoValidSigs = fmt.Errorf("no valid sigs")
var ErrNotEnoughBytes = fmt.Errorf("not enough bytes to read")
var ErrNotEnoughConnections = fmt.Errorf("not enough connections")
var ErrNotEnoughPartials = fmt.Errorf("not enough partial signatures")
var ErrNotEnoughSigs = fmt.Errorf("not enough sigs")
var ErrNotMember = fmt.Errorf("not a member")
member checker
var ErrNotOwner = fmt.Errorf("inputs owned by different pubs")
var ErrNotReceivedVRFProof = fmt.Errorf("have not received node's VRF proof")
when using random membership
var ErrParentNotFound = fmt.Errorf("parent index not found")
var ErrPrevIndexNotFound = fmt.Errorf("previous index not found")
graph
var ErrPubNotFound = fmt.Errorf("should register connection info before requesting")
ParticipantRegister
var ErrThresholdSigsNotSupported = fmt.Errorf("threshold signatures not supported")
var ErrTimeout = fmt.Errorf("timeout")
var ErrTooLargeBitID = fmt.Errorf("bitID too large")
var ErrTooManyAdditionalIndices = fmt.Errorf("message has too many additional indices")
var ErrUnsortedBitID = fmt.Errorf("bitID must be sorted")
var ErrWrongMemberChecker = fmt.Errorf("wrong member checker")
var ErrWrongMessageType = fmt.Errorf("tried to deserialize wrong message type")
msg
var HashIndexFuns = ConsensusIndexFuncs{ ConsensusIDUnMarshaler: ConsensusHashUnmarshaler, ComputeConsensusID: GenerateParentHash, }
var IntIndexFuns = ConsensusIndexFuncs{ ConsensusIDUnMarshaler: ConsensusIntUnmarshaler, ComputeConsensusID: SingleComputeConsensusID, }
var MultiSigTypes = []SigType{BLS}
var MultivalueProposerTypes = []StateMachineType{BytesProposer, CounterProposer, CounterTxProposer, CurrencyTxProposer}
MultivalueProposerTypes are the StateMachineTypes that are valid to use with multivalue consensus
var MultivalueProposerTypesNoCurrency = []StateMachineType{BytesProposer, CounterProposer, CounterTxProposer}
MultivalueProposerTypesNoCurrency is the same as MultivalueProposerTypes except without CurrencyTxProposer
var NetworkProtocolTypes = []NetworkProtocolType{UDP, TCP}
NetworkProtocolTypes lists all the posilbe network protocol type
var StrongCoins = []CoinType{StrongCoin1Type, StrongCoin1EchoType, StrongCoin2Type, StrongCoin2EchoType, KnownCoinType, FlipCoinType}
var ThrshSigTypes = []SigType{TBLS, TBLSDual, CoinDual}
var TotalOrderProposerTypes = append(BinaryProposerTypes, MultivalueProposerTypes...)
var VRFSigTypes = []SigType{EC, BLS}
var WeakCoins = []CoinType{LocalCoinType}
var WithBothBool = []bool{true, false}
var WithFalse = []bool{false}
Functions ¶
func AllowsGetRandBytes ¶
func AllowsGetRandBytes(smType StateMachineType) bool
func CheckStrongCoin ¶
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 GetOneThirdBottom ¶
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 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.
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 )
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) )
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 )
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 EncodeInterface ¶
type EncodeInterface interface { BasicEncodeInterface encoding.BinaryMarshaler encoding.BinaryUnmarshaler New() EncodeInterface }
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 ¶
DecodeHash reads a hash from the reader, returning a error if it could not read a valid hash size.
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) GetSignedHash ¶
GetSignedHash is a helper function
type HashStr ¶
type HashStr string
HashStr is a hash a a string
func (HashStr) MarshalBinary ¶
MarshalBinary encodes returns the encoded hash.
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 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 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