diff --git a/codec/std/codec.go b/codec/std/codec.go index 03f12020da..ccf17fba69 100644 --- a/codec/std/codec.go +++ b/codec/std/codec.go @@ -9,7 +9,7 @@ import ( "github.com/cosmos/cosmos-sdk/x/auth/vesting" "github.com/cosmos/cosmos-sdk/x/evidence" eviexported "github.com/cosmos/cosmos-sdk/x/evidence/exported" - "github.com/cosmos/cosmos-sdk/x/gov" + gov "github.com/cosmos/cosmos-sdk/x/gov/types" "github.com/cosmos/cosmos-sdk/x/supply" supplyexported "github.com/cosmos/cosmos-sdk/x/supply/exported" ) diff --git a/codec/std/codec.pb.go b/codec/std/codec.pb.go index 2d1c5b2325..a5231fa6cd 100644 --- a/codec/std/codec.pb.go +++ b/codec/std/codec.pb.go @@ -965,100 +965,100 @@ func init() { func init() { proto.RegisterFile("codec/std/codec.proto", fileDescriptor_daf09dc2dfa19bb4) } var fileDescriptor_daf09dc2dfa19bb4 = []byte{ - // 1479 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x58, 0xcd, 0x6f, 0xd4, 0x46, - 0x1b, 0xf7, 0xc2, 0x92, 0x84, 0x49, 0x80, 0x30, 0x2f, 0xbc, 0x59, 0xe5, 0x85, 0x4d, 0x08, 0xbc, - 0xa8, 0x05, 0x65, 0xcd, 0x47, 0x5b, 0x60, 0xd5, 0x0a, 0xf2, 0x01, 0x5a, 0xaa, 0xa6, 0x45, 0x0e, - 0xa4, 0x6a, 0x45, 0x6b, 0xcd, 0x7a, 0x06, 0x67, 0x9a, 0xb5, 0xc7, 0xf5, 0x8c, 0x37, 0x9b, 0x43, - 0xef, 0x6d, 0xa5, 0x4a, 0x55, 0xfb, 0x0f, 0xa0, 0xf6, 0xd8, 0x2b, 0xc7, 0x9e, 0x2b, 0xc4, 0x89, - 0x63, 0x4f, 0xa8, 0x82, 0x4b, 0xd5, 0xbf, 0xa2, 0x9a, 0x0f, 0x7b, 0xed, 0x5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, - 0x67, 0xba, 0x0b, 0x6c, 0x15, 0xd4, 0x5e, 0x28, 0xaa, 0xf5, 0x59, 0xb7, 0x20, 0x34, 0x45, 0x95, - 0x0a, 0x6d, 0x82, 0x49, 0x59, 0xce, 0x24, 0xeb, 0x0b, 0x8b, 0x23, 0x75, 0xae, 0x69, 0x3f, 0x27, - 0x05, 0xe4, 0x54, 0xfe, 0x58, 0x01, 0x53, 0x99, 0xb8, 0x9b, 0x05, 0x71, 0x67, 0x4a, 0xc5, 0x8d, - 0xd5, 0x74, 0xeb, 0x1f, 0x6b, 0x5a, 0xad, 0x4a, 0x8a, 0xbe, 0xb2, 0xaa, 0x52, 0xf5, 0xb8, 0x0a, - 0x26, 0x8d, 0x03, 0xbc, 0x06, 0xaa, 0x82, 0xf4, 0xc4, 0x58, 0x51, 0xf7, 0x49, 0x2f, 0x3b, 0xac, - 0x96, 0xe5, 0x28, 0x00, 0x7c, 0x08, 0x66, 0x55, 0x87, 0x27, 0x82, 0xc4, 0xae, 0xb7, 0x8d, 0x42, - 0x3f, 0xbd, 0xd1, 0x81, 0x24, 0xd1, 0x73, 0x40, 0xbd, 0x5c, 0xea, 0xbf, 0xa6, 0xdc, 0x73, 0x94, - 0xc7, 0xa2, 0xa2, 0x09, 0x7e, 0x06, 0x66, 0x39, 0x7b, 0x24, 0x76, 0x51, 0x4c, 0x5c, 0x33, 0x23, - 0x4c, 0xab, 0xbc, 0x54, 0x64, 0x37, 0x46, 0x55, 0xbe, 0x06, 0xf0, 0x40, 0x6f, 0xe5, 0xe9, 0x79, - 0xd1, 0x04, 0x23, 0x30, 0xe7, 0xa1, 0xd0, 0x23, 0x1d, 0x77, 0x28, 0x4a, 0xb5, 0x6c, 0x0a, 0xe4, - 0xa2, 0xac, 0x29, 0xdc, 0xe8, 0x58, 0x27, 0xbd, 0x32, 0x07, 0xd8, 0x01, 0x27, 0x3c, 0x16, 0x04, - 0x49, 0x48, 0xc5, 0x9e, 0x1b, 0x31, 0xd6, 0x71, 0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0x8c, 0xfa, 0x78, - 0xd9, 0x07, 0x70, 0x91, 0xfa, 0x41, 0x98, 0x63, 0x3d, 0x12, 0xe4, 0x37, 0x9a, 0x17, 0x9e, 0x3d, - 0x59, 0x3e, 0x3f, 0x76, 0xce, 0xe9, 0x09, 0x27, 0x15, 0x9a, 0xe9, 0xf6, 0x5d, 0x05, 0x4c, 0x6e, - 0x52, 0x3f, 0x5c, 0x67, 0x1e, 0xbc, 0x53, 0x98, 0x6c, 0xe7, 0x46, 0x4e, 0x36, 0xe3, 0xff, 0x6f, - 0x8c, 0xb7, 0xd5, 0x5b, 0x4f, 0x5f, 0xd6, 0x2b, 0xcf, 0x5f, 0xd6, 0x2b, 0x7f, 0xbc, 0xac, 0x57, - 0xbe, 0x7f, 0x55, 0xb7, 0x9e, 0xbf, 0xaa, 0x5b, 0xbf, 0xbf, 0xaa, 0x5b, 0x9f, 0x8e, 0x7f, 0xb1, - 0xec, 0x7f, 0x21, 0xed, 0x09, 0xf5, 0xa3, 0xf9, 0xea, 0xdf, 0x01, 0x00, 0x00, 0xff, 0xff, 0xb6, - 0xc7, 0x0e, 0x8b, 0x1f, 0x11, 0x00, 0x00, + // 1477 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x58, 0xdf, 0x6f, 0x14, 0x45, + 0x1c, 0xdf, 0x83, 0xa3, 0x2d, 0xd3, 0x02, 0x65, 0x04, 0x7b, 0xa9, 0x70, 0x2d, 0x05, 0x89, 0x42, + 0x7a, 0x27, 0xa0, 0x42, 0x2f, 0x1a, 0xe8, 0xb5, 0x90, 0xc3, 0x58, 0x25, 0x5b, 0xa8, 0xd1, 0xa0, + 0x9b, 0xb9, 0x9d, 0x61, 0x3b, 0xf6, 0x76, 0x67, 0xdd, 0x99, 0xbd, 0x5e, 0x1f, 0x7c, 0x57, 0x13, + 0x13, 0xa3, 0xff, 0x00, 0xea, 0xa3, 0xaf, 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 0xec, 0xfe, 0xc7, 0xd0, 0x94, 0x18, 0x3b, + 0x85, 0x98, 0x63, 0x18, 0xd8, 0x85, 0x1f, 0xeb, 0xe6, 0x1b, 0x07, 0x29, 0xf5, 0xf1, 0xa2, 0x2f, + 0xe0, 0x3c, 0xf5, 0xbd, 0x20, 0xc3, 0x7a, 0xc4, 0xcf, 0x6e, 0x34, 0x2e, 0x3c, 0x79, 0xb4, 0x7c, + 0x7e, 0xec, 0x9c, 0xd3, 0x13, 0x4e, 0x2a, 0x34, 0xd3, 0xed, 0xfb, 0x12, 0x98, 0xdc, 0xa4, 0x5e, + 0xb0, 0xce, 0x5c, 0x78, 0x2b, 0x37, 0xd9, 0xce, 0x8d, 0x9c, 0x6c, 0xc6, 0xff, 0xff, 0x18, 0x6f, + 0xcd, 0x1b, 0x8f, 0x9f, 0x57, 0x4b, 0x4f, 0x9f, 0x57, 0x4b, 0x7f, 0x3d, 0xaf, 0x96, 0x7e, 0x78, + 0x51, 0xb5, 0x9e, 0xbe, 0xa8, 0x5a, 0x7f, 0xbe, 0xa8, 0x5a, 0x9f, 0x8d, 0x7f, 0xb1, 0xf4, 0x9f, + 0x21, 0xed, 0x09, 0xf5, 0xab, 0xf9, 0xca, 0xbf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x23, 0x3f, 0x73, + 0xb2, 0x20, 0x11, 0x00, 0x00, } func (this *Supply) Equal(that interface{}) bool { @@ -1515,33 +1515,18 @@ func (this *Content) SetContent(value github_com_cosmos_cosmos_sdk_x_gov_types.C case *types4.TextProposal: this.Sum = &Content_Text{vt} return nil - case types4.TextProposal: - this.Sum = &Content_Text{&vt} - return nil case *proposal.ParameterChangeProposal: this.Sum = &Content_ParameterChange{vt} return nil - case proposal.ParameterChangeProposal: - this.Sum = &Content_ParameterChange{&vt} - return nil case *types5.SoftwareUpgradeProposal: this.Sum = &Content_SoftwareUpgrade{vt} return nil - case types5.SoftwareUpgradeProposal: - this.Sum = &Content_SoftwareUpgrade{&vt} - return nil case *types5.CancelSoftwareUpgradeProposal: this.Sum = &Content_CancelSoftwareUpgrade{vt} return nil - case types5.CancelSoftwareUpgradeProposal: - this.Sum = &Content_CancelSoftwareUpgrade{&vt} - return nil case *types6.CommunityPoolSpendProposal: this.Sum = &Content_CommunityPoolSpend{vt} return nil - case types6.CommunityPoolSpendProposal: - this.Sum = &Content_CommunityPoolSpend{&vt} - return nil } return fmt.Errorf("can't encode value of type %T as message Content", value) } diff --git a/codec/std/codec.proto b/codec/std/codec.proto index c7246a69cd..cf8e62865a 100644 --- a/codec/std/codec.proto +++ b/codec/std/codec.proto @@ -88,7 +88,7 @@ message Proposal { // governance proposal. message Content { option (gogoproto.equal) = true; - option (cosmos_proto.interface_type) = "github.com/cosmos/cosmos-sdk/x/gov/types.Content"; + option (cosmos_proto.interface_type) = "*github.com/cosmos/cosmos-sdk/x/gov/types.Content"; // sum defines a set of all acceptable concrete governance proposal Content types. oneof sum { diff --git a/codec/std/msgs.go b/codec/std/msgs.go index 4d15d8143c..f54f99e5f0 100644 --- a/codec/std/msgs.go +++ b/codec/std/msgs.go @@ -5,12 +5,12 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/x/evidence" eviexported "github.com/cosmos/cosmos-sdk/x/evidence/exported" - "github.com/cosmos/cosmos-sdk/x/gov" + gov "github.com/cosmos/cosmos-sdk/x/gov/types" ) var ( _ eviexported.MsgSubmitEvidence = MsgSubmitEvidence{} - _ gov.MsgSubmitProposalI = MsgSubmitProposal{} + _ gov.MsgSubmitProposalI = &MsgSubmitProposal{} ) // NewMsgSubmitEvidence returns a new MsgSubmitEvidence. @@ -47,13 +47,13 @@ func (msg MsgSubmitEvidence) GetEvidence() eviexported.Evidence { return msg.Evi func (msg MsgSubmitEvidence) GetSubmitter() sdk.AccAddress { return msg.Submitter } // NewMsgSubmitProposal returns a new MsgSubmitProposal. -func NewMsgSubmitProposal(c gov.Content, d sdk.Coins, p sdk.AccAddress) (MsgSubmitProposal, error) { +func NewMsgSubmitProposal(c gov.Content, d sdk.Coins, p sdk.AccAddress) (gov.MsgSubmitProposalI, error) { content := &Content{} if err := content.SetContent(c); err != nil { - return MsgSubmitProposal{}, err + return nil, err } - return MsgSubmitProposal{ + return &MsgSubmitProposal{ Content: content, MsgSubmitProposalBase: gov.NewMsgSubmitProposalBase(d, p), }, nil @@ -79,6 +79,13 @@ func (msg MsgSubmitProposal) ValidateBasic() error { } // nolint -func (msg MsgSubmitProposal) GetContent() gov.Content { return msg.Content.GetContent() } -func (msg MsgSubmitProposal) GetInitialDeposit() sdk.Coins { return msg.InitialDeposit } -func (msg MsgSubmitProposal) GetProposer() sdk.AccAddress { return msg.Proposer } +func (msg *MsgSubmitProposal) GetContent() gov.Content { return msg.Content.GetContent() } +func (msg *MsgSubmitProposal) SetContent(content gov.Content) error { + stdContent := &Content{} + err := stdContent.SetContent(content) + if err != nil { + return err + } + msg.Content = stdContent + return nil +} diff --git a/codec/std/msgs_test.go b/codec/std/msgs_test.go index f0bd00efae..0eda4809bd 100644 --- a/codec/std/msgs_test.go +++ b/codec/std/msgs_test.go @@ -4,12 +4,13 @@ import ( "testing" "time" + gov "github.com/cosmos/cosmos-sdk/x/gov/types" + "github.com/stretchr/testify/require" "github.com/cosmos/cosmos-sdk/codec/std" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/evidence" - "github.com/cosmos/cosmos-sdk/x/gov" ) func TestNewMsgSubmitEvidence(t *testing.T) { @@ -28,15 +29,45 @@ func TestNewMsgSubmitEvidence(t *testing.T) { require.NoError(t, msg.ValidateBasic()) } -func TestNewNewMsgSubmitProposal(t *testing.T) { +type invalidProposal struct { + *gov.TextProposal +} + +func TestMsgSubmitProposal(t *testing.T) { p := sdk.AccAddress("foo") d := sdk.NewCoins(sdk.NewInt64Coin("stake", 1000)) - c := gov.TextProposal{Title: "title", Description: "description"} + c := gov.NewTextProposal("title", "description") + + // + // test constructor + // msg, err := std.NewMsgSubmitProposal(c, d, p) require.NoError(t, err) - require.Equal(t, msg.GetContent(), &c) + require.Equal(t, msg.GetContent(), c) require.Equal(t, msg.GetProposer(), p) require.Equal(t, msg.GetInitialDeposit(), d) require.NoError(t, msg.ValidateBasic()) + + _, err = std.NewMsgSubmitProposal(invalidProposal{}, d, p) + require.Error(t, err) + + // + // test setter methods + // + + msg = &std.MsgSubmitProposal{} + msg.SetProposer(p) + msg.SetInitialDeposit(d) + err = msg.SetContent(c) + require.NoError(t, err) + require.Equal(t, msg.GetContent(), c) + require.Equal(t, msg.GetProposer(), p) + require.Equal(t, msg.GetInitialDeposit(), d) + require.NoError(t, msg.ValidateBasic()) + + msg = &std.MsgSubmitProposal{} + err = msg.SetContent(invalidProposal{}) + require.Error(t, err) + } diff --git a/docs/architecture/adr-020-protobuf-transaction-encoding.md b/docs/architecture/adr-020-protobuf-transaction-encoding.md index 4d32267a7a..843fb469bc 100644 --- a/docs/architecture/adr-020-protobuf-transaction-encoding.md +++ b/docs/architecture/adr-020-protobuf-transaction-encoding.md @@ -4,6 +4,7 @@ - 2020 March 06: Initial Draft - 2020 March 12: API Updates +- 2020 April 13: Added details on interface `oneof` handling ## Status @@ -132,9 +133,42 @@ We then update `CLIContext` to have a new field: `Marshaler`. Then, each module's client handler will at the minimum accept a `Marshaler` instead of a concrete Amino codec and a `Generator` along with an `AccountRetriever` so -that account fields can be retrieved for signing. If the module needs to work with -any interface types, it will use the `Codec` interface defined by the module which -also extends `Marshaler`. +that account fields can be retrieved for signing. + +#### Interface `oneof` Handling + +If the module needs to work with any `sdk.Msg`s that use interface types, that +`sdk.Msg` should be implemented as an interface with getters and setters on the +module level and a no-arg constructor function should be passed around to +required CLI and REST client commands. + +For example, in `x/gov`, `Content` is an interface type, so `MsgSubmitProposalI` +should also be an interface and implement setter methods: + +```go +// x/gov/types/msgs.go +type MsgSubmitProposalI interface { + sdk.Msg + + GetContent() Content + // SetContent returns an error if the underlying oneof does not support + // the concrete Content passed in + SetContent(Content) error + + GetInitialDeposit() sdk.Coins + SetInitialDeposit(sdk.Coins) + + GetProposer() sdk.AccAddress + SetProposer(sdk.AccAddress) +} +``` + +Note that the implementation of `MsgSubmitProposalI` can be simplified by +using an embedded base struct which implements most of that interface - in this +case `MsgSubmitProposalBase`. + +A parameter `ctr func() MsgSubmitProposalI` would then be passed to CLI client +methods in order to construct a concrete instance. ## Future Improvements diff --git a/x/distribution/handler.go b/x/distribution/handler.go index 5216cdad29..fa6ea6ec67 100644 --- a/x/distribution/handler.go +++ b/x/distribution/handler.go @@ -103,7 +103,7 @@ func handleMsgFundCommunityPool(ctx sdk.Context, msg types.MsgFundCommunityPool, func NewCommunityPoolSpendProposalHandler(k Keeper) govtypes.Handler { return func(ctx sdk.Context, content govtypes.Content) error { switch c := content.(type) { - case types.CommunityPoolSpendProposal: + case *types.CommunityPoolSpendProposal: return keeper.HandleCommunityPoolSpendProposal(ctx, k, c) default: diff --git a/x/distribution/keeper/proposal_handler.go b/x/distribution/keeper/proposal_handler.go index f60a3f8815..c87e8c99e6 100644 --- a/x/distribution/keeper/proposal_handler.go +++ b/x/distribution/keeper/proposal_handler.go @@ -9,7 +9,7 @@ import ( ) // HandleCommunityPoolSpendProposal is a handler for executing a passed community spend proposal -func HandleCommunityPoolSpendProposal(ctx sdk.Context, k Keeper, p types.CommunityPoolSpendProposal) error { +func HandleCommunityPoolSpendProposal(ctx sdk.Context, k Keeper, p *types.CommunityPoolSpendProposal) error { if k.blacklistedAddrs[p.Recipient.String()] { return sdkerrors.Wrapf(sdkerrors.ErrUnauthorized, "%s is blacklisted from receiving external funds", p.Recipient) } diff --git a/x/distribution/proposal_handler_test.go b/x/distribution/proposal_handler_test.go index 0fcb9c843e..f5b28296cc 100644 --- a/x/distribution/proposal_handler_test.go +++ b/x/distribution/proposal_handler_test.go @@ -24,7 +24,7 @@ var ( amount = sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(1))) ) -func testProposal(recipient sdk.AccAddress, amount sdk.Coins) types.CommunityPoolSpendProposal { +func testProposal(recipient sdk.AccAddress, amount sdk.Coins) *types.CommunityPoolSpendProposal { return types.NewCommunityPoolSpendProposal("Test", "description", recipient, amount) } diff --git a/x/distribution/types/codec.go b/x/distribution/types/codec.go index 0bc8316abf..b57767de08 100644 --- a/x/distribution/types/codec.go +++ b/x/distribution/types/codec.go @@ -10,7 +10,7 @@ func RegisterCodec(cdc *codec.Codec) { cdc.RegisterConcrete(MsgWithdrawDelegatorReward{}, "cosmos-sdk/MsgWithdrawDelegationReward", nil) cdc.RegisterConcrete(MsgWithdrawValidatorCommission{}, "cosmos-sdk/MsgWithdrawValidatorCommission", nil) cdc.RegisterConcrete(MsgSetWithdrawAddress{}, "cosmos-sdk/MsgModifyWithdrawAddress", nil) - cdc.RegisterConcrete(CommunityPoolSpendProposal{}, "cosmos-sdk/CommunityPoolSpendProposal", nil) + cdc.RegisterConcrete(&CommunityPoolSpendProposal{}, "cosmos-sdk/CommunityPoolSpendProposal", nil) } var ( diff --git a/x/distribution/types/proposal.go b/x/distribution/types/proposal.go index db65da9428..978b2973d4 100644 --- a/x/distribution/types/proposal.go +++ b/x/distribution/types/proposal.go @@ -14,32 +14,32 @@ const ( ) // Assert CommunityPoolSpendProposal implements govtypes.Content at compile-time -var _ govtypes.Content = CommunityPoolSpendProposal{} +var _ govtypes.Content = &CommunityPoolSpendProposal{} func init() { govtypes.RegisterProposalType(ProposalTypeCommunityPoolSpend) - govtypes.RegisterProposalTypeCodec(CommunityPoolSpendProposal{}, "cosmos-sdk/CommunityPoolSpendProposal") + govtypes.RegisterProposalTypeCodec(&CommunityPoolSpendProposal{}, "cosmos-sdk/CommunityPoolSpendProposal") } // NewCommunityPoolSpendProposal creates a new community pool spned proposal. -func NewCommunityPoolSpendProposal(title, description string, recipient sdk.AccAddress, amount sdk.Coins) CommunityPoolSpendProposal { - return CommunityPoolSpendProposal{title, description, recipient, amount} +func NewCommunityPoolSpendProposal(title, description string, recipient sdk.AccAddress, amount sdk.Coins) *CommunityPoolSpendProposal { + return &CommunityPoolSpendProposal{title, description, recipient, amount} } // GetTitle returns the title of a community pool spend proposal. -func (csp CommunityPoolSpendProposal) GetTitle() string { return csp.Title } +func (csp *CommunityPoolSpendProposal) GetTitle() string { return csp.Title } // GetDescription returns the description of a community pool spend proposal. -func (csp CommunityPoolSpendProposal) GetDescription() string { return csp.Description } +func (csp *CommunityPoolSpendProposal) GetDescription() string { return csp.Description } // GetDescription returns the routing key of a community pool spend proposal. -func (csp CommunityPoolSpendProposal) ProposalRoute() string { return RouterKey } +func (csp *CommunityPoolSpendProposal) ProposalRoute() string { return RouterKey } // ProposalType returns the type of a community pool spend proposal. -func (csp CommunityPoolSpendProposal) ProposalType() string { return ProposalTypeCommunityPoolSpend } +func (csp *CommunityPoolSpendProposal) ProposalType() string { return ProposalTypeCommunityPoolSpend } // ValidateBasic runs basic stateless validity checks -func (csp CommunityPoolSpendProposal) ValidateBasic() error { +func (csp *CommunityPoolSpendProposal) ValidateBasic() error { err := govtypes.ValidateAbstract(csp) if err != nil { return err diff --git a/x/gov/abci_test.go b/x/gov/abci_test.go index 4774f45084..94e461329a 100644 --- a/x/gov/abci_test.go +++ b/x/gov/abci_test.go @@ -4,10 +4,11 @@ import ( "testing" "time" + codecstd "github.com/cosmos/cosmos-sdk/codec/std" + "github.com/stretchr/testify/require" abci "github.com/tendermint/tendermint/abci/types" - codecstd "github.com/cosmos/cosmos-sdk/codec/std" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/gov" diff --git a/x/gov/alias.go b/x/gov/alias.go index aad984c2c1..b682fcd169 100644 --- a/x/gov/alias.go +++ b/x/gov/alias.go @@ -82,8 +82,8 @@ var ( SplitInactiveProposalQueueKey = types.SplitInactiveProposalQueueKey SplitKeyDeposit = types.SplitKeyDeposit SplitKeyVote = types.SplitKeyVote - NewMsgSubmitProposalBase = types.NewMsgSubmitProposalBase NewMsgSubmitProposal = types.NewMsgSubmitProposal + NewMsgSubmitProposalBase = types.NewMsgSubmitProposalBase NewMsgDeposit = types.NewMsgDeposit NewMsgVote = types.NewMsgVote ParamKeyTable = types.ParamKeyTable diff --git a/x/gov/client/cli/tx.go b/x/gov/client/cli/tx.go index 0af8eab61b..dc8f0eac5a 100644 --- a/x/gov/client/cli/tx.go +++ b/x/gov/client/cli/tx.go @@ -11,6 +11,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/context" "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" "github.com/cosmos/cosmos-sdk/codec" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/version" @@ -49,6 +50,209 @@ var ProposalFlags = []string{ FlagDeposit, } +// NewTxCmd returns the transaction commands for this module +// governance ModuleClient is slightly different from other ModuleClients in that +// it contains a slice of "proposal" child commands. These commands are respective +// to proposal type handlers that are implemented in other modules but are mounted +// under the governance CLI (eg. parameter change proposals). +func NewTxCmd( + cdc codec.Marshaler, + txg tx.Generator, + ar tx.AccountRetriever, + newMsgFn func() types.MsgSubmitProposalI, + pcmds []*cobra.Command) *cobra.Command { + govTxCmd := &cobra.Command{ + Use: types.ModuleName, + Short: "Governance transactions subcommands", + DisableFlagParsing: true, + SuggestionsMinimumDistance: 2, + RunE: client.ValidateCmd, + } + + cmdSubmitProp := NewCmdSubmitProposal(cdc, txg, ar, newMsgFn) + for _, pcmd := range pcmds { + cmdSubmitProp.AddCommand(flags.PostCommands(pcmd)[0]) + } + + govTxCmd.AddCommand(flags.PostCommands( + NewCmdDeposit(cdc, txg, ar), + NewCmdVote(cdc, txg, ar), + cmdSubmitProp, + )...) + + return govTxCmd +} + +// NewCmdSubmitProposal implements submitting a proposal transaction command. +func NewCmdSubmitProposal( + cdc codec.Marshaler, + txg tx.Generator, + ar tx.AccountRetriever, + newMsgFn func() types.MsgSubmitProposalI) *cobra.Command { + cmd := &cobra.Command{ + Use: "submit-proposal", + Short: "Submit a proposal along with an initial deposit", + Long: strings.TrimSpace( + fmt.Sprintf(`Submit a proposal along with an initial deposit. +Proposal title, description, type and deposit can be given directly or through a proposal JSON file. + +Example: +$ %s tx gov submit-proposal --proposal="path/to/proposal.json" --from mykey + +Where proposal.json contains: + +{ + "title": "Test Proposal", + "description": "My awesome proposal", + "type": "Text", + "deposit": "10test" +} + +Which is equivalent to: + +$ %s tx gov submit-proposal --title="Test Proposal" --description="My awesome proposal" --type="Text" --deposit="10test" --from mykey +`, + version.ClientName, version.ClientName, + ), + ), + RunE: func(cmd *cobra.Command, args []string) error { + inBuf := bufio.NewReader(cmd.InOrStdin()) + cliCtx := context.NewCLIContextWithInput(inBuf).WithMarshaler(cdc) + txf := tx.NewFactoryFromCLI(inBuf).WithTxGenerator(txg).WithAccountRetriever(ar) + + proposal, err := parseSubmitProposalFlags() + if err != nil { + return err + } + + amount, err := sdk.ParseCoins(proposal.Deposit) + if err != nil { + return err + } + + content := types.ContentFromProposalType(proposal.Title, proposal.Description, proposal.Type) + + msg := newMsgFn() + err = msg.SetContent(content) + if err != nil { + return err + } + msg.SetInitialDeposit(amount) + msg.SetProposer(cliCtx.FromAddress) + + if err = msg.ValidateBasic(); err != nil { + return err + } + + return tx.GenerateOrBroadcastTx(cliCtx, txf, msg) + }, + } + + cmd.Flags().String(FlagTitle, "", "title of proposal") + cmd.Flags().String(FlagDescription, "", "description of proposal") + cmd.Flags().String(flagProposalType, "", "proposalType of proposal, types: text/parameter_change/software_upgrade") + cmd.Flags().String(FlagDeposit, "", "deposit of proposal") + cmd.Flags().String(FlagProposal, "", "proposal file path (if this path is given, other proposal flags are ignored)") + + return cmd +} + +// NewCmdDeposit implements depositing tokens for an active proposal. +func NewCmdDeposit(cdc codec.Marshaler, txg tx.Generator, ar tx.AccountRetriever) *cobra.Command { + return &cobra.Command{ + Use: "deposit [proposal-id] [deposit]", + Args: cobra.ExactArgs(2), + Short: "Deposit tokens for an active proposal", + Long: strings.TrimSpace( + fmt.Sprintf(`Submit a deposit for an active proposal. You can +find the proposal-id by running "%s query gov proposals". + +Example: +$ %s tx gov deposit 1 10stake --from mykey +`, + version.ClientName, version.ClientName, + ), + ), + RunE: func(cmd *cobra.Command, args []string) error { + inBuf := bufio.NewReader(cmd.InOrStdin()) + cliCtx := context.NewCLIContextWithInput(inBuf).WithMarshaler(cdc) + txf := tx.NewFactoryFromCLI(inBuf).WithTxGenerator(txg).WithAccountRetriever(ar) + + // validate that the proposal id is a uint + proposalID, err := strconv.ParseUint(args[0], 10, 64) + if err != nil { + return fmt.Errorf("proposal-id %s not a valid uint, please input a valid proposal-id", args[0]) + } + + // Get depositor address + from := cliCtx.GetFromAddress() + + // Get amount of coins + amount, err := sdk.ParseCoins(args[1]) + if err != nil { + return err + } + + msg := types.NewMsgDeposit(from, proposalID, amount) + err = msg.ValidateBasic() + if err != nil { + return err + } + + return tx.GenerateOrBroadcastTx(cliCtx, txf, msg) + }, + } +} + +// NewCmdVote implements creating a new vote command. +func NewCmdVote(cdc codec.Marshaler, txg tx.Generator, ar tx.AccountRetriever) *cobra.Command { + return &cobra.Command{ + Use: "vote [proposal-id] [option]", + Args: cobra.ExactArgs(2), + Short: "Vote for an active proposal, options: yes/no/no_with_veto/abstain", + Long: strings.TrimSpace( + fmt.Sprintf(`Submit a vote for an active proposal. You can +find the proposal-id by running "%s query gov proposals". + + +Example: +$ %s tx gov vote 1 yes --from mykey +`, + version.ClientName, version.ClientName, + ), + ), + RunE: func(cmd *cobra.Command, args []string) error { + inBuf := bufio.NewReader(cmd.InOrStdin()) + cliCtx := context.NewCLIContextWithInput(inBuf).WithMarshaler(cdc) + txf := tx.NewFactoryFromCLI(inBuf).WithTxGenerator(txg).WithAccountRetriever(ar) + + // Get voting address + from := cliCtx.GetFromAddress() + + // validate that the proposal id is a uint + proposalID, err := strconv.ParseUint(args[0], 10, 64) + if err != nil { + return fmt.Errorf("proposal-id %s not a valid int, please input a valid proposal-id", args[0]) + } + + // Find out which vote option user chose + byteVoteOption, err := types.VoteOptionFromString(govutils.NormalizeVoteOption(args[1])) + if err != nil { + return err + } + + // Build vote message and run basic validation + msg := types.NewMsgVote(from, proposalID, byteVoteOption) + err = msg.ValidateBasic() + if err != nil { + return err + } + + return tx.GenerateOrBroadcastTx(cliCtx, txf, msg) + }, + } +} + // GetTxCmd returns the transaction commands for this module // governance ModuleClient is slightly different from other ModuleClients in that // it contains a slice of "proposal" child commands. These commands are respective diff --git a/x/gov/client/rest/rest.go b/x/gov/client/rest/rest.go index eca37e3644..b00b36b317 100644 --- a/x/gov/client/rest/rest.go +++ b/x/gov/client/rest/rest.go @@ -3,6 +3,11 @@ package rest import ( "net/http" + "github.com/cosmos/cosmos-sdk/codec" + + "github.com/cosmos/cosmos-sdk/client/tx" + "github.com/cosmos/cosmos-sdk/x/gov/types" + "github.com/gorilla/mux" "github.com/cosmos/cosmos-sdk/client/context" @@ -28,6 +33,11 @@ type ProposalRESTHandler struct { Handler func(http.ResponseWriter, *http.Request) } +func RegisterHandlers(cliCtx context.CLIContext, m codec.Marshaler, txg tx.Generator, r *mux.Router, msgSubmitProposalCtr func() types.MsgSubmitProposalI, phs []ProposalRESTHandler) { + registerQueryRoutes(cliCtx, r) + registerTxHandlers(cliCtx, m, txg, r, msgSubmitProposalCtr, phs) +} + // RegisterRoutes - Central function to define routes that get registered by the main application func RegisterRoutes(cliCtx context.CLIContext, r *mux.Router, phs []ProposalRESTHandler) { registerQueryRoutes(cliCtx, r) diff --git a/x/gov/client/rest/tx.go b/x/gov/client/rest/tx.go index 627525a49a..58a069b661 100644 --- a/x/gov/client/rest/tx.go +++ b/x/gov/client/rest/tx.go @@ -4,9 +4,12 @@ import ( "fmt" "net/http" + "github.com/cosmos/cosmos-sdk/codec" + "github.com/gorilla/mux" "github.com/cosmos/cosmos-sdk/client/context" + "github.com/cosmos/cosmos-sdk/client/tx" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/rest" authclient "github.com/cosmos/cosmos-sdk/x/auth/client" @@ -14,6 +17,128 @@ import ( "github.com/cosmos/cosmos-sdk/x/gov/types" ) +func registerTxHandlers(cliCtx context.CLIContext, m codec.Marshaler, txg tx.Generator, r *mux.Router, newMsgFn func() types.MsgSubmitProposalI, phs []ProposalRESTHandler) { + propSubRtr := r.PathPrefix("/gov/proposals").Subrouter() + for _, ph := range phs { + propSubRtr.HandleFunc(fmt.Sprintf("/%s", ph.SubRoute), ph.Handler).Methods("POST") + } + + cliCtx = cliCtx.WithMarshaler(m) + r.HandleFunc("/gov/proposals", newPostProposalHandlerFn(cliCtx, m, txg, newMsgFn)).Methods("POST") + r.HandleFunc(fmt.Sprintf("/gov/proposals/{%s}/deposits", RestProposalID), newDepositHandlerFn(cliCtx, txg)).Methods("POST") + r.HandleFunc(fmt.Sprintf("/gov/proposals/{%s}/votes", RestProposalID), newVoteHandlerFn(cliCtx, txg)).Methods("POST") +} + +func newPostProposalHandlerFn(cliCtx context.CLIContext, m codec.Marshaler, txg tx.Generator, newMsgFn func() types.MsgSubmitProposalI) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + var req PostProposalReq + if !rest.ReadRESTReq(w, r, cliCtx.Codec, &req) { + return + } + + req.BaseReq = req.BaseReq.Sanitize() + if !req.BaseReq.ValidateBasic(w) { + return + } + + proposalType := gcutils.NormalizeProposalType(req.ProposalType) + content := types.ContentFromProposalType(req.Title, req.Description, proposalType) + + msg := newMsgFn() + err := msg.SetContent(content) + if rest.CheckBadRequestError(w, err) { + return + } + msg.SetInitialDeposit(req.InitialDeposit) + msg.SetProposer(req.Proposer) + if rest.CheckBadRequestError(w, msg.ValidateBasic()) { + return + } + + tx.WriteGeneratedTxResponse(cliCtx, w, txg, req.BaseReq, msg) + } +} + +func newDepositHandlerFn(cliCtx context.CLIContext, txg tx.Generator) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + vars := mux.Vars(r) + strProposalID := vars[RestProposalID] + + if len(strProposalID) == 0 { + rest.WriteErrorResponse(w, http.StatusBadRequest, "proposalId required but not specified") + return + } + + proposalID, ok := rest.ParseUint64OrReturnBadRequest(w, strProposalID) + if !ok { + return + } + + var req DepositReq + if !rest.ReadRESTReq(w, r, cliCtx.Codec, &req) { + return + } + + req.BaseReq = req.BaseReq.Sanitize() + if !req.BaseReq.ValidateBasic(w) { + return + } + + // create the message + msg := types.NewMsgDeposit(req.Depositor, proposalID, req.Amount) + if rest.CheckBadRequestError(w, msg.ValidateBasic()) { + return + } + + tx.WriteGeneratedTxResponse(cliCtx, w, txg, req.BaseReq, msg) + } +} + +func newVoteHandlerFn(cliCtx context.CLIContext, txg tx.Generator) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + vars := mux.Vars(r) + strProposalID := vars[RestProposalID] + + if len(strProposalID) == 0 { + rest.WriteErrorResponse(w, http.StatusBadRequest, "proposalId required but not specified") + return + } + + proposalID, ok := rest.ParseUint64OrReturnBadRequest(w, strProposalID) + if !ok { + return + } + + var req VoteReq + if !rest.ReadRESTReq(w, r, cliCtx.Codec, &req) { + return + } + + req.BaseReq = req.BaseReq.Sanitize() + if !req.BaseReq.ValidateBasic(w) { + return + } + + voteOption, err := types.VoteOptionFromString(gcutils.NormalizeVoteOption(req.Option)) + if rest.CheckBadRequestError(w, err) { + return + } + + // create the message + msg := types.NewMsgVote(req.Voter, proposalID, voteOption) + if rest.CheckBadRequestError(w, msg.ValidateBasic()) { + return + } + + tx.WriteGeneratedTxResponse(cliCtx, w, txg, req.BaseReq, msg) + } +} + +// --------------------------------------------------------------------------- +// Deprecated +// +// TODO: Remove once client-side Protobuf migration has been completed. +// --------------------------------------------------------------------------- func registerTxRoutes(cliCtx context.CLIContext, r *mux.Router, phs []ProposalRESTHandler) { propSubRtr := r.PathPrefix("/gov/proposals").Subrouter() for _, ph := range phs { diff --git a/x/gov/keeper/proposal_test.go b/x/gov/keeper/proposal_test.go index a02b6da72a..aa176b473a 100644 --- a/x/gov/keeper/proposal_test.go +++ b/x/gov/keeper/proposal_test.go @@ -66,14 +66,14 @@ func TestSubmitProposal(t *testing.T) { content types.Content expectedErr error }{ - {types.TextProposal{Title: "title", Description: "description"}, nil}, + {&types.TextProposal{Title: "title", Description: "description"}, nil}, // Keeper does not check the validity of title and description, no error - {types.TextProposal{Title: "", Description: "description"}, nil}, - {types.TextProposal{Title: strings.Repeat("1234567890", 100), Description: "description"}, nil}, - {types.TextProposal{Title: "title", Description: ""}, nil}, - {types.TextProposal{Title: "title", Description: strings.Repeat("1234567890", 1000)}, nil}, + {&types.TextProposal{Title: "", Description: "description"}, nil}, + {&types.TextProposal{Title: strings.Repeat("1234567890", 100), Description: "description"}, nil}, + {&types.TextProposal{Title: "title", Description: ""}, nil}, + {&types.TextProposal{Title: "title", Description: strings.Repeat("1234567890", 1000)}, nil}, // error only when invalid route - {invalidProposalRoute{}, types.ErrNoProposalHandlerExists}, + {&invalidProposalRoute{}, types.ErrNoProposalHandlerExists}, } for i, tc := range testCases { diff --git a/x/gov/simulation/operations.go b/x/gov/simulation/operations.go index 883a2a5ed1..c45069eec9 100644 --- a/x/gov/simulation/operations.go +++ b/x/gov/simulation/operations.go @@ -5,6 +5,8 @@ import ( "math/rand" "time" + "github.com/cosmos/cosmos-sdk/codec/std" + "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/simapp/helpers" @@ -125,7 +127,10 @@ func SimulateSubmitProposal( return simtypes.NoOpMsg(types.ModuleName), nil, err } - msg := types.NewMsgSubmitProposal(content, deposit, simAccount.Address) + msg, err := std.NewMsgSubmitProposal(content, deposit, simAccount.Address) + if err != nil { + return simtypes.NoOpMsg(types.ModuleName), nil, err + } account := ak.GetAccount(ctx, simAccount.Address) spendable := bk.SpendableCoins(ctx, account.GetAddress()) diff --git a/x/gov/types/codec.go b/x/gov/types/codec.go index e4d7e16a32..0974df2ed2 100644 --- a/x/gov/types/codec.go +++ b/x/gov/types/codec.go @@ -17,10 +17,10 @@ type Codec interface { func RegisterCodec(cdc *codec.Codec) { cdc.RegisterInterface((*Content)(nil), nil) cdc.RegisterConcrete(MsgSubmitProposalBase{}, "cosmos-sdk/MsgSubmitProposalBase", nil) - cdc.RegisterConcrete(MsgSubmitProposal{}, "cosmos-sdk/MsgSubmitProposal", nil) + cdc.RegisterConcrete(&MsgSubmitProposal{}, "cosmos-sdk/MsgSubmitProposal", nil) cdc.RegisterConcrete(MsgDeposit{}, "cosmos-sdk/MsgDeposit", nil) cdc.RegisterConcrete(MsgVote{}, "cosmos-sdk/MsgVote", nil) - cdc.RegisterConcrete(TextProposal{}, "cosmos-sdk/TextProposal", nil) + cdc.RegisterConcrete(&TextProposal{}, "cosmos-sdk/TextProposal", nil) } // RegisterProposalTypeCodec registers an external proposal content type defined diff --git a/x/gov/types/msgs.go b/x/gov/types/msgs.go index 559a343e57..5f5beb6485 100644 --- a/x/gov/types/msgs.go +++ b/x/gov/types/msgs.go @@ -23,8 +23,13 @@ type MsgSubmitProposalI interface { sdk.Msg GetContent() Content + SetContent(Content) error + GetInitialDeposit() sdk.Coins + SetInitialDeposit(sdk.Coins) + GetProposer() sdk.AccAddress + SetProposer(sdk.AccAddress) } // NewMsgSubmitProposalBase creates a new MsgSubmitProposalBase. @@ -35,6 +40,18 @@ func NewMsgSubmitProposalBase(initialDeposit sdk.Coins, proposer sdk.AccAddress) } } +func (msg *MsgSubmitProposalBase) GetInitialDeposit() sdk.Coins { return msg.InitialDeposit } + +func (msg *MsgSubmitProposalBase) GetProposer() sdk.AccAddress { return msg.Proposer } + +func (msg *MsgSubmitProposalBase) SetInitialDeposit(coins sdk.Coins) { + msg.InitialDeposit = coins +} + +func (msg *MsgSubmitProposalBase) SetProposer(address sdk.AccAddress) { + msg.Proposer = address +} + // Route implements Msg func (msg MsgSubmitProposalBase) Route() string { return RouterKey } @@ -172,6 +189,8 @@ type MsgSubmitProposal struct { Proposer sdk.AccAddress `json:"proposer" yaml:"proposer"` // Address of the proposer } +var _ MsgSubmitProposalI = &MsgSubmitProposal{} + // NewMsgSubmitProposal returns a (deprecated) MsgSubmitProposal message. // // TODO: Remove once client-side Protobuf migration has been completed. @@ -213,3 +232,16 @@ func (msg MsgSubmitProposal) Type() string { return TypeMsgSubmi func (msg MsgSubmitProposal) GetContent() Content { return msg.Content } func (msg MsgSubmitProposal) GetInitialDeposit() sdk.Coins { return msg.InitialDeposit } func (msg MsgSubmitProposal) GetProposer() sdk.AccAddress { return msg.Proposer } + +func (msg *MsgSubmitProposal) SetContent(content Content) error { + msg.Content = content + return nil +} + +func (msg *MsgSubmitProposal) SetInitialDeposit(deposit sdk.Coins) { + msg.InitialDeposit = deposit +} + +func (msg *MsgSubmitProposal) SetProposer(proposer sdk.AccAddress) { + msg.Proposer = proposer +} diff --git a/x/gov/types/proposal.go b/x/gov/types/proposal.go index 9e65ec3c90..60f888d30e 100644 --- a/x/gov/types/proposal.go +++ b/x/gov/types/proposal.go @@ -195,27 +195,27 @@ const ( ) // Implements Content Interface -var _ Content = TextProposal{} +var _ Content = &TextProposal{} // NewTextProposal creates a text proposal Content func NewTextProposal(title, description string) Content { - return TextProposal{title, description} + return &TextProposal{title, description} } // GetTitle returns the proposal title -func (tp TextProposal) GetTitle() string { return tp.Title } +func (tp *TextProposal) GetTitle() string { return tp.Title } // GetDescription returns the proposal description -func (tp TextProposal) GetDescription() string { return tp.Description } +func (tp *TextProposal) GetDescription() string { return tp.Description } // ProposalRoute returns the proposal router key -func (tp TextProposal) ProposalRoute() string { return RouterKey } +func (tp *TextProposal) ProposalRoute() string { return RouterKey } // ProposalType is "Text" -func (tp TextProposal) ProposalType() string { return ProposalTypeText } +func (tp *TextProposal) ProposalType() string { return ProposalTypeText } // ValidateBasic validates the content's title and description of the proposal -func (tp TextProposal) ValidateBasic() error { return ValidateAbstract(tp) } +func (tp *TextProposal) ValidateBasic() error { return ValidateAbstract(tp) } // String implements Stringer interface func (tp TextProposal) String() string { diff --git a/x/params/proposal_handler.go b/x/params/proposal_handler.go index 6af7668aa3..173cc292df 100644 --- a/x/params/proposal_handler.go +++ b/x/params/proposal_handler.go @@ -14,7 +14,7 @@ import ( func NewParamChangeProposalHandler(k keeper.Keeper) govtypes.Handler { return func(ctx sdk.Context, content govtypes.Content) error { switch c := content.(type) { - case proposal.ParameterChangeProposal: + case *proposal.ParameterChangeProposal: return handleParameterChangeProposal(ctx, k, c) default: @@ -23,7 +23,7 @@ func NewParamChangeProposalHandler(k keeper.Keeper) govtypes.Handler { } } -func handleParameterChangeProposal(ctx sdk.Context, k keeper.Keeper, p proposal.ParameterChangeProposal) error { +func handleParameterChangeProposal(ctx sdk.Context, k keeper.Keeper, p *proposal.ParameterChangeProposal) error { for _, c := range p.Changes { ss, ok := k.GetSubspace(c.Subspace) if !ok { diff --git a/x/params/proposal_handler_test.go b/x/params/proposal_handler_test.go index e15fea3596..ddbb81fb7c 100644 --- a/x/params/proposal_handler_test.go +++ b/x/params/proposal_handler_test.go @@ -51,7 +51,7 @@ func (tp *testParams) ParamSetPairs() types.ParamSetPairs { } } -func testProposal(changes ...proposal.ParamChange) proposal.ParameterChangeProposal { +func testProposal(changes ...proposal.ParamChange) *proposal.ParameterChangeProposal { return proposal.NewParameterChangeProposal( "Test", "description", diff --git a/x/params/types/proposal/codec.go b/x/params/types/proposal/codec.go index 8160d51c1a..694b0b3c03 100644 --- a/x/params/types/proposal/codec.go +++ b/x/params/types/proposal/codec.go @@ -28,5 +28,5 @@ func init() { // RegisterCodec registers all necessary param module types with a given codec. func RegisterCodec(cdc *codec.Codec) { - cdc.RegisterConcrete(ParameterChangeProposal{}, "cosmos-sdk/ParameterChangeProposal", nil) + cdc.RegisterConcrete(&ParameterChangeProposal{}, "cosmos-sdk/ParameterChangeProposal", nil) } diff --git a/x/params/types/proposal/proposal.go b/x/params/types/proposal/proposal.go index 60fd6ce800..4480795789 100644 --- a/x/params/types/proposal/proposal.go +++ b/x/params/types/proposal/proposal.go @@ -15,31 +15,31 @@ const ( ) // Assert ParameterChangeProposal implements govtypes.Content at compile-time -var _ govtypes.Content = ParameterChangeProposal{} +var _ govtypes.Content = &ParameterChangeProposal{} func init() { govtypes.RegisterProposalType(ProposalTypeChange) - govtypes.RegisterProposalTypeCodec(ParameterChangeProposal{}, "cosmos-sdk/ParameterChangeProposal") + govtypes.RegisterProposalTypeCodec(&ParameterChangeProposal{}, "cosmos-sdk/ParameterChangeProposal") } -func NewParameterChangeProposal(title, description string, changes []ParamChange) ParameterChangeProposal { - return ParameterChangeProposal{title, description, changes} +func NewParameterChangeProposal(title, description string, changes []ParamChange) *ParameterChangeProposal { + return &ParameterChangeProposal{title, description, changes} } // GetTitle returns the title of a parameter change proposal. -func (pcp ParameterChangeProposal) GetTitle() string { return pcp.Title } +func (pcp *ParameterChangeProposal) GetTitle() string { return pcp.Title } // GetDescription returns the description of a parameter change proposal. -func (pcp ParameterChangeProposal) GetDescription() string { return pcp.Description } +func (pcp *ParameterChangeProposal) GetDescription() string { return pcp.Description } // ProposalRoute returns the routing key of a parameter change proposal. -func (pcp ParameterChangeProposal) ProposalRoute() string { return RouterKey } +func (pcp *ParameterChangeProposal) ProposalRoute() string { return RouterKey } // ProposalType returns the type of a parameter change proposal. -func (pcp ParameterChangeProposal) ProposalType() string { return ProposalTypeChange } +func (pcp *ParameterChangeProposal) ProposalType() string { return ProposalTypeChange } // ValidateBasic validates the parameter change proposal -func (pcp ParameterChangeProposal) ValidateBasic() error { +func (pcp *ParameterChangeProposal) ValidateBasic() error { err := govtypes.ValidateAbstract(pcp) if err != nil { return err diff --git a/x/upgrade/abci_test.go b/x/upgrade/abci_test.go index aa2bf33cfb..131cdd7853 100644 --- a/x/upgrade/abci_test.go +++ b/x/upgrade/abci_test.go @@ -61,28 +61,28 @@ func setupTest(height int64, skip map[int64]bool) TestSuite { func TestRequireName(t *testing.T) { s := setupTest(10, map[int64]bool{}) - err := s.handler(s.ctx, upgrade.SoftwareUpgradeProposal{Title: "prop", Plan: upgrade.Plan{}}) + err := s.handler(s.ctx, &upgrade.SoftwareUpgradeProposal{Title: "prop", Plan: upgrade.Plan{}}) require.NotNil(t, err) require.True(t, errors.Is(sdkerrors.ErrInvalidRequest, err), err) } func TestRequireFutureTime(t *testing.T) { s := setupTest(10, map[int64]bool{}) - err := s.handler(s.ctx, upgrade.SoftwareUpgradeProposal{Title: "prop", Plan: upgrade.Plan{Name: "test", Time: s.ctx.BlockHeader().Time}}) + err := s.handler(s.ctx, &upgrade.SoftwareUpgradeProposal{Title: "prop", Plan: upgrade.Plan{Name: "test", Time: s.ctx.BlockHeader().Time}}) require.NotNil(t, err) require.True(t, errors.Is(sdkerrors.ErrInvalidRequest, err), err) } func TestRequireFutureBlock(t *testing.T) { s := setupTest(10, map[int64]bool{}) - err := s.handler(s.ctx, upgrade.SoftwareUpgradeProposal{Title: "prop", Plan: upgrade.Plan{Name: "test", Height: s.ctx.BlockHeight()}}) + err := s.handler(s.ctx, &upgrade.SoftwareUpgradeProposal{Title: "prop", Plan: upgrade.Plan{Name: "test", Height: s.ctx.BlockHeight()}}) require.NotNil(t, err) require.True(t, errors.Is(sdkerrors.ErrInvalidRequest, err), err) } func TestCantSetBothTimeAndHeight(t *testing.T) { s := setupTest(10, map[int64]bool{}) - err := s.handler(s.ctx, upgrade.SoftwareUpgradeProposal{Title: "prop", Plan: upgrade.Plan{Name: "test", Time: time.Now(), Height: s.ctx.BlockHeight() + 1}}) + err := s.handler(s.ctx, &upgrade.SoftwareUpgradeProposal{Title: "prop", Plan: upgrade.Plan{Name: "test", Time: time.Now(), Height: s.ctx.BlockHeight() + 1}}) require.NotNil(t, err) require.True(t, errors.Is(sdkerrors.ErrInvalidRequest, err), err) } @@ -90,7 +90,7 @@ func TestCantSetBothTimeAndHeight(t *testing.T) { func TestDoTimeUpgrade(t *testing.T) { s := setupTest(10, map[int64]bool{}) t.Log("Verify can schedule an upgrade") - err := s.handler(s.ctx, upgrade.SoftwareUpgradeProposal{Title: "prop", Plan: upgrade.Plan{Name: "test", Time: time.Now()}}) + err := s.handler(s.ctx, &upgrade.SoftwareUpgradeProposal{Title: "prop", Plan: upgrade.Plan{Name: "test", Time: time.Now()}}) require.Nil(t, err) VerifyDoUpgrade(t) @@ -99,7 +99,7 @@ func TestDoTimeUpgrade(t *testing.T) { func TestDoHeightUpgrade(t *testing.T) { s := setupTest(10, map[int64]bool{}) t.Log("Verify can schedule an upgrade") - err := s.handler(s.ctx, upgrade.SoftwareUpgradeProposal{Title: "prop", Plan: upgrade.Plan{Name: "test", Height: s.ctx.BlockHeight() + 1}}) + err := s.handler(s.ctx, &upgrade.SoftwareUpgradeProposal{Title: "prop", Plan: upgrade.Plan{Name: "test", Height: s.ctx.BlockHeight() + 1}}) require.Nil(t, err) VerifyDoUpgrade(t) @@ -108,9 +108,9 @@ func TestDoHeightUpgrade(t *testing.T) { func TestCanOverwriteScheduleUpgrade(t *testing.T) { s := setupTest(10, map[int64]bool{}) t.Log("Can overwrite plan") - err := s.handler(s.ctx, upgrade.SoftwareUpgradeProposal{Title: "prop", Plan: upgrade.Plan{Name: "bad_test", Height: s.ctx.BlockHeight() + 10}}) + err := s.handler(s.ctx, &upgrade.SoftwareUpgradeProposal{Title: "prop", Plan: upgrade.Plan{Name: "bad_test", Height: s.ctx.BlockHeight() + 10}}) require.Nil(t, err) - err = s.handler(s.ctx, upgrade.SoftwareUpgradeProposal{Title: "prop", Plan: upgrade.Plan{Name: "test", Height: s.ctx.BlockHeight() + 1}}) + err = s.handler(s.ctx, &upgrade.SoftwareUpgradeProposal{Title: "prop", Plan: upgrade.Plan{Name: "test", Height: s.ctx.BlockHeight() + 1}}) require.Nil(t, err) VerifyDoUpgrade(t) @@ -164,7 +164,7 @@ func TestHaltIfTooNew(t *testing.T) { require.Equal(t, 0, called) t.Log("Verify we panic if we have a registered handler ahead of time") - err := s.handler(s.ctx, upgrade.SoftwareUpgradeProposal{Title: "prop", Plan: upgrade.Plan{Name: "future", Height: s.ctx.BlockHeight() + 3}}) + err := s.handler(s.ctx, &upgrade.SoftwareUpgradeProposal{Title: "prop", Plan: upgrade.Plan{Name: "future", Height: s.ctx.BlockHeight() + 3}}) require.NoError(t, err) require.Panics(t, func() { s.module.BeginBlock(newCtx, req) @@ -193,10 +193,10 @@ func VerifyCleared(t *testing.T, newCtx sdk.Context) { func TestCanClear(t *testing.T) { s := setupTest(10, map[int64]bool{}) t.Log("Verify upgrade is scheduled") - err := s.handler(s.ctx, upgrade.SoftwareUpgradeProposal{Title: "prop", Plan: upgrade.Plan{Name: "test", Time: time.Now()}}) + err := s.handler(s.ctx, &upgrade.SoftwareUpgradeProposal{Title: "prop", Plan: upgrade.Plan{Name: "test", Time: time.Now()}}) require.Nil(t, err) - err = s.handler(s.ctx, upgrade.CancelSoftwareUpgradeProposal{Title: "cancel"}) + err = s.handler(s.ctx, &upgrade.CancelSoftwareUpgradeProposal{Title: "cancel"}) require.Nil(t, err) VerifyCleared(t, s.ctx) @@ -204,11 +204,11 @@ func TestCanClear(t *testing.T) { func TestCantApplySameUpgradeTwice(t *testing.T) { s := setupTest(10, map[int64]bool{}) - err := s.handler(s.ctx, upgrade.SoftwareUpgradeProposal{Title: "prop", Plan: upgrade.Plan{Name: "test", Time: time.Now()}}) + err := s.handler(s.ctx, &upgrade.SoftwareUpgradeProposal{Title: "prop", Plan: upgrade.Plan{Name: "test", Time: time.Now()}}) require.Nil(t, err) VerifyDoUpgrade(t) t.Log("Verify an executed upgrade \"test\" can't be rescheduled") - err = s.handler(s.ctx, upgrade.SoftwareUpgradeProposal{Title: "prop", Plan: upgrade.Plan{Name: "test", Time: time.Now()}}) + err = s.handler(s.ctx, &upgrade.SoftwareUpgradeProposal{Title: "prop", Plan: upgrade.Plan{Name: "test", Time: time.Now()}}) require.NotNil(t, err) require.True(t, errors.Is(sdkerrors.ErrInvalidRequest, err), err) } @@ -279,7 +279,7 @@ func TestSkipUpgradeSkippingAll(t *testing.T) { newCtx := s.ctx req := abci.RequestBeginBlock{Header: newCtx.BlockHeader()} - err := s.handler(s.ctx, upgrade.SoftwareUpgradeProposal{Title: "prop", Plan: upgrade.Plan{Name: "test", Height: skipOne}}) + err := s.handler(s.ctx, &upgrade.SoftwareUpgradeProposal{Title: "prop", Plan: upgrade.Plan{Name: "test", Height: skipOne}}) require.NoError(t, err) t.Log("Verify if skip upgrade flag clears upgrade plan in both cases") @@ -291,7 +291,7 @@ func TestSkipUpgradeSkippingAll(t *testing.T) { }) t.Log("Verify a second proposal also is being cleared") - err = s.handler(s.ctx, upgrade.SoftwareUpgradeProposal{Title: "prop2", Plan: upgrade.Plan{Name: "test2", Height: skipTwo}}) + err = s.handler(s.ctx, &upgrade.SoftwareUpgradeProposal{Title: "prop2", Plan: upgrade.Plan{Name: "test2", Height: skipTwo}}) require.NoError(t, err) newCtx = newCtx.WithBlockHeight(skipTwo) @@ -316,7 +316,7 @@ func TestUpgradeSkippingOne(t *testing.T) { newCtx := s.ctx req := abci.RequestBeginBlock{Header: newCtx.BlockHeader()} - err := s.handler(s.ctx, upgrade.SoftwareUpgradeProposal{Title: "prop", Plan: upgrade.Plan{Name: "test", Height: skipOne}}) + err := s.handler(s.ctx, &upgrade.SoftwareUpgradeProposal{Title: "prop", Plan: upgrade.Plan{Name: "test", Height: skipOne}}) require.Nil(t, err) t.Log("Verify if skip upgrade flag clears upgrade plan in one case and does upgrade on another") @@ -329,7 +329,7 @@ func TestUpgradeSkippingOne(t *testing.T) { }) t.Log("Verify the second proposal is not skipped") - err = s.handler(s.ctx, upgrade.SoftwareUpgradeProposal{Title: "prop2", Plan: upgrade.Plan{Name: "test2", Height: skipTwo}}) + err = s.handler(s.ctx, &upgrade.SoftwareUpgradeProposal{Title: "prop2", Plan: upgrade.Plan{Name: "test2", Height: skipTwo}}) require.Nil(t, err) // Setting block height of proposal test2 newCtx = newCtx.WithBlockHeight(skipTwo) @@ -351,7 +351,7 @@ func TestUpgradeSkippingOnlyTwo(t *testing.T) { newCtx := s.ctx req := abci.RequestBeginBlock{Header: newCtx.BlockHeader()} - err := s.handler(s.ctx, upgrade.SoftwareUpgradeProposal{Title: "prop", Plan: upgrade.Plan{Name: "test", Height: skipOne}}) + err := s.handler(s.ctx, &upgrade.SoftwareUpgradeProposal{Title: "prop", Plan: upgrade.Plan{Name: "test", Height: skipOne}}) require.Nil(t, err) t.Log("Verify if skip upgrade flag clears upgrade plan in both cases and does third upgrade") @@ -364,7 +364,7 @@ func TestUpgradeSkippingOnlyTwo(t *testing.T) { }) // A new proposal with height in skipUpgradeHeights - err = s.handler(s.ctx, upgrade.SoftwareUpgradeProposal{Title: "prop2", Plan: upgrade.Plan{Name: "test2", Height: skipTwo}}) + err = s.handler(s.ctx, &upgrade.SoftwareUpgradeProposal{Title: "prop2", Plan: upgrade.Plan{Name: "test2", Height: skipTwo}}) require.Nil(t, err) // Setting block height of proposal test2 newCtx = newCtx.WithBlockHeight(skipTwo) @@ -373,7 +373,7 @@ func TestUpgradeSkippingOnlyTwo(t *testing.T) { }) t.Log("Verify a new proposal is not skipped") - err = s.handler(s.ctx, upgrade.SoftwareUpgradeProposal{Title: "prop3", Plan: upgrade.Plan{Name: "test3", Height: skipThree}}) + err = s.handler(s.ctx, &upgrade.SoftwareUpgradeProposal{Title: "prop3", Plan: upgrade.Plan{Name: "test3", Height: skipThree}}) require.Nil(t, err) newCtx = newCtx.WithBlockHeight(skipThree) VerifyDoUpgradeWithCtx(t, newCtx, "test3") @@ -388,7 +388,7 @@ func TestUpgradeWithoutSkip(t *testing.T) { s := setupTest(10, map[int64]bool{}) newCtx := s.ctx.WithBlockHeight(s.ctx.BlockHeight() + 1).WithBlockTime(time.Now()) req := abci.RequestBeginBlock{Header: newCtx.BlockHeader()} - err := s.handler(s.ctx, upgrade.SoftwareUpgradeProposal{Title: "prop", Plan: upgrade.Plan{Name: "test", Height: s.ctx.BlockHeight() + 1}}) + err := s.handler(s.ctx, &upgrade.SoftwareUpgradeProposal{Title: "prop", Plan: upgrade.Plan{Name: "test", Height: s.ctx.BlockHeight() + 1}}) require.Nil(t, err) t.Log("Verify if upgrade happens without skip upgrade") require.Panics(t, func() { diff --git a/x/upgrade/handler.go b/x/upgrade/handler.go index 8a4a9f89ab..d98d0a5da6 100644 --- a/x/upgrade/handler.go +++ b/x/upgrade/handler.go @@ -12,10 +12,10 @@ import ( func NewSoftwareUpgradeProposalHandler(k Keeper) govtypes.Handler { return func(ctx sdk.Context, content govtypes.Content) error { switch c := content.(type) { - case SoftwareUpgradeProposal: + case *SoftwareUpgradeProposal: return handleSoftwareUpgradeProposal(ctx, k, c) - case CancelSoftwareUpgradeProposal: + case *CancelSoftwareUpgradeProposal: return handleCancelSoftwareUpgradeProposal(ctx, k, c) default: @@ -24,11 +24,11 @@ func NewSoftwareUpgradeProposalHandler(k Keeper) govtypes.Handler { } } -func handleSoftwareUpgradeProposal(ctx sdk.Context, k Keeper, p SoftwareUpgradeProposal) error { +func handleSoftwareUpgradeProposal(ctx sdk.Context, k Keeper, p *SoftwareUpgradeProposal) error { return k.ScheduleUpgrade(ctx, p.Plan) } -func handleCancelSoftwareUpgradeProposal(ctx sdk.Context, k Keeper, p CancelSoftwareUpgradeProposal) error { +func handleCancelSoftwareUpgradeProposal(ctx sdk.Context, k Keeper, _ *CancelSoftwareUpgradeProposal) error { k.ClearUpgradePlan(ctx) return nil } diff --git a/x/upgrade/types/codec.go b/x/upgrade/types/codec.go index 4a8b07cfbb..78ad0af013 100644 --- a/x/upgrade/types/codec.go +++ b/x/upgrade/types/codec.go @@ -7,6 +7,6 @@ import ( // RegisterCodec registers concrete types on the Amino codec func RegisterCodec(cdc *codec.Codec) { cdc.RegisterConcrete(Plan{}, "cosmos-sdk/Plan", nil) - cdc.RegisterConcrete(SoftwareUpgradeProposal{}, "cosmos-sdk/SoftwareUpgradeProposal", nil) - cdc.RegisterConcrete(CancelSoftwareUpgradeProposal{}, "cosmos-sdk/CancelSoftwareUpgradeProposal", nil) + cdc.RegisterConcrete(&SoftwareUpgradeProposal{}, "cosmos-sdk/SoftwareUpgradeProposal", nil) + cdc.RegisterConcrete(&CancelSoftwareUpgradeProposal{}, "cosmos-sdk/CancelSoftwareUpgradeProposal", nil) } diff --git a/x/upgrade/types/proposal.go b/x/upgrade/types/proposal.go index 2067110e74..bc7acc7b7a 100644 --- a/x/upgrade/types/proposal.go +++ b/x/upgrade/types/proposal.go @@ -3,7 +3,7 @@ package types import ( "fmt" - "github.com/cosmos/cosmos-sdk/x/gov" + gov "github.com/cosmos/cosmos-sdk/x/gov/types" ) const ( @@ -12,25 +12,25 @@ const ( ) func NewSoftwareUpgradeProposal(title, description string, plan Plan) gov.Content { - return SoftwareUpgradeProposal{title, description, plan} + return &SoftwareUpgradeProposal{title, description, plan} } // Implements Proposal Interface -var _ gov.Content = SoftwareUpgradeProposal{} +var _ gov.Content = &SoftwareUpgradeProposal{} func init() { gov.RegisterProposalType(ProposalTypeSoftwareUpgrade) - gov.RegisterProposalTypeCodec(SoftwareUpgradeProposal{}, "cosmos-sdk/SoftwareUpgradeProposal") + gov.RegisterProposalTypeCodec(&SoftwareUpgradeProposal{}, "cosmos-sdk/SoftwareUpgradeProposal") gov.RegisterProposalType(ProposalTypeCancelSoftwareUpgrade) - gov.RegisterProposalTypeCodec(CancelSoftwareUpgradeProposal{}, "cosmos-sdk/CancelSoftwareUpgradeProposal") + gov.RegisterProposalTypeCodec(&CancelSoftwareUpgradeProposal{}, "cosmos-sdk/CancelSoftwareUpgradeProposal") } // nolint -func (sup SoftwareUpgradeProposal) GetTitle() string { return sup.Title } -func (sup SoftwareUpgradeProposal) GetDescription() string { return sup.Description } -func (sup SoftwareUpgradeProposal) ProposalRoute() string { return RouterKey } -func (sup SoftwareUpgradeProposal) ProposalType() string { return ProposalTypeSoftwareUpgrade } -func (sup SoftwareUpgradeProposal) ValidateBasic() error { +func (sup *SoftwareUpgradeProposal) GetTitle() string { return sup.Title } +func (sup *SoftwareUpgradeProposal) GetDescription() string { return sup.Description } +func (sup *SoftwareUpgradeProposal) ProposalRoute() string { return RouterKey } +func (sup *SoftwareUpgradeProposal) ProposalType() string { return ProposalTypeSoftwareUpgrade } +func (sup *SoftwareUpgradeProposal) ValidateBasic() error { if err := sup.Plan.ValidateBasic(); err != nil { return err } @@ -45,20 +45,20 @@ func (sup SoftwareUpgradeProposal) String() string { } func NewCancelSoftwareUpgradeProposal(title, description string) gov.Content { - return CancelSoftwareUpgradeProposal{title, description} + return &CancelSoftwareUpgradeProposal{title, description} } // Implements Proposal Interface -var _ gov.Content = CancelSoftwareUpgradeProposal{} +var _ gov.Content = &CancelSoftwareUpgradeProposal{} // nolint -func (sup CancelSoftwareUpgradeProposal) GetTitle() string { return sup.Title } -func (sup CancelSoftwareUpgradeProposal) GetDescription() string { return sup.Description } -func (sup CancelSoftwareUpgradeProposal) ProposalRoute() string { return RouterKey } -func (sup CancelSoftwareUpgradeProposal) ProposalType() string { +func (sup *CancelSoftwareUpgradeProposal) GetTitle() string { return sup.Title } +func (sup *CancelSoftwareUpgradeProposal) GetDescription() string { return sup.Description } +func (sup *CancelSoftwareUpgradeProposal) ProposalRoute() string { return RouterKey } +func (sup *CancelSoftwareUpgradeProposal) ProposalType() string { return ProposalTypeCancelSoftwareUpgrade } -func (sup CancelSoftwareUpgradeProposal) ValidateBasic() error { +func (sup *CancelSoftwareUpgradeProposal) ValidateBasic() error { return gov.ValidateAbstract(sup) } diff --git a/x/upgrade/types/proposal_test.go b/x/upgrade/types/proposal_test.go index 02d204a167..cf4fd6eee1 100644 --- a/x/upgrade/types/proposal_test.go +++ b/x/upgrade/types/proposal_test.go @@ -7,7 +7,7 @@ import ( "github.com/stretchr/testify/require" "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/x/gov" + gov "github.com/cosmos/cosmos-sdk/x/gov/types" ) type ProposalWrapper struct {