fix(basichost): sort confirmed addrs#3526
Open
lidel wants to merge 1 commit into
Open
Conversation
probeManager.AppendConfirmedAddrs emits primary addrs followed by secondary addrs. Each half is sorted, the concatenation is not, and both consumers require input sorted by Multiaddr.Compare: addrsManager.getConfirmedAddrs feeds the buckets to removeNotInSource, and Addrs() subtracts the unreachable bucket via removeInSource. Unsorted input makes removeNotInSource silently drop confirmed addrs: a webrtc-direct secondary sorts before its quic-v1 primary and gets nil'd, so ConfirmedAddrs() under-reports secondary transports even though the tracker confirmed them, defeating the reachability inheritance added in #3435. removeInSource fails the other way and retains confirmed-unreachable addrs in Addrs(). Sort the three buckets before returning them.
lidel
force-pushed
the
fix/autonatv2-sorted-confirmed-addrs
branch
from
July 15, 2026 21:10
45f2acf to
42aa212
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
AutoNAT v2 keeps a list of the node's addresses that are confirmed reachable from the internet. The list is built in two parts: primary transports (tcp, quic-v1) first, then secondary ones (webrtc-direct, websocket, webtransport). Each part is sorted, but the combined list is not.
The consumer of that list,
removeNotInSource, assumes fully sorted input and silently drops entries when it is not. webrtc-direct is the common victim: on a shared UDP port its address sorts before quic-v1, so it lands out of order and gets dropped.ConfirmedAddrs()then says the node is not reachable over webrtc-direct even though AutoNAT just confirmed it was, undoing the inheritance from #3435. Kubo announces confirmed addresses to HTTP routers, so browsers never saw the webrtc-direct address (ipfs/kubo#11369) 🙈Fix