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

Check if ClientStatePath is empty during client creation #605

Merged
merged 2 commits into from
Apr 12, 2023

Conversation

Farhad-Shabani
Copy link
Member

Closes: #604


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 Apr 5, 2023

Codecov Report

Patch coverage: 77.77% and no project coverage change.

Comparison is base (845cf48) 72.88% compared to head (c9eba3e) 72.88%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #605   +/-   ##
=======================================
  Coverage   72.88%   72.88%           
=======================================
  Files         126      126           
  Lines       15699    15703    +4     
=======================================
+ Hits        11442    11445    +3     
- Misses       4257     4258    +1     
Impacted Files Coverage Δ
crates/ibc/src/core/ics02_client/error.rs 5.55% <ø> (ø)
crates/ibc/src/mock/context.rs 75.30% <75.00%> (ø)
...ibc/src/core/ics02_client/handler/create_client.rs 81.94% <80.00%> (-0.41%) ⬇️

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 in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

ClientError::ClientIdentifierConstructor {
client_type: client_state.client_type(),
counter: id_counter,
validation_error: e,
}
})?;

let stored_client_state = ctx.client_state(&client_id);
match stored_client_state {
Err(ContextError::ClientError(ClientError::ClientStateNotFound { client_id: _ })) => (),
Copy link
Contributor

Choose a reason for hiding this comment

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

I wouldn't rely on users actually returning ClientStateNotFound. As we do elsewhere, we should just check is_err() here. I would wait for my suggested error system redesign to be implemented before we match on specific errors returned from users

Copy link
Member Author

Choose a reason for hiding this comment

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

I see, but I'd like to point out that relying on the is_err() still leaves the validation step dependent on the users. wouldn't be much better. If client_state() fails due to any other reasons such as "broken storage" or "unable to fetch from storage", etc... the validation will wrongly pass, which is why I created issue #607.
I think, this is a significant one needing to be addressed even before we begin to refactor our errors.

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 using is_err() achieves the exact same behavior from ibc-go. Being more specific about which error occurred would be good for sure, but I consider using is_err() as at least following the same standard as ibc-go.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, though IBC-go's situation is better than ours. The nil is handled internally, users' preferences in error picking do not affect that. Plus, the storage is in a more known and clearer position with respect to the entire IBC implementation, which makes it less susceptible to errors, but it still suffers from this problem.
np, I went with the is_err approach for this PR (c9eba3e) Though, the discussed issue remains there.

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 907ed69 into main Apr 12, 2023
@plafer plafer deleted the farhad/check-clientstatepath branch April 12, 2023 13:53
Farhad-Shabani added a commit that referenced this pull request Sep 9, 2024
* Check if ClientStatePath is empty during client creation

* Rewrite ClientState present check with is_ok
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.

[ICS02] ClientStatePath is not checked during client creation
2 participants