Documentation
¶
Overview ¶
Package hotstuff implements the basic types that are used by consbench.
Index ¶
- Constants
- func IDSetToString(set IDSet) string
- func NumFaulty(n int) int
- func QuorumSize(n int) int
- type AggregateQC
- type Block
- type Command
- type CommitEvent
- type Hash
- type ID
- type IDSet
- type NewViewMsg
- type PartialCert
- type PrivateKey
- type ProposeMsg
- type PublicKey
- type QuorumCert
- type QuorumSignature
- type SyncInfo
- func (si SyncInfo) AggQC() (_ AggregateQC, _ bool)
- func (si SyncInfo) QC() (_ QuorumCert, _ bool)
- func (si SyncInfo) String() string
- func (si SyncInfo) TC() (_ TimeoutCert, _ bool)
- func (si SyncInfo) WithAggQC(aggQC AggregateQC) SyncInfo
- func (si SyncInfo) WithQC(qc QuorumCert) SyncInfo
- func (si SyncInfo) WithTC(tc TimeoutCert) SyncInfo
- type ThresholdSignaturedeprecated
- type TimeoutCert
- type TimeoutMsg
- type ToBytes
- type View
- type VoteMsg
Constants ¶
const DefaultLatency = 500
DefaultLatency is the default latencies between the default replicas.
const DefaultLocation = "default"
DefaultLocation is the default location of a replica.
Variables ¶
This section is empty.
Functions ¶
func IDSetToString ¶
IDSetToString formats an IDSet as a string.
func NumFaulty ¶
NumFaulty calculates 'f', which is the number of replicas that can be faulty for a configuration of size 'n'.
func QuorumSize ¶
QuorumSize calculates '2f + 1', which is the quorum size for a configuration of size 'n'.
Types ¶
type AggregateQC ¶
type AggregateQC struct {
// contains filtered or unexported fields
}
AggregateQC is a set of QCs extracted from timeout messages and an aggregate signature of the timeout signatures.
This is used by the Fast-HotStuff consensus protocol.
func NewAggregateQC ¶
func NewAggregateQC(qcs map[ID]QuorumCert, sig QuorumSignature, view View) AggregateQC
NewAggregateQC returns a new AggregateQC from the QC map and the threshold signature.
func (AggregateQC) QCs ¶
func (aggQC AggregateQC) QCs() map[ID]QuorumCert
QCs returns the quorum certificates in the AggregateQC.
func (AggregateQC) Sig ¶
func (aggQC AggregateQC) Sig() QuorumSignature
Sig returns the threshold signature in the AggregateQC.
func (AggregateQC) String ¶
func (aggQC AggregateQC) String() string
func (AggregateQC) View ¶
func (aggQC AggregateQC) View() View
View returns the view in which the AggregateQC was created.
type Block ¶
type Block struct {
// contains filtered or unexported fields
}
Block contains a propsed "command", metadata for the protocol, and a link to the "parent" block.
func GetGenesis ¶
func GetGenesis() *Block
GetGenesis returns a pointer to the genesis block, the starting point for the hotstuff blockchain.
func (*Block) QuorumCert ¶
func (b *Block) QuorumCert() QuorumCert
QuorumCert returns the quorum certificate in the block
type Command ¶
type Command string
Command is a client request to be executed by the consensus protocol.
The string type is used because it is immutable and can hold arbitrary bytes of any length.
type CommitEvent ¶
type CommitEvent struct {
Commands int
}
CommitEvent is raised whenever a block is committed, and includes the number of client commands that were executed.
type IDSet ¶
type IDSet interface { // Add adds an ID to the set. Add(id ID) // Contains returns true if the set contains the ID. Contains(id ID) bool // ForEach calls f for each ID in the set. ForEach(f func(ID)) // RangeWhile calls f for each ID in the set until f returns false. RangeWhile(f func(ID) bool) // Len returns the number of entries in the set. Len() int }
IDSet implements a set of replica IDs. It is used to show which replicas participated in some event.
type NewViewMsg ¶
type NewViewMsg struct { ID ID // The ID of the replica who sent the message. SyncInfo SyncInfo // The highest QC / TC. }
NewViewMsg is sent to the leader whenever a replica decides to advance to the next view. It contains the highest QC or TC known to the replica.
type PartialCert ¶
type PartialCert struct {
// contains filtered or unexported fields
}
PartialCert is a signed block hash.
func NewPartialCert ¶
func NewPartialCert(signature QuorumSignature, blockHash Hash) PartialCert
NewPartialCert returns a new partial certificate.
func (PartialCert) BlockHash ¶
func (pc PartialCert) BlockHash() Hash
BlockHash returns the hash of the block that was signed.
func (PartialCert) Signature ¶
func (pc PartialCert) Signature() QuorumSignature
Signature returns the signature.
func (PartialCert) Signer ¶
func (pc PartialCert) Signer() ID
Signer returns the ID of the replica that created the certificate.
func (PartialCert) ToBytes ¶
func (pc PartialCert) ToBytes() []byte
ToBytes returns a byte representation of the partial certificate.
type PrivateKey ¶
type PrivateKey interface { // Public returns the public key associated with this private key. Public() PublicKey }
PrivateKey is the private part of a replica's key pair.
type ProposeMsg ¶
type ProposeMsg struct { ID ID // The ID of the replica who sent the message. Block *Block // The block that is proposed. AggregateQC *AggregateQC // Optional AggregateQC }
ProposeMsg is broadcast when a leader makes a proposal.
func (ProposeMsg) String ¶
func (p ProposeMsg) String() string
type QuorumCert ¶
type QuorumCert struct {
// contains filtered or unexported fields
}
QuorumCert (QC) is a certificate for a Block created by a quorum of partial certificates.
func NewQuorumCert ¶
func NewQuorumCert(signature QuorumSignature, view View, hash Hash) QuorumCert
NewQuorumCert creates a new quorum cert from the given values.
func (QuorumCert) BlockHash ¶
func (qc QuorumCert) BlockHash() Hash
BlockHash returns the hash of the block that was signed.
func (QuorumCert) Equals ¶
func (qc QuorumCert) Equals(other QuorumCert) bool
Equals returns true if the other QC equals this QC.
func (QuorumCert) Signature ¶
func (qc QuorumCert) Signature() QuorumSignature
Signature returns the threshold signature.
func (QuorumCert) String ¶
func (qc QuorumCert) String() string
func (QuorumCert) ToBytes ¶
func (qc QuorumCert) ToBytes() []byte
ToBytes returns a byte representation of the quorum certificate.
func (QuorumCert) View ¶
func (qc QuorumCert) View() View
View returns the view in which the QC was created.
type QuorumSignature ¶
type QuorumSignature interface { ToBytes // Participants returns the IDs of replicas who participated in the threshold signature. Participants() IDSet }
QuorumSignature is a signature that is only valid when it contains the signatures of a quorum of replicas.
type SyncInfo ¶
type SyncInfo struct {
// contains filtered or unexported fields
}
SyncInfo holds the highest known QC or TC. Generally, if highQC.View > highTC.View, there is no need to include highTC in the SyncInfo. However, if highQC.View < highTC.View, we should still include highQC. This can also hold an AggregateQC for Fast-Hotstuff.
func (SyncInfo) AggQC ¶
func (si SyncInfo) AggQC() (_ AggregateQC, _ bool)
AggQC returns the AggregateQC, if present.
func (SyncInfo) QC ¶
func (si SyncInfo) QC() (_ QuorumCert, _ bool)
QC returns the quorum certificate, if present.
func (SyncInfo) TC ¶
func (si SyncInfo) TC() (_ TimeoutCert, _ bool)
TC returns the timeout certificate, if present.
func (SyncInfo) WithAggQC ¶
func (si SyncInfo) WithAggQC(aggQC AggregateQC) SyncInfo
WithAggQC returns a copy of the SyncInfo struct with the given AggregateQC.
func (SyncInfo) WithQC ¶
func (si SyncInfo) WithQC(qc QuorumCert) SyncInfo
WithQC returns a copy of the SyncInfo struct with the given QC.
func (SyncInfo) WithTC ¶
func (si SyncInfo) WithTC(tc TimeoutCert) SyncInfo
WithTC returns a copy of the SyncInfo struct with the given TC.
type ThresholdSignature
deprecated
type ThresholdSignature = QuorumSignature
ThresholdSignature is a signature that is only valid when it contains the signatures of a quorum of replicas.
Deprecated: renamed to QuorumSignature
type TimeoutCert ¶
type TimeoutCert struct {
// contains filtered or unexported fields
}
TimeoutCert (TC) is a certificate created by a quorum of timeout messages.
func NewTimeoutCert ¶
func NewTimeoutCert(signature QuorumSignature, view View) TimeoutCert
NewTimeoutCert returns a new timeout certificate.
func (TimeoutCert) Signature ¶
func (tc TimeoutCert) Signature() QuorumSignature
Signature returns the threshold signature.
func (TimeoutCert) String ¶
func (tc TimeoutCert) String() string
func (TimeoutCert) ToBytes ¶
func (tc TimeoutCert) ToBytes() []byte
ToBytes returns a byte representation of the timeout certificate.
func (TimeoutCert) View ¶
func (tc TimeoutCert) View() View
View returns the view in which the timeouts occurred.
type TimeoutMsg ¶
type TimeoutMsg struct { ID ID // The ID of the replica who sent the message. View View // The view that the replica wants to enter. ViewSignature QuorumSignature // A signature of the view MsgSignature QuorumSignature // A signature of the view, QC.BlockHash, and the replica ID SyncInfo SyncInfo // The highest QC/TC known to the sender. }
TimeoutMsg is broadcast whenever a replica has a local timeout.
func (TimeoutMsg) String ¶
func (timeout TimeoutMsg) String() string
func (TimeoutMsg) ToBytes ¶
func (timeout TimeoutMsg) ToBytes() []byte
ToBytes returns a byte form of the timeout message.
type ToBytes ¶
type ToBytes interface { // ToBytes returns the object as bytes. ToBytes() []byte }
ToBytes is an object that can be converted into bytes for the purposes of hashing, etc.
Directories
¶
Path | Synopsis |
---|---|
Package backend implements the networking backend for hotstuff using the Gorums framework.
|
Package backend implements the networking backend for hotstuff using the Gorums framework. |
Package blockchain provides an implementation of the consensus.BlockChain interface.
|
Package blockchain provides an implementation of the consensus.BlockChain interface. |
Package client implements a simple client for testing HotStuff.
|
Package client implements a simple client for testing HotStuff. |
cmd
|
|
hotstuff
Hotstuff is a utility for running HotStuff clients and replicas.
|
Hotstuff is a utility for running HotStuff clients and replicas. |
latencygen
LatencyGen generates a Go source file containing the latency matrix.
|
LatencyGen generates a Go source file containing the latency matrix. |
plot
Plot is a tool for plotting measurements from a HotStuff experiment.
|
Plot is a tool for plotting measurements from a HotStuff experiment. |
consensus
|
|
hotstuff
Package consensus defines the types and interfaces that are used to implement consensus.
|
Package consensus defines the types and interfaces that are used to implement consensus. |
hotstuff/byzantine
Package byzantine contiains byzantine behaviors that can be applied to the consensus protocols.
|
Package byzantine contiains byzantine behaviors that can be applied to the consensus protocols. |
hotstuff/chainedhotstuff
Package chainedhotstuff implements the pipelined three-chain version of the HotStuff protocol.
|
Package chainedhotstuff implements the pipelined three-chain version of the HotStuff protocol. |
hotstuff/fasthotstuff
Package fasthotstuff implements the two-chain Fast-HotStuff protocol.
|
Package fasthotstuff implements the two-chain Fast-HotStuff protocol. |
hotstuff/simplehotstuff
Package simplehotstuff implements a simplified version of the three-chain HotStuff protocol.
|
Package simplehotstuff implements a simplified version of the three-chain HotStuff protocol. |
Package crypto provides implementations of the Crypto interface.
|
Package crypto provides implementations of the Crypto interface. |
bls12
Package bls12 implements the crypto primitives used by HotStuff using curve BLS12-381.
|
Package bls12 implements the crypto primitives used by HotStuff using curve BLS12-381. |
ecdsa
Package ecdsa implements the spec-k256 curve signature.
|
Package ecdsa implements the spec-k256 curve signature. |
eddsa
Package eddsa implements the ed25519 curve signature.
|
Package eddsa implements the ed25519 curve signature. |
keygen
Package keygen provides helper methods for generating, serializing, and deserializing public keys, private keys and certificates.
|
Package keygen provides helper methods for generating, serializing, and deserializing public keys, private keys and certificates. |
Package eventloop provides an event loop which is widely used by modules.
|
Package eventloop provides an event loop which is widely used by modules. |
Package handel provides signature aggregation through a peer-to-peer protocol.
|
Package handel provides signature aggregation through a peer-to-peer protocol. |
internal
|
|
cli
Package cli provide command line interface helpers for consbench.
|
Package cli provide command line interface helpers for consbench. |
mocks
Package mocks is a generated GoMock package.
|
Package mocks is a generated GoMock package. |
orchestration
Package orchestration implements deployment and orchestration of hotstuff replicas and clients on remote hosts.
|
Package orchestration implements deployment and orchestration of hotstuff replicas and clients on remote hosts. |
profiling
Package profiling provides helpers for using various profilers.
|
Package profiling provides helpers for using various profilers. |
proto/hotstuffpb
Package hotstuffpb contains protocol buffers message types and conversion functions for the HotStuff protocol.
|
Package hotstuffpb contains protocol buffers message types and conversion functions for the HotStuff protocol. |
protostream
Package protostream implements reading and writing of protobuf messages to data streams.
|
Package protostream implements reading and writing of protobuf messages to data streams. |
testutil
Package testutil provides helper methods that are useful for implementing tests.
|
Package testutil provides helper methods that are useful for implementing tests. |
Package leaderrotation provide various leader rotation algorithms.
|
Package leaderrotation provide various leader rotation algorithms. |
Package logging defines the Logger interface which is used by the module system.
|
Package logging defines the Logger interface which is used by the module system. |
Package metrics contains modules that collect data or metrics from other modules.
|
Package metrics contains modules that collect data or metrics from other modules. |
plotting
Package plotting provides functions and structures for plotting measurement data collected from running an experiment.
|
Package plotting provides functions and structures for plotting measurement data collected from running an experiment. |
types
Package types defines various types for metrics collection.
|
Package types defines various types for metrics collection. |
Package modules contains the module system used in the hotstuff project.
|
Package modules contains the module system used in the hotstuff project. |
Package replica provides the required code for starting and running a replica and handling client requests.
|
Package replica provides the required code for starting and running a replica and handling client requests. |
Package synchronizer implements the synchronizer module.
|
Package synchronizer implements the synchronizer module. |
Package twins implements a framework for testing HotStuff implementations.
|
Package twins implements a framework for testing HotStuff implementations. |
util
|
|
gpool
Package gpool provides a generic sync.Pool.
|
Package gpool provides a generic sync.Pool. |