Skip to content

fix(dht): seed routing with peer DHT port not gossip port (#1575 GAP 2)#85

Merged
MichaelTaylor3d merged 2 commits into
mainfrom
feat/1575-read-path-p2p
Jul 24, 2026
Merged

fix(dht): seed routing with peer DHT port not gossip port (#1575 GAP 2)#85
MichaelTaylor3d merged 2 commits into
mainfrom
feat/1575-read-path-p2p

Conversation

@MichaelTaylor3d

@MichaelTaylor3d MichaelTaylor3d commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

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 with received corrupt message InvalidContentTypefind_providers therefore 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 fixed GOSSIP_TO_DHT_PORT_OFFSET, applied at all three seed sites: the snapshot seed + PoolEvent::PeerAdded in spawn_dht_routing_feed, and the bootstrap_peers_from_pool seed. Once routing seeds a DIALABLE DHT contact, the existing Tier 2 read path (content_serve.rs peer_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_peer callers = only the routing feed + bootstrap (both in peer.rs); no external consumer depends on the changed addr. bootstrap_peers_from_pool stays pure. Read-path only, no custody/signing. LOW risk.

Verification

  • Regression test 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.
  • 144 peer-module tests green; fmt + clippy clean.
  • Version-increment gate: 0.56.0 -> 0.56.1.

Closes #1575 (GAP 2 scope; GAP 1 -> #1576, GAP 3 -> confirmed on the #1572 re-run).

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
MichaelTaylor3d force-pushed the feat/1575-read-path-p2p branch from 52bfd72 to 6966de4 Compare July 24, 2026 12:04
@MichaelTaylor3d MichaelTaylor3d changed the title feat(dht): read-path P2P — DHT routing port fix + read-leg findings (#1575) fix(dht): seed routing with peer DHT port not gossip port (#1575 GAP 2) Jul 24, 2026
@MichaelTaylor3d
MichaelTaylor3d marked this pull request as ready for review July 24, 2026 12:05
…x #1575)

Co-Authored-By: Claude <noreply@anthropic.com>
@MichaelTaylor3d
MichaelTaylor3d force-pushed the feat/1575-read-path-p2p branch from 6966de4 to 3cc48fe Compare July 24, 2026 12:08

@MichaelTaylor3d MichaelTaylor3d left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@MichaelTaylor3d
MichaelTaylor3d merged commit ea07c5f into main Jul 24, 2026
13 checks passed
@MichaelTaylor3d
MichaelTaylor3d deleted the feat/1575-read-path-p2p branch July 24, 2026 12:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant