diff --git a/documentation/docs/pages/docs/references/rpc-node-providers.mdx b/documentation/docs/pages/docs/references/rpc-node-providers.mdx index 8048eee4..eea773b3 100644 --- a/documentation/docs/pages/docs/references/rpc-node-providers.mdx +++ b/documentation/docs/pages/docs/references/rpc-node-providers.mdx @@ -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/) \ No newline at end of file +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. \ No newline at end of file diff --git a/documentation/docs/pages/docs/start-building/yaml-config/networks.mdx b/documentation/docs/pages/docs/start-building/yaml-config/networks.mdx index ee771dda..2b303091 100644 --- a/documentation/docs/pages/docs/start-building/yaml-config/networks.mdx +++ b/documentation/docs/pages/docs/start-building/yaml-config/networks.mdx @@ -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]