Documentation
¶
Index ¶
- func Validated(msg *gpbft.GMessage) gpbft.ValidatedMessage
- type Absent
- func (*Absent) AllowMessage(_ gpbft.ActorID, _ gpbft.ActorID, _ gpbft.GMessage) bool
- func (a *Absent) ID() gpbft.ActorID
- func (*Absent) ReceiveAlarm() error
- func (*Absent) ReceiveMessage(_ gpbft.ValidatedMessage) error
- func (*Absent) StartInstanceAt(uint64, time.Time) error
- func (*Absent) ValidateMessage(msg *gpbft.GMessage) (gpbft.ValidatedMessage, error)
- type Adversary
- type Deny
- func (d *Deny) AllowMessage(from gpbft.ActorID, to gpbft.ActorID, msg gpbft.GMessage) bool
- func (d *Deny) ID() gpbft.ActorID
- func (*Deny) ReceiveAlarm() error
- func (*Deny) ReceiveMessage(gpbft.ValidatedMessage) error
- func (*Deny) StartInstanceAt(uint64, time.Time) error
- func (*Deny) ValidateMessage(msg *gpbft.GMessage) (gpbft.ValidatedMessage, error)
- type DenyMessageMatcher
- type DenyTargetMode
- type Drop
- func (d *Drop) AllowMessage(from gpbft.ActorID, to gpbft.ActorID, _ gpbft.GMessage) bool
- func (d *Drop) ID() gpbft.ActorID
- func (*Drop) ReceiveAlarm() error
- func (*Drop) ReceiveMessage(gpbft.ValidatedMessage) error
- func (*Drop) StartInstanceAt(uint64, time.Time) error
- func (*Drop) ValidateMessage(msg *gpbft.GMessage) (gpbft.ValidatedMessage, error)
- type Generator
- func NewAbsentGenerator(power gpbft.StoragePower) Generator
- func NewDenyGenerator(power gpbft.StoragePower, denialDuration time.Duration, ...) Generator
- func NewDropGenerator(power gpbft.StoragePower, seed int64, dropProbability float64, ...) Generator
- func NewImmediateDecideGenerator(value *gpbft.ECChain, power gpbft.StoragePower, opts ...ImmediateDecideOption) Generator
- func NewRepeatGenerator(power gpbft.StoragePower, sampler RepetitionSampler) Generator
- func NewSpamGenerator(power gpbft.StoragePower, roundsAhead uint64) Generator
- func NewWitholdCommitGenerator(power gpbft.StoragePower, victims []gpbft.ActorID, victimValue *gpbft.ECChain) Generator
- type Host
- type ImmediateDecide
- func (*ImmediateDecide) AllowMessage(_ gpbft.ActorID, _ gpbft.ActorID, _ gpbft.GMessage) bool
- func (i *ImmediateDecide) ID() gpbft.ActorID
- func (*ImmediateDecide) ReceiveAlarm() error
- func (*ImmediateDecide) ReceiveMessage(_ gpbft.ValidatedMessage) error
- func (i *ImmediateDecide) StartInstanceAt(instance uint64, _when time.Time) error
- func (*ImmediateDecide) ValidateMessage(msg *gpbft.GMessage) (gpbft.ValidatedMessage, error)
- type ImmediateDecideOption
- type Receiver
- type Repeat
- func (r *Repeat) AllowMessage(gpbft.ActorID, gpbft.ActorID, gpbft.GMessage) bool
- func (r *Repeat) ID() gpbft.ActorID
- func (r *Repeat) ReceiveAlarm() error
- func (r *Repeat) ReceiveMessage(vmsg gpbft.ValidatedMessage) error
- func (r *Repeat) StartInstanceAt(uint64, time.Time) error
- func (*Repeat) ValidateMessage(msg *gpbft.GMessage) (gpbft.ValidatedMessage, error)
- type RepetitionSampler
- type Spam
- func (s *Spam) AllowMessage(gpbft.ActorID, gpbft.ActorID, gpbft.GMessage) bool
- func (s *Spam) ID() gpbft.ActorID
- func (s *Spam) ReceiveAlarm() error
- func (s *Spam) ReceiveMessage(vmsg gpbft.ValidatedMessage) error
- func (s *Spam) StartInstanceAt(instance uint64, _when time.Time) error
- func (*Spam) ValidateMessage(msg *gpbft.GMessage) (gpbft.ValidatedMessage, error)
- type WithholdCommit
- func (w *WithholdCommit) AllowMessage(_ gpbft.ActorID, to gpbft.ActorID, msg gpbft.GMessage) bool
- func (w *WithholdCommit) ID() gpbft.ActorID
- func (*WithholdCommit) ReceiveAlarm() error
- func (*WithholdCommit) ReceiveMessage(gpbft.ValidatedMessage) error
- func (w *WithholdCommit) SetVictim(victims []gpbft.ActorID, victimValue *gpbft.ECChain)
- func (w *WithholdCommit) StartInstanceAt(instance uint64, _when time.Time) error
- func (*WithholdCommit) ValidateMessage(msg *gpbft.GMessage) (gpbft.ValidatedMessage, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Absent ¶
type Absent struct {
// contains filtered or unexported fields
}
func (*Absent) AllowMessage ¶
func (*Absent) ReceiveAlarm ¶
func (*Absent) ReceiveMessage ¶
func (*Absent) ReceiveMessage(_ gpbft.ValidatedMessage) error
func (*Absent) StartInstanceAt ¶ added in v0.0.3
func (*Absent) ValidateMessage ¶
type Adversary ¶
type Adversary struct { Receiver Power gpbft.StoragePower }
type Deny ¶
type Deny struct {
// contains filtered or unexported fields
}
Deny adversary denies all messages to/from a given set of participants for a configured duration of time.
For this adversary to take effect global stabilisation time must be configured to be at least as long as the configured deny duration.
See sim.WithGlobalStabilizationTime.
func NewDeny ¶
func NewDeny(id gpbft.ActorID, host Host, denialDuration time.Duration, msgMatcher DenyMessageMatcher, mode DenyTargetMode, targets ...gpbft.ActorID) *Deny
func (*Deny) AllowMessage ¶
func (*Deny) ReceiveAlarm ¶
func (*Deny) ReceiveMessage ¶
func (*Deny) ReceiveMessage(gpbft.ValidatedMessage) error
func (*Deny) StartInstanceAt ¶ added in v0.0.3
func (*Deny) ValidateMessage ¶
type DenyMessageMatcher ¶ added in v0.3.0
DenyMessageMatcher checks whether a message should be denied by the Deny adversary or not.
See: DenyAllMessages, DenyPhase.
var (
DenyAllMessages DenyMessageMatcher = func(*gpbft.GMessage) bool { return true }
)
func DenyPhase ¶ added in v0.3.0
func DenyPhase(phase gpbft.Phase) DenyMessageMatcher
DenyPhase denies all messages at the given phase.
type DenyTargetMode ¶ added in v0.3.0
type DenyTargetMode int
const ( // DenyToOrFrom denies message to or from target actor IDs. DenyToOrFrom DenyTargetMode = iota // DenyTo only denies messages destined to target actor IDs. DenyTo // DenyFrom only denies messages sent from target actor IDs. DenyFrom )
func (DenyTargetMode) String ¶ added in v0.3.0
func (m DenyTargetMode) String() string
type Drop ¶
type Drop struct {
// contains filtered or unexported fields
}
Drop adversary stochastically drops messages to/from a given set of participants for a configured duration of time, mimicking at-most-once message delivery semantics across a simulation network.
When no participants are set, all exchanged messages will be targeted by this adversary. For this adversary to take effect global stabilisation time must be configured to be at least as long as the configured drop duration.
See sim.WithGlobalStabilizationTime.
func (*Drop) AllowMessage ¶
func (*Drop) ReceiveAlarm ¶
func (*Drop) ReceiveMessage ¶
func (*Drop) ReceiveMessage(gpbft.ValidatedMessage) error
func (*Drop) StartInstanceAt ¶ added in v0.0.3
func (*Drop) ValidateMessage ¶
type Generator ¶
func NewAbsentGenerator ¶
func NewAbsentGenerator(power gpbft.StoragePower) Generator
func NewDenyGenerator ¶
func NewDenyGenerator(power gpbft.StoragePower, denialDuration time.Duration, msgMatcher DenyMessageMatcher, mode DenyTargetMode, targets ...gpbft.ActorID) Generator
func NewDropGenerator ¶
func NewImmediateDecideGenerator ¶
func NewImmediateDecideGenerator(value *gpbft.ECChain, power gpbft.StoragePower, opts ...ImmediateDecideOption) Generator
func NewRepeatGenerator ¶
func NewRepeatGenerator(power gpbft.StoragePower, sampler RepetitionSampler) Generator
func NewSpamGenerator ¶
func NewSpamGenerator(power gpbft.StoragePower, roundsAhead uint64) Generator
type Host ¶
type Host interface { gpbft.Host gpbft.Signer // Sends a message to all other participants, immediately. // Note that the adversary can subsequently delay delivery to some participants, // before messages are actually received. RequestSynchronousBroadcast(mb *gpbft.MessageBuilder) error }
Endpoint with which the adversary can control the network
type ImmediateDecide ¶
type ImmediateDecide struct {
// contains filtered or unexported fields
}
/ An "adversary" that immediately sends a DECIDE message, justified by its own COMMIT.
func NewImmediateDecide ¶
func NewImmediateDecide(id gpbft.ActorID, host Host, value *gpbft.ECChain, opts ...ImmediateDecideOption) *ImmediateDecide
func (*ImmediateDecide) AllowMessage ¶
func (*ImmediateDecide) ID ¶
func (i *ImmediateDecide) ID() gpbft.ActorID
func (*ImmediateDecide) ReceiveAlarm ¶
func (*ImmediateDecide) ReceiveAlarm() error
func (*ImmediateDecide) ReceiveMessage ¶
func (*ImmediateDecide) ReceiveMessage(_ gpbft.ValidatedMessage) error
func (*ImmediateDecide) StartInstanceAt ¶ added in v0.0.3
func (i *ImmediateDecide) StartInstanceAt(instance uint64, _when time.Time) error
func (*ImmediateDecide) ValidateMessage ¶
func (*ImmediateDecide) ValidateMessage(msg *gpbft.GMessage) (gpbft.ValidatedMessage, error)
type ImmediateDecideOption ¶ added in v0.0.3
type ImmediateDecideOption func(*ImmediateDecide)
func ImmediateDecideWithJustifiedSupplementalData ¶ added in v0.0.4
func ImmediateDecideWithJustifiedSupplementalData(data gpbft.SupplementalData) ImmediateDecideOption
Immediately decide with a value that may or may not match the justification.
func ImmediateDecideWithJustifiedValue ¶ added in v0.0.4
func ImmediateDecideWithJustifiedValue(value *gpbft.ECChain) ImmediateDecideOption
Immediately decide with a value that may or may not match the justification.
func ImmediateDecideWithNthParticipant ¶ added in v0.0.3
func ImmediateDecideWithNthParticipant(n uint64) ImmediateDecideOption
type Repeat ¶
type Repeat struct {
// contains filtered or unexported fields
}
Repeat is a type of adversary in the gpbft consensus protocol that intercepts and rebroadcasts messages. It is designed to test the resilience of the consensus mechanism against Byzantine faults, specifically through message repetition attacks.
The number of times each message is repeated can be configured using RepetitionSampler. This allows simulating fixed or varying degrees of repetition throughout a simulation. The repeated messages are resigned by the adversary with other fields left unmodified. This results in a mimicking behaviour, where the adversary broadcasts any message it receives as its own.
By repeating messages, this adversary can simulate a variety of fault conditions, including the creation of equivocations. Equivocations occur when a node (or in this case, an adversary) sends conflicting information to different parts of the network, which can potentially mislead other nodes about the state of consensus. This behavior effectively amplifies the likelihood of network partitions in cases where there are diverging base chains across the participants. More importantly, this adversary may momentarily appear to be part of one or other network partitions.
See RepetitionSampler.
func NewRepeat ¶
func NewRepeat(id gpbft.ActorID, host Host, sampler RepetitionSampler) *Repeat
NewRepeat creates a new instance of the Repeat adversary using the provided id, host, and repetitionSampler. The RepetitionSampler is used to determine the number of times each message received by this adversary should be repeated and retransmitted to other nodes in the network. This repetition could potentially disrupt or manipulate the consensus process depending on how the repetitionSampler is configured (e.g., fixed or probabilistic repetitions), and can lead to equivocating messages across the network.
The primary role of the Repeat adversary is to intercept messages and then broadcast them multiple times. The number of repetitions for each message is determined by the RepetitionSampler. Each echoed message is signed and optionally includes a new ticket if the original message had one. Note, this adversary does not modify the received messages. Instead, it resigns them as its own and broadcasts them effectively mimicking the behavior of other participants in the network.
func (*Repeat) AllowMessage ¶
func (*Repeat) ReceiveAlarm ¶
func (*Repeat) ReceiveMessage ¶
func (r *Repeat) ReceiveMessage(vmsg gpbft.ValidatedMessage) error
func (*Repeat) StartInstanceAt ¶ added in v0.0.3
func (*Repeat) ValidateMessage ¶
type RepetitionSampler ¶
RepetitionSampler returns the number of times each message is repeated by Repeat adversary. The sampler may implement a fixed or random sampling, and can return different values over time. This allows an implementer to program scenarios where messages are repeated probabilistically or at certain stage through the experiment.
The number of times a message s repeated is dynamically configurable based on the original message itself. For example, an implementer may choose to only repeat messages in a certain phase or from a certain participants. A repetition count of less than or equal to zero signals that the adversary should not rebroadcast the message at all.
type Spam ¶
type Spam struct {
// contains filtered or unexported fields
}
Spam is an adversary that propagates COMMIT messages for bottom for a configured number of future rounds.
func NewSpam ¶
NewSpam instantiates a new Spam adversary that spams the network with spammable messages (i.e. COMMIT for bottom) for the configured number of roundsAhead via either synchronous or regular broadcast. This adversary resigns the spammable messages as its own to mimic messages with valid signature but for future rounds.
func (*Spam) AllowMessage ¶
func (*Spam) ReceiveAlarm ¶
func (*Spam) ReceiveMessage ¶
func (s *Spam) ReceiveMessage(vmsg gpbft.ValidatedMessage) error
func (*Spam) StartInstanceAt ¶ added in v0.0.3
func (*Spam) ValidateMessage ¶
type WithholdCommit ¶
type WithholdCommit struct {
// contains filtered or unexported fields
}
This adversary send its COMMIT message to only a single victim, withholding it from others. Against a naive algorithm, when set up with 30% of power, and a victim set with 40%, it can cause one victim to decide, while others revert to the base.
func NewWitholdCommit ¶
func NewWitholdCommit(id gpbft.ActorID, host Host) *WithholdCommit
A participant that never sends anything.
func (*WithholdCommit) AllowMessage ¶
func (*WithholdCommit) ID ¶
func (w *WithholdCommit) ID() gpbft.ActorID
func (*WithholdCommit) ReceiveAlarm ¶
func (*WithholdCommit) ReceiveAlarm() error
func (*WithholdCommit) ReceiveMessage ¶
func (*WithholdCommit) ReceiveMessage(gpbft.ValidatedMessage) error
func (*WithholdCommit) SetVictim ¶
func (w *WithholdCommit) SetVictim(victims []gpbft.ActorID, victimValue *gpbft.ECChain)
func (*WithholdCommit) StartInstanceAt ¶ added in v0.0.3
func (w *WithholdCommit) StartInstanceAt(instance uint64, _when time.Time) error
func (*WithholdCommit) ValidateMessage ¶
func (*WithholdCommit) ValidateMessage(msg *gpbft.GMessage) (gpbft.ValidatedMessage, error)