Set up ETH Tracker
Requirements
- A Gnosis node with HTTP JSON-RPC and WebSocket. It must serve
eth_getBlockReceiptsand full blocks fromchain.start_blockto the tip. A gnosis-node host serves both on8545and8546. - NATS with JetStream.
- Go 1.26 to build from source, or Docker.
The tracker keeps its state in a BoltDB file at db/tracker_db, relative to the working directory. It needs no database server.
Start NATS
For development, run one NATS server with JetStream on port 4222:
git clone https://github.com/cosmo-local-credit/eth-tracker.git
cd eth-tracker/dev
docker compose up -dFor production, deploy/nats/ has a three-node cluster, with one Compose file per host. Create the cluster Docker network on each host, then run docker compose -f deploy/nats/docker-compose-N.yaml up -d on host N. Set jetstream.stream_replicas to 3.
Configure
The tracker reads config.toml. Set -config to use another file. Environment variables with the TRACKER_ prefix override file values, with two underscores between section and key: TRACKER_CHAIN__RPC_ENDPOINT sets chain.rpc_endpoint. Separate list items with commas. A list with one item needs a trailing comma, such as nats://nats:4222,.
Chain
| Setting | What it controls |
|---|---|
chain.rpc_endpoint | HTTP JSON-RPC URL for blocks, receipts and contract calls. |
chain.ws_endpoint | WebSocket URL for new block heads. Required. |
chain.chainid | 100 for Gnosis. Used to recover transaction senders. |
chain.start_block | First block on the first run. 0 starts at the current tip. Ignored once db/tracker_db exists. |
chain.pool_settlement_block | First block where POOL_SWAP is read from SwapSettlement instead of Swap. 0 reads Swap only. |
Tracked contracts
The tracker only decodes logs from addresses it tracks. On first start it reads each registry in bootstrap.ge_registry. It tracks the registry's account, token and pool indexes, every entry in them, and each pool's quoter, token registry, fee policy and protocol fee controller. Later starts load the saved list and refresh it in the background.
| Setting | What it controls |
|---|---|
bootstrap.ge_registry | Registry contracts to read. Required, even with a watchlist. |
bootstrap.watchlist | If set, track only these addresses and skip the registries. |
bootstrap.blacklist | Addresses to stop tracking at startup. |
bootstrap.contracts | Addresses to always track, such as the ERC1967Factory. |
bootstrap.custodial_registration_address | Checksummed address. register(address) calls to it publish CUSTODIAL_REGISTRATION instead of INDEX_ADD. |
New vouchers, pools and Safes are tracked as their creation or registration events arrive.
JetStream
| Setting | What it controls |
|---|---|
jetstream.endpoint | NATS URLs, as a TOML array. Unset means nats://127.0.0.1:4222. |
jetstream.persist_duration_hrs | Hours the TRACKER stream keeps events. |
jetstream.dedup_window_hrs | Hours JetStream drops duplicate message IDs. Keep it equal to persist_duration_hrs. |
jetstream.stream_replicas | 1, or 3 for the cluster. |
publisher.max_retries | Publish attempts per event. |
publisher.circuit_breaker_threshold | Consecutive publish failures before publishing pauses. |
publisher.circuit_breaker_timeout_s | Seconds publishing stays paused. |
WARNING
The example config.toml sets jetstream.endpoints. The tracker reads jetstream.endpoint, so rename the key before you point it at another NATS server.
Workers
| Setting | What it controls |
|---|---|
api.address | Listen address for /health, /stats and /metrics. |
core.pool_size | Block workers. 0 means three per CPU. |
core.batch_size | Missing blocks queued per backfill scan. |
core.max_block_retries | Attempts before a block moves to the dead-letter queue. Must be above zero. |
Keep core.cache_type = "internal" and core.db_type = "bolt". core.reorg_depth_limit, jetstream.enable and redis.dsn are not read.
Run
From source:
make build
./eth-tracker -config config.tomlWith Docker, mount the config and a volume for the database:
docker run -d --name eth-tracker \
-v "$PWD/config.toml:/service/config.toml:ro" \
-v tracker-db:/service/db \
-p 5001:5001 \
ghcr.io/cosmo-local-credit/eth-tracker:<tag>On startup the tracker reads the registries, then catches up from chain.start_block to the tip. It follows new blocks only after the catch-up finishes. A first start with a cold cache can take several minutes before the first block.
Verify
curl -s localhost:5001/health
curl -s localhost:5001/stats
nats stream info TRACKER
nats subscribe 'TRACKER.*'/health returns {"nats":true,"syncer":true}, or HTTP 503 if either is false. /stats returns the latest block, queue size, active workers and the number of tracked addresses. The log prints block stats every 15 seconds.
Operate
- A restart resumes after the last completed block.
- A block that fails is retried up to
core.max_block_retriestimes, then moved to the dead-letter queue. The backfill scan, which runs every minute, queues it again. - The tracker does not handle chain reorganizations.
- To start again from another block, stop the tracker, delete
db/tracker_db, setchain.start_block, and start it. /metricsserves Go runtime metrics in Prometheus format.