# SMOM-DBIS-138 Proxmox VE LXC Deployment

Complete Proxmox VE LXC container deployment for the DeFi Oracle Meta Mainnet (ChainID 138) blockchain infrastructure.

## 📋 Overview

This deployment package provides complete automation for deploying the smom-dbis-138 blockchain network on Proxmox VE using LXC containers. It maintains all connections, ensures upgradeability, and provides comprehensive management tools.

## 🏗️ Architecture

### Container Layout

```
┌─────────────────────────────────────────────────────────────┐
│                    Proxmox VE Host                          │
├─────────────────────────────────────────────────────────────┤
│                                                             │
│  ┌──────────────┐  ┌──────────────┐  ┌──────────────┐    │
│  │   Validator  │  │   Sentry     │  │   RPC Node   │    │
│  │   Containers │  │  Containers  │  │  Containers  │    │
│  │   (4+ nodes) │  │  (3-5 nodes) │  │  (3-5 nodes) │    │
│  └──────────────┘  └──────────────┘  └──────────────┘    │
│                                                             │
│  ┌──────────────┐  ┌──────────────┐  ┌──────────────┐    │
│  │   Oracle     │  │  CCIP Monitor│  │  Monitoring  │    │
│  │  Publisher   │  │   Service    │  │    Stack     │    │
│  └──────────────┘  └──────────────┘  └──────────────┘    │
│                                                             │
│  ┌──────────────┐  ┌──────────────┐  ┌──────────────┐    │
│  │  Blockscout  │  │   Keeper     │  │  Hyperledger │    │
│  │   Explorer   │  │   Service    │  │   Services   │    │
│  └──────────────┘  └──────────────┘  │ (Firefly,    │    │
│                                        │  Cacti,      │    │
│                                        │  Fabric,     │    │
│                                        │  Indy)       │    │
│                                        └──────────────┘    │
│                                                             │
└─────────────────────────────────────────────────────────────┘
```

## 🚀 Quick Start

### Prerequisites

1. **Proxmox VE** (7.0 or later)
2. **Storage** with at least 500GB available
3. **Network** with VLAN support (optional but recommended)
4. **API Access** enabled in Proxmox

### Installation

1. **Clone/Copy this directory** to your Proxmox host or management machine

2. **Configure deployment**:
```bash
cd smom-dbis-138-proxmox
cp config/proxmox.conf.example config/proxmox.conf
# Edit config/proxmox.conf with your Proxmox details
```

3. **Run deployment**:
```bash
./scripts/deployment/deploy-all.sh
```

## 📁 Directory Structure

```
smom-dbis-138-proxmox/
├── README.md                    # This file
├── config/
│   ├── proxmox.conf.example     # Proxmox connection config template
│   ├── network.conf.example     # Network configuration template
│   └── inventory.example        # Container inventory template
├── scripts/
│   ├── deployment/
│   │   ├── deploy-all.sh        # Main deployment orchestration
│   │   ├── deploy-besu-nodes.sh # Besu node deployment
│   │   ├── deploy-hyperledger-services.sh # Hyperledger services deployment
│   │   ├── deploy-services.sh   # Service deployment
│   │   └── deploy-monitoring.sh # Monitoring stack deployment
│   ├── upgrade/
│   │   ├── upgrade-all.sh       # Upgrade orchestration
│   │   └── upgrade-node.sh      # Individual node upgrade
│   ├── backup/
│   │   ├── backup-all.sh        # Full backup
│   │   └── restore.sh           # Restore from backup
│   └── network/
│       ├── setup-network.sh     # Network configuration
│       └── update-static-nodes.sh # Update peer list
├── install/
│   ├── besu-validator-install.sh
│   ├── besu-sentry-install.sh
│   ├── besu-rpc-install.sh
│   ├── firefly-install.sh
│   ├── cacti-install.sh
│   ├── fabric-install.sh
│   ├── indy-install.sh
│   ├── oracle-publisher-install.sh
│   ├── ccip-monitor-install.sh
│   └── monitoring-install.sh
├── templates/
│   └── lxc-config.template      # LXC container template
├── lib/
│   ├── proxmox-api.sh           # Proxmox API functions
│   ├── common.sh                # Common functions
│   └── validation.sh            # Validation functions
└── docs/
    ├── DEPLOYMENT.md            # Detailed deployment guide
    ├── UPGRADE.md               # Upgrade procedures
    ├── NETWORKING.md            # Network configuration
    └── TROUBLESHOOTING.md       # Troubleshooting guide
```

