The Data Distribution System is designed to efficiently handle the flow of data within the ecosystem. This system involves various components such as Collectors, Archivers, Validators, Distributors, and more. The system revolves around the Collector, which saves incoming data chunks from Archivers or Distributors into log files and an SQLite database. Active Validators generate data passed on to Archivers, which in turn distribute it to various services like Explorers, JSON-RPC servers, and wallets for end-user access.
- Clone the repository and switch to
devbranch
git clone https://github.com/shardeum/relayer-collector.git
cd collector
npm install- Configure the config.json with correct
distributorInfoandcollectorInfo
Set the ip, port, and publicKey of the distributor service in the distributorInfo object, and the public and secret keys of the collector service in the collectorInfo object. 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.
"distributorInfo": {
"ip": "<distributor-server-ip>", //eg: 127.0.0.1
"port": "<distributor-server-port>", //eg: 6100
"publicKey": "distributor-server-public-key"
},
"collectorInfo": {
"publicKey": "<collector-pub-key>",
"secretKey": "<collector-secret-key>"
}To generate key-pair for collector, do the following
# Navigate to the Shardeum repository
cd path/to/shardeum/repo # https://github.com/shardeum/shardeum
# Generate a new wallet
node scripts/generateWallet.js- Update
src/config/index.tswith the following settings
enableShardeumIndexer: false,The enableShardeumIndexer flag, when enabled, allows the collector to save accounts data in a format required by the service Validator, in addition to its standard data storage; it's typically set to false for most use cases.
- Now you can compile the project using the following command
npm run prepare- To start the main data collector, run
pm2 start --name collector-data-server --node-args="--max_old_space_size=16000" npm -- run collector- Monitor the collector logs
pm2 logsCheck the logs for any errors or issues during startup and operation. By following these steps, you'll have the collector set up and connected to the distributor, ready to receive and process data from the Shardeum network.
The Collector service connects to a distributor service as configured in config.json. It can be started with the following command:
npm run collectorHere's what the Collector does:
- Data Syncing: Initiates a data syncing process in which it queries all the historical data (Accounts, Transactions, Receipts etc) from the distributor and saves it to its own SQLite DB.
- Real-time Data Subscription: Simultaneously, it subscribes to real-time data from the distributor and writes it to a log file (under
/data-logs) and the SQLite DB.
This API Server is used to expose the data stored in the SQLite DB to the RPC Server, if you intend to point an RPC to the collector data. The server can be started using:
npm run serverThe log_server hosts an endpoint named /evm_log_subscription, specifically designed for hosting on-chain event logs like eth_getLogs. This feature further enhances the capabilities and accessibility of the system.
The log server can be started using:
npm run log_server- GET
/is-alivethis endpoint returns 200 if the server is running. - GET
/is-healthycurrently the same as/is-alivebut will be expanded.
Contributions are highly encouraged! We welcome everyone to participate in our codebases, issue trackers, and any other form of communication. However, we expect all contributors to adhere to our code of conduct to ensure a positive and collaborative environment for all involved in the project.