# Tutus Testnet Deployment Guide

## Overview

This guide deploys two sovereign Tutus blockchain instances for testing:

| Instance | Magic | Validators | RPC Port | Purpose |
|----------|-------|------------|----------|---------|
| Alpha | 88890 | 3 | 10332 | Primary test chain |
| Beta | 88891 | 3 | 11332 | Bridge testing chain |

## Quick Start

```bash
cd tutus/chain

# Build images (first time or after code changes)
docker-compose build

# Start both instances (6 nodes total)
docker-compose up -d

# Check status
docker-compose ps

# View logs
docker-compose logs -f alpha_one
docker-compose logs -f beta_one

# Stop all nodes
docker-compose down

# Stop and remove all data (fresh start)
docker-compose down -v
```

## Starting Individual Instances

```bash
# Alpha only (3 validators)
docker-compose up -d alpha_one alpha_two alpha_three

# Beta only (3 validators)
docker-compose up -d beta_one beta_two beta_three
```

## RPC Endpoints

### Instance Alpha
| Node | RPC | P2P | Prometheus |
|------|-----|-----|------------|
| alpha_one | http://localhost:10332 | :10333 | :2112 |
| alpha_two | http://localhost:10342 | :10343 | :2122 |
| alpha_three | http://localhost:10352 | :10353 | :2132 |

### Instance Beta
| Node | RPC | P2P | Prometheus |
|------|-----|-----|------------|
| beta_one | http://localhost:11332 | :11333 | :2113 |
| beta_two | http://localhost:11342 | :11343 | :2123 |
| beta_three | http://localhost:11352 | :11353 | :2133 |

## Verify Nodes Are Running

```bash
# Check Alpha block height
curl -s -X POST http://localhost:10332 \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","method":"getblockcount","params":[],"id":1}'

# Check Beta block height
curl -s -X POST http://localhost:11332 \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","method":"getblockcount","params":[],"id":1}'

# Get native contracts
curl -s -X POST http://localhost:10332 \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","method":"getnativecontracts","params":[],"id":1}' | jq '.result[].manifest.name'
```

## Validator Configuration

### Instance Alpha Committee
Uses wallet1, wallet2, wallet3:
- `02b3622bf4017bdfe317c58aed5f4c753f206b7db896046fa7d774bbc4bf7f8dc2`
- `02103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e`
- `03d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699`

### Instance Beta Committee
Uses wallet2, wallet3, wallet4 (different committee):
- `02103a7f7dd016558597f7960d27c516a4394fd968b9e65155eb4b013e4040406e`
- `03d90c07df63e690ce77912e10ab51acc944b66860237b608c4f8f8309e71ee699`
- `02a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd62`

## Consensus Requirements

With 3 validators (dBFT):
- Block production: 2-of-3 validators required
- Network can tolerate 1 validator failure

## Testing Bridge Protocol

Once both instances are running:

1. Register a Vita on Alpha
2. Use Federation contract to register as visitor on Beta
3. Test Pons contract for cross-border verification

## Troubleshooting

### Nodes not producing blocks
```bash
# Check if all validators are connected
docker-compose logs alpha_one | grep -i "connected"

# Restart with fresh data
docker-compose down -v
docker-compose up -d
```

### Build fails
```bash
# Ensure Go 1.24+ is used in Dockerfile
# Clean rebuild
docker-compose build --no-cache
```

### Port conflicts
```bash
# Check what's using the ports
netstat -tlnp | grep -E "1033|1133"
```

## Native Contracts Available

Both instances include all Tutus native contracts:
- Vita (identity), Annos (lifespan), VTS (stablecoin)
- Scire (education), Salus (healthcare), Sese (life planning)
- Eligere (voting), Lex (rights), Collocatio (investments)
- Tribute (anti-hoarding), Opus (AI workforce)
- Federation, Pons, Palam (cross-chain)
- Tutus (governance), Lub (utility)
