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: ica handshake reopening channel - use GetAppVersion in favour of channel.Version #2302

Merged
merged 9 commits into from
Sep 21, 2022

Conversation

damiannolan
Copy link
Member

Description

  • Adding unwrapping of channel version to ica controller handshake reopening flow

closes: #XXXX


Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

  • Targeted PR against correct branch (see CONTRIBUTING.md)
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Code follows the module structure standards.
  • Wrote unit and integration tests
  • Updated relevant documentation (docs/) or specification (x/<module>/spec/)
  • Added relevant godoc comments.
  • Added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • Re-reviewed Files changed in the Github PR explorer
  • Review Codecov Report in the comment section below once CI passes

Copy link
Contributor

@crodriguezvega crodriguezvega left a comment

Choose a reason for hiding this comment

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

Can we add a changelog entry, @damiannolan? :)

@damiannolan
Copy link
Member Author

Can we add a changelog entry, @damiannolan? :)

Done! ✅

if !icatypes.IsPreviousMetadataEqual(channel.Version, metadata) {
appVersion, found := k.GetAppVersion(ctx, portID, activeChannelID)
if !found {
panic(fmt.Sprintf("active channel mapping set for %s, but channel does not exist in channel store", activeChannelID))
Copy link
Contributor

Choose a reason for hiding this comment

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

looks like this panic introduces multiple conventions in the function (error return + panic) does it make more sense to return an error instead?

Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to panic?

Copy link
Member Author

@damiannolan damiannolan Sep 19, 2022

Choose a reason for hiding this comment

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

As mentioned earlier in person I just followed essentially the same used above here - as in some places in ibc-go code we just panic because it's unreachable code.

Copy link
Contributor

Choose a reason for hiding this comment

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

maybe we could add a comment indicating as such? The message we panic with seems like it would be a regular error that we could run into.

Copy link
Contributor

@colin-axner colin-axner left a comment

Choose a reason for hiding this comment

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

Is it possible to add a test case for the exact issue we had?

Copy link
Member

@AdityaSripal AdityaSripal left a comment

Choose a reason for hiding this comment

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

Nice work!

@damiannolan
Copy link
Member Author

damiannolan commented Sep 19, 2022

I've been modifying the existing the test TestControlAccountAfterChannelClose to use an ICS29/ICS27 channel version.

It looks like we need to handle the same unwrapping of the channel version on the host in the OnChanOpenTry callback: https://github.com/cosmos/ibc-go/blob/main/modules/apps/27-interchain-accounts/host/keeper/handshake.go#L62.

This requires us to compose the hostKeeper with an ics4Wrapper and pass the feeKeeper similarly to how we do with the controller: https://github.com/cosmos/ibc-go/blob/main/testing/simapp/app.go#L401
This has to be done to unwrap the ICS27 app version from the fee enabled version correctly.

I'll make the changes locally and see if it resolves the failing test before pushing an update.

Edit: This seemed to do the trick. I've pushed an update with the changes to the host submodule and simapp, as well as updated/moved the changelog entry to API breaking. I guess we can't backport this fix. cc. @crodriguezvega @colin-axner

@codecov-commenter
Copy link

codecov-commenter commented Sep 19, 2022

Codecov Report

Merging #2302 (3559f5b) into main (b97729d) will increase coverage by 0.03%.
The diff coverage is 77.77%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2302      +/-   ##
==========================================
+ Coverage   79.54%   79.58%   +0.03%     
==========================================
  Files         175      175              
  Lines       12069    12131      +62     
==========================================
+ Hits         9600     9654      +54     
- Misses       2045     2049       +4     
- Partials      424      428       +4     
Impacted Files Coverage Δ
...7-interchain-accounts/controller/ibc_middleware.go 70.96% <42.85%> (-9.56%) ⬇️
...interchain-accounts/controller/keeper/handshake.go 89.85% <50.00%> (+1.97%) ⬆️
...27-interchain-accounts/controller/keeper/keeper.go 92.53% <75.00%> (-0.21%) ⬇️
...nterchain-accounts/controller/keeper/migrations.go 81.25% <75.00%> (+1.25%) ⬆️
...ps/27-interchain-accounts/host/keeper/handshake.go 89.55% <90.47%> (+4.93%) ⬆️
...7-interchain-accounts/controller/keeper/account.go 85.00% <100.00%> (ø)
...7-interchain-accounts/controller/keeper/genesis.go 91.30% <100.00%> (ø)
...apps/27-interchain-accounts/host/keeper/account.go 100.00% <100.00%> (+23.07%) ⬆️
.../apps/27-interchain-accounts/host/keeper/keeper.go 83.80% <100.00%> (+0.47%) ⬆️
modules/apps/27-interchain-accounts/module.go 54.00% <100.00%> (+1.42%) ⬆️
... and 8 more

@jackzampolin
Copy link
Member

Thank you for this fix ibc-go team!

@crodriguezvega
Copy link
Contributor

@damiannolan Could you please document this API change in the PR for the migration docs of v5?

Copy link
Contributor

@chatton chatton left a comment

Choose a reason for hiding this comment

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

LGTM just left a very minor nit!

Copy link
Contributor

@charleenfei charleenfei left a comment

Choose a reason for hiding this comment

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

nice!

if !icatypes.IsPreviousMetadataEqual(channel.Version, metadata) {
appVersion, found := k.GetAppVersion(ctx, portID, activeChannelID)
if !found {
panic(fmt.Sprintf("active channel mapping set for %s, but channel does not exist in channel store", activeChannelID))
Copy link
Contributor

Choose a reason for hiding this comment

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

a nit: channel does not exist in channel store is kind of confusing if the error is GetAppVersion returning not found -- maybe something like channel version does not exist?

@damiannolan damiannolan enabled auto-merge (squash) September 21, 2022 12:54
@damiannolan damiannolan merged commit 9e6246f into main Sep 21, 2022
@damiannolan damiannolan deleted the damian/fix-reopening-channel-handshake branch September 21, 2022 12:59
mergify bot pushed a commit that referenced this pull request Sep 21, 2022
…of `channel.Version` (#2302)

* adding unwrapping of channel version to ica controller handshake reopening flow

* adding changelog

* adding ics4Wrapper to ics27 host submodule, handling unwrapping channel version in OnChanOpenTry handshake cb

* updating changelog

Co-authored-by: colin axnér <[email protected]>
Co-authored-by: Carlos Rodriguez <[email protected]>
(cherry picked from commit 9e6246f)

# Conflicts:
#	CHANGELOG.md
#	modules/apps/27-interchain-accounts/host/keeper/keeper.go
mergify bot pushed a commit that referenced this pull request Sep 21, 2022
…of `channel.Version` (#2302)

* adding unwrapping of channel version to ica controller handshake reopening flow

* adding changelog

* adding ics4Wrapper to ics27 host submodule, handling unwrapping channel version in OnChanOpenTry handshake cb

* updating changelog

Co-authored-by: colin axnér <[email protected]>
Co-authored-by: Carlos Rodriguez <[email protected]>
(cherry picked from commit 9e6246f)

# Conflicts:
#	CHANGELOG.md
#	modules/apps/27-interchain-accounts/host/keeper/keeper.go
colin-axner pushed a commit that referenced this pull request Sep 21, 2022
…of `channel.Version` (backport #2302) (#2357)

* fix: ica handshake reopening channel - use `GetAppVersion` in favour of `channel.Version` (#2302)

* adding unwrapping of channel version to ica controller handshake reopening flow

* adding changelog

* adding ics4Wrapper to ics27 host submodule, handling unwrapping channel version in OnChanOpenTry handshake cb

* updating changelog

Co-authored-by: colin axnér <[email protected]>
Co-authored-by: Carlos Rodriguez <[email protected]>
(cherry picked from commit 9e6246f)

# Conflicts:
#	CHANGELOG.md
#	modules/apps/27-interchain-accounts/host/keeper/keeper.go

* fixing imports and interface type

Co-authored-by: Damian Nolan <[email protected]>
colin-axner pushed a commit that referenced this pull request Sep 21, 2022
…of `channel.Version` (backport #2302) (#2358)

* fix: ica handshake reopening channel - use `GetAppVersion` in favour of `channel.Version` (#2302)

* adding unwrapping of channel version to ica controller handshake reopening flow

* adding changelog

* adding ics4Wrapper to ics27 host submodule, handling unwrapping channel version in OnChanOpenTry handshake cb

* updating changelog

Co-authored-by: colin axnér <[email protected]>
Co-authored-by: Carlos Rodriguez <[email protected]>
(cherry picked from commit 9e6246f)

# Conflicts:
#	CHANGELOG.md
#	modules/apps/27-interchain-accounts/host/keeper/keeper.go

* fixing merge conflict error - reinstate interface type for msg router

Co-authored-by: Damian Nolan <[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.

8 participants