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

feat: optimize IdentifierError variants #942

Merged
merged 8 commits into from
Nov 27, 2023
Merged

feat: optimize IdentifierError variants #942

merged 8 commits into from
Nov 27, 2023

Conversation

mina86
Copy link
Contributor

@mina86 mina86 commented Nov 3, 2023

Remove IdentifierError::Empty and ContainSeparator variants as they
are redundant. The former is a special case of InvalidLength; the
latter is a special case of InvalidCharacter.

With that, remove length checking from validate_identifier_chars
(which didn’t belong there anyway) and rely on check in
validate_identifier_length instead.

Closes: #978


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

Copy link

codecov bot commented Nov 3, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (45b1c97) 70.23% compared to head (251f9ef) 70.76%.
Report is 6 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #942      +/-   ##
==========================================
+ Coverage   70.23%   70.76%   +0.53%     
==========================================
  Files         177      178       +1     
  Lines       17733    17943     +210     
==========================================
+ Hits        12455    12698     +243     
+ Misses       5278     5245      -33     

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

@Farhad-Shabani
Copy link
Member

Farhad-Shabani commented Nov 4, 2023

Thanks @mina86. Just kindly note that you are touching parts that are getting refactored thru this PR as well: #941.

Let me page @rnbguy to look into these points and apply the relevant changes there (particular first one).

@Farhad-Shabani
Copy link
Member

Farhad-Shabani commented Nov 4, 2023

@mina86, also on a side request:
Really appreciate if you open an issue and put the description there before making any changes and link that to your PR.
This way, it won't disrupt our project board and helps us prioritize things. We're trying to be efficient with our bandwidth. So, if something's lower on the priority list, we can give you the heads up, so you won't waste time on it.
Thanks!

@rnbguy
Copy link
Collaborator

rnbguy commented Nov 6, 2023

hey @mina86, #941 and this PR are in conflict. Please wait till we merge #941.

@rnbguy
Copy link
Collaborator

rnbguy commented Nov 7, 2023

The PR has been merged, you may continue with your PR 🙂 but it is now in conflict with main branch.

@mina86
Copy link
Contributor Author

mina86 commented Nov 10, 2023

@mina86, also on a side request: Really appreciate if you open an issue and put the description there before making any changes and link that to your PR. This way, it won't disrupt our project board and helps us prioritize things. We're trying to be efficient with our bandwidth. So, if something's lower on the priority list, we can give you the heads up, so you won't waste time on it. Thanks!

From my point of view I’d rather write a PR and then be told that the review is low on priority list than create an issue. I often don’t exactly know what I want and by the time I formulate an Issue I already have code written for it. If that’s the only concern than I’d prefer not deal with Issues. ;) But let me know if me sending PRs break your workflow.

I guess two features that I’m pretty sure I’d love to have for sure are efficient zero-copy TryFrom<Vec<u8>> and TryFrom<String>> implementations for the identifiers.

Copy link
Collaborator

@rnbguy rnbguy left a comment

Choose a reason for hiding this comment

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

Thanks 👍

crates/ibc/src/core/ics24_host/identifier/validate.rs Outdated Show resolved Hide resolved
Copy link
Collaborator

@rnbguy rnbguy left a comment

Choose a reason for hiding this comment

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

Thanks for the optimization ! 🎉

Signed-off-by: Rano | Ranadeep <ranadip.bswas@gmail.com>
@rnbguy rnbguy changed the title feat: improve set of IdentifierError variants feat: optimize IdentifierError variants Nov 27, 2023
@rnbguy rnbguy merged commit 8f2ddfe into cosmos:main Nov 27, 2023
13 checks passed
@mina86 mina86 deleted the a branch November 27, 2023 16:45
Farhad-Shabani pushed a commit that referenced this pull request Sep 9, 2024
* remove ContainsSeparator

* remove length

* remove Empty

* changelog

* update changelog entry

Signed-off-by: Rano | Ranadeep <ranadip.bswas@gmail.com>

---------

Signed-off-by: Rano | Ranadeep <ranadip.bswas@gmail.com>
Co-authored-by: Rano | Ranadeep <ranadip.bswas@gmail.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.

IdentifierError variants are not mutually exclusive
3 participants