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:
@@ -78,7 +78,7 @@ type sim struct {
|
||||
timeout time.Duration
|
||||
made []*listing.Listing
|
||||
mu sync.Mutex // guards nodes against the sampler
|
||||
seedConns int // raised connection limit of the seeds; 0 keeps libp2p's default
|
||||
seedConns int // the seeds' MaxConns setting
|
||||
}
|
||||
|
||||
func main() {
|
||||
@@ -95,7 +95,7 @@ func main() {
|
||||
timeout := flag.Duration("timeout", 60*time.Second, "how long to wait for each thing to spread")
|
||||
latency := flag.Duration("latency", 0, "delay added to every write on connections a node dials (one direction), with up to 50% jitter")
|
||||
lifetime := flag.Duration("lifetime", 0, "mean lifetime of a dialed connection before it is cut (0: never); redials and resyncs follow")
|
||||
seedConns := flag.Int("seed-conns", 0, "raise the seeds' inbound connection limit to this many (0: libp2p's default, which scales with RAM)")
|
||||
seedConns := flag.Int("seed-conns", 0, "the seeds' inbound connection limit (0: the node's default for --public, 1000; -1: libp2p's own, which scales with RAM)")
|
||||
jsonOut := flag.String("json", "", "write the run (samples every second, phases, arrival times) to this JSON file, for graphs")
|
||||
hostile := flag.Bool("hostile", false, "also run attackers: invalid listings, a message flood")
|
||||
killSeeds := flag.Bool("kill-seeds", false, "also shut the seeds down and see what the network and newcomers do")
|
||||
@@ -336,16 +336,17 @@ func (s *sim) start(n *simNode) error {
|
||||
if bootstrap == nil {
|
||||
bootstrap = s.seedAddrs
|
||||
}
|
||||
extra := s.extra
|
||||
if n.seed && s.seedConns > 0 {
|
||||
extra = append(append([]libp2p.Option(nil), extra...), seedLimits(s.seedConns))
|
||||
maxConns := 0 // the node's own default: DefaultPublicConns for a seed
|
||||
if n.seed {
|
||||
maxConns = s.seedConns
|
||||
}
|
||||
node, err := p2p.New(s.ctx, p2p.Config{
|
||||
Device: n.dev,
|
||||
Store: n.st,
|
||||
ListenAddrs: []string{"/ip4/127.0.0.1/tcp/0"},
|
||||
Bootstrap: bootstrap,
|
||||
ExtraOptions: extra,
|
||||
MaxConns: maxConns,
|
||||
ExtraOptions: s.extra,
|
||||
Regions: n.regions,
|
||||
DHT: true,
|
||||
Public: n.seed,
|
||||
|
||||
Reference in New Issue
Block a user