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

Channel query validation & tests #163

Merged
merged 6 commits into from
Jul 23, 2020
Merged

Channel query validation & tests #163

merged 6 commits into from
Jul 23, 2020

Conversation

adizere
Copy link
Member

@adizere adizere commented Jul 21, 2020

Closes: cosmos/ibc-rs#130
Closes: cosmos/ibc-rs#133
Closes: cosmos/ibc-rs#126

Description


For contributor use:

  • Unit tests written
  • Added test to CI if applicable
  • Updated CHANGELOG_PENDING.md
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Updated relevant documentation (docs/) and code comments
  • Re-reviewed Files changed in the Github PR explorer

@adizere adizere marked this pull request as ready for review July 22, 2020 13:38
.collect::<Result<Vec<_>, _>>()
.map_err(|e| Kind::IdentifierError.context(e))?;

// No explicit validation is necessary for the version attribute (opaque field).
Copy link
Member

Choose a reason for hiding this comment

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

Then what's the point of it? :)
Is it checked in some other context?

Copy link
Member Author

Choose a reason for hiding this comment

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

The full details on the version field are here:
https://github.com/cosmos/ics/tree/master/spec/ics-004-channel-and-packet-semantics#versioning

The version field may be checked in other contexts (e.g., during a handshake, but as far as I can tell, it is not). But the point is that this field may contain fairly arbitrary data, according to the ICS4 spec. Looking through the cosmos-sdk codebase, however, I see that there is some basic validation on this field:

https://github.com/cosmos/cosmos-sdk/blob/e6a56226a88ec4e8761b1388a3a666af627d9e2e/x/ibc/04-channel/types/channel.go#L72

I'm adding a TODO to clarify this.

Copy link
Member Author

Choose a reason for hiding this comment

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

It seems that there might be a mistake in cosmos-sdk code. We should permit an empty version string for ChannelEnd, so basically no validation is required here.

cosmos/cosmos-sdk#6830

Copy link
Member

@greg-szabo greg-szabo left a comment

Choose a reason for hiding this comment

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

Looks good.

I feel like we should do something about the version check but I don't have enough context yet to understand what that version entails.

Thanks for fixing my comments. :)

The only thing that could get better here is the same advice Ismail gave me: decompose different issues into separate branches/PRs. I think the ics24 fix could have gone into its own PR. But I'm still learning this feat too.

@greg-szabo
Copy link
Member

Ah, one more thing! If you merge master into your branch, you can get rid of the nightly coverage error. If others are picky about it, it's an easy solution.

Copy link
Contributor

@andynog andynog left a comment

Choose a reason for hiding this comment

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

  • Changes look good to me.

Copy link
Contributor

@andynog andynog left a comment

Choose a reason for hiding this comment

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

Just a couple of comments that would be good to get some feedback before merging.

modules/src/ics24_host/validate.rs Outdated Show resolved Hide resolved
// Parses the State out from a i32.
pub fn from_i32(s: i32) -> Result<Self, error::Error> {
match s {
0 => Ok(Self::Uninitialized),
Copy link
Contributor

Choose a reason for hiding this comment

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

Just out of curiosity, is the Uninitialized state an implementation requirement ? Just asking because in the ics4 spec the Channel state only has

enum ChannelState { INIT, OPENTRY, OPEN, CLOSED, }

I know the Golang implementation has the uninitialized state too, so maybe the spec should be updated ?

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 think this is an oversight in the cosmos/ICS repo and should be fixed in ICS4. I pinged Chris about it, will update here with details!

Copy link
Member Author

Choose a reason for hiding this comment

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

Opened an issue in cosmos/ibc#452.

Copy link
Contributor

@andynog andynog left a comment

Choose a reason for hiding this comment

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

Looks good now.

@adizere adizere merged commit 6f89b2d into master Jul 23, 2020
@adizere adizere deleted the adi/channel-query branch July 23, 2020 15:30
romac pushed a commit that referenced this pull request Jul 29, 2020
…48 #164)

* Refactored the location of JSON files for serialization testing (#118).

* Validation for channel end + tests template; needs more tests (#148).

* Refining tests for channel end.

* Aligned identifier validation with ICS024 & updated tests (#164).

* Added TODO re: version validation; fix VALID_SPECIAL_CHARS to remove space.

* Fixing the TODO for version field validation.
hu55a1n1 pushed a commit to hu55a1n1/hermes that referenced this pull request Sep 13, 2022
…lsystems#163 #148 #164)

* Refactored the location of JSON files for serialization testing (#118).

* Validation for channel end + tests template; needs more tests (#148).

* Refining tests for channel end.

* Aligned identifier validation with ICS024 & updated tests (#164).

* Added TODO re: version validation; fix VALID_SPECIAL_CHARS to remove space.

* Fixing the TODO for version field validation.
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.

3 participants