Documentation ¶
Index ¶
- Constants
- type ChainCount
- type DecisionLog
- func (dl *DecisionLog) BeginInstance(instance uint64, base gpbft.TipSet, power *gpbft.PowerTable)
- func (dl *DecisionLog) HasCompletedInstance(instance uint64, adversary gpbft.ActorID) bool
- func (dl *DecisionLog) PrintInstance(instance uint64)
- func (dl *DecisionLog) ReceiveDecision(participant gpbft.ActorID, decision *gpbft.Justification) (first bool)
- func (dl *DecisionLog) VerifyInstance(instance uint64, adversary gpbft.ActorID) error
- type EC
- type ECInstance
- type Network
- func (n *Network) AddParticipant(p gpbft.Receiver)
- func (n *Network) Broadcast(msg *gpbft.GMessage)
- func (n *Network) BroadcastSynchronous(sender gpbft.ActorID, msg gpbft.GMessage)
- func (n *Network) Log(format string, args ...interface{})
- func (n *Network) NetworkName() gpbft.NetworkName
- func (n *Network) SetAlarm(sender gpbft.ActorID, at time.Time)
- func (n *Network) Tick(adv *adversary.Adversary) (bool, error)
- func (n *Network) Time() time.Time
- type 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 WithGpbftOptions(gOpts ...gpbft.Option) Option
- func WithHonestParticipantCount(i int) Option
- func WithLatencyModel(lm latency.Model) Option
- func WithSigningBackend(sb signing.Backend) Option
- func WithTipSetGenerator(tsg *TipSetGenerator) Option
- func WithTraceLevel(i int) Option
- type Simulation
- func (s *Simulation) Describe() string
- func (s *Simulation) GetDecision(instance uint64, participant gpbft.ActorID) (gpbft.ECChain, bool)
- func (s *Simulation) GetInstance(i int) *ECInstance
- func (s *Simulation) HonestParticipantsCount() int
- func (s *Simulation) ListParticipantIDs() []gpbft.ActorID
- func (s *Simulation) PowerTable(instance uint64) *gpbft.PowerTable
- func (s *Simulation) PrintResults()
- func (s *Simulation) Run(instanceCount uint64, maxRounds uint64) error
- func (s *Simulation) SetChains(chains ...ChainCount)
- type TipSetGenerator
Constants ¶
const ( TraceNone = iota TraceSent TraceRecvd TraceLogic TraceAll //nolint:unused )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChainCount ¶
type DecisionLog ¶
type DecisionLog struct { // Base tipset for each instance. Bases []gpbft.TipSet // Powertable for each instance. PowerTables []*gpbft.PowerTable // Decisions received for each instance and participant. Decisions []map[gpbft.ActorID]*gpbft.Justification // contains filtered or unexported fields }
Receives and validates finality decisions
func (*DecisionLog) BeginInstance ¶
func (dl *DecisionLog) BeginInstance(instance uint64, base gpbft.TipSet, power *gpbft.PowerTable)
Establishes the base tipset and power table for a new instance.
func (*DecisionLog) HasCompletedInstance ¶
func (dl *DecisionLog) HasCompletedInstance(instance uint64, adversary gpbft.ActorID) bool
Checks whether all participants (except any adversary) have decided on a value for an instance.
func (*DecisionLog) PrintInstance ¶
func (dl *DecisionLog) PrintInstance(instance uint64)
func (*DecisionLog) ReceiveDecision ¶
func (dl *DecisionLog) ReceiveDecision(participant gpbft.ActorID, decision *gpbft.Justification) (first bool)
Verifies and records a decision from a participant. Returns whether this was the first decision for the instance.
func (*DecisionLog) VerifyInstance ¶
func (dl *DecisionLog) VerifyInstance(instance uint64, adversary gpbft.ActorID) error
Checks that all participants (except any adversary) for an instance decided on the same value.
type EC ¶
type EC struct {
Instances []*ECInstance
}
Simulated EC state for each protocol instance.
func (*EC) AddInstance ¶
Adds a new instance to the EC state, with a new chain shared by all participants. The power table and beacon correspond to the base of the new chain.
func (*EC) AddParticipant ¶
Adds a participant to the first instance.
type ECInstance ¶
type ECInstance struct { // The base of all chains, which participants must agree on. Base gpbft.ECChain // EC chains visible to participants. Chains map[gpbft.ActorID]gpbft.ECChain // The power table at the base chain head. PowerTable *gpbft.PowerTable // The beacon value of the base chain head. Beacon []byte }
type Network ¶
type Network struct {
// contains filtered or unexported fields
}
func (*Network) AddParticipant ¶
func (*Network) BroadcastSynchronous ¶
func (*Network) NetworkName ¶
func (n *Network) NetworkName() gpbft.NetworkName
type Option ¶
type Option func(*options) error
func WitECStabilisationDelay ¶
func WithAdversary ¶
func WithBaseChain ¶
func WithECEpochDuration ¶
func WithGpbftOptions ¶
func WithLatencyModel ¶
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 WithTipSetGenerator ¶
func WithTipSetGenerator(tsg *TipSetGenerator) Option
func WithTraceLevel ¶
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) GetDecision ¶
Returns the decision for a participant in an instance.
func (*Simulation) GetInstance ¶
func (s *Simulation) GetInstance(i int) *ECInstance
func (*Simulation) HonestParticipantsCount ¶
func (s *Simulation) HonestParticipantsCount() int
func (*Simulation) ListParticipantIDs ¶
func (s *Simulation) ListParticipantIDs() []gpbft.ActorID
func (*Simulation) PowerTable ¶
func (s *Simulation) PowerTable(instance uint64) *gpbft.PowerTable
func (*Simulation) PrintResults ¶
func (s *Simulation) PrintResults()
func (*Simulation) Run ¶
func (s *Simulation) Run(instanceCount uint64, maxRounds uint64) error
Runs simulation, and returns whether all participants decided on the same value.
func (*Simulation) SetChains ¶
func (s *Simulation) SetChains(chains ...ChainCount)
Sets canonical chains to be delivered to honest participants in the first instance.
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.TipSet