fix(dht): seed routing with peer DHT port not gossip port (#1575 GAP 2)#85
Merged
Conversation
connected_pool_peers()/PoolEvents report a peer's gossip addr (9445); the DHT routing feed + bootstrap seed fed that straight into routing, so every DHT dial hit the gossip listener and died with InvalidContentType. Map the gossip addr down to the DHT/peer-RPC addr (9444) via a fixed port offset before seeding routing. Co-Authored-By: Claude <noreply@anthropic.com>
MichaelTaylor3d
force-pushed
the
feat/1575-read-path-p2p
branch
from
July 24, 2026 12:04
52bfd72 to
6966de4
Compare
MichaelTaylor3d
marked this pull request as ready for review
July 24, 2026 12:05
…x #1575) Co-Authored-By: Claude <noreply@anthropic.com>
MichaelTaylor3d
force-pushed
the
feat/1575-read-path-p2p
branch
from
July 24, 2026 12:08
6966de4 to
3cc48fe
Compare
MichaelTaylor3d
commented
Jul 24, 2026
MichaelTaylor3d
left a comment
Contributor
Author
There was a problem hiding this comment.
PASS (loop-reviewer, correctness gate).
Verified #1575 GAP 2 fix:
- Direction/magnitude correct: GOSSIP_TO_DHT_PORT_OFFSET = 9445-9444 = 1; dht_addr = gossip - offset → 9445→9444, matching the peer.rs listener split (DHT/peer-RPC on 9444, gossip on 9445).
- Applied at ALL THREE routing-seed sites: snapshot seed (peer.rs:1330), PoolEvent::PeerAdded (peer.rs:1352), bootstrap_peers_from_pool feed (peer.rs:1987). None missed. No other DHT-routing add_peer caller feeds an unmapped addr.
- Preserves IP (set_port only); handles IPv4 + IPv6 + custom base port (offset-relative, saturating_sub guards underflow).
- Regression test dht_candidate_from_pool_addr_uses_dht_port_not_gossip_port is non-vacuous — asserts 9444 (not 9445) across IPv4/IPv6/custom; fails on the old build that fed the raw gossip addr.
- v0.56.0→0.56.1 patch; Cargo.lock refreshed in the same commit; version-increment gate green.
- Gates green: Rustfmt, Clippy, Test+coverage, CodeQL, commitlint.
No custody/crypto/signing touched (read-path only); single correctness gate is the right tier. No blocking findings.
Non-gating observation (not blocking, no action needed on this PR): ports 9444/9445 are pre-existing local consts — whether they should migrate to dig-constants is a separate, out-of-scope concern for this patch.
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.
Corrects #1574's wrong-port routing bug — the resource read leg (#836) node->node unblock. Version 0.56.1 (PATCH — fix, not feat). GAP 1 (whole-capsule reshare) deferred to #1576; GAP 3 accepted as already-covered.
The bug
connected_pool_peers()/PoolEvents report a peer's GOSSIP addr (9445). #1574's live routing feed + the bootstrap seed fed that straight into the DHT routing table, so every DHT dial hit the peer's GOSSIP listener and died withreceived corrupt message InvalidContentType—find_providerstherefore routed to nobody and every read fell back to RPC/upstream ("zero dht/download trace on a read" in the #1062/#1572 e2e). #1574 was necessary but wired the wrong port.The fix
dht_addr_from_gossip_addr()maps the gossip addr down to the DHT/peer-RPC addr (9444) via the fixedGOSSIP_TO_DHT_PORT_OFFSET, applied at all three seed sites: the snapshot seed +PoolEvent::PeerAddedinspawn_dht_routing_feed, and thebootstrap_peers_from_poolseed. Once routing seeds a DIALABLE DHT contact, the existing Tier 2 read path (content_serve.rspeer_serve_plaintext->fetch_resource-> locate_providers ->dig.fetchRange-> merkle-verify -> serve) moves content node->node — the #836 resource read leg.Blast radius (socraticode + read)
crate::dht::add_peercallers = only the routing feed + bootstrap (both inpeer.rs); no external consumer depends on the changed addr.bootstrap_peers_from_poolstays pure. Read-path only, no custody/signing. LOW risk.Verification
dht_candidate_from_pool_addr_uses_dht_port_not_gossip_port(9445->9444, IPv4 + IPv6 + custom-port via the offset) — FAILS on the old build.Closes #1575 (GAP 2 scope; GAP 1 -> #1576, GAP 3 -> confirmed on the #1572 re-run).