update docs & config

This commit is contained in:
Roy Crihfield 2023-08-25 19:02:32 +08:00
parent 73292c4046
commit 90f64c2a94
4 changed files with 49 additions and 172 deletions

View File

@ -15,7 +15,7 @@ RUN GO111MODULE=on GCO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -ldfl
FROM alpine FROM alpine
ARG USER="vdm" ARG USER="vdm"
ARG CONFIG_FILE="./environments/config.toml" ARG CONFIG_FILE="./environments/docker.toml"
ARG EXPOSE_PORT=8545 ARG EXPOSE_PORT=8545
RUN adduser -Du 5000 $USER adm RUN adduser -Du 5000 $USER adm

130
README.md
View File

@ -10,15 +10,7 @@ Stand up a statediffing service directly on top of a go-ethereum LevelDB instanc
This service can serve historical state data over the same rpc interface as This service can serve historical state data over the same rpc interface as
[statediffing geth](https://github.com/vulcanize/go-ethereum/releases/tag/v1.9.11-statediff-0.0.5) without needing to run a full node [statediffing geth](https://github.com/vulcanize/go-ethereum/releases/tag/v1.9.11-statediff-0.0.5) without needing to run a full node
## Setup ## Configuration
Build the binary:
```bash
make build
```
### Local Setup
* Create a chain config file `chain.json` according to chain config in genesis json file used by local geth. * Create a chain config file `chain.json` according to chain config in genesis json file used by local geth.
@ -42,7 +34,7 @@ make build
} }
``` ```
* Change the following in [config file](./environments/config.toml) * Sample database and chain configuration (from [environments/config.toml](./environments/config.toml)):
```toml ```toml
[leveldb] [leveldb]
@ -53,7 +45,7 @@ make build
[ethereum] [ethereum]
chainConfig = "./chain.json" # Path to custom chain config file chainConfig = "./chain.json" # Path to custom chain config file
chainID = 41337 # Same chain ID as in chain.json chainID = 41337 # Same chain ID as in chain.json
[database] [database]
# Update database config # Update database config
@ -65,22 +57,42 @@ make build
type = "postgres" type = "postgres"
``` ```
* To write statediff for a range of block make changes in [config file](./environments/config.toml) * Service and metrics configuration:
```toml ```toml
[prerun] [statediff]
only = false serviceWorkers = 1 # Number of diffs to process concurrently
ranges = [ workerQueueSize = 1024 # Size of buffer for block range requests
[8, 15] # Block number range for which to write statediff. trieWorkers = 4 # Number of state subtries to process concurrently
]
[cache]
database = 1024 # Trie node cache size in MB
trie = 1024 # LevelDB cache size in MiB
[prom]
dbStats = false
metrics = true
http = true
httpAddr = "localhost"
httpPort = "8889"
``` ```
* To use remote LevelDB RPC endpoint change the following in [config file](./environments/config.toml) * To use a remote LevelDB RPC endpoint change the following in [config file](./environments/config.toml)
```toml ```toml
[leveldb] [leveldb]
mode = "remote" mode = "remote"
url = "http://127.0.0.1:8082/" # Remote LevelDB RPC url url = "http://127.0.0.1:8082/" # Remote LevelDB RPC url
``` ```
* When using the `run` command to write diffs for specific block ranges, add this:
```toml
[run]
only = false
ranges = [
[8, 15] # Block number range for which to write statediff.
]
```
## Usage ## Usage
### `serve` ### `serve`
@ -96,88 +108,18 @@ Example:
``` ```
Available RPC methods are: Available RPC methods are:
* `statediff_stateTrieAt()`
* `statediff_streamCodeAndCodeHash()`
* `statediff_stateDiffAt()` * `statediff_stateDiffAt()`
* `statediff_writeStateDiffAt()` * `statediff_writeStateDiffAt()`
* `statediff_writeStateDiffsInRange()` * `statediff_writeStateDiffsInRange()`
e.g. `curl -X POST -H 'Content-Type: application/json' --data '{"jsonrpc":"2.0","method":"statediff_writeStateDiffsInRange","params":['"$BEGIN"', '"$END"', {"intermediateStateNodes":true,"intermediateStorageNodes":true,"includeBlock":true,"includeReceipts":true,"includeTD":true,"includeCode":true}],"id":1}' "$HOST":"$PORT"` e.g. `curl -X POST -H 'Content-Type: application/json' --data '{"jsonrpc":"2.0","method":"statediff_writeStateDiffsInRange","params":['"$BEGIN"', '"$END"', {"includeBlock":true,"includeReceipts":true,"includeTD":true,"includeCode":true}],"id":1}' "$HOST":"$PORT"`
The process can be configured locally with sets of ranges to process as a "prerun" to processing directed by the server endpoints. ### `run`
This is done by turning "prerun" on in the config (`statediff.prerun = true`) and defining ranged and params in the
`prerun` section of the config as shown below.
## Configuration Produces diffs for specific block ranges.
An example config file: Example:
```toml ```bash
[leveldb] ./eth-statediff-service run --config environments/config.toml --run.ranges '[8,15]'
mode = "local"
# path and ancient LevelDB paths required in local mode
path = "/Users/user/Library/Ethereum/geth/chaindata"
ancient = "/Users/user/Library/Ethereum/geth/chaindata/ancient"
# url for leveldb-ethdb-rpc endpoint required in remote mode
url = "http://127.0.0.1:8082/"
[server]
ipcPath = ".ipc"
httpPath = "127.0.0.1:8545"
[statediff]
prerun = true
serviceWorkers = 1
workerQueueSize = 1024
trieWorkers = 4
[prerun]
only = false
ranges = [
[0, 1000]
]
[prerun.params]
intermediateStateNodes = true
intermediateStorageNodes = true
includeBlock = true
includeReceipts = true
includeTD = true
includeCode = true
watchedAddresses = []
[log]
file = ""
level = "info"
[eth]
chainID = 1
[database]
name = "vulcanize_test"
hostname = "localhost"
port = 5432
user = "vulcanize"
password = "..."
type = "postgres"
driver = "sqlx"
dumpDestination = ""
filePath = ""
[cache]
database = 1024
trie = 1024
[prom]
dbStats = false
metrics = true
http = true
httpAddr = "localhost"
httpPort = "8889"
[ethereum]
nodeID = ""
clientName = "eth-statediff-service"
genesisBlock = "0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3"
networkID = 1
chainID = 1
``` ```

