From 24941884b5063e33b948e090cd73b1e38845b2ae Mon Sep 17 00:00:00 2001 From: Herbert Date: Wed, 4 Dec 2024 09:32:08 +0100 Subject: [PATCH] Skip fetching event payloads when streaming events (#372) --- gossip/handler.go | 8 +++++++- .../protocols/dag/dagstream/dagstreamleecher/leecher.go | 7 ++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/gossip/handler.go b/gossip/handler.go index 1a550cb1b..732c8a147 100644 --- a/gossip/handler.go +++ b/gossip/handler.go @@ -3,6 +3,8 @@ package gossip import ( "errors" "fmt" + "io" + "log/slog" "math" "math/rand/v2" "strings" @@ -553,7 +555,11 @@ func (h *handler) handle(p *peer) error { // Handle incoming messages until the connection is torn down for { if err := h.handleMsg(p); err != nil { - p.Log().Debug("Message handling failed", "err", err, "peer", p.ID(), "name", p.Name()) + level := slog.LevelWarn + if errors.Is(err, io.EOF) { + level = slog.LevelDebug + } + p.Log().Log(level, "Message handling failed", "err", err, "peer", p.ID(), "name", p.Name()) return err } } diff --git a/gossip/protocols/dag/dagstream/dagstreamleecher/leecher.go b/gossip/protocols/dag/dagstream/dagstreamleecher/leecher.go index fe8f221a5..e5aba7692 100644 --- a/gossip/protocols/dag/dagstream/dagstreamleecher/leecher.go +++ b/gossip/protocols/dag/dagstream/dagstreamleecher/leecher.go @@ -148,10 +148,11 @@ func (d *Leecher) startSession(candidates []string) { } } + // We only fetch IDs since fetching IDs and events leads to message decoding + // issues causing the peer connection the request was send to to be closed. + // By requesting IDs only, this issue is avoided. The payloads of events are + // then requested independently using the non-streaming P2P protocol. typ := dagstream.RequestIDs - if d.callback.PeerEpoch(peer) > d.epoch && d.emptyState && d.session.try == 0 { - typ = dagstream.RequestEvents - } session := dagstream.Session{ ID: getSessionID(d.epoch, d.session.try),