From 4b9b61faeaa316e635817850b2d24cb936f19883 Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Tue, 28 Nov 2023 09:33:06 -0700 Subject: [PATCH] add expedited --- go.mod | 2 + go.sum | 4 +- tests/e2e/gov_test.go | 1 + x/wasm/client/cli/gov_tx.go | 80 ++++++++++++---------- x/wasm/client/cli/tx.go | 1 + x/wasm/keeper/proposal_integration_test.go | 1 + 6 files changed, 50 insertions(+), 39 deletions(-) diff --git a/go.mod b/go.mod index 594ef0d522..0b55ed7153 100644 --- a/go.mod +++ b/go.mod @@ -183,6 +183,8 @@ require ( replace ( github.com/99designs/keyring => github.com/cosmos/keyring v1.2.0 + + github.com/cosmos/cosmos-sdk => github.com/osmosis-labs/cosmos-sdk v0.47.6-0.20231124185741-15259ccd2249 // dgrijalva/jwt-go is deprecated and doesn't receive security updates. // See: https://github.com/cosmos/cosmos-sdk/issues/13134 github.com/dgrijalva/jwt-go => github.com/golang-jwt/jwt/v4 v4.4.2 diff --git a/go.sum b/go.sum index f75ad4ac2b..d30c6e9f7c 100644 --- a/go.sum +++ b/go.sum @@ -324,8 +324,6 @@ github.com/cosmos/btcutil v1.0.5 h1:t+ZFcX77LpKtDBhjucvnOH8C2l2ioGsBNEQ3jef8xFk= github.com/cosmos/btcutil v1.0.5/go.mod h1:IyB7iuqZMJlthe2tkIFL33xPyzbFYP0XVdS8P5lUPis= github.com/cosmos/cosmos-proto v1.0.0-beta.2 h1:X3OKvWgK9Gsejo0F1qs5l8Qn6xJV/AzgIWR2wZ8Nua8= github.com/cosmos/cosmos-proto v1.0.0-beta.2/go.mod h1:+XRCLJ14pr5HFEHIUcn51IKXD1Fy3rkEQqt4WqmN4V0= -github.com/cosmos/cosmos-sdk v0.47.5 h1:n1+WjP/VM/gAEOx3TqU2/Ny734rj/MX1kpUnn7zVJP8= -github.com/cosmos/cosmos-sdk v0.47.5/go.mod h1:EHwCeN9IXonsjKcjpS12MqeStdZvIdxt3VYXhus3G3c= github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y= github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY= github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw= @@ -801,6 +799,8 @@ github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJ github.com/openzipkin/zipkin-go v0.2.1/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= github.com/openzipkin/zipkin-go v0.2.2/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= github.com/ory/dockertest v3.3.5+incompatible h1:iLLK6SQwIhcbrG783Dghaaa3WPzGc+4Emza6EbVUUGA= +github.com/osmosis-labs/cosmos-sdk v0.47.6-0.20231124185741-15259ccd2249 h1:WXgQVDkydvC/5a2F/QJ7tTcsb1AsULqsX8e9BdgGROE= +github.com/osmosis-labs/cosmos-sdk v0.47.6-0.20231124185741-15259ccd2249/go.mod h1:EHwCeN9IXonsjKcjpS12MqeStdZvIdxt3VYXhus3G3c= github.com/pact-foundation/pact-go v1.0.4/go.mod h1:uExwJY4kCzNPcHRj+hCR/HBbOOIwwtUjcrb0b5/5kLM= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY= diff --git a/tests/e2e/gov_test.go b/tests/e2e/gov_test.go index 33b7fd34a4..99a68ecea5 100644 --- a/tests/e2e/gov_test.go +++ b/tests/e2e/gov_test.go @@ -97,6 +97,7 @@ func TestGovVoteByContract(t *testing.T) { "", "my proposal", "testing", + false, ) require.NoError(t, err) rsp, gotErr := chain.SendMsgs(msg) diff --git a/x/wasm/client/cli/gov_tx.go b/x/wasm/client/cli/gov_tx.go index 928dee6b69..e27d4e5bf7 100644 --- a/x/wasm/client/cli/gov_tx.go +++ b/x/wasm/client/cli/gov_tx.go @@ -62,7 +62,7 @@ func ProposalStoreCodeCmd() *cobra.Command { Short: "Submit a wasm binary proposal", Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, proposalTitle, summary, deposit, err := getProposalInfo(cmd) + clientCtx, proposalTitle, summary, deposit, expedite, err := getProposalInfo(cmd) if err != nil { return err } @@ -80,7 +80,7 @@ func ProposalStoreCodeCmd() *cobra.Command { return err } - proposalMsg, err := v1.NewMsgSubmitProposal([]sdk.Msg{&src}, deposit, clientCtx.GetFromAddress().String(), "", proposalTitle, summary) + proposalMsg, err := v1.NewMsgSubmitProposal([]sdk.Msg{&src}, deposit, clientCtx.GetFromAddress().String(), "", proposalTitle, summary, expedite) if err != nil { return err } @@ -154,7 +154,7 @@ func ProposalInstantiateContractCmd() *cobra.Command { Short: "Submit an instantiate wasm contract proposal", Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, proposalTitle, summary, deposit, err := getProposalInfo(cmd) + clientCtx, proposalTitle, summary, deposit, expedite, err := getProposalInfo(cmd) if err != nil { return err } @@ -173,7 +173,7 @@ func ProposalInstantiateContractCmd() *cobra.Command { return err } - proposalMsg, err := v1.NewMsgSubmitProposal([]sdk.Msg{src}, deposit, clientCtx.GetFromAddress().String(), "", proposalTitle, summary) + proposalMsg, err := v1.NewMsgSubmitProposal([]sdk.Msg{src}, deposit, clientCtx.GetFromAddress().String(), "", proposalTitle, summary, expedite) if err != nil { return err } @@ -201,7 +201,7 @@ func ProposalInstantiateContract2Cmd() *cobra.Command { Short: "Submit an instantiate wasm contract proposal with predictable address", Args: cobra.ExactArgs(3), RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, proposalTitle, summary, deposit, err := getProposalInfo(cmd) + clientCtx, proposalTitle, summary, deposit, expedite, err := getProposalInfo(cmd) if err != nil { return err } @@ -220,7 +220,7 @@ func ProposalInstantiateContract2Cmd() *cobra.Command { return err } - proposalMsg, err := v1.NewMsgSubmitProposal([]sdk.Msg{src}, deposit, clientCtx.GetFromAddress().String(), "", proposalTitle, summary) + proposalMsg, err := v1.NewMsgSubmitProposal([]sdk.Msg{src}, deposit, clientCtx.GetFromAddress().String(), "", proposalTitle, summary, expedite) if err != nil { return err } @@ -250,7 +250,7 @@ func ProposalStoreAndInstantiateContractCmd() *cobra.Command { Short: "Submit a store and instantiate wasm contract proposal", Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, proposalTitle, summary, deposit, err := getProposalInfo(cmd) + clientCtx, proposalTitle, summary, deposit, expedite, err := getProposalInfo(cmd) if err != nil { return err } @@ -342,7 +342,7 @@ func ProposalStoreAndInstantiateContractCmd() *cobra.Command { Funds: amount, } - proposalMsg, err := v1.NewMsgSubmitProposal([]sdk.Msg{&msg}, deposit, clientCtx.GetFromAddress().String(), "", proposalTitle, summary) + proposalMsg, err := v1.NewMsgSubmitProposal([]sdk.Msg{&msg}, deposit, clientCtx.GetFromAddress().String(), "", proposalTitle, summary, expedite) if err != nil { return err } @@ -375,7 +375,7 @@ func ProposalMigrateContractCmd() *cobra.Command { Short: "Submit a migrate wasm contract to a new code version proposal", Args: cobra.ExactArgs(3), RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, proposalTitle, summary, deposit, err := getProposalInfo(cmd) + clientCtx, proposalTitle, summary, deposit, expedite, err := getProposalInfo(cmd) if err != nil { return err } @@ -394,7 +394,7 @@ func ProposalMigrateContractCmd() *cobra.Command { return err } - proposalMsg, err := v1.NewMsgSubmitProposal([]sdk.Msg{&src}, deposit, clientCtx.GetFromAddress().String(), "", proposalTitle, summary) + proposalMsg, err := v1.NewMsgSubmitProposal([]sdk.Msg{&src}, deposit, clientCtx.GetFromAddress().String(), "", proposalTitle, summary, expedite) if err != nil { return err } @@ -417,7 +417,7 @@ func ProposalExecuteContractCmd() *cobra.Command { Short: "Submit a execute wasm contract proposal (run by any address)", Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, proposalTitle, summary, deposit, err := getProposalInfo(cmd) + clientCtx, proposalTitle, summary, deposit, expedite, err := getProposalInfo(cmd) if err != nil { return err } @@ -449,7 +449,7 @@ func ProposalExecuteContractCmd() *cobra.Command { Funds: funds, } - proposalMsg, err := v1.NewMsgSubmitProposal([]sdk.Msg{&msg}, deposit, clientCtx.GetFromAddress().String(), "", proposalTitle, summary) + proposalMsg, err := v1.NewMsgSubmitProposal([]sdk.Msg{&msg}, deposit, clientCtx.GetFromAddress().String(), "", proposalTitle, summary, expedite) if err != nil { return err } @@ -474,7 +474,7 @@ func ProposalSudoContractCmd() *cobra.Command { Short: "Submit a sudo wasm contract proposal (to call privileged commands)", Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, proposalTitle, summary, deposit, err := getProposalInfo(cmd) + clientCtx, proposalTitle, summary, deposit, expedite, err := getProposalInfo(cmd) if err != nil { return err } @@ -494,7 +494,7 @@ func ProposalSudoContractCmd() *cobra.Command { Msg: []byte(args[1]), } - proposalMsg, err := v1.NewMsgSubmitProposal([]sdk.Msg{&msg}, deposit, clientCtx.GetFromAddress().String(), "", proposalTitle, summary) + proposalMsg, err := v1.NewMsgSubmitProposal([]sdk.Msg{&msg}, deposit, clientCtx.GetFromAddress().String(), "", proposalTitle, summary, expedite) if err != nil { return err } @@ -517,7 +517,7 @@ func ProposalUpdateContractAdminCmd() *cobra.Command { Short: "Submit a new admin for a contract proposal", Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, proposalTitle, summary, deposit, err := getProposalInfo(cmd) + clientCtx, proposalTitle, summary, deposit, expedite, err := getProposalInfo(cmd) if err != nil { return err } @@ -533,7 +533,7 @@ func ProposalUpdateContractAdminCmd() *cobra.Command { src := parseUpdateContractAdminArgs(args, authority) - proposalMsg, err := v1.NewMsgSubmitProposal([]sdk.Msg{&src}, deposit, clientCtx.GetFromAddress().String(), "", proposalTitle, summary) + proposalMsg, err := v1.NewMsgSubmitProposal([]sdk.Msg{&src}, deposit, clientCtx.GetFromAddress().String(), "", proposalTitle, summary, expedite) if err != nil { return err } @@ -556,7 +556,7 @@ func ProposalClearContractAdminCmd() *cobra.Command { Short: "Submit a clear admin for a contract to prevent further migrations proposal", Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, proposalTitle, summary, deposit, err := getProposalInfo(cmd) + clientCtx, proposalTitle, summary, deposit, expedite, err := getProposalInfo(cmd) if err != nil { return err } @@ -575,7 +575,7 @@ func ProposalClearContractAdminCmd() *cobra.Command { Contract: args[0], } - proposalMsg, err := v1.NewMsgSubmitProposal([]sdk.Msg{&msg}, deposit, clientCtx.GetFromAddress().String(), "", proposalTitle, summary) + proposalMsg, err := v1.NewMsgSubmitProposal([]sdk.Msg{&msg}, deposit, clientCtx.GetFromAddress().String(), "", proposalTitle, summary, expedite) if err != nil { return err } @@ -598,7 +598,7 @@ func ProposalPinCodesCmd() *cobra.Command { Short: "Submit a pin code proposal for pinning a code to cache", Args: cobra.MinimumNArgs(1), RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, proposalTitle, summary, deposit, err := getProposalInfo(cmd) + clientCtx, proposalTitle, summary, deposit, expedite, err := getProposalInfo(cmd) if err != nil { return err } @@ -622,7 +622,7 @@ func ProposalPinCodesCmd() *cobra.Command { CodeIDs: codeIds, } - proposalMsg, err := v1.NewMsgSubmitProposal([]sdk.Msg{&msg}, deposit, clientCtx.GetFromAddress().String(), "", proposalTitle, summary) + proposalMsg, err := v1.NewMsgSubmitProposal([]sdk.Msg{&msg}, deposit, clientCtx.GetFromAddress().String(), "", proposalTitle, summary, expedite) if err != nil { return err } @@ -657,7 +657,7 @@ func ProposalUnpinCodesCmd() *cobra.Command { Short: "Submit a unpin code proposal for unpinning a code to cache", Args: cobra.MinimumNArgs(1), RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, proposalTitle, summary, deposit, err := getProposalInfo(cmd) + clientCtx, proposalTitle, summary, deposit, expedite, err := getProposalInfo(cmd) if err != nil { return err } @@ -680,7 +680,7 @@ func ProposalUnpinCodesCmd() *cobra.Command { CodeIDs: codeIds, } - proposalMsg, err := v1.NewMsgSubmitProposal([]sdk.Msg{&msg}, deposit, clientCtx.GetFromAddress().String(), "", proposalTitle, summary) + proposalMsg, err := v1.NewMsgSubmitProposal([]sdk.Msg{&msg}, deposit, clientCtx.GetFromAddress().String(), "", proposalTitle, summary, expedite) if err != nil { return err } @@ -763,7 +763,7 @@ Example: $ %s tx gov submit-proposal update-instantiate-config 1:nobody 2:everybody 3:%s1l2rsakp388kuv9k8qzq6lrm9taddae7fpx59wm,%s1vx8knpllrj7n963p9ttd80w47kpacrhuts497x `, version.AppName, bech32Prefix, bech32Prefix)), RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, proposalTitle, summary, deposit, err := getProposalInfo(cmd) + clientCtx, proposalTitle, summary, deposit, expedite, err := getProposalInfo(cmd) if err != nil { return err } @@ -792,7 +792,7 @@ $ %s tx gov submit-proposal update-instantiate-config 1:nobody 2:everybody 3:%s1 } } - proposalMsg, err := v1.NewMsgSubmitProposal(msgs, deposit, clientCtx.GetFromAddress().String(), "", proposalTitle, summary) + proposalMsg, err := v1.NewMsgSubmitProposal(msgs, deposit, clientCtx.GetFromAddress().String(), "", proposalTitle, summary, expedite) if err != nil { return err } @@ -815,7 +815,7 @@ func ProposalAddCodeUploadParamsAddresses() *cobra.Command { Short: "Submit an add code upload params addresses proposal to add addresses to code upload config params", Args: cobra.MinimumNArgs(1), RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, proposalTitle, summary, deposit, err := getProposalInfo(cmd) + clientCtx, proposalTitle, summary, deposit, expedite, err := getProposalInfo(cmd) if err != nil { return err } @@ -834,7 +834,7 @@ func ProposalAddCodeUploadParamsAddresses() *cobra.Command { Addresses: args, } - proposalMsg, err := v1.NewMsgSubmitProposal([]sdk.Msg{&msg}, deposit, clientCtx.GetFromAddress().String(), "", proposalTitle, summary) + proposalMsg, err := v1.NewMsgSubmitProposal([]sdk.Msg{&msg}, deposit, clientCtx.GetFromAddress().String(), "", proposalTitle, summary, expedite) if err != nil { return err } @@ -857,7 +857,7 @@ func ProposalRemoveCodeUploadParamsAddresses() *cobra.Command { Short: "Submit a remove code upload params addresses proposal to remove addresses from code upload config params", Args: cobra.MinimumNArgs(1), RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, proposalTitle, summary, deposit, err := getProposalInfo(cmd) + clientCtx, proposalTitle, summary, deposit, expedite, err := getProposalInfo(cmd) if err != nil { return err } @@ -876,7 +876,7 @@ func ProposalRemoveCodeUploadParamsAddresses() *cobra.Command { Addresses: args, } - proposalMsg, err := v1.NewMsgSubmitProposal([]sdk.Msg{&msg}, deposit, clientCtx.GetFromAddress().String(), "", proposalTitle, summary) + proposalMsg, err := v1.NewMsgSubmitProposal([]sdk.Msg{&msg}, deposit, clientCtx.GetFromAddress().String(), "", proposalTitle, summary, expedite) if err != nil { return err } @@ -899,35 +899,41 @@ func addCommonProposalFlags(cmd *cobra.Command) { cmd.Flags().String(cli.FlagSummary, "", "Summary of proposal") cmd.Flags().String(cli.FlagDeposit, "", "Deposit of proposal") cmd.Flags().String(flagAuthority, DefaultGovAuthority.String(), "The address of the governance account. Default is the sdk gov module account") + cmd.Flags().Bool(flagExpedite, false, "Expedite proposals have shorter voting period but require higher voting threshold") } -func getProposalInfo(cmd *cobra.Command) (client.Context, string, string, sdk.Coins, error) { +func getProposalInfo(cmd *cobra.Command) (client.Context, string, string, sdk.Coins, bool, error) { clientCtx, err := client.GetClientTxContext(cmd) if err != nil { - return client.Context{}, "", "", nil, err + return client.Context{}, "", "", nil, false, err } proposalTitle, err := cmd.Flags().GetString(cli.FlagTitle) if err != nil { - return clientCtx, proposalTitle, "", nil, err + return clientCtx, proposalTitle, "", nil, false, err } summary, err := cmd.Flags().GetString(cli.FlagSummary) if err != nil { - return client.Context{}, proposalTitle, summary, nil, err + return client.Context{}, proposalTitle, summary, nil, false, err } depositArg, err := cmd.Flags().GetString(cli.FlagDeposit) if err != nil { - return client.Context{}, proposalTitle, summary, nil, err + return client.Context{}, proposalTitle, summary, nil, false, err } deposit, err := sdk.ParseCoinsNormalized(depositArg) if err != nil { - return client.Context{}, proposalTitle, summary, deposit, err + return client.Context{}, proposalTitle, summary, deposit, false, err } - return clientCtx, proposalTitle, summary, deposit, nil + expedite, err := cmd.Flags().GetBool(flagExpedite) + if err != nil { + return client.Context{}, proposalTitle, summary, deposit, false, err + } + + return clientCtx, proposalTitle, summary, deposit, expedite, nil } func ProposalStoreAndMigrateContractCmd() *cobra.Command { @@ -936,7 +942,7 @@ func ProposalStoreAndMigrateContractCmd() *cobra.Command { Short: "Submit a store and migrate wasm contract proposal", Args: cobra.ExactArgs(3), RunE: func(cmd *cobra.Command, args []string) error { - clientCtx, proposalTitle, summary, deposit, err := getProposalInfo(cmd) + clientCtx, proposalTitle, summary, deposit, expedite, err := getProposalInfo(cmd) if err != nil { return err } @@ -963,7 +969,7 @@ func ProposalStoreAndMigrateContractCmd() *cobra.Command { Contract: args[1], } - proposalMsg, err := v1.NewMsgSubmitProposal([]sdk.Msg{&msg}, deposit, clientCtx.GetFromAddress().String(), "", proposalTitle, summary) + proposalMsg, err := v1.NewMsgSubmitProposal([]sdk.Msg{&msg}, deposit, clientCtx.GetFromAddress().String(), "", proposalTitle, summary, expedite) if err != nil { return err } diff --git a/x/wasm/client/cli/tx.go b/x/wasm/client/cli/tx.go index 49a326d333..fd59056830 100644 --- a/x/wasm/client/cli/tx.go +++ b/x/wasm/client/cli/tx.go @@ -47,6 +47,7 @@ const ( flagAllowAllMsgs = "allow-all-messages" flagNoTokenTransfer = "no-token-transfer" flagAuthority = "authority" + flagExpedite = "expedite" ) // GetTxCmd returns the transaction commands for this module diff --git a/x/wasm/keeper/proposal_integration_test.go b/x/wasm/keeper/proposal_integration_test.go index 2d2d0faf14..647970d7e4 100644 --- a/x/wasm/keeper/proposal_integration_test.go +++ b/x/wasm/keeper/proposal_integration_test.go @@ -216,6 +216,7 @@ func submitLegacyProposal(t *testing.T, ctx sdk.Context, content v1beta1.Content "", content.GetTitle(), content.GetDescription(), + false, ) require.NoError(t, err)