This document describes the refactoring of the Solana Validator Switch tool to use a modern async architecture with improved performance and user experience.
| Component | Old | New | Benefits |
|---|---|---|---|
| SSH Exec | ssh2 (sync) | openssh-rs (async) | Reuses sessions, async support, better performance |
| UI | ratatui (basic) | ratatui + channels | Scrollable logs, real-time updates, better state management |
| Async Runtime | tokio (partial) | tokio (full) | Clean concurrency, proper task management |
| Messaging | Direct calls | tokio::sync::mpsc | Non-blocking UI updates, streaming SSH output |
| State Mgmt | Mutex only | Arc<RwLock<>> | Better concurrent access, cleaner architecture |
The new SSH module uses openssh-rs which provides:
- Connection pooling with automatic reuse and Arc efficiency
- Async/await support throughout
- Native multiplexing with ControlPersist for better performance
- Streaming output via channels
- Optimized commands using execute_command_with_args for better performance
// Old approach (blocking)
let output = ssh_manager.execute_command("long_command")?;
// New approach (streaming)
ssh_pool.execute_command_streaming(
&node,
&ssh_key,
"long_command",
log_sender, // Channel for real-time output
).await?;The refactored UI provides:
- Split pane design - Summary view + scrollable logs
- Real-time SSH output - See command output as it happens
- Per-host log tracking - Switch between different hosts
- Keyboard navigation - Tab between panes, scroll logs
- Non-blocking updates - UI remains responsive during data fetches
pub struct UiState {
// Vote data with increment tracking
pub vote_data: Vec<Option<ValidatorVoteData>>,
pub increment_times: Vec<Option<Instant>>,
// SSH logs organized by host
pub host_logs: HashMap<String, Vec<String>>,
pub log_scroll_offset: usize,
// UI state
pub focused_pane: FocusedPane,
}The new architecture separates concerns:
- UI thread - Handles rendering at 10 FPS
- Vote data task - Fetches RPC data every 5 seconds
- Catchup task - Runs SSH catchup commands every 30 seconds
- Log processor - Receives SSH output via channels
The tower transfer process has been optimized with streaming approach:
- Old approach:
base64 -d > filewith shell redirection - New approach: streaming
base64 -d+ddwithout shell redirection - Benefits:
- Eliminates shell redirection overhead
- Better error handling with separate base64 and file write operations
- Reduced latency from 200-500ms to 100-300ms
- More reliable with direct stdin/stdout pipes
svs statusUSE_ENHANCED_UI=1 svs statusThe refactoring is designed to be incremental:
- Phase 1 ✅ - New SSH module with openssh-rs implemented and integrated
- Phase 2 ✅ - Build enhanced UI with channel-based updates
- Phase 3 🚧 - Migrate existing commands to use new SSH pool
- Phase 4 🚧 - Make enhanced UI the default
-
Performance
- SSH connections are reused (not recreated each time)
- Commands can be cancelled early (e.g., catchup when caught up)
- Async operations don't block the UI
-
User Experience
- See real-time output from SSH commands
- Navigate between different hosts' logs
- UI remains responsive during long operations
-
Developer Experience
- Cleaner async/await code
- Better error handling with Result types
- Modular architecture easier to test
- Complete migration of all SSH operations to the new pool
- Add configuration options for UI preferences
- Implement log persistence and search
- Add more real-time monitoring capabilities