Skip to content

Commit

Permalink
docs: RAINBOW_REMOTE_BACKENDS
Browse files Browse the repository at this point in the history
Setting RAINBOW_REMOTE_BACKENDS should be enough to
turn off libp2p and delegate everything to HTTP endpoints.
  • Loading branch information
lidel authored and hacdias committed May 23, 2024
1 parent 3433adb commit bdd3fc3
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 13 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/gateway-conformance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ concurrency:
cancel-in-progress: true

jobs:
tests:
test:
runs-on: ubuntu-latest
strategy:
matrix:
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
42 changes: 35 additions & 7 deletions docs/environment-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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.
Expand All @@ -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`
Expand Down
17 changes: 15 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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")

Check warning on line 336 in main.go

View check run for this annotation

Codecov / codecov/patch

main.go#L334-L336

Added lines #L334 - L336 were not covered by tests

libp2p := cctx.Bool("libp2p")

Check warning on line 338 in main.go

View check run for this annotation

Codecov / codecov/patch

main.go#L338

Added line #L338 was not covered by tests

// 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

Check warning on line 347 in main.go

View check run for this annotation

Codecov / codecov/patch

main.go#L342-L347

Added lines #L342 - L347 were not covered by tests
}

// Only load secrets if we need Libp2p.
if libp2p {
credDir := os.Getenv("CREDENTIALS_DIRECTORY")
Expand Down Expand Up @@ -413,7 +424,7 @@ share the same seed as long as the indexes are different.
SeedIndex: index,
SeedPeering: seedPeering,

Check warning on line 425 in main.go

View check run for this annotation

Codecov / codecov/patch

main.go#L425

Added line #L425 was not covered by tests
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")),

Check warning on line 429 in main.go

View check run for this annotation

Codecov / codecov/patch

main.go#L427-L429

Added lines #L427 - L429 were not covered by tests
GCInterval: cctx.Duration("gc-interval"),
Expand Down Expand Up @@ -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)

Check warning on line 499 in main.go

View check run for this annotation

Codecov / codecov/patch

main.go#L498-L499

Added lines #L498 - L499 were not covered by tests

fmt.Printf("\n")
fmt.Printf("CTL endpoint listening at http://%s\n", ctlListen)
Expand Down
6 changes: 3 additions & 3 deletions setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Check warning on line 141 in setup.go

View check run for this annotation

Codecov / codecov/patch

setup.go#L140-L141

Added lines #L140 - L141 were not covered by tests
}

// Setup a Value Store composed of both the remote backends and the delegated
Expand Down Expand Up @@ -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")

Check warning on line 179 in setup.go

View check run for this annotation

Codecov / codecov/patch

setup.go#L179

Added line #L179 was not covered by tests
}

var err error
Expand Down

0 comments on commit bdd3fc3

Please sign in to comment.