2021-03-23 07:28:04 +00:00
- [Introduction ](#introduction )
- [Getting Started ](#getting-started )
* [Running locally ](#running-locally )
* [Running remotely ](#running-remotely )
2021-09-28 09:27:57 +00:00
* [Healthcheck ](#healthcheck )
2021-03-23 07:28:04 +00:00
* [Testing ](#testing )
- [FAQ ](#faq )
Pruning for: exec, log_index, tx_lookup, history stages (#2399)
* Pruning for: exec, log_index, tx_lookup, history stages
* Pruning for: exec, log_index, tx_lookup, history stages
* Pruning for: exec, log_index, tx_lookup, history stages
* Pruning for: exec, log_index, tx_lookup, history stages
* add tvm flag
* save
* db migration for storage mode
add flag --prune=
remove flag --storage-mode=
add flag --experiments=tevm,...
rename integration set_storage_mode to set_prune
* fix
* forward move of stages must skip everything before PruneTo
* keep in db progress of prune method
* keep in db progress of prune method
* simplify logs
* simplify logs
* simplify logs
* fix test
* simplify logs
* simplify logs
* simplify logs
* simplify logs
* remove callTraceSet as dupsort
use etl transform for txlookup prune
remove some logs
* cleanup tests a bit
* print_stages and eth_sync to show prune progress
* fix print_stages
* add readme about --prune.to flag
* more docs
* add --prune.history.older and other flags support
* fix migration on empty db
* better toString
* better toString
2021-07-20 20:03:19 +00:00
* [Relations between prune options and rpc methods ](#relations-between-prune-options-and-rpc-method )
2021-03-23 07:28:04 +00:00
* [RPC Implementation Status ](#rpc-implementation-status )
2021-05-26 10:35:39 +00:00
* [Securing the communication between RPC daemon and Erigon instance via TLS and authentication ](#securing-the-communication-between-rpc-daemon-and-erigon-instance-via-tls-and-authentication )
2021-03-23 07:28:04 +00:00
* [Ethstats ](#ethstats )
* [Allowing only specific methods (Allowlist) ](#allowing-only-specific-methods--allowlist- )
* [Trace transactions progress ](#trace-transactions-progress )
* [Clients getting timeout, but server load is low ](#clients-getting-timeout--but-server-load-is-low )
* [Server load too high ](#server-load-too-high )
2021-10-06 06:58:18 +00:00
* [Faster Batch requests ](#faster-batch-requests )
2021-03-23 07:28:04 +00:00
- [For Developers ](#for-developers )
* [Code generation ](#code-generation )
2020-09-15 16:44:28 +00:00
## Introduction
2020-09-14 06:59:07 +00:00
2021-05-26 10:35:39 +00:00
Erigon's `rpcdaemon` runs in its own seperate process.
2020-09-14 06:59:07 +00:00
2021-07-11 05:25:21 +00:00
This brings many benefits including easier development, the ability to run multiple daemons at once, and the ability to
run the daemon remotely. It is possible to run the daemon locally as well (read-only) if both processes have access to
the data folder.
2020-09-15 16:44:28 +00:00
## Getting Started
2021-05-26 10:35:39 +00:00
The `rpcdaemon` gets built as part of the main `erigon` build process, but you can build it directly with this command:
2020-09-15 16:44:28 +00:00
```[bash]
make rpcdaemon
2020-09-14 06:59:07 +00:00
```
2020-09-15 16:44:28 +00:00
### Running locally
2020-09-14 06:59:07 +00:00
2021-07-11 05:25:21 +00:00
Run `rpcdaemon` on same computer with Erigon. It's default option because it using Shared Memory access to Erigon's db -
it's much faster than TCP access. Provide both `--datadir` and `--private.api.addr` flags:
2020-09-15 16:44:28 +00:00
```[bash]
2021-07-11 05:25:21 +00:00
make erigon
./build/bin/erigon --datadir=< your_data_dir > --private.api.addr=localhost:9090
make rpcdaemon
2021-12-12 23:06:12 +00:00
./build/bin/rpcdaemon --datadir=< your_data_dir > --txpool.api.addr=localhost:9090 --private.api.addr=localhost:9090 --http.api=eth,erigon,web3,net,debug,trace,txpool
2020-09-14 06:59:07 +00:00
```
2020-09-15 16:44:28 +00:00
2021-07-11 05:25:21 +00:00
Note that we've also specified which RPC namespaces to enable in the above command by `--http.api` flag.
2020-09-15 16:44:28 +00:00
### Running remotely
2021-07-11 05:25:21 +00:00
To start the daemon remotely - just don't set `--datadir` flag:
2020-09-15 16:44:28 +00:00
```[bash]
2021-07-11 05:25:21 +00:00
make erigon
./build/bin/erigon --datadir=< your_data_dir > --private.api.addr=0.0.0.0:9090
make rpcdaemon
2021-12-12 23:06:12 +00:00
./build/bin/rpcdaemon --private.api.addr=< erigon_ip > :9090 --txpool.api.addr=localhost:9090 --http.api=eth,erigon,web3,net,debug,trace,txpool
2020-09-14 06:59:07 +00:00
```
2020-09-15 16:44:28 +00:00
The daemon should respond with something like:
```[bash]
INFO [date-time] HTTP endpoint opened url=localhost:8545...
2020-09-14 06:59:07 +00:00
```
2021-12-05 02:03:08 +00:00
When RPC daemon runs remotely, by default it maintains a state cache, which is updated every time when Erigon imports a
new block. When state cache is reasonably warm, it allows such remote RPC daemon to execute queries related to `latest`
block (i.e. to current state) with comparable performance to a local RPC daemon
(around 2x slower vs 10x slower without state cache). Since there can be multiple such RPC daemons per one Erigon node,
it may scale well for some workloads that are heavy on the current state queries.
2021-12-01 07:52:36 +00:00
2021-09-28 09:27:57 +00:00
### Healthcheck
2021-10-06 06:58:18 +00:00
Running the daemon also opens an endpoint `/health` that provides a basic health check.
2021-09-28 09:27:57 +00:00
If the health check is successful it returns 200 OK.
If the health check fails it returns 500 Internal Server Error.
Configuration of the health check is sent as POST body of the method.
```
{
"min_peer_count": < minimal number of the node peers > ,
"known_block": < number_of_block_that_node_should_know >
}
```
Not adding a check disables that.
**`min_peer_count`** -- checks for mimimum of healthy node peers. Requires
`net` namespace to be listed in `http.api` .
**`known_block`** -- sets up the block that node has to know about. Requires
`eth` namespace to be listed in `http.api` .
2021-10-06 06:58:18 +00:00
Example request
2021-09-28 09:27:57 +00:00
```http POST http://localhost:8545/health --raw '{"min_peer_count": 3, "known_block": "0x1F"}'```
Example response
2021-10-06 06:58:18 +00:00
2021-09-28 09:27:57 +00:00
```
{
"check_block": "HEALTHY",
"healthcheck_query": "HEALTHY",
"min_peer_count": "HEALTHY"
}
```
2021-03-23 07:28:04 +00:00
### Testing
2020-09-14 06:59:07 +00:00
2021-07-11 05:25:21 +00:00
By default, the `rpcdaemon` serves data from `localhost:8545` . You may send `curl` commands to see if things are
working.
2020-09-14 06:59:07 +00:00
2020-09-15 16:44:28 +00:00
Try `eth_blockNumber` for example. In a third terminal window enter this command:
```[bash]
curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc": "2.0", "method": "eth_blockNumber", "params": [], "id":1}' localhost:8545
2020-09-14 06:59:07 +00:00
```
2021-05-26 10:35:39 +00:00
This should return something along the lines of this (depending on how far your Erigon node has synced):
2020-09-14 06:59:07 +00:00
2020-09-15 16:44:28 +00:00
```[bash]
{
"jsonrpc": "2.0",
"id": 1,
"result":" 0xa5b9ba"
}
2020-09-14 06:59:07 +00:00
```
2021-07-11 05:25:21 +00:00
Also, there
are [extensive instructions for using Postman ](https://github.com/ledgerwatch/erigon/wiki/Using-Postman-to-Test-TurboGeth-RPC )
to test the RPC.
2020-11-09 08:52:18 +00:00
2021-03-23 07:28:04 +00:00
## FAQ
2020-09-26 06:41:34 +00:00
Pruning for: exec, log_index, tx_lookup, history stages (#2399)
* Pruning for: exec, log_index, tx_lookup, history stages
* Pruning for: exec, log_index, tx_lookup, history stages
* Pruning for: exec, log_index, tx_lookup, history stages
* Pruning for: exec, log_index, tx_lookup, history stages
* add tvm flag
* save
* db migration for storage mode
add flag --prune=
remove flag --storage-mode=
add flag --experiments=tevm,...
rename integration set_storage_mode to set_prune
* fix
* forward move of stages must skip everything before PruneTo
* keep in db progress of prune method
* keep in db progress of prune method
* simplify logs
* simplify logs
* simplify logs
* fix test
* simplify logs
* simplify logs
* simplify logs
* simplify logs
* remove callTraceSet as dupsort
use etl transform for txlookup prune
remove some logs
* cleanup tests a bit
* print_stages and eth_sync to show prune progress
* fix print_stages
* add readme about --prune.to flag
* more docs
* add --prune.history.older and other flags support
* fix migration on empty db
* better toString
* better toString
2021-07-20 20:03:19 +00:00
### Relations between prune options and RPC methods
Next options available (by `--prune` flag):
```
2022-04-18 20:50:21 +00:00
* h - prune history (ChangeSets, HistoryIndices - used to access historical state, like eth_getStorageAt, eth_getBalanceAt, debug_traceTransaction, trace_block, trace_transaction, etc.)
Pruning for: exec, log_index, tx_lookup, history stages (#2399)
* Pruning for: exec, log_index, tx_lookup, history stages
* Pruning for: exec, log_index, tx_lookup, history stages
* Pruning for: exec, log_index, tx_lookup, history stages
* Pruning for: exec, log_index, tx_lookup, history stages
* add tvm flag
* save
* db migration for storage mode
add flag --prune=
remove flag --storage-mode=
add flag --experiments=tevm,...
rename integration set_storage_mode to set_prune
* fix
* forward move of stages must skip everything before PruneTo
* keep in db progress of prune method
* keep in db progress of prune method
* simplify logs
* simplify logs
* simplify logs
* fix test
* simplify logs
* simplify logs
* simplify logs
* simplify logs
* remove callTraceSet as dupsort
use etl transform for txlookup prune
remove some logs
* cleanup tests a bit
* print_stages and eth_sync to show prune progress
* fix print_stages
* add readme about --prune.to flag
* more docs
* add --prune.history.older and other flags support
* fix migration on empty db
* better toString
* better toString
2021-07-20 20:03:19 +00:00
* r - prune receipts (Receipts, Logs, LogTopicIndex, LogAddressIndex - used by eth_getLogs and similar RPC methods)
* t - prune tx lookup (used to get transaction by hash)
2022-04-18 20:50:21 +00:00
* c - prune call traces (used by trace_filter method)
Pruning for: exec, log_index, tx_lookup, history stages (#2399)
* Pruning for: exec, log_index, tx_lookup, history stages
* Pruning for: exec, log_index, tx_lookup, history stages
* Pruning for: exec, log_index, tx_lookup, history stages
* Pruning for: exec, log_index, tx_lookup, history stages
* add tvm flag
* save
* db migration for storage mode
add flag --prune=
remove flag --storage-mode=
add flag --experiments=tevm,...
rename integration set_storage_mode to set_prune
* fix
* forward move of stages must skip everything before PruneTo
* keep in db progress of prune method
* keep in db progress of prune method
* simplify logs
* simplify logs
* simplify logs
* fix test
* simplify logs
* simplify logs
* simplify logs
* simplify logs
* remove callTraceSet as dupsort
use etl transform for txlookup prune
remove some logs
* cleanup tests a bit
* print_stages and eth_sync to show prune progress
* fix print_stages
* add readme about --prune.to flag
* more docs
* add --prune.history.older and other flags support
* fix migration on empty db
* better toString
* better toString
2021-07-20 20:03:19 +00:00
```
By default data pruned after 90K blocks, can change it by flags like `--prune.history.after=100_000`
Some methods, if not found historical data in DB, can fallback to old blocks re-execution - but it require `h` .
2021-03-23 07:28:04 +00:00
### RPC Implementation Status
2020-09-15 16:44:28 +00:00
2021-08-13 15:51:59 +00:00
Label "remote" means: `--private.api.addr` flag is required.
2021-08-11 08:19:13 +00:00
2021-05-26 10:35:39 +00:00
The following table shows the current implementation status of Erigon's RPC daemon.
2020-09-15 16:44:28 +00:00
2021-06-04 16:25:17 +00:00
| Command | Avail | Notes |
| ------------------------------------------ | ------- | ------------------------------------------ |
| web3_clientVersion | Yes | |
| web3_sha3 | Yes | |
| | | |
2021-08-11 08:19:13 +00:00
| net_listening | HC | (`remote` hard coded returns true) |
2021-06-17 21:55:20 +00:00
| net_peerCount | Limited | internal sentries only |
2021-08-11 08:19:13 +00:00
| net_version | Yes | `remote` . |
2021-06-04 16:25:17 +00:00
| | | |
| eth_blockNumber | Yes | |
2021-09-21 01:57:23 +00:00
| eth_chainID/eth_chainId | Yes | |
2021-06-04 16:25:17 +00:00
| eth_protocolVersion | Yes | |
| eth_syncing | Yes | |
| eth_gasPrice | Yes | |
2021-08-08 07:27:47 +00:00
| eth_maxPriorityFeePerGas | Yes | |
| eth_feeHistory | Yes | |
2021-06-04 16:25:17 +00:00
| | | |
| eth_getBlockByHash | Yes | |
| eth_getBlockByNumber | Yes | |
| eth_getBlockTransactionCountByHash | Yes | |
| eth_getBlockTransactionCountByNumber | Yes | |
| eth_getUncleByBlockHashAndIndex | Yes | |
| eth_getUncleByBlockNumberAndIndex | Yes | |
| eth_getUncleCountByBlockHash | Yes | |
| eth_getUncleCountByBlockNumber | Yes | |
| | | |
| eth_getTransactionByHash | Yes | |
| eth_getRawTransactionByHash | Yes | |
| eth_getTransactionByBlockHashAndIndex | Yes | |
| eth_retRawTransactionByBlockHashAndIndex | Yes | |
| eth_getTransactionByBlockNumberAndIndex | Yes | |
| eth_retRawTransactionByBlockNumberAndIndex | Yes | |
| eth_getTransactionReceipt | Yes | |
| eth_getBlockReceipts | Yes | |
| | | |
| eth_estimateGas | Yes | |
| eth_getBalance | Yes | |
| eth_getCode | Yes | |
| eth_getTransactionCount | Yes | |
| eth_getStorageAt | Yes | |
| eth_call | Yes | |
| eth_callBundle | Yes | |
2021-12-01 07:52:36 +00:00
| eth_createAccessList | Yes |
2021-06-04 16:25:17 +00:00
| | | |
| eth_newFilter | - | not yet implemented |
| eth_newBlockFilter | - | not yet implemented |
| eth_newPendingTransactionFilter | - | not yet implemented |
| eth_getFilterChanges | - | not yet implemented |
| eth_uninstallFilter | - | not yet implemented |
| eth_getLogs | Yes | |
| | | |
| eth_accounts | No | deprecated |
2021-08-11 08:19:13 +00:00
| eth_sendRawTransaction | Yes | `remote` . |
2021-06-04 16:25:17 +00:00
| eth_sendTransaction | - | not yet implemented |
| eth_sign | No | deprecated |
| eth_signTransaction | - | not yet implemented |
| eth_signTypedData | - | ???? |
| | | |
| eth_getProof | - | not yet implemented |
| | | |
| eth_mining | Yes | returns true if --mine flag provided |
| eth_coinbase | Yes | |
| eth_hashrate | Yes | |
| eth_submitHashrate | Yes | |
| eth_getWork | Yes | |
| eth_submitWork | Yes | |
| | | |
| eth_subscribe | Limited | Websock Only - newHeads, |
2022-02-16 18:42:00 +00:00
| | | newPendingTransactions |
2021-06-04 16:25:17 +00:00
| eth_unsubscribe | Yes | Websock Only |
| | | |
2022-02-17 17:30:57 +00:00
| engine_newPayloadV1 | Yes | |
| engine_forkchoiceUpdatedV1 | Yes | |
| engine_getPayloadV1 | Yes | |
| engine_exchangeTransitionConfigurationV1 | Yes | |
| | | |
2021-06-04 16:25:17 +00:00
| debug_accountRange | Yes | Private Erigon debug module |
| debug_accountAt | Yes | Private Erigon debug module |
| debug_getModifiedAccountsByNumber | Yes | |
| debug_getModifiedAccountsByHash | Yes | |
| debug_storageRangeAt | Yes | |
2022-02-19 08:15:27 +00:00
| debug_traceBlockByHash | Yes | Streaming (can handle huge results) |
| debug_traceBlockByNumber | Yes | Streaming (can handle huge results) |
2021-06-04 16:25:17 +00:00
| debug_traceTransaction | Yes | Streaming (can handle huge results) |
| debug_traceCall | Yes | Streaming (can handle huge results) |
| | | |
| trace_call | Yes | |
| trace_callMany | Yes | |
| trace_rawTransaction | - | not yet implemented (come help!) |
2021-06-26 12:27:29 +00:00
| trace_replayBlockTransactions | yes | stateDiff only (come help!) |
| trace_replayTransaction | yes | stateDiff only (come help!) |
2021-06-04 16:25:17 +00:00
| trace_block | Yes | |
| trace_filter | Yes | no pagination, but streaming |
| trace_get | Yes | |
| trace_transaction | Yes | |
| | | |
2021-08-11 08:19:13 +00:00
| txpool_content | Yes | `remote` |
| txpool_status | Yes | `remote` |
2021-06-11 08:34:47 +00:00
| | | |
2022-02-07 21:30:46 +00:00
| eth_getCompilers | No | deprecated |
| eth_compileLLL | No | deprecated |
| eth_compileSolidity | No | deprecated |
| eth_compileSerpent | No | deprecated |
| | | |
2021-06-04 16:25:17 +00:00
| db_putString | No | deprecated |
| db_getString | No | deprecated |
| db_putHex | No | deprecated |
| db_getHex | No | deprecated |
| | | |
| erigon_getHeaderByHash | Yes | Erigon only |
| erigon_getHeaderByNumber | Yes | Erigon only |
| erigon_getLogsByHash | Yes | Erigon only |
| erigon_forks | Yes | Erigon only |
| erigon_issuance | Yes | Erigon only |
2022-02-22 01:42:23 +00:00
| erigon_GetBlockByTimestamp | Yes | Erigon only |
2022-01-20 15:34:00 +00:00
| | | |
| starknet_call | Yes | Starknet only |
2022-02-20 10:45:29 +00:00
| | | |
| bor_getSnapshot | Yes | Bor only |
| bor_getAuthor | Yes | Bor only |
| bor_getSnapshotAtHash | Yes | Bor only |
| bor_getSigners | Yes | Bor only |
| bor_getSignersAtHash | Yes | Bor only |
| bor_getCurrentProposer | Yes | Bor only |
| bor_getCurrentValidators | Yes | Bor only |
| bor_getRootHash | Yes | Bor only |
2020-09-15 16:44:28 +00:00
This table is constantly updated. Please visit again.
2021-05-26 10:35:39 +00:00
### Securing the communication between RPC daemon and Erigon instance via TLS and authentication
2020-09-26 06:41:34 +00:00
2021-07-11 05:25:21 +00:00
In some cases, it is useful to run Erigon nodes in a different network (for example, in a Public cloud), but RPC daemon
locally. To ensure the integrity of communication and access control to the Erigon node, TLS authentication can be
enabled. On the high level, the process consists of these steps (this process needs to be done for any "cluster" of
Erigon and RPC daemon nodes that are supposed to work together):
1. Generate key pair for the Certificate Authority (CA). The private key of CA will be used to authorise new Erigon
instances as well as new RPC daemon instances, so that they can mutually authenticate.
2. Create CA certificate file that needs to be deployed on any Erigon instance and any RPC daemon. This CA cerf file is
used as a "root of trust", whatever is in it, will be trusted by the participants when they authenticate their
counterparts.
3. For each Erigon instance and each RPC daemon instance, generate a key pair. If you are lazy, you can generate one
pair for all Erigon nodes, and one pair for all RPC daemons, and copy these keys around.
4. Using the CA private key, create cerificate file for each public key generated on the previous step. This
effectively "inducts" these keys into the "cluster of trust".
2020-09-19 14:16:04 +00:00
5. On each instance, deploy 3 files - CA certificate, instance key, and certificate signed by CA for this instance key.
Following is the detailed description of how it can be done using `openssl` suite of tools.
2021-07-11 05:25:21 +00:00
Generate CA key pair using Elliptic Curve (as opposed to RSA). The generated CA key will be in the file `CA-key.pem` .
Access to this file will allow anyone to later include any new instance key pair into the "cluster of trust", so keep it
secure.
2020-09-26 06:41:34 +00:00
2020-09-19 14:16:04 +00:00
```
openssl ecparam -name prime256v1 -genkey -noout -out CA-key.pem
```
2021-07-11 05:25:21 +00:00
Create CA self-signed certificate (this command will ask questions, answers aren't important for now). The file created
by this command is `CA-cert.pem`
2020-09-26 06:41:34 +00:00
2020-09-19 14:16:04 +00:00
```
openssl req -x509 -new -nodes -key CA-key.pem -sha256 -days 3650 -out CA-cert.pem
```
2021-05-26 10:35:39 +00:00
For Erigon node, generate a key pair:
2020-09-26 06:41:34 +00:00
2020-09-19 14:16:04 +00:00
```
2021-05-26 10:35:39 +00:00
openssl ecparam -name prime256v1 -genkey -noout -out erigon-key.pem
2020-09-19 14:16:04 +00:00
```
Also, generate one for the RPC daemon:
2020-09-26 06:41:34 +00:00
2020-09-19 14:16:04 +00:00
```
openssl ecparam -name prime256v1 -genkey -noout -out RPC-key.pem
```
2021-05-26 10:35:39 +00:00
Now create certificate signing request for Erigon key pair:
2020-09-26 06:41:34 +00:00
2020-09-19 14:16:04 +00:00
```
2021-05-26 10:35:39 +00:00
openssl req -new -key erigon-key.pem -out erigon.csr
2020-09-19 14:16:04 +00:00
```
2021-07-11 05:25:21 +00:00
And from this request, produce the certificate (signed by CA), proving that this key is now part of the "cluster of
trust"
2020-09-26 06:41:34 +00:00
2020-09-19 14:16:04 +00:00
```
2021-05-26 10:35:39 +00:00
openssl x509 -req -in erigon.csr -CA CA-cert.pem -CAkey CA-key.pem -CAcreateserial -out erigon.crt -days 3650 -sha256
2020-09-19 14:16:04 +00:00
```
Then, produce the certificate signing request for RPC daemon key pair:
2020-09-26 06:41:34 +00:00
2020-09-19 14:16:04 +00:00
```
openssl req -new -key RPC-key.pem -out RPC.csr
```
2021-07-11 05:25:21 +00:00
And from this request, produce the certificate (signed by CA), proving that this key is now part of the "cluster of
trust"
2020-09-26 06:41:34 +00:00
2020-09-19 14:16:04 +00:00
```
openssl x509 -req -in RPC.csr -CA CA-cert.pem -CAkey CA-key.pem -CAcreateserial -out RPC.crt -days 3650 -sha256
```
2021-07-11 05:25:21 +00:00
When this is all done, these three files need to be placed on the machine where Erigon is running: `CA-cert.pem`
, `erigon-key.pem` , `erigon.crt` . And Erigon needs to be run with these extra options:
2020-09-26 06:41:34 +00:00
2020-09-19 14:16:04 +00:00
```
2021-05-26 10:35:39 +00:00
--tls --tls.cacert CA-cert.pem --tls.key erigon-key.pem --tls.cert erigon.crt
2020-09-19 14:16:04 +00:00
```
2021-07-11 05:25:21 +00:00
On the RPC daemon machine, these three files need to be placed: `CA-cert.pem` , `RPC-key.pem` , and `RPC.crt` . And RPC
daemon needs to be started with these extra options:
2020-09-26 06:41:34 +00:00
2020-09-19 14:16:04 +00:00
```
--tls.key RPC-key.pem --tls.cacert CA-cert.pem --tls.cert RPC.crt
```
2021-07-11 05:25:21 +00:00
**WARNING** Normally, the "client side" (which in our case is RPC daemon), verifies that the host name of the server
matches the "Common Name" attribute of the "server" cerificate. At this stage, this verification is turned off, and it
will be turned on again once we have updated the instruction above on how to properly generate cerificates with "Common
Name".
2020-09-19 14:16:04 +00:00
2021-07-11 05:25:21 +00:00
When running Erigon instance in the Google Cloud, for example, you need to specify the **Internal IP** in
the `--private.api.addr` option. And, you will need to open the firewall on the port you are using, to that connection
to the Erigon instances can be made.
2020-09-19 14:16:04 +00:00
2021-03-23 07:28:04 +00:00
### Ethstats
2020-11-06 07:59:50 +00:00
This version of the RPC daemon is compatible with [ethstats-client ](https://github.com/goerli/ethstats-client ).
To run ethstats, run the RPC daemon remotely and open some of the APIs.
`./build/bin/rpcdaemon --private.api.addr=localhost:9090 --http.api=net,eth,web3`
Then update your `app.json` for ethstats-client like that:
```json
[
{
2021-07-11 05:25:21 +00:00
"name": "ethstats",
"script": "app.js",
"log_date_format": "YYYY-MM-DD HH:mm Z",
"merge_logs": false,
"watch": false,
"max_restarts": 10,
"exec_interpreter": "node",
"exec_mode": "fork_mode",
"env": {
"NODE_ENV": "production",
"RPC_HOST": "localhost",
"RPC_PORT": "8545",
"LISTENING_PORT": "30303",
"INSTANCE_NAME": "Erigon node",
2021-10-28 13:00:39 +00:00
"CONTACT_DETAILS": < your twitter handle > ,
2021-07-11 05:25:21 +00:00
"WS_SERVER": "wss://ethstats.net/api",
2021-10-28 13:00:39 +00:00
"WS_SECRET": < put your secret key here > ,
2021-07-11 05:25:21 +00:00
"VERBOSITY": 2
2020-11-06 07:59:50 +00:00
}
}
]
```
Run ethstats-client through pm2 as usual.
You will see these warnings in the RPC daemon output, but they are expected
```
WARN [11-05|09:03:47.911] Served conn=127.0.0.1:59753 method=eth_newBlockFilter reqid=5 t="21.194µs" err="the method eth_newBlockFilter does not exist/is not available"
WARN [11-05|09:03:47.911] Served conn=127.0.0.1:59754 method=eth_newPendingTransactionFilter reqid=6 t="9.053µs" err="the method eth_newPendingTransactionFilter does not exist/is not available"
```
2021-03-23 07:28:04 +00:00
### Allowing only specific methods (Allowlist)
2020-11-10 09:08:42 +00:00
2021-07-11 05:25:21 +00:00
In some cases you might want to only allow certain methods in the namespaces and hide others. That is possible
with `rpc.accessList` flag.
2020-11-10 09:08:42 +00:00
1. Create a file, say, `rules.json`
2. Add the following content
```json
{
2021-07-11 05:25:21 +00:00
"allow": [
"net_version",
"web3_eth_getBlockByHash"
]
2020-11-10 09:08:42 +00:00
}
```
3. Provide this file to the rpcdaemon using `--rpc.accessList` flag
```
> rpcdaemon --private.api.addr=localhost:9090 --http.api=eth,debug,net,web3 --rpc.accessList=rules.json
```
Now only these two methods are available.
2021-03-23 07:28:04 +00:00
### Clients getting timeout, but server load is low
2021-07-11 05:25:21 +00:00
In this case: increase default rate-limit - amount of requests server handle simultaneously - requests over this limit
will wait. Increase it - if your 'hot data' is small or have much RAM or see "request timeout" while server load is low.
2021-03-23 07:28:04 +00:00
```
2021-05-26 10:35:39 +00:00
./build/bin/erigon --private.api.addr=localhost:9090 --private.api.ratelimit=1024
2021-03-23 07:28:04 +00:00
```
2021-07-11 05:25:21 +00:00
### Server load too high
2021-03-23 07:28:04 +00:00
2021-07-11 05:25:21 +00:00
Reduce `--private.api.ratelimit`
2020-11-10 09:08:42 +00:00
2021-06-05 14:10:01 +00:00
### Read DB directly without Json-RPC/Graphql
2021-12-02 11:52:41 +00:00
[./../../docs/programmers_guide/db_faq.md ](./../../docs/programmers_guide/db_faq.md )
2021-06-05 14:10:01 +00:00
2021-10-06 06:58:18 +00:00
### Faster Batch requests
2021-06-06 01:09:25 +00:00
2021-07-11 05:25:21 +00:00
Currently batch requests are spawn multiple goroutines and process all sub-requests in parallel. To limit impact of 1
2021-10-06 06:58:18 +00:00
huge batch to other users - added flag `--rpc.batch.concurrency` (default: 2). Increase it to process large batches
2021-07-11 05:25:21 +00:00
faster.
2021-06-06 01:09:25 +00:00
2021-07-11 05:25:21 +00:00
Known Issue: if at least 1 request is "stremable" (has parameter of type *jsoniter.Stream) - then whole batch will
processed sequentially (on 1 goroutine).
2021-06-06 01:09:25 +00:00
2020-09-15 16:44:28 +00:00
## For Developers
### Code generation
2021-07-11 05:25:21 +00:00
`go.mod` stores right version of generators, use `make grpc` to install it and generate code (it also installs protoc
into ./build/bin folder).