fix: case unauthorized message (#11229)

* fix: case unauthorized message

* changes

* Update x/feegrant/client/testutil/suite.go

* review changes

* Update client/broadcast.go

* udpate changelog

* update changelog

Co-authored-by: Amaury <1293565+amaurym@users.noreply.github.com>
This commit is contained in:
atheeshp 2022-02-24 17:58:13 +05:30 committed by GitHub
parent 6324b5affb
commit ef6fed67de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 23 deletions

View File

@ -200,7 +200,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* [\#10466](https://github.com/cosmos/cosmos-sdk/issues/10466) Fixes error with simulation tests when genesis start time is randomly created after the year 2262
* [\#10394](https://github.com/cosmos/cosmos-sdk/issues/10394) Fixes issue related to grpc-gateway of account balance by
ibc-denom.
* [\#10593](https://github.com/cosmos/cosmos-sdk/pull/10593) Update swagger-ui to v4.1.0 to fix xss vulnerability.
* [\#10593](https://github.com/cosmos/cosmos-sdk/pull/10593) Update swagger-ui to v4.1.0 to fix xss vulnerability.
* [\#10842](https://github.com/cosmos/cosmos-sdk/pull/10842) Fix error when `--generate-only`, `--max-msgs` fags set while executing `WithdrawAllRewards` command.
* [\#10897](https://github.com/cosmos/cosmos-sdk/pull/10897) Fix: set a non-zero value on gas overflow.
* [#9790](https://github.com/cosmos/cosmos-sdk/pull/10687) Fix behavior of `DecCoins.MulDecTruncate`.
@ -208,7 +208,8 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (crypto) [#11027] Remove dependency on Tendermint core for xsalsa20symmetric.
* (x/authz) [\#10447](https://github.com/cosmos/cosmos-sdk/pull/10447) Fix authz `NewGrant` expiration check.
* (x/authz) [\#10633](https://github.com/cosmos/cosmos-sdk/pull/10633) Fixed authorization not found error when executing message.
* [#11222](https://github.com/cosmos/cosmos-sdk/pull/11222) reject query with block height in the future
* [#11222](https://github.com/cosmos/cosmos-sdk/pull/11222) reject query with block height in the future
* [#11229](https://github.com/cosmos/cosmos-sdk/pull/11229) Handled the error message of `transaction encountered error` from tendermint.
### State Machine Breaking

View File

@ -98,6 +98,15 @@ func (ctx Context) BroadcastTxCommit(txBytes []byte) (*sdk.TxResponse, error) {
return sdk.NewResponseFormatBroadcastTxCommit(res), nil
}
// with these changes(https://github.com/tendermint/tendermint/pull/7683)
// in tendermint, we receive both an error and a non-empty res from TM. Here
// we handle the case where both are relevant. Note: without this edge-case handling,
// CLI is breaking (for few transactions ex: executing unathorized messages in feegrant)
// this check is added to tackle the particular case.
if strings.Contains(err.Error(), "transaction encountered error") {
return sdk.NewResponseFormatBroadcastTxCommit(res), nil
}
if errRes := CheckTendermintError(err, txBytes); errRes != nil {
return errRes, nil
}

View File

@ -912,28 +912,24 @@ func (s *IntegrationTestSuite) TestFilteredFeeAllowance() {
&sdk.TxResponse{},
2,
},
/* TODO(#10559): This case times out after TM v0.35.
Figure out why and fix it.
{
"should fail with unauthorized msgs",
func() (testutil.BufferWriter, error) {
args := append(
[]string{
grantee.String(),
"cosmos14cm33pvnrv2497tyt8sp9yavhmw83nwej3m0e8",
fmt.Sprintf("--%s=%s", cli.FlagSpendLimit, "100stake"),
fmt.Sprintf("--%s=%s", flags.FlagFeeGranter, granter),
},
commonFlags...,
)
cmd := cli.NewCmdFeeGrant()
return clitestutil.ExecTestCLICmd(clientCtx, cmd, args)
{
"should fail with unauthorized msgs",
func() (testutil.BufferWriter, error) {
args := append(
[]string{
grantee.String(),
"cosmos14cm33pvnrv2497tyt8sp9yavhmw83nwej3m0e8",
fmt.Sprintf("--%s=%s", cli.FlagSpendLimit, "100stake"),
fmt.Sprintf("--%s=%s", flags.FlagFeeGranter, granter),
},
&sdk.TxResponse{},
7,
},
*/
commonFlags...,
)
cmd := cli.NewCmdFeeGrant()
return clitestutil.ExecTestCLICmd(clientCtx, cmd, args)
},
&sdk.TxResponse{},
7,
},
}
for _, tc := range cases {