config

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 11, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const LightbringerQuietDefault = true

Variables

View Source
var ConfigFile string

ConfigFile holds the path to the config file (set via --config flag)

Functions

func ApplyDefaults

func ApplyDefaults(v *viper.Viper)

func GetBool

func GetBool(key string) bool

GetBool returns a bool value from viper (config file or flag)

func GetFloat64

func GetFloat64(key string) float64

GetFloat64 returns a float64 value from viper (config file or flag)

func GetInt

func GetInt(key string) int

GetInt returns an int value from viper (config file or flag)

func GetInt64

func GetInt64(key string) int64

GetInt64 returns an int64 value from viper (config file or flag)

func GetString

func GetString(key string) string

GetString returns a string value from viper (config file or flag)

func GetStringSlice

func GetStringSlice(key string) []string

GetStringSlice returns a string slice value from viper (config file or flag)

func GetUint64

func GetUint64(key string) uint64

GetUint64 returns a uint64 value from viper (config file or flag)

func InitConfig

func InitConfig() error

InitConfig loads configuration from TOML file. If no --config flag is provided, defaults to "config.toml" in current directory. CLI flag precedence is handled separately in initConfigAndBindFlags.

func IsProductionLayout

func IsProductionLayout(p StoragePaths) bool

IsProductionLayout reports whether all four paths match productionStoragePaths(). Returns false for mixed sets so user-edited configs are not mislabeled.

func IsSet

func IsSet(key string) bool

IsSet returns true if a key has been set (either via config file or flag)

Types

type BlockConfig

type BlockConfig struct {
	Source               string `toml:"source" mapstructure:"source"`                               // "rpc" or "lightbringer"
	LightbringerEndpoint string `toml:"lightbringer_endpoint" mapstructure:"lightbringer_endpoint"` // Lightbringer endpoint (optional)

	// Global fetch tuning
	MaxRPS          int `toml:"max_rps" mapstructure:"max_rps"`                           // Rate limit (requests per second)
	MaxInflight     int `toml:"max_inflight" mapstructure:"max_inflight"`                 // Max concurrent workers
	TipPollMs       int `toml:"tip_poll_interval_ms" mapstructure:"tip_poll_interval_ms"` // Tip poll interval in ms
	TipSafetyMargin int `toml:"tip_safety_margin" mapstructure:"tip_safety_margin"`       // Don't fetch within N slots of tip

	// Mode thresholds (hysteresis)
	NearTipThreshold int `toml:"near_tip_threshold" mapstructure:"near_tip_threshold"` // Enter near-tip when gap <= this
	CatchupThreshold int `toml:"catchup_threshold" mapstructure:"catchup_threshold"`   // Exit near-tip when gap >= this

	// Tip gate: only apply safety margin when gap > this
	CatchupTipGateThreshold int `toml:"catchup_tip_gate_threshold" mapstructure:"catchup_tip_gate_threshold"`

	// Near-tip tuning
	NearTipPollMs    int `toml:"near_tip_poll_interval_ms" mapstructure:"near_tip_poll_interval_ms"` // Faster poll in near-tip
	NearTipLookahead int `toml:"near_tip_lookahead" mapstructure:"near_tip_lookahead"`               // Slots ahead to schedule
}

BlockConfig holds block source configuration

type Config

type Config struct {
	// Top-level (matches Firedancer style)
	Name             string `toml:"name" mapstructure:"name"`
	ScratchDirectory string `toml:"scratch_directory" mapstructure:"scratch_directory"` // was: scratchdir

	// Sections
	Ledger       LedgerConfig       `toml:"ledger" mapstructure:"ledger"`
	Rpc          RpcConfig          `toml:"rpc" mapstructure:"rpc"`
	Replay       ReplayConfig       `toml:"replay" mapstructure:"replay"`
	Block        BlockConfig        `toml:"block" mapstructure:"block"`
	Consensus    ConsensusConfig    `toml:"consensus" mapstructure:"consensus"`
	Lightbringer LightbringerConfig `toml:"lightbringer" mapstructure:"lightbringer"`
	Snapshot     SnapshotConfig     `toml:"snapshot" mapstructure:"snapshot"`
	Development  DevelopmentConfig  `toml:"development" mapstructure:"development"`
	Reporting    ReportingConfig    `toml:"reporting" mapstructure:"reporting"`
	Log          LogConfig          `toml:"log" mapstructure:"log"`
}

Config holds all configuration options for Mithril (Firedancer-style hierarchy)

type ConsensusConfig

type ConsensusConfig struct {
	SkipPathMaxDepth int    `toml:"skip_path_max_depth" mapstructure:"skip_path_max_depth"` // Max slots the skip-path solver explores (default: 64)
	UnresolvedPolicy string `toml:"unresolved_policy" mapstructure:"unresolved_policy"`     // "halt" or "warn" (default: "halt")
	EnforceOnSource  string `toml:"enforce_on_source" mapstructure:"enforce_on_source"`     // "lightbringer" or "all" (default: "lightbringer")
}

ConsensusConfig holds vote-anchored consensus configuration

type DebugConfig

type DebugConfig struct {
	TransactionSignatures     []string `toml:"transaction_signatures" mapstructure:"transaction_signatures"` // was: debugtx
	AccountWrites             []string `toml:"account_writes" mapstructure:"account_writes"`                 // was: debugacctwrites
	DumpEpochVotingRewardDiff bool     `toml:"dump_epoch_voting_reward_diff" mapstructure:"dump_epoch_voting_reward_diff"`
}

DebugConfig holds debug-related configuration

type DevelopmentConfig

type DevelopmentConfig struct {
	ZstdDecoderConcurrency   int         `toml:"zstd_decoder_concurrency" mapstructure:"zstd_decoder_concurrency"`       // was: zstd-decoder-concurrency
	MaxConcurrentFlushers    int         `toml:"max_concurrent_flushers" mapstructure:"max_concurrent_flushers"`         // was: max-concurrent-flushers
	ParamArenaSizeMB         uint64      `toml:"param_arena_size_mb" mapstructure:"param_arena_size_mb"`                 // was: param-arena-size-mb
	BorrowedAccountArenaSize uint64      `toml:"borrowed_account_arena_size" mapstructure:"borrowed_account_arena_size"` // was: borrowed-account-arena-size
	UsePool                  bool        `toml:"use_pool" mapstructure:"use_pool"`                                       // was: use-pool
	Pprof                    PprofConfig `toml:"pprof" mapstructure:"pprof"`
	Debug                    DebugConfig `toml:"debug" mapstructure:"debug"`
}

DevelopmentConfig holds development/tuning configuration (matches Firedancer [development] section)

type LedgerConfig

type LedgerConfig struct {
	Path                string `toml:"path" mapstructure:"path"`                                   // was: blockdir
	AccountsPath        string `toml:"accounts_path" mapstructure:"accounts_path"`                 // was: out
	SnapshotArchivePath string `toml:"snapshot_archive_path" mapstructure:"snapshot_archive_path"` // was: path
	IncrementalSnapshot string `toml:"incremental_snapshot" mapstructure:"incremental_snapshot"`   // was: incremental-snapshot-filename
}

LedgerConfig holds ledger-related configuration (matches Firedancer [ledger] section)

type LightbringerConfig

type LightbringerConfig struct {
	Enabled          bool   `toml:"enabled" mapstructure:"enabled"`                     // Enable managed Lightbringer sidecar
	BinaryPath       string `toml:"binary_path" mapstructure:"binary_path"`             // Path to lightbringer binary
	GossipEntrypoint string `toml:"gossip_entrypoint" mapstructure:"gossip_entrypoint"` // Solana gossip entrypoint (required when enabled)
	Storage          string `toml:"storage" mapstructure:"storage"`                     // Shred storage directory
	RpcAddr          string `toml:"rpc_addr" mapstructure:"rpc_addr"`                   // Debug HTTP endpoint
	GrpcAddr         string `toml:"grpc_addr" mapstructure:"grpc_addr"`                 // gRPC stream endpoint (auto-synced to block.lightbringer_endpoint)
	ConfigDir        string `toml:"config_dir" mapstructure:"config_dir"`               // Directory to write Lightbringer.toml

	// Optional: InfluxDB metrics — written as [influxdb] section in generated Lightbringer.toml
	InfluxdbHost     string `toml:"influxdb_host" mapstructure:"influxdb_host"`
	InfluxdbDatabase string `toml:"influxdb_database" mapstructure:"influxdb_database"`
	InfluxdbToken    string `toml:"influxdb_token" mapstructure:"influxdb_token"`

	// Optional: Block confirmation — written as [block_confirmation] section in generated Lightbringer.toml
	BlockConfirmRpcHTTP string `toml:"block_confirmation_rpc_http" mapstructure:"block_confirmation_rpc_http"`
	BlockConfirmRpcWS   string `toml:"block_confirmation_rpc_websocket" mapstructure:"block_confirmation_rpc_websocket"`

	// Quiet suppresses Lightbringer info/debug logs when true. Defaults to true. Written as
	// [log] quiet = true in the generated Lightbringer.toml.
	Quiet bool `toml:"quiet" mapstructure:"quiet"`
}

LightbringerConfig holds Lightbringer sidecar configuration. When Enabled, Mithril manages Lightbringer's lifecycle: generates its config, spawns the process, captures logs, and shuts it down on exit.

type LogConfig

type LogConfig struct {
	Dir        string `toml:"dir" mapstructure:"dir"`                   // Log directory (default: /mnt/mithril-logs)
	Level      string `toml:"level" mapstructure:"level"`               // Log level: debug, info, warn, error
	ToStdout   bool   `toml:"to_stdout" mapstructure:"to_stdout"`       // Also write to stdout (default: true)
	MaxSizeMB  int    `toml:"max_size_mb" mapstructure:"max_size_mb"`   // Max log file size in MB before rotation
	MaxAgeDays int    `toml:"max_age_days" mapstructure:"max_age_days"` // Delete logs older than this many days
	MaxBackups int    `toml:"max_backups" mapstructure:"max_backups"`   // Keep up to N old log files
}

LogConfig holds logging configuration

type PprofConfig

