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

Fix panic in conn open try when no connection id is provided #615

Merged
merged 1 commit into from
Feb 9, 2021

Conversation

vitorenesduarte
Copy link
Contributor

@vitorenesduarte vitorenesduarte commented Feb 5, 2021

Closes: #626

Description

Currently, a conn open try can only succeed if some previous_connection_id is provided in the MsgConnectionOpenTry:
https://github.com/informalsystems/ibc-rs/blob/b1b9dac6132a2fd2a86fa1c6f0179f47db3e3454/modules/src/ics03_connection/msgs/conn_open_try.rs#L26-L35
However, to have a valid previous_connection_id, one has to have a successful conn open try. This circular dependency makes it so that it's never possible to have successful conn open try.

This issue was found during the MBT work (#601). I tried to add a regression test but didn't find an easy way to do it. The best candidate was the routing_module_and_keepers test in ics26_routing/handler.rs: https://github.com/informalsystems/ibc-rs/blob/b1b9dac6132a2fd2a86fa1c6f0179f47db3e3454/modules/src/ics26_routing/handler.rs#L152-L316

There's a single chain here, which I think means it's not possible to have a successful conn open try. I've also noticed that the tests here don't check that the returned error matches the expected error. This is done in the IBCTestExecutor introduced in #601. Maybe at some point it will be possible to reuse this test executor to write these simple unit tests.


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.

vitorenesduarte added a commit that referenced this pull request Feb 5, 2021
vitorenesduarte added a commit that referenced this pull request Feb 5, 2021
vitorenesduarte added a commit that referenced this pull request Feb 5, 2021
Copy link
Collaborator

@ancazamfir ancazamfir 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 as a quick fix. But I think we should have a consistent approach with client and channel handling. I thought we decided when we re-wrote the client handler to return an id from process(). @adizere ? Looking at channels now, we do the same as in connection.

@adizere
Copy link
Member

adizere commented Feb 8, 2021

Looks good as a quick fix. But I think we should have a consistent approach with client and channel handling. I thought we decided when we re-wrote the client handler to return an id from process(). @adizere ? Looking at channels now, we do the same as in connection.

Currently only ICS02 performs identifier selection and returns that from process.

We should adapt both ICS03 (and ICS04) to return identifiers from process. The changes should not be difficult. I agree we need a consistent approach, and the approach in ICS02 should work.

@ancazamfir
Copy link
Collaborator

We should adapt both ICS03 (and ICS04) to return identifiers from process. The changes should not be difficult. I agree we need a consistent approach, and the approach in ICS02 should work.

Sounds good. I will leave it up to you @vitorenesduarte if you want to do it in this PR or we do it in a separate one. I opened cosmos/ibc-rs#91, please mention in Closes: #XXX if you decide to fix it here.

@vitorenesduarte
Copy link
Contributor Author

We should adapt both ICS03 (and ICS04) to return identifiers from process. The changes should not be difficult. I agree we need a consistent approach, and the approach in ICS02 should work.

Sounds good. I will leave it up to you @vitorenesduarte if you want to do it in this PR or we do it in a separate one. I opened cosmos/ibc-rs#91, please mention in Closes: #XXX if you decide to fix it here.

Let's do it in another PR.

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.

Looks good, thank you.

@adizere adizere merged commit 2bf5ce0 into master Feb 9, 2021
@adizere adizere deleted the vitor/conn_open_try branch February 9, 2021 09:47
@romac
Copy link
Member

romac commented Feb 9, 2021

@vitorenesduarte Great stuff! Can you please also create an issue, mention it in the body of this PR and update the CHANGELOG accordingly in a follow-up PR?

@vitorenesduarte vitorenesduarte mentioned this pull request Feb 9, 2021
5 tasks
@vitorenesduarte
Copy link
Contributor Author

@vitorenesduarte Great stuff! Can you please also create an issue, mention it in the body of this PR and update the CHANGELOG accordingly in a follow-up PR?

Thanks @romac. Done in #627.

adizere pushed a commit that referenced this pull request Feb 12, 2021
* Add ICS02 model

* Add MBT test driver

* Add ICS02TestExecutor

* Add another apalache counterexample

* Fix ICS02.tla: client counter starts at 0

* Check for errors in MockContext.deliver

* Handle errors in MBT tests

* Remove SyntheticTendermint mock context

* More idiomatic check_next_state

* Buffered file reads

* Make extract_handler_error_kind generic over the IBC handler

* Support multiple chains in MBT

* Make eyre a dev-dependency

* s/ICS0/IBC on TLA files

* Initial support for conn open init

* Start connection and channel identifiers at 0

* Add conn open init to TLA spec

* Represent clients with a record in TLA spec

* Finish connection open init

* s/state/step

* Minimize diff

* Modularize TLA spec

* TLA format convention

* s/Null/None

* Sketch conn open try; Model chain's height

* Bound model space

* Only update chain height upon success

* Check that chain heights match the ones in the model

* Sketch conn open try

* Sketch conn open try

* Model missing connections and connection mismatches in conn open try

* Trigger bug in conn open try

* Go back to previous way of generating connection and channel ids

* Disable failing MBT test

* Fix panic in conn open try when no connection id is provided

* ICS02TestExecutor -> IBCTestExecutor

* Failing MBT test now passes with #615

* Add notes on MBT

* Remove ICS02

* Add README

* Improve README

* Remove MBT intro

* new lines

* Make MBT README more easily discoverable

* IBCTestExecutor: Map from ChainId (instead of String) to MockContext

* s/epoch/revision

* Move from eyre to thiserror

* Improve README

* Improve README

* Improve arguments order in modelator::test

* Improve chain identifiers

* Improve README
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.

modules: Fix panic in conn open try when no connection id is provided
4 participants