Skip to content

Commit

Permalink
feat: simd runs in-process testnet by default (#9246)
Browse files Browse the repository at this point in the history
<!-- < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < ☺
v                               ✰  Thanks for creating a PR! ✰
v    Before smashing the submit button please review the checkboxes.
v    If a checkbox is n/a - please still include it but + a little note why
☺ > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >  -->

## Description

ref: #9183 

After some more recent conversations w/ @aaronc, I decided to go back to his original proposal of setting up a subcommand for running in-process testnets. 

This PR splits the `simd testnet` command into two subcommands:
- `simd testnet start` which starts an in-process n-node testnet
- `simd testnet init-files` which sets up configuration & genesis files for an n-node testnet to be run as separate processes (one per node, most likely via Docker Compose)


---

Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

- [x] Targeted PR against correct branch (see [CONTRIBUTING.md](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting))
- [x] Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
- [x] Code follows the [module structure standards](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules/structure.md). - **n/a**
- [ ] Wrote unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing)
- [x] Updated relevant documentation (`docs/`) or specification (`x/<module>/spec/`) - **see #9411**
- [x] Added relevant `godoc` [comments](https://blog.golang.org/godoc-documenting-go-code).
- [x] Added a relevant changelog entry to the `Unreleased` section in `CHANGELOG.md`
- [x] Re-reviewed `Files changed` in the Github PR explorer
- [ ] Review `Codecov Report` in the comment section below once CI passes
  • Loading branch information
clevinson authored Jun 29, 2021
1 parent 7a8b273 commit aef416f
Show file tree
Hide file tree
Showing 41 changed files with 525 additions and 189 deletions.
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ Ref: https://keepachangelog.com/en/1.0.0/
* [\#9427](https://github.com/cosmos/cosmos-sdk/pull/9427) Move simapp `FundAccount` and `FundModuleAccount` to `x/bank/testutil`
* (client/tx) [\#9421](https://github.com/cosmos/cosmos-sdk/pull/9421/) `BuildUnsignedTx`, `BuildSimTx`, `PrintUnsignedStdTx` functions are moved to
the Tx Factory as methods.
* [\#9246](https://github.com/cosmos/cosmos-sdk/pull/9246) The `New` method for the network package now returns an error.

### CLI Breaking Changes

* [\#9246](https://github.com/cosmos/cosmos-sdk/pull/9246) Removed the CLI flag `--setup-config-only` from the `testnet` command and added the subcommand `init-files`.

### Improvements
* (cli) [\#9593](https://github.com/cosmos/cosmos-sdk/pull/9593) Check if chain-id is blank before verifying signatures in multisign and error.
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -475,16 +475,16 @@ proto-update-deps:
### Localnet ###
###############################################################################

# Run a 4-node testnet locally
# Run a 4-node testnet locally via docker compose
localnet-start: build-linux localnet-stop
$(if $(shell $(DOCKER) inspect -f '{{ .Id }}' cosmossdk/simd-env 2>/dev/null),$(info found image cosmossdk/simd-env),$(MAKE) -C contrib/images simd-env)
if ! [ -f build/node0/simd/config/genesis.json ]; then $(DOCKER) run --rm \
if ! test -f build/node0/simd/config/genesis.json; then $(DOCKER) run --rm \
--user $(shell id -u):$(shell id -g) \
-v $(BUILDDIR):/simd:Z \
-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 init-files --v 4 -o . --starting-ip-address 192.168.10.2 --keyring-backend=test ; fi
docker-compose up -d

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

n := network.New(t, cfg)
n, err := network.New(t, t.TempDir(), cfg)
require.NoError(t, err)
defer n.Cleanup()

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

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

s.Require().NotNil(s.network)
var err error
s.network, err = network.New(s.T(), s.T().TempDir(), s.cfg)
s.Require().NoError(err)

_, err := s.network.WaitForHeight(1)
_, err = s.network.WaitForHeight(1)
s.Require().NoError(err)

s.queryClient = tmservice.NewServiceClient(s.network.Validators[0].ClientCtx)
Expand Down
7 changes: 4 additions & 3 deletions client/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ type IntegrationTestSuite struct {
func (s *IntegrationTestSuite) SetupSuite() {
s.T().Log("setting up integration test suite")

s.network = network.New(s.T(), network.DefaultConfig())
s.Require().NotNil(s.network)
var err error
s.network, err = network.New(s.T(), s.T().TempDir(), network.DefaultConfig())
s.Require().NoError(err)

_, err := s.network.WaitForHeight(2)
_, err = s.network.WaitForHeight(2)
s.Require().NoError(err)
}

Expand Down
5 changes: 3 additions & 2 deletions client/rpc/rpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ type IntegrationTestSuite struct {
func (s *IntegrationTestSuite) SetupSuite() {
s.T().Log("setting up integration test suite")

s.network = network.New(s.T(), network.DefaultConfig())
s.Require().NotNil(s.network)
var err error
s.network, err = network.New(s.T(), s.T().TempDir(), network.DefaultConfig())
s.Require().NoError(err)

s.Require().NoError(s.network.WaitForNextBlock())
}
Expand Down
8 changes: 5 additions & 3 deletions server/grpc/grpc_web_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,12 @@ func (s *GRPCWebTestSuite) SetupSuite() {
cfg := network.DefaultConfig()
cfg.NumValidators = 1
s.cfg = cfg
s.network = network.New(s.T(), s.cfg)
s.Require().NotNil(s.network)

_, err := s.network.WaitForHeight(2)
var err error
s.network, err = network.New(s.T(), s.T().TempDir(), s.cfg)
s.Require().NoError(err)

_, err = s.network.WaitForHeight(2)
s.Require().NoError(err)

s.protoCdc = codec.NewProtoCodec(s.cfg.InterfaceRegistry)
Expand Down
8 changes: 5 additions & 3 deletions server/grpc/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,12 @@ func (s *IntegrationTestSuite) SetupSuite() {
s.app = simapp.Setup(false)
s.cfg = network.DefaultConfig()
s.cfg.NumValidators = 1
s.network = network.New(s.T(), s.cfg)
s.Require().NotNil(s.network)

_, err := s.network.WaitForHeight(2)
var err error
s.network, err = network.New(s.T(), s.T().TempDir(), s.cfg)
s.Require().NoError(err)

_, err = s.network.WaitForHeight(2)
s.Require().NoError(err)

val0 := s.network.Validators[0]
Expand Down
2 changes: 1 addition & 1 deletion simapp/simd/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig) {
genutilcli.ValidateGenesisCmd(simapp.ModuleBasics),
AddGenesisAccountCmd(simapp.DefaultNodeHome),
tmcli.NewCompletionCmd(rootCmd, true),
testnetCmd(simapp.ModuleBasics, banktypes.GenesisBalancesIterator{}),
NewTestnetCmd(simapp.ModuleBasics, banktypes.GenesisBalancesIterator{}),
debug.Cmd(),
config.Cmd(),
)
Expand Down
Loading

0 comments on commit aef416f

Please sign in to comment.