Parallelizable statediffing process that extracts from an offline levelDB
Go to file
2023-08-25 20:21:36 +08:00
.github/workflows Create issues-notion-sync.yml 2022-06-29 08:49:56 -04:00
cmd replace prerun options with run command 2023-08-25 20:21:25 +08:00
environments update docs & config 2023-08-25 20:21:34 +08:00
monitoring Add grafana dashboard. 2021-11-01 19:39:00 +05:30
pkg replace prerun options with run command 2023-08-25 20:21:25 +08:00
version bump major version 2022-02-01 12:11:57 -06:00
.gitignore go mod 2020-08-19 01:13:48 -05:00
docker-compose.yml docker updates 2023-08-25 20:21:36 +08:00
Dockerfile docker updates 2023-08-25 20:21:36 +08:00
go.mod refactor types & use plugin builder 2023-08-25 20:21:15 +08:00
go.sum refactor types & use plugin builder 2023-08-25 20:21:15 +08:00
LICENSE cobra init 2020-08-18 23:27:37 -05:00
main.go cobra init 2020-08-18 23:27:37 -05:00
README.md update docs & config 2023-08-25 20:21:34 +08:00
startup_script.sh docker updates 2023-08-25 20:21:36 +08:00

eth-statediff-service

Go Report Card

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.json according 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 run command 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]'