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

Additional tests for counterparty conn & chan ids at initialization #360

Merged
merged 10 commits into from
Jan 20, 2023

Conversation

Farhad-Shabani
Copy link
Member

@Farhad-Shabani Farhad-Shabani commented Jan 19, 2023

Closes: #175

Summary

Ensure that disallows empty strings for counterparty connection and channel ids work correctly at the initialization phases (conn_open_init and chan_open_init)

Description

Firstly, It looks like the ICS24_host statement around identifiers implicitly refers to successfully made (open) connections. However, it’s true... it does not consider the transient state of the *ends during the opening process.

Btw, I also tested the opening of a connection using basecoin-rs and Hermes and it worked properly.
The counterparty connection id was set to None for the sent MsgConnectionOpenInit.

In this PR, a few comments and tests have been added to check the corner scenarios.
Also, while skimming the codes, I changed the naming of the client_counter, connection_counter, and channel_counter methods to correspond with the exact work they do. Counting is their side job, but they're basically used for identifier creation all over the repository. This way it would also align with IBC-go. Though… take it as a suggestion.


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

Farhad-Shabani and others added 2 commits January 18, 2023 21:17
* Investigate initialization with empty string for counterparty ids
* Add some unit tests for counterparty conn & chan ids
* Rename methods that creates identifiers
Signed-off-by: Farhad Shabani <Farhad.Shabani@gmail.com>
@Farhad-Shabani Farhad-Shabani self-assigned this Jan 19, 2023
@codecov
Copy link

codecov bot commented Jan 19, 2023

Codecov Report

Base: 57.68% // Head: 57.71% // Increases project coverage by +0.03% 🎉

Coverage data is based on head (30727a0) compared to base (7f62c1b).
Patch coverage: 90.74% of modified lines in pull request are covered.

❗ Current head 30727a0 differs from pull request most recent head e2ea605. Consider uploading reports for the commit e2ea605 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #360      +/-   ##
==========================================
+ Coverage   57.68%   57.71%   +0.03%     
==========================================
  Files         124      124              
  Lines       15333    15357      +24     
==========================================
+ Hits         8845     8864      +19     
- Misses       6488     6493       +5     
Impacted Files Coverage Δ
crates/ibc/src/core/context.rs 5.81% <0.00%> (-0.04%) ⬇️
crates/ibc/src/core/ics02_client/context.rs 85.96% <ø> (ø)
crates/ibc/src/core/ics03_connection/context.rs 100.00% <ø> (ø)
crates/ibc/src/core/ics04_channel/context.rs 74.54% <ø> (ø)
...bc/src/core/ics04_channel/handler/chan_open_ack.rs 49.11% <ø> (ø)
...rc/core/ics04_channel/handler/chan_open_confirm.rs 44.17% <ø> (ø)
...bc/src/core/ics04_channel/handler/chan_open_try.rs 52.91% <ø> (ø)
crates/ibc/src/core/ics26_routing/handler.rs 91.11% <ø> (ø)
...rc/core/ics03_connection/handler/conn_open_init.rs 56.07% <50.00%> (-0.24%) ⬇️
crates/ibc/src/core/ics03_connection/connection.rs 29.46% <100.00%> (+0.22%) ⬆️
... and 10 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@@ -255,7 +255,7 @@ mod val_exec_ctx {

/// Returns a natural number, counting how many clients have been created thus far.
/// The value of this counter should increase only via method `ClientKeeper::increase_client_counter`.
fn client_counter(&self) -> Result<u64, ContextError>;
fn generate_client_identifier(&self) -> Result<u64, ContextError>;
Copy link
Contributor

Choose a reason for hiding this comment

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

Note that we have an issue (#14) that tracks this. But also if the function were to be named generate_client_identifier, I would expect it to return a ClientId as opposed to an "id counter".

Can we make that change in another PR that addresses #14, in order to have self-contained PRs?

Copy link
Member Author

Choose a reason for hiding this comment

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

Didn't notice that issue.
Sure. Will do so

@Farhad-Shabani Farhad-Shabani marked this pull request as ready for review January 19, 2023 17:01
@plafer
Copy link
Contributor

plafer commented Jan 19, 2023

Note that I simplified the expression that confused me previously. Let me know if you also find that cleaner.

70c6c0d
30727a0

@Farhad-Shabani
Copy link
Member Author

Note that I simplified the expression that confused me previously. Let me know if you also find that cleaner.

70c6c0d 30727a0

Now it is easier to catch 👍

Copy link
Contributor

@plafer plafer left a comment

Choose a reason for hiding this comment

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

🙏 thank you for all these tests!

crates/ibc/src/core/context.rs Outdated Show resolved Hide resolved
crates/ibc/src/core/ics02_client/context.rs Outdated Show resolved Hide resolved
crates/ibc/src/core/ics03_connection/context.rs Outdated Show resolved Hide resolved
crates/ibc/src/core/ics04_channel/context.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@plafer plafer left a comment

Choose a reason for hiding this comment

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

🎉

@plafer plafer merged commit b807d8f into main Jan 20, 2023
@plafer plafer deleted the farhad/conn_id_investigation branch January 20, 2023 14:42
Farhad-Shabani added a commit that referenced this pull request Sep 9, 2024
…360)

* Additional tests for counterparty conn & chan ids at initialization

* Investigate initialization with empty string for counterparty ids
* Add some unit tests for counterparty conn & chan ids
* Rename methods that creates identifiers

* Fix cargo check & add changelog entry

* Revert *counter naming changes

* Fix a comment in MockIbcStore

* Change unclog section to improvements

* Fix some comments from reverting *_counters names

* Simplify conn counterparty parsing

* simplify channel counterparty parsing

* Fix comment issues

Signed-off-by: Farhad Shabani <Farhad.Shabani@gmail.com>
Co-authored-by: Philippe Laferriere <plafer@protonmail.com>
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.

Investigate: Connection's RawCounterparty.connection_id can be "" in the spec, but not our impl
2 participants