Koro/lightbringer config integration & tui ux#229
Open
NeerajGodiyal wants to merge 17 commits intodevfrom
Open
Koro/lightbringer config integration & tui ux#229NeerajGodiyal wants to merge 17 commits intodevfrom
NeerajGodiyal wants to merge 17 commits intodevfrom
Conversation
…og viewing Add [lightbringer] section to Mithril's config.toml so users can manage both Mithril and Lightbringer from a single config file. When enabled, Mithril automatically generates Lightbringer.toml, spawns the process, captures logs, and shuts it down on exit. Config integration: - LightbringerConfig struct in pkg/config/config.go - Auto-sync lightbringer.grpc_addr to block.lightbringer_endpoint - Validation for all edge cases (no gossip, no RPC, conflicting endpoints) - config.example.toml with full documentation Subprocess management (pkg/lightbringer/): - Spawn Lightbringer with Pdeathsig (Linux) for kernel-enforced cleanup - LockOSThread per Go issue #27505 to prevent premature death signal - Log capture with [lightbringer] prefix on stderr - WaitReady health check via TCP dial with timeout - Graceful SIGTERM -> SIGKILL shutdown escalation - RPC fallback if Lightbringer fails to start or isn't ready - Atomic config file write with 0600 permissions TUI extension: - Mithril Logs and Lightbringer Logs tabs via bubbles/viewport - Tab cycles through metrics views and log views - Reads from per-run log directory via --log-dir flag Signal handling: - Added SIGTERM to main.go signal.NotifyContext for graceful kill response - Startup banner shows "managed sidecar" or "external" mode
Interactive setup wizard (mithril setup): - Quick Start: 3-4 questions with sensible defaults - Full Config: all settings with descriptions and validation - Manual: generates template for manual editing - Custom Bubbletea TUI with Mithril teal theme - Back navigation (Esc) on every screen - Input validation with inline error messages - Disk auto-detection on Linux - RPC endpoint pre-filled per cluster selection Health check (mithril doctor): - Validates config file, cluster, RPC, storage, lightbringer binary, gossip entrypoint, gRPC port, and log directory - Config migration (--migrate) adds missing [lightbringer] and [consensus] sections independently Node status (mithril status): - Shows state file info (last slot, bankhash, shutdown reason) - Probes Mithril RPC, Lightbringer gRPC, and HTTP ports Interactive config editor (mithril config edit): - Section-based editing with looping menu - Back option on every section - Reads current values, writes back preserving TOML structure Lightbringer auto-restart: - MonitorAndRestart with exponential backoff (2s → 60s cap) - Stopping flag prevents false restart after deliberate Stop - Returns on Start failure (prevents stale channel spin) Signal handling: - Added SIGTERM to main.go signal.NotifyContext Security: - Config dir created with 0700 (was 0755) - All generated configs written 0600 - TOML injection prevented (newline stripping, %q, Atoi validation)
- Rename storage.blockstore → storage.shredstore - Move replay.txpar → tuning.txpar - Remove lightbringer.storage (use storage.shredstore) - Add backwards-compatible fallbacks with deprecation warnings - Quick Start skips Lightbringer (disabled by default) - Lightbringer defaults to Disable in Full Config menu - Add Mithril ASCII art logo on setup welcome screen - Remove CPU cores display and direct mode reference - Update config.example.toml descriptions (sidecar, not edge node)
- Add mutex to Pid() to prevent data race on m.cmd - Reset stopping flag in Start() so manager is reusable after Stop() - Change config init/set file permissions from 0644 to 0600 (security) - Fix TOML injection in formatTOMLValue: use %q instead of raw %s - Fix lightbringerStorage to respect --ledger-path CLI flag (getString) - Replace misleading UDP gossip "reachable" check with format validation - Fix [replay] → [tuning] in config init template (missed in prior commit) - Add storage.logs to config init template for consistency - Replace real IP placeholder with RFC 5737 documentation IP - Remove duplicate comment in components.go
…anner - Rebuild config edit using raw Bubbletea (replaces huh library) Same teal theme, cursor navigation, ESC back as setup wizard - Add persistent ASCII logo banner on all TUI screens Full logo on setup welcome, same logo on all other screens - Fix status.go color inconsistencies (teal 86→85, success 42→85, dim 241→#6c6c6c) - Add renderBanner() compact variant to components.go
- New `mithril dashboard` command with split-view TUI - Overview with health checks, services, node state, next steps - Full config view (two-column auto-layout, reads raw TOML) - Inline config editing with menu selections and text input - Doctor, Logs, Disk views with live data refresh - Embedded setup (Create Config) in dashboard right pane - Shared theme package (pkg/tui) for consistent styling - AtomicWriteFile helper for crash-safe config writes - Fix: mithril-tui log reading (64KB tail, symlink validation) - Fix: setup wizard overwrite confirmation instead of silent fail - Fix: 'q' key doesn't quit during text editing - Fix: parallel service probing (6s -> 2s) - Fix: proper child TUI quit interception via message type
LOG* pattern in .gitignore was matching logo.go on case-insensitive filesystems. Changed to explicit LOG and LOG.* patterns.
- Replace magic logPane 0/1 with logPaneMithril/logPaneLightbringer - Extract configFileName constant for Lightbringer.toml - Add defaultRPCPort/defaultLBGRPC/defaultLBHTTP constants - Make ColorSuccess/ColorBorderActive explicitly reference MithrilTeal - Remove internal project references from comments
- Resolve relative binary_path to absolute before subprocess exec - Preserve RPC failover endpoints when saving from editor and dashboard - Sync block.source and lightbringer.enabled with external mode awareness - Fix txpar display to match runtime semantics (sequential when unset) - Only probe Lightbringer services when block delivery uses Lightbringer - Validate Lightbringer config against runtime mode rules in doctor - Handle config parse errors in status and doctor commands - Skip RPC probe when port is disabled (rpc.port=0)
6b6adaa to
960d0f1
Compare
Collaborator
|
LGTM |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Lightbringer can now be managed directly from Mithril. Instead of running and configuring
Lightbringer separately, operators just add a [lightbringer] section to their config.toml and Mithril
handles the rest — starting the process, capturing logs, restarting on crash with backoff, and clean
shutdown when Mithril stops. On Linux, orphan prevention is handled via Pdeathsig.
Added an interactive dashboard (mithril dashboard) that gives a live view of the node — health
checks, service status, config viewer with inline editing, side-by-side mithril and lightbringer
logs, and disk usage. Config editing supports both menu selections for fixed options and text input
with validation for paths, ports, and addresses.
Also added a setup (mithril setup) for better ux that walks through config generation step by step, a doctor
command for health checks, and a shared theme package for consistent styling across all TUI
commands. All config writes use atomic temp-file-then-rename to prevent corruption.