feat: add Kademlia DHT high-level API and interop test node - #264
Conversation
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)
|
@adust09 : Thanks Shouki, this is a really great addition to 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 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 |
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.API—provide,putValue,findProvidersoperations built on existingiterativeFindNode,dhtSendRequest, and record store primitivesLibP2P.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 serverprovider— dials bootstrap, callsprovide+putValue, signals done via Redisquerier— dials bootstrap, queriesfindProviders+iterativeGetValue, prints status pass/failCoordination uses Redis SET/GET (matching the Python reference), with
{TEST_KEY}_bootstrap_addrand{TEST_KEY}_provider_donekeys.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— newkad-dht-interopjobinterop/Makefile—kad-dhttargetHousekeeping
interop/tointerop/transport/Test results
1134 examples, 0 failures
Ref: unified-testing PR #119 (nim precedent for this pattern)
Checklist
provide,putValue,findProviders