Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(eventindexer, blobstorage): improved configuration and README documentation #16652

Closed
wants to merge 17 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/blobstorage/docker-compose/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ services:
restart: always
environment:
- MYSQL_DATABASE=blobs
- MYSQL_ROOT_PASSWORD=passw00d
- MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
- MYSQL_ALLOW_EMPTY_PASSWORD=yes
ports:
- "3306:3306"
volumes:
Expand Down
3 changes: 2 additions & 1 deletion packages/blobstorage/python_query.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import mysql.connector

def query_blob_hash(collection_name, blob_hash):
Expand All @@ -6,7 +7,7 @@ def query_blob_hash(collection_name, blob_hash):
connection = mysql.connector.connect(
host='localhost',
user='root', # Update with your username
password='passw00d', # Update with your password
password=os.getenv('MYSQL_ROOT_PASSWORD'), # Update with your password
database='blobs' # Update with your database name
)

Expand Down
16 changes: 8 additions & 8 deletions packages/eventindexer/.default.env
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
HTTP_PORT=4101
PROMETHEUS_HTTP_PORT=6061
MYSQL_USER=root
MYSQL_PASSWORD=root
MYSQL_DATABASE=eventindexer
MYSQL_HOST=localhost:3306
MYSQL_MAX_IDLE_CONNS=50
MYSQL_MAX_OPEN_CONNS=3000
MYSQL_CONN_MAX_LIFETIME_IN_MS=100000
DATABASE_USER=
DATABASE_PASSWORD=
DATABASE_NAME=eventindexer
DATABASE_HOST=localhost:3306
DATABASE_MAX_IDLE_CONNS=50
DATABASE_MAX_OPEN_CONNS=3000
DATABASE_CONN_MAX_LIFETIME_IN_MS=100000
L1_TAIKO_ADDRESS=0x7B3AF414448ba906f02a1CA307C56c4ADFF27ce7
BRIDGE_ADDRESS=0x7D992599E1B8b4508Ba6E2Ba97893b4C36C23A28
SWAP_ADDRESS=0x501f63210aE6D7Eeb50DaE74DA5Ae407515ee246
RPC_URL=wss://l1ws.a2.taiko.xyz
CORS_ORIGINS=*
BLOCK_BATCH_SIZE=10
BLOCK_BATCH_SIZE=10
2 changes: 1 addition & 1 deletion packages/eventindexer/.l1.env
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ BLOCK_BATCH_SIZE=100
CACHE_INTERVAL_IN_SECONDS=60
LAYER=l1
GENESIS_DATE=2023-12-27
REGENERATE=true
REGENERATE=true
57 changes: 50 additions & 7 deletions packages/eventindexer/README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,58 @@
[![Golang](https://github.com/taikoxyz/taiko-mono/actions/workflows/golang.yml/badge.svg)](https://github.com/taikoxyz/taiko-mono/actions/workflows/golang.yml)
[![Relayer](https://codecov.io/gh/taikoxyz/taiko-mono/branch/main/graph/badge.svg?token=E468X2PTJC&flag=relayer)](https://codecov.io/gh/taikoxyz/taiko-mono)
# eventindexer

# Indexer
Repository dedicated to capturing events, storing them in a database for API queries.

Catches events, stores them in the database to be queried via API.
## Prerequisites

## Running the app
- Docker engine should be operational.
- Ensure Go is installed on the system.

run `cp .default.env .env`, and add your own private key as `RELAYER_ECDSA_KEY` in `.env`. You need to be running a MySQL instance, and replace all the `MYSQL_` env vars with yours.
## Configuration and Setup

Run `go run cmd/main.go --help` to see a list of possible configuration flags, or `go run cmd/main.go` to run with defaults, which will process messages from L1 to L2, and from L2 to L1, and start indexing blocks from 0.
### MySQL Setup

1. **Start MySQL** by navigating to the `docker-compose` directory and executing:

```bash
cd ./docker-compose
docker-compose up -d
```

2. **Migrate Database Schema** within the `migrations` folder:

```bash
cd ./migrations
goose mysql "<user>:<password>@tcp(localhost:3306)/eventindexer" status
goose mysql "<user>:<password>@tcp(localhost:3306)/eventindexer" up
```

### Environment Configuration

Configure `.l1.env`, `.l2.env`, and `.default.env` files with the necessary database credentials and other variables.

## Running the Application

Start various components by specifying the environment file with `EVENTINDEXER_ENV_FILE`:

- **Indexer**:

```bash
EVENTINDEXER_ENV_FILE=.default.env go run cmd/main.go indexer
```

- **API**:

```bash
EVENTINDEXER_ENV_FILE=.default.env go run cmd/main.go api
```

- **Generator**:

```bash
EVENTINDEXER_ENV_FILE=.l1.env go run cmd/main.go generator
```

Choose between `.default.env`, `.l1.env`, or `.l2.env` as per the requirement.

# Block data

Expand Down
15 changes: 15 additions & 0 deletions packages/eventindexer/docker-compose/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: "3.8"
services:
db:
image: mysql:8.0
cap_add:
- SYS_NICE
restart: always
environment:
- MYSQL_DATABASE=eventindexer
- MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
- MYSQL_ALLOW_EMPTY_PASSWORD=yes
ports:
- "3306:3306"
volumes:
- ~/.docker-conf/mysql/data/:/var/lib/mysql
Loading