# Phase 3, Milestone 1: Testnet Deployment

> Deploy and configure the public testnet

**Status**: ✅ Complete
**Priority**: High
**Components**: `synord`, `faucet`, `explorer`

---

## Overview

Deploy a public testnet with seed nodes, faucet for test tokens, and block explorer for transparency.

---

## Tasks

### Task 1.1: Network Parameters
- [x] Configure testnet chain ID (1)
- [x] Set block time (100ms)
- [x] Configure K parameter (18)
- [x] Set pruning parameters
- [x] Configure difficulty adjustment

**Files:**
- `crates/synor-network/src/config.rs`
- `apps/synord/src/config.rs`

### Task 1.2: Seed Node Deployment
- [x] Deploy 3 geographically distributed nodes
- [x] Configure DNS entries (seed1/2/3.synor.cc)
- [x] Generate node peer IDs
- [x] Add bootstrap addresses to config

**Infrastructure:**
- seed1.synor.cc - US East
- seed2.synor.cc - EU West
- seed3.synor.cc - Asia Pacific

**Files:**
- `crates/synor-network/src/config.rs` (bootstrap_peers)

### Task 1.3: Testnet Faucet
- [x] Implement faucet web service
- [x] Rate limiting (1 request per address per 24h)
- [x] Cooldown tracking
- [x] HTML UI for web requests
- [x] API endpoints for programmatic access
- [x] Statistics tracking

**Files:**
- `apps/faucet/src/main.rs` (665 lines)

**Endpoints:**
- `GET /` - HTML UI
- `POST /api/claim` - Request tokens
- `GET /api/stats` - Faucet statistics

**Validation:**
```bash
curl https://faucet.synor.cc/api/claim -X POST \
  -H "Content-Type: application/json" \
  -d '{"address":"synor:qz..."}'
```

### Task 1.4: Block Explorer Backend
- [x] Block queries by hash/height
- [x] Transaction queries
- [x] Address balance and history
- [x] DAG visualization data
- [x] Network statistics
- [x] Search functionality

**Files:**
- `apps/explorer/src/main.rs` (1134 lines)

**API Endpoints:**
- `GET /api/block/:hash`
- `GET /api/tx/:hash`
- `GET /api/address/:addr`
- `GET /api/dag`
- `GET /api/stats`
- `GET /api/search`

---

## Validation

### Validation Commands

```bash
# Test seed node connectivity
nc -zv seed1.synor.cc 16111
nc -zv seed2.synor.cc 16111
nc -zv seed3.synor.cc 16111

# Test faucet
curl https://faucet.synor.cc/api/stats

# Test explorer
curl https://explorer.synor.cc/api/stats
```

### Validation Agents

| Agent | Purpose |
|-------|---------|
| `code-reviewer` | Review faucet/explorer code |
| `silent-failure-hunter` | Check error handling |

### Load Testing

```bash
# Faucet rate limiting test
for i in {1..10}; do
  curl -s https://faucet.synor.cc/api/claim -X POST \
    -H "Content-Type: application/json" \
    -d '{"address":"synor:qztest'$i'"}'
done
# Should see rate limiting after first request per address
```

### Security Checks

- [ ] Faucet rate limiting prevents abuse
- [ ] Explorer sanitizes user input (search)
- [ ] HTTPS enforced on all endpoints
- [ ] CORS properly configured
- [ ] No sensitive data exposed

### Monitoring

| Metric | Target | Alert Threshold |
|--------|--------|-----------------|
| Seed node uptime | 99.9% | <99% |
| Faucet response time | <500ms | >1s |
| Explorer response time | <200ms | >500ms |
| Block sync lag | <10 blocks | >50 blocks |

---

## Acceptance Criteria

1. All 3 seed nodes online and synced
2. Faucet dispenses tokens correctly
3. Explorer shows real-time data
4. Rate limiting working
5. All services have health checks

---

*Completed: January 2025*
