osvm 0.8.3

OpenSVM CLI tool for managing SVM nodes and deployments
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
# SSH Deployment

The SSH Deployment module enables remote deployment and management of Solana validators, RPC nodes, and eBPF programs across distributed infrastructure.

## Overview

OSVM CLI provides comprehensive SSH-based deployment capabilities that handle everything from initial server setup to advanced features like hot-swap configurations, disk management, and automated monitoring.

## Quick Start

```bash
# Deploy a validator to remote host
osvm deploy-validator --host user@example.com --keypair validator.json

# Deploy an RPC node
osvm deploy-rpc --host user@example.com --network mainnet

# Deploy an eBPF program
osvm deploy-program --host user@example.com --program program.so --keypair authority.json
```

## Architecture

```mermaid
flowchart TD
    subgraph "SSH Deployment System"
        CLI[OSVM CLI]
        
        subgraph "Deployment Types"
            VALIDATOR[Validator Deploy]
            RPC[RPC Deploy]
            PROGRAM[Program Deploy]
        end
        
        subgraph "SSH Components"
            CONN[SSH Connection]
            AUTH[Authentication]
            TRANSFER[File Transfer]
            EXEC[Remote Execution]
        end
        
        subgraph "Remote Setup"
            DEPS[Dependencies]
            CONFIG[Configuration]
            SERVICES[Service Setup]
            MONITOR[Monitoring]
        end
        
        subgraph "Advanced Features"
            HOTSWAP[Hot-Swap]
            DISK[Disk Management]
            TUNNEL[Tunnel Setup]
            BACKUP[Backup Config]
        end
    end
    
    CLI --> VALIDATOR
    CLI --> RPC
    CLI --> PROGRAM
    
    VALIDATOR --> CONN
    RPC --> CONN
    PROGRAM --> CONN
    
    CONN --> AUTH
    CONN --> TRANSFER
    CONN --> EXEC
    
    EXEC --> DEPS
    EXEC --> CONFIG
    EXEC --> SERVICES
    EXEC --> MONITOR
    
    SERVICES --> HOTSWAP
    CONFIG --> DISK
    MONITOR --> TUNNEL
    SERVICES --> BACKUP
    
    classDef techDebt fill:#f6f6f6,stroke:#d9534f,color:#d9534f,font-family:Consolas,monospace,font-weight:bold
```

## Deployment Commands

### Validator Deployment

Deploy a Solana validator to a remote host with comprehensive configuration.

```bash
osvm deploy-validator [OPTIONS]
```

**Required Options:**
- `--host <HOST>` - SSH connection string (user@hostname)
- `--keypair <KEYPAIR>` - Path to identity keypair file

**Common Options:**
- `--network <NETWORK>` - Network (mainnet, testnet, devnet)
- `--ledger-disk <DEVICE>` - Ledger disk device path
- `--accounts-disk <DEVICE>` - Accounts disk device path
- `--vote-keypair <KEYPAIR>` - Vote account keypair
- `--enable-rpc` - Enable RPC endpoint
- `--monitoring` - Setup monitoring stack

**Examples:**
```bash
# Basic validator deployment
osvm deploy-validator \
  --host solana@validator.example.com \
  --keypair identity.json \
  --vote-keypair vote.json

# Advanced deployment with disk configuration
osvm deploy-validator \
  --host solana@validator.example.com \
  --keypair identity.json \
  --vote-keypair vote.json \
  --ledger-disk /dev/nvme0n1 \
  --accounts-disk /dev/nvme1n1 \
  --enable-rpc \
  --monitoring

# Hot-swap enabled deployment
osvm deploy-validator \
  --host solana@validator.example.com \
  --keypair identity.json \
  --vote-keypair vote.json \
  --hot-swap-keypair backup-identity.json \
  --enable-hot-swap
```

### RPC Node Deployment

Deploy specialized RPC nodes for serving client requests.

```bash
osvm deploy-rpc [OPTIONS]
```

**Options:**
- `--host <HOST>` - SSH connection string
- `--network <NETWORK>` - Target network
- `--rpc-port <PORT>` - RPC service port (default: 8899)
- `--websocket-port <PORT>` - WebSocket port (default: 8900)
- `--enable-private-rpc` - Enable private RPC methods
- `--accounts-db-caching` - Enable accounts database caching

