informalsystems / tendermint-rs

Client libraries for Tendermint/CometBFT in Rust!
Apache License 2.0
605 stars 224 forks source link

rpc: Fix deserialization of `/block_results` response when some tx results are non-ok #1391

Closed romac closed 6 months ago

romac commented 7 months ago

See https://github.com/informalsystems/hermes/issues/3817#issuecomment-1916478908 for background.


codecov-commenter commented 7 months ago

Codecov Report

Attention: 3 lines in your changes are missing coverage. Please review.

Comparison is base (194d81e) 59.0% compared to head (7388d27) 58.7%. Report is 4 commits behind head on main.

:exclamation: Current head 7388d27 differs from pull request most recent head 205ba79. Consider uploading reports for the commit 205ba79 to get more accurate results

Files Patch % Lines
rpc/tests/sei_fixtures.rs 97.4% 1 Missing :warning:
tendermint/src/chain/id.rs 0.0% 1 Missing :warning:
tendermint/src/error.rs 0.0% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #1391 +/- ## ======================================= - Coverage 59.0% 58.7% -0.4% ======================================= Files 275 274 -1 Lines 27930 27975 +45 ======================================= - Hits 16505 16443 -62 - Misses 11425 11532 +107 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

romac commented 7 months ago

@mzabaluev We should probably do something smarter in cometbft-rs, eg. model ExecTxResult as an enum rather than have all successful and failing fields in the same struct.

mzabaluev commented 7 months ago

@romac

We should probably do something smarter in cometbft-rs, eg. model ExecTxResult as an enum rather than have all successful and failing fields in the same struct.

Good idea. Which fields should be represented in results with Code != 0? I see "log" and "codespace" fields in these fixtures. What about "info"?

romac commented 7 months ago

Good question, I don't know! The fixture does not feature it in either case. Might have to check out the CometBFT source code to figure when it's included.

mzabaluev commented 7 months ago

Note that you can already match on the abci::Code domain type. As for whether the other fields may be present in ExecTxResult of a failed transaction, I can find no normative information on this. As far as I can see in the CometBFT source, result are only formed by test code, there are no helper methods to guide applications on how to properly report failures.

codespace perhaps only makes sense for non-zero codes and could be a member of redesigned Code::Err. log and info could be set with useful information in failure cases as well. gas_wanted, gas_used, and events only make sense in the success case.