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

Refactor store_* and get_* methods to take *Path structs instead #419

Merged
merged 8 commits into from
Feb 13, 2023

Conversation

Farhad-Shabani
Copy link
Member

@Farhad-Shabani Farhad-Shabani commented Feb 11, 2023

Closes: #382

Description

I initiated reorganizing the store_* methods, but it quickly escalated to more changes.

  • The store_* methods take a Path_* argument while the get_* methods had a different approach, accepting the needed parameters directly. IMHO, we should take a consistent approach throughout the repo. I believe that using Path_* is easier to maintain, understand the purpose of args, and align with the spec.
  • This change also had an impact on the verify_* methods under the ClientState trait and allowed us to eliminate some of the #[allow(clippy::too_many_arguments)] annotations.
  • I also revised the naming of some *Path structs to be in the singular form as each abstraction refers to a specific path. This previous naming caused confusion while working with the paths. (See also ibc-go)

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 Farhad-Shabani self-assigned this Feb 11, 2023
@codecov
Copy link

codecov bot commented Feb 11, 2023

Codecov Report

Base: 55.63% // Head: 55.93% // Increases project coverage by +0.30% 🎉

Coverage data is based on head (4babf0f) compared to base (6ad6162).
Patch coverage: 51.30% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #419      +/-   ##
==========================================
+ Coverage   55.63%   55.93%   +0.30%     
==========================================
  Files         122      122              
  Lines       16996    17093      +97     
==========================================
+ Hits         9455     9561     +106     
+ Misses       7541     7532       -9     
Impacted Files Coverage Δ
crates/ibc/src/core/context.rs 3.89% <0.00%> (+<0.01%) ⬆️
crates/ibc/src/core/ics02_client/client_state.rs 75.00% <ø> (ø)
crates/ibc/src/core/ics02_client/context.rs 85.96% <ø> (ø)
...ibc/src/core/ics02_client/handler/create_client.rs 35.18% <0.00%> (ø)
.../ibc/src/core/ics02_client/handler/misbehaviour.rs 53.77% <0.00%> (ø)
crates/ibc/src/core/ics03_connection/context.rs 100.00% <ø> (ø)
...rc/core/ics03_connection/handler/conn_open_init.rs 56.31% <0.00%> (ø)
...s/ibc/src/clients/ics07_tendermint/client_state.rs 39.07% <23.71%> (+1.26%) ⬆️
...src/core/ics04_channel/handler/timeout_on_close.rs 44.21% <33.33%> (-0.03%) ⬇️
...bc/src/core/ics02_client/handler/upgrade_client.rs 63.74% <37.50%> (-0.44%) ⬇️
... and 37 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.

@Farhad-Shabani Farhad-Shabani marked this pull request as ready for review February 13, 2023 18:59
@@ -534,14 +519,14 @@ pub trait ExecutionContext: ValidationContext {
/// Stores the given connection_end at path
fn store_connection(
&mut self,
connections_path: ConnectionsPath,
connection_path: ConnectionPath,
Copy link
Contributor

Choose a reason for hiding this comment

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

Contrary to what was stated in #319, I think all path arguments should be passed by reference, since either the host will generate the path string with to_string(), or read the internal fields to access its store data structure.

Copy link
Member Author

Choose a reason for hiding this comment

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

Because of the recent change, I was hesitant to say that :). My thought was there should be a reservation.
But yes, I also think so

Copy link
Member Author

Choose a reason for hiding this comment

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

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 d5a4416 into main Feb 13, 2023
@plafer plafer deleted the farhad/382-fix branch February 13, 2023 22:04
Farhad-Shabani added a commit that referenced this pull request Sep 9, 2024
* Implement *Path for get_* and store_* methods

* Refactor Path structure to be singular

* cargo fmt

* Add changelog entry

* Fix some args

* Fix some other path args in ics04

* Mend some naming mistakes

* Pass path args by reference into store_* methods
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.

ExecutionContext: all store_* methods should take a Path as input
2 participants