Skip to content

Commit

Permalink
Merge branch 'development' of github.com:ChainSafe/gossamer into noot…
Browse files Browse the repository at this point in the history
…/fixes
  • Loading branch information
noot committed Nov 26, 2021
2 parents f4bc742 + dd08424 commit a52b42c
Show file tree
Hide file tree
Showing 194 changed files with 4,803 additions and 764 deletions.
18 changes: 4 additions & 14 deletions .githooks/pre-push
Original file line number Diff line number Diff line change
@@ -1,19 +1,9 @@
#!/bin/bash

echo "Executing pre push hook. To disable do 'git push --no-verify'"
STAGED_GO_FILES=$(git diff --cached --name-only | grep ".go$")

make lint
if [ $? -ne 0 ]
then
echo "***ERROR*** 'make lint' failed. Fix errors before proceeding to push."
exit 1
if [[ "$STAGED_GO_FILES" = "" ]]; then
exit 0
fi

# Note: this won't detect unneeded `// indirect` commented dependencies
go mod tidy
git diff --exit-code -- go.mod go.sum >/dev/null
if [ $? -ne 0 ]
then
echo "***ERROR*** 'go.mod' file is updated. Add the file before proceeding to push."
exit 1
fi
make lint
13 changes: 7 additions & 6 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,22 @@ For coding style, you may refer to the [code style](CODE_STYLE.md) document whic
git remote -v (you should see myrepo and gossamer in the list of remotes)
```

5. **Find something to work on.**
5. You can optionally setup Git hooks defined in this repository with `make githooks`.
6. **Find something to work on.**

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 facilitate collaboration, please create an issue before you start working on it.

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

Each time you work on the code be sure that you are working on the branch that you have created as opposed to your local copy of the gossamer repo. Keeping your changes segregated in this branch will make it easier to merge your changes into the repo later.

```sh
git checkout -b feature-in-progress-branch
```

7. **Test your changes.**
8. **Test your changes.**

Changes that only affect a single file can be tested with

Expand All @@ -81,19 +82,19 @@ For coding style, you may refer to the [code style](CODE_STYLE.md) document whic

Generate the mock code with `go generate -run "mockery" ./...` from your working directory. This will also update existing mocks. You can update all mocks by running `go generate -run "mockery" ./...` from the repository root.

8. **Lint your changes.**
9. **Lint your changes.**

Before opening a pull request be sure to run the linter

```sh
make lint
```

9. **Add licenses to new Go and Proto files**
10. **Add licenses to new Go and Proto files**

If you added any new file, run `make license` to setup all licenses on relevant files.
If you do not have `make` available, you can copy paste the command from the Makefile's `license:` block and run that instead.
10. **Create a pull request.**
11. **Create a pull request.**
Navigate your browser to [https://github.com/ChainSafe/gossamer](https://github.com/ChainSafe/gossamer) and click on the new pull request button. In the “base” box on the left, change the branch to “**base development**”, the branch that you want your changes to be applied to. In the “compare” box on the right, select feature-in-progress-branch, the branch containing the changes you want to apply. You will then be asked to answer a few questions about your pull request. After you complete the questionnaire, the pull request will appear in the list of pull requests at [https://github.com/ChainSafe/gossamer/pulls](https://github.com/ChainSafe/gossamer/pulls).
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:

jobs:
builds:
timeout-minutes: 60
strategy:
matrix:
go-version: [1.17.x]
Expand Down Expand Up @@ -41,6 +42,7 @@ jobs:
run: make build

publish-code-coverage:
timeout-minutes: 60
strategy:
matrix:
go-version: [1.17.x]
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/code-cov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ env:

jobs:
publish-code-coverage:
timeout-minutes: 60
strategy:
matrix:
go-version: [1.17.x]
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ env:

jobs:
unit-tests:
timeout-minutes: 60
strategy:
matrix:
go-version: [1.17.x]
Expand Down
23 changes: 22 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,22 @@ linters-settings:
include-go-root: false
packages:
- github.com/davecgh/go-spew/spew

lll:
# max line length, lines longer will be reported. Default is 120.
# '\t' is counted as 1 character by default, and can be changed with the tab-width option
line-length: 120
# tab width in spaces. Default to 1.
tab-width: 1

misspell:
# 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: UK
ignore-words:
- gossamer
- flavor
gocritic:
# Which checks should be disabled; can't be combined with 'enabled-checks'; default is empty
disabled-checks:
Expand Down Expand Up @@ -84,6 +93,7 @@ linters:
- gosimple
- govet
- ineffassign
- lll
- megacheck
- megacheck
- misspell
Expand Down Expand Up @@ -155,7 +165,18 @@ issues:
- linters:
- lll
source: "^//go:generate "
text: "long-lines"

- source: "// https://"
linters:
- lll

- source: "// See https://"
linters:
- lll

- text: 'G204: Subprocess launched with variable'
linters:
- gosec

# Independently from option `exclude` we use default exclude patterns,
# it can be disabled by this option. To list all
Expand Down
10 changes: 4 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@ help: Makefile
@sed -n 's/^##//p' $< | column -t -s ':' | sed -e 's/^/ /'
@echo

## lint: Lints project files, go gets golangci-lint if missing. Runs `golangci-lint` on project files.
.PHONY: lint
lint:
./scripts/install-lint.sh
${GOPATH}/bin/golangci-lint run
lint:
go install github.com/golangci/golangci-lint/cmd/[email protected]
golangci-lint run

clean:
rm -fr ./bin
Expand Down Expand Up @@ -89,8 +88,7 @@ build-debug: clean
init:
./bin/gossamer init --force

## init-repo: Set initial configuration for the repo
init-repo:
githooks:
git config core.hooksPath .githooks

## start: Starts application from binary executable in `./bin/gossamer` with built-in key alice
Expand Down
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ For more information about Gossamer, the Polkadot ecosystem, and how to use Goss

### Prerequisites

install go version `>=1.16`
install go version `>=1.17`

### Installation

Expand All @@ -57,6 +57,22 @@ build gossamer command:
```
make gossamer
```
### Troubleshooting for Apple Silicon users

If you are facing the following problem with the `wasmer`:
```
undefined: cWasmerImportObjectT
undefined: cWasmerImportFuncT
undefined: cWasmerValueTag
```
Make sure you have the following Golang enviroment variables:

- GOARCH="amd64"
- CGO_ENABLED="1"

> use _go env_ to see all the Golang enviroment variables
> use _go env -w **ENV_NAME**=**ENV_VALUE**_ to set the new value


Expand Down
7 changes: 6 additions & 1 deletion chain/dev/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,12 @@ var (
// DefaultRPCHTTPPort rpc port
DefaultRPCHTTPPort = uint32(8545)
// DefaultRPCModules rpc modules
DefaultRPCModules = []string{"system", "author", "chain", "state", "rpc", "grandpa", "offchain", "childstate", "syncstate", "payment"}
DefaultRPCModules = []string{
"system", "author", "chain",
"state", "rpc", "grandpa",
"offchain", "childstate", "syncstate",
"payment",
}
// DefaultRPCWSPort rpc websocket port
DefaultRPCWSPort = uint32(8546)
// DefaultRPCEnabled enables the RPC server
Expand Down
7 changes: 6 additions & 1 deletion chain/gssmr/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,12 @@ var (
// DefaultRPCHTTPPort rpc port
DefaultRPCHTTPPort = uint32(8545)
// DefaultRPCModules rpc modules
DefaultRPCModules = []string{"system", "author", "chain", "state", "rpc", "grandpa", "offchain", "childstate", "syncstate", "payment"}
DefaultRPCModules = []string{
"system", "author", "chain",
"state", "rpc", "grandpa",
"offchain", "childstate", "syncstate",
"payment",
}
// DefaultRPCWSPort rpc websocket port
DefaultRPCWSPort = uint32(8546)
)
Expand Down
7 changes: 6 additions & 1 deletion chain/kusama/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,12 @@ var (
// DefaultRPCHTTPPort rpc port
DefaultRPCHTTPPort = uint32(8545)
// DefaultRPCModules rpc modules
DefaultRPCModules = []string{"system", "author", "chain", "state", "rpc", "grandpa", "offchain", "childstate", "syncstate", "payment"}
DefaultRPCModules = []string{
"system", "author", "chain",
"state", "rpc", "grandpa",
"offchain", "childstate", "syncstate",
"payment",
}
// DefaultRPCWSPort rpc websocket port
DefaultRPCWSPort = uint32(8546)
)
Expand Down
4 changes: 3 additions & 1 deletion chain/polkadot/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ var (
// DefaultRPCHTTPPort rpc port
DefaultRPCHTTPPort = uint32(8545)
// DefaultRPCModules rpc modules
DefaultRPCModules = []string{"system", "author", "chain", "state", "rpc", "grandpa", "offchain", "childstate", "syncstate", "payment"}
DefaultRPCModules = []string{
"system", "author", "chain", "state", "rpc",
"grandpa", "offchain", "childstate", "syncstate", "payment"}
// DefaultRPCWSPort rpc websocket port
DefaultRPCWSPort = uint32(8546)
)
Expand Down
13 changes: 10 additions & 3 deletions cmd/gossamer/account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,20 @@ func TestAccountImportRaw(t *testing.T) {
defer utils.RemoveTestDir(t)
directory := fmt.Sprintf("--basepath=%s", testDir)

err := app.Run([]string{"irrelevant", "account", directory, `--import-raw=0x33a6f3093f158a7109f679410bef1a0c54168145e0cecb4df006c1c2fffb1f09`, "--password=1234"})
err := app.Run([]string{
"irrelevant", "account", directory,
`--import-raw=0x33a6f3093f158a7109f679410bef1a0c54168145e0cecb4df006c1c2fffb1f09`,
"--password=1234"})
require.NoError(t, err)

ctx, err := newTestContext(
"Test gossamer account --import-raw=0x33a6f3093f158a7109f679410bef1a0c54168145e0cecb4df006c1c2fffb1f09 --password=1234",
"Test gossamer account "+
"--import-raw=0x33a6f3093f158a7109f679410bef1a0c54168145e0cecb4df006c1c2fffb1f09 "+
"--password=1234",
[]string{"import-raw", "password"},
[]interface{}{"0x33a6f3093f158a7109f679410bef1a0c54168145e0cecb4df006c1c2fffb1f09", "1234"},
[]interface{}{
"0x33a6f3093f158a7109f679410bef1a0c54168145e0cecb4df006c1c2fffb1f09",
"1234"},
)
require.NoError(t, err)

Expand Down
8 changes: 7 additions & 1 deletion cmd/gossamer/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,8 @@ func parseLogLevelString(logLevelString string) (logLevel log.Level, err error)
return logLevel, nil
}

func setLogConfig(flagsKVStore stringKVStore, tomlConfig *ctoml.Config, globalCfg *dot.GlobalConfig, logCfg *dot.LogConfig) (err error) {
func setLogConfig(flagsKVStore stringKVStore, tomlConfig *ctoml.Config,
globalCfg *dot.GlobalConfig, logCfg *dot.LogConfig) (err error) {
if tomlConfig == nil {
tomlConfig = new(ctoml.Config)
}
Expand Down Expand Up @@ -672,6 +673,11 @@ func setDotNetworkConfig(ctx *cli.Context, tomlCfg ctoml.NetworkConfig, cfg *dot
cfg.NoMDNS = true
}

// check --pubip flag and update node configuration
if pubip := ctx.GlobalString(PublicIPFlag.Name); pubip != "" {
cfg.PublicIP = pubip
}

if len(cfg.PersistentPeers) == 0 {
cfg.PersistentPeers = []string(nil)
}
Expand Down
18 changes: 17 additions & 1 deletion cmd/gossamer/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,8 @@ func TestGlobalConfigFromFlagsFails(t *testing.T) {
[]string{"ws://foo/bar k"},
testCfg.Global.Name,
},
"could not set global config from flags: could not parse verbosity from telemetry-url: strconv.Atoi: parsing \"k\": invalid syntax",
"could not set global config from flags: could not parse verbosity from telemetry-url: " +
`strconv.Atoi: parsing "k": invalid syntax`,
},
}

Expand Down Expand Up @@ -515,6 +516,21 @@ func TestNetworkConfigFromFlags(t *testing.T) {
MinPeers: testCfg.Network.MinPeers,
},
},
{
"Test gossamer --pubip",
[]string{"config", "pubip"},
[]interface{}{testCfgFile.Name(), "10.0.5.2"},
dot.NetworkConfig{
Port: testCfg.Network.Port,
Bootnodes: testCfg.Network.Bootnodes,
ProtocolID: testCfg.Network.ProtocolID,
NoBootstrap: testCfg.Network.NoBootstrap,
NoMDNS: false,
DiscoveryInterval: time.Second * 10,
MinPeers: testCfg.Network.MinPeers,
PublicIP: "10.0.5.2",
},
},
}

for _, c := range testcases {
Expand Down
10 changes: 8 additions & 2 deletions cmd/gossamer/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,10 @@ func TestExportCommand(t *testing.T) {
{
"Test gossamer export --config --genesis --bootnodes --log --force",
[]string{"config", "genesis", "bootnodes", "name", "force", "pruning", "retain-blocks"},
[]interface{}{testConfig, genFile.Name(), testBootnode, "Gossamer", "true", gssmr.DefaultPruningMode, gssmr.DefaultRetainBlocks},
[]interface{}{
testConfig, genFile.Name(), testBootnode,
"Gossamer", "true", gssmr.DefaultPruningMode,
gssmr.DefaultRetainBlocks},
&dot.Config{
Global: testCfg.Global,
Init: dot.InitConfig{
Expand Down Expand Up @@ -117,7 +120,10 @@ func TestExportCommand(t *testing.T) {
{
"Test gossamer export --config --genesis --protocol --log --force",
[]string{"config", "genesis", "protocol", "force", "name", "pruning", "retain-blocks"},
[]interface{}{testConfig, genFile.Name(), testProtocol, "true", "Gossamer", gssmr.DefaultPruningMode, gssmr.DefaultRetainBlocks},
[]interface{}{
testConfig, genFile.Name(), testProtocol,
"true", "Gossamer", gssmr.DefaultPruningMode,
gssmr.DefaultRetainBlocks},
&dot.Config{
Global: testCfg.Global,
Init: dot.InitConfig{
Expand Down
Loading

0 comments on commit a52b42c

Please sign in to comment.