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

api!: remove capabilities #7270

Merged
merged 7 commits into from
Sep 10, 2024
Merged

api!: remove capabilities #7270

merged 7 commits into from
Sep 10, 2024

Conversation

damiannolan
Copy link
Member

Description

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 the 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 and Go style guide.
  • Wrote unit and integration tests.
  • Updated relevant documentation (docs/).
  • Added relevant godoc comments.
  • Provide a conventional commit message to follow the repository standards.
  • Include a descriptive changelog entry when appropriate. This may be left to the discretion of the PR reviewers. (e.g. chores should be omitted from changelog)
  • Re-reviewed Files changed in the GitHub PR explorer.
  • Review SonarCloud Report in the comment section below once CI passes.

Copy link
Member Author

@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.

Needs migration docs. Can leave comments across this PR where stuff is removed.
There should probably be a store upgrades migration for removing capability store key.

@@ -65,16 +64,7 @@ func (k Keeper) registerInterchainAccount(ctx context.Context, connectionID, por
return "", errorsmod.Wrapf(icatypes.ErrActiveChannelAlreadySet, "existing active channel %s for portID %s on connection %s", activeChannelID, portID, connectionID)
}

switch {
case k.portKeeper.IsBound(ctx, portID) && !k.hasCapability(ctx, portID):
Copy link
Member Author

Choose a reason for hiding this comment

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

This case basically says - if a a capability exists (port is bound) with core ibc, but not claimed by the ica app, then return an error. This is essentially unreachable code, unless someone has wired a code path into the chain to allow icacontroller- port ids to be created with the core ibc scoped keeper.

switch {
case k.portKeeper.IsBound(ctx, portID) && !k.hasCapability(ctx, portID):
return "", errorsmod.Wrapf(icatypes.ErrPortAlreadyBound, "another module has claimed capability for and bound port with portID: %s", portID)
case !k.portKeeper.IsBound(ctx, portID):
Copy link
Member Author

Choose a reason for hiding this comment

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

This case is - if no capability exists (port bound) for port id in core ibc's scoped keeper, then;

  • Set port: this was previously used for genesis exports such that we can recreate ports on a genesis restart, unclear if we still actually need this for ica as ports are assumed to be in the format icacontroller-. Unlike transfer where we set the port because it could be modified by devs to e.g. "ibc-transfer" (unclear if there is assumptions in other places that it must just be "transfer").
  • Create a new capability via BindPort using ibc core's scoped keeper. This creates a capability and adds "ibc" as an owner.
  • Claim the capability using the ica scoped keeper. This adds ica as the second owner

In scenarios where we open a new channel(after close) for an existing port id, then neither of these cases are hit and skip the entire switch statement.

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 thanks for looking into this one 🫡

Copy link
Contributor

@bznein bznein left a comment

Choose a reason for hiding this comment

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

Massive red diff, love it! Should we add something to the changelog too?

@@ -19,7 +19,6 @@ require (
github.com/cosmos/cosmos-proto v1.0.0-beta.5
github.com/cosmos/cosmos-sdk v0.50.10-0.20240808075341-156231be8aef
github.com/cosmos/gogoproto v1.7.0
github.com/cosmos/ibc-go/modules/capability v1.0.1
Copy link
Contributor

Choose a reason for hiding this comment

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

🥳

Copy link

sonarcloud bot commented Sep 10, 2024

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.

🎉 finally! What a great simplification! ❤️

@damiannolan damiannolan added this pull request to the merge queue Sep 10, 2024
Merged via the queue into main with commit 59ca335 Sep 10, 2024
75 checks passed
@damiannolan damiannolan deleted the damian/remove-more-capabilities branch September 10, 2024 14:44
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