Skip to content

Commit

Permalink
chore(release): release v0.5.0 (#1562)
Browse files Browse the repository at this point in the history
  • Loading branch information
noot authored May 6, 2021
1 parent d53e245 commit 6bf1c62
Show file tree
Hide file tree
Showing 157 changed files with 5,719 additions and 2,962 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# CODEOWNERS: https://help.github.com/articles/about-codeowners/

# Primary repo maintainers
* @noot @arijitAD @edwardmack
* @noot @arijitAD @edwardmack @timwu20
10 changes: 5 additions & 5 deletions .github/CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ appearance, race, religion, or sexual identity and orientation.

## Our Standards

Examples of behavior that contributes to creating a positive environment
Examples of behaviour that contributes to creating a positive environment
include:

* Using welcoming and inclusive language
Expand All @@ -20,7 +20,7 @@ include:
* Focusing on what is best for the community
* Showing empathy towards other community members

Examples of unacceptable behavior by participants include:
Examples of unacceptable behaviour by participants include:

* The use of sexualized language or imagery and unwelcome sexual attention or
advances
Expand All @@ -34,13 +34,13 @@ Examples of unacceptable behavior by participants include:
## Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.
behaviour and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behaviour.

Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
permanently any contributor for other behaviours that they deem inappropriate,
threatening, offensive, or harmful.

## Scope
Expand Down
4 changes: 2 additions & 2 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ $ git remote -v (you should see myrepo and gossamer in the list of remotes)

To start, check out our open issues. We recommend starting with an [issue labeled `Good First Issue`](https://github.com/ChainSafe/gossamer/issues?q=is%3Aopen+is%3Aissue+label%3A%22Good+First+Issue%22). Leave a comment to let us know that you would like to work on it.

Another option is to improve gossamer where you see fit based on your evaluation of our code. In order to best faciliate collaboration, please create an issue before you start working on it.
Another option is to improve gossamer where you see fit based on your evaluation of our code. In order to best facilitate collaboration, please create an issue before you start working on it.

**6. Make improvements to the code.**

Expand Down Expand Up @@ -76,7 +76,7 @@ Navigate your browser to [https://github.com/ChainSafe/gossamer](https://github.

## Note on memory intensive tests
Unfortunately, the free tier for CI's have a memory cap and some tests will cause the CI to experience an out of memory error.
In order to mitigate this we have introduced the concept of **short tests**. If your PR causes an out of memory error please seperate the tests into two groups
In order to mitigate this we have introduced the concept of **short tests**. If your PR causes an out of memory error please separate the tests into two groups
like below and make sure to label it `large`:

```
Expand Down
6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ If you're suggesting a change/improvement, tell us how it should work.

<!---
If describing a bug, tell us what happens instead of the expected behavior.
If describing a bug, tell us what happens instead of the expected behaviour.
If suggesting a change or an improvement, explain the difference between your
suggestion and current behavior.
suggestion and current behaviour.
-->

Expand All @@ -55,7 +55,7 @@ submit a PR and you'll get credit for the whole thing.


## To Reproduce
Steps to reproduce the behavior:
Steps to reproduce the behaviour:

1.
2.
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Release
on:
push:
branches: [main, development]
branches: [main]

jobs:
release:
Expand All @@ -23,4 +23,4 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npx semantic-release
run: npx semantic-release
3 changes: 1 addition & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ jobs:
run: |
go test ./... -short -coverprofile=coverage.out -covermode=atomic -timeout=20m
- uses: codecov/codecov-action@v1
with:
token: "89982880-a53b-4a3a-9bdd-3dc9c78bd190"
with:
files: ./coverage.out
flags: unit-tests
name: coverage
Expand Down
4 changes: 2 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ run:

# which files to skip: they will be analyzed, but issues from them
# won't be reported. Default value is empty list, but there is
# no need to include all autogenerated files, we confidently recognize
# no need to include all autogenerated files, we confidently recognise
# autogenerated files. If it's not please let us know.
#skip-files:

Expand Down Expand Up @@ -132,7 +132,7 @@ linters-settings:
# Correct spellings using locale preferences for US or UK.
# Default is to use a neutral variety of English.
# Setting locale to US will correct the British spelling of 'colour' to 'color'.
locale: US
locale: UK
ignore-words:
- gossamer
lll:
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ build-debug:
@echo " > \033[32mBuilding binary...\033[0m "
GOBIN=$(PWD)/bin go run scripts/ci.go install-debug

## init: Initialize gossamer using the default genesis and toml configuration files
## init: Initialise gossamer using the default genesis and toml configuration files
init:
./bin/gossamer --key alice init --genesis chain/gssmr/genesis.json --force

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ make gossamer

### Run Default Node

initialize default node:
initialise default node:
```
./bin/gossamer --chain gssmr init
```
Expand All @@ -87,7 +87,7 @@ Then, re-run the above steps. NOTE: this feature is for testing only; if you wis

### Run Kusama Node

initialize kusama node:
initialise kusama node:
```
./bin/gossamer --chain kusama init
```
Expand All @@ -108,7 +108,7 @@ After it's finished bootstrapping, the node should begin to sync.

### Run Polkadot Node

initialize polkadot node:
initialise polkadot node:
```
./bin/gossamer --chain polkadot init
```
Expand Down
123 changes: 86 additions & 37 deletions cmd/gossamer/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package main

import (
"encoding/binary"
"fmt"
"strconv"
"strings"
Expand All @@ -33,7 +32,7 @@ import (
"github.com/ChainSafe/gossamer/lib/runtime/life"
"github.com/ChainSafe/gossamer/lib/runtime/wasmer"
"github.com/ChainSafe/gossamer/lib/runtime/wasmtime"
"github.com/cosmos/go-bip39"
"github.com/ChainSafe/gossamer/lib/utils"

log "github.com/ChainSafe/log15"
"github.com/urfave/cli"
Expand Down Expand Up @@ -132,7 +131,10 @@ func createDotConfig(ctx *cli.Context) (*dot.Config, error) {
logger.Info("loaded package log configuration", "cfg", cfg.Log)

// set global configuration values
setDotGlobalConfig(ctx, tomlCfg, &cfg.Global)
if err := setDotGlobalConfig(ctx, tomlCfg, &cfg.Global); err != nil {
logger.Error("failed to set global node configuration", "error", err)
return nil, err
}

// set remaining cli configuration values
setDotInitConfig(ctx, tomlCfg.Init, &cfg.Init)
Expand All @@ -151,7 +153,7 @@ func createDotConfig(ctx *cli.Context) (*dot.Config, error) {
return cfg, nil
}

// createInitConfig creates the configuration required to initialize a dot node
// createInitConfig creates the configuration required to initialise a dot node
func createInitConfig(ctx *cli.Context) (*dot.Config, error) {
tomlCfg, cfg, err := setupConfigFromChain(ctx)
if err != nil {
Expand All @@ -160,7 +162,11 @@ func createInitConfig(ctx *cli.Context) (*dot.Config, error) {
}

// set global configuration values
setDotGlobalConfig(ctx, tomlCfg, &cfg.Global)
err = setDotGlobalConfig(ctx, tomlCfg, &cfg.Global)
if err != nil {
logger.Error("failed to set global node configuration", "error", err)
return nil, err
}

// set log config
err = setLogConfig(ctx, tomlCfg, &cfg.Global, &cfg.Log)
Expand Down Expand Up @@ -196,7 +202,11 @@ func createImportStateConfig(ctx *cli.Context) (*dot.Config, error) {
}

// set global configuration values
setDotGlobalConfig(ctx, tomlCfg, &cfg.Global)
if err := setDotGlobalConfig(ctx, tomlCfg, &cfg.Global); err != nil {
logger.Error("failed to set global node configuration", "error", err)
return nil, err
}

return cfg, nil
}

Expand All @@ -210,7 +220,11 @@ func createBuildSpecConfig(ctx *cli.Context) (*dot.Config, error) {
}

// set global configuration values
setDotGlobalConfig(ctx, tomlCfg, &cfg.Global)
if err := setDotGlobalConfig(ctx, tomlCfg, &cfg.Global); err != nil {
logger.Error("failed to set global node configuration", "error", err)
return nil, err
}

return cfg, nil
}

Expand All @@ -229,7 +243,11 @@ func createExportConfig(ctx *cli.Context) (*dot.Config, error) {
updateDotConfigFromGenesisJSONRaw(*tomlCfg, cfg)

// set global configuration values
setDotGlobalConfig(ctx, tomlCfg, &cfg.Global)
err = setDotGlobalConfig(ctx, tomlCfg, &cfg.Global)
if err != nil {
logger.Error("failed to set global node configuration", "error", err)
return nil, err
}

// set log config
err = setLogConfig(ctx, &ctoml.Config{}, &cfg.Global, &cfg.Log)
Expand Down Expand Up @@ -385,13 +403,27 @@ func setDotInitConfig(ctx *cli.Context, tomlCfg ctoml.InitConfig, cfg *dot.InitC
)
}

// setDotGlobalConfig sets dot.GlobalConfig using flag values from the cli context
func setDotGlobalConfig(ctx *cli.Context, tomlCfg *ctoml.Config, cfg *dot.GlobalConfig) {
if tomlCfg != nil {
if tomlCfg.Global.Name != "" {
cfg.Name = tomlCfg.Global.Name
}
func setDotGlobalConfig(ctx *cli.Context, tomlConfig *ctoml.Config, cfg *dot.GlobalConfig) error {
setDotGlobalConfigFromToml(tomlConfig, cfg)
setDotGlobalConfigFromFlags(ctx, cfg)

if err := setDotGlobalConfigName(ctx, tomlConfig, cfg); err != nil {
return fmt.Errorf("could not set global node name: %w", err)
}

logger.Debug(
"global configuration",
"name", cfg.Name,
"id", cfg.ID,
"basepath", cfg.BasePath,
)

return nil
}

// setDotGlobalConfigFromToml will apply the toml configs to dot global config
func setDotGlobalConfigFromToml(tomlCfg *ctoml.Config, cfg *dot.GlobalConfig) {
if tomlCfg != nil {
if tomlCfg.Global.ID != "" {
cfg.ID = tomlCfg.Global.ID
}
Expand All @@ -406,20 +438,10 @@ func setDotGlobalConfig(ctx *cli.Context, tomlCfg *ctoml.Config, cfg *dot.Global

cfg.MetricsPort = tomlCfg.Global.MetricsPort
}
}

// TODO: generate random name if one is not assigned (see issue #1496)
// check --name flag and update node configuration
if name := ctx.GlobalString(NameFlag.Name); name != "" {
cfg.Name = name
} else {
// generate random name
entropy, _ := bip39.NewEntropy(128)
randomNamesString, _ := bip39.NewMnemonic(entropy)
randomNames := strings.Split(randomNamesString, " ")
number := binary.BigEndian.Uint16(entropy)
cfg.Name = randomNames[0] + "-" + randomNames[1] + "-" + fmt.Sprint(number)
}

// setDotGlobalConfigFromFlags sets dot.GlobalConfig using flag values from the cli context
func setDotGlobalConfigFromFlags(ctx *cli.Context, cfg *dot.GlobalConfig) {
// check --basepath flag and update node configuration
if basepath := ctx.GlobalString(BasePathFlag.Name); basepath != "" {
cfg.BasePath = basepath
Expand All @@ -429,6 +451,7 @@ func setDotGlobalConfig(ctx *cli.Context, tomlCfg *ctoml.Config, cfg *dot.Global
if cfg.BasePath == "" {
cfg.BasePath = dot.GssmrConfig().Global.BasePath
}

// check --log flag
if lvlToInt, err := strconv.Atoi(ctx.String(LogFlag.Name)); err == nil {
cfg.LogLvl = log.Lvl(lvlToInt)
Expand All @@ -444,13 +467,39 @@ func setDotGlobalConfig(ctx *cli.Context, tomlCfg *ctoml.Config, cfg *dot.Global
}

cfg.NoTelemetry = ctx.Bool("no-telemetry")
}

logger.Debug(
"global configuration",
"name", cfg.Name,
"id", cfg.ID,
"basepath", cfg.BasePath,
)
func setDotGlobalConfigName(ctx *cli.Context, tomlCfg *ctoml.Config, cfg *dot.GlobalConfig) error {
globalBasePath := utils.ExpandDir(cfg.BasePath)
initialised := dot.NodeInitialized(globalBasePath, false)

// consider the --name flag as higher priority
if ctx.GlobalString(NameFlag.Name) != "" {
cfg.Name = ctx.GlobalString(NameFlag.Name)
return nil
}

// consider the name on config as a second priority
if tomlCfg.Global.Name != "" {
cfg.Name = tomlCfg.Global.Name
return nil
}

// if node was previously initialised and is not the init command
if initialised && ctx.Command.Name != initCommandName {
var err error
if cfg.Name, err = dot.LoadGlobalNodeName(globalBasePath); err != nil {
return err
}

if cfg.Name != "" {
logger.Debug("load global node name from database", "name", cfg.Name)
return nil
}
}

cfg.Name = dot.RandomNodeName()
return nil
}

// setDotAccountConfig sets dot.AccountConfig using flag values from the cli context
Expand Down Expand Up @@ -736,18 +785,18 @@ func updateDotConfigFromGenesisJSONRaw(tomlCfg ctoml.Config, cfg *dot.Config) {
)
}

// updateDotConfigFromGenesisData updates the configuration from genesis data of an initialized node
// updateDotConfigFromGenesisData updates the configuration from genesis data of an initialised node
func updateDotConfigFromGenesisData(ctx *cli.Context, cfg *dot.Config) error {
// initialize database using data directory
// initialise database using data directory
db, err := chaindb.NewBadgerDB(&chaindb.Config{
DataDir: cfg.Global.BasePath,
})
if err != nil {
return fmt.Errorf("failed to create database: %s", err)
}

// load genesis data from initialized node database
gen, err := state.LoadGenesisData(db)
// load genesis data from initialised node database
gen, err := state.NewBaseState(db).LoadGenesisData()
if err != nil {
return fmt.Errorf("failed to load genesis data: %s", err)
}
Expand Down
Loading

0 comments on commit 6bf1c62

Please sign in to comment.