From 43447a28be3d50188e5691d7b5439db192735309 Mon Sep 17 00:00:00 2001 From: Daniel Wedul Date: Tue, 14 May 2024 17:01:58 -0600 Subject: [PATCH] [1760]: Remove the genesis- part out of all the genesis commands since its now redundant. --- CHANGELOG.md | 17 +++++++-- cmd/provenanced/cmd/genaccounts.go | 43 +++++++++++++---------- networks/dev/blockchain-dev/entrypoint.sh | 14 ++++---- scripts/initialize.sh | 24 ++++++------- 4 files changed, 57 insertions(+), 41 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cc4fde7ef..909a47cca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -82,9 +82,20 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Client Breaking * The `provenanced query account` command has been removed. It is still available as `provenanced query auth account` TODO: Add link. -* The genesis-related commands have been moved to the `provenanced genesis` sub-command (from the root `provenanced` command) TODO: Add link. - * Moved sub-commands: `add-genesis-custom-floor` `add-genesis-custom-market` `add-genesis-default-market` `add-genesis-marker` `add-genesis-msg-fee` `add-genesis-root-name` `collect-gentxs` `gentx` - * The `provenanced validate-genesis` command is now `provenanced genesis validate`. +* The genesis-related commands have been moved to the `provenanced genesis` sub-command TODO: Add link. + * | Old invocation | New invocation | + |------------------------------------------|------------------------------------------| + | `provenanced add-genesis-account` | `provenanced genesis add-account` | + | `provenanced add-genesis-custom-floor` | `provenanced genesis add-custom-floor` | + | `provenanced add-genesis-custom-market` | `provenanced genesis add-custom-market` | + | `provenanced add-genesis-default-market` | `provenanced genesis add-default-market` | + | `provenanced add-genesis-marker` | `provenanced genesis add-marker` | + | `provenanced add-genesis-msg-fee` | `provenanced genesis add-msg-fee` | + | `provenanced add-genesis-root-name` | `provenanced genesis add-root-name` | + | `provenanced collect-gentxs` | `provenanced genesis collect-gentxs` | + | `provenanced gentx` | `provenanced genesis gentx` | + | `provenanced validate-genesis` | `provenanced genesis validate` | +* Many of the SDK's query commands have had their usage altered TODO: Add link. ### Dependencies diff --git a/cmd/provenanced/cmd/genaccounts.go b/cmd/provenanced/cmd/genaccounts.go index 0a3ca7fbb..ef0e249c4 100644 --- a/cmd/provenanced/cmd/genaccounts.go +++ b/cmd/provenanced/cmd/genaccounts.go @@ -60,12 +60,17 @@ func GenesisCmd(txConfig client.TxConfig, moduleBasics module.BasicManager, defa gentxModule := moduleBasics[genutiltypes.ModuleName].(genutil.AppModuleBasic) + // Change the "add-genesis-account" command to just "add-account" since it's under the genesis command already. + addGenesisAcctCmd := genutilcli.AddGenesisAccountCmd(defaultNodeHome, txConfig.SigningContext().AddressCodec()) + if strings.HasPrefix(addGenesisAcctCmd.Use, "add-genesis-account") { + addGenesisAcctCmd.Use = "add-account" + strings.TrimPrefix(addGenesisAcctCmd.Use, "add-genesis-account") + } + cmd.AddCommand( genutilcli.GenTxCmd(moduleBasics, txConfig, banktypes.GenesisBalancesIterator{}, defaultNodeHome, txConfig.SigningContext().ValidatorAddressCodec()), - // migrate genesis? genutilcli.CollectGenTxsCmd(banktypes.GenesisBalancesIterator{}, defaultNodeHome, gentxModule.GenTxValidator, txConfig.SigningContext().ValidatorAddressCodec()), genutilcli.ValidateGenesisCmd(moduleBasics), - genutilcli.AddGenesisAccountCmd(defaultNodeHome, txConfig.SigningContext().AddressCodec()), + addGenesisAcctCmd, AddRootDomainAccountCmd(defaultNodeHome), AddGenesisMarkerCmd(defaultNodeHome), AddGenesisMsgFeeCmd(defaultNodeHome), @@ -122,17 +127,17 @@ func updateGenesisFileRunE(updater appStateUpdater) func(*cobra.Command, []strin } } -// AddRootDomainAccountCmd returns add-genesis-root-name cobra command. +// AddRootDomainAccountCmd returns add-root-name cobra command. func AddRootDomainAccountCmd(defaultNodeHome string) *cobra.Command { cmd := &cobra.Command{ - Use: "add-genesis-root-name [address_or_key_name] [root-name]", + Use: "add-root-name [address_or_key_name] [root-name]", Short: "Add a name binding to genesis.json", Long: `Add a name binding to genesis.json. The provided account must specify the account address or key name and domain-name to bind. If a key name is given, the address will be looked up in the local Keybase. The restricted flag can optionally be included to lock or unlock an entry to child names. `, - Example: fmt.Sprintf(`$ %[1]s add-genesis-root-name mykey rootname`, genCmdStart), + Example: fmt.Sprintf(`$ %[1]s add-root-name mykey rootname`, genCmdStart), Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) error { clientCtx := client.GetClientContextFromCmd(cmd) @@ -213,10 +218,10 @@ func AddRootDomainAccountCmd(defaultNodeHome string) *cobra.Command { return cmd } -// AddGenesisMarkerCmd configures a marker account and adds it to the list of genesis accounts +// AddGenesisMarkerCmd returns add-marker cobra command. func AddGenesisMarkerCmd(defaultNodeHome string) *cobra.Command { cmd := &cobra.Command{ - Use: "add-genesis-marker [coin] --manager [address_or_key_name] --access [grant][,[grant]] --escrow [coin][, [coin]] --finalize --activate --type [COIN] --required-attributes=attr.one,*.attr.two,...", + Use: "add-marker [coin] --manager [address_or_key_name] --access [grant][,[grant]] --escrow [coin][, [coin]] --finalize --activate --type [COIN] --required-attributes=attr.one,*.attr.two,...", Short: "Adds a marker to genesis.json", Long: `Adds a marker to genesis.json. The provided parameters must specify the marker supply and denom as a coin. A managing account may be added as a key name or address. An accessgrant @@ -225,7 +230,7 @@ a marker account is activated any unassigned marker supply must be provided as e a manager address assigned that can activate the marker after genesis. Activated markers will have supply invariants enforced immediately. An optional type flag can be provided or the default of COIN will be used. `, - Example: fmt.Sprintf(`$ %[1]s add-genesis-marker 1000000000funcoins --manager validator --access withdraw --escrow 100funcoins --finalize --type COIN --required-attributes=attr.one,*.attr.two,...`, genCmdStart), + Example: fmt.Sprintf(`$ %[1]s add-marker 1000000000funcoins --manager validator --access withdraw --escrow 100funcoins --finalize --type COIN --required-attributes=attr.one,*.attr.two,...`, genCmdStart), Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { clientCtx := client.GetClientContextFromCmd(cmd) @@ -414,15 +419,15 @@ enforced immediately. An optional type flag can be provided or the default of C return cmd } -// AddGenesisCustomFloorPriceDenomCmd returns add-genesis-msg-fee cobra command. +// AddGenesisCustomFloorPriceDenomCmd returns add-msg-fee cobra command. func AddGenesisCustomFloorPriceDenomCmd(defaultNodeHome string) *cobra.Command { cmd := &cobra.Command{ - Use: "add-genesis-custom-floor [coin]", + Use: "add-custom-floor [coin]", Short: "Add a floor price denom and amount to genesis.json", Long: `Add a floor price denom and amount to genesis.json. This will create a custom floor price denom and amount for calculating additional message costs. Currently, the denom and price defaults to 1905nhash `, - Example: fmt.Sprintf(`$ %[1]s add-genesis-custom-floor 0vspn`, genCmdStart), + Example: fmt.Sprintf(`$ %[1]s add-custom-floor 0vspn`, genCmdStart), Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { clientCtx := client.GetClientContextFromCmd(cmd) @@ -465,15 +470,15 @@ Currently, the denom and price defaults to 1905nhash return cmd } -// AddGenesisMsgFeeCmd returns add-genesis-msg-fee cobra command. +// AddGenesisMsgFeeCmd returns add-msg-fee cobra command. func AddGenesisMsgFeeCmd(defaultNodeHome string) *cobra.Command { cmd := &cobra.Command{ - Use: "add-genesis-msg-fee [msg-url] [additional-fee]", + Use: "add-msg-fee [msg-url] [additional-fee]", Short: "Add a msg fee to genesis.json", Long: `Add a msg fee to to genesis.json. This will create a msg based fee for an sdk msg type. The command will validate that the msg-url is a valid sdk.msg and that the fee is a valid amount and coin. `, - Example: fmt.Sprintf(`$ %[1]s add-genesis-msg-fee /cosmos.bank.v1beta1.MsgSend 10000000000nhash`, genCmdStart), + Example: fmt.Sprintf(`$ %[1]s add-msg-fee /cosmos.bank.v1beta1.MsgSend 10000000000nhash`, genCmdStart), Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) error { clientCtx := client.GetClientContextFromCmd(cmd) @@ -553,10 +558,10 @@ func checkMsgTypeValid(registry types.InterfaceRegistry, msgTypeURL string) erro return err } -// AddGenesisDefaultMarketCmd returns add-genesis-default-market cobra command. +// AddGenesisDefaultMarketCmd returns add-default-market cobra command. func AddGenesisDefaultMarketCmd(defaultNodeHome string) *cobra.Command { cmd := &cobra.Command{ - Use: `add-genesis-default-market [--denom ] + Use: `add-default-market [--denom ] All base accounts already in the genesis file will be given all permissions on this market. An error is returned if no such accounts are in the existing genesis file. @@ -565,7 +570,7 @@ If --denom is not provided, the staking bond denom is used. If no staking bond denom is defined either, then nhash is used. This command is equivalent to the following command: -$ ` + genCmdStart + ` add-genesis-custom-market \ +$ ` + genCmdStart + ` add-custom-market \ --name 'Default Market' \ --create-ask 100 --create-bid 100 \ --seller-flat 500 --buyer-flat 500 \ @@ -667,10 +672,10 @@ func makeDefaultMarket(feeDenom string, addrs []string) exchange.Market { return market } -// AddGenesisCustomMarketCmd returns add-genesis-custom-market cobra command. +// AddGenesisCustomMarketCmd returns add-custom-market cobra command. func AddGenesisCustomMarketCmd(defaultNodeHome string) *cobra.Command { cmd := &cobra.Command{ - Use: "add-genesis-custom-market", + Use: "add-custom-market", Short: "Add a market to the genesis file", RunE: updateGenesisFileRunE(func(clientCtx client.Context, cmd *cobra.Command, args []string, appState map[string]json.RawMessage) error { msg, err := exchangecli.MakeMsgGovCreateMarket(clientCtx, cmd.Flags(), args) diff --git a/networks/dev/blockchain-dev/entrypoint.sh b/networks/dev/blockchain-dev/entrypoint.sh index 96ea4bfcb..160ecf91c 100755 --- a/networks/dev/blockchain-dev/entrypoint.sh +++ b/networks/dev/blockchain-dev/entrypoint.sh @@ -18,16 +18,16 @@ if ! [ -f ${PIO_HOME}/config/genesis.json ]; then key_name=$(basename $f .txt) echo "Adding account $key_name from mnemonic file $f with 100000000000000000000nhash" "${BINARY}" -t --home "${PIO_HOME}" keys add $key_name --recover --keyring-backend test < "$f" - "${BINARY}" -t --home "${PIO_HOME}" genesis add-genesis-account $key_name 100000000000000000000nhash --keyring-backend test + "${BINARY}" -t --home "${PIO_HOME}" genesis add-account $key_name 100000000000000000000nhash --keyring-backend test let num_accounts=num_accounts+1 done - "${BINARY}" -t --home "${PIO_HOME}" genesis add-genesis-root-name validator pio --keyring-backend test - "${BINARY}" -t --home "${PIO_HOME}" genesis add-genesis-root-name validator pb --restrict=false --keyring-backend test - "${BINARY}" -t --home "${PIO_HOME}" genesis add-genesis-root-name validator io --restrict --keyring-backend test - "${BINARY}" -t --home "${PIO_HOME}" genesis add-genesis-root-name validator provenance --keyring-backend test - "${BINARY}" -t --home "${PIO_HOME}" genesis add-genesis-marker ${num_accounts}00000000000000000000nhash --manager validator --access mint,burn,admin,withdraw,deposit --activate --keyring-backend test + "${BINARY}" -t --home "${PIO_HOME}" genesis add-root-name validator pio --keyring-backend test + "${BINARY}" -t --home "${PIO_HOME}" genesis add-root-name validator pb --restrict=false --keyring-backend test + "${BINARY}" -t --home "${PIO_HOME}" genesis add-root-name validator io --restrict --keyring-backend test + "${BINARY}" -t --home "${PIO_HOME}" genesis add-root-name validator provenance --keyring-backend test + "${BINARY}" -t --home "${PIO_HOME}" genesis add-marker ${num_accounts}00000000000000000000nhash --manager validator --access mint,burn,admin,withdraw,deposit --activate --keyring-backend test "${BINARY}" -t --home "${PIO_HOME}" genesis gentx validator 100000000000000nhash --keyring-backend test --chain-id=chain-dev - "${BINARY}" -t --home "${PIO_HOME}" genesis add-genesis-default-market + "${BINARY}" -t --home "${PIO_HOME}" genesis add-default-market "${BINARY}" -t --home "${PIO_HOME}" genesis collect-gentxs "${BINARY}" -t --home "${PIO_HOME}" config set rpc.laddr tcp://0.0.0.0:26657 "${BINARY}" -t --home "${PIO_HOME}" config set api.enable true diff --git a/scripts/initialize.sh b/scripts/initialize.sh index 7b4026f06..3bdef7b62 100755 --- a/scripts/initialize.sh +++ b/scripts/initialize.sh @@ -79,23 +79,23 @@ fi set -ex $PROV_CMD init testing --custom-denom "$DENOM" $arg_timeout_commit $arg_chain_id $PROV_CMD keys add validator $arg_keyring -$PROV_CMD genesis add-genesis-root-name validator pio $arg_keyring -$PROV_CMD genesis add-genesis-root-name validator pb --restrict=false $arg_keyring -$PROV_CMD genesis add-genesis-root-name validator io --restrict $arg_keyring -$PROV_CMD genesis add-genesis-root-name validator provenance $arg_keyring -$PROV_CMD genesis add-genesis-account validator "100000000000000000000$DENOM" $arg_keyring +$PROV_CMD genesis add-root-name validator pio $arg_keyring +$PROV_CMD genesis add-root-name validator pb --restrict=false $arg_keyring +$PROV_CMD genesis add-root-name validator io --restrict $arg_keyring +$PROV_CMD genesis add-root-name validator provenance $arg_keyring +$PROV_CMD genesis add-account validator "100000000000000000000$DENOM" $arg_keyring $PROV_CMD genesis gentx validator "1000000000000000$DENOM" $arg_chain_id $arg_keyring -$PROV_CMD genesis add-genesis-marker "100000000000000000000$DENOM" \ +$PROV_CMD genesis add-marker "100000000000000000000$DENOM" \ --manager validator \ --access mint,burn,admin,withdraw,deposit \ $arg_keyring \ --activate -$PROV_CMD genesis add-genesis-msg-fee /provenance.name.v1.MsgBindNameRequest "10000000000$DENOM" -$PROV_CMD genesis add-genesis-msg-fee /provenance.marker.v1.MsgAddMarkerRequest "100000000000$DENOM" -$PROV_CMD genesis add-genesis-msg-fee /provenance.attribute.v1.MsgAddAttributeRequest "10000000000$DENOM" -$PROV_CMD genesis add-genesis-msg-fee /provenance.metadata.v1.MsgWriteScopeRequest "10000000000$DENOM" -$PROV_CMD genesis add-genesis-custom-floor "${MIN_FLOOR_PRICE}${DENOM}" -$PROV_CMD genesis add-genesis-default-market --denom "$DENOM" +$PROV_CMD genesis add-msg-fee /provenance.name.v1.MsgBindNameRequest "10000000000$DENOM" +$PROV_CMD genesis add-msg-fee /provenance.marker.v1.MsgAddMarkerRequest "100000000000$DENOM" +$PROV_CMD genesis add-msg-fee /provenance.attribute.v1.MsgAddAttributeRequest "10000000000$DENOM" +$PROV_CMD genesis add-msg-fee /provenance.metadata.v1.MsgWriteScopeRequest "10000000000$DENOM" +$PROV_CMD genesis add-custom-floor "${MIN_FLOOR_PRICE}${DENOM}" +$PROV_CMD genesis add-default-market --denom "$DENOM" $PROV_CMD genesis collect-gentxs $PROV_CMD config set minimum-gas-prices "${MIN_FLOOR_PRICE}${DENOM}" set +ex