## 🔧 Configuration

### Proxmox Connection (`config/proxmox.conf`)

```bash
PROXMOX_HOST="proxmox.example.com"
PROXMOX_PORT="8006"
PROXMOX_USER="root@pam"
PROXMOX_TOKEN_NAME="smom-dbis-138"
PROXMOX_TOKEN_SECRET="your-token-secret"
PROXMOX_NODE="pve"  # Proxmox node name
PROXMOX_STORAGE="local-lvm"  # Storage pool
PROXMOX_BRIDGE="vmbr0"  # Network bridge
```

### Network Configuration (`config/network.conf`)

```bash
VLAN_VALIDATORS=100
VLAN_SENTRIES=101
VLAN_RPC=102
VLAN_SERVICES=103
SUBNET_BASE="192.168.11"
GATEWAY="192.168.11.1"
```

## 📝 Usage

### Deploy Everything

```bash
./scripts/deployment/deploy-all.sh
```

### Deploy Specific Components

```bash
# Deploy Besu nodes only
./scripts/deployment/deploy-besu-nodes.sh

# Deploy services only
./scripts/deployment/deploy-services.sh

# Deploy monitoring only
./scripts/deployment/deploy-monitoring.sh
```

### Upgrade Components

```bash
# Upgrade all nodes
./scripts/upgrade/upgrade-all.sh

# Upgrade specific node
./scripts/upgrade/upgrade-node.sh besu-validator-1
```

### Backup & Restore

```bash
# Create backup
./scripts/backup/backup-all.sh

# Restore from backup
./scripts/backup/restore.sh /path/to/backup
```

## 🔗 Connections Maintained

✅ **P2P Network** - All nodes maintain peer connections  
✅ **Static Nodes** - Automatically configured  
✅ **Metrics Collection** - Prometheus scrape configs  
✅ **Service Discovery** - Internal DNS/hostname resolution  
✅ **Database State** - Persistent storage for blockchain data  
✅ **Configuration Sync** - Centralized config management  

## 🔄 Upgradeability

✅ **Rolling Upgrades** - Zero-downtime upgrades  
✅ **Version Management** - Track and manage versions  
✅ **Rollback Support** - Quick rollback if issues occur  
✅ **Configuration Migration** - Auto-migrate configs  
✅ **Data Preservation** - Maintain blockchain state  

## 📊 Monitoring

The deployment includes:
- **Prometheus** - Metrics collection
- **Grafana** - Dashboards and visualization
- **Loki** - Log aggregation
- **Alertmanager** - Alert routing
- **Node Exporter** - Host metrics

Access Grafana at: `http://monitoring-container-ip:3000`

## 🔒 Security

- **Network Isolation** - VLAN separation for node types
- **Firewall Rules** - iptables/firewall configuration
- **Key Management** - Secure key storage and rotation
- **Access Control** - SSH key-based access
- **Backup Encryption** - Encrypted backups

## 📚 Documentation

- [Deployment Guide](docs/DEPLOYMENT.md)
- [Upgrade Procedures](docs/UPGRADE.md)
- [Network Configuration](docs/NETWORKING.md)
- [Troubleshooting](docs/TROUBLESHOOTING.md)

## 🆘 Support

For issues or questions:
1. Check [Troubleshooting Guide](docs/TROUBLESHOOTING.md)
2. Review deployment logs in `logs/` directory
3. Check container status: `pct status <vmid>`

## 📄 License

This deployment package is part of the smom-dbis-138 project and follows the same license.

