diff --git a/sim/options.go b/sim/options.go index 76d5c4ef..58f19dbc 100644 --- a/sim/options.go +++ b/sim/options.go @@ -16,9 +16,8 @@ const ( ) var ( - defaultBaseChain gpbft.ECChain - defaultBeacon = []byte("beacon") - defaultLatencyModel latency.Model + defaultBaseChain gpbft.ECChain + defaultBeacon = []byte("beacon") ) func init() { @@ -27,10 +26,6 @@ func init() { if err != nil { panic("failed to instantiate default simulation base chain") } - defaultLatencyModel, err = latency.NewLogNormal(time.Now().UnixMilli(), time.Second*5) - if err != nil { - panic("failed to instantiate default simulation latency model") - } } type Option func(*options) error @@ -69,7 +64,7 @@ func newOptions(o ...Option) (*options, error) { opts.honestCount = defaultHonestCount } if opts.latencyModel == nil { - opts.latencyModel = defaultLatencyModel + opts.latencyModel = latency.None } if opts.signingBacked == nil { opts.signingBacked = signing.NewFakeBackend() diff --git a/sim/sim.go b/sim/sim.go index d316a91d..4e8f3271 100644 --- a/sim/sim.go +++ b/sim/sim.go @@ -122,7 +122,7 @@ func (s *Simulation) Run(instanceCount uint64, maxRounds uint64) error { if s.decisions.err != nil { return fmt.Errorf("error in decision: %w", s.decisions.err) } - if s.participants[0].CurrentRound() >= maxRounds { + if s.getMaxRound() > maxRounds { return fmt.Errorf("reached maximum number of %d rounds", maxRounds) } // Verify the current instance as soon as it completes. @@ -181,3 +181,14 @@ func (s *Simulation) GetInstance(i int) *ECInstance { } return s.ec.Instances[i] } + +func (s *Simulation) getMaxRound() uint64 { + var maxRound uint64 + for _, participant := range s.participants { + currentRound := participant.CurrentRound() + if currentRound > maxRound { + maxRound = currentRound + } + } + return maxRound +}