Skip to content

Commit

Permalink
refactor!: remove UpgradeProposal type (#4602)
Browse files Browse the repository at this point in the history
  • Loading branch information
colin-axner authored Sep 8, 2023
1 parent c4f947e commit 386ea01
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 981 deletions.
96 changes: 0 additions & 96 deletions modules/core/02-client/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"github.com/cosmos/cosmos-sdk/version"
govcli "github.com/cosmos/cosmos-sdk/x/gov/client/cli"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"

"github.com/cosmos/ibc-go/v7/modules/core/02-client/types"
"github.com/cosmos/ibc-go/v7/modules/core/exported"
Expand Down Expand Up @@ -303,101 +302,6 @@ func newSubmitRecoverClientProposalCmd() *cobra.Command {
return cmd
}

// NewCmdSubmitUpgradeProposal implements a command handler for submitting an upgrade IBC client proposal transaction.
func NewCmdSubmitUpgradeProposal() *cobra.Command {
cmd := &cobra.Command{
Use: "ibc-upgrade [name] [height] [path/to/upgraded_client_state.json] [flags]",
Args: cobra.ExactArgs(3),
Short: "Submit an IBC upgrade proposal",
Long: "Submit an IBC client breaking upgrade proposal along with an initial deposit.\n" +
"The client state specified is the upgraded client state representing the upgraded chain\n" +
`Example Upgraded Client State JSON:
{
"@type":"/ibc.lightclients.tendermint.v1.ClientState",
"chain_id":"testchain1",
"unbonding_period":"1814400s",
"latest_height":{"revision_number":"0","revision_height":"2"},
"proof_specs":[{"leaf_spec":{"hash":"SHA256","prehash_key":"NO_HASH","prehash_value":"SHA256","length":"VAR_PROTO","prefix":"AA=="},"inner_spec":{"child_order":[0,1],"child_size":33,"min_prefix_length":4,"max_prefix_length":12,"empty_child":null,"hash":"SHA256"},"max_depth":0,"min_depth":0},{"leaf_spec":{"hash":"SHA256","prehash_key":"NO_HASH","prehash_value":"SHA256","length":"VAR_PROTO","prefix":"AA=="},"inner_spec":{"child_order":[0,1],"child_size":32,"min_prefix_length":1,"max_prefix_length":1,"empty_child":null,"hash":"SHA256"},"max_depth":0,"min_depth":0}],
"upgrade_path":["upgrade","upgradedIBCState"],
}
`,
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
}
cdc := codec.NewProtoCodec(clientCtx.InterfaceRegistry)

title, err := cmd.Flags().GetString(govcli.FlagTitle) //nolint:staticcheck // need this till full govv1 conversion.
if err != nil {
return err
}

description, err := cmd.Flags().GetString(govcli.FlagDescription) //nolint:staticcheck // need this till full govv1 conversion.
if err != nil {
return err
}

name := args[0]

height, err := strconv.ParseInt(args[1], 10, 64)
if err != nil {
return err
}

plan := upgradetypes.Plan{
Name: name,
Height: height,
}

// attempt to unmarshal client state argument
var clientState exported.ClientState
clientContentOrFileName := args[2]
if err := cdc.UnmarshalInterfaceJSON([]byte(clientContentOrFileName), &clientState); err != nil {

// check for file path if JSON input is not provided
contents, err := os.ReadFile(clientContentOrFileName)
if err != nil {
return fmt.Errorf("neither JSON input nor path to .json file for client state were provided: %w", err)
}

if err := cdc.UnmarshalInterfaceJSON(contents, &clientState); err != nil {
return fmt.Errorf("error unmarshalling client state file: %w", err)
}
}

content, err := types.NewUpgradeProposal(title, description, plan, clientState)
if err != nil {
return err
}

from := clientCtx.GetFromAddress()

depositStr, err := cmd.Flags().GetString(govcli.FlagDeposit)
if err != nil {
return err
}
deposit, err := sdk.ParseCoinsNormalized(depositStr)
if err != nil {
return err
}

msg, err := govv1beta1.NewMsgSubmitProposal(content, deposit, from)
if err != nil {
return err
}

return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
},
}

cmd.Flags().String(govcli.FlagTitle, "", "title of proposal") //nolint:staticcheck // need this till full govv1 conversion.
cmd.Flags().String(govcli.FlagDescription, "", "description of proposal") //nolint:staticcheck // need this till full govv1 conversion.
cmd.Flags().String(govcli.FlagDeposit, "", "deposit of proposal")

return cmd
}

// newScheduleIBCUpgradeProposalCmd defines the command for submitting an IBC software upgrade proposal.
func newScheduleIBCUpgradeProposalCmd() *cobra.Command {
cmd := &cobra.Command{
Expand Down
9 changes: 0 additions & 9 deletions modules/core/02-client/client/proposal_handler.go

This file was deleted.

42 changes: 0 additions & 42 deletions modules/core/02-client/keeper/proposal.go

This file was deleted.

132 changes: 0 additions & 132 deletions modules/core/02-client/keeper/proposal_test.go

This file was deleted.

25 changes: 0 additions & 25 deletions modules/core/02-client/proposal_handler.go

This file was deleted.

Loading

0 comments on commit 386ea01

Please sign in to comment.