Skip to content

Commit

Permalink
chore: update branch
Browse files Browse the repository at this point in the history
  • Loading branch information
EclesioMeloJunior committed Aug 10, 2022
1 parent a48f7a6 commit d1db66e
Show file tree
Hide file tree
Showing 115 changed files with 3,892 additions and 1,871 deletions.
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/.githooks
/.github
!/.github/workflows/staging
/docker
/docs
/.deepsource.toml
/.dockerignore
Expand All @@ -12,5 +13,4 @@
/docker-compose.yml
/Dockerfile
/Dockerfile.staging
/prometheus.yml
/README.md
10 changes: 10 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,16 @@ issues:
- lll
source: "^//go:generate "

- linters:
- lll
path: lib/runtime/wasmer/imports\.go
source: "^// extern "

- linters:
- lll
path: lib/runtime/wasmer/imports\.go
source: '{"ext_.+", ext_.+, C.ext_.+},$'

- source: "// https://"
linters:
- lll
Expand Down
3 changes: 2 additions & 1 deletion chain/dev/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package dev

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"
)
Expand Down Expand Up @@ -52,7 +53,7 @@ var (
// DefaultAuthority is true if the node is a block producer and a grandpa authority
DefaultAuthority = true
// DefaultRoles Default node roles
DefaultRoles = byte(4) // authority node (see Table D.2)
DefaultRoles = common.AuthorityRole // 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)
Expand Down
3 changes: 2 additions & 1 deletion chain/gssmr/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"time"

"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"
)
Expand Down Expand Up @@ -54,7 +55,7 @@ var (
// DefaultAuthority is true if the node is a block producer and a grandpa authority
DefaultAuthority = true
// DefaultRoles Default node roles
DefaultRoles = byte(4) // authority node (see Table D.2)
DefaultRoles = common.AuthorityRole // 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)
Expand Down
3 changes: 2 additions & 1 deletion chain/kusama/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package kusama

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"
)
Expand Down Expand Up @@ -52,7 +53,7 @@ var (
// DefaultAuthority true if BABE block producer
DefaultAuthority = false
// DefaultRoles Default node roles
DefaultRoles = byte(1) // full node (see Table D.2)
DefaultRoles = common.FullNodeRole // full node (see Table D.2)
// DefaultWasmInterpreter is the name of the wasm interpreter to use by default
DefaultWasmInterpreter = wasmer.Name

Expand Down
3 changes: 2 additions & 1 deletion chain/polkadot/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package polkadot

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"
)
Expand Down Expand Up @@ -49,7 +50,7 @@ var (
// DefaultAuthority is true if the node is a block producer and a grandpa authority
DefaultAuthority = true
// DefaultRoles Default node roles
DefaultRoles = byte(1) // authority node (see Table D.2)
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)
Expand Down
25 changes: 12 additions & 13 deletions cmd/gossamer/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (
ctoml "github.com/ChainSafe/gossamer/dot/config/toml"
"github.com/ChainSafe/gossamer/dot/state"
"github.com/ChainSafe/gossamer/dot/state/pruner"
"github.com/ChainSafe/gossamer/dot/types"
"github.com/ChainSafe/gossamer/internal/log"
"github.com/ChainSafe/gossamer/lib/common"
"github.com/ChainSafe/gossamer/lib/genesis"
Expand Down Expand Up @@ -572,9 +571,9 @@ func setDotAccountConfig(ctx *cli.Context, tomlCfg ctoml.AccountConfig, cfg *dot

// setDotCoreConfig sets dot.CoreConfig using flag values from the cli context
func setDotCoreConfig(ctx *cli.Context, tomlCfg ctoml.CoreConfig, cfg *dot.CoreConfig) {
cfg.Roles = tomlCfg.Roles
cfg.BabeAuthority = tomlCfg.Roles == types.AuthorityRole
cfg.GrandpaAuthority = tomlCfg.Roles == types.AuthorityRole
cfg.Roles = common.Roles(tomlCfg.Roles)
cfg.BabeAuthority = common.Roles(tomlCfg.Roles) == common.AuthorityRole
cfg.GrandpaAuthority = common.Roles(tomlCfg.Roles) == common.AuthorityRole
cfg.GrandpaInterval = time.Second * time.Duration(tomlCfg.GrandpaInterval)

cfg.BABELead = tomlCfg.BABELead
Expand All @@ -586,14 +585,14 @@ func setDotCoreConfig(ctx *cli.Context, tomlCfg ctoml.CoreConfig, cfg *dot.CoreC
if roles := ctx.GlobalString(RolesFlag.Name); roles != "" {
// convert string to byte
n, err := strconv.Atoi(roles)
b := byte(n)
b := common.Roles(n)
if err != nil {
logger.Errorf("failed to convert Roles to byte: %s", err)
} else if b == types.AuthorityRole {
} else if b == common.AuthorityRole {
// if roles byte is 4, act as an authority (see Table D.2)
logger.Debug("authority enabled (roles=4)")
cfg.Roles = b
} else if b > types.AuthorityRole {
} else if b > common.AuthorityRole {
// if roles byte is greater than 4, invalid roles byte (see Table D.2)
logger.Errorf("invalid roles option provided, authority disabled (roles=%d)", b)
} else {
Expand All @@ -605,15 +604,15 @@ func setDotCoreConfig(ctx *cli.Context, tomlCfg ctoml.CoreConfig, cfg *dot.CoreC

// to turn on BABE but not grandpa, cfg.Roles must be set to 4
// and cfg.GrandpaAuthority must be set to false
if cfg.Roles == types.AuthorityRole && !tomlCfg.BabeAuthority {
if cfg.Roles == common.AuthorityRole && !tomlCfg.BabeAuthority {
cfg.BabeAuthority = false
}

if cfg.Roles == types.AuthorityRole && !tomlCfg.GrandpaAuthority {
if cfg.Roles == common.AuthorityRole && !tomlCfg.GrandpaAuthority {
cfg.GrandpaAuthority = false
}

if cfg.Roles != types.AuthorityRole {
if cfg.Roles != common.AuthorityRole {
cfg.BabeAuthority = false
cfg.GrandpaAuthority = false
}
Expand Down Expand Up @@ -805,9 +804,9 @@ func setSystemInfoConfig(ctx *cli.Context, cfg *dot.Config) {
func updateDotConfigFromGenesisJSONRaw(tomlCfg ctoml.Config, cfg *dot.Config) {
cfg.Account.Key = tomlCfg.Account.Key
cfg.Account.Unlock = tomlCfg.Account.Unlock
cfg.Core.Roles = tomlCfg.Core.Roles
cfg.Core.BabeAuthority = tomlCfg.Core.Roles == types.AuthorityRole
cfg.Core.GrandpaAuthority = tomlCfg.Core.Roles == types.AuthorityRole
cfg.Core.Roles = common.Roles(tomlCfg.Core.Roles)
cfg.Core.BabeAuthority = common.Roles(tomlCfg.Core.Roles) == common.AuthorityRole
cfg.Core.GrandpaAuthority = common.Roles(tomlCfg.Core.Roles) == common.AuthorityRole

// use default genesis file if genesis configuration not provided, for example,
// if we load a toml configuration file without a defined genesis init value or
Expand Down
3 changes: 2 additions & 1 deletion cmd/gossamer/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"github.com/ChainSafe/gossamer/dot/state"
"github.com/ChainSafe/gossamer/dot/types"
"github.com/ChainSafe/gossamer/internal/log"
"github.com/ChainSafe/gossamer/lib/common"
"github.com/ChainSafe/gossamer/lib/genesis"
"github.com/ChainSafe/gossamer/lib/runtime"
"github.com/ChainSafe/gossamer/lib/utils"
Expand Down Expand Up @@ -974,7 +975,7 @@ func TestGlobalNodeName_WhenNodeAlreadyHasStoredName(t *testing.T) {
err = os.WriteFile(genPath, genData, os.ModePerm)
require.NoError(t, err)

cfg.Core.Roles = types.FullNodeRole
cfg.Core.Roles = common.FullNodeRole
cfg.Core.BabeAuthority = false
cfg.Core.GrandpaAuthority = false
cfg.Init.Genesis = genPath
Expand Down
2 changes: 1 addition & 1 deletion cmd/gossamer/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func dotConfigToToml(dcfg *dot.Config) *ctoml.Config {
}

cfg.Core = ctoml.CoreConfig{
Roles: dcfg.Core.Roles,
Roles: byte(dcfg.Core.Roles),
BabeAuthority: dcfg.Core.BabeAuthority,
GrandpaAuthority: dcfg.Core.GrandpaAuthority,
GrandpaInterval: uint32(dcfg.Core.GrandpaInterval / time.Second),
Expand Down
65 changes: 55 additions & 10 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,60 @@
version: '3.7'
# This docker-compose.yml configuration contains:
# - a Gossamer node on the Kusama chain
# - a Prometheus server scrapping metrics from Gossamer
# - a Grafana server using the Prometheus server as source
#
# Prometheus and Grafana are both provisioned to give you a dashboard to play with.
# They are tailored for local development, and Grafana gives you anonymous admin access.
#
# You can run all of the containers with: `docker-compose up`
# Alternatively, you can run select containers with for example: `docker-compose up gossamer`
#
# To rebuild the Gossamer Docker image: `docker-compose build`

version: '3'

services:
gossamer:
image: chainsafe/gossamer
build: .
volumes:
# Remove with: docker volume rm gossamer
- gossamer:/data/gossamer
command:
- --basepath=/data/gossamer
- --chain=kusama
- --log=info
- --publish-metrics
- --metrics-address=:9876
- --pprofserver
ports:
- 6060:6060/tcp # Pprof server
- 7001:7001/tcp # Network port
- 8545:8545/tcp # RPC HTTP port
- 8546:8546/tcp # RPC Websocket port
expose:
- 9876/tcp # Prometheus metrics for Prometheus server

services:
prometheus:
image: prom/prometheus
volumes:
- ./prometheus.yml:/etc/prometheus/prometheus.yml
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
- '--web.console.libraries=/usr/share/prometheus/console_libraries'
- '--web.console.templates=/usr/share/prometheus/consoles'
- ./docker/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro
# The following line can be uncommented to persist metrics data.
# - gossamer-prometheus:/prometheus
expose:
- 9090/tcp # Prometheus metrics for Grafana

grafana:
image: grafana/grafana-oss
ports:
- 9090:9090
restart: always
- 3000:3000/tcp # HTTP Web interface at http://localhost:3000/
volumes:
- ./docker/grafana/grafana.ini:/etc/grafana/grafana.ini:ro
- ./docker/grafana/provisioning:/etc/grafana/provisioning:ro
# The following line can be uncommented to persist modifications.
# - gossamer-grafana:/var/lib/grafana

volumes:
gossamer:
gossamer-prometheus:
gossamer-grafana:
12 changes: 12 additions & 0 deletions docker/grafana/grafana.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# See https://github.com/grafana/grafana/blob/main/conf/sample.ini

[dashboards]
min_refresh_interval = 5s
default_home_dashboard_path = /etc/grafana/provisioning/dashboards/gossamer.json

[users]
allow_sign_up = false

[auth.anonymous]
enabled = true
org_role = Admin
Loading

0 comments on commit d1db66e

Please sign in to comment.