type PprofConfig struct {
	Port           int64  `toml:"port" mapstructure:"port"`                         // was: pprofport
	CpuProfilePath string `toml:"cpu_profile_path" mapstructure:"cpu_profile_path"` // was: cpuprof-filename
}

PprofConfig holds pprof-related configuration

type ReplayConfig

type ReplayConfig struct {
	Txpar    int64 `toml:"txpar" mapstructure:"txpar"`
	NumSlots int64 `toml:"num_slots" mapstructure:"num_slots"`
	EndSlot  int64 `toml:"end_slot" mapstructure:"end_slot"`
}

ReplayConfig holds replay-related configuration

type ReportingConfig

type ReportingConfig struct {
	MetricsPath string `toml:"metrics_path" mapstructure:"metrics_path"` // was: metrics-filename
}

ReportingConfig holds metrics/reporting configuration (matches Firedancer [reporting] section)

type RpcConfig

type RpcConfig struct {
	Rpc  []string `toml:"rpc" mapstructure:"rpc"`   // List of RPC endpoints
	Port int      `toml:"port" mapstructure:"port"` // was: rpc-server-port
}

RpcConfig holds RPC-related configuration (matches Firedancer [rpc] section)

type SnapshotConfig

type SnapshotConfig struct {
	// MaxFullSnapshots controls both saving and retention:
	//   0 = Stream-only mode (don't save snapshots to disk)
	//   1+ = Save snapshots and keep up to N on disk
	MaxFullSnapshots int    `toml:"max_full_snapshots" mapstructure:"max_full_snapshots"`
	DownloadPath     string `toml:"download_path" mapstructure:"download_path"` // Path to download snapshot to

	// Output verbosity
	Verbose bool `toml:"verbose" mapstructure:"verbose"` // Enable detailed statistics output

	// AlwaysDownloadFull controls whether to always download a new full snapshot
	// even if a valid one exists on disk within the age threshold.
	// When false (default), uses existing full snapshot if fresh enough.
	AlwaysDownloadFull bool `toml:"always_download_full" mapstructure:"always_download_full"`

	// Stage 1: Fast parallel triage
	Stage1WarmKiB     int64 `toml:"stage1_warm_kib" mapstructure:"stage1_warm_kib"`
	Stage1WindowKiB   int64 `toml:"stage1_window_kib" mapstructure:"stage1_window_kib"`
	Stage1Windows     int   `toml:"stage1_windows" mapstructure:"stage1_windows"`
	Stage1TimeoutMS   int64 `toml:"stage1_timeout_ms" mapstructure:"stage1_timeout_ms"`
	Stage1Concurrency int   `toml:"stage1_concurrency" mapstructure:"stage1_concurrency"`

	// Stage 2: Sustained speed test
	Stage2TopK       int     `toml:"stage2_top_k" mapstructure:"stage2_top_k"`
	Stage2WarmSec    int     `toml:"stage2_warm_sec" mapstructure:"stage2_warm_sec"`
	Stage2MeasureSec int     `toml:"stage2_measure_sec" mapstructure:"stage2_measure_sec"`
	Stage2MinRatio   float64 `toml:"stage2_min_ratio" mapstructure:"stage2_min_ratio"`
	Stage2MinAbsMBs  float64 `toml:"stage2_min_abs_mbs" mapstructure:"stage2_min_abs_mbs"`

	// Node filtering
	MaxRTTMs            int      `toml:"max_rtt_ms" mapstructure:"max_rtt_ms"`
	TCPTimeoutMs        int      `toml:"tcp_timeout_ms" mapstructure:"tcp_timeout_ms"`
	MinNodeVersion      string   `toml:"min_node_version" mapstructure:"min_node_version"`
	AllowedNodeVersions []string `toml:"allowed_node_versions" mapstructure:"allowed_node_versions"`

	// Snapshot age thresholds
	FullThreshold        int `toml:"full_threshold" mapstructure:"full_threshold"`
	IncrementalThreshold int `toml:"incremental_threshold" mapstructure:"incremental_threshold"`
	SafetyMarginSlots    int `toml:"safety_margin_slots" mapstructure:"safety_margin_slots"`

	// Performance
	WorkerCount int `toml:"worker_count" mapstructure:"worker_count"`

	// Fallback resilience
	MaxSnapshotURLAttempts int `toml:"max_snapshot_url_attempts" mapstructure:"max_snapshot_url_attempts"`

	// Incremental snapshot selection
	MinIncrementalSpeedMBs float64 `toml:"min_incremental_speed_mbs" mapstructure:"min_incremental_speed_mbs"`
}

SnapshotConfig holds snapshot download configuration

type StoragePaths

type StoragePaths struct {
	Accounts   string
	Snapshots  string
	Logs       string
	Shredstore string
}

StoragePaths holds the four Mithril storage path defaults.

func DefaultStoragePaths

func DefaultStoragePaths() StoragePaths

DefaultStoragePaths returns /mnt/mithril-* when /mnt/mithril-accounts is writable, otherwise ~/.mithril/*. Detection is all-or-nothing on the /mnt/mithril-accounts probe so path roots are never mixed.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL