From 0608d8ff0222ec7bbf6baa39c85b1939cb9a83f1 Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Wed, 9 Aug 2023 18:25:12 +0200 Subject: [PATCH] ipip-388: editorial tweaks --- src/ipips/ipip-0388.md | 61 +++++++++++++++++++++++----------- src/routing/http-routing-v1.md | 30 +++++++++++++++-- 2 files changed, 68 insertions(+), 23 deletions(-) diff --git a/src/ipips/ipip-0388.md b/src/ipips/ipip-0388.md index 06699d295..a4fb2a687 100644 --- a/src/ipips/ipip-0388.md +++ b/src/ipips/ipip-0388.md @@ -1,18 +1,31 @@ -# IPIP-0388: Routing HTTP API Support for Querying Multiple Routers - - - -- 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 @@ -20,31 +33,39 @@ At the moment there is no way for a Routing v1 client to ask for a specific rout 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=` 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=` 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 @@ -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 diff --git a/src/routing/http-routing-v1.md b/src/routing/http-routing-v1.md index b39ed88db..0e4fbb29f 100644 --- a/src/routing/http-routing-v1.md +++ b/src/routing/http-routing-v1.md @@ -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 @@ -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 @@ -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 @@ -133,7 +153,6 @@ Each object in the `Providers` list is a *read provider record*. { "Schema": "router", "Name": "", - "Description": "", ... }, ... @@ -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}` @@ -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 } ```