### eBPF Program Deployment

Deploy Solana programs to the network via remote hosts.

```bash
osvm deploy-program [OPTIONS]
```

**Required Options:**
- `--host <HOST>` - SSH connection string
- `--program <PROGRAM>` - Path to program binary (.so file)
- `--keypair <KEYPAIR>` - Program authority keypair

**Optional Features:**
- `--upgrade` - Upgrade existing program
- `--buffer-keypair <KEYPAIR>` - Use buffer account for large programs
- `--max-sign-attempts <NUM>` - Maximum signing attempts

## Deployment Workflow

```mermaid
sequenceDiagram
    participant U as User
    participant CLI as OSVM CLI
    participant SSH as SSH Manager
    participant HOST as Remote Host
    participant SOL as Solana Network
    
    U->>CLI: deploy-validator command
    CLI->>SSH: Establish SSH connection
    SSH->>HOST: Authenticate and connect
    
    Note over SSH,HOST: System Preparation
    SSH->>HOST: Install system dependencies
    SSH->>HOST: Setup user accounts
    SSH->>HOST: Configure firewall
    
    Note over SSH,HOST: Disk Configuration
    SSH->>HOST: Detect and format disks
    SSH->>HOST: Mount ledger/accounts disks
    SSH->>HOST: Create directory structure
    
    Note over SSH,HOST: Solana Setup
    SSH->>HOST: Install Solana binaries
    SSH->>HOST: Transfer keypairs
    SSH->>HOST: Configure validator
    SSH->>HOST: Setup systemd service
    
    Note over SSH,HOST: Monitoring Setup
    SSH->>HOST: Install monitoring tools
    SSH->>HOST: Configure log rotation
    SSH->>HOST: Setup metrics collection
    
    SSH->>HOST: Start validator service
    HOST->>SOL: Connect to network
    SOL->>HOST: Begin sync process
    HOST->>SSH: Service status
    SSH->>CLI: Deployment complete
    CLI->>U: Success notification
    
    classDef techDebt fill:#f6f6f6,stroke:#d9534f,color:#d9534f,font-family:Consolas,monospace,font-weight:bold
```

## Advanced Features

### Disk Management

OSVM CLI supports automated disk configuration for optimal validator performance.

**Supported Configuration:**
- **OS Disk:** System and binaries (~500GB SSD)
- **Ledger Disk:** High-performance NVMe (≥2TB) at `/mnt/ledger`
- **Accounts Disk:** High-performance NVMe (≥2TB) at `/mnt/extras`

**Automatic Setup:**
1. Disk detection and validation
2. Filesystem creation (ext4)
3. Mount point configuration
4. Directory structure creation
5. Permission setup

```bash
# Example with disk configuration
osvm deploy-validator \
  --host validator@example.com \
  --keypair identity.json \
  --ledger-disk /dev/nvme0n1 \
  --accounts-disk /dev/nvme1n1
```

### Hot-Swap Configuration

Enable seamless validator identity switching for maintenance operations.

```mermaid
stateDiagram-v2
    [*] --> Primary
    Primary --> Preparing: Hot-swap initiated
    Preparing --> Switching: Identity prepared
    Switching --> Secondary: Identity switched
    Secondary --> Preparing: Switch back
    Preparing --> Primary: Back to primary
    
    Primary: Primary Identity Active
    Secondary: Secondary Identity Active
    Preparing: Preparing New Identity
    Switching: Switching Process
    
    classDef techDebt fill:#f6f6f6,stroke:#d9534f,color:#d9534f,font-family:Consolas,monospace,font-weight:bold
```

### Monitoring Integration

Automatic setup of comprehensive monitoring stack:

- **System Monitoring:** CPU, memory, disk, network
- **Solana Metrics:** Validator performance, vote credits, delinquency
- **Log Analysis:** Real-time log parsing and alerting
- **Dashboards:** Grafana dashboards with pre-configured panels

## SSH Connection Management

### Authentication Methods

**SSH Key Authentication (Recommended):**
```bash
# Setup SSH key for password-less access
ssh-copy-id solana@validator.example.com

# Deploy with SSH key
osvm deploy-validator --host solana@validator.example.com --keypair identity.json
```

