diff --git a/docs/delegated-routing.md b/docs/delegated-routing.md index f4207f409e4..6f15972ed27 100644 --- a/docs/delegated-routing.md +++ b/docs/delegated-routing.md @@ -11,8 +11,8 @@ Previously we only used the Amino DHT for content routing and content providing. -Kubo 0.14 introduced experimental support for [delegated routing using Reframe protocol](https://github.com/ipfs/kubo/pull/8997). -Since then, Reframe got deprecated and superseded by [Routing V1 HTTP API](https://specs.ipfs.tech/routing/http-routing-v1/). +Kubo 0.14 introduced experimental support for [delegated routing](https://github.com/ipfs/kubo/pull/8997), +which then got changed and standardized as [Routing V1 HTTP API](https://specs.ipfs.tech/routing/http-routing-v1/). Kubo 0.23.0 release added support for [self-hosting Routing V1 HTTP API server](https://github.com/ipfs/kubo/blob/master/docs/changelogs/v0.23.md#self-hosting-routingv1-endpoint-for-delegated-routing-needs). @@ -42,15 +42,15 @@ The `Routing` configuration section will contain the following keys: #### Routers -`Routers` will be a key-value list of routers that will be available to use. The key is the router name and the value is all the needed configurations for that router. the `Type` will define the routing kind. The main router types will be `reframe` and `dht`, but we will implement two special routers used to execute a set of routers in parallel or sequentially: `parallel` router and `sequential` router. +`Routers` will be a key-value list of routers that will be available to use. The key is the router name and the value is all the needed configurations for that router. the `Type` will define the routing kind. The main router types will be `http` and `dht`, but we will implement two special routers used to execute a set of routers in parallel or sequentially: `parallel` router and `sequential` router. Depending on the routing type, it will use different parameters: -##### Reframe +##### HTTP Params: -- `"Endpoint"`: URL endpoint implementing Reframe protocol. +- `"Endpoint"`: URL of HTTP server with endpoints that implement [Delegated Routing V1 HTTP API](https://specs.ipfs.tech/routing/http-routing-v1/) protocol. ##### Amino DHT @@ -89,10 +89,10 @@ The value will contain: "Routing": { "Type": "custom", "Routers": { - "storetheindex": { - "Type": "reframe", + "http-delegated": { + "Type": "http", "Parameters": { - "Endpoint": "https://cid.contact/reframe" + "Endpoint": "https://delegated-ipfs.dev" // /routing/v1 (https://specs.ipfs.tech/routing/http-routing-v1/) } }, "dht-lan": { @@ -123,7 +123,7 @@ The value will contain: "RouterName": "dht-wan" }, { - "RouterName": "storetheindex" + "RouterName": "http-delegated" } ] } @@ -142,7 +142,7 @@ The value will contain: "Timeout": "100ms" }, { - "RouterName": "storetheindex", + "RouterName": "http-delegated", "ExecuteAfter": "100ms" } ] @@ -161,7 +161,7 @@ The value will contain: "Timeout": "300ms" }, { - "RouterName": "storetheindex", + "RouterName": "http-delegated", "Timeout": "300ms" } ] @@ -178,7 +178,7 @@ The value will contain: "RouterName": "dht-wan" }, { - "RouterName": "storetheindex" + "RouterName": "http-delegated" } ] } @@ -201,75 +201,6 @@ The value will contain: } ``` -Added YAML for clarity: - -```yaml ---- -Type: custom -Routers: - storetheindex: - Type: reframe - Parameters: - Endpoint: https://cid.contact/reframe - dht-lan: - Type: dht - Parameters: - Mode: server - PublicIPNetwork: false - AcceleratedDHTClient: false - dht-wan: - Type: dht - Parameters: - Mode: auto - PublicIPNetwork: true - AcceleratedDHTClient: false - find-providers-router: - Type: parallel - Parameters: - Routers: - - RouterName: dht-lan - IgnoreErrors: true - - RouterName: dht-wan - - RouterName: storetheindex - provide-router: - Type: parallel - Parameters: - Routers: - - RouterName: dht-lan - IgnoreErrors: true - - RouterName: dht-wan - ExecuteAfter: 100ms - Timeout: 100ms - - RouterName: storetheindex - ExecuteAfter: 100ms - get-ipns-router: - Type: sequential - Parameters: - Routers: - - RouterName: dht-lan - IgnoreErrors: true - - RouterName: dht-wan - Timeout: 300ms - - RouterName: storetheindex - Timeout: 300ms - put-ipns-router: - Type: parallel - Parameters: - Routers: - - RouterName: dht-lan - - RouterName: dht-wan - - RouterName: storetheindex -Methods: - find-providers: - RouterName: find-providers-router - provide: - RouterName: provide-router - get-ipns: - RouterName: get-ipns-router - put-ipns: - RouterName: put-ipns-router -``` - ### Error cases - If any of the routers fails, the output will be an error by default. - You can use `IgnoreErrors:true` to ignore errors for a specific router output @@ -402,48 +333,6 @@ As test fixtures we can add different use cases here and see how the configurati } } ``` -YAML representation for clarity: - -```yaml ---- -Type: custom -Routers: - dht-lan: - Type: dht - Parameters: - Mode: server - PublicIPNetwork: false - dht-wan: - Type: dht - Parameters: - Mode: auto - PublicIPNetwork: true - parallel-dht-strict: - Type: parallel - Parameters: - Routers: - - RouterName: dht-lan - - RouterName: dht-wan - parallel-dht: - Type: parallel - Parameters: - Routers: - - RouterName: dht-lan - IgnoreError: true - - RouterName: dht-wan -Methods: - provide: - RouterName: dht-wan - find-providers: - RouterName: parallel-dht-strict - find-peers: - RouterName: parallel-dht-strict - get-ipns: - RouterName: parallel-dht - put-ipns: - RouterName: parallel-dht - -``` ### Compatibility diff --git a/test/sharness/t0701-delegated-routing-reframe.sh b/test/sharness/t0701-delegated-routing-reframe.sh deleted file mode 100755 index 5070b4fff16..00000000000 --- a/test/sharness/t0701-delegated-routing-reframe.sh +++ /dev/null @@ -1,171 +0,0 @@ -#!/usr/bin/env bash - -test_description="Test delegated routing via reframe endpoint" - -. lib/test-lib.sh - -if ! test_have_prereq SOCAT; then - skip_all="skipping '$test_description': socat is not available" - test_done -fi - -# simple reframe server mock -# local endpoint responds with deterministic application/vnd.ipfs.rpc+dag-json; version=1 -REFRAME_PORT=5098 -function start_reframe_mock_endpoint() { - REMOTE_SERVER_LOG="reframe-server.log" - rm -f $REMOTE_SERVER_LOG - - touch response - socat tcp-listen:$REFRAME_PORT,fork,bind=127.0.0.1,reuseaddr 'SYSTEM:cat response'!!CREATE:$REMOTE_SERVER_LOG & - REMOTE_SERVER_PID=$! - - socat /dev/null tcp:127.0.0.1:$REFRAME_PORT,retry=10 - return $? -} -function serve_reframe_response() { - local body=$1 - local status_code=${2:-"200 OK"} - local length=$((1 + ${#body})) - echo -e "HTTP/1.1 $status_code\nContent-Type: application/vnd.ipfs.rpc+dag-json; version=1\nContent-Length: $length\n\n$body" > response -} -function stop_reframe_mock_endpoint() { - exec 7<&- - kill $REMOTE_SERVER_PID > /dev/null 2>&1 - wait $REMOTE_SERVER_PID || true -} - -# daemon running in online mode to ensure Pin.origins/PinStatus.delegates work -test_init_ipfs - -# based on static, synthetic reframe messages: -# t0701-delegated-routing-reframe/FindProvidersRequest -# t0701-delegated-routing-reframe/FindProvidersResponse -FINDPROV_CID="bafybeigvgzoolc3drupxhlevdp2ugqcrbcsqfmcek2zxiw5wctk3xjpjwy" -EXPECTED_PROV="QmQzqxhK82kAmKvARFZSkUVS6fo9sySaiogAnx5EnZ6ZmC" - -test_expect_success "default Routing config has no Routers defined" ' - echo null > expected && - ipfs config show | jq .Routing.Routers > actual && - test_cmp expected actual -' - -# turn off all implicit routers -ipfs config Routing.Type none || exit 1 -test_launch_ipfs_daemon -test_expect_success "disabling default router (dht) works" ' - ipfs config Routing.Type > actual && - echo none > expected && - test_cmp expected actual -' -test_expect_success "no routers means findprovs returns no results" ' - ipfs routing findprovs "$FINDPROV_CID" > actual && - echo -n > expected && - test_cmp expected actual -' - -test_kill_ipfs_daemon - -ipfs config Routing.Type --json '"custom"' || exit 1 -ipfs config Routing.Methods --json '{ - "find-peers": { - "RouterName": "TestDelegatedRouter" - }, - "find-providers": { - "RouterName": "TestDelegatedRouter" - }, - "get-ipns": { - "RouterName": "TestDelegatedRouter" - }, - "provide": { - "RouterName": "TestDelegatedRouter" - } - }' || exit 1 - -test_expect_success "missing method params makes daemon fails" ' - echo "Error: constructing the node (see log for full detail): method name \"put-ipns\" is missing from Routing.Methods config param" > expected_error && - GOLOG_LOG_LEVEL=fatal ipfs daemon 2> actual_error || exit 0 && - test_cmp expected_error actual_error -' - -ipfs config Routing.Methods --json '{ - "find-peers": { - "RouterName": "TestDelegatedRouter" - }, - "find-providers": { - "RouterName": "TestDelegatedRouter" - }, - "get-ipns": { - "RouterName": "TestDelegatedRouter" - }, - "provide": { - "RouterName": "TestDelegatedRouter" - }, - "put-ipns": { - "RouterName": "TestDelegatedRouter" - }, - "NOT_SUPPORTED": { - "RouterName": "TestDelegatedRouter" - } - }' || exit 1 - -test_expect_success "having wrong methods makes daemon fails" ' - echo "Error: constructing the node (see log for full detail): method name \"NOT_SUPPORTED\" is not a supported method on Routing.Methods config param" > expected_error && - GOLOG_LOG_LEVEL=fatal ipfs daemon 2> actual_error || exit 0 && - test_cmp expected_error actual_error -' - -# set Routing config to only use delegated routing via mocked reframe endpoint - -ipfs config Routing.Type --json '"custom"' || exit 1 -ipfs config Routing.Routers.TestDelegatedRouter --json '{ - "Type": "reframe", - "Parameters": { - "Endpoint": "http://127.0.0.1:5098/reframe" - } -}' || exit 1 -ipfs config Routing.Methods --json '{ - "find-peers": { - "RouterName": "TestDelegatedRouter" - }, - "find-providers": { - "RouterName": "TestDelegatedRouter" - }, - "get-ipns": { - "RouterName": "TestDelegatedRouter" - }, - "provide": { - "RouterName": "TestDelegatedRouter" - }, - "put-ipns": { - "RouterName": "TestDelegatedRouter" - } - }' || exit 1 - -test_expect_success "adding reframe endpoint to Routing.Routers config works" ' - echo "http://127.0.0.1:5098/reframe" > expected && - ipfs config Routing.Routers.TestDelegatedRouter.Parameters.Endpoint > actual && - test_cmp expected actual -' - -test_launch_ipfs_daemon - -test_expect_success "start_reframe_mock_endpoint" ' - start_reframe_mock_endpoint -' - -test_expect_success "'ipfs routing findprovs' returns result from delegated reframe router" ' - serve_reframe_response "$(<../t0701-delegated-routing-reframe/FindProvidersResponse)" && - echo "$EXPECTED_PROV" > expected && - ipfs routing findprovs "$FINDPROV_CID" > actual && - test_cmp expected actual -' - -test_expect_success "stop_reframe_mock_endpoint" ' - stop_reframe_mock_endpoint -' - - -test_kill_ipfs_daemon -test_done -# vim: ts=2 sw=2 sts=2 et: