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

Change ChannelId representation to String #2361

Merged
merged 13 commits into from
Jul 4, 2022
Merged

Conversation

mzabaluev
Copy link
Contributor

@mzabaluev mzabaluev commented Jul 1, 2022

Closes: cosmos/ibc-rs#39

Description

ICS 024 does not restrict channel IDs to the "channel-{N}" format.

Change the internal representation of ChannelId to String, and modify the API accordingly to the similar ID types.


PR author checklist:

  • Added changelog entry, using unclog.
  • Added tests: integration (for Hermes) or unit/mock tests (for modules).
  • Linked to GitHub issue.
  • Updated code comments and documentation (e.g., docs/).

Reviewer checklist:

  • Reviewed Files changed in the GitHub PR explorer.
  • Manually tested (in case integration/unit/mock tests are absent).

@mzabaluev mzabaluev marked this pull request as ready for review July 1, 2022 17:18
- Create valid IDs with ChannelId::new (could be under valid length).
- Format as the inner string with Display.
- Derive Debug, no need for a manual definition, which printed it wrong.
The length limit is now 64 characters in accordance with ICS 024
and ibc-go, but longer than previous code admitted.
@romac romac self-assigned this Jul 4, 2022
- File under the modules component.
- Add an entry to bug-fixes mentioning the corrected enforcement
  of the length limit on channel IDs.
/// A valid Identifier must be between 10-64 characters and only contain lowercase
/// alphabetic characters,
pub fn validate_channel_identifier(id: &str) -> Result<(), Error> {
validate_identifier(id, 8, 64)
Copy link
Member

Choose a reason for hiding this comment

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

There is discrepancy between the spec and the code here. The spec says channel ids must be 10 characters long or more but that would mean that channel-0 is not a valid channel id. We should clarify that.

Copy link
Member

@romac romac Jul 4, 2022

Choose a reason for hiding this comment

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

Clarified offline, the spec is wrong. Let's update the comment above then.

modules/src/core/ics24_host/validate.rs Outdated Show resolved Hide resolved
Copy link
Member

@romac romac 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 grinding through all this 🙏

@romac romac merged commit 11f8b79 into master Jul 4, 2022
@romac romac deleted the mikhail/string-channel-id branch July 4, 2022 13:49
hu55a1n1 pushed a commit to hu55a1n1/hermes that referenced this pull request Sep 13, 2022
ICS 024 does not restrict channel IDs to the "channel-{N}" format.

Change the internal representation of ChannelId to String, and modify the API accordingly to the similar ID types.

---

* Change ChannelId representation to String

ICS 024 does not restrict channel IDs to the "channel-{N}" format.

* More clone calls for ChannelId, clippy fixes

* fmt fix

* Changelog entry for informalsystems#2361

* ChannelId formatting fixes

- Create valid IDs with ChannelId::new (could be under valid length).
- Format as the inner string with Display.
- Derive Debug, no need for a manual definition, which printed it wrong.

* Relax the channel identifier valid length

Contrary to what is still documented in ICS 024,
the minimum length accepted by ibc-go is 8 characters:
https://github.com/cosmos/ibc-go/blob/e04964912c266bab923253c48d72cc8ec8b38f5e/modules/core/24-host/validate.go#L76-L81

* Add unit tests for validate_channel_identifier

* Tweak test data for excessively long channel IDs

The length limit is now 64 characters in accordance with ICS 024
and ibc-go, but longer than previous code admitted.

* Improve changelog entries for informalsystems#2361

- File under the modules component.
- Add an entry to bug-fixes mentioning the corrected enforcement
  of the length limit on channel IDs.

* Fix outdated comment

* Clarify comment

Co-authored-by: Romain Ruetschi <romain@informal.systems>
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.

2 participants