Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions cmd/mithril/configcmd/edit.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"strconv"
"strings"

"github.com/Overclock-Validator/mithril/pkg/config"
"github.com/Overclock-Validator/mithril/pkg/tui"
tea "github.com/charmbracelet/bubbletea"
"github.com/charmbracelet/lipgloss"
Expand Down Expand Up @@ -296,8 +297,8 @@ func (m editModel) currentItems() []edItem {
return items
case edScrLightbringerQuiet:
return []edItem{
{label: "Normal logs", value: "false", desc: "Show all info messages (default)"},
{label: "Quiet mode", value: "true", desc: "Only warnings and errors — recommended for long runs"},
{label: "Quiet mode", value: "true", desc: "Only warnings and errors — default and recommended for long runs"},
{label: "Normal logs", value: "false", desc: "Show all info messages"},
{isSep: true},
{label: "← Back", value: "_back"},
}
Expand Down Expand Up @@ -441,7 +442,7 @@ func (m *editModel) handleSelect(value string) {
m.pushInput(edScrGossip)
case "disable":
m.lbEnabled = false
m.lbQuiet = false // Reset dependent state so disable→re-enable starts clean.
m.lbQuiet = config.LightbringerQuietDefault // Reset dependent state so disable→re-enable starts clean.
m.goBack()
case "quiet":
m.pushMenu(edScrLightbringerQuiet)
Expand Down Expand Up @@ -906,6 +907,7 @@ func runConfigEdit() {
}

v := viper.New()
config.ApplyDefaults(v)
v.SetConfigFile(configFile)
if err := v.ReadInConfig(); err != nil {
fmt.Printf("Error reading config: %v\n", err)
Expand Down
8 changes: 4 additions & 4 deletions cmd/mithril/configcmd/edit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ func TestEditor_ScrLightbringerQuiet_False(t *testing.T) {
assert.False(t, m.lbQuiet, "picking 'false' should set lbQuiet=false")
}

// TestEditor_DisableLB_ResetsQuiet verifies that "disable" resets m.lbQuiet
// so a later re-enable starts clean (no stale quiet state carried over).
func TestEditor_DisableLB_ResetsQuiet(t *testing.T) {
// TestEditor_DisableLB_ResetsQuiet verifies that "disable" resets m.lbQuiet to
// the default so a later re-enable starts clean (no stale quiet state carried over).
func TestEditor_DisableLB_ResetsQuietDefault(t *testing.T) {
m := &editModel{
screen: edScrLightbringer,
lbEnabled: true,
lbQuiet: true, // previously enabled quiet
}
m.handleSelect("disable")
assert.False(t, m.lbEnabled, "disable should set lbEnabled=false")
assert.False(t, m.lbQuiet, "disable should reset lbQuiet to avoid stale state on re-enable")
assert.True(t, m.lbQuiet, "disable should reset lbQuiet to the default to avoid stale state on re-enable")
}

// TestEditor_EnableLB_PreservesQuiet ensures enable does not clobber quiet.
Expand Down
4 changes: 2 additions & 2 deletions cmd/mithril/dashboardcmd/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -767,8 +767,8 @@ func menuOptionsFor(section, key string) []editOption {
}
case "lightbringer.quiet":
return []editOption{
{label: "false", value: "false", desc: "Show all info messages (default)"},
{label: "true", value: "true", desc: "Only warnings and errors — recommended for long runs"},
{label: "true", value: "true", desc: "Only warnings and errors — default and recommended for long runs"},
{label: "false", value: "false", desc: "Show all info messages"},
}
case "log.level":
return []editOption{
Expand Down
79 changes: 41 additions & 38 deletions cmd/mithril/dashboardcmd/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"sync"
"time"

"github.com/Overclock-Validator/mithril/pkg/config"
"github.com/Overclock-Validator/mithril/pkg/tui"
"github.com/spf13/viper"
)
Expand Down Expand Up @@ -60,30 +61,31 @@ func readState(accountsPath string) *nodeState {
// ── Config reading ──────────────────────────────────────────────────────

type configData struct {
cluster string
rpcEndpoints []string
blockSource string
lbEnabled bool
lbGossip string
lbGrpcAddr string
cluster string
rpcEndpoints []string
blockSource string
lbEnabled bool
lbGossip string
lbGrpcAddr string
lbRpcAddr string
lbExternalEndpoint string // block.lightbringer_endpoint for external LB mode
lbBinaryPath string
lbQuiet bool
accountsPath string
snapshotsPath string
shredstorePath string
logsPath string
txpar string
blockMaxRPS string
blockInflight string
rpcPort string
logLevel string
bootstrapMode string
accountsPath string
snapshotsPath string
shredstorePath string
logsPath string
txpar string
blockMaxRPS string
blockInflight string
rpcPort string
logLevel string
bootstrapMode string
}

func readConfig(configFile string) *configData {
v := viper.New()
config.ApplyDefaults(v)
v.SetConfigFile(configFile)
if err := v.ReadInConfig(); err != nil {
return nil
Expand All @@ -106,42 +108,42 @@ func readConfig(configFile string) *configData {
}

return &configData{
cluster: cluster,
rpcEndpoints: v.GetStringSlice("network.rpc"),
blockSource: v.GetString("block.source"),
lbEnabled: v.GetBool("lightbringer.enabled"),
lbGossip: v.GetString("lightbringer.gossip_entrypoint"),
lbGrpcAddr: v.GetString("lightbringer.grpc_addr"),
cluster: cluster,
rpcEndpoints: v.GetStringSlice("network.rpc"),
blockSource: v.GetString("block.source"),
lbEnabled: v.GetBool("lightbringer.enabled"),
lbGossip: v.GetString("lightbringer.gossip_entrypoint"),
lbGrpcAddr: v.GetString("lightbringer.grpc_addr"),
lbRpcAddr: v.GetString("lightbringer.rpc_addr"),
lbQuiet: v.GetBool("lightbringer.quiet"),
lbExternalEndpoint: v.GetString("block.lightbringer_endpoint"),
lbBinaryPath: v.GetString("lightbringer.binary_path"),
accountsPath: v.GetString("storage.accounts"),
snapshotsPath: v.GetString("storage.snapshots"),
shredstorePath: v.GetString("storage.shredstore"),
logsPath: logsPath,
txpar: txpar,
blockMaxRPS: v.GetString("block.max_rps"),
blockInflight: v.GetString("block.max_inflight"),
rpcPort: v.GetString("rpc.port"),
logLevel: v.GetString("log.level"),
bootstrapMode: v.GetString("bootstrap.mode"),
accountsPath: v.GetString("storage.accounts"),
snapshotsPath: v.GetString("storage.snapshots"),
shredstorePath: v.GetString("storage.shredstore"),
logsPath: logsPath,
txpar: txpar,
blockMaxRPS: v.GetString("block.max_rps"),
blockInflight: v.GetString("block.max_inflight"),
rpcPort: v.GetString("rpc.port"),
logLevel: v.GetString("log.level"),
bootstrapMode: v.GetString("bootstrap.mode"),
}
}

// ── Service probing ─────────────────────────────────────────────────────

type serviceStatus struct {
name string
addr string
up bool
name string
addr string
up bool
}

// Default service addresses (must match config template defaults).
const (
defaultRPCPort = "8899"
defaultLBGRPC = "127.0.0.1:3001"
defaultLBHTTP = "127.0.0.1:3000"
defaultRPCPort = "8899"
defaultLBGRPC = "127.0.0.1:3001"
defaultLBHTTP = "127.0.0.1:3000"
)

func probeServices(cfg *configData) []serviceStatus {
Expand Down Expand Up @@ -490,6 +492,7 @@ func saveConfigValue(configFile, section, key, value string) error {
case fullKey == "network.rpc":
// Preserve failover endpoints — read existing array, update first element
v := viper.New()
config.ApplyDefaults(v)
v.SetConfigFile(configFile)
if err := v.ReadInConfig(); err == nil {
existing := v.GetStringSlice("network.rpc")
Expand Down
Loading
Loading