From 3e8dd392c86f4d5b45246924bc2e776107e395fc Mon Sep 17 00:00:00 2001 From: PrathyushaLakkireddy Date: Thu, 17 Dec 2020 15:19:03 +0530 Subject: [PATCH 1/4] Read gentx amount as argument --- x/genutil/client/cli/gentx.go | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/x/genutil/client/cli/gentx.go b/x/genutil/client/cli/gentx.go index 6ded1b76b9dd..4bf32bb44329 100644 --- a/x/genutil/client/cli/gentx.go +++ b/x/genutil/client/cli/gentx.go @@ -10,11 +10,6 @@ import ( "os" "path/filepath" - "github.com/pkg/errors" - "github.com/spf13/cobra" - tmos "github.com/tendermint/tendermint/libs/os" - tmtypes "github.com/tendermint/tendermint/types" - "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" @@ -27,6 +22,10 @@ import ( "github.com/cosmos/cosmos-sdk/x/genutil" "github.com/cosmos/cosmos-sdk/x/genutil/types" "github.com/cosmos/cosmos-sdk/x/staking/client/cli" + "github.com/pkg/errors" + "github.com/spf13/cobra" + tmos "github.com/tendermint/tendermint/libs/os" + tmtypes "github.com/tendermint/tendermint/types" ) // GenTxCmd builds the application's gentx command. @@ -45,8 +44,7 @@ file. The following default parameters are included: %s Example: -$ %s gentx my-key-name --home=/path/to/home/dir --keyring-backend=os --chain-id=test-chain-1 \ - --amount=1000000stake \ +$ %s gentx my-key-name 1000000stake --home=/path/to/home/dir --keyring-backend=os --chain-id=test-chain-1 \ --moniker="myvalidator" \ --commission-max-change-rate=0.01 \ --commission-max-rate=1.0 \ @@ -118,7 +116,7 @@ $ %s gentx my-key-name --home=/path/to/home/dir --keyring-backend=os --chain-id= return errors.Wrap(err, "error creating configuration to create validator msg") } - amount, _ := cmd.Flags().GetString(cli.FlagAmount) + amount := args[1] coins, err := sdk.ParseCoinsNormalized(amount) if err != nil { return errors.Wrap(err, "failed to parse coins") From f3946f57eaf2282d3f444f80bac8ccbe669b38e2 Mon Sep 17 00:00:00 2001 From: PrathyushaLakkireddy Date: Thu, 17 Dec 2020 15:50:57 +0530 Subject: [PATCH 2/4] Update gentx command usage --- x/genutil/client/cli/gentx.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/x/genutil/client/cli/gentx.go b/x/genutil/client/cli/gentx.go index 4bf32bb44329..200d038f627a 100644 --- a/x/genutil/client/cli/gentx.go +++ b/x/genutil/client/cli/gentx.go @@ -10,6 +10,11 @@ import ( "os" "path/filepath" + "github.com/pkg/errors" + "github.com/spf13/cobra" + tmos "github.com/tendermint/tendermint/libs/os" + tmtypes "github.com/tendermint/tendermint/types" + "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/client/tx" @@ -22,10 +27,6 @@ import ( "github.com/cosmos/cosmos-sdk/x/genutil" "github.com/cosmos/cosmos-sdk/x/genutil/types" "github.com/cosmos/cosmos-sdk/x/staking/client/cli" - "github.com/pkg/errors" - "github.com/spf13/cobra" - tmos "github.com/tendermint/tendermint/libs/os" - tmtypes "github.com/tendermint/tendermint/types" ) // GenTxCmd builds the application's gentx command. @@ -34,9 +35,9 @@ func GenTxCmd(mbm module.BasicManager, txEncCfg client.TxEncodingConfig, genBalI fsCreateValidator, defaultsDesc := cli.CreateValidatorMsgFlagSet(ipDefault) cmd := &cobra.Command{ - Use: "gentx [key_name]", + Use: "gentx [key_name] [amount]", Short: "Generate a genesis tx carrying a self delegation", - Args: cobra.ExactArgs(1), + Args: cobra.ExactArgs(2), Long: fmt.Sprintf(`Generate a genesis transaction that creates a validator with a self-delegation, that is signed by the key in the Keyring referenced by a given name. A node ID and Bech32 consensus pubkey may optionally be provided. If they are omitted, they will be retrieved from the priv_validator.json From ae10989377548aee1d6bdf9d63dfbb540fd1e712 Mon Sep 17 00:00:00 2001 From: PrathyushaLakkireddy Date: Thu, 17 Dec 2020 16:29:33 +0530 Subject: [PATCH 3/4] Update gentx tests --- x/genutil/client/cli/gentx_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/x/genutil/client/cli/gentx_test.go b/x/genutil/client/cli/gentx_test.go index a433a97643d2..bbea1818ddb5 100644 --- a/x/genutil/client/cli/gentx_test.go +++ b/x/genutil/client/cli/gentx_test.go @@ -65,6 +65,7 @@ func (s *IntegrationTestSuite) TestGenTxCmd() { fmt.Sprintf("--%s=%s", flags.FlagChainID, s.network.Config.ChainID), fmt.Sprintf("--%s=%s", flags.FlagOutputDocument, genTxFile), val.Moniker, + sdk.NewCoin(s.cfg.BondDenom, sdk.NewInt(10)).String(), }) err := cmd.ExecuteContext(ctx) From 4bcc321ddc011351c2412485f113395ab18eb861 Mon Sep 17 00:00:00 2001 From: PrathyushaLakkireddy Date: Thu, 17 Dec 2020 21:12:29 +0530 Subject: [PATCH 4/4] Update docs of gentx --- docs/run-node/run-node.md | 2 +- docs/using-the-sdk/cosmovisor.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/run-node/run-node.md b/docs/run-node/run-node.md index 768726d602d8..393172b9aa0c 100644 --- a/docs/run-node/run-node.md +++ b/docs/run-node/run-node.md @@ -53,7 +53,7 @@ Now that your account has some tokens, you need to add a validator to your chain ```bash # Create a gentx. -simd gentx my_validator --amount 100000stake --chain-id my-test-chain --keyring-backend test +simd gentx my_validator 100000stake --chain-id my-test-chain --keyring-backend test # Add the gentx to the genesis file. simd collect-gentxs diff --git a/docs/using-the-sdk/cosmovisor.md b/docs/using-the-sdk/cosmovisor.md index 870bbae236b2..56ee5f7fa7bb 100644 --- a/docs/using-the-sdk/cosmovisor.md +++ b/docs/using-the-sdk/cosmovisor.md @@ -103,7 +103,7 @@ rm -rf $HOME/.simapp ./build/simd keys --keyring-backend=test add validator ./build/simd init testing --chain-id test ./build/simd add-genesis-account --keyring-backend=test $(./build/simd keys --keyring-backend=test show validator -a) 1000000000stake,1000000000validatortoken -./build/simd gentx --keyring-backend test --chain-id test validator +./build/simd gentx --keyring-backend test --chain-id test validator 100000stake ./build/simd collect-gentxs ```