Skip to content

Commit

Permalink
ipip-388: editorial tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
lidel committed Aug 9, 2023
1 parent fc5de71 commit 0608d8f
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 23 deletions.
61 changes: 41 additions & 20 deletions src/ipips/ipip-0388.md
Original file line number Diff line number Diff line change
@@ -1,50 +1,71 @@
# IPIP-0388: Routing HTTP API Support for Querying Multiple Routers

<!-- IPIP number should match its pull request number. After you open a PR,
please update title and include an abbreviated title in the filename too:
`0000-draft-title-abbrev.md`. -->

- Start Date: 2023-03-20
- Related Issues:
---
title: "IPIP-0388: Routing V1 Support for Querying Multiple Routers"
date: 2023-03-20
ipip: proposal
editors:
- name: Adin Schmahmann
github: aschmahmann
affiliation:
name: Protocol Labs
url: https://protocol.ai/
- name: Marcin Rataj
github: lidel
url: https://lidel.org/
affiliation:
name: Protocol Labs
url: https://protocol.ai/
relatedIssues:
- https://github.com/ipfs-shipyard/someguy/issues/12
- https://github.com/ipfs-shipyard/someguy/issues/13
- https://github.com/ipfs/bifrost-gateway/issues/151
order: 388
tags: ['ipips']
---

## Summary

Adding support for querying individual routers to a single Routing v1 HTTP endpoint.
Adding opt-in support for querying individual routers to a single Routing v1 HTTP endpoint,
and discovering available routers via HTTP GET.

## Motivation

At the moment there is no way for a Routing v1 client to ask for a specific routing backend to be used nor for a Routing v1 endpoint to signal what routing backends they support. When Routing v1 is used as a proxy for one or more routing systems (e.g. IPFS Public DHT, IPNI, mainlineDHT, ...) clients may want to be able to judge a given endpoint's suitability to be a proxy for that routing system.

For instance if all-the-routers.alice.tld is very good at proxying IPNI requests but bad at proxying IPFS Public DHT requests, but dht-proxy.bob.tld is good at proxying IPFS Public DHT requests. In this scenario clients wanting good responses would have to ask both Alice and Bob to do DHT lookups for them even though Alice's DHT lookups are unneccessary because Bob is doing them. Similarly, clients could evaluate the best endpoint to request responses from since they can now do comparisons between largely equivalent routing systems. Additionally, this allows clients to discover the data sources behind Routing v1 endpoints without as much out of band information.

## Detailed design
IPFS Ecosystem is also lacking a HTTP-native way for discovering available HTTP routers.

AKA Solution Proposal
## Detailed design

The proposal is to:
1. Add a `?routing=<list-of-routers>` optional parameter to `GET /routing/v1/providers/{CID}` that indicates which routing systems to use
2. Add an `OPTIONS /routing/v1/providers` endpoint which when queried may respond with a `Ipfs-Supported-Routers` HTTP header, with the value as the comma separated list of the routing systems supported
1. Add a `?routing=<list-of-routers>` optional parameter to `GET /routing/v1/providers/{CID}` (and other lookup endpoints) that indicates which routing systems to use
2. Add an `GET /routing/v1/routers` endpoint which when queried may respond with a results that follow the `router` schema.

Details in :cite[http-routing-v1].

## Design rationale

The rationale fleshes out the specification by describing what motivated
the design and why particular design decisions were made.
We want to create opt-in way for a client to enumerate supported backends, and make a query using a specific backend.
We do not want to change any default behavior, or create yet another HTTP API only for the purpose of discovering other routers.

