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

Add Height domain type #304

Merged
merged 9 commits into from
Oct 13, 2020
Merged

Add Height domain type #304

merged 9 commits into from
Oct 13, 2020

Conversation

ancazamfir
Copy link
Collaborator

@ancazamfir ancazamfir commented Oct 12, 2020

Closes: cosmos/ibc-rs#110
Closes: https://github.com/informalsystems/ibc-rs/issues/191


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

@ancazamfir ancazamfir requested a review from romac as a code owner October 12, 2020 15:36
@ancazamfir ancazamfir self-assigned this Oct 12, 2020
@codecov-io
Copy link

codecov-io commented Oct 12, 2020

Codecov Report

Merging #304 into master will increase coverage by 23.9%.
The diff coverage is 61.9%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    informalsystems/hermes#304      +/-   ##
=========================================
+ Coverage    13.6%   37.6%   +23.9%     
=========================================
  Files          69     122      +53     
  Lines        3752    7978    +4226     
  Branches     1374    2861    +1487     
=========================================
+ Hits          513    3000    +2487     
- Misses       2618    4667    +2049     
+ Partials      621     311     -310     
Impacted Files Coverage Δ
modules/src/events.rs 0.0% <0.0%> (ø)
modules/src/ics02_client/events.rs 0.0% <ø> (ø)
modules/src/ics02_client/raw.rs 0.0% <0.0%> (ø)
modules/src/ics03_connection/context.rs 0.0% <0.0%> (ø)
modules/src/ics03_connection/error.rs 16.6% <0.0%> (-16.7%) ⬇️
modules/src/ics04_channel/error.rs 75.0% <ø> (+50.0%) ⬆️
modules/src/ics04_channel/packet.rs 0.0% <0.0%> (ø)
modules/src/ics07_tendermint/client_def.rs 0.0% <0.0%> (ø)
modules/src/ics07_tendermint/error.rs 75.0% <ø> (+75.0%) ⬆️
modules/src/ics18_relayer/error.rs 0.0% <0.0%> (ø)
... and 222 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a8ffca2...6b18f9f. Read the comment docs.

@ancazamfir ancazamfir requested a review from adizere October 12, 2020 16:19

/// is_epoch_format() checks if a chain_id is in the format required for parsing epochs
/// The chainID must be in the form: `{chainID}-{version}
fn is_epoch_format(chain_id: String) -> bool {
Copy link
Member

Choose a reason for hiding this comment

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

Is this specified somewhere (in an ICS)? I did not come across it so far.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not afaik

Copy link
Member

Choose a reason for hiding this comment

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

Then is this requirement we invented ourselves? In any case, if this is a requirement on the name of a chain, it probably should be captured and standardized in cosmos/ics.

Perhaps @cwgoes knows more?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We do the same handling as in cosmos-SDK but I agree it should be standardized.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is a requirement we initially came up with when implementing epochs for the tendermint light client on the SDK's IBC implementation. The issue is we need the epoch number to be included in the signed header. The solution is to put it in the chainID, but this requires some standardized parsing format so we can obtain the epoch number from the chainID.

ref: issue, comment

We also renamed epoch to version as per a suggestion

Copy link

Choose a reason for hiding this comment

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

Aye. Admittedly this is a bit of a hack, but it's a compromise to make future (safe) upgrades easier.

We can add these details to the ICS standards as well.

modules/src/ics02_client/height.rs Show resolved Hide resolved
modules/src/ics03_connection/error.rs Outdated Show resolved Hide resolved
modules/src/ics03_connection/msgs/conn_open_ack.rs Outdated Show resolved Hide resolved
modules/src/ics07_tendermint/consensus_state.rs Outdated Show resolved Hide resolved
modules/src/lib.rs Outdated Show resolved Hide resolved
modules/src/proofs.rs Outdated Show resolved Hide resolved
romac added 4 commits October 13, 2020 11:53
- Remove unused error kind
- Remove outdated comment
- Use crate::Height everywhere
- Use RawHeight alias
Copy link
Member

@adizere adizere left a comment

Choose a reason for hiding this comment

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

Thanks Anca & Romain for the quick fixes and feedback. Looking forward to getting this in master!

@romac
Copy link
Member

romac commented Oct 13, 2020

Let's merge this after #292.

adizere
adizere previously approved these changes Oct 13, 2020
@@ -468,7 +468,7 @@ impl MsgTimeout {
packet: Packet,
next_sequence_recv: Option<u64>,
proof: CommitmentProof,
proof_height: Height,
proof_height: RawHeight,
Copy link
Member

Choose a reason for hiding this comment

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

Minor comment: it's a bit odd to see raw type side by side with domain type. I guess we could have just as well used crate::Height instead of ibc_proto::ibc::core::client::v1::Height as RawHeight; unless I'm missing something.

We can fix this in a later iteration, and perhaps also split the modules/src/ics04_channel/msgs.rs file like we did in ICS3.

Copy link
Member

Choose a reason for hiding this comment

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

Agreed, let’s use crate::Height instead.

romac
romac previously approved these changes Oct 13, 2020
@romac romac dismissed stale reviews from adizere and themself October 13, 2020 16:29

Tests are failing

@romac romac merged commit c8a7c65 into master Oct 13, 2020
@romac romac deleted the anca/height_domaintype branch October 13, 2020 16:43
hu55a1n1 pushed a commit to hu55a1n1/hermes that referenced this pull request Sep 13, 2022
* WIP - add Height domain type and make the code compile

* Change crate::Height to point to the domain type

* Cleanup unused variables

* Implement PartialOrd and Ord for Height

* Address Adi's comments

- Remove unused error kind
- Remove outdated comment
- Use crate::Height everywhere
- Use RawHeight alias

* Cleaned up new() for ICS4 messages and Proof to eliminate raw type

Co-authored-by: Romain Ruetschi <[email protected]>
Co-authored-by: Adi Seredinschi <[email protected]>
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.

6 participants