-
Notifications
You must be signed in to change notification settings - Fork 657
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
Changes from 7 commits
ad21454
936aaf7
c316b30
bd29bb4
4c56bc3
9307fed
d340715
7fa1078
9d4fca7
475394a
8a24b07
2b712b3
29e5503
554308a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,6 @@ import ( | |
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
|
||
capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" | ||
"github.com/cosmos/ibc-go/v9/modules/apps/27-interchain-accounts/controller" | ||
controllerkeeper "github.com/cosmos/ibc-go/v9/modules/apps/27-interchain-accounts/controller/keeper" | ||
"github.com/cosmos/ibc-go/v9/modules/apps/27-interchain-accounts/controller/types" | ||
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. Capability-related test. No longer needed |
||
suite.chainA.GetSimApp().ICAAuthModule.IBCApp.OnChanOpenInit = func(ctx context.Context, order channeltypes.Order, connectionHops []string, | ||
portID, channelID string, chanCap *capabilitytypes.Capability, | ||
counterparty channeltypes.Counterparty, version string, | ||
) (string, error) { | ||
if chanCap != nil { | ||
return "", fmt.Errorf("channel capability should be nil") | ||
} | ||
|
||
return version, nil | ||
} | ||
}, nil, | ||
}, | ||
{ | ||
"ICA auth module modification of channel version is ignored", func() { | ||
// NOTE: explicitly modify the channel version via the auth module callback, | ||
// ensuring the expected JSON encoded metadata is not modified upon return | ||
suite.chainA.GetSimApp().ICAAuthModule.IBCApp.OnChanOpenInit = func(ctx context.Context, order channeltypes.Order, connectionHops []string, | ||
portID, channelID string, chanCap *capabilitytypes.Capability, | ||
portID, channelID string, | ||
counterparty channeltypes.Counterparty, version string, | ||
) (string, error) { | ||
return "invalid-version", nil | ||
|
@@ -162,7 +147,7 @@ func (suite *InterchainAccountsTestSuite) TestOnChanOpenInit() { | |
{ | ||
"ICA auth module callback fails", func() { | ||
suite.chainA.GetSimApp().ICAAuthModule.IBCApp.OnChanOpenInit = func(ctx context.Context, order channeltypes.Order, connectionHops []string, | ||
portID, channelID string, chanCap *capabilitytypes.Capability, | ||
portID, channelID string, | ||
counterparty channeltypes.Counterparty, version string, | ||
) (string, error) { | ||
return "", fmt.Errorf("mock ica auth fails") | ||
|
@@ -179,7 +164,7 @@ func (suite *InterchainAccountsTestSuite) TestOnChanOpenInit() { | |
suite.chainA.GetSimApp().ICAControllerKeeper.DeleteMiddlewareEnabled(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ConnectionID) | ||
|
||
suite.chainA.GetSimApp().ICAAuthModule.IBCApp.OnChanOpenInit = func(ctx context.Context, order channeltypes.Order, connectionHops []string, | ||
portID, channelID string, chanCap *capabilitytypes.Capability, | ||
portID, channelID string, | ||
counterparty channeltypes.Counterparty, version string, | ||
) (string, error) { | ||
return "", fmt.Errorf("error should be unreachable") | ||
|
@@ -203,9 +188,6 @@ func (suite *InterchainAccountsTestSuite) TestOnChanOpenInit() { | |
portID, err := icatypes.NewControllerPortID(TestOwnerAddress) | ||
suite.Require().NoError(err) | ||
|
||
portCap := suite.chainA.GetSimApp().IBCKeeper.PortKeeper.BindPort(suite.chainA.GetContext(), portID) | ||
suite.chainA.GetSimApp().ICAControllerKeeper.ClaimCapability(suite.chainA.GetContext(), portCap, host.PortPath(portID)) //nolint:errcheck // checking this error isn't needed for the test | ||
|
||
path.EndpointA.ChannelConfig.PortID = portID | ||
path.EndpointA.ChannelID = ibctesting.FirstChannelID | ||
|
||
|
@@ -226,21 +208,15 @@ func (suite *InterchainAccountsTestSuite) TestOnChanOpenInit() { | |
// ensure channel on chainA is set in state | ||
suite.chainA.GetSimApp().IBCKeeper.ChannelKeeper.SetChannel(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, *channel) | ||
|
||
module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID) | ||
suite.Require().NoError(err) | ||
|
||
chanCap, err := suite.chainA.App.GetScopedIBCKeeper().NewCapability(suite.chainA.GetContext(), host.ChannelCapabilityPath(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID)) | ||
suite.Require().NoError(err) | ||
|
||
cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.Route(module) | ||
cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.Route(path.EndpointA.ChannelConfig.PortID) | ||
suite.Require().True(ok) | ||
|
||
if isNilApp { | ||
cbs = controller.NewIBCMiddleware(suite.chainA.GetSimApp().ICAControllerKeeper) | ||
} | ||
|
||
version, err := cbs.OnChanOpenInit(suite.chainA.GetContext(), channel.Ordering, channel.ConnectionHops, | ||
path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, chanCap, channel.Counterparty, channel.Version, | ||
path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, channel.Counterparty, channel.Version, | ||
) | ||
|
||
if tc.expErr == nil { | ||
|
@@ -286,20 +262,14 @@ func (suite *InterchainAccountsTestSuite) TestChanOpenTry() { | |
|
||
suite.Require().Error(err) | ||
|
||
// call application callback directly | ||
module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), path.EndpointB.ChannelConfig.PortID) | ||
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 commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Uhm, it is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes sorry! |
||
suite.Require().True(ok) | ||
|
||
counterparty := channeltypes.NewCounterparty(path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID) | ||
chanCap, found := suite.chainA.App.GetScopedIBCKeeper().GetCapability(suite.chainA.GetContext(), host.ChannelCapabilityPath(path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID)) | ||
suite.Require().True(found) | ||
|
||
version, err := cbs.OnChanOpenTry( | ||
suite.chainA.GetContext(), path.EndpointA.ChannelConfig.Order, []string{path.EndpointA.ConnectionID}, | ||
path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, chanCap, | ||
path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, | ||
counterparty, path.EndpointB.ChannelConfig.Version, | ||
) | ||
suite.Require().Error(err) | ||
|
@@ -377,10 +347,7 @@ func (suite *InterchainAccountsTestSuite) TestOnChanOpenAck() { | |
|
||
tc.malleate() // malleate mutates test data | ||
|
||
module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID) | ||
suite.Require().NoError(err) | ||
|
||
cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.Route(module) | ||
cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.Route(path.EndpointA.ChannelConfig.PortID) | ||
suite.Require().True(ok) | ||
|
||
err = cbs.OnChanOpenAck(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelID, path.EndpointB.ChannelConfig.Version) | ||
|
@@ -437,11 +404,7 @@ func (suite *InterchainAccountsTestSuite) TestChanOpenConfirm() { | |
|
||
suite.Require().Error(err) | ||
|
||
// call application callback directly | ||
module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID) | ||
suite.Require().NoError(err) | ||
|
||
cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.Route(module) | ||
cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.Route(path.EndpointA.ChannelConfig.PortID) | ||
suite.Require().True(ok) | ||
|
||
err = cbs.OnChanOpenConfirm( | ||
|
@@ -462,10 +425,7 @@ func (suite *InterchainAccountsTestSuite) TestOnChanCloseInit() { | |
err := SetupICAPath(path, TestOwnerAddress) | ||
suite.Require().NoError(err) | ||
|
||
module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID) | ||
suite.Require().NoError(err) | ||
|
||
cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.Route(module) | ||
cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.Route(path.EndpointA.ChannelConfig.PortID) | ||
suite.Require().True(ok) | ||
|
||
err = cbs.OnChanCloseInit( | ||
|
@@ -512,10 +472,8 @@ func (suite *InterchainAccountsTestSuite) TestOnChanCloseConfirm() { | |
suite.Require().NoError(err) | ||
|
||
tc.malleate() // malleate mutates test data | ||
module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID) | ||
suite.Require().NoError(err) | ||
|
||
cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.Route(module) | ||
cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.Route(path.EndpointA.ChannelConfig.PortID) | ||
suite.Require().True(ok) | ||
|
||
if isNilApp { | ||
|
@@ -561,10 +519,7 @@ func (suite *InterchainAccountsTestSuite) TestOnRecvPacket() { | |
|
||
tc.malleate() // malleate mutates test data | ||
|
||
module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID) | ||
suite.Require().NoError(err) | ||
|
||
cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.Route(module) | ||
cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.Route(path.EndpointA.ChannelConfig.PortID) | ||
suite.Require().True(ok) | ||
|
||
packet := channeltypes.NewPacket( | ||
|
@@ -674,10 +629,7 @@ func (suite *InterchainAccountsTestSuite) TestOnAcknowledgementPacket() { | |
|
||
tc.malleate() // malleate mutates test data | ||
|
||
module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID) | ||
suite.Require().NoError(err) | ||
|
||
cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.Route(module) | ||
cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.Route(path.EndpointA.ChannelConfig.PortID) | ||
suite.Require().True(ok) | ||
|
||
if isNilApp { | ||
|
@@ -771,10 +723,7 @@ func (suite *InterchainAccountsTestSuite) TestOnTimeoutPacket() { | |
|
||
tc.malleate() // malleate mutates test data | ||
|
||
module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID) | ||
suite.Require().NoError(err) | ||
|
||
cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.Route(module) | ||
cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.Route(path.EndpointA.ChannelConfig.PortID) | ||
suite.Require().True(ok) | ||
|
||
if isNilApp { | ||
|
@@ -860,10 +809,7 @@ func (suite *InterchainAccountsTestSuite) TestOnChanUpgradeInit() { | |
|
||
tc.malleate() // malleate mutates test data | ||
|
||
module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID) | ||
suite.Require().NoError(err) | ||
|
||
app, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.Route(module) | ||
app, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.Route(path.EndpointA.ChannelConfig.PortID) | ||
suite.Require().True(ok) | ||
cbs, ok := app.(porttypes.UpgradableModule) | ||
suite.Require().True(ok) | ||
|
@@ -903,10 +849,7 @@ func (suite *InterchainAccountsTestSuite) TestOnChanUpgradeTry() { | |
suite.Require().NoError(err) | ||
|
||
// call application callback directly | ||
module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID) | ||
suite.Require().NoError(err) | ||
|
||
app, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.Route(module) | ||
app, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.Route(path.EndpointA.ChannelConfig.PortID) | ||
suite.Require().True(ok) | ||
cbs, ok := app.(porttypes.UpgradableModule) | ||
suite.Require().True(ok) | ||
|
@@ -988,10 +931,7 @@ func (suite *InterchainAccountsTestSuite) TestOnChanUpgradeAck() { | |
|
||
tc.malleate() // malleate mutates test data | ||
|
||
module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID) | ||
suite.Require().NoError(err) | ||
|
||
app, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.Route(module) | ||
app, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.Route(path.EndpointA.ChannelConfig.PortID) | ||
suite.Require().True(ok) | ||
cbs, ok := app.(porttypes.UpgradableModule) | ||
suite.Require().True(ok) | ||
|
@@ -1078,10 +1018,7 @@ func (suite *InterchainAccountsTestSuite) TestOnChanUpgradeOpen() { | |
|
||
tc.malleate() // malleate mutates test data | ||
|
||
module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID) | ||
suite.Require().NoError(err) | ||
|
||
app, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.Route(module) | ||
app, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.Route(path.EndpointA.ChannelConfig.PortID) | ||
suite.Require().True(ok) | ||
cbs, ok := app.(porttypes.UpgradableModule) | ||
suite.Require().True(ok) | ||
|
@@ -1196,10 +1133,7 @@ func (suite *InterchainAccountsTestSuite) TestGetAppVersion() { | |
err := SetupICAPath(path, TestOwnerAddress) | ||
suite.Require().NoError(err) | ||
|
||
module, _, err := suite.chainA.App.GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID) | ||
suite.Require().NoError(err) | ||
|
||
cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.Route(module) | ||
cbs, ok := suite.chainA.App.GetIBCKeeper().PortKeeper.Route(path.EndpointA.ChannelConfig.PortID) | ||
suite.Require().True(ok) | ||
|
||
controllerStack, ok := cbs.(porttypes.ICS4Wrapper) | ||
|
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