# Geo-Aware Committee Configuration

## Overview

This document defines the geo-aware validator committee configuration for the 36-region global deployment. The configuration optimizes consensus performance by organizing validators into latency-aware rings and assigning primary vs. backup roles.

---

## 🎯 Consensus Strategy

### Primary Producing Validators (60-70%)

**Geographic Distribution:**
- **Europe Ring:** 6 primary regions × 2 validators = 12 validators
- **Asia Pacific Ring:** 5 primary regions × 2 validators = 10 validators
- **Subtotal:** 22 validators (46% of total, ~60% of producing capacity)

**Selection Criteria:**
- Regions with lowest inter-region latency
- Well-connected network infrastructure
- Strategic geographic positioning

### Geo-Distributed Backup Validators (30-40%)

**Geographic Distribution:**
- **Europe:** 8 remaining regions × 1 validator = 8 validators
- **Asia Pacific:** 8 remaining regions × 1 validator = 8 validators
- **Middle East:** 3 regions × 1 validator = 3 validators
- **Americas:** 4 remaining regions × 1 validator = 4 validators
- **Africa:** 1 region × 1 validator = 1 validator
- **Primary regions (backup):** 12 regions × 1 validator = 12 validators (second validator acts as backup)
- **Subtotal:** 36 backup validators

**Selection Criteria:**
- Geographic diversity for resilience
- Regional coverage for compliance
- Backup capacity for fault tolerance

---

## 🌍 Latency-Aware Rings

### Ring 1: Europe (14 regions)

**Primary Validators (12):**
- West Europe (2 validators)
- North Europe (2 validators)
- France Central (2 validators)
- Germany West Central (2 validators)
- UK South (2 validators)
- Switzerland North (2 validators)

**Backup Validators (8):**
- UK West (1 validator)
- Sweden Central (1 validator)
- Norway East (1 validator)
- Poland Central (1 validator)
- Spain Central (1 validator)
- Italy North (1 validator)
- Austria East (1 validator)
- Belgium Central (1 validator)

**Characteristics:**
- Very tight RTT between regions (typically < 50ms)
- Ideal for fast consensus rounds
- High bandwidth connectivity

### Ring 2: Asia Pacific (13 regions)

**Primary Validators (10):**
- East Asia (2 validators)
- Southeast Asia (2 validators)
- Japan East (2 validators)
- Australia East (2 validators)
- Central India (2 validators)

**Backup Validators (8):**
- Japan West (1 validator)
- Korea Central (1 validator)
- Korea South (1 validator)
- Australia Southeast (1 validator)
- New Zealand North (1 validator)
- West India (1 validator)
- Indonesia Central (1 validator)
- Malaysia West (1 validator)

**Characteristics:**
- Regional clustering for APAC optimization
- Lower inter-region latency within clusters
- Strategic positioning for APAC users

### Ring 3: Middle East + Africa (4 regions)

**Backup Validators (4):**
- UAE North (1 validator)
- Qatar Central (1 validator)
- Israel Central (1 validator)
- South Africa North (1 validator)

**Characteristics:**
- Regional coverage and compliance
- Geographic diversity
- Backup capacity for ME/Africa region

### Ring 4: Americas Non-US (5 regions)

**Primary Validators (2):**
- Canada Central (2 validators)

**Backup Validators (4):**
- Canada East (1 validator)
- Brazil South (1 validator)
- Chile Central (1 validator)
- Mexico Central (1 validator)

**Characteristics:**
- Western hemisphere coverage
- Strategic positioning for Americas users
- Regional compliance support

---

## 📊 Committee Configuration

### QBFT Settings

**Block Time:** 2-4 seconds
- Optimized for low-latency rings (2s for Europe/Asia primary)
- Extended for geo-distributed backups (4s max)

**Committee Selection:**
- **Primary Committee:** 12-15 validators (from primary regions)
- **Backup Committee:** 8-12 validators (from backup regions)
- **Total Active:** 20-27 validators per round

**Rotation Strategy:**
- Primary validators: Active in 80% of rounds
- Backup validators: Active in 20% of rounds (rotating)
- Ensures all validators participate while maintaining low latency

### Consensus Algorithm: QBFT

**Configuration:**
```yaml
consensus:
  algorithm: QBFT
  block_period: 2  # 2 seconds for primary regions
  epoch_length: 30000
  request_timeout: 10
  validator_selection:
    primary_weight: 70  # 70% of rounds use primary validators
    backup_weight: 30   # 30% of rounds use backup validators
    geo_aware: true     # Prefer same-ring validators for faster rounds
```

---

## 🔄 Validator Role Assignment

### Primary Validators (22 total)

**Producing Role:**
- Active in 70% of consensus rounds
- Located in low-latency primary regions
- Fastest block production times

