Skip to content

Commit

Permalink
Remove name legacy governance proposal (#1963)
Browse files Browse the repository at this point in the history
* Add changelog.

* Fix changelog.

* Migrate proposal methods to keeper and update tests. Remove handler from app

* Remove proposal messages, types, and tests. Update codec and cli. Remove simulation for proposals.

* Fix name tests.

* Add coderabbit suggestions.

* Remove deprecated and unused proposal handlers for wasm and ibc.
  • Loading branch information
Taztingo authored May 15, 2024
1 parent ca0ec9c commit a8bdd20
Show file tree
Hide file tree
Showing 20 changed files with 375 additions and 532 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* Switch to InputOutputCoinsProv for exchange transfers [#1930](https://github.com/provenance-io/provenance/pull/1930).
* Use fields of the SimulationState for the encoders needed for simulations [#1931](https://github.com/provenance-io/provenance/pull/1931).
* Removes sync-info code for sdk v0.50 [#1760](https://github.com/provenance-io/provenance/issues/1760).
* Remove `name` legacy gov proposals [#1963](https://github.com/provenance-io/provenance/pull/1963).
* Fix most of the failing unit tests [#1943](https://github.com/provenance-io/provenance/pull/1943).
* Clean up ReadFromClient [#1760](https://github.com/provenance-io/provenance/issues/1760).
* Enhance the config get and changed commands to make it easier to find fields [#1968](https://github.com/provenance-io/provenance/pull/1968).
Expand Down
6 changes: 0 additions & 6 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ import (
ibctransferkeeper "github.com/cosmos/ibc-go/v8/modules/apps/transfer/keeper"
ibctransfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types"
ibc "github.com/cosmos/ibc-go/v8/modules/core"
ibcclient "github.com/cosmos/ibc-go/v8/modules/core/02-client"
ibcclienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types"
ibcconnectiontypes "github.com/cosmos/ibc-go/v8/modules/core/03-connection/types"
porttypes "github.com/cosmos/ibc-go/v8/modules/core/05-port/types"
Expand Down Expand Up @@ -159,7 +158,6 @@ import (
msgfeestypes "github.com/provenance-io/provenance/x/msgfees/types"
msgfeeswasm "github.com/provenance-io/provenance/x/msgfees/wasm"
"github.com/provenance-io/provenance/x/name"
nameclient "github.com/provenance-io/provenance/x/name/client"
namekeeper "github.com/provenance-io/provenance/x/name/keeper"
nametypes "github.com/provenance-io/provenance/x/name/types"
namewasm "github.com/provenance-io/provenance/x/name/wasm"
Expand Down Expand Up @@ -691,9 +689,6 @@ func New(
govRouter := govtypesv1beta1.NewRouter()
govRouter.AddRoute(govtypes.RouterKey, govtypesv1beta1.ProposalHandler).
AddRoute(paramproposal.RouterKey, params.NewParamChangeProposalHandler(app.ParamsKeeper)).
AddRoute(ibcclienttypes.RouterKey, ibcclient.NewClientProposalHandler(app.IBCKeeper.ClientKeeper)).
AddRoute(wasm.RouterKey, wasmkeeper.NewLegacyWasmProposalHandler(app.WasmKeeper, wasmtypes.EnableAllProposals)). // TODO[1760]: gov: Can probably remove with gov v1
AddRoute(nametypes.ModuleName, name.NewProposalHandler(app.NameKeeper)).
AddRoute(markertypes.ModuleName, marker.NewProposalHandler(app.MarkerKeeper)).
AddRoute(msgfeestypes.ModuleName, msgfees.NewProposalHandler(app.MsgFeesKeeper, app.InterfaceRegistry()))
govKeeper := govkeeper.NewKeeper(
Expand Down Expand Up @@ -793,7 +788,6 @@ func New(
append(
[]govclient.ProposalHandler{},
paramsclient.ProposalHandler,
nameclient.RootNameProposalHandler,
),
),
})
Expand Down
3 changes: 3 additions & 0 deletions proto/provenance/name/v1/name.proto
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ message NameRecord {
// CreateRootNameProposal details a proposal to create a new root name
// that is controlled by a given owner and optionally restricted to the owner
// for the sole creation of sub names.
// Deprecated: This legacy proposal is deprecated in favor of Msg-based gov
// proposals, see MsgCreateRootNameRequest.
message CreateRootNameProposal {
option deprecated = true;
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;
option (gogoproto.goproto_stringer) = false;
Expand Down
17 changes: 16 additions & 1 deletion third_party/proto/cosmos_proto/cosmos.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ import "google/protobuf/descriptor.proto";

option go_package = "github.com/cosmos/cosmos-proto;cosmos_proto";

extend google.protobuf.MethodOptions {

// method_added_in is used to indicate from which version the method was added.
string method_added_in = 93001;
}

extend google.protobuf.MessageOptions {

// implements_interface is used to indicate the type name of the interface
Expand All @@ -13,6 +19,9 @@ extend google.protobuf.MessageOptions {
// interfaces. Interfaces should be declared using a declare_interface
// file option.
repeated string implements_interface = 93001;

// message_added_in is used to indicate from which version the message was added.
string message_added_in = 93002;
}

extend google.protobuf.FieldOptions {
Expand All @@ -27,6 +36,9 @@ extend google.protobuf.FieldOptions {
// generators may choose to use this information to map this field to a
// language-specific type representing the scalar.
string scalar = 93002;

// field_added_in is used to indicate from which version the field was added.
string field_added_in = 93003;
}

extend google.protobuf.FileOptions {
Expand All @@ -46,6 +58,9 @@ extend google.protobuf.FileOptions {
// expected that the declaration will be found in a protobuf file named
// a/b/scalars.proto in the file descriptor set.
repeated ScalarDescriptor declare_scalar = 793022;

// file_added_in is used to indicate from which the version the file was added.
string file_added_in = 793023;
}

// InterfaceDescriptor describes an interface type to be used with
Expand Down Expand Up @@ -94,4 +109,4 @@ enum ScalarType {
SCALAR_TYPE_UNSPECIFIED = 0;
SCALAR_TYPE_STRING = 1;
SCALAR_TYPE_BYTES = 2;
}
}
110 changes: 71 additions & 39 deletions x/name/client/cli/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -573,91 +573,120 @@ func (s *IntegrationTestSuite) TestPaginationWithPageKey() {
})
}

func (s *IntegrationTestSuite) TestCreateRootNameCmd() {
func (s *IntegrationTestSuite) TestGovRootNameCmd() {
testCases := []struct {
name string
cmd *cobra.Command
args []string
expectErr bool
respType proto.Message
expectedCode uint32
errorMessage string
}{
{
"should create a root name proposal",
namecli.GetRootNameProposalCmd(),
[]string{"rootprop",
fmt.Sprintf("--%s=%s", namecli.FlagTitle, "title"),
fmt.Sprintf("--%s=%s", namecli.FlagDescription, "description"),
fmt.Sprintf("--%s=%s%s", namecli.FlagDeposit, "10", s.cfg.BondDenom),
name: "should create a root name proposal",
cmd: namecli.GetGovRootNameCmd(),
args: []string{"rootprop",
fmt.Sprintf("--%s=%s", govcli.FlagTitle, "title"),
fmt.Sprintf("--%s=%s", govcli.FlagSummary, "description"),
fmt.Sprintf("--%s=%s%s", govcli.FlagDeposit, "10", s.cfg.BondDenom),
fmt.Sprintf("--%s=%s", "owner", s.testnet.Validators[0].Address.String()),
fmt.Sprintf("--%s=%s", flags.FlagFrom, s.testnet.Validators[0].Address.String()),
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewInt64Coin(s.cfg.BondDenom, 10)).String()),
},
false, &sdk.TxResponse{}, 0,
expectErr: false,
respType: &sdk.TxResponse{},
expectedCode: 0,
},
{
"should succeed with missing deposit",
namecli.GetRootNameProposalCmd(),
[]string{"rootprop",
fmt.Sprintf("--%s=%s", namecli.FlagTitle, "title"),
fmt.Sprintf("--%s=%s", namecli.FlagDescription, "description"),
name: "should fail for missing arg",
cmd: namecli.GetGovRootNameCmd(),
args: []string{
fmt.Sprintf("--%s=%s", govcli.FlagTitle, "title"),
fmt.Sprintf("--%s=%s", govcli.FlagSummary, "description"),
fmt.Sprintf("--%s=%s%s", govcli.FlagDeposit, "10", s.cfg.BondDenom),
fmt.Sprintf("--%s=%s", "owner", s.testnet.Validators[0].Address.String()),
fmt.Sprintf("--%s=%s", flags.FlagFrom, s.testnet.Validators[0].Address.String()),
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewInt64Coin(s.cfg.BondDenom, 10)).String()),
},
false, &sdk.TxResponse{}, 0,
expectErr: false,
respType: &sdk.TxResponse{},
expectedCode: 0,
errorMessage: "accepts 1 arg(s), received 0",
},
{
"should fail for bad deposit",
namecli.GetRootNameProposalCmd(),
[]string{"rootprop",
fmt.Sprintf("--%s=%s", namecli.FlagTitle, "title"),
fmt.Sprintf("--%s=%s", namecli.FlagDescription, "description"),
fmt.Sprintf("--%s=%s", namecli.FlagDeposit, "10"),
name: "should succeed with missing deposit",
cmd: namecli.GetGovRootNameCmd(),
args: []string{"rootprop",
fmt.Sprintf("--%s=%s", govcli.FlagTitle, "title"),
fmt.Sprintf("--%s=%s", govcli.FlagSummary, "description"),
fmt.Sprintf("--%s=%s", "owner", s.testnet.Validators[0].Address.String()),
fmt.Sprintf("--%s=%s", flags.FlagFrom, s.testnet.Validators[0].Address.String()),
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewInt64Coin(s.cfg.BondDenom, 10)).String()),
},
true, &sdk.TxResponse{}, 1,
expectErr: false,
respType: &sdk.TxResponse{},
expectedCode: 0,
},
{
"should fail for empty title",
namecli.GetRootNameProposalCmd(),
[]string{"rootprop",
fmt.Sprintf("--%s=%s", namecli.FlagDescription, "description"),
fmt.Sprintf("--%s=%s%s", namecli.FlagDeposit, "10", s.cfg.BondDenom),
name: "should fail for bad deposit",
cmd: namecli.GetGovRootNameCmd(),
args: []string{"rootprop",
fmt.Sprintf("--%s=%s", govcli.FlagTitle, "title"),
fmt.Sprintf("--%s=%s", govcli.FlagSummary, "description"),
fmt.Sprintf("--%s=%s", govcli.FlagDeposit, "10"),
fmt.Sprintf("--%s=%s", "owner", s.testnet.Validators[0].Address.String()),
fmt.Sprintf("--%s=%s", flags.FlagFrom, s.testnet.Validators[0].Address.String()),
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewInt64Coin(s.cfg.BondDenom, 10)).String()),
},
true, &sdk.TxResponse{}, 1,
expectErr: true,
respType: &sdk.TxResponse{},
expectedCode: 1,
},
{
"should fail for empty description",
namecli.GetRootNameProposalCmd(),
[]string{"rootprop",
fmt.Sprintf("--%s=%s", namecli.FlagTitle, "title"),
fmt.Sprintf("--%s=%s%s", namecli.FlagDeposit, "10", s.cfg.BondDenom),
name: "should fail for empty title",
cmd: namecli.GetGovRootNameCmd(),
args: []string{"rootprop",
fmt.Sprintf("--%s=%s", govcli.FlagSummary, "description"),
fmt.Sprintf("--%s=%s%s", govcli.FlagDeposit, "10", s.cfg.BondDenom),
fmt.Sprintf("--%s=%s", flags.FlagFrom, s.testnet.Validators[0].Address.String()),
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewInt64Coin(s.cfg.BondDenom, 10)).String()),
},
true, &sdk.TxResponse{}, 1,
expectErr: false,
respType: &sdk.TxResponse{},
expectedCode: 18,
},
{
name: "should fail for empty summary",
cmd: namecli.GetGovRootNameCmd(),
args: []string{"rootprop",
fmt.Sprintf("--%s=%s", govcli.FlagTitle, "title"),
fmt.Sprintf("--%s=%s%s", govcli.FlagDeposit, "10", s.cfg.BondDenom),
fmt.Sprintf("--%s=%s", flags.FlagFrom, s.testnet.Validators[0].Address.String()),
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewInt64Coin(s.cfg.BondDenom, 10)).String()),
},
expectErr: false,
respType: &sdk.TxResponse{},
expectedCode: 18,
},
{
"should fail for bad owner",
namecli.GetRootNameProposalCmd(),
[]string{"rootprop",
fmt.Sprintf("--%s=%s", namecli.FlagTitle, "title"),
fmt.Sprintf("--%s=%s%s", namecli.FlagDeposit, "10", s.cfg.BondDenom),
name: "should fail for bad owner",
cmd: namecli.GetGovRootNameCmd(),
args: []string{"rootprop",
fmt.Sprintf("--%s=%s", govcli.FlagTitle, "title"),
fmt.Sprintf("--%s=%s%s", govcli.FlagDeposit, "10", s.cfg.BondDenom),

fmt.Sprintf("--%s=%s", "owner", "asdf"),

Expand All @@ -666,7 +695,9 @@ func (s *IntegrationTestSuite) TestCreateRootNameCmd() {
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastSync),
fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewInt64Coin(s.cfg.BondDenom, 10)).String()),
},
true, &sdk.TxResponse{}, 1,
expectErr: true,
respType: &sdk.TxResponse{},
expectedCode: 1,
},
}

Expand All @@ -677,6 +708,7 @@ func (s *IntegrationTestSuite) TestCreateRootNameCmd() {
testcli.NewCLITxExecutor(tc.cmd, tc.args).
WithExpErr(tc.expectErr).
WithExpCode(tc.expectedCode).
WithExpErrMsg(tc.errorMessage).
Execute(s.T(), s.testnet)
})
}
Expand Down
Loading

0 comments on commit a8bdd20

Please sign in to comment.