# Deployment Execution Guide

**Date**: 2025-01-20  
**Deployment Type**: Complete Validated Deployment (Option 1)

## Quick Start

### SSH to ml110 and Run Deployment

```bash
ssh root@192.168.11.10
cd /opt/smom-dbis-138-proxmox
./scripts/deployment/deploy-validated-set.sh --source-project /opt/smom-dbis-138
```

## What the Deployment Script Does

The `deploy-validated-set.sh` script orchestrates the complete deployment in these phases:

### Phase 1: Deploy Containers
- Creates LXC containers for all Besu nodes:
  - 5 Validator containers (VMIDs 1000-1004)
  - 4 Sentry containers (VMIDs 1500-1503)
  - 3 RPC containers (VMIDs 2500-2502)
- Installs Besu on each container
- Configures network settings
- Sets up systemd services

**Timeout**: 1 hour (3600 seconds)

### Phase 2: Copy Configuration
- Copies `genesis.json` to all containers
- Copies validator keys to respective containers
- Copies configuration files (`config-validator.toml`, etc.)
- Copies permissions files (`permissions-nodes.toml`, etc.)
- Sets correct file permissions

**Timeout**: 30 minutes (1800 seconds)

### Phase 3: Bootstrap Network
- Generates `static-nodes.json` with correct enode URLs
- Updates network configuration
- Configures peer discovery
- Sets up initial network connections

**Timeout**: 5 minutes (300 seconds)

### Phase 4: Validation
- Validates container status
- Checks service status
- Verifies configuration files
- Validates key files
- Checks network connectivity

## Expected Duration

- **Full Deployment**: 30-60 minutes
- **Quick Deployment** (containers already exist): 10-15 minutes

## Monitoring Progress

The script provides progress indicators and logs. Watch for:

1. **Container Creation**: Progress for each container
2. **Configuration Copy**: Files being copied to each container
3. **Network Bootstrap**: Enode URL generation
4. **Validation**: Status checks for each component

## Troubleshooting

### If Deployment Fails

1. **Check Logs**: The script logs to stdout/stderr
2. **Verify Prerequisites**:
   ```bash
   # Check source project exists
   ls -la /opt/smom-dbis-138/config/genesis.json
   
   # Check validator keys exist
   ls -la /opt/smom-dbis-138/keys/validators/
   ```

3. **Retry with Skip Options**:
   ```bash
   # If containers already exist, skip deployment
   ./scripts/deployment/deploy-validated-set.sh \
     --source-project /opt/smom-dbis-138 \
     --skip-deployment
   ```

### Common Issues

**Issue**: Containers already exist
- **Solution**: Use `--skip-deployment` flag

**Issue**: Configuration files not found
- **Solution**: Verify source project path: `/opt/smom-dbis-138`

**Issue**: Keys not found
- **Solution**: Ensure validator keys are in `/opt/smom-dbis-138/keys/validators/`

## Alternative: Step-by-Step Deployment

If the automated script fails, deploy manually:

```bash
# Step 1: Deploy containers
./scripts/deployment/deploy-besu-nodes.sh

# Step 2: Copy configuration
./scripts/copy-besu-config.sh /opt/smom-dbis-138

# Step 3: Fix IPs (if needed)
./scripts/fix-container-ips.sh

# Step 4: Bootstrap network
./scripts/network/bootstrap-network.sh

# Step 5: Start services
./scripts/fix-besu-services.sh

# Step 6: Validate
./scripts/validation/validate-deployment-comprehensive.sh
```

## Post-Deployment Verification

After deployment completes, verify:

```bash
# Check container status
pct list | grep -E "100[0-4]|150[0-3]|250[0-2]"

# Check services
pct exec 1000 -- systemctl status besu-validator.service

# Check network
pct exec 1000 -- curl -X POST -H "Content-Type: application/json" \
  --data '{"jsonrpc":"2.0","method":"net_peerCount","params":[],"id":1}' \
  http://localhost:8545
```

## Next Steps After Deployment

1. **Monitor Logs**: Watch Besu logs for each validator
2. **Verify Consensus**: Check that blocks are being produced
3. **Test RPC**: Verify RPC nodes are accessible
4. **Network Health**: Monitor peer connections

---

**Ready to Deploy**: All prerequisites met ✅  
**Genesis.json**: Updated with current validator addresses ✅  
**Keys**: All 5 validator keys present and verified ✅

