From e866ebb759cfd66362c1148c22f08d2be4710c8d Mon Sep 17 00:00:00 2001 From: Richard Gibson Date: Fri, 19 Jan 2024 10:37:53 -0500 Subject: [PATCH] chore(simapp): Deprecate --v in favor of --validator-count, -n --- CHANGELOG.md | 4 ++++ simapp/simd/cmd/testnet.go | 30 ++++++++++++++++++++++++------ 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 661d890e2091..be6a3e0cf6b5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -78,6 +78,10 @@ Every Module contains its own CHANGELOG.md. Please refer to the module you are i * (testutil) [#18930](https://github.com/cosmos/cosmos-sdk/pull/18930) Add NodeURI for clientCtx. * (types) [#18963](https://github.com/cosmos/cosmos-sdk/pull/18963) Swap out amino json encoding of `ABCIMessageLogs` for std lib json encoding +### Deprecated + +* (simapp) [#19146](https://github.com/cosmos/cosmos-sdk/pull/19146) Deprecate `--v` CLI option in favor of `--validator-count`/`-n`. + ### Bug Fixes * (baseapp) [#19058](https://github.com/cosmos/cosmos-sdk/pull/19058) Fix baseapp posthandler branch would fail if the `runMsgs` had returned an error. diff --git a/simapp/simd/cmd/testnet.go b/simapp/simd/cmd/testnet.go index 4ae56e28c4fb..58d8c2958392 100644 --- a/simapp/simd/cmd/testnet.go +++ b/simapp/simd/cmd/testnet.go @@ -39,7 +39,7 @@ import ( var ( flagNodeDirPrefix = "node-dir-prefix" - flagNumValidators = "v" + flagNumValidators = "validator-count" flagOutputDir = "output-dir" flagNodeDaemonHome = "node-daemon-home" flagStartingIPAddress = "starting-ip-address" @@ -78,7 +78,11 @@ type startArgs struct { } func addTestnetFlagsToCmd(cmd *cobra.Command) { - cmd.Flags().Int(flagNumValidators, 4, "Number of validators to initialize the testnet with") + cmd.Flags().IntP(flagNumValidators, "n", 4, "Number of validators to initialize the testnet with") + cmd.Flags().Int("v", 4, fmt.Sprintf("Alias for --%s", flagNumValidators)) + if vFlag := cmd.Flags().Lookup("v"); vFlag != nil { + vFlag.Deprecated = fmt.Sprintf("use --%s", flagNumValidators) + } cmd.Flags().StringP(flagOutputDir, "o", "./.testnets", "Directory to store initialization data for the testnet") 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)") @@ -116,7 +120,7 @@ func testnetInitFilesCmd(mbm module.BasicManager, genBalIterator banktypes.Genes cmd := &cobra.Command{ Use: "init-files", Short: "Initialize config directories & files for a multi-validator testnet running locally via separate processes (e.g. Docker Compose or similar)", - Long: `init-files will setup "v" number of directories and populate each with + Long: `init-files will setup one directory per validator and populate each with necessary files (private validator, genesis, config, etc.) for running "v" validator nodes. Booting up a network with these validator folders is intended to be used with Docker Compose, @@ -125,7 +129,7 @@ or a similar setup where each node has a manually configurable IP address. Note, strict routability for addresses is turned off in the config file. Example: - simd testnet init-files --v 4 --output-dir ./.testnets --starting-ip-address 192.168.10.2 + simd testnet init-files -n 4 --output-dir ./.testnets --starting-ip-address 192.168.10.2 `, RunE: func(cmd *cobra.Command, _ []string) error { clientCtx, err := client.GetClientQueryContext(cmd) @@ -148,12 +152,19 @@ Example: args.numValidators, _ = cmd.Flags().GetInt(flagNumValidators) args.algo, _ = cmd.Flags().GetString(flags.FlagKeyType) + if cmd.Flags().Changed("v") { + if cmd.Flags().Changed(flagNumValidators) { + return fmt.Errorf("--%s and --v are mutually exclusive", flagNumValidators) + } + args.numValidators, _ = cmd.Flags().GetInt("v") + } + return initTestnetFiles(clientCtx, cmd, config, mbm, genBalIterator, clientCtx.TxConfig.SigningContext().ValidatorAddressCodec(), args) }, } addTestnetFlagsToCmd(cmd) - cmd.Flags().String(flagNodeDirPrefix, "node", "Prefix the directory name for each node with (node results in node0, node1, ...)") + cmd.Flags().String(flagNodeDirPrefix, "node", "Prefix for the name of per-validator subdirectories (to be number-suffixed like 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 ID0@192.168.0.1:46656, ID1@192.168.0.2:46656, ...)") cmd.Flags().String(flagListenIPAddress, "127.0.0.1", "TCP or UNIX socket IP address for the RPC server to listen on") @@ -172,7 +183,7 @@ and generate "v" directories, populated with necessary validator configuration f (private validator, genesis, config, etc.). Example: - simd testnet --v 4 --output-dir ./.testnets + simd testnet -n 4 --output-dir ./.testnets `, RunE: func(cmd *cobra.Command, _ []string) error { args := startArgs{} @@ -187,6 +198,13 @@ Example: args.grpcAddress, _ = cmd.Flags().GetString(flagGRPCAddress) args.printMnemonic, _ = cmd.Flags().GetBool(flagPrintMnemonic) + if cmd.Flags().Changed("v") { + if cmd.Flags().Changed(flagNumValidators) { + return fmt.Errorf("--%s and --v are mutually exclusive", flagNumValidators) + } + args.numValidators, _ = cmd.Flags().GetInt("v") + } + return startTestnet(cmd, args) }, }