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

Use connection id instead of channel id in IsMiddlewareEnabled #2260

Conversation

chatton
Copy link
Contributor

@chatton chatton commented Sep 9, 2022

Description

This PR updates IsMiddlewareEnabled, SetMiddlewareEnabled and DeleteMiddlewareEnabled to use portID and connectionID as opposed to portID and channelID.

closes: #2235


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

@@ -23,7 +23,7 @@ type IBCMiddleware struct {
keeper keeper.Keeper
}

// IBCMiddleware creates a new IBCMiddleware given the associated keeper and underlying application
// NewIBCMiddleware creates a new IBCMiddleware given the associated keeper and underlying application
Copy link
Contributor Author

Choose a reason for hiding this comment

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

unrelated docstring fix

@@ -61,6 +62,15 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger {
return ctx.Logger().With("module", fmt.Sprintf("x/%s-%s", host.ModuleName, icatypes.ModuleName))
}

// GetConnectionID returns the connection id for the given port and channelIDs.
func (k Keeper) GetConnectionID(ctx sdk.Context, portID, channelID string) (string, error) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I chose to add this function rather than export the channelKeeper, as so far it's the only time we've needed.

…ection-id-instead-of-the-channel-id' of https://github.com/cosmos/ibc-go into cian/issue#2235-ismiddlewareenabled-should-use-the-connection-id-instead-of-the-channel-id
Comment on lines +157 to +159
portID := keySplit[1]
connectionID := keySplit[2]
channelID := string(iterator.Value())
Copy link
Contributor Author

Choose a reason for hiding this comment

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

extracted these out to make it more clear which values are being passed into IsMiddlewareEnabled

@chatton chatton marked this pull request as ready for review September 9, 2022 13:32
…se-the-connection-id-instead-of-the-channel-id
…se-the-connection-id-instead-of-the-channel-id
@codecov-commenter
Copy link

codecov-commenter commented Sep 9, 2022

Codecov Report

Merging #2260 (d83733e) into main (c2ce323) will decrease coverage by 0.07%.
The diff coverage is 63.82%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2260      +/-   ##
==========================================
- Coverage   79.51%   79.43%   -0.08%     
==========================================
  Files         175      175              
  Lines       12077    12103      +26     
==========================================
+ Hits         9603     9614      +11     
- Misses       2049     2059      +10     
- Partials      425      430       +5     
Impacted Files Coverage Δ
...7-interchain-accounts/controller/ibc_middleware.go 70.96% <42.85%> (-9.56%) ⬇️
...27-interchain-accounts/controller/keeper/keeper.go 91.04% <75.00%> (-1.70%) ⬇️
...7-interchain-accounts/controller/keeper/account.go 85.00% <100.00%> (ø)
...7-interchain-accounts/controller/keeper/genesis.go 91.30% <100.00%> (ø)
...nterchain-accounts/controller/keeper/migrations.go 80.00% <100.00%> (ø)
modules/apps/27-interchain-accounts/types/keys.go 100.00% <100.00%> (ø)

…se-the-connection-id-instead-of-the-channel-id
…se-the-connection-id-instead-of-the-channel-id
…se-the-connection-id-instead-of-the-channel-id
…se-the-connection-id-instead-of-the-channel-id
…se-the-connection-id-instead-of-the-channel-id
Copy link
Contributor

@damiannolan damiannolan left a comment

Choose a reason for hiding this comment

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

Awesome, LGTM!

…se-the-connection-id-instead-of-the-channel-id
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.

Looks great to me!

if err != nil {
return err
}

k.SetMiddlewareEnabled(ctx, portID, channelID)
k.SetMiddlewareEnabled(ctx, portID, connectionID)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there an issue that moves this setting (it needs to be moved to be called before registerInterchainAccount, since it is referenced in OnChanOpenInit

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 its covered in #2283

…ection-id-instead-of-the-channel-id' of https://github.com/cosmos/ibc-go into cian/issue#2235-ismiddlewareenabled-should-use-the-connection-id-instead-of-the-channel-id
@chatton chatton merged commit 6b7d67f into main Sep 20, 2022
@chatton chatton deleted the cian/issue#2235-ismiddlewareenabled-should-use-the-connection-id-instead-of-the-channel-id branch September 20, 2022 15:27
mergify bot pushed a commit that referenced this pull request Sep 20, 2022
(cherry picked from commit 6b7d67f)

# Conflicts:
#	modules/apps/27-interchain-accounts/controller/keeper/keeper.go
damiannolan pushed a commit that referenced this pull request Sep 26, 2022
…ort #2260) (#2319)

* Use connection id instead of channel id in IsMiddlewareEnabled (#2260)

(cherry picked from commit 6b7d67f)

# Conflicts:
#	modules/apps/27-interchain-accounts/controller/keeper/keeper.go

* chore: handle merge conflicts

Co-authored-by: Cian Hatton <[email protected]>
Co-authored-by: Cian Hatton <[email protected]>
Co-authored-by: colin axnér <[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.

IsMiddlewareEnabled should use the connection id instead of the channel id
4 participants