Skip to content

Repository files navigation

ChainScope EVM Indexer

Go chain indexer for Roburna testnet (Phase 1).

Quick Start

Option 1: Docker Compose (Recommended)

cd chain-indexer
docker-compose up -d

This will start:

  • PostgreSQL database
  • Redis cache
  • The indexer service

Option 2: Manual Build and Run

# Build
cd chain-indexer
go mod tidy
CGO_ENABLED=0 go build -o bin/indexer ./cmd/indexer

# Run with environment variables
RPC_URL=https://preseed-testnet-1.roburna.com/ DB_URL=postgresql://postgres:postgres@localhost:5432/chainscope ./bin/indexer

Option 3: Windows Batch Script

.\run-supabase.bat

Environment Variables

Variable Required Default Description
RPC_URL Yes - EVM chain RPC endpoint
DB_URL Yes - PostgreSQL connection string
REDIS_URL No redis://localhost:6379 Redis connection string
CHAIN_ID No auto-detect Override chain ID
START_BLOCK No 0 Starting block for backfill
BATCH_SIZE No 100 Blocks per batch
WORKERS No 4 Concurrent workers

Configuration File (Optional)

Create config.yaml for defaults:

rpc_url: https://preseed-testnet-1.roburna.com/
chain_id: 159
db_url: postgres://postgres:postgres@localhost:5432/chainscope
redis_url: redis://localhost:6379
start_block: 0
batch_size: 100
workers: 4

Environment variables override config file values.

Requirements

  • PostgreSQL 16+ (or Docker)
  • Redis 7+ (or Docker)
  • Go 1.22+

Monitoring

# View live logs
docker-compose logs -f indexer

# Check service status
docker-compose ps

# View database data
docker exec -it chain-indexer-postgres-1 psql -U postgres -d chainscope

# Stop the system
docker-compose down

# Restart services
docker-compose restart

Database Schema

The indexer creates the following tables:

  • blocks - Block headers and metadata
  • transactions - Transaction details
  • logs - Event logs from smart contracts
  • sync_state - Indexer synchronization state

Troubleshooting

Database Connection Issues

If you see connection errors, ensure PostgreSQL is running:

# Check if containers are running
docker-compose ps

# Restart database
docker-compose restart postgres

Schema Issues

If you encounter "value too long" errors, the database schema may need updates:

# Stop indexer
docker-compose stop indexer

# Update schema (if needed)
docker exec -i chain-indexer-postgres-1 psql -U postgres -d chainscope -c "
ALTER TABLE transactions ALTER COLUMN value TYPE TEXT;
ALTER TABLE transactions ALTER COLUMN gas_price TYPE TEXT;
ALTER TABLE transactions ALTER COLUMN gas_fee_cap TYPE TEXT;
ALTER TABLE transactions ALTER COLUMN gas_tip_cap TYPE TEXT;
ALTER TABLE transactions ALTER COLUMN r TYPE TEXT;
ALTER TABLE transactions ALTER COLUMN s TYPE TEXT;
"

# Restart indexer
docker-compose up -d indexer

Performance Tuning

For better performance:

  • Increase BATCH_SIZE for faster backfill
  • Increase WORKERS for parallel processing
  • Use SSD storage for PostgreSQL
  • Tune PostgreSQL configuration for your hardware

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages