Documentation
¶
Overview ¶
Package twins implements a framework for testing HotStuff implementations.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FixedTimeout ¶ added in v0.5.0
func FixedTimeout(timeout time.Duration) synchronizer.ViewDuration
FixedTimeout returns an ExponentialTimeout with a max exponent of 0.
Types ¶
type Generator ¶
type Generator struct {
// contains filtered or unexported fields
}
Generator generates twins scenarios.
func NewGenerator ¶
NewGenerator creates a new generator.
func (*Generator) NextScenario ¶
NextScenario generates the next scenario.
type JSONWriter ¶
type JSONWriter struct {
// contains filtered or unexported fields
}
JSONWriter writes scenarios to JSON.
func ToJSON ¶
func ToJSON(settings Settings, wr io.Writer) (*JSONWriter, error)
ToJSON returns a JSONWriter that can be used to write scenarios as JSON.
func (*JSONWriter) WriteScenario ¶
func (jwr *JSONWriter) WriteScenario(s Scenario) error
WriteScenario writes a single scenario to the JSON stream.
type Network ¶ added in v0.5.0
type Network struct {
// contains filtered or unexported fields
}
Network is a simulated network that supports twins.
func NewPartitionedNetwork ¶ added in v0.5.0
NewPartitionedNetwork creates a new Network with the specified partitions. partitions specifies the network partitions for each view.
func NewSimpleNetwork ¶ added in v0.5.0
func NewSimpleNetwork() *Network
NewSimpleNetwork creates a simple network.
func (*Network) GetNodeBuilder ¶ added in v0.5.0
GetNodeBuilder returns a consensus.Builder instance for a node in the network.
func (*Network) NewConfiguration ¶ added in v0.5.0
func (n *Network) NewConfiguration() modules.Configuration
NewConfiguration returns a new Configuration module for this network.
type NodeID ¶
NodeID is an ID that is unique to a node in the network. The ReplicaID is the ID that the node uses when taking part in the consensus protocol, while the NetworkID is used to distinguish nodes on the network.
type NodeSet ¶
type NodeSet map[uint32]struct{}
NodeSet is a set of network ids.
func (NodeSet) MarshalJSON ¶
MarshalJSON returns a JSON representation of the node set.
func (*NodeSet) UnmarshalJSON ¶
UnmarshalJSON restores the node set from JSON.
type Scenario ¶
type Scenario []View
Scenario specifies the nodes, partitions and leaders for a twins scenario.
type ScenarioResult ¶
type ScenarioResult struct {
Safe bool
Commits int
NetworkLog string
NodeLogs map[NodeID]string
NodeCommits map[NodeID][]*hotstuff.Block
}
ScenarioResult contains the result and logs from executing a scenario.
func ExecuteScenario ¶
func ExecuteScenario(scenario Scenario, numNodes, numTwins uint8, numTicks int, consensusName string) (result ScenarioResult, err error)
ExecuteScenario executes a twins scenario.
type ScenarioSource ¶
type ScenarioSource interface {
Settings() Settings
NextScenario() (Scenario, error)
Remaining() int64
}
ScenarioSource is a source of twins scenarios to execute.