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: recursive call in connection State conversion to i32 #1010

Merged
merged 5 commits into from
Dec 18, 2023
Merged

fix: recursive call in connection State conversion to i32 #1010

merged 5 commits into from
Dec 18, 2023

Conversation

dhruvja
Copy link
Contributor

@dhruvja dhruvja commented Dec 17, 2023

Closes: #1009

Description

Since the conversion from state to i32 causes a recursive call, it can be solved by matching the enum variants and returning the i32 for the respective variant.


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).

@dhruvja dhruvja changed the title fix state conversion recursive call Bug: fix state conversion recursive call Dec 17, 2023
Copy link
Contributor

@mina86 mina86 left a comment

Choose a reason for hiding this comment

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

Also, while you’re doing this could you replace TryFrom<i32> implementation to call Self::from_i32 (or the other way around)?

ibc-core/ics03-connection/types/src/connection.rs Outdated Show resolved Hide resolved
dhruvja and others added 2 commits December 18, 2023 13:25
Co-authored-by: Michal Nazarewicz <[email protected]>
Signed-off-by: Dhruv D Jain <[email protected]>
Copy link
Member

@Farhad-Shabani Farhad-Shabani left a comment

Choose a reason for hiding this comment

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

Nice catch @dhruvja, thank you for the fix.

@Farhad-Shabani Farhad-Shabani changed the title Bug: fix state conversion recursive call fix: recursive call in connection State conversion to i32 Dec 18, 2023
@Farhad-Shabani Farhad-Shabani added this to the v0.49.0 milestone Dec 18, 2023
Copy link

codecov bot commented Dec 18, 2023

Codecov Report

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

Comparison is base (3894b50) 70.69% compared to head (91f601d) 70.70%.
Report is 1 commits behind head on main.

Files Patch % Lines
ibc-core/ics03-connection/types/src/connection.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1010   +/-   ##
=======================================
  Coverage   70.69%   70.70%           
=======================================
  Files         178      178           
  Lines       17870    17865    -5     
=======================================
- Hits        12634    12631    -3     
+ Misses       5236     5234    -2     

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

@Farhad-Shabani Farhad-Shabani merged commit 38f746d into cosmos:main Dec 18, 2023
13 checks passed
@dhruvja
Copy link
Contributor Author

dhruvja commented Dec 19, 2023

Nice catch @dhruvja, thank you for the fix.

Spent quite a while figuring out the vague stack overflow bug lol.

Farhad-Shabani added a commit that referenced this pull request Dec 22, 2023
* fix state conversion recursive call

* replace match with casting

Co-authored-by: Michal Nazarewicz <[email protected]>
Signed-off-by: Dhruv D Jain <[email protected]>

* chore: add unclog

* nit

---------

Signed-off-by: Dhruv D Jain <[email protected]>
Co-authored-by: Michal Nazarewicz <[email protected]>
Co-authored-by: Farhad Shabani <[email protected]>
Farhad-Shabani added a commit that referenced this pull request Jan 2, 2024
* fix: packet sequence in Timeout handlers should be encoded in big-endian (#1004)

* fix: encode package sequence into big endian bytes

* Fix this issue in `to_vec` method.

* fix: recursive call in connection `State` conversion to `i32` (#1010)

* fix state conversion recursive call

* replace match with casting

Co-authored-by: Michal Nazarewicz <[email protected]>
Signed-off-by: Dhruv D Jain <[email protected]>

* chore: add unclog

* nit

---------

Signed-off-by: Dhruv D Jain <[email protected]>
Co-authored-by: Michal Nazarewicz <[email protected]>
Co-authored-by: Farhad Shabani <[email protected]>

* Release v0.48.2

chore: update changelog + summary

deps: bump versions to v0.48.2

---------

Signed-off-by: Dhruv D Jain <[email protected]>
Co-authored-by: Yuanchao Sun <[email protected]>
Co-authored-by: Dhruv D Jain <[email protected]>
Co-authored-by: Michal Nazarewicz <[email protected]>
Farhad-Shabani added a commit that referenced this pull request Sep 9, 2024
* fix state conversion recursive call

* replace match with casting

Co-authored-by: Michal Nazarewicz <[email protected]>
Signed-off-by: Dhruv D Jain <[email protected]>

* chore: add unclog

* nit

---------

Signed-off-by: Dhruv D Jain <[email protected]>
Co-authored-by: Michal Nazarewicz <[email protected]>
Co-authored-by: Farhad Shabani <[email protected]>
Farhad-Shabani added a commit that referenced this pull request Sep 9, 2024
* fix: packet sequence in Timeout handlers should be encoded in big-endian (#1004)

* fix: encode package sequence into big endian bytes

* Fix this issue in `to_vec` method.

* fix: recursive call in connection `State` conversion to `i32` (#1010)

* fix state conversion recursive call

* replace match with casting

Co-authored-by: Michal Nazarewicz <[email protected]>
Signed-off-by: Dhruv D Jain <[email protected]>

* chore: add unclog

* nit

---------

Signed-off-by: Dhruv D Jain <[email protected]>
Co-authored-by: Michal Nazarewicz <[email protected]>
Co-authored-by: Farhad Shabani <[email protected]>

* Release v0.48.2

chore: update changelog + summary

deps: bump versions to v0.48.2

---------

Signed-off-by: Dhruv D Jain <[email protected]>
Co-authored-by: Yuanchao Sun <[email protected]>
Co-authored-by: Dhruv D Jain <[email protected]>
Co-authored-by: Michal Nazarewicz <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Connection State conversion to i32 recursively calls itself causing stack overflow
3 participants