Skip to content

Commit

Permalink
fix: remove potential panic on *MsgCreateClient.String (#1383)
Browse files Browse the repository at this point in the history
The following appeared during `bloom-beta-1` testing (specifically ibc setup).

```
reflect.Value.Interface: cannot return value obtained from unexported field or method
stack:
goroutine 1923512 [running]:
runtime/debug.Stack()
\t/mnt/s/go/src/runtime/debug/stack.go:24 +0x65
github.com/cosmos/cosmos-sdk/baseapp.newDefaultRecoveryMiddleware.func1({0x1f67b80, 0x2d97600})
\t/home/umeeandre/go/pkg/mod/github.com/umee-network/cosmos-sdk@v0.46.1-umee/baseapp/recovery.go:71 +0x27
github.com/cosmos/cosmos-sdk/baseapp.newRecoveryMiddleware.func1({0x1f67b80?, 0x2d97600?})
\t/home/umeeandre/go/pkg/mod/github.com/umee-network/cosmos-sdk@v0.46.1-umee/baseapp/recovery.go:39 +0x30
github.com/cosmos/cosmos-sdk/baseapp.processRecovery({0x1f67b80, 0x2d97600}, 0xc00d122fc0?)
\t/home/umeeandre/go/pkg/mod/github.com/umee-network/cosmos-sdk@v0.46.1-umee/baseapp/recovery.go:28 +0x37
github.com/cosmos/cosmos-sdk/baseapp.processRecovery({0x1f67b80, 0x2d97600}, 0x2dc8100?)
\t/home/umeeandre/go/pkg/mod/github.com/umee-network/cosmos-sdk@v0.46.1-umee/baseapp/recovery.go:33 +0x5e
github.com/cosmos/cosmos-sdk/baseapp.(*BaseApp).runTx.func1()
\t/home/umeeandre/go/pkg/mod/github.com/umee-network/cosmos-sdk@v0.46.1-umee/baseapp/baseapp.go:605 +0xf0
panic({0x1f67b80, 0x2d97600})
\t/mnt/s/go/src/runtime/panic.go:838 +0x207
github.com/cosmos/cosmos-sdk/x/auth/ante.SetUpContextDecorator.AnteHandle.func1()
\t/home/umeeandre/go/pkg/mod/github.com/umee-network/cosmos-sdk@v0.46.1-umee/x/auth/ante/setup.go:59 +0x1e6
panic({0x1f67b80, 0x2d97600})
\t/mnt/s/go/src/runtime/panic.go:838 +0x207
reflect.valueInterface({0x1fcc2c0?, 0xc0236ba528?, 0x8f?}, 0x58?)
\t/mnt/s/go/src/reflect/value.go:1441 +0xd8
reflect.Value.Interface(...)
\t/mnt/s/go/src/reflect/value.go:1430
github.com/gogo/protobuf/proto.(*TextMarshaler).writeAny(0x0?, 0xc02d12ad40, {0x1fcc2c0?, 0xc0236ba528?, 0x2dce670?}, 0xc028b88f00)
\t/home/umeeandre/go/pkg/mod/github.com/regen-network/protobuf@v1.3.3-alpha.regen.1/proto/text.go:615 +0xa38
github.com/gogo/protobuf/proto.(*TextMarshaler).writeStruct(0x3e980b6, 0xc02d12ad40, {0x21d70e0?, 0xc0236ba4e0?, 0x7f4bf67ce108?})
\t/home/umeeandre/go/pkg/mod/github.com/regen-network/protobuf@v1.3.3-alpha.regen.1/proto/text.go:453 +0x8ad
github.com/gogo/protobuf/proto.(*TextMarshaler).writeAny(0x2091d99?, 0xc02d12ad40, {0x228f940?, 0xc02d12a060?, 0x2dce670?}, 0xc028b88900)
\t/home/umeeandre/go/pkg/mod/github.com/regen-network/protobuf@v1.3.3-alpha.regen.1/proto/text.go:606 +0x8c5
github.com/gogo/protobuf/proto.(*TextMarshaler).writeStruct(0x3e980b6, 0xc02d12ad40, {0x21916a0?, 0xc02d12a060?, 0xc026d16468?})
\t/home/umeeandre/go/pkg/mod/github.com/regen-network/protobuf@v1.3.3-alpha.regen.1/proto/text.go:453 +0x8ad
github.com/gogo/protobuf/proto.(*TextMarshaler).Marshal(0x3e980b6, {0x2d97e60?, 0xc02766c000?}, {0x2daf0d0?, 0xc02d12a060?})
\t/home/umeeandre/go/pkg/mod/github.com/regen-network/protobuf@v1.3.3-alpha.regen.1/proto/text.go:896 +0x367
github.com/gogo/protobuf/proto.(*TextMarshaler).Text(0xc026d16438?, {0x2daf0d0, 0xc02d12a060})
\t/home/umeeandre/go/pkg/mod/github.com/regen-network/protobuf@v1.3.3-alpha.regen.1/proto/text.go:908 +0x56
github.com/gogo/protobuf/proto.CompactTextString(...)
\t/home/umeeandre/go/pkg/mod/github.com/regen-network/protobuf@v1.3.3-alpha.regen.1/proto/text.go:930
github.com/cosmos/ibc-go/v5/modules/core/02-client/types.(*MsgCreateClient).String(0xc00021e648?)
\t/home/umeeandre/go/pkg/mod/github.com/cosmos/ibc-go/v5@v5.0.0-rc1/modules/core/02-client/types/tx.pb.go:44 +0x2a
github.com/umee-network/umee/v3/ante.FeeAndPriority({{0x2db8940, 0xc00012a000}, {0x2dc8100, 0xc026c968c0}, {{0xb, 0x0}, {0xc02875c270, 0xc}, 0x3a79, {0x1829c70e, ...}, ...}, ...}, ...)
\t/mnt/s/Umee/umee-3.0.0-beta1/ante/fee.go:46 +0x475
github.com/cosmos/cosmos-sdk/x/auth/ante.DeductFeeDecorator.AnteHandle({{_, _}, {_, _}, {_, _}, _}, {{0x2db8940, 0xc00012a000}, {0x2dc8100, ...}, ...}, ...)
\t/home/umeeandre/go/pkg/mod/github.com/umee-network/cosmos-sdk@v0.46.1-umee/x/auth/ante/fee.go:56 +0x18d
github.com/cosmos/cosmos-sdk/types.ChainAnteDecorators.func1({{0x2db8940, 0xc00012a000}, {0x2dc8100, 0xc026c968c0}, {{0xb, 0x0}, {0xc02875c270, 0xc}, 0x3a79, {0x1829c70e, ...}, ...}, ...}, ...)
\t/home/umeeandre/go/pkg/mod/github.com/umee-network/cosmos-sdk@v0.46.1-umee/types/handler.go:40 +0x136
github.com/cosmos/cosmos-sdk/x/auth/ante.ConsumeTxSizeGasDecorator.AnteHandle({{_, _}}, {{0x2db8940, 0xc00012a000}, {0x2dc8100, 0xc026c968c0}, {{0xb, 0x0}, {0xc02875c270, 0xc}, ...}, ...}, ...)
\t/home/umeeandre/go/pkg/mod/github.com/umee-network/cosmos-sdk@v0.46.1-umee/x/auth/ante/basic.go:142 +0x34f
github.com/cosmos/cosmos-sdk/types.ChainAnteDecorators.func1({{0x2db8940, 0xc00012a000}, {0x2dc8100, 0xc026c968c0}, {{0xb, 0x0}, {0xc02875c270, 0xc}, 0x3a79, {0x1829c70e, ...}, ...}, ...}, ...)
\t/home/umeeandre/go/pkg/mod/github.com/umee-network/cosmos-sdk@v0.46.1-umee/types/handler.go:40 +0x136
github.com/cosmos/cosmos-sdk/x/auth/ante.ValidateMemoDecorator.AnteHandle({{_, _}}, {{0x2db8940, 0xc00012a000}, {0x2dc8100, 0xc026c968c0}, {{0xb, 0x0}, {0xc02875c270, 0xc}, ...}, ...}, ...)
\t/home/umeeandre/go/pkg/mod/github.com/umee-network/cosmos-sdk@v0.46.1-umee/x/auth/ante/basic.go:66 +0x2d7
github.com/cosmos/cosmos-sdk/types.ChainAnteDecorators.func1({{0x2db8940, 0xc00012a000}, {0x2dc8100, 0xc026c968c0}, {{0xb, 0x0}, {0xc02875c270, 0xc}, 0x3a79, {0x1829c70e, ...}, ...}, ...}, ...)
\t/home/umeeandre/go/pkg/mod/github.com/umee-network/cosmos-sdk@v0.46.1-umee/types/handler.go:40 +0x136
github.com/cosmos/cosmos-sdk/x/auth/ante.TxTimeoutHeightDecorator.AnteHandle({}, {{0x2db8940, 0xc00012a000}, {0x2dc8100, 0xc026c968c0}, {{0xb, 0x0}, {0xc02875c270, 0xc}, 0x3a79, ...}, ...}, ...)
\t/home/umeeandre/go/pkg/mod/github.com/umee-network/cosmos-sdk@v0.46.1-umee/x/auth/ante/basic.go:205 +0x297
github.com/cosmos/cosmos-sdk/types.ChainAnteDecorators.func1({{0x2db8940, 0xc00012a000}, {0x2dc8100, 0xc026c968c0}, {{0xb, 0x0}, {0xc02875c270, 0xc}, 0x3a79, {0x1829c70e, ...}, ...}, ...}, ...)
\t/home/umeeandre/go/pkg/mod/github.com/umee-network/cosmos-sdk@v0.46.1-umee/types/handler.go:40 +0x136
github.com/cosmos/cosmos-sdk/x/auth/ante.ValidateBasicDecorator.AnteHandle({}, {{0x2db8940, 0xc00012a000}, {0x2dc8100, 0xc026c968c0}, {{0xb, 0x0}, {0xc02875c270, 0xc}, 0x3a79, ...}, ...}, ...)
\t/home/umeeandre/go/pkg/mod/github.com/umee-network/cosmos-sdk@v0.46.1-umee/x/auth/ante/basic.go:34 +0x157
github.com/cosmos/cosmos-sdk/types.ChainAnteDecorators.func1({{0x2db8940, 0xc00012a000}, {0x2dc8100, 0xc026c968c0}, {{0xb, 0x0}, {0xc02875c270, 0xc}, 0x3a79, {0x1829c70e, ...}, ...}, ...}, ...)
\t/home/umeeandre/go/pkg/mod/github.com/umee-network/cosmos-sdk@v0.46.1-umee/types/handler.go:40 +0x136
github.com/umee-network/umee/v3/ante.(*SpamPreventionDecorator).AnteHandle(_, {{0x2db8940, 0xc00012a000}, {0x2dc8100, 0xc026c968c0}, {{0xb, 0x0}, {0xc02875c270, 0xc}, 0x3a79, ...}, ...}, ...)
\t/mnt/s/Umee/umee-3.0.0-beta1/ante/spam_prevention.go:47 +0x203
github.com/cosmos/cosmos-sdk/types.ChainAnteDecorators.func1({{0x2db8940, 0xc00012a000}, {0x2dc8100, 0xc026c968c0}, {{0xb, 0x0}, {0xc02875c270, 0xc}, 0x3a79, {0x1829c70e, ...}, ...}, ...}, ...)
\t/home/umeeandre/go/pkg/mod/github.com/umee-network/cosmos-sdk@v0.46.1-umee/types/handler.go:40 +0x136
github.com/cosmos/cosmos-sdk/x/auth/ante.RejectExtensionOptionsDecorator.AnteHandle({_}, {{0x2db8940, 0xc00012a000}, {0x2dc8100, 0xc026c968c0}, {{0xb, 0x0}, {0xc02875c270, 0xc}, 0x3a79, ...}, ...}, ...)
\t/home/umeeandre/go/pkg/mod/github.com/umee-network/cosmos-sdk@v0.46.1-umee/x/auth/ante/ext.go:52 +0x137
github.com/cosmos/cosmos-sdk/types.ChainAnteDecorators.func1({{0x2db8940, 0xc00012a000}, {0x2dc8100, 0xc026c968c0}, {{0xb, 0x0}, {0xc02875c270, 0xc}, 0x3a79, {0x1829c70e, ...}, ...}, ...}, ...)
\t/home/umeeandre/go/pkg/mod/github.com/umee-network/cosmos-sdk@v0.46.1-umee/types/handler.go:40 +0x136
github.com/cosmos/cosmos-sdk/x/auth/ante.SetUpContextDecorator.AnteHandle({}, {{0x2db8940, 0xc00012a000}, {0x2dc8100, 0xc026c968c0}, {{0xb, 0x0}, {0xc02875c270, 0xc}, 0x3a79, ...}, ...}, ...)
\t/home/umeeandre/go/pkg/mod/github.com/umee-network/cosmos-sdk@v0.46.1-umee/x/auth/ante/setup.go:64 +0x593
github.com/cosmos/cosmos-sdk/types.ChainAnteDecorators.func1({{0x2db8940, 0xc00012a000}, {0x2dc8100, 0xc026c968c0}, {{0xb, 0x0}, {0xc02875c270, 0xc}, 0x3a79, {0x1829c70e, ...}, ...}, ...}, ...)
\t/home/umeeandre/go/pkg/mod/github.com/umee-network/cosmos-sdk@v0.46.1-umee/types/handler.go:40 +0x136
github.com/cosmos/cosmos-sdk/baseapp.(*BaseApp).runTx(0xc001398380, 0x0, {0xc00018f600, 0x29a, 0x29a})
\t/home/umeeandre/go/pkg/mod/github.com/umee-network/cosmos-sdk@v0.46.1-umee/baseapp/baseapp.go:657 +0x736
github.com/cosmos/cosmos-sdk/baseapp.(*BaseApp).CheckTx(0xc001398380, {{0xc00018f600?, 0xc011e83710?, 0xc011e83818?}, 0xeb8888?})
\t/home/umeeandre/go/pkg/mod/github.com/umee-network/cosmos-sdk@v0.46.1-umee/baseapp/abci.go:261 +0x86
github.com/tendermint/tendermint/abci/client.(*localClient).CheckTxAsync(0xc0012bf320, {{0xc00018f600?, 0xdfb2e0?, 0xc0011b6820?}, 0xeb89a0?})
\t/home/umeeandre/go/pkg/mod/github.com/tendermint/tendermint@v0.34.21/abci/client/local_client.go:104 +0x118
github.com/tendermint/tendermint/proxy.(*appConnMempool).CheckTxAsync(0xc0011b6820?, {{0xc00018f600?, 0x0?, 0x0?}, 0x96d33930?})
\t/home/umeeandre/go/pkg/mod/github.com/tendermint/tendermint@v0.34.21/proxy/app_conn.go:126 +0x26
github.com/tendermint/tendermint/mempool/v0.(*CListMempool).CheckTx(0xc00122bd40, {0xc00018f600, 0x29a, 0x29a}, 0x0?, {0x20?, {0x0?, 0x50003?}})
\t/home/umeeandre/go/pkg/mod/github.com/tendermint/tendermint@v0.34.21/mempool/v0/clist_mempool.go:254 +0x32d
github.com/tendermint/tendermint/rpc/core.BroadcastTxSync(0xc02d12a000, {0xc00018f600, 0x29a, 0x29a})
\t/home/umeeandre/go/pkg/mod/github.com/tendermint/tendermint@v0.34.21/rpc/core/mempool.go:36 +0xf6
reflect.Value.call({0x1fe7360?, 0x2a14e50?, 0x30?}, {0x22e631b, 0x4}, {0xc02c70c630, 0x2, 0x18?})
\t/mnt/s/go/src/reflect/value.go:556 +0x845
reflect.Value.Call({0x1fe7360?, 0x2a14e50?, 0x38a?}, {0xc02c70c630, 0x2, 0x2})
\t/mnt/s/go/src/reflect/value.go:339 +0xbf
github.com/tendermint/tendermint/rpc/jsonrpc/server.makeJSONRPCHandler.func1({0x2db5b80, 0xc026d16018}, 0xc00d23da00)
\t/home/umeeandre/go/pkg/mod/github.com/tendermint/tendermint@v0.34.21/rpc/jsonrpc/server/http_json_handler.go:96 +0x1075
github.com/tendermint/tendermint/rpc/jsonrpc/server.handleInvalidJSONRPCPaths.func1({0x2db5b80?, 0xc026d16018?}, 0x7f4bf67ce108?)
\t/home/umeeandre/go/pkg/mod/github.com/tendermint/tendermint@v0.34.21/rpc/jsonrpc/server/http_json_handler.go:122 +0x5d
net/http.HandlerFunc.ServeHTTP(0xc026c96080?, {0x2db5b80?, 0xc026d16018?}, 0xc000eb9878?)
```

This panic seems to be from `*MsgCreateClient.String()` and is obscuring the actual error being wrapped by `sdkerrors.Wrap(err, msgs[0].String()) in `FeeAndPriority`.

Removing the wrap will let us see the actual error. Since I don't see other antehandlers trying to `String()` offending messages, I think it's fine to do this.

---

### Author Checklist

_All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues._

I have...

- [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [x] added `!` to the type prefix if API or client breaking change
- [x] added appropriate labels to the PR
- [x] targeted the correct branch (see [PR Targeting](https://github.com/umee-network/umee/blob/main/CONTRIBUTING.md#pr-targeting))
- [ ] provided a link to the relevant issue or specification
- [ ] added a changelog entry to `CHANGELOG.md`
- [ ] included comments for [documenting Go code](https://blog.golang.org/godoc)
- [ ] updated the relevant documentation or specification
- [ ] reviewed "Files changed" and left comments if necessary
- [ ] confirmed all CI checks have passed

### Reviewers Checklist

_All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items._

I have...

- [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [ ] confirmed all author checklist items have been addressed
- [ ] reviewed state machine logic
- [ ] reviewed API design and naming
- [ ] reviewed documentation is accurate
- [ ] reviewed tests and test coverage
- [ ] manually tested (if applicable)
  • Loading branch information
toteki committed Sep 15, 2022
1 parent 71b0d68 commit 970184f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
- [1156](https://github.com/umee-network/umee/pull/1156) Propagate context correctly.
- [1288](https://github.com/umee-network/umee/pull/1288) Safeguards LastInterestTime against time reversals and unintended interest from hard forks.
- [1357](https://github.com/umee-network/umee/pull/1357) Interptex x/0 collateral liquidity as 100%
- [1383](https://github.com/umee-network/umee/pull/1383) Remove potential panic during FeeAndPriority error case.

## [v2.0.2](https://github.com/umee-network/umee/releases/tag/v2.0.2) - 2022-05-13

Expand Down
9 changes: 4 additions & 5 deletions ante/ante_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@ import (

type IntegrationTestSuite struct {
suite.Suite
app *umeeapp.UmeeApp
anteHandler sdk.AnteHandler
ctx sdk.Context
clientCtx client.Context
txBuilder client.TxBuilder
app *umeeapp.UmeeApp
ctx sdk.Context
clientCtx client.Context
txBuilder client.TxBuilder
}

func (s *IntegrationTestSuite) SetupTest() {
Expand Down
10 changes: 2 additions & 8 deletions ante/fee.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,10 @@ func FeeAndPriority(ctx sdk.Context, tx sdk.Tx) (sdk.Coins, int64, error) {
return sdk.Coins{}, priority, nil
}

var err error
if ctx.IsCheckTx() {
err = checkFees(ctx.MinGasPrices(), providedFees, gasLimit)
} else {
err = checkFees(nil, providedFees, gasLimit)
}
if err != nil {
err = sdkerrors.Wrap(err, msgs[0].String())
return providedFees, priority, checkFees(ctx.MinGasPrices(), providedFees, gasLimit)
}
return providedFees, priority, err
return providedFees, priority, checkFees(nil, providedFees, gasLimit)
}

func checkFees(minGasPrices sdk.DecCoins, fees sdk.Coins, gasLimit uint64) error {
Expand Down

0 comments on commit 970184f

Please sign in to comment.