Skip to content

Intercept and Format Tendermint Broadcast Errors #4972

@alexanderbez

Description

@alexanderbez

Summary

Through the CLIContext, we can broadcast signed txs in one of three ways: async, sync, and block via node.BroadcastTx*. Regardless of the mode, all the modes return a (Result*, error).

Problem Definition

When calling node.BroadcastTx* we get no error and a valid Result* if the tx successfully executed (depending on the mode). This means the client will get a TxResponse returned back.

However, there are a few cases where an error can be returned from Tendermint because the tx wasn't even executed at all. Namely, ErrTxTooLarge, ErrPreCheck, and ErrTxInCache. When these errors are returned, it would be nice for clients to still get back a TxResponse with an appropriate code.

Proposal

During node.BroadcastTx*, intercept the error and check if it's any of the above mentioned. If so, map that to an SDK error code and return a TxResponse.

e.g.

	if err != nil {
		switch err {
		case mempool.ErrTxInCache:
			return sdk.TxResponse{Code: ...}, nil
		}
	}

For Admin Use

  • Not duplicate issue
  • Appropriate labels applied
  • Appropriate contributors tagged
  • Contributor assigned/self-assigned

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions