Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: erpc #76

Merged
merged 3 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 61 additions & 1 deletion documentation/docs/pages/docs/references/rpc-node-providers.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,64 @@ You can use [chainlist](https://chainlist.org/) to find all the providers which

## Local nodes

rindexer should work with any local nodes you run including [Anvil](https://book.getfoundry.sh/anvil/) and [Hardhat](https://hardhat.org/)
rindexer should work with any local nodes you run including [Anvil](https://book.getfoundry.sh/anvil/) and [Hardhat](https://hardhat.org/)

# RPC Proxy and Caching

[eRPC](https://github.com/erpc/erpc) is a fault-tolerant EVM RPC proxy and re-org aware permanent caching solution. It is built with read-heavy use-cases in mind such as data indexing and high-load frontend usage.

## Quickstart

1. Create your [`erpc.yaml`](https://docs.erpc.cloud/config/example) configuration file:

```yaml filename="erpc.yaml"
logLevel: debug
projects:
- id: main
upstreams:
# You don't need to define architecture (e.g. evm) or chain id (e.g. 137)
# as they will be detected automatically by eRPC.
- endpoint: https://eth-mainnet.blastapi.io/xxxx
- endpoint: https://polygon-mainnet.blastapi.io/xxxx
- endpoint: evm+alchemy://xxxx-my-alchemy-api-key-xxxx
```

See [a complete config example](https://docs.erpc.cloud/config/example) for inspiration.

2. Use the Docker image:

```bash
docker run -v $(pwd)/erpc.yaml:/root/erpc.yaml -p 4000:4000 -p 4001:4001 ghcr.io/erpc/erpc:latest
```

or add the below configs to the rindexer's [docker-compose.yaml](https://github.com/joshstevens19/rindexer/blob/master/docker-compose.yml) as a service and run `docker-compose up -d`:

```yaml [rindexer.yaml]
services:
...

erpc: // [!code focus]
image: ghcr.io/erpc/erpc:latest // [!code focus]
platform: linux/amd64 // [!code focus]
volumes: // [!code focus]
- ${PROJECT_PATH}/erpc.yaml:/root/erpc.yaml // [!code focus]
ports: // [!code focus]
- 4000:4000 // [!code focus]
- 4001:4001 // [!code focus]
restart: always // [!code focus]
```

3. Set erpc url in [rindexer network config](https://rindexer.xyz/docs/start-building/yaml-config/networks#rpc):

```yaml [rindexer.yaml]
name: rETHIndexer
description: My first rindexer project
repository: https://github.com/joshstevens19/rindexer
project_type: no-code
networks:
- name: ethereum
chain_id: 1
rpc: http://erpc:4000/main/evm/1 // [!code focus]
```

and you are set to go. the rpc requests now will be redirected toward erpc and it will handle caching, failover, auto-batching, rate-limiting, auto-discovery of node providers, etc. behind the scens.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,19 @@ networks:
rpc: https://mainnet.gateway.tenderly.co // [!code focus]
```

You can use [erpc](https://rindexer.xyz/docs/references/rpc-node-providers#rpc-proxy-and-caching) for load-balancing between multiple rpc endpoints (with failover, re-org aware caching, auto-batching, rate-limiters, auto-discovery of node providers, etc.)

```yaml [rindexer.yaml]
name: rETHIndexer
description: My first rindexer project
repository: https://github.com/joshstevens19/rindexer
project_type: no-code
networks:
- name: ethereum
chain_id: 1
rpc: http://erpc:4000/main/evm/1 // [!code focus]
```

We advise using environment variables for the rpc url to avoid checking in sensitive information.

```yaml [rindexer.yaml]
Expand Down