p2p: a --public node accepts 1000 inbound connections (--max-conns), instead of libp2p's memory-scaled default
The simulator showed libp2p's default cap (about 190 on 16 GB) stranding newcomers on a bootstrap node: 12 of 200 and 212 of 400 nodes never found a peer. As shipped, the same networks now form and deliver 100% up to 600 nodes. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AeFqV96dVeBX94inzcgZKw
This commit is contained in:
@@ -15,7 +15,6 @@ import (
|
||||
pubsub "github.com/libp2p/go-libp2p-pubsub"
|
||||
"github.com/libp2p/go-libp2p/core/host"
|
||||
"github.com/libp2p/go-libp2p/core/peer"
|
||||
rcmgr "github.com/libp2p/go-libp2p/p2p/host/resource-manager"
|
||||
"github.com/libp2p/go-libp2p/p2p/transport/tcp"
|
||||
ma "github.com/multiformats/go-multiaddr"
|
||||
|
||||
@@ -79,21 +78,6 @@ func (l *lossyConn) Write(p []byte) (int, error) {
|
||||
return l.Conn.Write(p)
|
||||
}
|
||||
|
||||
// seedLimits lifts libp2p's connection limits (which scale with the machine's
|
||||
// memory, and by default allow only about 190 inbound connections on 16 GB of
|
||||
// RAM) so a run can show what they do to a network of a few hundred nodes.
|
||||
func seedLimits(conns int) libp2p.Option {
|
||||
limits := rcmgr.DefaultLimits
|
||||
libp2p.SetDefaultServiceLimits(&limits)
|
||||
cfg := rcmgr.PartialLimitConfig{
|
||||
System: rcmgr.ResourceLimits{Conns: rcmgr.LimitVal(conns * 2), ConnsInbound: rcmgr.LimitVal(conns)},
|
||||
Transient: rcmgr.ResourceLimits{Conns: rcmgr.LimitVal(conns), ConnsInbound: rcmgr.LimitVal(conns)},
|
||||
}
|
||||
mgr, err := rcmgr.NewResourceManager(rcmgr.NewFixedLimiter(cfg.Build(limits.AutoScale())))
|
||||
must(err)
|
||||
return libp2p.ResourceManager(mgr)
|
||||
}
|
||||
|
||||
// --- attackers ----------------------------------------------------------------------------
|
||||
|
||||
// attacker is a bare libp2p and gossipsub peer without any of the node's
|
||||
|
||||
Reference in New Issue
Block a user