2020-08-31 15:52:47 +00:00
# ipld-eth-server
2018-01-25 23:19:15 +00:00
2020-08-31 15:52:47 +00:00
[![Go Report Card ](https://goreportcard.com/badge/github.com/vulcanize/ipld-eth-server )](https://goreportcard.com/report/github.com/vulcanize/ipld-eth-server)
2019-04-05 15:10:34 +00:00
2020-09-01 21:14:37 +00:00
> ipld-eth-server is the server backend for indexed ETH IPLD objects
2019-04-05 15:10:34 +00:00
## Table of Contents
2019-05-10 15:21:08 +00:00
1. [Background ](#background )
1. [Install ](#install )
1. [Usage ](#usage )
1. [Contributing ](#contributing )
1. [License ](#license )
2019-04-05 15:10:34 +00:00
## Background
2020-09-01 21:14:37 +00:00
NOTE: WIP
2018-06-20 21:55:33 +00:00
2020-10-23 15:15:35 +00:00
ipld-eth-server is used to service queries against the Ethereum IPLD objects indexed by [ipld-eth-indexer ](https://github.com/vulcanize/ipld-eth-indexer ).
2020-09-01 21:14:37 +00:00
It exposes standard Ethereum JSON RPC endpoints on top of the database, in some cases these endpoints can leverage the unique indexes to improve query performance.
Additional, unique endpoints are exposed which utilize the new indexes and state diff data objects.
2018-06-20 21:55:33 +00:00
2019-05-08 16:44:04 +00:00
2020-08-06 20:00:41 +00:00
## Dependencies
Minimal build dependencies
2022-07-12 08:10:45 +00:00
* Go (1.18)
2020-08-06 20:00:41 +00:00
* Git
* GCC compiler
* This repository
2020-09-01 21:14:37 +00:00
External dependency
2022-09-20 15:52:06 +00:00
* Postgres database populated by [ipld-eth-db ](https://github.com/cerc-io/ipld-eth-db )
2020-08-06 20:00:41 +00:00
2019-05-13 18:44:20 +00:00
## Install
2020-08-31 15:52:47 +00:00
Start by downloading ipld-eth-server and moving into the repo:
2020-06-20 15:55:34 +00:00
2022-09-20 15:52:06 +00:00
`GO111MODULE=off go get -d github.com/cerc-io/ipld-eth-server/v4`
2020-06-20 15:55:34 +00:00
2022-09-20 15:52:06 +00:00
`cd $GOPATH/src/github.com/cerc-io/ipld-eth-server/v4@v4.x.x`
2020-06-20 15:55:34 +00:00
Then, build the binary:
`make build`
## Usage
After building the binary, run as
2020-09-01 21:14:37 +00:00
`./ipld-eth-server serve --config=<the name of your config file.toml>`
2020-06-20 15:55:34 +00:00
### Configuration
2020-09-01 21:14:37 +00:00
Below is the set of parameters for the ipld-eth-server command, in .toml form, with the respective environmental variables commented to the side.
The corresponding CLI flags can be found with the `./ipld-eth-server serve --help` command.
2020-06-20 15:55:34 +00:00
```toml
[database]
name = "vulcanize_public" # $DATABASE_NAME
hostname = "localhost" # $DATABASE_HOSTNAME
port = 5432 # $DATABASE_PORT
2020-09-01 21:14:37 +00:00
user = "postgres" # $DATABASE_USER
2020-06-20 15:55:34 +00:00
password = "" # $DATABASE_PASSWORD
2020-09-01 21:14:37 +00:00
[log]
level = "info" # $LOGRUS_LEVEL
[server]
ipcPath = "~/.vulcanize/vulcanize.ipc" # $SERVER_IPC_PATH
wsPath = "127.0.0.1:8081" # $SERVER_WS_PATH
httpPath = "127.0.0.1:8082" # $SERVER_HTTP_PATH
2020-10-27 19:08:30 +00:00
graphql = true # $SERVER_GRAPHQL
graphqlEndpoint = "" # $SERVER_GRAPHQL_ENDPOINT
2020-10-20 20:33:18 +00:00
[ethereum]
chainID = "1" # $ETH_CHAIN_ID
defaultSender = "" # $ETH_DEFAULT_SENDER_ADDR
2020-10-27 19:08:30 +00:00
rpcGasCap = "1000000000000" # $ETH_RPC_GAS_CAP
httpPath = "127.0.0.1:8545" # $ETH_HTTP_PATH
nodeID = "arch1" # $ETH_NODE_ID
clientName = "Geth" # $ETH_CLIENT_NAME
genesisBlock = "0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3" # $ETH_GENESIS_BLOCK
networkID = "1" # $ETH_NETWORK_ID
2020-06-20 15:55:34 +00:00
```
2020-10-27 19:08:30 +00:00
The `database` fields are for connecting to a Postgres database that has been/is being populated by [ipld-eth-indexer ](https://github.com/vulcanize/ipld-eth-indexer )
The `server` fields set the paths for exposing the ipld-eth-server endpoints
The `ethereum` fields set the chainID and default sender address to use for EVM simulation, and can optionally be used to configure a remote eth node to forward cache misses to
2020-06-20 15:55:34 +00:00
2020-09-01 21:14:37 +00:00
### Endpoints
#### IPLD subscription
TODO: Port the IPLD RPC subscription endpoints after the decoupling
2020-06-20 15:55:34 +00:00
2020-09-01 21:14:37 +00:00
#### Ethereum JSON-RPC
ipld-eth-server currently recapitulates portions of the Ethereum JSON-RPC api standard.
2020-06-20 15:55:34 +00:00
2020-09-02 15:22:55 +00:00
The currently supported standard endpoints are:
2020-10-28 14:02:27 +00:00
`eth_call`
`eth_getBalance`
`eth_getStorageAt`
`eth_getCode`
`eth_getProof`
2020-09-02 15:22:55 +00:00
`eth_blockNumber`
`eth_getHeaderByNumber`
2020-10-28 14:02:27 +00:00
`eth_getHeaderByHash`
2020-09-02 15:22:55 +00:00
`eth_getBlockByNumber`
`eth_getBlockByHash`
2020-10-28 14:02:27 +00:00
`eth_getTransactionCount`
`eth_getBlockTransactionCountByHash`
`eth_getBlockTransactionCountByNumber`
2020-09-02 15:22:55 +00:00
`eth_getTransactionByHash`
2020-10-28 14:02:27 +00:00
`eth_getRawTransactionByHash`
`eth_getTransactionByBlockHashAndIndex`
`eth_getTransactionByBlockNumberAndIndex`
`eth_getRawTransactionByBlockHashAndIndex`
`eth_getRawTransactionByBlockNumberAndIndex`
`eth_getTransactionReceipt`
`eth_getLogs`
`eth_getUncleCountByBlockHash`
`eth_getUncleCountByBlockNumber`
`eth_getUncleByBlockHashAndIndex`
`eth_getUncleByBlockNumberAndIndex`
2020-06-20 15:55:34 +00:00
2020-10-23 15:15:35 +00:00
TODO: Add the rest of the standard endpoints and unique endpoints (e.g. getSlice)
2020-06-20 15:55:34 +00:00
2021-04-14 15:53:44 +00:00
### CLI Options and Environment variables
| CLI Option | Environment Variable | Default Value | Comment |
| ----------------------------- | ----------------------------- | ---------------- | ----------------------------------- |
| `database-hostname` | `DATABASE_HOSTNAME` | localhost | IPLD database host |
| `database-port` | `DATABASE_PORT` | 5432 | IPLD database port |
| `database-name` | `DATABASE_NAME` | vulcanize_public | IPLD database name |
| `database-user` | `DATABASE_USER` | | IPLD database user |
| `database-password` | `DATABASE_PASSWORD` | | IPLD database password |
| `eth-server-graphql` | `ETH_SERVER_GRAPHQL` | false | If `true` enable Eth GraphQL Server |
| `eth-server-graphql-path` | `ETH_SERVER_GRAPHQLPATH` | | If `eth-server-graphql` set to true, endpoint url for graphql server (host:port) |
| `eth-server-http` | `ETH_SERVER_HTTP` | true | If `true` enable Eth HTTP JSON-RPC Server |
2021-04-19 20:07:38 +00:00
| `eth-server-http-path` | `ETH_SERVER_HTTPPATH` | | If `eth-server-http` set to `true` , endpoint url for Eth HTTP JSON-RPC server (host:port) |
2021-04-14 15:53:44 +00:00
| `eth-server-ws` | `ETH_SERVER_WS` | false | If `true` enable Eth WS JSON-RPC Server |
2021-04-19 20:07:38 +00:00
| `eth-server-ws-path` | `ETH_SERVER_WSPATH` | | If `eth-server-ws` set to `true` , endpoint url for Eth WS JSON-RPC server (host:port) |
2021-04-14 15:53:44 +00:00
| `eth-server-ipc` | `ETH_SERVER_IPC` | false | If `true` enable Eth IPC JSON-RPC Server |
| `eth-server-ipc-path` | `ETH_SERVER_IPC_PATH` | | If `eth-server-ws` set to `true` , path for Eth IPC JSON-RPC server |
| `ipld-server-graphql` | `IPLD_SERVER_GRAPHQL` | false | If `true` enable IPLD GraphQL Server |
| `ipld-server-graphql-path` | `IPLD_SERVER_GRAPHQLPATH` | | If `ipld-server-graphql` set to true, endpoint url for graphql server (host:port) |
| `ipld-postgraphile-path` | `IPLD_POSTGRAPHILEPATH` | | If `ipld-server-graphql` set to true, http url for postgraphile server on top of IPLD db |
| `tracing-http-path` | `TRACING_HTTPPATH` | | If `ipld-server-graphql` set to true, http url for tracing server |
| `tracing-postgraphile-path` | `TRACING.POSTGRAPHILEPATH` | | If `ipld-server-graphql` set to true, http url for postgraphile server on top of tracing db |
2020-06-20 15:55:34 +00:00
### Testing
2022-05-05 06:03:10 +00:00
Follow steps in [test/README.md ](./test/README.md )
2019-04-05 15:10:34 +00:00
2020-10-21 12:38:48 +00:00
## Monitoring
* Enable http server and metrics using parameters `--http --metrics`
* ipld-eth-server exposes prometheus metrics at `/metric` endpoint
* start prometheus using `monitoring/prometheus.yml` config (`prometheus --config.file=monitoring/prometheus.yml`)
* start grafana, connect to prometheus datasource and import dashboard from `monitoring/grafana/dashboard_main.json`
![](monitoring/grafana.png)
2019-04-05 15:10:34 +00:00
## Contributing
2019-05-08 18:19:32 +00:00
Contributions are welcome!
2019-04-05 15:10:34 +00:00
2019-05-10 15:07:25 +00:00
VulcanizeDB follows the [Contributor Covenant Code of Conduct ](https://www.contributor-covenant.org/version/1/4/code-of-conduct ).
2019-04-05 15:10:34 +00:00
## License
2020-08-09 15:10:39 +00:00
[AGPL-3.0 ](LICENSE ) © Vulcanize Inc