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

chore (api)!: remove capabilities from channel handshakes #7232

Merged
merged 14 commits into from
Sep 2, 2024

Conversation

bznein
Copy link
Contributor

@bznein bznein commented Aug 30, 2024

Description

ref: #7107


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
Contributor Author

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

This PR is definitely bigger than expected. I'm happy to split it into separate PRs if needed.

However, most of the diff is from removing stuff (usages of LookupModule.., tests that rely on capabilities, and usage of capabilities within other tets)

I also added as many comments to the PR as possible, to make review easier :)

@@ -128,26 +127,12 @@ func (suite *InterchainAccountsTestSuite) TestOnChanOpenInit() {
{
"success", func() {}, nil,
},
{
"ICA auth module does not claim channel capability", func() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Capability-related test. No longer needed

}, false},
{"connection does not support ORDERED channels", func() {
path.SetupConnections()
path.SetChannelOrdered()
err := path.EndpointA.ChanOpenInit()
suite.Require().NoError(err)

// modify connA versions to only support UNORDERED channels
path.EndpointA.UpdateConnection(func(c *connectiontypes.ConnectionEnd) {
// modify connB versions to only support UNORDERED channels
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 change was needed because the test was not correct. It comes from 29d9b59 (comments on #7009 explain it better)


// trigger upgradeInit on B which will bump the counterparty upgrade sequence.
path.EndpointB.ChannelConfig.ProposedUpgrade.Fields.Version = mock.UpgradeVersion
err := path.EndpointB.ChanUpgradeInit()
path.EndpointA.ChannelConfig.ProposedUpgrade.Fields.Version = mock.UpgradeVersion
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same re: 29d9b59

@@ -87,5 +88,21 @@ func (k *Keeper) LookupModuleByPort(ctx context.Context, portID string) (string,
// Route returns a IBCModule for a given module, and a boolean indicating
// whether or not the route is present.
func (k *Keeper) Route(module string) (types.IBCModule, bool) {
return k.Router.GetRoute(module)
routes, ok := k.Router.GetRoute(module)
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 is basically the same as https://github.com/cosmos/ibc-go/pull/7009/files#r1700067369, with the added function "Keys" (and the underlying Keys() in router.go)

@@ -193,32 +193,24 @@ func (k *Keeper) ConnectionOpenConfirm(goCtx context.Context, msg *connectiontyp
func (k *Keeper) ChannelOpenInit(goCtx context.Context, msg *channeltypes.MsgChannelOpenInit) (*channeltypes.MsgChannelOpenInitResponse, 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.

This is probably the file with most changes. They can be quite easily summarized as follows:

  • For each method that uses capability:
    • Remove usages of LookupModule... and replace with direct call to the (now changed) Route method.
    • Since we do not get the capability anymore from the function above, remove it as an argument to underlying functions

@bznein bznein marked this pull request as ready for review August 30, 2024 10:46
@bznein bznein added the priority PRs that need prompt reviews label Aug 30, 2024
@bznein
Copy link
Contributor Author

bznein commented Aug 30, 2024

Note: I haven't run E2E tests yet, and I need to open the PR for review for that. If anything fails, I'll mark the PR as not ready :)

Edit: everything is Green!!!

if err != nil {
return "", err
}

if err := im.keeper.ClaimCapability(ctx, chanCap, host.ChannelCapabilityPath(portID, channelID)); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

is this Path func in host in use anymore after this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Undirectly in a lot of test cases. I plan to remove them as followup

capName := host.ChannelCapabilityPath(packet.GetDestPort(), packet.GetDestChannel())
if !k.scopedKeeper.AuthenticateCapability(ctx, chanCap, capName) {
return "", errorsmod.Wrapf(
types.ErrInvalidChannelCapability,
Copy link
Contributor

Choose a reason for hiding this comment

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

can also be removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Which one do you mean exactly? If it is AuthenticateCapability (the definition of the method itself), I'd like to do that as followup as well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

(or did you mean the error type? same answer anyway :) )

Copy link
Contributor

Choose a reason for hiding this comment

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

sgtm! just worried that a lot of these public symbols don't get caught by linters so would be nice to keep track of them. A grep for Capability in the end might do the trick though!

capName := host.ChannelCapabilityPath(packet.GetSourcePort(), packet.GetSourceChannel())
if !k.scopedKeeper.AuthenticateCapability(ctx, chanCap, capName) {
return errorsmod.Wrapf(
types.ErrChannelCapabilityNotFound,
Copy link
Contributor

Choose a reason for hiding this comment

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

also axing time?

suite.Require().NoError(err)

cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.Route(module)
cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.Route(path.EndpointB.ChannelConfig.PortID)
Copy link
Contributor

Choose a reason for hiding this comment

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

not from your changes, but I think the test might have been incorrect. I feel like this should be EndpointB

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Uhm, it is EndpointB. Did you mean A?

Copy link
Contributor

Choose a reason for hiding this comment

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

yes sorry!

@@ -87,5 +88,21 @@ func (k *Keeper) LookupModuleByPort(ctx context.Context, portID string) (string,
// Route returns a IBCModule for a given module, and a boolean indicating
// whether or not the route is present.
func (k *Keeper) Route(module string) (types.IBCModule, bool) {
return k.Router.GetRoute(module)
routes, ok := k.Router.GetRoute(module)
Copy link
Contributor

Choose a reason for hiding this comment

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

we can probably rename this back to route

Copy link
Contributor

Choose a reason for hiding this comment

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

haha I meant the var routes but all good

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.

Amazing 🙌 thank you @bznein! I appreciate you doing this seemingly tedious work (twice!). It makes me quite happy to see over 800 lines of red code 😄

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! Thank you so much for doing this clean up!

Copy link
Contributor

@DimitrisJim DimitrisJim left a comment

Choose a reason for hiding this comment

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

thats what I call a sweet diff. thanks much for clean up!

Copy link

sonarqubecloud bot commented Sep 2, 2024

@bznein bznein added this pull request to the merge queue Sep 2, 2024
Merged via the queue into main with commit eb9bcc3 Sep 2, 2024
72 of 73 checks passed
@bznein bznein deleted the bznein/removeCap/channelhandshakes branch September 2, 2024 12:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority PRs that need prompt reviews
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants