config

package
v1.0.0-beta.10 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2025 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FlagPrefixRollkit = "rollkit."
	FlagPrefixEvnode  = "evnode."

	// FlagRootDir is a flag for specifying the root directory
	FlagRootDir = "home"
	// FlagDBPath is a flag for specifying the database path
	FlagDBPath = FlagPrefixEvnode + "db_path"

	// FlagAggregator is a flag for running node in aggregator mode
	FlagAggregator = FlagPrefixEvnode + "node.aggregator"
	// FlagLight is a flag for running the node in light mode
	FlagLight = FlagPrefixEvnode + "node.light"
	// FlagBlockTime is a flag for specifying the block time
	FlagBlockTime = FlagPrefixEvnode + "node.block_time"
	// FlagLazyAggregator is a flag for enabling lazy aggregation mode that only produces blocks when transactions are available
	FlagLazyAggregator = FlagPrefixEvnode + "node.lazy_mode"
	// FlagMaxPendingHeadersAndData is a flag to limit and pause block production when too many headers or data are waiting for DA confirmation
	FlagMaxPendingHeadersAndData = FlagPrefixEvnode + "node.max_pending_headers_and_data"
	// FlagLazyBlockTime is a flag for specifying the maximum interval between blocks in lazy aggregation mode
	FlagLazyBlockTime = FlagPrefixEvnode + "node.lazy_block_interval"
	// FlagReadinessWindowSeconds configures the time window (in seconds) used to calculate readiness threshold
	FlagReadinessWindowSeconds = FlagPrefixEvnode + "node.readiness_window_seconds"
	// FlagReadinessMaxBlocksBehind configures how many blocks behind best-known head is still considered ready
	FlagReadinessMaxBlocksBehind = FlagPrefixEvnode + "node.readiness_max_blocks_behind"
	// FlagClearCache is a flag for clearing the cache
	FlagClearCache = FlagPrefixEvnode + "clear_cache"

	// FlagDAAddress is a flag for specifying the data availability layer address
	FlagDAAddress = FlagPrefixEvnode + "da.address"
	// FlagDAAuthToken is a flag for specifying the data availability layer auth token
	FlagDAAuthToken = FlagPrefixEvnode + "da.auth_token" // #nosec G101
	// FlagDABlockTime is a flag for specifying the data availability layer block time
	FlagDABlockTime = FlagPrefixEvnode + "da.block_time"
	// FlagDANamespace is a flag for specifying the DA namespace ID
	FlagDANamespace = FlagPrefixEvnode + "da.namespace"
	// FlagDADataNamespace is a flag for specifying the DA data namespace ID
	FlagDADataNamespace = FlagPrefixEvnode + "da.data_namespace"
	// FlagDASubmitOptions is a flag for data availability submit options
	FlagDASubmitOptions = FlagPrefixEvnode + "da.submit_options"
	// FlagDASigningAddresses is a flag for specifying multiple DA signing addresses
	FlagDASigningAddresses = FlagPrefixEvnode + "da.signing_addresses"
	// FlagDAMempoolTTL is a flag for specifying the DA mempool TTL
	FlagDAMempoolTTL = FlagPrefixEvnode + "da.mempool_ttl"
	// FlagDAMaxSubmitAttempts is a flag for specifying the maximum DA submit attempts
	FlagDAMaxSubmitAttempts = FlagPrefixEvnode + "da.max_submit_attempts"

	// FlagP2PListenAddress is a flag for specifying the P2P listen address
	FlagP2PListenAddress = FlagPrefixEvnode + "p2p.listen_address"
	// FlagP2PPeers is a flag for specifying the P2P peers
	FlagP2PPeers = FlagPrefixEvnode + "p2p.peers"
	// FlagP2PBlockedPeers is a flag for specifying the P2P blocked peers
	FlagP2PBlockedPeers = FlagPrefixEvnode + "p2p.blocked_peers"
	// FlagP2PAllowedPeers is a flag for specifying the P2P allowed peers
	FlagP2PAllowedPeers = FlagPrefixEvnode + "p2p.allowed_peers"

	// FlagPrometheus is a flag for enabling Prometheus metrics
	FlagPrometheus = FlagPrefixEvnode + "instrumentation.prometheus"
	// FlagPrometheusListenAddr is a flag for specifying the Prometheus listen address
	FlagPrometheusListenAddr = FlagPrefixEvnode + "instrumentation.prometheus_listen_addr"
	// FlagMaxOpenConnections is a flag for specifying the maximum number of open connections
	FlagMaxOpenConnections = FlagPrefixEvnode + "instrumentation.max_open_connections"
	// FlagPprof is a flag for enabling pprof profiling endpoints for runtime debugging
	FlagPprof = FlagPrefixEvnode + "instrumentation.pprof"
	// FlagPprofListenAddr is a flag for specifying the pprof listen address
	FlagPprofListenAddr = FlagPrefixEvnode + "instrumentation.pprof_listen_addr"

	// FlagLogLevel is a flag for specifying the log level
	FlagLogLevel = FlagPrefixEvnode + "log.level"
	// FlagLogFormat is a flag for specifying the log format
	FlagLogFormat = FlagPrefixEvnode + "log.format"
	// FlagLogTrace is a flag for enabling stack traces in error logs
	FlagLogTrace = FlagPrefixEvnode + "log.trace"

	// FlagSignerType is a flag for specifying the signer type
	FlagSignerType = FlagPrefixEvnode + "signer.signer_type"
	// FlagSignerPath is a flag for specifying the signer path
	FlagSignerPath = FlagPrefixEvnode + "signer.signer_path"

	// FlagSignerPassphraseFile is a flag for specifying the file containing the signer passphrase
	FlagSignerPassphraseFile = FlagPrefixEvnode + "signer.passphrase_file"

	// FlagRPCAddress is a flag for specifying the RPC server address
	FlagRPCAddress = FlagPrefixEvnode + "rpc.address"
	// FlagRPCEnableDAVisualization is a flag for enabling DA visualization endpoints
	FlagRPCEnableDAVisualization = FlagPrefixEvnode + "rpc.enable_da_visualization"
)
View Source
const (
	// ConfigFileName is the base name of the evolve configuration file without extension.
	ConfigFileName = "evnode"
	// ConfigExtension is the file extension for the configuration file without the leading dot.
	ConfigExtension = "yaml"
	// ConfigPath is the filename for the evolve configuration file.
	ConfigName = ConfigFileName + "." + ConfigExtension
	// AppConfigDir is the directory name for the app configuration.
	AppConfigDir = "config"
)

