Skip to main content

Avail Protocol Mainnet Commands

This page provides useful commands for managing your Avail Protocol node on the Turing Mainnet. These commands help you monitor, troubleshoot, and maintain your validator node effectively.

Environment Variables

# Common environment variables
export AVAIL_VER="v2.3.2.0"
export AVAIL_IMAGE="availj/avail:${AVAIL_VER}"
export AVAIL_DIR="/data/avail"
export AVAIL_DATA="${AVAIL_DIR}/node-data"
export AVAIL_NODE_NAME="your-validator-name"
export AVAIL_P2P_PORT="30333"
export AVAIL_PROMETHEUS_PORT="30334"
export AVAIL_RPC_PORT="9944"

Node Management Commands

Check Node Status

# Check if Docker container is running
docker ps | grep avail

# Check node sync status via RPC
curl -H "Content-Type: application/json" \
-d '{"id":1, "jsonrpc":"2.0", "method": "system_syncState", "params":[]}' \
http://localhost:9944

# Check node health
curl -H "Content-Type: application/json" \
-d '{"id":1, "jsonrpc":"2.0", "method": "system_health", "params":[]}' \
http://localhost:9944

# Check peer count
curl -H "Content-Type: application/json" \
-d '{"id":1, "jsonrpc":"2.0", "method": "system_peers", "params":[]}' \
http://localhost:9944

# Check chain information
curl -H "Content-Type: application/json" \
-d '{"id":1, "jsonrpc":"2.0", "method": "system_chain", "params":[]}' \
http://localhost:9944

View Logs

# View real-time logs (Docker)
docker compose logs -f avail-node

# View recent logs (last 100 lines)
docker compose logs --tail=100 avail-node

# View logs with timestamps
docker compose logs -t avail-node

# Check for errors in logs
docker compose logs avail-node | grep -i error

# View logs for specific time period
docker compose logs --since "1 hour ago" avail-node

# View logs (Binary installation)
sudo journalctl -f -u avail
sudo journalctl -u avail --since "1 hour ago"

Container Management

# Start the validator node
docker compose up -d

# Stop the validator node
docker compose down

# Restart the validator node
docker compose restart

# Check container status
docker compose ps

# View container resource usage
docker stats avail-validator

# View container details
docker inspect avail-validator

Key Management Commands

Generate Session Keys

# Generate new session keys
curl -H "Content-Type: application/json" \
-d '{"id":1, "jsonrpc":"2.0", "method": "author_rotateKeys", "params":[]}' \
http://localhost:9944

# Check current session keys
curl -H "Content-Type: application/json" \
-d '{"id":1, "jsonrpc":"2.0", "method": "author_hasSessionKeys", "params":["YOUR_SESSION_KEYS"]}' \
http://localhost:9944

Network and Connectivity

Check Network Status

# Check if P2P port is open
ss -tulpn | grep :30333

# Check if Prometheus port is open
ss -tulpn | grep :30334

# Check if RPC port is open
ss -tulpn | grep :9944

# Test RPC endpoint connectivity
curl -s http://localhost:9944 -X POST \
-H "Content-Type: application/json" \
-d '{"id":1, "jsonrpc":"2.0", "method": "system_name", "params":[]}' | jq

Port Testing

# Test external P2P connectivity
nc -zv your-server-ip 30333

# Test local RPC port
nc -zv localhost 9944

# Test Prometheus metrics port
nc -zv localhost 30334

Validator Operations

Validator Status Commands

# Check validator status
curl -H "Content-Type: application/json" \
-d '{"id":1, "jsonrpc":"2.0", "method": "author_hasSessionKeys", "params":["YOUR_SESSION_KEYS"]}' \
http://localhost:9944

# Get current session keys
curl -H "Content-Type: application/json" \
-d '{"id":1, "jsonrpc":"2.0", "method": "author_rotateKeys", "params":[]}' \
http://localhost:9944

# Check if validator is in active set
curl -H "Content-Type: application/json" \
-d '{"id":1, "jsonrpc":"2.0", "method": "session_validators", "params":[]}' \
http://localhost:9944

Account Information

# Get account balance
curl -H "Content-Type: application/json" \
-d '{"id":1, "jsonrpc":"2.0", "method": "system_accountNextIndex", "params":["YOUR_ACCOUNT_ADDRESS"]}' \
http://localhost:9944

# Get account information
curl -H "Content-Type: application/json" \
-d '{"id":1, "jsonrpc":"2.0", "method": "system_account", "params":["YOUR_ACCOUNT_ADDRESS"]}' \
http://localhost:9944

System Monitoring

Resource Usage

# Check disk usage
df -h $AVAIL_DATA

# Check memory usage
free -h

# Check CPU usage
top -p $(pgrep -f avail)

# Check system load
uptime

# Check available disk space
du -sh $AVAIL_DATA

Performance Monitoring

# Monitor container resources (Docker)
docker stats avail-validator --no-stream

# Check system performance
htop

# Monitor disk I/O
iotop -ao

# Check network usage
iftop -i eth0

# Monitor memory usage per process
ps aux --sort=-%mem | head -10

Prometheus Metrics

