feat!: use gov v1 proposals in upgrade cli (#14880)
This commit is contained in:
parent
f926631d04
commit
5ec3d2b875
@ -250,6 +250,7 @@ extension interfaces. `module.Manager.Modules` is now of type `map[string]interf
|
||||
|
||||
### CLI Breaking Changes
|
||||
|
||||
* (x/gov) [#14880](https://github.com/cosmos/cosmos-sdk/pull/14880) Remove `simd tx gov submit-legacy-proposal cancel-software-upgrade` and `software-upgrade` commands. These commands are now in the `x/upgrade` module and using gov v1. Use `tx upgrade software-upgrade` instead.
|
||||
* (grpc-web) [#14652](https://github.com/cosmos/cosmos-sdk/pull/14652) Remove `grpc-web.address` flag.
|
||||
* (client) [#14342](https://github.com/cosmos/cosmos-sdk/pull/14342) `simd config` command is now a sub-command. Use `simd config --help` to learn more.
|
||||
* (x/genutil) [#13535](https://github.com/cosmos/cosmos-sdk/pull/13535) Replace in `simd init`, the `--staking-bond-denom` flag with `--default-denom` which is used for all default denomination in the genesis, instead of only staking.
|
||||
|
||||
@ -26,7 +26,6 @@ import (
|
||||
nftmodule "cosmossdk.io/x/nft/module"
|
||||
|
||||
"cosmossdk.io/x/upgrade"
|
||||
upgradeclient "cosmossdk.io/x/upgrade/client"
|
||||
upgradekeeper "cosmossdk.io/x/upgrade/keeper"
|
||||
upgradetypes "cosmossdk.io/x/upgrade/types"
|
||||
|
||||
@ -127,8 +126,6 @@ var (
|
||||
gov.NewAppModuleBasic(
|
||||
[]govclient.ProposalHandler{
|
||||
paramsclient.ProposalHandler,
|
||||
upgradeclient.LegacyProposalHandler,
|
||||
upgradeclient.LegacyCancelProposalHandler,
|
||||
},
|
||||
),
|
||||
params.AppModuleBasic{},
|
||||
|
||||
@ -22,7 +22,6 @@ import (
|
||||
feegrantkeeper "cosmossdk.io/x/feegrant/keeper"
|
||||
feegrantmodule "cosmossdk.io/x/feegrant/module"
|
||||
"cosmossdk.io/x/upgrade"
|
||||
upgradeclient "cosmossdk.io/x/upgrade/client"
|
||||
upgradekeeper "cosmossdk.io/x/upgrade/keeper"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/baseapp"
|
||||
@ -91,8 +90,6 @@ var (
|
||||
gov.NewAppModuleBasic(
|
||||
[]govclient.ProposalHandler{
|
||||
paramsclient.ProposalHandler,
|
||||
upgradeclient.LegacyProposalHandler,
|
||||
upgradeclient.LegacyCancelProposalHandler,
|
||||
},
|
||||
),
|
||||
params.AppModuleBasic{},
|
||||
|
||||
@ -210,12 +210,12 @@ If `DAEMON_ALLOW_DOWNLOAD_BINARIES` is set to `true`, and no local binary can be
|
||||
When submitting this as a proposal ensure there are no spaces. An example command using `gaiad` could look like:
|
||||
|
||||
```shell
|
||||
> gaiad tx gov submit-proposal software-upgrade Vega \
|
||||
> gaiad tx upgrade software-upgrade Vega \
|
||||
--title Vega \
|
||||
--deposit 100uatom \
|
||||
--upgrade-height 7368420 \
|
||||
--upgrade-info '{"binaries":{"linux/amd64":"https://github.com/cosmos/gaia/releases/download/v6.0.0-rc1/gaiad-v6.0.0-rc1-linux-amd64","linux/arm64":"https://github.com/cosmos/gaia/releases/download/v6.0.0-rc1/gaiad-v6.0.0-rc1-linux-arm64","darwin/amd64":"https://github.com/cosmos/gaia/releases/download/v6.0.0-rc1/gaiad-v6.0.0-rc1-darwin-amd64"}}' \
|
||||
--description "upgrade to Vega" \
|
||||
--summary "upgrade to Vega" \
|
||||
--gas 400000 \
|
||||
--from user \
|
||||
--chain-id test \
|
||||
@ -293,9 +293,6 @@ cat <<< $(jq '.app_state.gov.voting_params.voting_period = "20s"' $HOME/.simapp/
|
||||
|
||||
Create a validator, and setup genesis transaction:
|
||||
|
||||
<!-- TODO: add-genesis-account does not read keyring-backend from config -->
|
||||
<!-- TODO: gentx does not read chain-id from config -->
|
||||
|
||||
```shell
|
||||
./build/simd keys add validator
|
||||
./build/simd genesis add-genesis-account validator 1000000000stake --keyring-backend test
|
||||
@ -351,7 +348,8 @@ cp ./build/simd $DAEMON_HOME/cosmovisor/upgrades/test1/bin
|
||||
```
|
||||
|
||||
Open a new terminal window and submit an upgrade proposal along with a deposit and a vote (these commands must be run within 20 seconds of each other):
|
||||
Note, when using a `v0.46+` chain, replace `submit-proposal` by `submit-legacy-proposal`.
|
||||
|
||||
**<= v0.45**:
|
||||
|
||||
```shell
|
||||
./build/simd tx gov submit-proposal software-upgrade test1 --title upgrade --description upgrade --upgrade-height 200 --from validator --yes
|
||||
@ -359,4 +357,20 @@ Note, when using a `v0.46+` chain, replace `submit-proposal` by `submit-legacy-p
|
||||
./build/simd tx gov vote 1 yes --from validator --yes
|
||||
```
|
||||
|
||||
**v0.46, v0.47**:
|
||||
|
||||
```shell
|
||||
./build/simd tx gov submit-legacy-proposal software-upgrade test1 --title upgrade --description upgrade --upgrade-height 200 --from validator --yes
|
||||
./build/simd tx gov deposit 1 10000000stake --from validator --yes
|
||||
./build/simd tx gov vote 1 yes --from validator --yes
|
||||
```
|
||||
|
||||
**>= v0.48+**:
|
||||
|
||||
```shell
|
||||
./build/simd tx upgrade software-upgrade test1 --title upgrade --summary upgrade --upgrade-height 200 --from validator --yes
|
||||
./build/simd tx gov deposit 1 10000000stake --from validator --yes
|
||||
./build/simd tx gov vote 1 yes --from validator --yes
|
||||
```
|
||||
|
||||
The upgrade will occur automatically at height 200. Note: you may need to change the upgrade height in the snippet above if your test play takes more time.
|
||||
|
||||
@ -32,36 +32,35 @@ The following specification uses *ATOM* as the native staking token. The module
|
||||
can be adapted to any Proof-Of-Stake blockchain by replacing *ATOM* with the native
|
||||
staking token of the chain.
|
||||
|
||||
|
||||
* [Concepts](#concepts)
|
||||
* [Proposal submission](#proposal-submission)
|
||||
* [Deposit](#deposit)
|
||||
* [Vote](#vote)
|
||||
* [Software Upgrade](#software-upgrade)
|
||||
* [Proposal submission](#proposal-submission)
|
||||
* [Deposit](#deposit)
|
||||
* [Vote](#vote)
|
||||
* [Software Upgrade](#software-upgrade)
|
||||
* [State](#state)
|
||||
* [Proposals](#proposals)
|
||||
* [Parameters and base types](#parameters-and-base-types)
|
||||
* [Deposit](#deposit-1)
|
||||
* [ValidatorGovInfo](#validatorgovinfo)
|
||||
* [Stores](#stores)
|
||||
* [Proposal Processing Queue](#proposal-processing-queue)
|
||||
* [Legacy Proposal](#legacy-proposal)
|
||||
* [Proposals](#proposals)
|
||||
* [Parameters and base types](#parameters-and-base-types)
|
||||
* [Deposit](#deposit-1)
|
||||
* [ValidatorGovInfo](#validatorgovinfo)
|
||||
* [Stores](#stores)
|
||||
* [Proposal Processing Queue](#proposal-processing-queue)
|
||||
* [Legacy Proposal](#legacy-proposal)
|
||||
* [Messages](#messages)
|
||||
* [Proposal Submission](#proposal-submission-1)
|
||||
* [Deposit](#deposit-2)
|
||||
* [Vote](#vote-1)
|
||||
* [Proposal Submission](#proposal-submission-1)
|
||||
* [Deposit](#deposit-2)
|
||||
* [Vote](#vote-1)
|
||||
* [Events](#events)
|
||||
* [EndBlocker](#endblocker)
|
||||
* [Handlers](#handlers)
|
||||
* [EndBlocker](#endblocker)
|
||||
* [Handlers](#handlers)
|
||||
* [Parameters](#parameters)
|
||||
* [SubKeys](#subkeys)
|
||||
* [SubKeys](#subkeys)
|
||||
* [Client](#client)
|
||||
* [CLI](#cli)
|
||||
* [gRPC](#grpc)
|
||||
* [REST](#rest)
|
||||
* [CLI](#cli)
|
||||
* [gRPC](#grpc)
|
||||
* [REST](#rest)
|
||||
* [Metadata](#metadata)
|
||||
* [Proposal](#proposal-3)
|
||||
* [Vote](#vote-5)
|
||||
* [Proposal](#proposal-3)
|
||||
* [Vote](#vote-5)
|
||||
* [Future Improvements](#future-improvements)
|
||||
|
||||
## Concepts
|
||||
@ -392,7 +391,7 @@ We will use one KVStore `Governance` to store four mappings:
|
||||
* A mapping from `proposalID|'addresses'|address` to `Vote`. This mapping allows
|
||||
us to query all addresses that voted on the proposal along with their vote by
|
||||
doing a range query on `proposalID:addresses`.
|
||||
* A mapping from `ParamsKey|'Params'` to `Params`. This map allows to query all
|
||||
* A mapping from `ParamsKey|'Params'` to `Params`. This map allows to query all
|
||||
x/gov params.
|
||||
* A mapping from `VotingPeriodProposalKeyPrefix|proposalID` to a single byte. This allows
|
||||
us to know if a proposal is in the voting period or not with very low gas cost.
|
||||
@ -507,7 +506,7 @@ must not be larger than the `maxMetadataLen` config passed into the gov keeper.
|
||||
* Initialise `Proposal`'s attributes
|
||||
* Decrease balance of sender by `InitialDeposit`
|
||||
* If `MinDeposit` is reached:
|
||||
* Push `proposalID` in `ProposalProcessingQueue`
|
||||
* Push `proposalID` in `ProposalProcessingQueue`
|
||||
* Transfer `InitialDeposit` from the `Proposer` to the governance `ModuleAccount`
|
||||
|
||||
A `MsgSubmitProposal` transaction can be handled according to the following
|
||||
@ -572,7 +571,7 @@ https://github.com/cosmos/cosmos-sdk/blob/v0.47.0-rc1/proto/cosmos/gov/v1/tx.pro
|
||||
* Add `deposit` of sender in `proposal.Deposits`
|
||||
* Increase `proposal.TotalDeposit` by sender's `deposit`
|
||||
* If `MinDeposit` is reached:
|
||||
* Push `proposalID` in `ProposalProcessingQueueEnd`
|
||||
* Push `proposalID` in `ProposalProcessingQueueEnd`
|
||||
* Transfer `Deposit` from the `proposer` to the governance `ModuleAccount`
|
||||
|
||||
A `MsgDeposit` transaction has to go through a number of checks to be valid.
|
||||
@ -1175,28 +1174,6 @@ Example:
|
||||
simd tx gov submit-legacy-proposal --title="Test Proposal" --description="testing" --type="Text" --deposit="100000000stake" --from cosmos1..
|
||||
```
|
||||
|
||||
Example (`cancel-software-upgrade`):
|
||||
|
||||
```bash
|
||||
simd tx gov submit-legacy-proposal cancel-software-upgrade --title="Test Proposal" --description="testing" --deposit="100000000stake" --from cosmos1..
|
||||
```
|
||||
|
||||
Example (`community-pool-spend`):
|
||||
|
||||
```bash
|
||||
simd tx gov submit-legacy-proposal community-pool-spend proposal.json --from cosmos1..
|
||||
```
|
||||
|
||||
```json
|
||||
{
|
||||
"title": "Test Proposal",
|
||||
"description": "testing, 1, 2, 3",
|
||||
"recipient": "cosmos1..",
|
||||
"amount": "10000000stake",
|
||||
"deposit": "10000000stake"
|
||||
}
|
||||
```
|
||||
|
||||
Example (`param-change`):
|
||||
|
||||
```bash
|
||||
@ -1218,12 +1195,6 @@ simd tx gov submit-legacy-proposal param-change proposal.json --from cosmos1..
|
||||
}
|
||||
```
|
||||
|
||||
Example (`software-upgrade`):
|
||||
|
||||
```bash
|
||||
simd tx gov submit-legacy-proposal software-upgrade v2 --title="Test Proposal" --description="testing, testing, 1, 2, 3" --upgrade-height 1000000 --from cosmos1..
|
||||
```
|
||||
|
||||
#### cancel-proposal
|
||||
|
||||
Once proposal is canceled, from the deposits of proposal `deposits * proposal_cancel_ratio` will be burned or sent to `ProposalCancelDest` address , if `ProposalCancelDest` is empty then deposits will be burned. The `remaining deposits` will be sent to depositers.
|
||||
@ -1233,6 +1204,7 @@ simd tx gov cancel-proposal [proposal-id] [flags]
|
||||
```
|
||||
|
||||
Example:
|
||||
|
||||
```bash
|
||||
simd tx gov cancel-proposal 1 --from cosmos1...
|
||||
```
|
||||
@ -1366,7 +1338,6 @@ Example Output:
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
#### Proposals
|
||||
|
||||
The `Proposals` endpoint allows users to query all proposals with optional filters.
|
||||
@ -2603,7 +2574,6 @@ Example Output:
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## Metadata
|
||||
|
||||
The gov module has two locations for metadata where users can provide further context about the on-chain actions they are taking. By default all metadata fields have a 255 character length field where metadata can be stored in json format, either on-chain or off-chain depending on the amount of data required. Here we provide a recommendation for the json structure and where the data should be stored. There are two important factors in making these recommendations. First, that the gov and group modules are consistent with one another, note the number of proposals made by all groups may be quite large. Second, that client applications such as block explorers and governance interfaces have confidence in the consistency of metadata structure accross chains.
|
||||
|
||||
@ -20,19 +20,19 @@ import (
|
||||
|
||||
// Proposal flags
|
||||
const (
|
||||
FlagTitle = "title"
|
||||
FlagTitle = "title"
|
||||
FlagDeposit = "deposit"
|
||||
flagVoter = "voter"
|
||||
flagDepositor = "depositor"
|
||||
flagStatus = "status"
|
||||
FlagMetadata = "metadata"
|
||||
FlagSummary = "summary"
|
||||
// Deprecated: only used for v1beta1 legacy proposals.
|
||||
FlagProposal = "proposal"
|
||||
// Deprecated: only used for v1beta1 legacy proposals.
|
||||
FlagDescription = "description"
|
||||
// Deprecated: only used for v1beta1 legacy proposals.
|
||||
FlagProposalType = "type"
|
||||
FlagDeposit = "deposit"
|
||||
flagVoter = "voter"
|
||||
flagDepositor = "depositor"
|
||||
flagStatus = "status"
|
||||
FlagMetadata = "metadata"
|
||||
FlagSummary = "summary"
|
||||
// Deprecated: only used for v1beta1 legacy proposals.
|
||||
FlagProposal = "proposal"
|
||||
)
|
||||
|
||||
// ProposalFlags defines the core required fields of a legacy proposal. It is used to
|
||||
|
||||
@ -48,6 +48,18 @@ func (m *MsgSubmitProposal) GetMsgs() ([]sdk.Msg, error) {
|
||||
return sdktx.GetMsgs(m.Messages, "sdk.MsgProposal")
|
||||
}
|
||||
|
||||
// SetMsgs packs sdk.Msg's into m.Messages Any's
|
||||
// NOTE: this will overwrite any existing messages
|
||||
func (m *MsgSubmitProposal) SetMsgs(msgs []sdk.Msg) error {
|
||||
anys, err := sdktx.SetMsgs(msgs)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
m.Messages = anys
|
||||
return nil
|
||||
}
|
||||
|
||||
// ValidateBasic implements the sdk.Msg interface.
|
||||
func (m MsgSubmitProposal) ValidateBasic() error {
|
||||
if m.Title == "" {
|
||||
|
||||
@ -27,4 +27,5 @@ Ref: https://keepachangelog.com/en/1.0.0/
|
||||
|
||||
### Features
|
||||
|
||||
* (x/upgrade) [14764](https://github.com/cosmos/cosmos-sdk/pull/14764) The `x/upgrade` module is extracted to have a separate go.mod file which allows it be a standalone module.
|
||||
* [#14880](https://github.com/cosmos/cosmos-sdk/pull/14880) Switch from using gov v1beta1 to gov v1 in upgrade CLIs.
|
||||
* [#14764](https://github.com/cosmos/cosmos-sdk/pull/14764) The `x/upgrade` module is extracted to have a separate go.mod file which allows it be a standalone module.
|
||||
|
||||
@ -22,9 +22,9 @@ recover from.
|
||||
* [State](#state)
|
||||
* [Events](#events)
|
||||
* [Client](#client)
|
||||
* [CLI](#cli)
|
||||
* [REST](#rest)
|
||||
* [gRPC](#grpc)
|
||||
* [CLI](#cli)
|
||||
* [REST](#rest)
|
||||
* [gRPC](#grpc)
|
||||
* [Resources](#resources)
|
||||
|
||||
## Concepts
|
||||
@ -316,6 +316,23 @@ time: "0001-01-01T00:00:00Z"
|
||||
upgraded_client_state: null
|
||||
```
|
||||
|
||||
#### Transactions
|
||||
|
||||
The upgrade module supports the following transactions:
|
||||
|
||||
* `software-proposal` - submits an upgrade proposal:
|
||||
|
||||
```bash
|
||||
simd tx upgrade software-upgrade v2 --title="Test Proposal" --summary="testing" --deposit="100000000stake" --upgrade-height 1000000 \
|
||||
--upgrade-info '{ "binaries": { "linux/amd64":"https://example.com/simd.zip?checksum=sha256:aec070645fe53ee3b3763059376134f058cc337247c978add178b6ccdfb0019f" } }' --from cosmos1..
|
||||
```
|
||||
|
||||
* `cancel-software-upgrade` - cancels a previously submitted upgrade proposal:
|
||||
|
||||
```bash
|
||||
simd tx upgrade cancel-software-upgrade --title="Test Proposal" --summary="testing" --deposit="100000000stake" --from cosmos1..
|
||||
```
|
||||
|
||||
### REST
|
||||
|
||||
A user can query the `upgrade` module using REST endpoints.
|
||||
|
||||
@ -3,33 +3,18 @@ package cli
|
||||
import (
|
||||
"cosmossdk.io/x/upgrade/types"
|
||||
"github.com/spf13/pflag"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/x/gov/client/cli"
|
||||
gov "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
|
||||
)
|
||||
|
||||
func parseArgsToContent(fs *pflag.FlagSet, name string) (gov.Content, error) {
|
||||
title, err := fs.GetString(cli.FlagTitle)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
description, err := fs.GetString(cli.FlagDescription) //nolint:staticcheck // we are intentionally using a deprecated flag here.
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
func parsePlan(fs *pflag.FlagSet, name string) (types.Plan, error) {
|
||||
height, err := fs.GetInt64(FlagUpgradeHeight)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return types.Plan{}, err
|
||||
}
|
||||
|
||||
info, err := fs.GetString(FlagUpgradeInfo)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return types.Plan{}, err
|
||||
}
|
||||
|
||||
plan := types.Plan{Name: name, Height: height, Info: info}
|
||||
content := types.NewSoftwareUpgradeProposal(title, description, plan)
|
||||
return content, nil
|
||||
return types.Plan{Name: name, Height: height, Info: info}, nil
|
||||
}
|
||||
|
||||
@ -6,16 +6,12 @@ import (
|
||||
|
||||
"cosmossdk.io/x/upgrade/types"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/x/gov/client/cli"
|
||||
)
|
||||
|
||||
func TestParseArgsToContent(t *testing.T) {
|
||||
fs := NewCmdSubmitLegacyUpgradeProposal().Flags()
|
||||
func TestParsePlan(t *testing.T) {
|
||||
fs := NewCmdSubmitUpgradeProposal().Flags()
|
||||
|
||||
proposal := types.SoftwareUpgradeProposal{ //nolint:staticcheck // SA1019: types.SoftwareUpgradeProposal is deprecated: use types.Content instead
|
||||
Title: "proposal title",
|
||||
Description: "proposal description",
|
||||
proposal := types.MsgSoftwareUpgrade{
|
||||
Plan: types.Plan{
|
||||
Name: "plan name",
|
||||
Height: 123456,
|
||||
@ -23,19 +19,12 @@ func TestParseArgsToContent(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
fs.Set(cli.FlagTitle, proposal.Title)
|
||||
fs.Set(cli.FlagDescription, proposal.Description) //nolint:staticcheck // SA1019: cli.FlagDescription is deprecated: use cli.FlagProposalDescription instead
|
||||
fs.Set(FlagUpgradeHeight, strconv.FormatInt(proposal.Plan.Height, 10))
|
||||
fs.Set(FlagUpgradeInfo, proposal.Plan.Info)
|
||||
|
||||
content, err := parseArgsToContent(fs, proposal.Plan.Name)
|
||||
p, err := parsePlan(fs, proposal.Plan.Name)
|
||||
require.NoError(t, err)
|
||||
|
||||
p, ok := content.(*types.SoftwareUpgradeProposal) //nolint:staticcheck // SA1019: types.SoftwareUpgradeProposal is deprecated: use types.Content instead
|
||||
require.Equal(t, ok, true)
|
||||
require.Equal(t, p.Title, proposal.Title)
|
||||
require.Equal(t, p.Description, proposal.Description)
|
||||
require.Equal(t, p.Plan.Name, proposal.Plan.Name)
|
||||
require.Equal(t, p.Plan.Height, proposal.Plan.Height)
|
||||
require.Equal(t, p.Plan.Info, proposal.Plan.Info)
|
||||
require.Equal(t, p.Name, proposal.Plan.Name)
|
||||
require.Equal(t, p.Height, proposal.Plan.Height)
|
||||
require.Equal(t, p.Info, proposal.Plan.Info)
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
@ -10,19 +11,19 @@ import (
|
||||
"cosmossdk.io/x/upgrade/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/client/tx"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/address"
|
||||
"github.com/cosmos/cosmos-sdk/x/gov/client/cli"
|
||||
"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
|
||||
)
|
||||
|
||||
const (
|
||||
// Deprecated: only used for v1beta1 legacy proposals.
|
||||
FlagUpgradeHeight = "upgrade-height"
|
||||
// Deprecated: only used for v1beta1 legacy proposals.
|
||||
FlagUpgradeInfo = "upgrade-info"
|
||||
FlagNoValidate = "no-validate"
|
||||
FlagDaemonName = "daemon-name"
|
||||
FlagUpgradeInfo = "upgrade-info"
|
||||
FlagNoValidate = "no-validate"
|
||||
FlagDaemonName = "daemon-name"
|
||||
FlagAuthority = "authority"
|
||||
)
|
||||
|
||||
// GetTxCmd returns the transaction commands for this module
|
||||
@ -32,41 +33,53 @@ func GetTxCmd() *cobra.Command {
|
||||
Short: "Upgrade transaction subcommands",
|
||||
}
|
||||
|
||||
cmd.AddCommand(
|
||||
NewCmdSubmitUpgradeProposal(),
|
||||
NewCmdSubmitCancelUpgradeProposal(),
|
||||
)
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
// NewCmdSubmitLegacyUpgradeProposal implements a command handler for submitting a software upgrade proposal transaction.
|
||||
// Deprecated: please use NewCmdSubmitUpgradeProposal instead.
|
||||
func NewCmdSubmitLegacyUpgradeProposal() *cobra.Command {
|
||||
// NewCmdSubmitUpgradeProposal implements a command handler for submitting a software upgrade proposal transaction.
|
||||
func NewCmdSubmitUpgradeProposal() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "software-upgrade [name] (--upgrade-height [height]) (--upgrade-info [info]) [flags]",
|
||||
Args: cobra.ExactArgs(1),
|
||||
Short: "Submit a software upgrade proposal",
|
||||
Long: "Submit a software upgrade along with an initial deposit.\n" +
|
||||
"Please specify a unique name and height for the upgrade to take effect.\n" +
|
||||
"You may include info to reference a binary download link, in a format compatible with: https://github.com/cosmos/cosmos-sdk/tree/main/cosmovisor",
|
||||
"You may include info to reference a binary download link, in a format compatible with: https://docs.cosmos.network/main/tooling/cosmovisor",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx, err := client.GetClientTxContext(cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
name := args[0]
|
||||
content, err := parseArgsToContent(cmd.Flags(), name)
|
||||
|
||||
proposal, err := cli.ReadGovPropFlags(clientCtx, cmd.Flags())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
name := args[0]
|
||||
p, err := parsePlan(cmd.Flags(), name)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
noValidate, err := cmd.Flags().GetBool(FlagNoValidate)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if !noValidate {
|
||||
prop := content.(*types.SoftwareUpgradeProposal) //nolint:staticcheck // we are intentionally using a deprecated proposal type.
|
||||
var daemonName string
|
||||
if daemonName, err = cmd.Flags().GetString(FlagDaemonName); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var planInfo *plan.Info
|
||||
if planInfo, err = plan.ParseInfo(prop.Plan.Info); err != nil {
|
||||
if planInfo, err = plan.ParseInfo(p.Info); err != nil {
|
||||
return err
|
||||
}
|
||||
if err = planInfo.ValidateFull(daemonName); err != nil {
|
||||
@ -74,40 +87,44 @@ func NewCmdSubmitLegacyUpgradeProposal() *cobra.Command {
|
||||
}
|
||||
}
|
||||
|
||||
from := clientCtx.GetFromAddress()
|
||||
|
||||
depositStr, err := cmd.Flags().GetString(cli.FlagDeposit)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
deposit, err := sdk.ParseCoinsNormalized(depositStr)
|
||||
if err != nil {
|
||||
return err
|
||||
authority, _ := cmd.Flags().GetString(FlagAuthority)
|
||||
if authority != "" {
|
||||
if _, err = sdk.AccAddressFromBech32(authority); err != nil {
|
||||
return fmt.Errorf("invalid authority address: %w", err)
|
||||
}
|
||||
} else {
|
||||
authority = sdk.AccAddress(address.Module("gov")).String()
|
||||
}
|
||||
|
||||
msg, err := v1beta1.NewMsgSubmitProposal(content, deposit, from)
|
||||
if err != nil {
|
||||
return err
|
||||
if err := proposal.SetMsgs([]sdk.Msg{
|
||||
&types.MsgSoftwareUpgrade{
|
||||
Authority: authority,
|
||||
Plan: p,
|
||||
},
|
||||
}); err != nil {
|
||||
return fmt.Errorf("failed to create cancel upgrade message: %w", err)
|
||||
}
|
||||
|
||||
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
|
||||
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), proposal)
|
||||
},
|
||||
}
|
||||
|
||||
cmd.Flags().String(cli.FlagTitle, "", "title of proposal")
|
||||
cmd.Flags().String(cli.FlagDescription, "", "description of proposal") //nolint:staticcheck // we are intentionally using a deprecated flag here.
|
||||
cmd.Flags().String(cli.FlagDeposit, "", "deposit of proposal")
|
||||
cmd.Flags().Int64(FlagUpgradeHeight, 0, "The height at which the upgrade must happen")
|
||||
cmd.Flags().String(FlagUpgradeInfo, "", "Info for the upgrade plan such as new version download urls, etc.")
|
||||
cmd.Flags().Bool(FlagNoValidate, false, "Skip validation of the upgrade info")
|
||||
cmd.Flags().String(FlagDaemonName, getDefaultDaemonName(), "The name of the executable being upgraded (for upgrade-info validation). Default is the DAEMON_NAME env var if set, or else this executable")
|
||||
cmd.Flags().String(FlagAuthority, "", "The address of the upgrade module authority (defaults to gov)")
|
||||
|
||||
// add common proposal flags
|
||||
flags.AddTxFlagsToCmd(cmd)
|
||||
cli.AddGovPropFlagsToCmd(cmd)
|
||||
cmd.MarkFlagRequired(cli.FlagTitle)
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
// NewCmdSubmitLegacyCancelUpgradeProposal implements a command handler for submitting a software upgrade cancel proposal transaction.
|
||||
// Deprecated: please use NewCmdSubmitCancelUpgradeProposal instead.
|
||||
func NewCmdSubmitLegacyCancelUpgradeProposal() *cobra.Command {
|
||||
// NewCmdSubmitCancelUpgradeProposal implements a command handler for submitting a software upgrade cancel proposal transaction.
|
||||
func NewCmdSubmitCancelUpgradeProposal() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "cancel-software-upgrade [flags]",
|
||||
Args: cobra.ExactArgs(0),
|
||||
@ -118,44 +135,39 @@ func NewCmdSubmitLegacyCancelUpgradeProposal() *cobra.Command {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
from := clientCtx.GetFromAddress()
|
||||
|
||||
depositStr, err := cmd.Flags().GetString(cli.FlagDeposit)
|
||||
proposal, err := cli.ReadGovPropFlags(clientCtx, cmd.Flags())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
deposit, err := sdk.ParseCoinsNormalized(depositStr)
|
||||
if err != nil {
|
||||
return err
|
||||
authority, _ := cmd.Flags().GetString(FlagAuthority)
|
||||
if authority != "" {
|
||||
if _, err = sdk.AccAddressFromBech32(authority); err != nil {
|
||||
return fmt.Errorf("invalid authority address: %w", err)
|
||||
}
|
||||
} else {
|
||||
authority = sdk.AccAddress(address.Module("gov")).String()
|
||||
}
|
||||
|
||||
title, err := cmd.Flags().GetString(cli.FlagTitle)
|
||||
if err != nil {
|
||||
return err
|
||||
if err := proposal.SetMsgs([]sdk.Msg{
|
||||
&types.MsgCancelUpgrade{
|
||||
Authority: authority,
|
||||
},
|
||||
}); err != nil {
|
||||
return fmt.Errorf("failed to create cancel upgrade message: %w", err)
|
||||
}
|
||||
|
||||
description, err := cmd.Flags().GetString(cli.FlagDescription) //nolint:staticcheck // we are intentionally using a deprecated flag here.
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
content := types.NewCancelSoftwareUpgradeProposal(title, description)
|
||||
|
||||
msg, err := v1beta1.NewMsgSubmitProposal(content, deposit, from)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
|
||||
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), proposal)
|
||||
},
|
||||
}
|
||||
|
||||
cmd.Flags().String(cli.FlagTitle, "", "title of proposal")
|
||||
cmd.Flags().String(cli.FlagDescription, "", "description of proposal") //nolint:staticcheck // we are intentionally using a deprecated flag here.
|
||||
cmd.Flags().String(cli.FlagDeposit, "", "deposit of proposal")
|
||||
cmd.Flags().String(FlagAuthority, "", "The address of the upgrade module authority (defaults to gov)")
|
||||
|
||||
// add common proposal flags
|
||||
flags.AddTxFlagsToCmd(cmd)
|
||||
cli.AddGovPropFlagsToCmd(cmd)
|
||||
cmd.MarkFlagRequired(cli.FlagTitle)
|
||||
cmd.MarkFlagRequired(cli.FlagDescription) //nolint:staticcheck // we are intentionally using a deprecated flag here.
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
@ -1,12 +0,0 @@
|
||||
package client
|
||||
|
||||
import (
|
||||
"cosmossdk.io/x/upgrade/client/cli"
|
||||
|
||||
govclient "github.com/cosmos/cosmos-sdk/x/gov/client"
|
||||
)
|
||||
|
||||
var (
|
||||
LegacyProposalHandler = govclient.NewProposalHandler(cli.NewCmdSubmitLegacyUpgradeProposal)
|
||||
LegacyCancelProposalHandler = govclient.NewProposalHandler(cli.NewCmdSubmitLegacyCancelUpgradeProposal)
|
||||
)
|
||||
@ -2,11 +2,12 @@ package keeper_test
|
||||
|
||||
import (
|
||||
"cosmossdk.io/x/upgrade/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/address"
|
||||
)
|
||||
|
||||
func (s *KeeperTestSuite) TestSoftwareUpgrade() {
|
||||
govAccAddr := "cosmos10d07y265gmmuvt4z0w9aw880jnsr700j6zn9kn" // TODO
|
||||
// govAccAddr := s.govKeeper.GetGovernanceAccount(s.ctx).GetAddress().String()
|
||||
govAccAddr := sdk.AccAddress(address.Module("gov")).String()
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
|
||||
Loading…
Reference in New Issue
Block a user