Skip to content

Commit

Permalink
add westend chain option
Browse files Browse the repository at this point in the history
  • Loading branch information
timwu20 committed Feb 13, 2023
1 parent 56ec4cb commit 9028085
Show file tree
Hide file tree
Showing 5 changed files with 362 additions and 9 deletions.
55 changes: 55 additions & 0 deletions chain/westend/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
[global]
basepath = "~/.gossamer/westend"
log = "info"
metrics-address = "localhost:9876"

[log]
core = ""
network = ""
rpc = ""
state = ""
runtime = ""
babe = ""
grandpa = ""
sync = ""
digest = ""

[init]
genesis = "./chain/westend/genesis.json"

[account]
key = ""
unlock = ""

[core]
roles = 1
babe-authority = false
grandpa-authority = false

[network]
port = 7001
nobootstrap = false
nomdns = false

[rpc]
enabled = false
port = 8545
host = "localhost"
modules = [
"system",
"author",
"chain",
"state",
"rpc",
"grandpa",
"offchain",
"childstate",
"syncstate",
"payment",
]
ws-port = 8546

[pprof]
listening-address = "localhost:6060"
block-rate = 0
mutex-rate = 0
99 changes: 99 additions & 0 deletions chain/westend/defaults.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
// Copyright 2021 ChainSafe Systems (ON)
// SPDX-License-Identifier: LGPL-3.0-only

package westend

import (
"github.com/ChainSafe/gossamer/internal/log"
"github.com/ChainSafe/gossamer/lib/common"
"github.com/ChainSafe/gossamer/lib/genesis"
"github.com/ChainSafe/gossamer/lib/runtime/wasmer"
)

var (
// GlobalConfig

// DefaultName Default node name
DefaultName = string("Westend")
// DefaultID Default chain ID
DefaultID = string("westend2")
// DefaultConfig Default toml configuration path
DefaultConfig = string("./chain/westend/config.toml")
// DefaultBasePath Default node base directory path
DefaultBasePath = string("~/.gossamer/westend")

// DefaultLvl is the default log level
DefaultLvl = log.Info

// DefaultPruningMode is the default pruning mode
DefaultPruningMode = "archive"
// DefaultRetainBlocks is the default pruning mode
DefaultRetainBlocks = uint32(512)

// DefaultTelemetryURLs is the default URL of the telemetry server to connect to.
DefaultTelemetryURLs []genesis.TelemetryEndpoint

// InitConfig

// DefaultGenesis is the default genesis configuration path
DefaultGenesis = string("./chain/westend/genesis.json")

// AccountConfig

// DefaultKey Default account key
DefaultKey = string("")
// DefaultUnlock Default account unlock
DefaultUnlock = string("")

// CoreConfig

// DefaultAuthority is true if the node is a block producer and a grandpa authority
DefaultAuthority = true
// DefaultRoles Default node roles
DefaultRoles = common.FullNodeRole // authority node (see Table D.2)
// DefaultBabeAuthority is true if the node is a block producer (overwrites previous settings)
DefaultBabeAuthority = true
// DefaultGrandpaAuthority is true if the node is a grandpa authority (overwrites previous settings)
DefaultGrandpaAuthority = true
// DefaultWasmInterpreter is the name of the wasm interpreter to use by default
DefaultWasmInterpreter = wasmer.Name

// NetworkConfig

// DefaultNetworkPort network port
DefaultNetworkPort = uint16(7001)
// DefaultNetworkBootnodes network bootnodes
DefaultNetworkBootnodes = []string(nil)
// DefaultNoBootstrap disables bootstrap
DefaultNoBootstrap = false
// DefaultNoMDNS disables mDNS discovery
DefaultNoMDNS = false

// RPCConfig

// DefaultRPCHTTPHost rpc host
DefaultRPCHTTPHost = string("localhost")
// DefaultRPCHTTPPort rpc port
DefaultRPCHTTPPort = uint32(8545)
// DefaultRPCModules rpc modules
DefaultRPCModules = []string{
"system", "author", "chain", "state", "rpc",
"grandpa", "offchain", "childstate", "syncstate", "payment"}
// DefaultRPCWSPort rpc websocket port
DefaultRPCWSPort = uint32(8546)
)

const (
// PprofConfig

// DefaultPprofListeningAddress default pprof HTTP server listening address.
DefaultPprofListeningAddress = "localhost:6060"

// DefaultPprofBlockRate default block profile rate.
// Set to 0 to disable profiling.
DefaultPprofBlockRate = 0

// DefaultPprofMutexRate default mutex profile rate.
// Set to 0 to disable profiling.
DefaultPprofMutexRate = 0
)
140 changes: 140 additions & 0 deletions chain/westend/genesis.json

Large diffs are not rendered by default.

19 changes: 10 additions & 9 deletions cmd/gossamer/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,7 @@ var (
defaultKusamaConfigPath = "./chain/kusama/config.toml"
defaultPolkadotConfigPath = "./chain/polkadot/config.toml"
defaultDevConfigPath = "./chain/dev/config.toml"

gossamerName = "gssmr"
kusamaName = "kusama"
polkadotName = "polkadot"
devName = "dev"
defaultWestendConfigPath = "./chain/westend/config.toml"
)

// loadConfigFile loads a default config file if --chain is specified, a specific
Expand Down Expand Up @@ -70,25 +66,30 @@ func setupConfigFromChain(ctx *cli.Context) (*ctoml.Config, *dot.Config, error)
// check --chain flag and load configuration from defaults.go
if id := ctx.GlobalString(ChainFlag.Name); id != "" {
switch id {
case gossamerName:
case "gssmr":
logger.Info("loading toml configuration from " + defaultGssmrConfigPath + "...")
tomlCfg = &ctoml.Config{}
err = loadConfig(tomlCfg, defaultGssmrConfigPath)
case kusamaName:
case "kusama":
logger.Info("loading toml configuration from " + defaultKusamaConfigPath + "...")
tomlCfg = &ctoml.Config{}
cfg = dot.KusamaConfig()
err = loadConfig(tomlCfg, defaultKusamaConfigPath)
case polkadotName:
case "polkadot":
logger.Info("loading toml configuration from " + defaultPolkadotConfigPath + "...")
tomlCfg = &ctoml.Config{}
cfg = dot.PolkadotConfig()
err = loadConfig(tomlCfg, defaultPolkadotConfigPath)
case devName:
case "dev":
logger.Info("loading toml configuration from " + defaultDevConfigPath + "...")
tomlCfg = &ctoml.Config{}
cfg = dot.DevConfig()
err = loadConfig(tomlCfg, defaultDevConfigPath)
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 @@ -12,6 +12,7 @@ import (
"github.com/ChainSafe/gossamer/chain/gssmr"
"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 @@ -423,3 +424,60 @@ func DevConfig() *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: gssmr.DefaultRetainBlocks,
Pruning: pruner.Mode(gssmr.DefaultPruningMode),
MetricsAddress: gssmr.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 9028085

Please sign in to comment.