Skip to content

Commit 463591e

Browse files
committed
docs(routing): align IPIP-476 with someguy v0.11.0 implementation
Final ratification cleanup aligning specs with actual shipped implementation. Changes to IPIP-0476: - change path parameter from {peer-id} to {key} - remove unimplemented query parameters (count, closer-than) - document query parameters in Alternatives section with rationale - add peer sorting requirement (XOR distance for Kademlia DHTs) - update test fixtures to reflect actual API surface - note about raw codec for arbitrary multihash lookups - update date to 2025-11-20 Changes to http-routing-v1.md: - add raw codec documentation for arbitrary multihash lookups - clarify peer sorting requirement (SHOULD, XOR distance) - fix streaming description (remove "more results" language) - add note about streaming being blocked until DHT lookup completes - reorganize frontmatter: move inactive editors to former_editors - add contributors to thanks section - update date to 2025-11-20 Both specs now accurately reflect the API shipped in: - boxo v0.35.2 (ipfs/boxo#1021) - someguy v0.11.0 (https://github.com/ipfs/someguy/releases/tag/v0.11.0)
1 parent cc70f9b commit 463591e

File tree

2 files changed

+54
-31
lines changed

2 files changed

+54
-31
lines changed

src/ipips/ipip-0476.md

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: "IPIP-0476: Delegated Routing DHT Closest Peers API"
3-
date: 2025-08-19
3+
date: 2025-11-20
44
ipip: proposal
55
editors:
66
- name: Alex Potsides
@@ -42,19 +42,14 @@ This is particularly problematic for:
4242

4343
This IPIP introduces a new "DHT Routing API" section to the Delegated Routing V1 HTTP API specification with the following endpoint:
4444

45-
### `GET /routing/v1/dht/closest/peers/{peer-id}`
45+
### `GET /routing/v1/dht/closest/peers/{key}`
4646

4747
#### Path Parameters
4848

49-
- `peer-id`: The target peer ID to find closest peers for, represented as a CIDv1 encoded with `libp2p-key` codec
50-
51-
#### Query Parameters
52-
53-
- `closer-than` (optional): A peer ID represented as a CIDv1 encoded with `libp2p-key` codec
54-
- Returned peer records must be closer to `peer-id` than `closer-than`
55-
- If omitted, the routing implementation should use its own peer ID
56-
- `count` (optional): Number of peer records to return
57-
- Minimum 1, maximum 100, default 20
49+
- `key` is a [CID](https://github.com/multiformats/cid) or Peer ID to find the closest peers to.
50+
- CID SHOULD be a CIDv1 in any encoding.
51+
- Peer ID can be represented as a Multihash in Base58btc, or a CIDv1 with `libp2p-key` (`0x72`) codec in Base36 or Base32.
52+
- Arbitrary multihash lookups can be performed by wrapping the multihash in a CIDv1 with `raw` (`0x55`) codec.
5853

5954
#### Response
6055

@@ -65,7 +60,7 @@ The response follows the same format as the existing peer routing endpoints, ret
6560
The following changes are made to `src/routing/http-routing-v1.md`:
6661

6762
1. Add a new "## DHT Routing API" section after the "Peer Routing API" section
68-
2. Document the `/routing/v1/dht/closest/peers/{peer-id}` endpoint with its parameters and response format
63+
2. Document the `/routing/v1/dht/closest/peers/{key}` endpoint with its parameters and response format
6964
3. Update the document date to reflect the modification
7065

7166
## Design rationale
@@ -78,7 +73,7 @@ The endpoint provides the minimum viable functionality needed for the primary us
7873

7974
### Future-Proofed Path Structure
8075

81-
The path `/routing/v1/dht/closest/peers/{peer-id}` is intentionally structured to allow future expansion:
76+
The path `/routing/v1/dht/closest/peers/{key}` is intentionally structured to allow future expansion:
8277
- The `/dht/` segment clearly indicates DHT-specific operations
8378
- The `/closest/peers/` structure allows for potential future endpoints like `/closest/keys/` for keyspace queries
8479
- This organization keeps the API logical and extensible
@@ -131,14 +126,25 @@ Several alternatives were considered:
131126

132127
4. **Amino-Specific Endpoint**: Initially considered `/routing/v1/amino/` namespace but rejected in favor of the more generic `/dht/` approach
133128

129+
5. **Query Parameters for Filtering and Limiting**: During design discussions, `count` and `closer-than` query parameters were considered:
130+
- `count`: limit the number of results returned
131+
- `closer-than`: filter peers to only return those closer than a reference peer
132+
133+
These were omitted from the initial implementation (boxo v0.35.2, someguy v0.11.0) for simplicity. The endpoint defaults to returning up to the DHT bucket size (20 for Amino DHT). Future backwards-compatible updates MAY add these parameters if use cases emerge that require more fine-grained control.
134+
135+
### Peer Ordering
136+
137+
Implementations SHOULD return peers sorted by closeness to the key. For Kademlia-based DHT implementations (such as Amino DHT), this means sorting by XOR distance with the closest peers first.
138+
134139
## Test fixtures
135140

136141
This IPIP does not deal with content-addressed data, so specific test CIDs are not applicable. However, implementations should test:
137142

138-
1. Valid peer ID inputs return appropriate closest peers
139-
2. The `closerThan` parameter correctly filters results
140-
3. The `count` parameter limits results as specified
141-
4. Invalid peer IDs return appropriate error responses
143+
1. Valid CID and Peer ID inputs return appropriate closest peers
144+
2. Results are limited to the DHT bucket size
145+
3. Peers are sorted by closeness (XOR distance for Kademlia DHTs)
146+
4. Invalid keys return appropriate error responses
147+
5. Both streaming (NDJSON) and non-streaming (JSON) response formats work correctly
142148

143149
### Copyright
144150

src/routing/http-routing-v1.md

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,28 @@ description: >
44
Delegated routing is a mechanism for IPFS implementations to use for offloading
55
content routing, peer routing and naming to another process/server. This specification describes
66
an HTTP API for delegated routing of content, peers, and IPNS.
7-
date: 2025-08-19
7+
date: 2025-11-20
88
maturity: reliable
99
editors:
10+
- name: Marcin Rataj
11+
github: lidel
12+
url: https://lidel.org/
13+
affiliation:
14+
name: Shipyard
15+
url: https://ipshipyard.com
16+
former_editors:
17+
- name: Henrique Dias
18+
url: https://hacdias.com/
19+
github: hacdias
20+
affiliation:
21+
name: Shipyard
22+
url: https://ipshipyard.com
23+
- name: Daniel Norman
24+
github: 2color
25+
affiliation:
26+
name: Shipyard
27+
url: https://ipshipyard.com
28+
thanks:
1029
- name: Gus Eggert
1130
github: guseggert
1231
affiliation:
@@ -17,20 +36,15 @@ editors:
1736
affiliation:
1837
name: Protocol Labs
1938
url: https://protocol.ai/
20-
- name: Henrique Dias
21-
url: https://hacdias.com/
22-
github: hacdias
39+
- name: Alex Potsides
40+
github: achingbrain
2341
affiliation:
2442
name: Shipyard
2543
url: https://ipshipyard.com
26-
- name: Marcin Rataj
27-
github: lidel
28-
url: https://lidel.org/
29-
affiliation:
30-
name: Shipyard
31-
url: https://ipshipyard.com
32-
- name: Daniel Norman
33-
github: 2color
44+
- name: Will Scott
45+
github: willscott
46+
- name: Hector Sanjuan
47+
github: hsanjuan
3448
affiliation:
3549
name: Shipyard
3650
url: https://ipshipyard.com
@@ -254,8 +268,9 @@ This optional endpoint allows light clients to lower the cost of DHT walks in br
254268
#### Path Parameters
255269

256270
- `key` is a [CID] or [Peer ID][peer-id-representation] to find the closest peers to.
257-
- [CID] should be a CIDv1 in any encoding.
271+
- [CID] SHOULD be a CIDv1 in any encoding.
258272
- [Peer ID][peer-id-representation] can be represented as a Multihash in Base58btc, or a CIDv1 with `libp2p-key` (`0x72`) codec in Base36 or Base32.
273+
- Arbitrary multihash lookups can be performed by wrapping the multihash in a CIDv1 with `raw` (`0x55`) codec.
259274
- Implementations SHOULD support both CID and Peer ID formats for maximum interoperability.
260275

261276
#### Response Status Codes
@@ -294,7 +309,9 @@ This optional endpoint allows light clients to lower the cost of DHT walks in br
294309

295310
The number of peer records in the response SHOULD be limited to the DHT bucket size (20 for Amino DHT).
296311

297-
The client SHOULD be able to make a request with `Accept: application/x-ndjson` and get a [stream](#streaming) with more results.
312+
Peers SHOULD be returned sorted by closeness to the key. For Kademlia-based DHT implementations (such as Amino DHT), this means sorting by XOR distance with the closest peers first.
313+
314+
The client SHOULD be able to make a request with `Accept: application/x-ndjson` and get a [stream](#streaming) with results. Note that due to the XOR sorting requirement, the streamed response may be blocked until the DHT lookup completes and peers can be sorted before transmission.
298315

299316
Each object in the `Peers` list is a record conforming to the [Peer Schema](#peer-schema).
300317

0 commit comments

Comments
 (0)