chore: migrate to nim-libp2p v2.2.0 - #4102
Conversation
* bump nim-libp2p * require nimble 0.24.1 for the 2.2.0 dependency graph * drop the direct nat_traversal requirement * update mix revision * pin lsquic * refresh dependency locks
* update imports * adapt API changes * update protocol metadata * read the relay message payload once per callback * store peer public keys as bytes and validate them on decode * run the relay bad-peers test over TCP only * fix affected tests
* model NAT user intent * parse existing CLI values * thread strategy through config * treat an empty nat value as not specified * add NAT strategy tests
* configure NATService via the switch builder * select UPnP / NAT-PMP port mappers per strategy * support UPnP-then-NAT-PMP fallback for --nat any * remove legacy nim-eth switch mapping (setupNat) * preserve builder-attached NATService among waku switch services * migrate chat2, chat2bridge, chat2mix off setupNat * default test nodes to --nat none
* capture NAT-mapped addresses from the address mapper chain * recompute announced addresses from the configured base and the mappings * keep every mapped endpoint when resyncing from the recomputed config * stop announcing external endpoints once their mapping lapses * feed NAT results into recomputed NetConfig and ENR * announce no guessed external quic port without a mapping
* bound gateway discovery * recover rejected mappings * re-elect fallback mappers * map discv5 UDP and renew it * refresh the ENR when discv5 renews on a different external port * project the discv5 external port only with a switch external address * reject a zero NAT discovery timeout * refresh ENR on announced-address changes * announce no guessed external websocket port without a mapping * extend NAT coverage
…ost (#4100) * raise the test job timeout from 60 to 80 minutes
|
You can find the images built from this PR at Built from b944495 |
|
Hi, here's what Claude tells me: IssuesCorrectness / behavior
Configuration surface
|
|
Correction: this comment was posted to the wrong repository while investigating a different PR numbered #4102. Please disregard it. No code or branch changes were made here. |
|
nim-libp2p v2.3.0 will likely be released today, so maybe worth wait and integrate with that instead? |
Thanks! Yes, I'll port the bump version I have now to it. This PR here won't be merged. |
PR Description
NOTE: I'm working on an alternative version of the NAT feature; if that pans out, this PR will be replaced.
This PR bumps nim-libp2p to v2.2.0.
The work is split across the 8 PRs below, which can be reviewed individually.
Most changes in this PR are about NAT. v2.2.0 adds a
NATConfigcovering port mapping (UPnP, NAT-PMP or a static external IP), reachability (autonat), and hole punching. Each is built with its own helper (upnpConfig,natPmpConfig,explicitIpConfig) and attached to a switch withwithNAT, which can be called once per concern. ANATServiceon the switch owns gateway discovery, the mappings and their lease renewal, and publishes the mapped addresses through the switch's address mapper chain.--natkeeps its contract:none,any,upnp,pmp,extip:<ip>. It is parsed once at the CLI edge into a typedNatStrategy.The point at which mappings are known also moved.
setupNatran before the switch existed, so an external IP and ports were available while the announced addresses were still being built. Under the NATService they exist only once the switch has started, so the announced set is now resolved at start: port 0 placeholders are replaced with the ports the sockets actually bound, and the NATService's mapped addresses are read off the address mapper chain and added to the announced set. The ENR is rebuilt from that same set, and again whenever a later mapping changes the set.Announced addresses now follow the mappings that exist rather than the ones we assume. The external port used to be guessed from the bind port; now a transport without a mapping announces no external address for that transport, a mapping that changes port is followed, and one that lapses stops being announced.
discv5 is mapped separately. Its UDP socket is not owned by the switch, so the NATService does not map it; the node requests that mapping itself and renews it before the lease expires, and the port the gateway grants is the one the ENR advertises.
What configuration asked for is kept separately as a base, and the announced set is recomputed from that base plus whatever mappings are live rather than edited in place. Mappings can appear, move to another port or lapse without taking the configured entries with them, so an operator's
extip:endpoint or dns4 announce stays in the set regardless of what the gateway is doing.Notes
send-api-e2e-testsis failing in master, and this PR makes it slightly worse (e.g. NAT changes make e2e tests take longer, which is solved if we increase timeouts from e.g. 20s to 45s); fixes for this CI job should be in a separate PR.nat_traversalis no longer a direct dependency, but libp2p's NATService links the same miniupnpc and libnatpmp static libraries.Nat.mk, the iOS vendor build inlogos_delivery.nimbleandlibrary/ios_natpmp_stubs.ctherefore stay, although Bump nim-libp2p to v2.2.0 and replace nat_traversal with libp2p NATConfig #4041 expects all three to go with the dependency.Changes
Superseded PRs
closes #4055
closes #4060
Issue
Closes #4041