# Deployment Quick Start - Full Parallel Mode

**Last Updated**: 2025-01-27  
**Status**: Active

## One-Command Deployment

**Fastest way to deploy Phase 2 and all contracts:**

```bash
cd /home/intlc/projects/smom-dbis-138
source .env  # Ensure .env is configured
./scripts/deployment/deploy-phase2-and-contracts-parallel.sh
```

**Time**: ~10-15 minutes (all operations in parallel)

---

## Step-by-Step Parallel Deployment

### 1. Generate Phase 2 Configuration

```bash
# Reads .env + Phase 1 outputs, generates terraform.tfvars automatically
./scripts/deployment/generate-phase2-tfvars.sh
```

### 2. Deploy Phase 2 (All Regions Parallel)

```bash
cd terraform/phases/phase2
terraform apply  # All 5 regions deploy simultaneously
```

### 3. Start Services (All Regions Parallel)

```bash
./terraform/phases/phase2/scripts/start-services.sh all
# All 5 regions start simultaneously
```

### 4. Deploy Contracts (Full Parallel)

```bash
source .env
./scripts/deployment/deploy-contracts-parallel.sh
# Independent contracts deploy simultaneously
```

### 5. Verify Everything (Parallel)

```bash
# Verify Phase 2 services (all regions parallel)
./terraform/phases/phase2/scripts/status.sh all &

# Verify contracts (all contracts parallel)
source .env && ./scripts/deployment/verify-contracts-parallel.sh &

wait  # Wait for both to complete
```

---

## Makefile Commands (All Parallel)

```bash
# Load .env first
source .env

# Deploy contracts (parallel)
make deploy-contracts

# Verify deployments (parallel)
make verify

# Run tests (parallel)
make test

# Compile and test contracts (parallel tests)
make contracts
```

---

## Environment Setup (.env)

Ensure `.env` file exists in project root:

```bash
# Required
PRIVATE_KEY=<your_private_key>
RPC_URL=http://<besu-rpc-node>:8545
SSH_PRIVATE_KEY_PATH=/path/to/ssh/private/key
CHAIN_ID=138

# Phase 2
ENVIRONMENT=prod
VM_ADMIN_USERNAME=besuadmin

# Contract Deployment
CCIP_ROUTER=<address_or_empty>
CCIP_FEE_TOKEN=<link_address_or_zero_address>
ORACLE_DESCRIPTION="ETH/USD Price Feed"
MULTISIG_OWNERS=<comma_separated_addresses>

# Optional
DEPLOY_WETH9=true
DEPLOY_WETH10=true
DEPLOY_BRIDGES=true
```

---

## Performance Comparison

| Operation | Sequential | Parallel | Speedup |
|-----------|-----------|----------|---------|
| Phase 2 Start | ~50s | ~10s | **5x** |
| Phase 2 Status | ~45s | ~9s | **5x** |
| Contract Deployment | ~15min | ~4min | **3.75x** |
| Contract Verification | ~90s | ~10s | **9x** |
| **Total** | **~25min** | **~7min** | **3.6x** |

---

## Troubleshooting

### .env Not Found
```bash
# Create .env file with required variables
cp .env.example .env  # If example exists
# Or create manually
```

### Variables Not Set
```bash
# Check .env has required variables
grep -E "^(PRIVATE_KEY|RPC_URL|SSH_PRIVATE_KEY_PATH)=" .env

# Load .env
source .env
```

### Parallel Execution Issues
```bash
# Use sequential scripts as fallback
./scripts/deployment/deploy-contracts-ordered.sh  # Sequential
./scripts/deployment/verify-on-chain-deployments.sh  # Sequential
```

---

## Next Steps

After deployment:
1. Verify all services: `./terraform/phases/phase2/scripts/status.sh all`
2. Verify contracts: `./scripts/deployment/verify-contracts-parallel.sh`
3. Configure services (FireFly, Cacti, Chainlink)
4. Set up monitoring and alerts
5. Test end-to-end workflows

For detailed documentation, see:
- `docs/NEXT_STEPS_COMPLETE_GUIDE.md` - Full guide
- `docs/PARALLEL_EXECUTION_SUMMARY.md` - Parallel execution details
- `terraform/phases/phase2/README.md` - Phase 2 documentation

