diff --git a/.github/workflows/gateway-conformance.yml b/.github/workflows/gateway-conformance.yml index fae26d4..33df29e 100644 --- a/.github/workflows/gateway-conformance.yml +++ b/.github/workflows/gateway-conformance.yml @@ -18,7 +18,7 @@ concurrency: cancel-in-progress: true jobs: - tests: + test: runs-on: ubuntu-latest strategy: matrix: @@ -102,6 +102,7 @@ jobs: env: RAINBOW_REMOTE_BACKENDS: http://127.0.0.1:8080 RAINBOW_REMOTE_BACKENDS_MODE: block + RAINBOW_REMOTE_BACKENDS_IPNS: true RAINBOW_LIBP2P: false RAINBOW_BITSWAP: false RAINBOW_DHT_ROUTING: off @@ -116,6 +117,7 @@ jobs: env: RAINBOW_REMOTE_BACKENDS: http://127.0.0.1:8080 RAINBOW_REMOTE_BACKENDS_MODE: car + RAINBOW_REMOTE_BACKENDS_IPNS: true RAINBOW_LIBP2P: false RAINBOW_BITSWAP: false RAINBOW_DHT_ROUTING: off diff --git a/docs/environment-variables.md b/docs/environment-variables.md index ec8a9b8..977bad5 100644 --- a/docs/environment-variables.md +++ b/docs/environment-variables.md @@ -6,15 +6,22 @@ - [`RAINBOW_GATEWAY_DOMAINS`](#rainbow_gateway_domains) - [`RAINBOW_SUBDOMAIN_GATEWAY_DOMAINS`](#rainbow_subdomain_gateway_domains) - [`RAINBOW_TRUSTLESS_GATEWAY_DOMAINS`](#rainbow_trustless_gateway_domains) + - [`RAINBOW_DATADIR`](#rainbow_datadir) - [`RAINBOW_GC_INTERVAL`](#rainbow_gc_interval) - [`RAINBOW_GC_THRESHOLD`](#rainbow_gc_threshold) - [`RAINBOW_IPNS_MAX_CACHE_TTL`](#rainbow_ipns_max_cache_ttl) - [`RAINBOW_PEERING`](#rainbow_peering) - [`RAINBOW_SEED`](#rainbow_seed) - [`RAINBOW_SEED_INDEX`](#rainbow_seed_index) + - [`RAINBOW_DHT_ROUTING`](#rainbow_dht_routing) + - [`RAINBOW_HTTP_ROUTERS`](#rainbow_http_routers) +- [Experiments](#experiments) - [`RAINBOW_SEED_PEERING`](#rainbow_seed_peering) - [`RAINBOW_SEED_PEERING_MAX_INDEX`](#rainbow_seed_peering_max_index) - [`RAINBOW_PEERING_SHARED_CACHE`](#rainbow_peering_shared_cache) + - [`RAINBOW_REMOTE_BACKENDS`](#rainbow_remote_backends) + - [`RAINBOW_REMOTE_BACKENDS_MODE`](#rainbow_remote_backends_mode) + - [`RAINBOW_REMOTE_BACKENDS_IPNS`](#rainbow_remote_backends_ipns) - [Logging](#logging) - [`GOLOG_LOG_LEVEL`](#golog_log_level) - [`GOLOG_LOG_FMT`](#golog_log_fmt) @@ -69,6 +76,12 @@ when request comes with the `Host` header set to `trustless-gateway.link`. Default: none (`Host` is ignored and gateway at `127.0.0.1` supports both deserialized and verifiable response types) +### `RAINBOW_DATADIR` + +Directory for persistent data (keys, blocks, denylists) + +Default: not set (uses the current directory) + ### `RAINBOW_GC_INTERVAL` The interval at which the garbage collector will be called. This is given as a string that corresponds to the duration of the interval. Set 0 to disable. @@ -121,6 +134,20 @@ Index to derivate the PeerID identity from `RAINBOW_SEED`. Default: not set +### `RAINBOW_DHT_ROUTING` + +Control the type of Amino DHT client used for for routing. Options are `accelerated`, `standard` and `off`. + +Default: `accelerated` + +### `RAINBOW_HTTP_ROUTERS` + +HTTP servers with /routing/v1 endpoints to use for delegated routing (comma-separated). + +Default: `https://cid.contact` + +## Experiments + ### `RAINBOW_SEED_PEERING` > [!WARNING] @@ -162,16 +189,10 @@ queries from these safelisted peers, serving locally cached blocks if requested. Default: `false` (no cache sharing) -### `RAINBOW_DHT_ROUTING` - -Control the type of Amino DHT client used for for routing. Options are `accelerated`, `standard` and `off`. - -Default: `accelerated` - ### `RAINBOW_REMOTE_BACKENDS` > [!WARNING] -> Experimental feature. Requires setting `RAINBOW_DHT_ROUTING=off` and `RAINBOW_BITSWAP=false`. +> Experimental feature, forces setting `RAINBOW_LIBP2P=false`. URL(s) of of remote [trustless gateways](https://docs.ipfs.tech/reference/http/gateway/#trustless-verifiable-retrieval) to use as backend instead of libp2p node with Bitswap. @@ -189,6 +210,13 @@ Controls how requests to remote backend are made. Default: `block` +### `RAINBOW_REMOTE_BACKENDS_IPNS` + +Controls whether to fetch IPNS Records ([`application/vnd.ipfs.ipns-record`](https://www.iana.org/assignments/media-types/application/vnd.ipfs.ipns-record)) from trustless gateway defined in `RAINBOW_REMOTE_BACKENDS`. +This is done in addition to other routing systems, such as `RAINBOW_DHT_ROUTING` or `RAINBOW_HTTP_ROUTERS` (if also enabled). + +Default: `true` + ## Logging ### `GOLOG_LOG_LEVEL` diff --git a/main.go b/main.go index 66f0f6a..7f09cef 100644 --- a/main.go +++ b/main.go @@ -160,7 +160,7 @@ Generate an identity seed and launch a gateway: Name: "libp2p", Value: true, EnvVars: []string{"RAINBOW_LIBP2P"}, - Usage: "Enable or disable the usage of Libp2p", + Usage: "Controls if a local libp2p node is used (useful for testing or when remote backend is used instead)", }, &cli.IntFlag{ Name: "libp2p-connmgr-low", @@ -334,8 +334,19 @@ share the same seed as long as the indexes are different. bitswap := cctx.Bool("bitswap") dhtRouting := DHTRouting(cctx.String("dht-routing")) seedPeering := cctx.Bool("seed-peering") + libp2p := cctx.Bool("libp2p") + // as a convenience to the end user, and to reduce confusion + // libp2p is disabled when remote backends are defined + remoteBackends := cctx.StringSlice("remote-backends") + if len(remoteBackends) > 0 { + fmt.Printf("RAINBOW_REMOTE_BACKENDS set, forcing RAINBOW_LIBP2P=false\n") + libp2p = false + bitswap = false + dhtRouting = DHTOff + } + // Only load secrets if we need Libp2p. if libp2p { credDir := os.Getenv("CREDENTIALS_DIRECTORY") @@ -413,7 +424,7 @@ share the same seed as long as the indexes are different. SeedIndex: index, SeedPeering: seedPeering, SeedPeeringMaxIndex: cctx.Int("seed-peering-max-index"), - RemoteBackends: cctx.StringSlice("remote-backends"), + RemoteBackends: remoteBackends, RemoteBackendsIPNS: cctx.Bool("remote-backends-ipns"), RemoteBackendMode: RemoteBackendMode(cctx.String("remote-backends-mode")), GCInterval: cctx.Duration("gc-interval"), @@ -484,6 +495,8 @@ share the same seed as long as the indexes are different. printIfListConfigured(" RAINBOW_GATEWAY_DOMAINS = ", cfg.GatewayDomains) printIfListConfigured(" RAINBOW_SUBDOMAIN_GATEWAY_DOMAINS = ", cfg.SubdomainGatewayDomains) printIfListConfigured(" RAINBOW_TRUSTLESS_GATEWAY_DOMAINS = ", cfg.TrustlessGatewayDomains) + printIfListConfigured(" RAINBOW_HTTP_ROUTERS = ", cfg.RoutingV1Endpoints) + printIfListConfigured(" RAINBOW_REMOTE_BACKENDS = ", cfg.RemoteBackends) fmt.Printf("\n") fmt.Printf("CTL endpoint listening at http://%s\n", ctlListen) diff --git a/setup.go b/setup.go index 7631423..f86c679 100644 --- a/setup.go +++ b/setup.go @@ -138,7 +138,7 @@ func SetupNoLibp2p(ctx context.Context, cfg Config, dnsCache *cachedDNS) (*Node, // The stars aligned and Libp2p does not need to be turned on at all. if len(cfg.RemoteBackends) == 0 { - return nil, errors.New("URL of RAINBOW_REMOTE_BACKENDS must be set when RAINBOW_BITSWAP and RAINBOW_DHT_ROUTING are disabled") + return nil, errors.New("RAINBOW_REMOTE_BACKENDS must be set if RAINBOW_LIBP2P is disabled") } // Setup a Value Store composed of both the remote backends and the delegated @@ -175,8 +175,8 @@ func SetupNoLibp2p(ctx context.Context, cfg Config, dnsCache *cachedDNS) (*Node, } func SetupWithLibp2p(ctx context.Context, cfg Config, key crypto.PrivKey, dnsCache *cachedDNS) (*Node, error) { - if !cfg.Bitswap && cfg.DHTRouting == DHTOff && !cfg.SeedPeering { - return nil, errors.New("libp2p is enabled, but not used: bitswap, dht and seed peering are disabled") + if !cfg.Bitswap && cfg.DHTRouting == DHTOff { + return nil, errors.New("libp2p is enabled, but not used: bitswap and dht are disabled") } var err error