Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(chain): Add Westend network as command line chain option #3103

Merged
merged 3 commits into from
Feb 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions chain/westend/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
[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
external = false
port = 8545
host = "localhost"
modules = [
"system",
"author",
"chain",
"state",
"rpc",
"grandpa",
"offchain",
"childstate",
"syncstate",
"payment",
]
ws-port = 8546
timwu20 marked this conversation as resolved.
Show resolved Hide resolved
ws = false
ws-external = false


[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,
},
},
}
}
4 changes: 0 additions & 4 deletions lib/grandpa/vote_message_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,10 +283,6 @@ func TestValidateMessage_Equivocation(t *testing.T) {

_, err = gs.validateVoteMessage("", msg)
require.ErrorIs(t, err, ErrEquivocation)
require.EqualError(t, err, "checking for equivocation: vote is equivocatory: "+
"voter 0x88dc3417d5058ec4b4503e0c12ea1a0a89be200fe98922423d4334014fa6b0ee has "+
"existing vote 0xfa6648885514eb4e8e5cbcbd18bdcf18a903f71b44769131604304099384e930 "+
"and new vote 0x3d5687d4ca7f086a0e18c4730cac0e1bcfa0e1ae592b5966dcc1a5330a58d10b")
}

func TestValidateMessage_BlockDoesNotExist(t *testing.T) {
Expand Down