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 7 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
2 changes: 1 addition & 1 deletion packages/blobstorage/.default.indexer.env
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
RPC_URL=wss://l1ws.hekla.taiko.xyz
BEACON_URL=https://l1beacon.hekla.taiko.xyz
TAIKO_L1_CONTRACT_ADDRESS=0xC069c3d2a9f2479F559AD34485698ad5199C555f
TAIKO_L1_CONTRACT_ADDRESS=0xB20BB9105e007Bd3E0F73d63D4D3dA2c8f736b77
SamiAlHassan marked this conversation as resolved.
Show resolved Hide resolved
DATABASE_HOST=localhost
DATABASE_PORT=3306
DATABASE_USER=
Expand Down
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
24 changes: 12 additions & 12 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
L1_TAIKO_ADDRESS=0x7B3AF414448ba906f02a1CA307C56c4ADFF27ce7
BRIDGE_ADDRESS=0x7D992599E1B8b4508Ba6E2Ba97893b4C36C23A28
SWAP_ADDRESS=0x501f63210aE6D7Eeb50DaE74DA5Ae407515ee246
RPC_URL=wss://l1ws.a2.taiko.xyz
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=0xB20BB9105e007Bd3E0F73d63D4D3dA2c8f736b77
BRIDGE_ADDRESS=0xf458747c6d6db57970dE80Da6474C0A3dfE94BF1
SWAP_ADDRESS=0xD2C3cbB943FEd0Cfc8389b14a3f6df518fD46346
RPC_URL=wss://l1ws.hekla.taiko.xyz
CORS_ORIGINS=*
BLOCK_BATCH_SIZE=10
BLOCK_BATCH_SIZE=10
10 changes: 5 additions & 5 deletions packages/eventindexer/.l1.env
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ DATABASE_HOST=localhost:3306
DATABASE_MAX_IDLE_CONNS=50
DATABASE_MAX_OPEN_CONNS=3000
DATABASE_CONN_MAX_LIFETIME_IN_MS=100000
L1_TAIKO_ADDRESS=0x62Acda3Ad15B382C32B2fB21BEAc9DfB95bbb02F
BRIDGE_ADDRESS=0xa9242c7A736910357384c8Fe92870B74f8cBE784
ASSIGNMENT_HOOK_ADDRESS=0xb190786090Fc4308c4C40808f3bEB55c4463c152
RPC_URL=wss://l1ws.katla.taiko.xyz
L1_TAIKO_ADDRESS=0xB20BB9105e007Bd3E0F73d63D4D3dA2c8f736b77
BRIDGE_ADDRESS=0xf458747c6d6db57970dE80Da6474C0A3dfE94BF1
ASSIGNMENT_HOOK_ADDRESS=0x41e574f051Bd887024B4dEe2a7F684D6936c4488
RPC_URL=wss://l1ws.hekla.taiko.xyz
CORS_ORIGINS=*
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