Skip to content

feat: add Kademlia DHT high-level API and interop test node - #264

Merged
seetadev merged 2 commits into
mainfrom
feat/kad-dht-interop-node
Aug 14, 2026
Merged

feat: add Kademlia DHT high-level API and interop test node#264
seetadev merged 2 commits into
mainfrom
feat/kad-dht-interop-node

Conversation

@adust09

@adust09 adust09 commented Aug 13, 2026

Copy link
Copy Markdown
Owner

Summary

High-level Kademlia DHT API (LibP2P.DHT.API) plus a three-role interop test binary (libp2p-kad-dht-node) that implements the libp2p/unified-testing kad-dht contract.

New modules

  • LibP2P.DHT.APIprovide, putValue, findProviders operations built on existing iterativeFindNode, dhtSendRequest, and record store primitives
  • LibP2P.DHT.APISpec — 5 unit tests with mock DHT nodes (all pass)

Interop binary (interop/kad-dht-node/)

Three roles matching the unified-testing kad-dht test app contract:

  • bootstrap — listens, publishes address to Redis, runs DHT server
  • provider — dials bootstrap, calls provide + putValue, signals done via Redis
  • querier — dials bootstrap, queries findProviders + iterativeGetValue, prints status pass/fail

Coordination uses Redis SET/GET (matching the Python reference), with {TEST_KEY}_bootstrap_addr and {TEST_KEY}_provider_done keys.

Docker / CI

  • interop/kad-dht-node/Dockerfile — multi-stage build (GHC 9.10 to debian-slim, ~10MB)
  • docker-compose.kad-dht.yml — self-test compose (redis + bootstrap + provider + querier)
  • .github/workflows/interop.yml — new kad-dht-interop job
  • interop/Makefilekad-dht target

Housekeeping

Test results

1134 examples, 0 failures

Ref: unified-testing PR #119 (nim precedent for this pattern)

Checklist

  • Compiles (library + both executables)
  • All 1134 tests pass (1129 existing + 5 new)
  • API test suite covers provide, putValue, findProviders
  • Dockerfile builds clean
  • CI job defined for self-test (bootstrap -> provider -> querier)

Implement LibP2P.DHT.API (provide, putValue, findProviders) and a
kad-dht interop test binary with three roles (bootstrap, provider,
querier) following the libp2p/unified-testing kad-dht contract.

- LibP2P.DHT.API: high-level DHT operations on top of existing primitives
- interop/kad-dht-node/Main.hs: 3-role test binary (Redis coordination)
- interop/kad-dht-node/Dockerfile: multi-stage build (GHC 9.10 -> ~10MB)
- docker-compose.kad-dht.yml: self-test compose (bootstrap+provider+querier)
- .github/workflows/interop.yml: kad-dht-interop CI job
- test/LibP2P.DHT.APISpec: 5 API tests (all pass, 1134 total, 0 failures)
- Relocate transport interop to interop/transport/ for clarity
- Port transport interop to RPUSH/BLPOP Redis list contract (#263)
@seetadev

Copy link
Copy Markdown
Collaborator

@adust09 : Thanks Shouki, this is a really great addition to libp2p-hs and to the broader libp2p ecosystem.

I reviewed the PR and the overall approach looks solid. In particular, it’s great to see the high-level Kademlia API built cleanly on top of the existing DHT primitives, with coverage for provide, putValue, and findProviders. The dedicated API tests are a strong addition as well.

The three-role interop test node is especially valuable. Following the unified-testing Kademlia contract with bootstrap, provider, and querier roles gives us a clear path toward exercising Haskell interoperability against the other libp2p implementations. I also appreciate the Redis coordination matching the established interop patterns, along with the dedicated Docker/CI setup.

The routing-table bootstrap fix and the transport interop housekeeping also make this feel like a well-rounded change rather than just adding the API surface. 1134 tests passing with 0 failures and all CI checks green is excellent.

From the libp2p maintainer side, LGTM! 👍 Thanks for the thorough implementation and for continuing to move libp2p-hs forward with proper interoperability and conformance testing. Happy to see this merged.

@seetadev
seetadev merged commit 3c7ddd2 into main Aug 14, 2026
3 checks passed
@seetadev
seetadev deleted the feat/kad-dht-interop-node branch August 14, 2026 07:11
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.

2 participants