Documentation ¶
Index ¶
- Constants
- Variables
- func MakeJustification(backend signing.Backend, nn gpbft.NetworkName, chain gpbft.ECChain, ...) (*gpbft.Justification, error)
- type AggregateECChainGenerator
- type BaseECChainGenerator
- type ECChainGenerator
- type ECInstance
- func (eci *ECInstance) GetDecision(participant gpbft.ActorID) *gpbft.ECChain
- func (eci *ECInstance) HasCompleted(exclude ...gpbft.ActorID) bool
- func (eci *ECInstance) HasReachedConsensus(exclude ...gpbft.ActorID) (*gpbft.ECChain, bool)
- func (eci *ECInstance) NotifyDecision(participant gpbft.ActorID, decision *gpbft.Justification)
- func (eci *ECInstance) Print()
- type FixedECChainGenerator
- type Network
- func (n *Network) AddParticipant(id gpbft.ActorID, p gpbft.Receiver)
- func (n *Network) HasMoreTicks() bool
- func (n *Network) NetworkName() gpbft.NetworkName
- func (n *Network) SetAlarm(sender gpbft.ActorID, at time.Time)
- func (n *Network) Tick(adv *adversary.Adversary) error
- func (n *Network) Time() time.Time
- type Option
- func AddHonestParticipants(count int, ecg ECChainGenerator, spg StoragePowerGenerator) Option
- func WitECStabilisationDelay(d time.Duration) Option
- func WithAdversary(generator adversary.Generator) Option
- func WithBaseChain(base *gpbft.ECChain) Option
- func WithECEpochDuration(d time.Duration) Option
- func WithECStabilisationDelay(d time.Duration) Option
- func WithGlobalStabilizationTime(d time.Duration) Option
- func WithGpbftOptions(gOpts ...gpbft.Option) Option
- func WithIgnoreConsensusFor(id ...gpbft.ActorID) Option
- func WithLatencyModeler(lm latency.Modeler) Option
- func WithSigningBackend(sb signing.Backend) Option
- func WithTraceLevel(i int) Option
- type Participant
- type RandomECChainGenerator
- type SimNetwork
- type Simulation
- type StoragePowerGenerator
- type TipSetGenerator
- type UniformECChainGenerator
Constants ¶
const ( TraceNone = iota TraceSent TraceRecvd TraceLogic TraceAll //nolint:unused )
Variables ¶
An error to be returned when a chain or committee is not available for an instance.
Functions ¶
func MakeJustification ¶ added in v0.0.3
func MakeJustification(backend signing.Backend, nn gpbft.NetworkName, chain gpbft.ECChain, instance uint64, powerTable, nextPowerTable gpbft.PowerEntries) (*gpbft.Justification, error)
Generate a justification from the given power table. This assumes the signing backend can sign for all keys.
Types ¶
type AggregateECChainGenerator ¶
type AggregateECChainGenerator struct {
// contains filtered or unexported fields
}
AggregateECChainGenerator generates EC chain by aggregating the chains generated by a given set of generators in the order their corresponding generator is specified.
func NewAppendingECChainGenerator ¶
func NewAppendingECChainGenerator(g ...ECChainGenerator) *AggregateECChainGenerator
func (*AggregateECChainGenerator) GenerateECChain ¶
type BaseECChainGenerator ¶
type BaseECChainGenerator struct{}
BaseECChainGenerator always return the given base as the EC chain for all participants and instances.
func NewBaseECChainGenerator ¶
func NewBaseECChainGenerator() *BaseECChainGenerator
func (*BaseECChainGenerator) GenerateECChain ¶
type ECChainGenerator ¶
type ECChainGenerator interface {
GenerateECChain(instance uint64, base gpbft.TipSet, id gpbft.ActorID) gpbft.ECChain
}
ECChainGenerator generates the ECChain that a simulation participant would attempt to reach consensus on at the given GPBFT instance. The return chain must have the given TipSet as its base.
type ECInstance ¶
type ECInstance struct { Instance uint64 // The base of all chains, which participants must agree on. BaseChain gpbft.ECChain // The power table to be used for this instance. PowerTable *gpbft.PowerTable // The beacon value to use for this instance. Beacon []byte // SupplementalData is the additional data for this instance. SupplementalData *gpbft.SupplementalData // contains filtered or unexported fields }
func (*ECInstance) GetDecision ¶
func (eci *ECInstance) GetDecision(participant gpbft.ActorID) *gpbft.ECChain
func (*ECInstance) HasCompleted ¶
func (eci *ECInstance) HasCompleted(exclude ...gpbft.ActorID) bool
HasCompleted checks whether all participants, except any excluded ones, have reached some decision.
func (*ECInstance) HasReachedConsensus ¶
HasReachedConsensus checks that all participants (except any adversary) for an instance decided on the same value.
func (*ECInstance) NotifyDecision ¶
func (eci *ECInstance) NotifyDecision(participant gpbft.ActorID, decision *gpbft.Justification)
func (*ECInstance) Print ¶
func (eci *ECInstance) Print()
type FixedECChainGenerator ¶
type FixedECChainGenerator struct {
// contains filtered or unexported fields
}
func NewFixedECChainGenerator ¶
func NewFixedECChainGenerator(chain gpbft.ECChain) *FixedECChainGenerator
func (*FixedECChainGenerator) GenerateECChain ¶
type Network ¶
type Network struct {
// contains filtered or unexported fields
}
func (*Network) AddParticipant ¶
func (*Network) HasMoreTicks ¶ added in v0.4.0
HasMoreTicks checks whether there are any messages left to propagate across the network participants. See Tick.
func (*Network) NetworkName ¶
func (n *Network) NetworkName() gpbft.NetworkName
type Option ¶
type Option func(*options) error
func AddHonestParticipants ¶
func AddHonestParticipants(count int, ecg ECChainGenerator, spg StoragePowerGenerator) Option
func WitECStabilisationDelay ¶
func WithAdversary ¶
func WithBaseChain ¶
func WithECEpochDuration ¶
func WithGpbftOptions ¶
func WithIgnoreConsensusFor ¶
WithIgnoreConsensusFor sets the participant IDs for which the simulation will not error if they do not reach consensus at the end of each instance. Defaults to none.
func WithLatencyModeler ¶
func WithSigningBackend ¶
WithSigningBackend sets the signing backend to be used by all participants in the simulation. Defaults to signing.FakeBackend if unset.
See signing.FakeBackend, signing.BLSBackend.
func WithTraceLevel ¶
type Participant ¶
type Participant struct { *gpbft.Participant // contains filtered or unexported fields }
Participant is a wrapper around gpbft.Participant that implements the Receiver interface
func (Participant) ID ¶
func (p Participant) ID() gpbft.ActorID
type RandomECChainGenerator ¶
type RandomECChainGenerator struct {
// contains filtered or unexported fields
}
RandomECChainGenerator generates deterministic random EC chains with configurable min and max number of tpisets per instance per participant.
Note, the generated chains per instance per participant do not change once generated.
func NewRandomECChainGenerator ¶
func NewRandomECChainGenerator(seed, minTipSets, maxTipSets uint64) *RandomECChainGenerator
func (*RandomECChainGenerator) GenerateECChain ¶
type SimNetwork ¶
type Simulation ¶
type Simulation struct {
// contains filtered or unexported fields
}
func NewSimulation ¶
func NewSimulation(o ...Option) (*Simulation, error)
func (*Simulation) Describe ¶
func (s *Simulation) Describe() string
func (*Simulation) GetInstance ¶
func (s *Simulation) GetInstance(i uint64) *ECInstance
func (*Simulation) ListParticipantIDs ¶
func (s *Simulation) ListParticipantIDs() []gpbft.ActorID
ListParticipantIDs lists the ID of honest participants in simulation. Note that the adversary ID is not included in the list.
type StoragePowerGenerator ¶
type StoragePowerGenerator func(instance uint64, id gpbft.ActorID) gpbft.StoragePower
func UniformStoragePower ¶
func UniformStoragePower(power gpbft.StoragePower) StoragePowerGenerator
type TipSetGenerator ¶
type TipSetGenerator struct {
// contains filtered or unexported fields
}
A tipset generator. This uses a fast xorshift PRNG to generate random tipset IDs. The statistical properties of these are not important to correctness.
func NewTipSetGenerator ¶
func NewTipSetGenerator(seed uint64) *TipSetGenerator
func (*TipSetGenerator) Sample ¶
func (c *TipSetGenerator) Sample() gpbft.TipSetKey
type UniformECChainGenerator ¶
type UniformECChainGenerator struct {
// contains filtered or unexported fields
}
UniformECChainGenerator generates deterministic random EC chains that are uniform across all participants per instance.
func NewUniformECChainGenerator ¶
func NewUniformECChainGenerator(seed, minTipSets, maxTipSets uint64) *UniformECChainGenerator