Variables

DefaultRootDir returns the default root directory for evolve

View Source
var ErrReadYaml = fmt.Errorf("reading %s", ConfigName)

ErrReadYaml is the error returned when reading the evnode.yml file fails.

Functions

func AddFlags

func AddFlags(cmd *cobra.Command)

AddFlags adds Evolve specific configuration options to cobra Command.

func AddGlobalFlags

func AddGlobalFlags(cmd *cobra.Command, defaultHome string)

AddGlobalFlags registers the basic configuration flags that are common across applications. This includes logging configuration and root directory settings. It should be used in apps that do not already define their logger and home flag.

func DefaultRootDirWithName

func DefaultRootDirWithName(appName string) string

DefaultRootDirWithName returns the default root directory for an application, based on the app name and the user's home directory

func GetMultiAddr

func GetMultiAddr(addr string) (multiaddr.Multiaddr, error)

GetMultiAddr converts single Cosmos-style network address into Multiaddr. Input format: [protocol://][<NODE_ID>@]<IPv4>:<PORT>

func TranslateAddresses

func TranslateAddresses(conf *Config) error

TranslateAddresses updates conf by changing Cosmos-style addresses to Multiaddr format.

Types

type Config

type Config struct {
	RootDir    string `mapstructure:"-" yaml:"-" comment:"Root directory where rollkit files are located"`
	ClearCache bool   `mapstructure:"-" yaml:"-" comment:"Clear the cache"`

	// Base configuration
	DBPath string `mapstructure:"db_path" yaml:"db_path" comment:"Path inside the root directory where the database is located"`
	// P2P configuration
	P2P P2PConfig `mapstructure:"p2p" yaml:"p2p"`

	// Node specific configuration
	Node NodeConfig `mapstructure:"node" yaml:"node"`

	// Data availability configuration
	DA DAConfig `mapstructure:"da" yaml:"da"`

	// RPC configuration
	RPC RPCConfig `mapstructure:"rpc" yaml:"rpc"`

	// Instrumentation configuration
	Instrumentation *InstrumentationConfig `mapstructure:"instrumentation" yaml:"instrumentation"`

	// Logging configuration
	Log LogConfig `mapstructure:"log" yaml:"log"`

	// Remote signer configuration
	Signer SignerConfig `mapstructure:"signer" yaml:"signer"`
}

Config stores Rollkit configuration.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig keeps default values of NodeConfig

func Load

func Load(cmd *cobra.Command) (Config, error)

Load loads the node configuration in the following order of precedence: 1. DefaultNodeConfig() (lowest priority) 2. YAML configuration file 3. Command line flags (highest priority)

func LoadFromViper

func LoadFromViper(inputViper *viper.Viper) (Config, error)

LoadFromViper loads the node configuration from a provided viper instance. It gets the home directory from the input viper, sets up a new viper instance to read the config file, and then merges both instances. This allows getting configuration values from both command line flags (or other sources) and the config file, with the same precedence as Load.

func (*Config) ConfigPath

func (c *Config) ConfigPath() string

ConfigPath returns the path to the configuration file.

func (*Config) SaveAsYaml

func (c *Config) SaveAsYaml() error

SaveAsYaml saves the current configuration to a YAML file.

func (*Config) Validate

func (c *Config) Validate() error

Validate validates the config and ensures that the root directory exists. It creates the directory if it does not exist.

type DAConfig

type DAConfig struct {
	Address           string          `` /* 184-byte string literal not displayed */
	AuthToken         string          `` /* 164-byte string literal not displayed */
	SubmitOptions     string          `` /* 186-byte string literal not displayed */
	SigningAddresses  []string        `` /* 258-byte string literal not displayed */
	Namespace         string          `` /* 185-byte string literal not displayed */
	DataNamespace     string          `` /* 143-byte string literal not displayed */
	BlockTime         DurationWrapper `` /* 301-byte string literal not displayed */
	MempoolTTL        uint64          `` /* 184-byte string literal not displayed */
	MaxSubmitAttempts int             `` /* 216-byte string literal not displayed */
}

DAConfig contains all Data Availability configuration parameters

func (*DAConfig) GetDataNamespace

func (d *DAConfig) GetDataNamespace() string

GetDataNamespace returns the namespace for data submissions, falling back to the header namespace if not set

func (*DAConfig) GetNamespace

func (d *DAConfig) GetNamespace() string

GetNamespace returns the namespace for header submissions.

type DurationWrapper

type DurationWrapper struct {
	time.Duration
}

DurationWrapper is a wrapper for time.Duration that implements encoding.TextMarshaler and encoding.TextUnmarshaler needed for YAML marshalling/unmarshalling especially for time.Duration

func (DurationWrapper) MarshalText

func (d DurationWrapper) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler to format the duration as text

func (*DurationWrapper) UnmarshalText

func (d *DurationWrapper) UnmarshalText(text []byte) error

UnmarshalText implements encoding.TextUnmarshaler to parse the duration from text

type InstrumentationConfig

type InstrumentationConfig struct {
	// When true, Prometheus metrics are served under /metrics on
	// PrometheusListenAddr.
	// Check out the documentation for the list of available metrics.
	Prometheus bool `yaml:"prometheus" comment:"Enable Prometheus metrics"` // When true, Prometheus metrics are served

	// Address to listen for Prometheus collector(s) connections.
	PrometheusListenAddr string `mapstructure:"prometheus_listen_addr" yaml:"prometheus_listen_addr" comment:"Address to listen for Prometheus metrics"`

	// Maximum number of simultaneous connections.
	// If you want to accept a larger number than the default, make sure
	// you increase your OS limits.
	// 0 - unlimited.
	MaxOpenConnections int `mapstructure:"max_open_connections" yaml:"max_open_connections" comment:"Maximum number of simultaneous connections"`

	// Instrumentation namespace.
	Namespace string `yaml:"namespace" comment:"Namespace for metrics"` // Instrumentation namespace

	// When true, pprof endpoints are served under /debug/pprof/ on
	// PprofListenAddr. This enables runtime profiling of the application.
	// Available endpoints include:
	// - /debug/pprof/          - Index page
	// - /debug/pprof/cmdline   - Command line arguments
	// - /debug/pprof/profile   - CPU profile
	// - /debug/pprof/symbol    - Symbol lookup
	// - /debug/pprof/trace     - Execution trace
	// - /debug/pprof/goroutine - Goroutine stack dumps
	// - /debug/pprof/heap      - Heap memory profile
	// - /debug/pprof/mutex     - Mutex contention profile
	// - /debug/pprof/block     - Block profile
	// - /debug/pprof/allocs    - Allocation profile
	Pprof bool `yaml:"pprof" comment:"Enable pprof profiling server"` // When true, pprof endpoints are served

	// Address to listen for pprof connections.
	// Default is ":6060" which is the standard port for pprof.
	PprofListenAddr string `mapstructure:"pprof_listen_addr" yaml:"pprof_listen_addr" comment:"Address to listen for pprof connections"`
}

InstrumentationConfig defines the configuration for metrics reporting.

func DefaultInstrumentationConfig

func DefaultInstrumentationConfig() *InstrumentationConfig

DefaultInstrumentationConfig returns a default configuration for metrics reporting.

func (*InstrumentationConfig) GetPprofListenAddr

func (cfg *InstrumentationConfig) GetPprofListenAddr() string

GetPprofListenAddr returns the address to listen for pprof connections. If PprofListenAddr is empty, it returns the default pprof port ":6060".

func (*InstrumentationConfig) IsPprofEnabled

func (cfg *InstrumentationConfig) IsPprofEnabled() bool

IsPprofEnabled returns true if pprof endpoints are enabled.

func (*InstrumentationConfig) IsPrometheusEnabled

func (cfg *InstrumentationConfig) IsPrometheusEnabled() bool

IsPrometheusEnabled returns true if Prometheus metrics are enabled.

func (*InstrumentationConfig) ValidateBasic

func (cfg *InstrumentationConfig) ValidateBasic() error

ValidateBasic performs basic validation (checking param bounds, etc.) and returns an error if any check fails.

type LogConfig

type LogConfig struct {
	Level  string `mapstructure:"level" yaml:"level" comment:"Log level (debug, info, warn, error)"`
	Format string `mapstructure:"format" yaml:"format" comment:"Log format (text, json)"`
	Trace  bool   `mapstructure:"trace" yaml:"trace" comment:"Enable stack traces in error logs"`
}

LogConfig contains all logging configuration parameters

type NodeConfig

type NodeConfig struct {
	// Node mode configuration
	Aggregator bool `yaml:"aggregator" comment:"Run node in aggregator mode"`
	Light      bool `yaml:"light" comment:"Run node in light mode"`

	// Block management configuration
	BlockTime                DurationWrapper `` /* 141-byte string literal not displayed */
	MaxPendingHeadersAndData uint64          `` /* 275-byte string literal not displayed */
	LazyMode                 bool            `` /* 252-byte string literal not displayed */
	LazyBlockInterval        DurationWrapper `` /* 272-byte string literal not displayed */

	// Readiness / health configuration
	ReadinessWindowSeconds   uint64 `` /* 189-byte string literal not displayed */
	ReadinessMaxBlocksBehind uint64 `` /* 206-byte string literal not displayed */
}

NodeConfig contains all Rollkit specific configuration parameters

type P2PConfig

type P2PConfig struct {
	ListenAddress string `mapstructure:"listen_address" yaml:"listen_address" comment:"Address to listen for incoming connections (host:port)"`
	Peers         string `mapstructure:"peers" yaml:"peers" comment:"Comma separated list of peers to connect to"`
	BlockedPeers  string `mapstructure:"blocked_peers" yaml:"blocked_peers" comment:"Comma separated list of peer IDs to block from connecting"`
	AllowedPeers  string `mapstructure:"allowed_peers" yaml:"allowed_peers" comment:"Comma separated list of peer IDs to allow connections from"`
}

P2PConfig contains all peer-to-peer networking configuration parameters

type RPCConfig

type RPCConfig struct {
	Address               string `mapstructure:"address" yaml:"address" comment:"Address to bind the RPC server to (host:port). Default: 127.0.0.1:7331"`
	EnableDAVisualization bool   `` /* 161-byte string literal not displayed */
}

RPCConfig contains all RPC server configuration parameters

type SignerConfig

type SignerConfig struct {
	SignerType string `mapstructure:"signer_type" yaml:"signer_type" comment:"Type of remote signer to use (file, grpc)"`
	SignerPath string `mapstructure:"signer_path" yaml:"signer_path" comment:"Path to the signer file or address"`
}

SignerConfig contains all signer configuration parameters

Jump to

Keyboard shortcuts

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