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: simd runs in-process testnet by default #9246

Merged
merged 38 commits into from
Jun 29, 2021
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
e1fd374
update testnet subcommand to run in-process testnets by default
clevinson Apr 30, 2021
15803e3
Update simapp/simd/cmd/testnet.go
clevinson Apr 30, 2021
21a0961
update flag names, update `make localnet-start` task with new simd te…
clevinson Apr 30, 2021
80704f2
Merge remote-tracking branch 'origin/clevinson/ci-devnets' into clevi…
clevinson Apr 30, 2021
082d317
Merge remote-tracking branch 'origin/master' into clevinson/ci-devnets
clevinson Apr 30, 2021
837e58d
fix tests
clevinson Apr 30, 2021
12c7283
make lint-fix
clevinson Apr 30, 2021
60d3acf
Merge remote-tracking branch 'origin/master' into clevinson/ci-devnets
clevinson May 4, 2021
858fb0a
refactor Network's TestnetEnv to use network.Logger interface
clevinson May 4, 2021
052e19b
split testnet start & init-files into subcommands
clevinson May 6, 2021
72ff9d5
update makefile
clevinson May 11, 2021
ca21ad5
add port flags to testnets-start subcommand
clevinson May 13, 2021
9f15d2c
add option for printing mnemonic when running testnet
clevinson May 13, 2021
a7954de
add godocs for new testnet command
clevinson May 13, 2021
0918491
Merge branch 'master' into clevinson/ci-devnets
clevinson May 14, 2021
3766c4e
fix format
ryanchristo May 19, 2021
3bf532f
fix test vars
ryanchristo May 19, 2021
e4cae70
use chain subdirectories
ryanchristo May 19, 2021
9763928
use localnet directory
ryanchristo May 19, 2021
ccec784
fix lint
ryanchristo May 19, 2021
42e68ea
fix description
ryanchristo May 20, 2021
5b0d334
revert changes
ryanchristo May 20, 2021
2c286ef
Merge branch 'master' into clevinson/ci-devnets
ryanchristo May 20, 2021
606363b
fix description
ryanchristo May 21, 2021
42ab2fc
fix error
ryanchristo May 21, 2021
b9b53a9
Merge branch 'master' into clevinson/ci-devnets
ryanchristo May 21, 2021
d71fdb7
remove brackets
ryanchristo May 21, 2021
4587e1c
add changelog entries
ryanchristo May 26, 2021
65c6410
use private functions
ryanchristo May 26, 2021
2725ac7
consolidate input params
ryanchristo May 26, 2021
aee829f
Merge branch 'master' into clevinson/ci-devnets
ryanchristo May 26, 2021
0b9aaf1
fix struct name
ryanchristo May 26, 2021
f2210bd
Merge branch 'master' into clevinson/ci-devnets
ryanchristo Jun 28, 2021
e479ff1
amend changelog
ryanchristo Jun 28, 2021
b86cdcf
fix new testsuite
ryanchristo Jun 28, 2021
4717b85
fix test command
ryanchristo Jun 29, 2021
61ac80b
Merge branch 'master' into clevinson/ci-devnets
amaury1093 Jun 29, 2021
6892453
Merge branch 'master' into clevinson/ci-devnets
amaury1093 Jun 29, 2021
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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ artifacts
# Data - ideally these don't exist
baseapp/data/*
client/lcd/keys/*
mytestnet
.testnets

# Testing
coverage.txt
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ localnet-start: build-linux localnet-stop
-v /etc/group:/etc/group:ro \
-v /etc/passwd:/etc/passwd:ro \
-v /etc/shadow:/etc/shadow:ro \
cosmossdk/simd-env testnet --v 4 -o . --starting-ip-address 192.168.10.2 --keyring-backend=test ; fi
cosmossdk/simd-env testnet --setup-config-only --v 4 -o . --starting-ip-address 192.168.10.2 --keyring-backend=test ; fi
docker-compose up -d
ryanchristo marked this conversation as resolved.
Show resolved Hide resolved

localnet-stop:
Expand Down
2 changes: 1 addition & 1 deletion client/context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func TestCLIQueryConn(t *testing.T) {
cfg := network.DefaultConfig()
cfg.NumValidators = 1

n := network.New(t, cfg)
n := network.NewForTesting(t, cfg)
defer n.Cleanup()

testClient := testdata.NewQueryClient(n.Validators[0].ClientCtx)
Expand Down
2 changes: 1 addition & 1 deletion client/grpc/tmservice/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (s *IntegrationTestSuite) SetupSuite() {
cfg.NumValidators = 1

s.cfg = cfg
s.network = network.New(s.T(), cfg)
s.network = network.NewForTesting(s.T(), cfg)

s.Require().NotNil(s.network)

Expand Down
2 changes: 1 addition & 1 deletion client/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type IntegrationTestSuite struct {
func (s *IntegrationTestSuite) SetupSuite() {
s.T().Log("setting up integration test suite")

s.network = network.New(s.T(), network.DefaultConfig())
s.network = network.NewForTesting(s.T(), network.DefaultConfig())
s.Require().NotNil(s.network)

_, err := s.network.WaitForHeight(2)
Expand Down
2 changes: 1 addition & 1 deletion client/rpc/rpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type IntegrationTestSuite struct {
func (s *IntegrationTestSuite) SetupSuite() {
s.T().Log("setting up integration test suite")

s.network = network.New(s.T(), network.DefaultConfig())
s.network = network.NewForTesting(s.T(), network.DefaultConfig())
s.Require().NotNil(s.network)

s.Require().NoError(s.network.WaitForNextBlock())
Expand Down
2 changes: 1 addition & 1 deletion server/grpc/grpc_web_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func (s *GRPCWebTestSuite) SetupSuite() {
cfg := network.DefaultConfig()
cfg.NumValidators = 1
s.cfg = cfg
s.network = network.New(s.T(), s.cfg)
s.network = network.NewForTesting(s.T(), s.cfg)
s.Require().NotNil(s.network)

_, err := s.network.WaitForHeight(2)
Expand Down
2 changes: 1 addition & 1 deletion server/grpc/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (s *IntegrationTestSuite) SetupSuite() {

s.cfg = network.DefaultConfig()
s.cfg.NumValidators = 1
s.network = network.New(s.T(), s.cfg)
s.network = network.NewForTesting(s.T(), s.cfg)
s.Require().NotNil(s.network)

_, err := s.network.WaitForHeight(2)
Expand Down
53 changes: 43 additions & 10 deletions simapp/simd/cmd/testnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"os"
"path/filepath"

"github.com/cosmos/cosmos-sdk/testutil/network"
ryanchristo marked this conversation as resolved.
Show resolved Hide resolved
"github.com/spf13/cobra"
tmconfig "github.com/tendermint/tendermint/config"
tmos "github.com/tendermint/tendermint/libs/os"
Expand Down Expand Up @@ -40,20 +41,29 @@ var (
flagOutputDir = "output-dir"
flagNodeDaemonHome = "node-daemon-home"
flagStartingIPAddress = "starting-ip-address"
flagSetupConfigOnly = "setup-config-only"
)

// get cmd to initialize all files for tendermint testnet and application
func testnetCmd(mbm module.BasicManager, genBalIterator banktypes.GenesisBalancesIterator) *cobra.Command {
cmd := &cobra.Command{
Use: "testnet",
Short: "Initialize files for a simapp testnet",
Long: `testnet will create "v" number of directories and populate each with
Short: "Launch an in-process multi-validator testnet, or initialize config directories & files for a multi-validator testnet running locally via a separate processes",
amaury1093 marked this conversation as resolved.
Show resolved Hide resolved
Long: `testnet will launch an in-process multi-validator testnet, and generate "v" directories, populated with necessary validator configuration files
(private validator, genesis, config, etc.).

If --setup-config-only flag is provided, it will not launch a testnet, but instead will only setup
"v" number of directories and populate each with
necessary files (private validator, genesis, config, etc.).

The following flags are only intended for use if --setup-config-only flag is present, and ignored otherwise:
--keyring-backend, --algo, --node-dir-prefix, --node-daemon-home, --starting-ip-address

Note, strict routability for addresses is turned off in the config file.

Example:
simd testnet --v 4 --output-dir ./output --starting-ip-address 192.168.10.2
simd testnet --v 4 --output-dir ./output
simd testnet --v 4 --output-dir ./output --setup-config-only --starting-ip-address 192.168.10.2
`,
RunE: func(cmd *cobra.Command, _ []string) error {
clientCtx, err := client.GetClientQueryContext(cmd)
Expand All @@ -70,22 +80,28 @@ Example:
minGasPrices, _ := cmd.Flags().GetString(server.FlagMinGasPrices)
nodeDirPrefix, _ := cmd.Flags().GetString(flagNodeDirPrefix)
nodeDaemonHome, _ := cmd.Flags().GetString(flagNodeDaemonHome)
setupConfigOnly, _ := cmd.Flags().GetBool(flagSetupConfigOnly)
startingIPAddress, _ := cmd.Flags().GetString(flagStartingIPAddress)
numValidators, _ := cmd.Flags().GetInt(flagNumValidators)
algo, _ := cmd.Flags().GetString(flags.FlagKeyAlgorithm)

return InitTestnet(
clientCtx, cmd, config, mbm, genBalIterator, outputDir, chainID, minGasPrices,
nodeDirPrefix, nodeDaemonHome, startingIPAddress, keyringBackend, algo, numValidators,
)
if setupConfigOnly {
return SetupTestnetConfigs(
clientCtx, cmd, config, mbm, genBalIterator, outputDir, chainID, minGasPrices,
nodeDirPrefix, nodeDaemonHome, startingIPAddress, keyringBackend, algo, numValidators,
)
}
return StartTestnet(cmd, outputDir, chainID, minGasPrices, algo, numValidators)

},
}

cmd.Flags().Int(flagNumValidators, 4, "Number of validators to initialize the testnet with")
cmd.Flags().StringP(flagOutputDir, "o", "./mytestnet", "Directory to store initialization data for the testnet")
cmd.Flags().StringP(flagOutputDir, "o", "./.testnets", "Directory to store initialization data for the testnet")
cmd.Flags().String(flagNodeDirPrefix, "node", "Prefix the directory name for each node with (node results in node0, node1, ...)")
cmd.Flags().String(flagNodeDaemonHome, "simd", "Home directory of the node's daemon configuration")
cmd.Flags().String(flagStartingIPAddress, "192.168.0.1", "Starting IP address (192.168.0.1 results in persistent peers list [email protected]:46656, [email protected]:46656, ...)")
cmd.Flags().Bool(flagSetupConfigOnly, false, "Initialize data for separately running validator nodes manually, does not start in-process testnet")
cmd.Flags().String(flagStartingIPAddress, "192.168.0.1", "Starting IP address (192.168.0.1 results in persistent peers list [email protected]:46656, [email protected]:46656, ...), required if --setup-config-only")
cmd.Flags().String(flags.FlagChainID, "", "genesis file chain-id, if left blank will be randomly created")
cmd.Flags().String(server.FlagMinGasPrices, fmt.Sprintf("0.000006%s", sdk.DefaultBondDenom), "Minimum gas prices to accept for transactions; All fees in a tx must meet this minimum (e.g. 0.01photino,0.001stake)")
cmd.Flags().String(flags.FlagKeyringBackend, flags.DefaultKeyringBackend, "Select keyring's backend (os|file|test)")
Expand All @@ -97,7 +113,7 @@ Example:
const nodeDirPerm = 0755

// Initialize the testnet
func InitTestnet(
func SetupTestnetConfigs(
clientCtx client.Context,
cmd *cobra.Command,
nodeConfig *tmconfig.Config,
Expand Down Expand Up @@ -398,3 +414,20 @@ func writeFile(name string, dir string, contents []byte) error {

return nil
}

func StartTestnet(cmd *cobra.Command, configDir string, chainID string, minGasPrices string, algo string, numValidators int) error {
networkConfig := network.DefaultConfig()

// Default networkConfig.ChainID is random, and we should only override it if chainID provided
// is non-empty
if chainID != "" {
networkConfig.ChainID = chainID
}
networkConfig.SigningAlgo = algo
networkConfig.MinGasPrices = minGasPrices
networkConfig.NumValidators = numValidators
testnetEnv := network.NewStandaloneTestnetEnv(cmd, configDir)

network.New(testnetEnv, networkConfig)
return server.WaitForQuitSignals()
}
Loading