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

Allow a conn open ack to succeed in the happy case #700

Merged
merged 9 commits into from
Feb 23, 2021

Conversation

vitorenesduarte
Copy link
Contributor

@vitorenesduarte vitorenesduarte commented Feb 22, 2021

Closes: #699

Description

Currently, the conn open ack handler requires a connection to have the counterparty connection id set (line 36):

https://github.com/informalsystems/ibc-rs/blob/02aef9cf5055a3817579b555c84289b99d5d08a8/modules/src/ics03_connection/handler/conn_open_ack.rs#L33-L45

However, if the connection is in the Init state (the happy/normal case), the counterparty connection id is unknown (i.e. a None), in which case the conn open ack fails with a ConnectionMismatch.

With this PR, we allow the counterparty connection id to be None, and only fail with a ConnectionMismatch in case it's a Some (that doesn't match).

Since theMsgConnectionOpenAck.counterparty_connection_id field is always required, this PR also changes it to simply be a ConnectionId (instead of an Option<ConnectionId>).


For contributor use:

  • Updated the Unreleased section of CHANGELOG.md with the issue.
  • If applicable: Unit tests written, added test to CI.
  • 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.

conn_end_cparty.set_state(State::Init);
conn_end_cparty.set_counterparty(Counterparty::new(
client_id.clone(),
None, // incorrect field
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This test has been removed as my understanding is that msg.counterparty_connection_id should always be a Some (which hints that it should not be an Option).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now this field is no longer an Option.

@@ -96,7 +96,7 @@ pub fn verify_connection_proof(
proof_height,
connection_end.counterparty().prefix(),
proof,
&connection_end.counterparty().connection_id().unwrap(),
connection_end.counterparty().connection_id(),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If the connection is in the Init state, connection_end.counterparty().connection_id() is a None, and thus it's not okay to unwrap.

@vitorenesduarte vitorenesduarte mentioned this pull request Feb 22, 2021
5 tasks
@codecov-io
Copy link

codecov-io commented Feb 22, 2021

Codecov Report

Merging #700 (731dcc9) into master (b1b37f5) will increase coverage by 30.4%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #700      +/-   ##
=========================================
+ Coverage    13.6%   44.1%   +30.4%     
=========================================
  Files          69     150      +81     
  Lines        3752    9764    +6012     
  Branches     1374       0    -1374     
=========================================
+ Hits          513    4312    +3799     
- Misses       2618    5452    +2834     
+ Partials      621       0     -621     
Impacted Files Coverage Δ
modules/src/address.rs 100.0% <ø> (ø)
...application/ics20_fungible_token_transfer/error.rs 0.0% <ø> (ø)
...ion/ics20_fungible_token_transfer/msgs/transfer.rs 0.0% <ø> (ø)
modules/src/events.rs 0.0% <ø> (ø)
modules/src/handler.rs 100.0% <ø> (ø)
modules/src/ics02_client/client_def.rs 48.3% <ø> (ø)
modules/src/ics02_client/client_type.rs 79.1% <ø> (+31.5%) ⬆️
modules/src/ics02_client/context.rs 100.0% <ø> (ø)
modules/src/ics02_client/error.rs 100.0% <ø> (ø)
modules/src/ics02_client/events.rs 15.7% <ø> (+15.7%) ⬆️
... and 255 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 02aef9c...dda8c6f. Read the comment docs.

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.

LGTM, thank you Vitor.

@vitorenesduarte vitorenesduarte merged commit 08db234 into master Feb 23, 2021
@vitorenesduarte vitorenesduarte deleted the vitor/open-ack branch February 23, 2021 12:58
hu55a1n1 pushed a commit to hu55a1n1/hermes that referenced this pull request Sep 13, 2022
* Allow a conn open ack to succeed

* Remove invalid test

* update CHANGELOG

* Make MsgConnectionOpenAck.counterparty_connection_id not an Option
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.

conn open ack does not succeed in the happy case
3 participants