Skip to content

Commit

Permalink
move ./chain dir to ./internal/chain
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardmack committed Feb 2, 2023
1 parent 3ec939b commit 9267edf
Show file tree
Hide file tree
Showing 53 changed files with 31 additions and 31 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,5 @@ EXPOSE 7001 8546 8540

ENTRYPOINT [ "/gossamer/bin/gossamer" ]

COPY chain /gossamer/chain
COPY internal/chain /gossamer/chain
COPY --from=builder /go/src/github.com/ChainSafe/gossamer/bin/gossamer /gossamer/bin/gossamer
4 changes: 2 additions & 2 deletions cmd/gossamer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ This is the default Gossamer execution method, which invokes the `gossamerAction
blockchain client are [described below in the Client Components section](#client-components).

- `--basepath` - the path to the directory where Gossamer will store its data
- `--chain` - specifies the [chain configuration](../../chain) that the
- `--chain` - specifies the [chain configuration](../../internal/chain) that the
[Gossamer host node](https://chainsafe.github.io/gossamer/getting-started/overview/host-architecture/) should load
- `--key` - specifies a test keyring account to use (e.g. `--key=alice`)
- `--log` - supports levels `crit` (silent), `error`, `warn`, `info`, `debug`, and `trce` (detailed), default is `info`
Expand Down Expand Up @@ -86,7 +86,7 @@ The `importStateAction` function is defined in [`main.go`](main.go).
The `export` subcommand transforms a genesis configuration and Gossamer state into a TOML configuration file. This
subcommand invokes the `exportAction` function defined in [`export.go`](export.go).

- `--config` - path to a TOML configuration file (e.g. those defined in [the `chain` directory](../../chain))
- `--config` - path to a TOML configuration file (e.g. those defined in [the `chain` directory](../../internal/chain))
- `--basepath` - path to the Gossamer data directory that defines the state to export

## Client Components
Expand Down
4 changes: 2 additions & 2 deletions cmd/gossamer/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import (
"strings"
"time"

"github.com/ChainSafe/gossamer/chain/dev"
"github.com/ChainSafe/gossamer/chain/gssmr"
"github.com/ChainSafe/gossamer/dot"
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/internal/chain/dev"
"github.com/ChainSafe/gossamer/internal/chain/gssmr"
"github.com/ChainSafe/gossamer/internal/log"
"github.com/ChainSafe/gossamer/lib/common"
"github.com/ChainSafe/gossamer/lib/genesis"
Expand Down
4 changes: 2 additions & 2 deletions cmd/gossamer/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ import (
"testing"
"time"

"github.com/ChainSafe/gossamer/chain/dev"
"github.com/ChainSafe/gossamer/chain/gssmr"
"github.com/ChainSafe/gossamer/dot"
ctoml "github.com/ChainSafe/gossamer/dot/config/toml"
"github.com/ChainSafe/gossamer/dot/state"
"github.com/ChainSafe/gossamer/dot/types"
"github.com/ChainSafe/gossamer/internal/chain/dev"
"github.com/ChainSafe/gossamer/internal/chain/gssmr"
"github.com/ChainSafe/gossamer/internal/log"
"github.com/ChainSafe/gossamer/lib/common"
"github.com/ChainSafe/gossamer/lib/genesis"
Expand Down
3 changes: 1 addition & 2 deletions cmd/gossamer/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ import (
"io"
"testing"

"github.com/ChainSafe/gossamer/chain/gssmr"
"github.com/ChainSafe/gossamer/dot"

ctoml "github.com/ChainSafe/gossamer/dot/config/toml"
"github.com/ChainSafe/gossamer/internal/chain/gssmr"
"github.com/ChainSafe/gossamer/internal/log"
"github.com/stretchr/testify/require"
"github.com/urfave/cli"
Expand Down
2 changes: 1 addition & 1 deletion cmd/gossamer/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
package main

import (
"github.com/ChainSafe/gossamer/chain/dev"
"github.com/ChainSafe/gossamer/internal/chain/dev"
"github.com/urfave/cli"
)

Expand Down
2 changes: 1 addition & 1 deletion cmd/gossamer/flags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"io"
"testing"

"github.com/ChainSafe/gossamer/chain/dev"
"github.com/ChainSafe/gossamer/dot"
"github.com/ChainSafe/gossamer/internal/chain/dev"
"github.com/stretchr/testify/require"
"github.com/urfave/cli"
)
Expand Down
2 changes: 1 addition & 1 deletion cmd/gossamer/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ func TestMain(m *testing.M) {
panic(err)
}

testGssmrConfigPath = filepath.Join(rootPath, "./chain/gssmr/config.toml")
testGssmrConfigPath = filepath.Join(rootPath, "./internal/chain/gssmr/config.toml")

os.Exit(m.Run())
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/gossamer/toml_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ import (
"reflect"
"unicode"

"github.com/ChainSafe/gossamer"
ctoml "github.com/ChainSafe/gossamer/dot/config/toml"
"github.com/ChainSafe/gossamer/internal"
"github.com/naoina/toml"
)

func loadConfigFromResource(cfg *ctoml.Config, resourcePath string) error {
file, err := gossamer.DefaultConfigTomlFiles.Open(resourcePath)
file, err := internal.DefaultConfigTomlFiles.Open(resourcePath)
if err != nil {
logger.Errorf("failed to open toml configuration file: %s", err)
logger.Errorf("opening toml configuration file: %w", err)
return err
}
return loadConfig(cfg, file)
Expand Down
4 changes: 2 additions & 2 deletions cmd/gossamer/toml_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func TestLoadConfigGssmr(t *testing.T) {
require.NoError(t, err)

projectRootPath := utils.GetProjectRootPathTest(t)
gssmrConfigPath := filepath.Join(projectRootPath, "./chain/gssmr/config.toml")
gssmrConfigPath := filepath.Join(projectRootPath, "./internal/chain/gssmr/config.toml")

err = loadConfigFromFile(dotConfigToToml(cfg), gssmrConfigPath)
require.NoError(t, err)
Expand All @@ -57,7 +57,7 @@ func TestLoadConfigKusama(t *testing.T) {
require.NoError(t, err)

projectRootPath := utils.GetProjectRootPathTest(t)
kusamaConfigPath := filepath.Join(projectRootPath, "./chain/kusama/config.toml")
kusamaConfigPath := filepath.Join(projectRootPath, "./internal/chain/kusama/config.toml")

err = loadConfigFromFile(dotConfigToToml(cfg), kusamaConfigPath)
require.NoError(t, err)
Expand Down
8 changes: 4 additions & 4 deletions dot/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import (
"strings"
"time"

"github.com/ChainSafe/gossamer/chain/dev"
"github.com/ChainSafe/gossamer/chain/gssmr"
"github.com/ChainSafe/gossamer/chain/kusama"
"github.com/ChainSafe/gossamer/chain/polkadot"
"github.com/ChainSafe/gossamer/dot/state/pruner"
"github.com/ChainSafe/gossamer/dot/types"
"github.com/ChainSafe/gossamer/internal/chain/dev"
"github.com/ChainSafe/gossamer/internal/chain/gssmr"
"github.com/ChainSafe/gossamer/internal/chain/kusama"
"github.com/ChainSafe/gossamer/internal/chain/polkadot"
"github.com/ChainSafe/gossamer/internal/log"
"github.com/ChainSafe/gossamer/internal/pprof"
"github.com/ChainSafe/gossamer/lib/common"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions resources.go → internal/resources.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Copyright 2023 ChainSafe Systems (ON)
// SPDX-License-Identifier: LGPL-3.0-only
package gossamer
package internal

import "embed"

//go:embed chain/*/*.toml
// DefaultConfigTomlFiles resource files for default toml configurations
// DefaultConfigTomlFiles is the embedded file system containing the default toml configurations.
var DefaultConfigTomlFiles embed.FS
17 changes: 9 additions & 8 deletions lib/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,31 +151,31 @@ func KeystoreFilepaths(basepath string) ([]string, error) {
// GetWestendDevHumanReadableGenesisPath gets the westend-dev human readable spec filepath
func GetWestendDevHumanReadableGenesisPath(t *testing.T) string {
t.Helper()
return filepath.Join(GetProjectRootPathTest(t), "./chain/westend-dev/westend-dev-spec.json")
return filepath.Join(GetProjectRootPathTest(t), "./internal/chain/westend-dev/westend-dev-spec.json")
}

// GetWestendDevRawGenesisPath gets the westend-dev genesis raw path
func GetWestendDevRawGenesisPath(t *testing.T) string {
t.Helper()
return filepath.Join(GetProjectRootPathTest(t), "./chain/westend-dev/westend-dev-spec-raw.json")
return filepath.Join(GetProjectRootPathTest(t), "./internal/chain/westend-dev/westend-dev-spec-raw.json")
}

// GetWestendLocalRawGenesisPath gets the westend-local genesis raw path
func GetWestendLocalRawGenesisPath(t *testing.T) string {
t.Helper()
return filepath.Join(GetProjectRootPathTest(t), "./chain/westend-local/westend-local-spec-raw.json")
return filepath.Join(GetProjectRootPathTest(t), "./internal/chain/westend-local/westend-local-spec-raw.json")
}

// GetKusamaGenesisPath gets the Kusama genesis path
func GetKusamaGenesisPath(t *testing.T) string {
t.Helper()
return filepath.Join(GetProjectRootPathTest(t), "./chain/kusama/genesis.json")
return filepath.Join(GetProjectRootPathTest(t), "./internal/chain/kusama/genesis.json")
}

// GetPolkadotGenesisPath gets the Polkadot genesis path
func GetPolkadotGenesisPath(t *testing.T) string {
t.Helper()
return filepath.Join(GetProjectRootPathTest(t), "./chain/polkadot/genesis.json")
return filepath.Join(GetProjectRootPathTest(t), "./internal/chain/polkadot/genesis.json")
}

// GetProjectRootPathTest finds the root of the project where `go.mod` is
Expand All @@ -191,14 +191,15 @@ var (
ErrFindProjectRoot = errors.New("cannot find project root")
)

// GetProjectRootPath finds the root of the project where `go.mod` is
// GetProjectRootPath finds the root of the project where directory `cmd`
// and subdirectories `gossamer, testcases` are
// and returns it as an absolute path.
func GetProjectRootPath() (rootPath string, err error) {
_, fullpath, _, _ := runtime.Caller(0)
rootPath = path.Dir(fullpath)

const directoryToFind = "chain"
const subPathsToFind = "dev,gssmr,kusama,polkadot"
const directoryToFind = "cmd"
const subPathsToFind = "gossamer,testcases"

subPaths := strings.Split(subPathsToFind, ",")

Expand Down

0 comments on commit 9267edf

Please sign in to comment.