# Get all metrics
curl -s http://localhost:30334/metrics

# Get specific metrics
curl -s http://localhost:30334/metrics | grep avail_

# Get block height metric
curl -s http://localhost:30334/metrics | grep block_height

# Get peer count metric
curl -s http://localhost:30334/metrics | grep peer_count

# Get sync status metrics
curl -s http://localhost:30334/metrics | grep sync_

Blockchain Information

Block Information

# Get latest block number
curl -H "Content-Type: application/json" \
-d '{"id":1, "jsonrpc":"2.0", "method": "chain_getHeader", "params":[]}' \
http://localhost:9944

# Get specific block by number
curl -H "Content-Type: application/json" \
-d '{"id":1, "jsonrpc":"2.0", "method": "chain_getBlockHash", "params":[BLOCK_NUMBER]}' \
http://localhost:9944

# Get block by hash
curl -H "Content-Type: application/json" \
-d '{"id":1, "jsonrpc":"2.0", "method": "chain_getBlock", "params":["BLOCK_HASH"]}' \
http://localhost:9944

# Get finalized head
curl -H "Content-Type: application/json" \
-d '{"id":1, "jsonrpc":"2.0", "method": "chain_getFinalizedHead", "params":[]}' \
http://localhost:9944

Runtime Information

# Get runtime version
curl -H "Content-Type: application/json" \
-d '{"id":1, "jsonrpc":"2.0", "method": "state_getRuntimeVersion", "params":[]}' \
http://localhost:9944

# Get runtime metadata
curl -H "Content-Type: application/json" \
-d '{"id":1, "jsonrpc":"2.0", "method": "state_getMetadata", "params":[]}' \
http://localhost:9944

# Get node properties
curl -H "Content-Type: application/json" \
-d '{"id":1, "jsonrpc":"2.0", "method": "system_properties", "params":[]}' \
http://localhost:9944

Troubleshooting Commands

Common Issues

Node Not Syncing

# Check sync state
curl -H "Content-Type: application/json" \
-d '{"id":1, "jsonrpc":"2.0", "method": "system_syncState", "params":[]}' \
http://localhost:9944

# Check peer connections
curl -H "Content-Type: application/json" \
-d '{"id":1, "jsonrpc":"2.0", "method": "system_health", "params":[]}' \
http://localhost:9944

# Restart node to reset connections
docker compose restart avail-node

Container Issues

# Check Docker daemon status
sudo systemctl status docker

# View detailed container information
docker inspect avail-validator

# Check container logs for errors
docker compose logs avail-node | grep -i "error\|fatal\|panic"

# Check resource constraints
docker stats avail-validator

Log Analysis

# Search for specific errors
docker compose logs avail-node | grep -i "error"

# Search for warnings
docker compose logs avail-node | grep -i "warn"

# Search for sync-related messages
docker compose logs avail-node | grep -i "sync\|import"

# Search for peer-related messages
docker compose logs avail-node | grep -i "peer\|connection"

# Search for validator-related messages
docker compose logs avail-node | grep -i "validator\|authority"

Maintenance Commands

Cleanup Commands

# Clean up old Docker images
docker image prune -f

# Clean up unused volumes
docker volume prune -f

# Clean up old logs
sudo journalctl --vacuum-time=7d

# Clean up system logs (Docker)
docker system prune -f

Update Commands

export NEW_VERSION="v2.3.2.0"
export AVAIL_IMAGE="availj/avail:${NEW_VERSION}"

# Update environment file
sed -i "s/AVAIL_IMAGE=.*/AVAIL_IMAGE=${AVAIL_IMAGE}/" .env

# Pull new image and restart
docker compose pull
docker compose up -d

# Update Avail node (Binary)
cd /tmp
wget https://github.com/availproject/avail/releases/download/${NEW_VERSION}/avail-node-ubuntu-2404-x86_64.tar.gz
tar -xzf avail-node-ubuntu-2404-x86_64.tar.gz
sudo systemctl stop avail
sudo mv avail-node ${AVAIL_DIR}/
sudo systemctl start avail

Quick Reference

Essential Commands

CommandPurpose
docker compose logs -fView real-time logs
docker compose psCheck container status
docker compose restartRestart the node
curl localhost:9944 -X POST -H "Content-Type: application/json" -d '{"id":1, "jsonrpc":"2.0", "method": "system_syncState", "params":[]}'Check sync status
curl localhost:30334/metricsView Prometheus metrics
ss -tulpn | grep :30333Check if P2P port is open

Important RPC Methods

MethodPurpose
system_syncStateGet synchronization status
system_healthGet node health information
system_peersGet connected peers information
author_rotateKeysGenerate new session keys
chain_getHeaderGet latest block header

tip

Pro Tips:

  • Always backup your node data before major updates
  • Monitor your node regularly using Prometheus metrics
  • Keep your system and Docker updated
  • Join the Avail community for support and updates
  • Use screen or tmux for long-running commands
warning

Safety Notes:

  • Never expose RPC ports to the internet without proper authentication
  • Backup your session keys securely
  • Monitor disk space regularly
  • Be cautious when running cleanup commands