Skip to content

Commit

Permalink
fix: correctly propagate msg errors in gov (backport #13918) (#13928)
Browse files Browse the repository at this point in the history
* 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 5581f7f)

# Conflicts:
#	CHANGELOG.md
#	x/gov/abci_test.go

* fix conflicts

* updates

Co-authored-by: John Letey <j@letey.de>
Co-authored-by: Julien Robert <julien@rbrt.fr>
  • Loading branch information
3 people committed Nov 18, 2022
1 parent b88f086 commit 2f55513
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 27 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Expand Up @@ -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
Expand Down
20 changes: 4 additions & 16 deletions 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:

Expand Down
4 changes: 3 additions & 1 deletion x/gov/abci.go
Expand Up @@ -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
}
Expand Down
16 changes: 8 additions & 8 deletions x/gov/abci_test.go
Expand Up @@ -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"
Expand Down Expand Up @@ -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)))
Expand All @@ -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) {
Expand Down
2 changes: 0 additions & 2 deletions x/gov/common_test.go
Expand Up @@ -78,8 +78,6 @@ func SortByteArrays(src [][]byte) [][]byte {
return sorted
}

const contextKeyBadProposal = "contextKeyBadProposal"

var pubkeys = []cryptotypes.PubKey{
ed25519.GenPrivKey().PubKey(),
ed25519.GenPrivKey().PubKey(),
Expand Down

0 comments on commit 2f55513

Please sign in to comment.