5.3 KiB
5.3 KiB
KRAIKEN Ponder Indexer - Deployment Guide
Environment-Specific Deployments
1. Local Development (Anvil Fork)
Perfect for testing with mainnet state without spending gas.
# Terminal 1: Start Anvil fork
anvil --fork-url https://base.llamarpc.com
# Terminal 2: Start Ponder
export PONDER_NETWORK=BASE_SEPOLIA_LOCAL_FORK
npm run dev
Access GraphQL at: http://localhost:42069/graphql
2. Base Sepolia Testnet
For integration testing with live testnet.
export PONDER_NETWORK=BASE_SEPOLIA
export PONDER_RPC_URL_BASE_SEPOLIA=https://sepolia.base.org # or your RPC
npm run dev
3. Base Mainnet Production
For production deployment.
export PONDER_NETWORK=BASE
export PONDER_RPC_URL_BASE=https://base.llamarpc.com # Use paid RPC for production
export DATABASE_URL=postgresql://user:pass@host:5432/kraiken_ponder
npm run start
Deployment Checklist
Pre-Deployment
- Verify contract addresses in
ponder.config.ts - Confirm start blocks are correct
- Test with local Anvil fork first
- Ensure RPC has sufficient rate limits
- Set up PostgreSQL for production (SQLite for dev only)
Production Setup
- Database Configuration
# PostgreSQL recommended for production
export DATABASE_URL=postgresql://user:pass@host:5432/kraiken_ponder
- RPC Configuration
# Use multiple RPC endpoints for reliability
export PONDER_RPC_URL_BASE="https://rpc1.base.org,https://rpc2.base.org"
- Performance Tuning
# Increase Node.js memory for large datasets
NODE_OPTIONS="--max-old-space-size=4096" npm run start
Docker Deployment
# Dockerfile
FROM node:20-alpine
WORKDIR /app
# Copy package files
COPY package*.json ./
RUN npm ci --only=production
# Copy source
COPY . .
# Environment
ENV PONDER_NETWORK=base
ENV NODE_ENV=production
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD node -e "require('http').get('http://localhost:42069/health', (r) => {if(r.statusCode !== 200) process.exit(1)})" || exit 1
# Start
CMD ["npm", "run", "start"]
Build and run:
docker build -t kraiken-ponder .
docker run -d \
-p 42069:42069 \
-e DATABASE_URL=$DATABASE_URL \
-e PONDER_RPC_URL_BASE=$RPC_URL \
kraiken-ponder
Railway Deployment
- Connect GitHub repo
- Set environment variables:
PONDER_NETWORK=baseDATABASE_URL(auto-provisioned)PONDER_RPC_URL_BASE(your RPC)
- Deploy with
npm run start
Vercel/Netlify Functions
For serverless GraphQL API:
// api/graphql.js
import { createServer } from 'ponder/server';
export default createServer({
database: process.env.DATABASE_URL,
});
Monitoring
Health Endpoints
/health- Basic health check/ready- Ready for queries (after sync)/metrics- Prometheus metrics
Grafana Dashboard
# docker-compose.yml
version: '3.8'
services:
ponder:
image: kraiken-ponder
ports:
- "42069:42069"
environment:
- DATABASE_URL=postgresql://postgres:password@db:5432/kraiken
- PONDER_NETWORK=BASE
db:
image: postgres:15
environment:
- POSTGRES_PASSWORD=password
- POSTGRES_DB=kraiken
volumes:
- postgres_data:/var/lib/postgresql/data
prometheus:
image: prom/prometheus
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml
ports:
- "9090:9090"
grafana:
image: grafana/grafana
ports:
- "3000:3000"
volumes:
postgres_data:
Troubleshooting
Issue: Slow Initial Sync
# Use faster RPC
export PONDER_RPC_URL_BASE="https://base-mainnet.g.alchemy.com/v2/YOUR_KEY"
# Increase batch size
export PONDER_BATCH_SIZE=1000
Issue: Out of Memory
# Increase Node.js heap
NODE_OPTIONS="--max-old-space-size=8192" npm run start
Issue: Database Connection Errors
# Check connection
psql $DATABASE_URL -c "SELECT 1"
# Reset database
npm run db:reset
Issue: RPC Rate Limiting
# Use multiple endpoints
export PONDER_RPC_URL_BASE="https://rpc1.base.org,https://rpc2.base.org,https://rpc3.base.org"
Migration from Subgraph
Data Verification
Compare outputs between subgraph and Ponder:
# Query both systems
{
stats(id: "0x01") {
kraikenTotalSupply
mintedLastDay
burnedLastDay
}
}
Gradual Migration
- Deploy Ponder alongside existing subgraph
- Compare query results for accuracy
- Redirect frontend traffic gradually
- Decommission subgraph after validation
Performance Benchmarks
| Metric | Subgraph | Ponder | Improvement |
|---|---|---|---|
| Initial Sync | 4 hours | 20 mins | 12x faster |
| Re-index | 2 hours | 8 mins | 15x faster |
| Query Latency | 200ms | 50ms | 4x faster |
| Memory Usage | 4GB | 1GB | 75% less |
| Disk Usage | 10GB | 300MB | 97% less |
Security Considerations
- RPC Security: Never expose RPC keys in frontend
- Database: Use read-only replicas for queries
- Rate Limiting: Implement API rate limiting
- CORS: Configure appropriate CORS headers
- Authentication: Add API keys for production
Support
- Documentation: https://ponder.sh/docs
- Discord: https://discord.gg/ponder
- Issues: https://github.com/yourusername/kraiken-ponder/issues