Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix JSON deserialization of abci::ResponseInfo #1131

Merged
merged 5 commits into from
Jun 9, 2022

Conversation

mzabaluev
Copy link
Contributor

@mzabaluev mzabaluev commented May 24, 2022

Fixes: #1132

The fields of the tendermint-go struct equivalent to abci::ResponseInfo are annotated with json:"omitempty", so give them default values for Deserialize. The /abci_info endpoint is known to omit the app_version field in some recent revisions of Gaia.

  • Referenced an issue explaining the need for the change
  • Updated all relevant documentation in docs
  • Updated all code comments where relevant
  • Wrote tests
  • Added entry in .changelog/

The fields are annotated with json:"omitempty" in the Go source,
so give them default values for Deserialize. The /abci_info endpoint
is known to omit the app_version field in some recent revisions of Gaia.
Comment on lines +91 to +100
(".tendermint.abci.ResponseInfo.data", DEFAULT),
(".tendermint.abci.ResponseInfo.version", DEFAULT),
(
".tendermint.abci.ResponseInfo.app_version",
QUOTED_WITH_DEFAULT,
),
(
".tendermint.abci.ResponseInfo.last_block_height",
QUOTED_WITH_DEFAULT,
),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if it's best to fix it here with compiler tweaks, or maybe move the serde annotations to the AbciInfo struct, where the serde traits are really used, while currently being delegated to tendermint_proto::abci::ResponseInfo.
We have to customize serde for every field of the involved struct in either case, so doing it directly in source would be cleaner.

greg-szabo
greg-szabo previously approved these changes May 24, 2022
Copy link
Member

@greg-szabo greg-szabo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. You'd think "default" de/serializations have been around long enough that this is already listed in the consts list, but alas...

Anyway, if this works for now, cool.

The only field of abci::ResponseInfo where it remained missing,
 to match the json:"omitempty" flag in Go.
@codecov-commenter
Copy link

codecov-commenter commented May 25, 2022

Codecov Report

Merging #1131 (11396ba) into master (cd3e391) will increase coverage by 0.0%.
The diff coverage is n/a.

@@          Coverage Diff           @@
##           master   #1131   +/-   ##
======================================
  Coverage    64.7%   64.7%           
======================================
  Files         231     231           
  Lines       15637   15637           
======================================
+ Hits        10121   10124    +3     
+ Misses       5516    5513    -3     
Impacted Files Coverage Δ
testgen/src/commit.rs 91.3% <0.0%> (+0.6%) ⬆️
tendermint/src/block/commit_sig.rs 80.3% <0.0%> (+1.9%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cd3e391...11396ba. Read the comment docs.

@thanethomson thanethomson merged commit 7ad20be into master Jun 9, 2022
@thanethomson thanethomson deleted the mikhail/allow-omitted-fields-in-abci_info branch June 9, 2022 16:09
mzabaluev added a commit that referenced this pull request Jul 21, 2022
Backport of #1131 to v0.23.x

The fields are annotated with json:"omitempty" in the Go source,
so give them default values for Deserialize. The /abci_info endpoint
is known to omit some of the fields depending on what the node
software supplies.
thanethomson added a commit that referenced this pull request Jul 21, 2022
…1156)

* Fix JSON deserialization of abci::ResponseInfo

Backport of #1131 to v0.23.x

The fields are annotated with json:"omitempty" in the Go source,
so give them default values for Deserialize. The /abci_info endpoint
is known to omit some of the fields depending on what the node
software supplies.

* Fix a clippy lint

* Correct fmt

* Use writeln! instead of write!

Co-authored-by: Thane Thomson <connect@thanethomson.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Deserialization of RPC endpoint /abci_info fails with recent revisions of gaiad
4 participants