Documentation

Run Archive Node

Setup archive node with full blockchain history

Archive nodes store complete blockchain history without pruning. Required for block explorers, indexers, and historical data queries.

Current size: ~1.8TB. Growth: 50-100GB/month. NVMe SSD essential.

Archive vs Full Node

FeatureFull NodeArchive Node
Storage~200GB~2TB+
Sync Time4-8 hours24-48 hours
Historical QueriesLast 256 blocksComplete history
Use CasesdApp backendExplorer, analytics
Cloud Cost$50-90/mo$280-420/mo

Prerequisites

Ubuntu 22.04/Debian 12, 32GB RAM minimum, 2TB+ NVMe SSD, 100 Mbps internet, sudo access.


Installation

System Prep

# Verify storage
df -h
lsblk && nvme list

# Install dependencies
sudo apt update && sudo apt install -y wget curl

Download Binary

wget https://github.com/selendra/selendra/releases/latest/download/selendra
chmod +x selendra && sudo mv selendra /usr/local/bin/
selendra --version

Storage Setup

# Format NVMe (WARNING: destroys data)
sudo mkfs.ext4 /dev/nvme0n1

# Mount with optimization
sudo mkdir -p /mnt/archive
sudo mount /dev/nvme0n1 /mnt/archive
echo "/dev/nvme0n1 /mnt/archive ext4 defaults,noatime,nodiratime 0 2" | sudo tee -a /etc/fstab

# Create data directory
sudo mkdir -p /mnt/archive/selendra
sudo useradd -r -s /bin/false selendra
sudo chown selendra:selendra /mnt/archive/selendra

Configuration

Create /etc/systemd/system/selendra-archive.service:

[Unit]
Description=Selendra Archive Node
After=network.target

[Service]
Type=simple
User=selendra
Group=selendra
WorkingDirectory=/mnt/archive/selendra
ExecStart=/usr/local/bin/selendra \
  --base-path /mnt/archive/selendra \
  --chain mainnet \
  --name "YourArchiveNode" \
  --pruning archive \
  --state-cache-size 8 \
  --db-cache 4096 \
  --rpc-cors all \
  --rpc-methods safe \
  --rpc-max-connections 200 \
  --ws-max-connections 200 \
  --port 30333 \
  --rpc-port 9933 \
  --ws-port 9944 \
  --prometheus-port 9615 \
  --prometheus-external

Restart=on-failure
RestartSec=10
LimitNOFILE=65536

[Install]
WantedBy=multi-user.target

Key archive parameters:

  • --pruning archive: Disables pruning (keeps full history)
  • --state-cache-size 8: Use 25-50% of available RAM
  • --db-cache 4096: Database cache in MB
  • --rpc-max-connections 200: Higher limit for public access

Start & Sync

sudo systemctl daemon-reload
sudo systemctl enable --now selendra-archive
sudo journalctl -u selendra-archive -f

Sync time: 24-48 hours (50-100 blocks/sec average)

Verify archive mode:

sudo journalctl -u selendra-archive | grep -i archive
curl -H "Content-Type: application/json" \
  -d '{"id":1, "jsonrpc":"2.0", "method":"system_properties"}' \
  http://localhost:9933

Public RPC (Optional)

Nginx Reverse Proxy

upstream selendra_rpc { server localhost:9933; keepalive 32; }
upstream selendra_ws { server localhost:9944; keepalive 32; }

server {
    listen 443 ssl http2;
    server_name rpc.yourdomain.com;
    ssl_certificate /path/to/fullchain.pem;
    ssl_certificate_key /path/to/privkey.pem;

    limit_req_zone $binary_remote_addr zone=rpc_limit:10m rate=10r/s;
    limit_req zone=rpc_limit burst=20 nodelay;

    location / {
        proxy_pass http://selendra_rpc;
        proxy_http_version 1.1;
        proxy_set_header Connection "";
        add_header Access-Control-Allow-Origin *;
    }

    location /ws {
        proxy_pass http://selendra_ws;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }
}

DDoS Protection

sudo apt install -y fail2ban

Create /etc/fail2ban/filter.d/nginx-rpc.conf:

[Definition]
failregex = ^<HOST> .* "(GET|POST) .*" (?:429|503)

Add jail to /etc/fail2ban/jail.local:

[nginx-rpc]
enabled = true
port = http,https
filter = nginx-rpc
logpath = /var/log/nginx/access.log
maxretry = 100
findtime = 60
bantime = 3600

Historical Queries

Query old block:

curl -H "Content-Type: application/json" \
  -d '{"id":1, "jsonrpc":"2.0", "method":"chain_getBlock", "params":["0xBLOCKHASH"]}' \
  http://localhost:9933

Historical state:

curl -H "Content-Type: application/json" \
  -d '{"id":1, "jsonrpc":"2.0", "method":"state_getStorage", "params":["KEY", "BLOCKHASH"]}' \
  http://localhost:9933

Monitoring

Storage Growth

# Check size
du -sh /mnt/archive/selendra
df -h /mnt/archive

# Automated alerts (add to crontab)
0 0 * * * df -h /mnt/archive | mail -s "Archive Storage" admin@yourdomain.com

Growth planning:

  • Current: 1.8TB
  • 1 year: 2.4-3.0TB
  • 2 years: 3.0-4.2TB

Key Metrics

curl http://localhost:9615/metrics | grep -E "database_cache|state_cache|peers_count"

Maintenance

Storage Expansion

Add storage at 80% full:

sudo mkfs.ext4 /dev/nvme1n1
sudo mkdir -p /mnt/archive2
sudo systemctl stop selendra-archive
sudo rsync -avP /mnt/archive/selendra /mnt/archive2/
# Update fstab and systemd service
sudo systemctl start selendra-archive

Backup (Snapshot Method)

# LVM snapshot
sudo lvcreate -L 50G -s -n selendra-snapshot /dev/vg/archive
sudo dd if=/dev/vg/selendra-snapshot | gzip > selendra-archive-$(date +%Y%m%d).img.gz
sudo lvremove /dev/vg/selendra-snapshot

Use Cases

Block Explorer: Complete transaction and block history
Analytics: Statistical analysis across full chain history
Indexing: Build searchable databases for fast queries


Cost Analysis

Cloud Hosting (Monthly)

ProviderInstanceCost
AWSi3.2xlarge~$600
Google Cloudn2-highmem-8 + SSD~$450
HetznerAX102 dedicated~$250
OVHRise-4 + storage~$300

Self-Hosted

Initial: $3,000-4,500 (hardware + 2yr storage)
Operating: $70-140/mo (power + internet)
Break-even: 12-18 months vs cloud


Hardware Requirements | Run Full Node | Monitoring | Maintenance

Community

Telegram: t.me/selendranetwork | X: @selendranetwork | GitHub: github.com/selendra/selendra

Contribute

Found an issue or want to contribute?

Help us improve this documentation by editing this page on GitHub.

Edit this page on GitHub
Selendra - Build on Cambodian Blockchain with Testnet