sim

package
v0.7.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 3, 2024 License: Apache-2.0, MIT Imports: 18 Imported by: 1

Documentation

Index

Constants

View Source
const (
	TraceNone = iota
	TraceSent
	TraceRecvd
	TraceLogic
	TraceAll //nolint:unused
)

Variables

View Source
var ErrInstanceUnavailable = errors.New("instance not available")

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

func (u *AggregateECChainGenerator) GenerateECChain(instance uint64, base gpbft.TipSet, participant gpbft.ActorID) gpbft.ECChain

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

func (u *BaseECChainGenerator) GenerateECChain(_ uint64, base gpbft.TipSet, _ gpbft.ActorID) gpbft.ECChain

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

func (eci *ECInstance) HasReachedConsensus(exclude ...gpbft.ActorID) (*gpbft.ECChain, bool)

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 (n *Network) AddParticipant(id gpbft.ActorID, p gpbft.Receiver)

func (*Network) HasMoreTicks added in v0.4.0

func (n *Network) HasMoreTicks() bool

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

func (*Network) SetAlarm

func (n *Network) SetAlarm(sender gpbft.ActorID, at time.Time)

func (*Network) Tick

func (n *Network) Tick(adv *adversary.Adversary) error

Tick disseminates one message among participants and returns whether there are any more messages to process.

func (*Network) Time

func (n *Network) Time() time.Time

type Option

type Option func(*options) error

func AddHonestParticipants

func AddHonestParticipants(count int, ecg ECChainGenerator, spg StoragePowerGenerator) Option

func WitECStabilisationDelay

func WitECStabilisationDelay(d time.Duration) Option

func WithAdversary

func WithAdversary(generator adversary.Generator) Option

func WithBaseChain

func WithBaseChain(base *gpbft.ECChain) Option

func WithECEpochDuration

func WithECEpochDuration(d time.Duration) Option

func WithECStabilisationDelay

func WithECStabilisationDelay(d time.Duration) Option

func WithGlobalStabilizationTime

func WithGlobalStabilizationTime(d time.Duration) Option

func WithGpbftOptions

func WithGpbftOptions(gOpts ...gpbft.Option) Option

func WithIgnoreConsensusFor

func WithIgnoreConsensusFor(id ...gpbft.ActorID) Option

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 WithLatencyModeler(lm latency.Modeler) Option

func WithSigningBackend

func WithSigningBackend(sb signing.Backend) Option

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

func WithTraceLevel(i int) Option

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

func (u *RandomECChainGenerator) GenerateECChain(instance uint64, base gpbft.TipSet, participant gpbft.ActorID) gpbft.ECChain

type SimNetwork

type SimNetwork interface {
	gpbft.Network
	gpbft.Tracer
	// sends a message to all other participants immediately.
	RequestSynchronousBroadcast(mb *gpbft.MessageBuilder) error
}

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.

func (*Simulation) Run

func (s *Simulation) Run(instanceCount uint64, maxRounds uint64) error

Run runs simulation, and returns whether all participants decided on the same value.

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

func (*UniformECChainGenerator) GenerateECChain

func (u *UniformECChainGenerator) GenerateECChain(instance uint64, base gpbft.TipSet, _ gpbft.ActorID) gpbft.ECChain

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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