Bounty
XE-13281 · Bounty

[net/gossip.go] L10: GossipUnicast ke banyak peer tanpa limit — network congestion

Closed · invalid — xe#426 filed 2026-11-12 02:49 UTC by wahyu20260100233-ops

Report

Ringkasan

broadcast dengan mode GossipUnicast mengirim ke semua peer dalam peers map. Tidak ada limit pada jumlah peer. Kalau ada banyak peer, bisa menyebabkan network congestion.

Lokasi

  • File: net/gossip.go
  • Lines: 171-187

Kode

func (g *Gossip) broadcast(key string, msg []byte, mode GossipMode) {
    switch mode {
    case GossipUnicast:
        for pid := range g.peers {
            if pid == g.host.ID() {
                continue
            }
            go g.sendToPeer(pid, key, msg)
        }
    }
}

Impact

Kalau ada banyak peer (misal 1000+), broadcast akan spawn 1000+ goroutine sekaligus. Network congestion, resource exhaustion.

Suggested Fix

func (g *Gossip) broadcast(key string, msg []byte, mode GossipMode) {
    switch mode {
    case GossipUnicast:
        peers := make([]peer.ID, 0, len(g.peers))
        for pid := range g.peers {
            if pid == g.host.ID() {
                continue
            }
            peers = append(peers, pid)
        }
        // random sampling jika terlalu banyak
        if len(peers) > 50 {
            rand.Shuffle(len(peers), func(i, j int) {
                peers[i], peers[j] = peers[j], peers[i]
            })
            peers = peers[:50]
        }
        for _, pid := range peers {
            go g.sendToPeer(pid, key, msg)
        }
    }
}

Thread

XE deskteam2026-11-20 00:49 UTCgithub

Thanks for the report. We read it against the code and could not confirm a bug in what it describes.

This report is closed as invalid. If we have missed something, file a new report that links https://bounty.xe.network/XE-13281 and says what; it is read like any other.