Skip to content

Commit

Permalink
Implement divergent EC chain in simulations
Browse files Browse the repository at this point in the history
So far simulations used the same EC chain across all participants after
the first instance. This approach was simple but not representative of
the real-world where the EC chain may diverge across multiple subsets
of participants.

The changes here implement a comprehensive set of APIs that allow a set
of EC generation strategies to mix-and-match and replicate complex EC
chain evolution through iterations of a simulation. The chain evolution
is controllable by instance by actor ID. This allows us to simulate
fluctuating EC evolution patterns throughout a simulation. The changes
include an initial set of EC generators that cover:

* Fixed EC for all instances and participants.
* Random EC per instance per participant.
* Random EC per instance but uniform across all participants.
* Common prefix EC per instance with probabilistic length
* Majority common prefix across a set of participants with probabilistic
  length

The EC generators can be aggregated and set per number of participants,
which enables simulation of a flexible set of scenarios including
evolving majority common prefix.

Fixes #115
  • Loading branch information
masih committed May 10, 2024
1 parent fbfbde9 commit 52f910b
Show file tree
Hide file tree
Showing 18 changed files with 674 additions and 585 deletions.
4 changes: 2 additions & 2 deletions gpbft/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ func (c ECChain) BaseChain() ECChain {
return ECChain{c[0]}
}

func (c ECChain) Extend(tip TipSet) ECChain {
return append(c, tip)
func (c ECChain) Extend(tip ...TipSet) ECChain {
return append(c, tip...)
}

// Returns a chain with suffix (after the base) truncated to a maximum length.
Expand Down
19 changes: 2 additions & 17 deletions sim/cmd/f3sim/f3sim.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,11 @@ func main() {
log.Panicf("failed to instantiate log normal latency model: %c\n", err)
}

tsg := sim.NewTipSetGenerator(uint64(seed))
baseChain, err := gpbft.NewChain(tsg.Sample())
if err != nil {
log.Fatalf("failed to generate base chain: %v\n", err)
}

options := []sim.Option{
sim.WithHonestParticipantCount(*participantCount),
sim.WithLatencyModel(latencyModel),
sim.WithECEpochDuration(30 * time.Second),
sim.WithECStabilisationDelay(0),
sim.WithTipSetGenerator(tsg),
sim.WithBaseChain(&baseChain),
sim.AddHonestParticipants(*participantCount, sim.NewUniformECChainGenerator(uint64(seed), 1, 10)),
sim.WithTraceLevel(*traceLevel),
sim.WithGpbftOptions(
gpbft.WithDelta(*delta),
Expand All @@ -60,19 +52,12 @@ func main() {
}

sm, err := sim.NewSimulation(options...)
if err != nil {
return
}
if err != nil {
log.Panicf("failed to instantiate simulation: %v\n", err)
}

// Same chain for everyone.
candidate := baseChain.Extend(tsg.Sample())
sm.SetChains(sim.ChainCount{Count: *participantCount, Chain: candidate})

if err := sm.Run(1, *maxRounds); err != nil {
sm.PrintResults()
sm.GetInstance(0).Print()
os.Exit(1)
}
}
Expand Down
164 changes: 0 additions & 164 deletions sim/decision_log.go

This file was deleted.

Loading

0 comments on commit 52f910b

Please sign in to comment.