**Primary Regions (12):**
1. West Europe
2. North Europe
3. France Central
4. Germany West Central
5. UK South
6. Switzerland North
7. East Asia
8. Southeast Asia
9. Japan East
10. Australia East
11. Central India
12. Canada Central

### Backup Validators (26 total from remaining regions)

**Backup Role:**
- Active in 30% of consensus rounds (rotating)
- Located across all geographic regions
- Ensures fault tolerance and geographic diversity

**Remaining Regions (24):**
- All non-primary regions have 1 validator each (backup role)
- Primary regions also have 1 validator in backup pool (second validator)

---

## 📈 Performance Optimization

### Latency Optimization

**Within-Ring Consensus:**
- When possible, select validators from same ring
- Reduces cross-region latency
- Faster block finality

**Inter-Ring Communication:**
- Prefer adjacent rings for backup validators
- Europe-Asia collaboration for global coverage
- Americas-MEA for Western hemisphere

### Fault Tolerance

**Geographic Diversity:**
- No single region/ring failure can halt consensus
- At least 3 validators per major geographic area
- Redundant validators in critical regions

**Resilience Targets:**
- Can withstand failure of 1 entire ring (backup validators activate)
- Can withstand failure of 6 primary regions (12 validators)
- Maintains consensus with 33%+ validator availability

---

## 🛠️ Implementation

### Validator Selection Logic

```go
type ValidatorRole string

const (
    ValidatorRolePrimary ValidatorRole = "primary"
    ValidatorRoleBackup  ValidatorRole = "backup"
)

type GeoRing string

const (
    GeoRingEurope   GeoRing = "europe"
    GeoRingAPAC     GeoRing = "apac"
    GeoRingMEAfrica GeoRing = "me-africa"
    GeoRingAmericas GeoRing = "americas"
)

func SelectValidators(round int, allValidators []Validator) []Validator {
    // 70% of rounds use primary validators
    usePrimary := (round % 10) < 7
    
    if usePrimary {
        return SelectPrimaryValidators(allValidators)
    }
    
    return SelectBackupValidators(allValidators)
}

func SelectPrimaryValidators(allValidators []Validator) []Validator {
    // Select from primary regions
    // Prefer same-ring for lower latency
    // Target: 12-15 validators from Europe + Asia primary regions
}

func SelectBackupValidators(allValidators []Validator) []Validator {
    // Rotate through backup regions
    // Ensure geographic diversity
    // Target: 8-12 validators from remaining regions
}
```

---

## 📊 Monitoring & Metrics

### Key Metrics

**Latency Metrics:**
- Average block time per ring
- Inter-region round-trip time
- Consensus round duration

**Availability Metrics:**
- Primary validator uptime
- Backup validator activation rate
- Geographic coverage percentage

**Performance Metrics:**
- Blocks per second (per ring)
- Transaction throughput
- Finality time

---

## 🔄 Rotation Schedule

### Daily Rotation

- **00:00-08:00 UTC:** Europe primary emphasis
- **08:00-16:00 UTC:** Asia Pacific primary emphasis
- **16:00-24:00 UTC:** Balanced global distribution

### Weekly Rotation

- **Monday-Wednesday:** Primary validators (70% rounds)
- **Thursday-Saturday:** Increased backup participation (40% rounds)
- **Sunday:** Full diversity test (50/50 split)

---

## 📝 Configuration Files

### Besu Genesis Configuration

```json
{
  "config": {
    "ibft2": {
      "blockperiodseconds": 2,
      "epochlength": 30000,
      "requesttimeoutseconds": 10,
      "validatorselectionmode": "geo-aware",
      "primaryvalidatorweight": 0.7,
      "backupvalidatorweight": 0.3
    }
  }
}
```

### Validator Registry

```yaml
validators:
  primary:
    - region: westeurope
      validators: [validator1, validator2]
      role: primary
      ring: europe
    - region: northeurope
      validators: [validator3, validator4]
      role: primary
      ring: europe
    # ... (12 primary regions)
  
  backup:
    - region: ukwest
      validators: [validator25]
      role: backup
      ring: europe
    # ... (24 remaining regions)
```

---

## 🚀 Next Steps

1. ✅ Geo-aware committee configuration defined
2. ⏳ Implement validator selection logic in Besu
3. ⏳ Configure IBFT2 geo-aware mode
4. ⏳ Set up rotation schedules
5. ⏳ Deploy monitoring for geo-aware metrics
6. ⏳ Test consensus with geo-aware validator selection

---

## 📚 References

- [Hyperledger Besu QBFT](https://besu.hyperledger.org/private-networks/how-to/configure/consensus/qbft)
- [36-Region Blueprint](../deployment/36-REGION-BLUEPRINT.md)
- [Deployment Checklist](../deployment/DEPLOYMENT_CHECKLIST.md)
