Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Merged by Bors] - hare3: increase round latency to 700ms in system tests #4949

Closed
wants to merge 9 commits into from
Closed
2 changes: 1 addition & 1 deletion config/presets/fastnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func fastnet() config.Config {
conf.HARE3.Committee = 800
conf.HARE3.Leaders = 10
conf.HARE3.PreroundDelay = 3 * time.Second
conf.HARE3.RoundDuration = 500 * time.Millisecond
conf.HARE3.RoundDuration = 700 * time.Millisecond
conf.HARE3.IterationsLimit = 2

conf.P2P.MinPeers = 10
Expand Down
15 changes: 8 additions & 7 deletions hare3/hare.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/spacemeshos/go-spacemesh/common/types"
"github.com/spacemeshos/go-spacemesh/datastore"
"github.com/spacemeshos/go-spacemesh/layerpatrol"
"github.com/spacemeshos/go-spacemesh/log"
"github.com/spacemeshos/go-spacemesh/metrics"
"github.com/spacemeshos/go-spacemesh/p2p"
"github.com/spacemeshos/go-spacemesh/p2p/pubsub"
Expand Down Expand Up @@ -69,7 +70,10 @@ func (cfg *Config) MarshalLogObject(encoder zapcore.ObjectEncoder) error {
// roundStart returns expected time for iter/round relative to
// layer start.
func (cfg *Config) roundStart(round IterRound) time.Duration {
return cfg.PreroundDelay + time.Duration(round.Absolute())*cfg.RoundDuration
if round.Round == 0 {
return cfg.PreroundDelay
}
return cfg.PreroundDelay + time.Duration(round.Absolute()-1)*cfg.RoundDuration
}

func DefaultConfig() Config {
Expand Down Expand Up @@ -278,11 +282,9 @@ func (h *Hare) Handler(ctx context.Context, peer p2p.Peer, buf []byte) error {
malicious: malicious,
atxgrade: g,
}
h.log.Debug("on message", zap.Inline(input))
gossip, equivocation := session.OnInput(input)
h.log.Debug("on message",
zap.Inline(input),
zap.Bool("gossip", gossip),
)
h.log.Debug("after on message", log.ZShortStringer("hash", input.msgHash), zap.Bool("gossip", gossip))
submitLatency.Observe(time.Since(start).Seconds())
if equivocation != nil && !malicious {
h.log.Debug("registered equivocation",
Expand Down Expand Up @@ -377,7 +379,6 @@ func (h *Hare) run(layer types.LayerID, beacon types.Beacon, proto *protocol) er
if err := h.onOutput(layer, current, proto.Next(vrf != nil), vrf); err != nil {
return err
}
h.log.Debug("ready to accept messages", zap.Uint32("lid", layer.Uint32()))
walltime = walltime.Add(h.config.RoundDuration)
result := false
for {
Expand All @@ -388,9 +389,9 @@ func (h *Hare) run(layer types.LayerID, beacon types.Beacon, proto *protocol) er
zap.Uint8("iter", proto.Iter), zap.Stringer("round", proto.Round),
)
current := proto.IterRound
start := time.Now()
var vrf *types.HareEligibility
if current.IsMessageRound() {
start := time.Now()
vrf = h.oracle.active(h.signer.NodeID(), layer, current)
activeLatency.Observe(time.Since(start).Seconds())
}
Expand Down
17 changes: 5 additions & 12 deletions hare3/hare_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/require"
"go.uber.org/zap/zapcore"
"golang.org/x/sync/errgroup"

"github.com/spacemeshos/go-spacemesh/codec"
"github.com/spacemeshos/go-spacemesh/common/types"
Expand Down Expand Up @@ -65,13 +64,14 @@ type testNodeClock struct {
started types.LayerID
waiters []waiter

clock clock.Clock
genesis time.Time
layerDuration time.Duration
}

func (t *testNodeClock) CurrentLayer() types.LayerID {
return types.LayerID(t.clock.Now().Sub(t.genesis) / t.layerDuration)
t.mu.Lock()
defer t.mu.Unlock()
return t.started
}

func (t *testNodeClock) LayerToTime(lid types.LayerID) time.Time {
Expand Down Expand Up @@ -208,7 +208,6 @@ func (n *node) withHare() *node {
require.NoError(n.t, err)

n.nclock = &testNodeClock{
clock: n.clock,
genesis: n.t.start,
layerDuration: n.t.layerDuration,
}
Expand Down Expand Up @@ -396,17 +395,11 @@ func (cl *lockstepCluster) setup() {
n.oracle.UpdateActiveSet(cl.t.genesis.GetEpoch()+1, active)
n.mpublisher.EXPECT().Publish(gomock.Any(), gomock.Any(), gomock.Any()).Do(func(ctx context.Context, _ string, msg []byte) error {
cl.timedReceive(cl.start)
var eg errgroup.Group
for _, other := range cl.nodes {
other := other
eg.Go(func() error {
other.hare.Handler(ctx, "self", msg)
return nil
})
other.hare.Handler(ctx, "self", msg)
}
err := eg.Wait()
cl.timedSend(cl.complete)
return err
return nil
}).AnyTimes()
}
}
Expand Down
3 changes: 3 additions & 0 deletions systest/parameters/fastnet/smesher.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,8 @@
"transaction", "activation", "admin", "smesher"
],
"grpc-private-services": []
},
"logging": {
"hare": "debug"
}
}