net: capture peer addrMe votes via AddLocal(LOCAL_PEER) instead of SeenLocal #7
Labels
No labels
enhancement
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
SubGeniusFinance/Offerings-to-Cthulhu#7
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
At
src/main.cpp:3895-3898, every inbound peer'saddrMevote — i.e., "this is the address I see you coming from" — is fed toSeenLocal(addrMe):But
SeenLocalatsrc/net.cpp:271-283is only an increment:If no static /
LOCAL_BIND/LOCAL_IF/LOCAL_UPNP/LOCAL_HTTPentry already exists for that address, the peer's vote is silently thrown away. Peer agreement — which is the single most reliable signal of what our actual external address is — never gets a chance to seedmapLocalHost.The change
Three lines.
LOCAL_PEERscore tier insrc/net.h, slotted betweenLOCAL_BINDandLOCAL_MANUAL(mirroring upstream bitcoin/bitcoin#7028):SeenLocal→AddLocalatsrc/main.cpp:3898:That's it. Existing
AddLocal(src/net.cpp:216-243) already does the right thing: refuses non-routable / limited, creates if absent, increments score if present, callsAdvertizeLocal().Why this is strictly an improvement
LOCAL_IF,LOCAL_BINDall keep doing what they do.addrMeaccumulatesLOCAL_PEERscore and competes naturally with other sources.LOCAL_BINDor-externalip=config still wins; peer votes are a fallback, not an override.LOCAL_PEERentry, but honest peers' competing votes create their own entries with their own score, andLOCAL_BIND/LOCAL_MANUALalways beatLOCAL_PEER.Files touched
src/net.h— addLOCAL_PEERenum valuesrc/main.cpp— one-line swap at line 3898Trade-offs / risks
-externalip=explicitly. The cluster's external-IP discovery is already handled outside this code path. So this change is a hygiene fix benefiting third-party operators, not us.-debug=netlogs: an extraAddLocal(%s, 3)line per first-time inbound peer at startup. Cosmetic.pfrom->fInboundguard at line 3895 means only inbound peers feedaddrMe. A node behind NAT with no port-forwarding still learns nothing. Accepted — such a node is unreachable anyway, no useful address to advertise.Relation to issue #5
Issue #5 proposed the same swap plus deleting the HTTP path (
GetMyExternalIP/GetMyExternalIP2/ThreadGetMyExternalIP). Splitting that into two issues:Land this first, sit on the deletion in #5 until we've actually seen peer-vote scores accumulate on a real node in
-debug=netlogs.References
Closing as substantively obviated by PR #9 (merge commit
24196aa), with an architectural caveat worth recording.PR #9 ported gmaxwell's 2014 design (bitcoin/bitcoin#5161), not Wuille's 2016 design (bitcoin/bitcoin#7028) that this issue cites. The difference:
mapLocalHostwith newLOCAL_PEERtieraddrMestored per-CNode inpfrom->addrLocalGetLocalAddress()for all peersIsPeerAddrLocalGood()LOCAL_PEERenum valueLOCAL_HTTP)For the OFF cluster (which uses
-externalip=everywhere) the two designs are functionally equivalent. The one residual benefit of layering this issue'sLOCAL_PEERaggregation on top of PR #9 is for a fresh outbound-only NAT'd node that wants to learn its IP from one peer and advertise it to a different peer. The gmaxwell-2014 approach in PR #9 only ever advertises a peer-told IP back to the same peer who told us.Closing because:
mapLocalHost") is moot — peer agreement no longer needs to seedmapLocalHost, because the per-peeraddrLocalis consulted directly inAdvertizeLocal().Thanks @9019x for the broader fix that made this unnecessary.