A real world example, cid.contact HTTP service, effectively has two backend routers: (1) IPNI and (2) [CaskaDHT](https://github.com/ipni/caskadht) proxy.
Rhea/Saturn (Lassie) queries both backends at the same time via cid.contact-specific API queries: `https://cid.contact/cid/{cid}?cascade=ipfs-dht`.

Provide evidence of rough consensus and working code within the community,
and discuss important objections or concerns raised during discussion.
This IPIP aims to make the same possible via vendor-agnostic `/routing/v1/providers/{cid}?routers=all` and create more flexible API for HTTP clients like ipfs-chromium or Brave mobile.

We allow enumeration of available router backends via plain HTTP `GET /routing/v1/routers` for better DX/UX and interop with HTTP tools.

### User benefit

End users will be able to query endpoints that provide proxies for multiple routing systems (e.g. cid.contact/routing/v1) and get back DHT, IPNI or both depending on what they need.
End users will be able to query endpoints that provide proxies for multiple routing systems (e.g. `cid.contact/routing/v1`) and get back DHT, IPNI or both depending on what they need.

For users that are running a DHT client locally they can dynamically evaluate if cid.contact's DHT proxy is either good enough that they can conserve their local resources by reducing how they use their client. Similarly, if they discover that their local DHT results are better than cid.contact's DHT proxy then they can ease the burden on cid.contact by only requesting IPNI results and doing the DHT lookups themselves.

### Compatibility

This should not effect existing clients or servers
This should not effect existing clients or servers.

The default behavior when `?routers` is not passed is left unspecified, this IPIP is limited to opt-in behavior.

### Security

Expand All @@ -55,7 +76,7 @@ Mostly not applicable. However, clients should not expect proxies to give 1:1 ma
- Having clients fetch from multiple sources which may have overlapping data -> lots of work on servers and extra processing work for clients
- Having clients fetch from a single source with the best data -> is not friendly to the introduction of new services and may result in less data being retrieved
- Having servers restrict to one endpoint per router (e.g. dht.alice.tld and ipni.alice.tld or alice.tld/dht/routing/v1 and alice.tld/ipni/routing/v1) -> also doable, but discoverability of new router types would require other semantics (e.g. an OPTIONS request to alice.tld/routing/v1)
- Having `OPTIONS` on `/routing/v1` instead of `/routing/v1/providers` -> also good, perhaps a better choice. given that not every router will support every request type there's a tradeoff around how low level you put the `OPTIONS`. In theory both could be supported.
- Having `OPTIONS` instead of `/routing/v1/routers` -> also good, but given that we ended up with more metadata per router, cramming that into HTTP headers would not be the best UX, nor it would work in web browser.
- Having `OPTIONS` on `/routing/v1/providers/{CID}` in the event the CID tells you some information about which providers to use (e.g. for non-BitTorrent codecs don't use mainline DHT) -> also doable. Unclear if this would be useful in practice since sometimes the codec information will get lost (e.g. replaced with the raw/0x55 codec).

### Copyright
Expand Down
30 changes: 27 additions & 3 deletions src/routing/http-routing-v1.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,31 @@ maturity: reliable
editors:
- name: Gus Eggert
github: guseggert
affiliation:
name: Protocol Labs
url: https://protocol.ai/
- name: Masih H. Derkani
github: masih
affiliation:
name: Protocol Labs
url: https://protocol.ai/
- name: Henrique Dias
url: https://hacdias.com/
github: hacdias
affiliation:
name: Protocol Labs
url: https://protocol.ai/
- name: Adin Schmahmann
github: aschmahmann
affiliation:
name: Protocol Labs
url: https://protocol.ai/
- name: Marcin Rataj
github: lidel
url: https://lidel.org/
affiliation:
name: Protocol Labs
url: https://protocol.ai/
xref:
- ipns-record
order: 0
Expand Down Expand Up @@ -72,7 +92,7 @@ Specifications for some transfer protocols are provided in the "Transfer Protoco

## Content Providers API

### `GET /routing/v1/providers/{cid}[?routers=rA,rB]`
### `GET /routing/v1/providers/{cid}`

#### Path Parameters

Expand Down Expand Up @@ -118,7 +138,7 @@ Each object in the `Providers` list is a *read provider record*.

## Routers API

### `GET /routing/v1/routers
### `GET /routing/v1/routers`

#### Response Status Codes

Expand All @@ -133,7 +153,6 @@ Each object in the `Providers` list is a *read provider record*.
{
"Schema": "router",
"Name": "<router_name>",
"Description": "<router_description>",
...
},
...
Expand All @@ -145,6 +164,8 @@ Response limit: 100 routers

Each `Name` can be used in explicit `?routers=name1,name2` queries.

Additional metadata per router SHOULD be included in other fields defined by `router` schema.

## IPNS API

### `GET /routing/v1/ipns/{name}`
Expand Down Expand Up @@ -255,7 +276,10 @@ This section contains a non-exhaustive list of known schemas (by name) that may
{
"Schema": "router",
"Name": "example",
"Default": false, // is it used when no ?routers is not passed
"RoutingType": ["providers", "ipns", "peers"], // where can this router be used
"Description": "A human-readable description of this router.",
"Addrs": ["/ip4/..."] // optional URLs or Multiddrs of the upstream router
}
```

Expand Down

0 comments on commit 0608d8f

Please sign in to comment.