View File

@ -1,61 +0,0 @@
[leveldb]
mode = "local"
path = "/app/geth-rw/chaindata"
ancient = "/app/geth-rw/chaindata/ancient"
url = "http://127.0.0.1:8082/"
[server]
ipcPath = ""
httpPath = "0.0.0.0:8545"
[statediff]
prerun = true
serviceWorkers = 1
workerQueueSize = 1024
trieWorkers = 16
[prerun]
only = true
ranges = []
[prerun.params]
intermediateStateNodes = true
intermediateStorageNodes = true
includeBlock = true
includeReceipts = true
includeTD = true
includeCode = true
watchedAddresses = []
[log]
file = ""
level = "info"
[database]
name = ""
hostname = ""
port = 5432
user = ""
password = ""
type = "postgres"
driver = "sqlx"
dumpDestination = ""
filePath = ""
[cache]
database = 1024
trie = 4096
[prom]
dbStats = false
metrics = true
http = true
httpAddr = "0.0.0.0"
httpPort = 9100
[ethereum]
chainConfig = ""
nodeID = ""
clientName = "eth-statediff-service"
genesisBlock = "0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3"
networkID = 1
chainID = 1

View File

@ -1,7 +1,7 @@
[leveldb] [leveldb]
mode = "local" mode = "local"
path = "/Users/user/Library/Ethereum/geth/chaindata" path = "/home/user/.ethereum/geth/chaindata"
ancient = "/Users/user/Library/Ethereum/geth/chaindata/ancient" ancient = "/home/user/.ethereum/geth/chaindata/ancient"
url = "http://127.0.0.1:8082/" url = "http://127.0.0.1:8082/"
[server] [server]
@ -9,19 +9,15 @@
httpPath = "127.0.0.1:8545" httpPath = "127.0.0.1:8545"
[statediff] [statediff]
prerun = true
serviceWorkers = 1 serviceWorkers = 1
workerQueueSize = 1024 workerQueueSize = 1024
trieWorkers = 4 trieWorkers = 4
[prerun] [run]
only = false
ranges = [ ranges = [
[0, 1000] [0, 1000]
] ]
[prerun.params] [run.params]
intermediateStateNodes = true
intermediateStorageNodes = true
includeBlock = true includeBlock = true
includeReceipts = true includeReceipts = true
includeTD = true includeTD = true
@ -33,15 +29,15 @@
level = "info" level = "info"
[database] [database]
name = "vulcanize_test" name = "cerc_testing"
hostname = "localhost" hostname = "localhost"
port = 5432 port = 5432
user = "vulcanize" user = "vdbm"
password = "..." password = "password"
type = "postgres" type = "postgres"
driver = "sqlx" driver = "sqlx"
dumpDestination = "" dumpDestination = ""
filePath = "" filePath = ""
[cache] [cache]
database = 1024 database = 1024