From 2f555130949806a1655271478fd0a33bf99bf960 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Fri, 18 Nov 2022 17:44:14 +0000 Subject: [PATCH] fix: correctly propagate msg errors in gov (backport #13918) (#13928) * fix: correctly propagate msg errors in gov (#13918) * fix: correctly propagate msg errors in gov * chore: update changelog * fix: correctly check proposal status in tests * chore: delete unused var (cherry picked from commit 5581f7f3004116b3031702959f72c7fc2d7811d8) # Conflicts: # CHANGELOG.md # x/gov/abci_test.go * fix conflicts * updates Co-authored-by: John Letey Co-authored-by: Julien Robert --- CHANGELOG.md | 6 ++++++ RELEASE_NOTES.md | 20 ++++---------------- x/gov/abci.go | 4 +++- x/gov/abci_test.go | 16 ++++++++-------- x/gov/common_test.go | 2 -- 5 files changed, 21 insertions(+), 27 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 14993abd1385..94457b101323 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,10 +37,16 @@ Ref: https://keepachangelog.com/en/1.0.0/ ## [Unreleased] +## [v0.46.6](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.46.6) - 2022-11-18 + ### Improvements * (config) [#13894](https://github.com/cosmos/cosmos-sdk/pull/13894) Support state streaming configuration in `app.toml` template and default configuration. +## Bug Fixes + +* (x/gov) [#13918](https://github.com/cosmos/cosmos-sdk/pull/13918) Fix propagation of message errors when executing a proposal. + ## [v0.46.5](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.46.5) - 2022-11-17 ### Features diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 50f19e680591..9d1711e20caa 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,24 +1,12 @@ -# Cosmos SDK v0.46.5 Release Notes +# Cosmos SDK v0.46.6 Release Notes -This release introduces a number of serious bug fixes and improvements. Notably, an upgrade to Tendermint [v0.34.23](https://github.com/tendermint/tendermint/releases/tag/v0.34.23). +This release introduces small bug fixes and improvements. -If you are planning to migrate to v0.46, please use `v0.46.5`. All releases prior to `v0.46.5` are [retracted](https://go.dev/ref/mod#go-mod-file-retract) and **must NOT be used** (`go get` directly upgrades the SDK version to `>= v0.46.5` thanks to the retraction, current builds are not affected). - -If your chain's state has coin metadata, an issue has been discovered in the bank module coin metadata migration. This issue is fixed in `v0.46.5`. - -* If your chain is already on v0.46 using `<= v0.46.4` and has coin metadata, a **coordinated upgrade** to `v0.46.5` is required. - * Use the helper function `Migrate_V0464_To_V0465` for migrating a chain **already on v0.46 with versions <=v0.46.4** to the latest v0.46.5 correct state. -* If your chain is already on v0.46 using `<= v0.46.4` but has no coin metadata, this release is **non-breaking**. - -Moreover, serious issues have been found in the group module. These issues are fixed in `v0.46.5`. - -* If you use the group module, upgrade to `v0.46.5` **immediately**. A **coordinated upgrade** to `v0.46.5` is required. - -When a chain is already using `<= v0.46.4`, but has no coin metadata and no group module, this release is **non-breaking**. +Please read the release notes of [v0.46.5](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.46.5) if you are upgrading from `<=0.46.4`. Please see the [CHANGELOG](https://github.com/cosmos/cosmos-sdk/blob/release/v0.46.x/CHANGELOG.md) for an exhaustive list of changes. -Full Commit History: https://github.com/cosmos/cosmos-sdk/compare/v0.46.4...v0.46.5 +Full Commit History: https://github.com/cosmos/cosmos-sdk/compare/v0.46.5...v0.46.6 **NOTE**: The changes mentioned in `v0.46.3` are **still** required: diff --git a/x/gov/abci.go b/x/gov/abci.go index 21aca44ed08a..ae553149d9c1 100644 --- a/x/gov/abci.go +++ b/x/gov/abci.go @@ -71,7 +71,9 @@ func EndBlocker(ctx sdk.Context, keeper keeper.Keeper) { if err == nil { for idx, msg = range messages { handler := keeper.Router().Handler(msg) - res, err := handler(cacheCtx, msg) + + var res *sdk.Result + res, err = handler(cacheCtx, msg) if err != nil { break } diff --git a/x/gov/abci_test.go b/x/gov/abci_test.go index f0e002f12395..ad789edeec89 100644 --- a/x/gov/abci_test.go +++ b/x/gov/abci_test.go @@ -10,6 +10,8 @@ import ( "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" + authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" + banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/cosmos/cosmos-sdk/x/gov" "github.com/cosmos/cosmos-sdk/x/gov/keeper" "github.com/cosmos/cosmos-sdk/x/gov/types" @@ -340,10 +342,8 @@ func TestEndBlockerProposalHandlerFailed(t *testing.T) { createValidators(t, stakingMsgSvr, ctx, []sdk.ValAddress{valAddr}, []int64{10}) staking.EndBlocker(ctx, app.StakingKeeper) - // Create a proposal where the handler will pass for the test proposal - // because the value of contextKeyBadProposal is true. - ctx = ctx.WithValue(contextKeyBadProposal, true) - proposal, err := app.GovKeeper.SubmitProposal(ctx, []sdk.Msg{mkTestLegacyContent(t)}, "") + msg := banktypes.NewMsgSend(authtypes.NewModuleAddress(types.ModuleName), addrs[0], sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(100000)))) + proposal, err := app.GovKeeper.SubmitProposal(ctx, []sdk.Msg{msg}, "") require.NoError(t, err) proposalCoins := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, app.StakingKeeper.TokensFromConsensusPower(ctx, 10))) @@ -361,12 +361,12 @@ func TestEndBlockerProposalHandlerFailed(t *testing.T) { newHeader.Time = ctx.BlockHeader().Time.Add(*app.GovKeeper.GetDepositParams(ctx).MaxDepositPeriod).Add(*app.GovKeeper.GetVotingParams(ctx).VotingPeriod) ctx = ctx.WithBlockHeader(newHeader) - // Set the contextKeyBadProposal value to false so that the handler will fail - // during the processing of the proposal in the EndBlocker. - ctx = ctx.WithValue(contextKeyBadProposal, false) - // validate that the proposal fails/has been rejected gov.EndBlocker(ctx, app.GovKeeper) + + proposal, ok := app.GovKeeper.GetProposal(ctx, proposal.Id) + require.True(t, ok) + require.Equal(t, v1.StatusFailed, proposal.Status) } func createValidators(t *testing.T, stakingMsgSvr stakingtypes.MsgServer, ctx sdk.Context, addrs []sdk.ValAddress, powerAmt []int64) { diff --git a/x/gov/common_test.go b/x/gov/common_test.go index d4d9bd382d4c..ad3d0e3cb94d 100644 --- a/x/gov/common_test.go +++ b/x/gov/common_test.go @@ -78,8 +78,6 @@ func SortByteArrays(src [][]byte) [][]byte { return sorted } -const contextKeyBadProposal = "contextKeyBadProposal" - var pubkeys = []cryptotypes.PubKey{ ed25519.GenPrivKey().PubKey(), ed25519.GenPrivKey().PubKey(),