Local Data RPC (LD-RPC)
What is a LD-RPC?
LD-RPC (Local Data RPC) is a general RPC capable of storing data locally and serving it from there. The regular RPC server used to initially query a lot of components for information. It used to query Archiver and explorer services to get the data for each request, increasing the load on the network and leading to slower response times.
LD-RPCs are primarily expected to be run by seasoned Infrastructure providers who want to provide RPC services on Shardeum. General public is not expected to run RPCs and running a RPC has no direct rewards unlike a Validator.
With LD-RPC, the Archiver gets info from the validators and serves that to a distributor. A collector subscribes to the distributor and is set up as a server to be used by the RPC server. These streaming services help the RPC server to have the data locally, eliminating the need for constant calls to the Shardeum's explorer, archiver, or validator services.
Components of LD-RPC
Distributor Service: The Archivers run a Distributor server that makes the collected data available to subscribers. The Distributor service provides APIs to allow Collectors to subscribe and establishes a socket connection with the collector to stream the data.
Collector Service: Collector service subscribes to Distributors and collects data from them in real-time, stores this data in a local SQLite3 DB, and provides API endpoints to serve this data to further downstream services.
Service Validator: A special type of Shardeum validator which does not join the network or make network calls to the active components in a running network like the active validators or the archivers and always relies on the local account DB for all its data needs.
System Requirements
Here are the recommended system requirements for running a LD-RPC:
- 16 cores CPU
- 32 GB RAM
- 500 GB SSD (Expected to grow overtime)
- Linux-based OS
Install dependencies
- Build essentials
- NVM
- Node
Install and set Node 18.16.1 (Other versions may bot be compatible)
- Node gyp & Python
If you don’t have python3 installed, please follow docs and install it.
Then confirm your python setting
- Install pm2
- Install Rust
Rust version and Cargo version should match below:
That's it! All the dependencies are now installed. Let's setup the inidividual services now.
Collector setup
- Clone the collector codebase using below command:
- Update the config.json file with correct distributorInfo and collectorInfo:
You can request distributor and collector info from the Shardeum team or else you can generate a key-pair of your own and request the administrator to whitelist your keys on the one of the running distributors. (For steps on how to create a key-pair for collector server refer to the steps mentioned at the bottom of this document). In future, you will be able to setup your own distributor.
- Update src/config/index.ts
Update the following parameters in the index.ts file
Value of shardeumIndexerSqlitePath
depends on where you set up the service validator. Please check below how to set one up and accordingly update the value here.
We will start the collectorservice after setting up Service validator in the next step.
Service Validator setup
- Clone the service-validator codebase using below command:
- Update config.json file
Start all the services
- Start Collector services
Change directory to Collector & compile the code
- Start the main data collector
- Start the collector API server
- Start the collector LOG server
You can use the following endpoint to check the status of data. Be sure that some data quantity is shown instead of all 0.
- Check status of services
- Check logs to confirm collector has successfully started
- Start the service-validator service using below command:
- Check if service validator has started
Start the JSON-RPC setup
- Clone the json-rpc codebase using below command:
- Update src/config.ts file
- Update archiverConfig.json with correct Archiver info
Update archiverConfig.json
- Start the json-rpc service using below command
Check status of json-rpc services
How to validate if RPC server is working?
Once your RPC server is running, you can test it by making some read calls.
By default RPC is set at port 8080. So your RPC will be something like
It is advised that you give the node at least 10 minutes to sync after spinning it up to avoid issues.