func DefaultRPCConfig() *RPCConfig {
	return &RPCConfig{
		ListenAddress:          "tcp://127.0.0.1:26657",
		CORSAllowedOrigins:     []string{},
		CORSAllowedMethods:     []string{http.MethodHead, http.MethodGet, http.MethodPost},
		CORSAllowedHeaders:     []string{"Origin", "Accept", "Content-Type", "X-Requested-With", "X-Server-Time"},
		GRPCListenAddress:      "",
		GRPCMaxOpenConnections: 900,
		Unsafe:             false,
		MaxOpenConnections: 900,
		ReadTimeout:        10 * time.Second,
		WriteTimeout:       10 * time.Second,
		IdleTimeout:        60 * time.Second,
		MaxSubscriptionClients:    100,
		MaxSubscriptionsPerClient: 5,
		TimeoutBroadcastTxCommit:  10 * time.Second,
		MaxBodyBytes:   int64(1000000),  
		MaxHeaderBytes: 1 << 20,         
		TLSCertFile: "",
		TLSKeyFile:  "",
	}
}
DefaultRPCConfig returns a default configuration for the RPC server
package config
import (
	"encoding/hex"
	"errors"
	"fmt"
	"net/http"
	"os"
	"path/filepath"
	"time"
	"github.com/line/ostracon/privval"
	"github.com/line/tm-db/v2/metadb"
)
const (
	FuzzModeDrop = iota
	FuzzModeDelay
	LogFormatPlain = "plain"
	LogFormatJSON = "json"
	DefaultLogLevel = "info"
	DefaultDBBackend = "goleveldb"
)
var (
	DefaultOstraconDir = ".ostracon"
	defaultConfigDir   = "config"
	defaultDataDir     = "data"
	defaultConfigFileName  = "config.toml"
	defaultGenesisJSONName = "genesis.json"
	defaultPrivValKeyName   = "priv_validator_key.json"
	defaultPrivValStateName = "priv_validator_state.json"
	defaultNodeKeyName  = "node_key.json"
	defaultAddrBookName = "addrbook.json"
	defaultConfigFilePath   = filepath.Join(defaultConfigDir, defaultConfigFileName)
	defaultGenesisJSONPath  = filepath.Join(defaultConfigDir, defaultGenesisJSONName)
	defaultPrivValKeyPath   = filepath.Join(defaultConfigDir, defaultPrivValKeyName)
	defaultPrivValStatePath = filepath.Join(defaultDataDir, defaultPrivValStateName)
	defaultNodeKeyPath  = filepath.Join(defaultConfigDir, defaultNodeKeyName)
	defaultAddrBookPath = filepath.Join(defaultConfigDir, defaultAddrBookName)
)
type Config struct {
	BaseConfig `mapstructure:",squash"`
	RPC             *RPCConfig             `mapstructure:"rpc"`
	P2P             *P2PConfig             `mapstructure:"p2p"`
	Mempool         *MempoolConfig         `mapstructure:"mempool"`
	StateSync       *StateSyncConfig       `mapstructure:"statesync"`
	FastSync        *FastSyncConfig        `mapstructure:"fastsync"`
	Consensus       *ConsensusConfig       `mapstructure:"consensus"`
	TxIndex         *TxIndexConfig         `mapstructure:"tx_index"`
	Instrumentation *InstrumentationConfig `mapstructure:"instrumentation"`
}
func DefaultConfig() *Config {
	return &Config{
		BaseConfig:      DefaultBaseConfig(),
		RPC:             DefaultRPCConfig(),
		P2P:             DefaultP2PConfig(),
		Mempool:         DefaultMempoolConfig(),
		StateSync:       DefaultStateSyncConfig(),
		FastSync:        DefaultFastSyncConfig(),
		Consensus:       DefaultConsensusConfig(),
		TxIndex:         DefaultTxIndexConfig(),
		Instrumentation: DefaultInstrumentationConfig(),
	}
}
func TestConfig() *Config {
	return &Config{
		BaseConfig:      TestBaseConfig(),
		RPC:             TestRPCConfig(),
		P2P:             TestP2PConfig(),
		Mempool:         TestMempoolConfig(),
		StateSync:       TestStateSyncConfig(),
		FastSync:        TestFastSyncConfig(),
		Consensus:       TestConsensusConfig(),
		TxIndex:         TestTxIndexConfig(),
		Instrumentation: TestInstrumentationConfig(),
	}
}
func (cfg *Config) SetRoot(root string) *Config {
	cfg.BaseConfig.RootDir = root
	cfg.RPC.RootDir = root
	cfg.P2P.RootDir = root
	cfg.Mempool.RootDir = root
	cfg.Consensus.RootDir = root
	return cfg
}
func (cfg *Config) ValidateBasic() error {
	if err := cfg.BaseConfig.ValidateBasic(); err != nil {
		return err
	}
	if err := cfg.RPC.ValidateBasic(); err != nil {
		return fmt.Errorf("error in [rpc] section: %w", err)
	}
	if err := cfg.P2P.ValidateBasic(); err != nil {
		return fmt.Errorf("error in [p2p] section: %w", err)
	}
	if err := cfg.Mempool.ValidateBasic(); err != nil {
		return fmt.Errorf("error in [mempool] section: %w", err)
	}
	if err := cfg.StateSync.ValidateBasic(); err != nil {
		return fmt.Errorf("error in [statesync] section: %w", err)
	}
	if err := cfg.FastSync.ValidateBasic(); err != nil {
		return fmt.Errorf("error in [fastsync] section: %w", err)
	}
	if err := cfg.Consensus.ValidateBasic(); err != nil {
		return fmt.Errorf("error in [consensus] section: %w", err)
	}
	if err := cfg.Instrumentation.ValidateBasic(); err != nil {
		return fmt.Errorf("error in [instrumentation] section: %w", err)
	}
	return nil
}
type BaseConfig struct {  
	chainID string
	RootDir string `mapstructure:"home"`
	ProxyApp string `mapstructure:"proxy_app"`
	Moniker string `mapstructure:"moniker"`
	FastSyncMode bool `mapstructure:"fast_sync"`
	DBBackend string `mapstructure:"db_backend"`
	DBPath string `mapstructure:"db_dir"`
	LogLevel string `mapstructure:"log_level"`
	LogFormat string `mapstructure:"log_format"`
	Genesis string `mapstructure:"genesis_file"`
	PrivValidatorKey string `mapstructure:"priv_validator_key_file"`
	PrivValidatorState string `mapstructure:"priv_validator_state_file"`
	PrivValidatorListenAddr string `mapstructure:"priv_validator_laddr"`
	NodeKey string `mapstructure:"node_key_file"`
	ABCI string `mapstructure:"abci"`
	FilterPeers bool `mapstructure:"filter_peers"`  
	PrivKeyType string `mapstructure:"priv_key_type"`
}
func DefaultBaseConfig() BaseConfig {
	dbs := metadb.AvailableDBBackends()
	defaultDBBackend := DefaultDBBackend
	for _, b := range dbs {
		defaultDBBackend = string(b)
		if defaultDBBackend == DefaultDBBackend {
			break
		}
	}
	return BaseConfig{
		Genesis:            defaultGenesisJSONPath,
		PrivValidatorKey:   defaultPrivValKeyPath,
		PrivValidatorState: defaultPrivValStatePath,
		NodeKey:            defaultNodeKeyPath,
		Moniker:            defaultMoniker,
		ProxyApp:           "tcp://127.0.0.1:26658",
		ABCI:               "socket",
		LogLevel:           DefaultLogLevel,
		LogFormat:          LogFormatPlain,
		FastSyncMode:       true,
		FilterPeers:        false,
		DBBackend:          defaultDBBackend,
		DBPath:             "data",
		PrivKeyType:        privval.PrivKeyTypeEd25519,
	}
}
func TestBaseConfig() BaseConfig {
	cfg := DefaultBaseConfig()
	cfg.chainID = "ostracon_test"
	cfg.ProxyApp = "kvstore"
	cfg.FastSyncMode = false
	cfg.DBBackend = "memdb"
	return cfg
}
func (cfg BaseConfig) ChainID() string {
	return cfg.chainID
}
func (cfg BaseConfig) GenesisFile() string {
	return rootify(cfg.Genesis, cfg.RootDir)
}
func (cfg BaseConfig) PrivValidatorKeyFile() string {
	return rootify(cfg.PrivValidatorKey, cfg.RootDir)
}
func (cfg BaseConfig) PrivValidatorStateFile() string {
	return rootify(cfg.PrivValidatorState, cfg.RootDir)
}
func (cfg BaseConfig) NodeKeyFile() string {
	return rootify(cfg.NodeKey, cfg.RootDir)
}
func (cfg BaseConfig) DBDir() string {
	return rootify(cfg.DBPath, cfg.RootDir)
}
func (cfg BaseConfig) PrivValidatorKeyType() string {
	return cfg.PrivKeyType
}
func (cfg BaseConfig) ValidateBasic() error {
	switch cfg.LogFormat {
	case LogFormatPlain, LogFormatJSON:
	default:
		return errors.New("unknown log_format (must be 'plain' or 'json')")
	}
	return nil
}
type RPCConfig struct {
	RootDir string `mapstructure:"home"`
	ListenAddress string `mapstructure:"laddr"`
	CORSAllowedOrigins []string `mapstructure:"cors_allowed_origins"`
	CORSAllowedMethods []string `mapstructure:"cors_allowed_methods"`
	CORSAllowedHeaders []string `mapstructure:"cors_allowed_headers"`
	GRPCListenAddress string `mapstructure:"grpc_laddr"`
	GRPCMaxOpenConnections int `mapstructure:"grpc_max_open_connections"`
	Unsafe bool `mapstructure:"unsafe"`
	MaxOpenConnections int `mapstructure:"max_open_connections"`
	ReadTimeout time.Duration `mapstructure:"read_timeout"`
	WriteTimeout time.Duration `mapstructure:"write_timeout"`
	IdleTimeout time.Duration `mapstructure:"idle_timeout"`
	MaxSubscriptionClients int `mapstructure:"max_subscription_clients"`
	MaxSubscriptionsPerClient int `mapstructure:"max_subscriptions_per_client"`
	TimeoutBroadcastTxCommit time.Duration `mapstructure:"timeout_broadcast_tx_commit"`
	MaxBodyBytes int64 `mapstructure:"max_body_bytes"`
	MaxHeaderBytes int `mapstructure:"max_header_bytes"`
	TLSCertFile string `mapstructure:"tls_cert_file"`
	TLSKeyFile string `mapstructure:"tls_key_file"`
	PprofListenAddress string `mapstructure:"pprof_laddr"`
}