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

ibc: prevent invalid Height from being deserialised #932

Closed
wants to merge 1 commit into from

Conversation

mina86
Copy link
Contributor

@mina86 mina86 commented Oct 21, 2023

Change revision_height from u64 to NonZeroU64 to make invalid heights
(ones where revision_height is zero) impossible to represent. This
makes borsh and serde deserialisation fail when given invalid height
(while in the past they would construct an invalid object).


PR author checklist:

  • Added changelog entry, using unclog.
  • Added tests.
  • Linked to GitHub issue.
  • Updated code comments and documentation (e.g., docs/).
  • Tagged one reviewer who will be the one responsible for shepherding this PR.

Reviewer checklist:

  • Reviewed Files changed in the GitHub PR explorer.
  • Manually tested (in case integration/unit/mock tests are absent).

@codecov
Copy link

codecov bot commented Oct 21, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (553bc79) 67.65% compared to head (75f64a9) 67.75%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #932      +/-   ##
==========================================
+ Coverage   67.65%   67.75%   +0.09%     
==========================================
  Files         130      130              
  Lines       16415    16401      -14     
==========================================
+ Hits        11106    11112       +6     
+ Misses       5309     5289      -20     
Files Coverage Δ
crates/ibc/src/core/ics02_client/height.rs 92.68% <100.00%> (+1.43%) ⬆️

... and 7 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Change revision_height from u64 to NonZeroU64 to make invalid heights
(ones where revision_height is zero) impossible to represent.  This
makes borsh and serde deserialisation fail when given invalid height
(while in the past they would construct an invalid object).
@mina86
Copy link
Contributor Author

mina86 commented Oct 26, 2023

@Farhad-Shabani

@rnbguy
Copy link
Member

rnbguy commented Oct 30, 2023

Thanks for the PR @mina86.

We intend to change this behavior via #603. To summarize, ics-02 allows zero for heights. It is the ics-07 (tmclient) that doesn't allow zero for heights. Hence this validation should be client-specific.

But if this is blocking you, please open an issue and we will consider this PR.

@mina86 mina86 closed this Oct 30, 2023
@mina86 mina86 deleted the b branch October 30, 2023 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants