Skip to content

Commit

Permalink
fix(chain): Fix chain=westend option (#3123)
Browse files Browse the repository at this point in the history
Co-authored-by: Eclésio Junior <eclesiomelo.1@gmail.com>
  • Loading branch information
timwu20 and EclesioMeloJunior committed Feb 24, 2023
1 parent 72529cd commit 64dbba6
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 0 deletions.
2 changes: 2 additions & 0 deletions chain/westend/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ var (
DefaultConfig = string("./chain/westend/config.toml")
// DefaultBasePath Default node base directory path
DefaultBasePath = string("~/.gossamer/westend")
// DefaultMetricsAddress is the default metrics server listening address.
DefaultMetricsAddress = "localhost:9876"

// DefaultLvl is the default log level
DefaultLvl = log.Info
Expand Down
6 changes: 6 additions & 0 deletions cmd/gossamer/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ var (
defaultKusamaConfigPath = "./chain/kusama/config.toml"
defaultPolkadotConfigPath = "./chain/polkadot/config.toml"
defaultWestendDevConfigPath = "./chain/westend-dev/config.toml"
defaultWestendConfigPath = "./chain/westend/config.toml"
)

// loadConfigFile loads a default config file if --chain is specified, a specific
Expand Down Expand Up @@ -77,6 +78,11 @@ func setupConfigFromChain(ctx *cli.Context) (*ctoml.Config, *dot.Config, error)
tomlCfg = &ctoml.Config{}
cfg = dot.WestendDevConfig()
err = loadConfig(tomlCfg, defaultWestendDevConfigPath)
case "westend":
logger.Info("loading toml configuration from " + defaultWestendConfigPath + "...")
tomlCfg = &ctoml.Config{}
cfg = dot.WestendConfig()
err = loadConfig(tomlCfg, defaultWestendConfigPath)
default:
return nil, nil, fmt.Errorf("unknown chain id provided: %s", id)
}
Expand Down
58 changes: 58 additions & 0 deletions dot/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

"github.com/ChainSafe/gossamer/chain/kusama"
"github.com/ChainSafe/gossamer/chain/polkadot"
"github.com/ChainSafe/gossamer/chain/westend"
"github.com/ChainSafe/gossamer/dot/state/pruner"
"github.com/ChainSafe/gossamer/dot/types"
"github.com/ChainSafe/gossamer/internal/log"
Expand Down Expand Up @@ -361,3 +362,60 @@ func PolkadotConfig() *Config {
},
}
}

// WestendConfig returns a "westend" node configuration
func WestendConfig() *Config {
return &Config{
Global: GlobalConfig{
Name: westend.DefaultName,
ID: westend.DefaultID,
BasePath: westend.DefaultBasePath,
LogLvl: westend.DefaultLvl,
RetainBlocks: westend.DefaultRetainBlocks,
Pruning: pruner.Mode(westend.DefaultPruningMode),
MetricsAddress: westend.DefaultMetricsAddress,
TelemetryURLs: westend.DefaultTelemetryURLs,
},
Log: LogConfig{
CoreLvl: westend.DefaultLvl,
DigestLvl: westend.DefaultLvl,
SyncLvl: westend.DefaultLvl,
NetworkLvl: westend.DefaultLvl,
RPCLvl: westend.DefaultLvl,
StateLvl: westend.DefaultLvl,
RuntimeLvl: westend.DefaultLvl,
BlockProducerLvl: westend.DefaultLvl,
FinalityGadgetLvl: westend.DefaultLvl,
},
Init: InitConfig{
Genesis: westend.DefaultGenesis,
},
Account: AccountConfig{
Key: westend.DefaultKey,
Unlock: westend.DefaultUnlock,
},
Core: CoreConfig{
Roles: westend.DefaultRoles,
WasmInterpreter: westend.DefaultWasmInterpreter,
},
Network: NetworkConfig{
Port: westend.DefaultNetworkPort,
Bootnodes: westend.DefaultNetworkBootnodes,
NoBootstrap: westend.DefaultNoBootstrap,
NoMDNS: westend.DefaultNoMDNS,
},
RPC: RPCConfig{
Port: westend.DefaultRPCHTTPPort,
Host: westend.DefaultRPCHTTPHost,
Modules: westend.DefaultRPCModules,
WSPort: westend.DefaultRPCWSPort,
},
Pprof: PprofConfig{
Settings: pprof.Settings{
ListeningAddress: westend.DefaultPprofListeningAddress,
BlockProfileRate: westend.DefaultPprofBlockRate,
MutexProfileRate: westend.DefaultPprofMutexRate,
},
},
}
}

0 comments on commit 64dbba6

Please sign in to comment.