AutoNAT junk candidates

未关闭
#7,798 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
56/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
rust
领域
networking

调研方向

Start in src/libp2p/discovery.rs and find where Identify candidates enter DiscoveryBehaviour::poll. Use libp2p's swarm address-translation helper to map each observed address to the observed IP with the node's listen port for the same transport, then add a unit test covering that translation. Done means the candidate set stays bounded, the translation test passes, and the 25-server reproduction reaches Public status.

由索引模型根据 Issue 内容生成。

描述

Type: Task

[!CAUTION]
Issue AI-generated while investigating connectivity/reachability issues with crawlers.

Summary

Forest nodes behind a NAT that rewrites outgoing ports (Kubernetes, many Docker setups, CGNAT) never confirm their external address, even when their listen port is forwarded and reachable. They stay AutoNAT Private, don't advertise a public address, and are therefore absent from Lotus routing tables and from network measurements (see #7527).

Cause:

  • Identify reports one observed address per connection. Behind such a NAT each outgoing connection is observed with a different port, so every observation is a distinct, undialable candidate. A home node collected 12 of them within seconds of startup.
  • libp2p-autonat (v1, 0.15) only ever adds candidates and never removes them (behaviour.rs:290). Every probe sends all candidates first, followed by our listen addresses (as_client.rs:190-195).
  • The go-libp2p AutoNAT server that Lotus runs dials the observed address plus at most 15 of the requested addresses, substituting the observed IP (p2p/host/autonat/svc.go:150-193, maxPeerAddresses = 16). Once 15 or more junk candidates have accumulated, observed IP + listen port, the only address that would work, is never tried.

Reproduced locally with a calibnet node that was reachable throughout, connected through a port-rewriting proxy to go-libp2p's AutoNAT server code (only change: loopback dial-backs allowed, so the test could run locally):

AutoNAT servers (junk candidates) Probes Status
5 4/4 succeeded Public, listen address confirmed
25 3/3 failed Private

Proposed fix: identify's candidates pass through DiscoveryBehaviour::poll before they reach AutoNAT. Replace each one with observed IP + our listen port for the same transport (libp2p::swarm::_address_translation). The candidate set then stays small and contains the address that actually works for port-forwarded setups (k8s hostPort, Docker -p, cloud 1:1 NAT).

Completion Criteria

  • Translate external address candidates to observed IP + listen port in src/libp2p/discovery.rs
  • Unit test for the translation
  • Verify with the 25-server reproduction: the node reaches Public
  • Report the unbounded candidate set upstream (rust-libp2p autonat v1)

Additional Links & Resources

  • #7527
  • libp2p-autonat 0.15 src/v1/behaviour.rs:290, src/v1/behaviour/as_client.rs:190-195
  • go-libp2p v0.50.0 p2p/host/autonat/svc.go:125-193
主要语言
Rust
星标
700
派生
201
平均合并
1 天 17 小时
30 天内合并 PR
65

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

ChainSafe/forest 的其他 Issue

查看 ChainSafe/forest 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。