| .github/workflows | ||
| cmd | ||
| environments | ||
| monitoring | ||
| pkg | ||
| version | ||
| .gitignore | ||
| docker-compose.yml | ||
| Dockerfile | ||
| go.mod | ||
| go.sum | ||
| LICENSE | ||
| main.go | ||
| Makefile | ||
| README.md | ||
| startup_script.sh | ||
eth-statediff-service
standalone statediffing service ontop of LevelDB
Purpose:
Stand up a statediffing service directly on top of a go-ethereum LevelDB instance. This service can serve historical state data over the same rpc interface as statediffing geth without needing to run a full node
Configuration
-
Create a chain config file
chain.jsonaccording to chain config in genesis json file used by local geth.Example:
{ "chainId": 41337, "homesteadBlock": 0, "eip150Block": 0, "eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000", "eip155Block": 0, "eip158Block": 0, "byzantiumBlock": 0, "constantinopleBlock": 0, "petersburgBlock": 0, "istanbulBlock": 0, "clique": { "period": 5, "epoch": 30000 } } -
Sample database and chain configuration (from environments/config.toml):
[leveldb] mode = "local" # Path to geth LevelDB data path = "/path-to-local-geth-data/chaindata" ancient = "/path-to-local-geth-data/chaindata/ancient" [ethereum] chainConfig = "./chain.json" # Path to custom chain config file chainID = 41337 # Same chain ID as in chain.json [database] # Update database config name = "vulcanize_testing" hostname = "localhost" port = 5432 user = "postgres" password = "postgres" type = "postgres" -
Service and metrics configuration:
[statediff] serviceWorkers = 1 # Number of diffs to process concurrently workerQueueSize = 1024 # Size of buffer for block range requests 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 a remote LevelDB RPC endpoint change the following in config file
[leveldb] mode = "remote" url = "http://127.0.0.1:8082/" # Remote LevelDB RPC url -
When using the
runcommand to write diffs for specific block ranges, add this:[run] only = false ranges = [ [8, 15] # Block number range for which to write statediff. ]
Usage
serve
To serve state diffs over RPC:
eth-statediff-service serve --config=<config path>
Example:
./eth-statediff-service serve --config environments/config.toml
Available RPC methods are:
statediff_stateDiffAt()statediff_writeStateDiffAt()statediff_writeStateDiffsInRange()
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"
run
Produces diffs for specific block ranges.
Example:
./eth-statediff-service run --config environments/config.toml --run.ranges '[8,15]'