Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
eitu5ami committed Feb 16, 2024
1 parent a404edd commit 118c740
Showing 1 changed file with 19 additions and 38 deletions.
57 changes: 19 additions & 38 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
RPC Gateway
===
**Danger:**
RPC gateway is in development and you should not consider it stable yet.

RPC Gateway acts as a failover proxy routing ETH RPC requests across configured RPC nodes. For every ETH RPC node(group) configured the RPC Gateway tracks its latency, current height and error rates. These are then used to determine whether or not to failover.
## RPC Gateway

RPC Gateway acts as a failover proxy routing ETH RPC requests across configured
RPC nodes. For every ETH RPC node(group) configured the RPC Gateway tracks its
latency, current height and error rates. These are then used to determine
whether or not to failover.

From a high level it simply looks like this:
```mermaid
sequenceDiagram
Alice->>RPC Gateway: eth_call
Expand All @@ -22,42 +26,39 @@ Infura-->>RPC Gateway: {"result":[...]}
RPC Gateway-->>Alice: {"result":[...]}
```

The gateway assesses the health of the underlying RPC provider by:
- continuously (configurable how often) checking the blockNumber, if the request fails or timeouts it marks it as unhealthy (configurable thresholds)
- every request that fails will be rerouted to the next available healthy target after a configurable amount of retries
- if it will be rerouted the current target will be "tainted"
The gateway assesses the health of the underlying RPC provider by use of health
checks.

## Developing
## Development

Start dependent services
```zsh
```console
docker-compose up
```

Make sure the test pass
```zsh
```console
go test
```

To run the app locally
```zsh
```console
go run . --config ./example_config.yml
```

## Running & Configuration
## Running

Build the binary:
```
go build
```console
go build cmd/rpcgateway/main.go
```

The statically linked `rpc-gateway` binary has one flag `--config` that defaults to `./config.yml` simply run it by:
```
```console
./rpc-gateway --config ~/.rpc-gateway/config.yml
```


### Configuration
## Configuration

```yaml
metrics:
Expand All @@ -83,23 +84,3 @@ targets: # the order here determines the failover order
http: # ws is supported by default, it will be a sticky connection.
url: "https://alchemy.com/rpc/<apikey>"
```
## Websockets
Websockets are sticky and are handled transparently.
## Taints
Taints are a way for the `HealthcheckManager` to mark a node as unhealthy even though it responds to RPC calls. Some reasons for that are:
- BlockNumber is way behind a "quorum".
- A number of proxied requests fail in a given time.

Currently taint clearing is not implemented yet.

## Build Docker images locally
We should build multi-arch image so the image can be run in both `arm64` and `amd64` arch.

```zsh
TAG="$(git rev-parse HEAD)"
docker buildx build --platform linux/amd64,linux/arm64 -t 883408475785.dkr.ecr.us-east-1.amazonaws.com/rpc-gateway:${TAG} --push .
```

0 comments on commit 118c740

Please sign in to comment.