**SSH Agent Support:**
```bash
# Add key to SSH agent
ssh-add ~/.ssh/id_rsa

# Use agent for deployment
osvm deploy-validator --host solana@validator.example.com --keypair identity.json
```

### Connection Configuration

**SSH Config File (~/.ssh/config):**
```
Host validator-1
  HostName validator1.example.com
  User solana
  IdentityFile ~/.ssh/validator_key
  Port 22
  
Host validator-2
  HostName validator2.example.com
  User solana
  IdentityFile ~/.ssh/validator_key
  Port 22
```

## Security Considerations

### Access Control

1. **Dedicated User Accounts**
   - Create dedicated `solana` user
   - Restrict sudo access
   - Use SSH key authentication

2. **Firewall Configuration**
   - Close unnecessary ports
   - Allow Solana network ports (8000-8020)
   - Restrict SSH access

3. **Keypair Management**
   - Store keypairs securely
   - Use hardware security modules when possible
   - Implement key rotation procedures

### Network Security

```bash
# Firewall configuration example
ufw default deny incoming
ufw default allow outgoing
ufw allow ssh
ufw allow 8000:8020/tcp  # Solana ports
ufw allow 8899/tcp       # RPC port (if needed)
ufw enable
```

## Configuration Files

### Deployment Configuration

Create a deployment configuration file for complex setups:

```yaml
# deployment-config.yaml
deployment:
  type: "validator"
  network: "mainnet"
  host: "solana@validator.example.com"
  
keypairs:
  identity: "identity.json"
  vote: "vote.json"
  
disks:
  ledger: "/dev/nvme0n1"
  accounts: "/dev/nvme1n1"
  
features:
  rpc_enabled: true
  monitoring: true
  hot_swap: true
  
system:
  optimization: true
  log_rotation: true
  metrics_collection: true
```

**Use configuration file:**
```bash
osvm deploy --config deployment-config.yaml
```

## Troubleshooting

### Connection Issues

**SSH Connection Fails:**
```bash
# Test SSH connection manually
ssh -v solana@validator.example.com

# Check SSH key permissions
chmod 600 ~/.ssh/id_rsa
chmod 644 ~/.ssh/id_rsa.pub
```

**Permission Denied:**
```bash
# Verify SSH key is added to authorized_keys
ssh-copy-id solana@validator.example.com

# Check user permissions on remote host
sudo usermod -aG sudo solana
```

### Deployment Failures

**Disk Setup Fails:**
```bash
# Check disk availability
lsblk

# Verify disk permissions
sudo fdisk -l /dev/nvme0n1
```

**Service Won't Start:**
```bash
# Check service status
systemctl status solana-validator

# Check logs
journalctl -u solana-validator -f
```

### Performance Issues

**Slow Sync:**
```bash
# Check network connectivity
ping api.mainnet-beta.solana.com

# Monitor resource usage
htop
iostat -x 1
```

## Best Practices

### Pre-deployment Checklist

1. **Server Preparation**
   - [ ] SSH access configured
   - [ ] Sudo privileges granted
   - [ ] Firewall configured
   - [ ] Disks available and unmounted

2. **Keypair Preparation**
   - [ ] Identity keypair generated
   - [ ] Vote account created
   - [ ] Keypairs backed up securely
   - [ ] Sufficient SOL for rent exemption

3. **Network Planning**
   - [ ] Network selection confirmed
   - [ ] RPC endpoints identified
   - [ ] Monitoring endpoints configured

### Post-deployment Verification

1. **Service Health**
   ```bash
   # Check validator is running
   systemctl status solana-validator
   
   # Verify network connectivity
   solana gossip
   
   # Check vote submission
   solana vote-account <VOTE_PUBKEY>
   ```

2. **Performance Monitoring**
   ```bash
   # Monitor sync progress
   solana catchup <VALIDATOR_PUBKEY>
   
   # Check resource usage
   htop
   df -h
   ```

## Related Documentation

- [Node Management]node-management.md - Managing deployed nodes
- [Self-Repair System]self-repair-system.md - Automated maintenance
- [Log Monitoring]log-monitoring.md - Real-time log analysis
- [Validator Enhancements]validator-enhancements.md - Advanced validator features