Cosmos-sdk: The omission of codespaces when BroadcastTxSync

Created on 24 Mar 2020  路  6Comments  路  Source: cosmos/cosmos-sdk

https://github.com/cosmos/cosmos-sdk/blob/a1ac04c96b15eba2c02f19b359b65dac9a5e9d0a/types/result.go#L186

When the broadcast mode SYNC, the codespace field is omitted.
Is it intended?

If the failure is from the module, such as msg.ValidateBasic(), the codespace is significant for recognizing the errors.

good first issue

Most helpful comment

Totally, I agree! But wouldn't ResultBroadcastTx need to support and include codespace? If so, that's a change required in Tendermint first. Then we can support it here 馃憤

All 6 comments

Messages are not executed during sync/async -- only the ante-handler. Thus it makes no sense to have a codespace. You'll notice, ResultBroadcastTx doesn't have a codespace field.

@alexanderbez

  • Messages are not executed during sync/async -> yes
  • only the ante-handler -> validateBasicTxMsgs is also executed.

https://github.com/cosmos/cosmos-sdk/blob/206a511fa9b636f007c85959505a4de6b2367223/baseapp/baseapp.go#L523

Right, so I'm having trouble following the proposal exactly...?

I mean,

The codespace is also needed to SYNC mode.
If an error occurs in validateBasicTxMsgs, codespace + code guarantees the error uniqueness.

I made an example as below.

  • cosmos-sdk/MsgCreateValidator
  • set commission.rate to -1
  • then broadcast sync response is
    json { "height": "0", "txhash": "DF2FC489D5EA6F60FA0DC651A5D2C3F62A7947C2845AA608F1C176D80DD5B6BE", "code": 9, "raw_log": "commission must be positive" }
    the code 9 is used by
  • ErrUnknownAddress
  • ErrInvalidProposalAmount
  • ErrCommissionNegative

Clients can not recognize the exact error by code only.

Totally, I agree! But wouldn't ResultBroadcastTx need to support and include codespace? If so, that's a change required in Tendermint first. Then we can support it here 馃憤

codespace was added to ResultBroadcastTx in the latest tendermint version(v0.33.4)

https://github.com/tendermint/tendermint/blob/master/CHANGELOG.md#features

Could you update the issue status?

Was this page helpful?
0 / 5 - 0 ratings