From 4bbe5abf818239c83ef332508f0aca8b35f63653 Mon Sep 17 00:00:00 2001 From: whyrusleeping Date: Wed, 29 Jul 2020 14:20:07 -0700 Subject: [PATCH 1/2] improve slow block production logs --- miner/miner.go | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/miner/miner.go b/miner/miner.go index a6b18c3fe..399268553 100644 --- a/miner/miner.go +++ b/miner/miner.go @@ -367,15 +367,14 @@ func (m *Miner) mineOne(ctx context.Context, base *MiningBase) (*types.BlockMsg, dur := tCreateBlock.Sub(start) log.Infow("mined new block", "cid", b.Cid(), "height", b.Header.Height, "took", dur) if dur > time.Second*time.Duration(build.BlockDelaySecs) { - log.Warn("CAUTION: block production took longer than the block delay. Your computer may not be fast enough to keep up") - - log.Warnw("tMinerBaseInfo ", "duration", tMBI.Sub(start)) - log.Warnw("tDrand ", "duration", tDrand.Sub(tMBI)) - log.Warnw("tPowercheck ", "duration", tPowercheck.Sub(tDrand)) - log.Warnw("tTicket ", "duration", tTicket.Sub(tPowercheck)) - log.Warnw("tSeed ", "duration", tSeed.Sub(tTicket)) - log.Warnw("tPending ", "duration", tPending.Sub(tSeed)) - log.Warnw("tCreateBlock ", "duration", tCreateBlock.Sub(tPending)) + log.Warnw("CAUTION: block production took longer than the block delay. Your computer may not be fast enough to keep up", + "tMinerBaseInfo ", tMBI.Sub(start), + "tDrand ", tDrand.Sub(tMBI), + "tPowercheck ", tPowercheck.Sub(tDrand), + "tTicket ", tTicket.Sub(tPowercheck), + "tSeed ", tSeed.Sub(tTicket), + "tPending ", tPending.Sub(tSeed), + "tCreateBlock ", tCreateBlock.Sub(tPending)) } return b, nil From 4e4fbafbe0881c90a13fcd13fec6c670a84f1279 Mon Sep 17 00:00:00 2001 From: whyrusleeping Date: Wed, 29 Jul 2020 14:28:25 -0700 Subject: [PATCH 2/2] only log hello failure if the other side claims to support hello --- node/modules/services.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/node/modules/services.go b/node/modules/services.go index 3b7fff46a..278b64186 100644 --- a/node/modules/services.go +++ b/node/modules/services.go @@ -43,7 +43,11 @@ func RunHello(mctx helpers.MetricsCtx, lc fx.Lifecycle, h host.Host, svc *hello. if err := svc.SayHello(helpers.LifecycleCtx(mctx, lc), pic.Peer); err != nil { protos, _ := h.Peerstore().GetProtocols(pic.Peer) agent, _ := h.Peerstore().Get(pic.Peer, "AgentVersion") - log.Warnw("failed to say hello", "error", err, "peer", pic.Peer, "supported", protos, "agent", agent) + if protosContains(protos, hello.ProtocolID) { + log.Warnw("failed to say hello", "error", err, "peer", pic.Peer, "supported", protos, "agent", agent) + } else { + log.Debugw("failed to say hello", "error", err, "peer", pic.Peer, "supported", protos, "agent", agent) + } return } }() @@ -52,6 +56,15 @@ func RunHello(mctx helpers.MetricsCtx, lc fx.Lifecycle, h host.Host, svc *hello. return nil } +func protosContains(protos []string, search string) bool { + for _, p := range protos { + if p == search { + return true + } + } + return false +} + func RunPeerMgr(mctx helpers.MetricsCtx, lc fx.Lifecycle, pmgr *peermgr.PeerMgr) { go pmgr.Run(helpers.LifecycleCtx(mctx, lc)) }