-
Notifications
You must be signed in to change notification settings - Fork 645
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
Conversation
There was a problem hiding this 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() { |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
// 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 |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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
- Remove usages of
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 { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can also be removed?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 :) )
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this 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 😄
Co-authored-by: colin axnér <[email protected]>
There was a problem hiding this 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!
There was a problem hiding this 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!
Quality Gate passed for 'ibc-go'Issues Measures |
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.
docs/
).godoc
comments.Files changed
in the GitHub PR explorer.SonarCloud Report
in the comment section below once CI passes.