2024-09-27 13:55:05 +02:00
|
|
|
# eth-tracker
|
2024-09-05 08:48:59 +02:00
|
|
|
|
2024-09-27 13:55:05 +02:00
|
|
|

|
2024-09-05 08:48:59 +02:00
|
|
|
|
2024-10-31 12:58:59 +01:00
|
|
|
A fast and lightweight tracker designed to monitor EVM blockchains for live and
|
|
|
|
historical transaction events, including reverted transactions. It filters these
|
|
|
|
events and publishes them to NATS for further processing.
|
2024-09-05 08:48:59 +02:00
|
|
|
|
2024-11-21 16:18:02 +01:00
|
|
|
On a warmed up archive RPC node (HTTP) with the default config, it can process
|
|
|
|
in excess of 10k blocks/min utilizing not more than 50 MB of RAM.
|
|
|
|
|
2024-10-31 12:58:59 +01:00
|
|
|
It applies deduplication at the NATS level, making it safe to run in a
|
|
|
|
distributed fashion.
|
2024-09-05 08:48:59 +02:00
|
|
|
|
2024-10-31 12:58:59 +01:00
|
|
|
Note: To run it against an L2/EVM chain, you will need to manually add a replace
|
|
|
|
directive in the `go.mod` file pointing to the EVM chain's `*geth` compatible
|
|
|
|
source code. This will allow the tracker to process transaction types other than
|
|
|
|
Ethereum's `0x0, 0x1 and 0x2`.
|
2024-09-27 14:01:14 +02:00
|
|
|
|
2024-10-04 11:35:35 +02:00
|
|
|
### CEL2
|
|
|
|
|
2024-10-31 12:58:59 +01:00
|
|
|
We maintain a CEL2 compatible tracker (source and container image) on the `cel2`
|
|
|
|
branch.
|
2024-10-04 11:35:35 +02:00
|
|
|
|
2024-09-05 08:48:59 +02:00
|
|
|
## Getting Started
|
|
|
|
|
2024-09-27 13:55:05 +02:00
|
|
|
A `Makefile` is also provided to build the required binaries to run eth-tracker.
|
2024-09-05 08:48:59 +02:00
|
|
|
|
2024-10-31 12:58:59 +01:00
|
|
|
### Cache Bootstrap
|
2024-09-05 08:48:59 +02:00
|
|
|
|
2024-10-31 12:58:59 +01:00
|
|
|
During startup `eth-tracker` will always build the cache with all relevant
|
|
|
|
Grassroots Economics smart contract and user addresses to allow filtering on
|
|
|
|
very busy smart contracts e.g. cUSD.
|
2024-09-05 08:48:59 +02:00
|
|
|
|
|
|
|
The cache will auto-update based on any additions/removals from all indexes.
|
|
|
|
|
|
|
|
### Prerequisites
|
|
|
|
|
2024-10-31 12:58:59 +01:00
|
|
|
- Git
|
|
|
|
- Docker
|
|
|
|
- NATS server
|
2024-11-21 16:18:02 +01:00
|
|
|
- Access to an RPC node, archive preffered
|
2024-09-05 08:48:59 +02:00
|
|
|
|
2024-10-31 12:58:59 +01:00
|
|
|
See [docker-compose.yaml](dev/docker-compose.yaml) for an example on how to run
|
|
|
|
and deploy a single instance.
|
2024-09-05 08:48:59 +02:00
|
|
|
|
|
|
|
### 1. Build the Docker image
|
|
|
|
|
|
|
|
We provide pre-built images for `linux/amd64`. See the packages tab on Github.
|
|
|
|
|
|
|
|
If you are on any other platform:
|
|
|
|
|
|
|
|
```bash
|
2024-09-27 13:28:26 +02:00
|
|
|
git clone https://github.com/grassrootseconomics/eth-tracker.git
|
2024-09-27 13:55:05 +02:00
|
|
|
cd eth-tracker
|
|
|
|
docker buildx build --build-arg BUILD=$(git rev-parse --short HEAD) --tag eth-tracker:$(git rev-parse --short HEAD) --tag eth-tracker:latest .
|
2024-09-05 08:48:59 +02:00
|
|
|
docker images
|
|
|
|
```
|
|
|
|
|
2024-11-21 16:18:02 +01:00
|
|
|
### 2. Run NATS
|
2024-09-05 08:48:59 +02:00
|
|
|
|
|
|
|
For an example, see `dev/docker-compose.yaml`.
|
2024-10-31 12:58:59 +01:00
|
|
|
|
2024-09-05 08:48:59 +02:00
|
|
|
### 3. Update config values
|
|
|
|
|
2024-10-31 12:58:59 +01:00
|
|
|
See `.env.example` on how to override default values defined in `config.toml`
|
|
|
|
using env variables. Alternatively, mount your own config.toml either during
|
|
|
|
build time or Docker runtime.
|
2024-09-05 08:48:59 +02:00
|
|
|
|
|
|
|
```bash
|
|
|
|
# Override only specific config values
|
|
|
|
nano .env.example
|
|
|
|
mv .env.example .env
|
|
|
|
```
|
|
|
|
|
2024-10-31 12:58:59 +01:00
|
|
|
Refer to [`config.toml`](config.toml) to understand different config value
|
|
|
|
settings.
|
2024-09-05 08:48:59 +02:00
|
|
|
|
|
|
|
### 4. Run the tracker
|
|
|
|
|
|
|
|
```bash
|
|
|
|
cd dev
|
|
|
|
docker compose up
|
|
|
|
```
|
|
|
|
|
|
|
|
## Processing NATS messages
|
|
|
|
|
|
|
|
### JSON structure
|
|
|
|
|
|
|
|
```js
|
|
|
|
{
|
|
|
|
"block": Number,
|
|
|
|
"contractAddress": String,
|
|
|
|
"success": Boolean,
|
|
|
|
"timetamp" Number,
|
|
|
|
"transactionHash": String,
|
|
|
|
"transactionType": String,
|
|
|
|
"payload": Object
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
### Monitoring with NATS CLI
|
|
|
|
|
2024-10-31 12:58:59 +01:00
|
|
|
Install NATS CLI from
|
|
|
|
[here](https://github.com/nats-io/natscli?tab=readme-ov-file#installation).
|
2024-09-05 08:48:59 +02:00
|
|
|
|
|
|
|
```bash
|
|
|
|
nats subscribe "TRACKER.*"
|
|
|
|
```
|
|
|
|
|
|
|
|
### DB File
|
|
|
|
|
2024-10-31 12:58:59 +01:00
|
|
|
A `tracker_db` file is created on the first run. This keeps track of all blocks
|
|
|
|
missed by the processor to attempt a retry later on. This file should not be
|
|
|
|
deleted if you want to maintain resume support for historical tracking across
|
|
|
|
restarts.
|
2024-09-05 08:48:59 +02:00
|
|
|
|
|
|
|
## License
|
|
|
|
|
2024-10-31 12:58:59 +01:00
|
|
|
[AGPL-3.0](LICENSE).
|