/ testnet / DEPLOYMENT.md
DEPLOYMENT.md
  1  # ALPHA/DELTA Testnet Deployment Guide
  2  
  3  This document describes the complete process for deploying the ALPHA/DELTA testnet.
  4  
  5  ## Overview
  6  
  7  The testnet consists of:
  8  - **5 Validator Nodes**: Run consensus for both ALPHA and DELTA chains
  9  - **3 RPC Nodes**: Provide public API endpoints
 10  - **1 Monitor Node**: Prometheus/Grafana monitoring
 11  - **1 Faucet Node**: Testnet token distribution
 12  
 13  ## Prerequisites
 14  
 15  ### Infrastructure Requirements
 16  
 17  | Node Type | CPU | RAM | Storage | Network |
 18  |-----------|-----|-----|---------|---------|
 19  | Validator | 8+ cores | 32GB | 500GB NVMe | 100Mbps |
 20  | RPC | 4+ cores | 16GB | 256GB SSD | 100Mbps |
 21  | Monitor | 4 cores | 16GB | 100GB SSD | 50Mbps |
 22  | Faucet | 2 cores | 8GB | 50GB SSD | 50Mbps |
 23  
 24  ### Software Requirements
 25  
 26  - Ubuntu 22.04 LTS or Debian 12
 27  - Rust 1.82+ (for building from source)
 28  - systemd
 29  - SSH access to all nodes
 30  
 31  ### Network Requirements
 32  
 33  | Port | Protocol | Purpose |
 34  |------|----------|---------|
 35  | 30303 | TCP/UDP | P2P networking |
 36  | 3030 | TCP | ALPHA RPC |
 37  | 3031 | TCP | DELTA RPC |
 38  | 3032 | TCP | DELTA WebSocket |
 39  | 9090 | TCP | ALPHA Prometheus metrics |
 40  | 9091 | TCP | DELTA Prometheus metrics |
 41  | 9100 | TCP | Combined metrics |
 42  | 9101 | TCP | Node exporter |
 43  
 44  ## Deployment Steps
 45  
 46  ### 1. Prepare SSH Keys
 47  
 48  ```bash
 49  # Generate deployment SSH key
 50  ssh-keygen -t ed25519 -f ~/.ssh/testnet_ed25519 -N "" -C "testnet-deployment"
 51  
 52  # Copy to all nodes
 53  for node in validator-{1..5} rpc-{1..3} monitor faucet; do
 54      ssh-copy-id -i ~/.ssh/testnet_ed25519.pub ac-dc@testnet-${node}.ac-dc.network
 55  done
 56  ```
 57  
 58  ### 2. Generate Validator Keys
 59  
 60  ```bash
 61  cd testnet/scripts
 62  ./generate-keys.sh --validators 5
 63  ```
 64  
 65  This creates placeholder key files. Replace with real keys:
 66  
 67  ```bash
 68  # Generate real consensus keys (run on each validator)
 69  adnet validator keygen --output /var/lib/adnet/keys/consensus.json
 70  
 71  # Generate account keys
 72  adnet alpha account new --output /var/lib/adnet/keys/account.json
 73  
 74  # Generate network peer keys
 75  adnet keygen --type network --output /var/lib/adnet/keys/network.json
 76  ```
 77  
 78  ### 3. Configure DNS
 79  
 80  Create DNS A records:
 81  ```
 82  testnet-validator-1.ac-dc.network -> <IP>
 83  testnet-validator-2.ac-dc.network -> <IP>
 84  testnet-validator-3.ac-dc.network -> <IP>
 85  testnet-validator-4.ac-dc.network -> <IP>
 86  testnet-validator-5.ac-dc.network -> <IP>
 87  testnet-rpc-1.ac-dc.network -> <IP>
 88  testnet-rpc-2.ac-dc.network -> <IP>
 89  testnet-rpc-3.ac-dc.network -> <IP>
 90  testnet-monitor.ac-dc.network -> <IP>
 91  testnet-faucet.ac-dc.network -> <IP>
 92  ```
 93  
 94  ### 4. Install ac-dc on All Nodes
 95  
 96  ```bash
 97  # Using ac-dc fleet management
 98  ac-dc fleet exec --config config/fleet-testnet.toml \
 99      --command "curl -sSf https://install.ac-dc.network | bash"
100  ```
101  
102  Or manually on each node:
103  ```bash
104  cargo install --git https://code.ac-dc.network/Alpha-Delta-Network/ac-dc
105  ```
106  
107  ### 5. Deploy Validators
108  
109  ```bash
110  # Dry run first
111  ./scripts/deploy-testnet.sh --validators-only --dry-run
112  
113  # Deploy validators
114  ./scripts/deploy-testnet.sh --validators-only
115  ```
116  
117  ### 6. Wait for Genesis
118  
119  After deploying validators:
120  1. Validators will generate genesis block
121  2. Wait for all 5 validators to be online
122  3. Verify consensus is running:
123  
124  ```bash
125  ac-dc fleet exec --config config/fleet-testnet.toml \
126      --tags validator \
127      --command "ac-dc status"
128  ```
129  
130  ### 7. Deploy RPC Nodes
131  
132  ```bash
133  ./scripts/deploy-testnet.sh --rpc-only
134  ```
135  
136  ### 8. Deploy Monitoring
137  
138  ```bash
139  # Deploy Prometheus
140  scp monitoring/prometheus.yml ac-dc@testnet-monitor.ac-dc.network:/etc/prometheus/
141  
142  # Deploy alerting rules
143  scp monitoring/alerting-rules.yml ac-dc@testnet-monitor.ac-dc.network:/etc/prometheus/rules/
144  
145  # Deploy Grafana dashboard
146  scp monitoring/grafana-dashboard.json ac-dc@testnet-monitor.ac-dc.network:/var/lib/grafana/dashboards/
147  
148  # Restart services
149  ssh ac-dc@testnet-monitor.ac-dc.network "sudo systemctl restart prometheus grafana-server"
150  ```
151  
152  ### 9. Deploy Faucet
153  
154  ```bash
155  # Configure faucet with testnet keys
156  ssh ac-dc@testnet-faucet.ac-dc.network << 'EOF'
157  ac-dc configure --node-type client --network testnet
158  ac-dc start
159  EOF
160  ```
161  
162  ### 10. Verify Deployment
163  
164  ```bash
165  # Check all nodes
166  ac-dc fleet status --config config/fleet-testnet.toml
167  
168  # Check consensus
169  curl -s http://testnet-rpc-1.ac-dc.network:3030/status | jq
170  
171  # Check DELTA chain
172  curl -s http://testnet-rpc-1.ac-dc.network:3031/status | jq
173  
174  # Test faucet
175  curl -X POST http://testnet-faucet.ac-dc.network/drip \
176      -H "Content-Type: application/json" \
177      -d '{"address": "<your-testnet-address>"}'
178  ```
179  
180  ## Configuration Files
181  
182  ### adnet-testnet.toml
183  
184  Main configuration for the unified adnet binary. Key settings:
185  - `chain_mode = "dual"` - Run both chains
186  - `node.node_type = "validator"` - For validator nodes
187  - `alpha.block_time_ms = 10000` - 10 second blocks on ALPHA
188  - `delta.block_time_ms = 1000` - 1 second blocks on DELTA
189  
190  ### fleet-testnet.toml
191  
192  Fleet management configuration for ac-dc:
193  - Defines all nodes in the testnet
194  - SSH connection settings
195  - Rolling update parameters
196  
197  ### alpha-testnet.toml / delta-testnet.toml
198  
199  Chain-specific genesis and network parameters.
200  
201  ## Operations
202  
203  ### Rolling Updates
204  
205  ```bash
206  ac-dc fleet update --config config/fleet-testnet.toml \
207      --batch-size 1 \
208      --health-check-timeout 180
209  ```
210  
211  ### Restart All Nodes
212  
213  ```bash
214  ac-dc fleet exec --config config/fleet-testnet.toml \
215      --command "ac-dc restart"
216  ```
217  
218  ### View Logs
219  
220  ```bash
221  # Single node
222  ssh ac-dc@testnet-validator-1.ac-dc.network "ac-dc logs -f"
223  
224  # All validators
225  ac-dc fleet exec --config config/fleet-testnet.toml \
226      --tags validator \
227      --command "ac-dc logs --lines 50"
228  ```
229  
230  ### Emergency Shutdown
231  
232  ```bash
233  ac-dc fleet exec --config config/fleet-testnet.toml \
234      --parallel \
235      --command "ac-dc stop"
236  ```
237  
238  ## Troubleshooting
239  
240  ### Consensus Not Starting
241  
242  1. Check all validators have correct genesis files
243  2. Verify network connectivity between validators
244  3. Check firewall rules for port 30303
245  
246  ```bash
247  # Test connectivity
248  nc -zv testnet-validator-2.ac-dc.network 30303
249  ```
250  
251  ### Nodes Out of Sync
252  
253  1. Check disk space
254  2. Verify network bandwidth
255  3. Consider increasing sync batch size
256  
257  ```bash
258  # Check sync status
259  ac-dc fleet exec --tags validator --command "ac-dc status --format json | jq '.sync'"
260  ```
261  
262  ### High Memory Usage
263  
264  1. Check for memory leaks in logs
265  2. Reduce cache size in configuration
266  3. Add swap if needed (not recommended for validators)
267  
268  ## Monitoring URLs
269  
270  - **Grafana**: https://testnet-monitor.ac-dc.network/grafana
271  - **Prometheus**: https://testnet-monitor.ac-dc.network:9090
272  - **ALPHA RPC**: https://testnet-rpc-1.ac-dc.network:3030
273  - **DELTA RPC**: https://testnet-rpc-1.ac-dc.network:3031
274  - **Faucet**: https://testnet-faucet.ac-dc.network