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

Add counterpartyChannelId param to IBCModule.OnChanOpenAck #1076

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ func (im IBCModule) OnChanOpenAck(
portID,
channelID string,
counterpartyVersion string,
counterpartyChannelID string,
) error {
if !im.keeper.IsControllerEnabled(ctx) {
return types.ErrControllerSubModuleDisabled
Expand All @@ -91,7 +92,7 @@ func (im IBCModule) OnChanOpenAck(
}

// call underlying app's OnChanOpenAck callback with the counterparty app version.
return im.app.OnChanOpenAck(ctx, portID, channelID, counterpartyVersion)
return im.app.OnChanOpenAck(ctx, portID, channelID, counterpartyVersion, counterpartyChannelID)
}

// OnChanOpenAck implements the IBCModule interface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ func (suite *InterchainAccountsTestSuite) TestOnChanOpenAck() {
{
"ICA auth module callback fails", func() {
suite.chainA.GetSimApp().ICAAuthModule.IBCApp.OnChanOpenAck = func(
ctx sdk.Context, portID, channelID string, counterpartyVersion string,
ctx sdk.Context, portID, channelID string, counterpartyVersion string, counterpartyChannelID string,
) error {
return fmt.Errorf("mock ica auth fails")
}
Expand Down Expand Up @@ -316,7 +316,7 @@ func (suite *InterchainAccountsTestSuite) TestOnChanOpenAck() {
cbs, ok := suite.chainA.App.GetIBCKeeper().Router.GetRoute(module)
suite.Require().True(ok)

err = cbs.OnChanOpenAck(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.Version)
err = cbs.OnChanOpenAck(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, path.EndpointB.ChannelConfig.Version, path.EndpointB.ChannelID)

if tc.expPass {
suite.Require().NoError(err)
Expand Down
1 change: 1 addition & 0 deletions modules/apps/27-interchain-accounts/host/ibc_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ func (im IBCModule) OnChanOpenAck(
portID,
channelID string,
counterpartyVersion string,
counterpartyChannelID string,
) error {
return sdkerrors.Wrap(icatypes.ErrInvalidChannelFlow, "channel handshake must be initiated by controller chain")
}
Expand Down
1 change: 1 addition & 0 deletions modules/apps/transfer/ibc_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ func (im IBCModule) OnChanOpenAck(
portID,
channelID string,
counterpartyVersion string,
_ string,
) error {
if counterpartyVersion != types.Version {
return sdkerrors.Wrapf(types.ErrInvalidVersion, "invalid counterparty version: %s, expected %s", counterpartyVersion, types.Version)
Expand Down
3 changes: 1 addition & 2 deletions modules/apps/transfer/ibc_module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,7 @@ func (suite *TransferTestSuite) TestOnChanOpenAck() {
suite.Require().True(ok)

tc.malleate() // explicitly change fields in channel and testChannel

err = cbs.OnChanOpenAck(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, counterpartyVersion)
err = cbs.OnChanOpenAck(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID, path.EndpointA.ChannelID, counterpartyVersion, path.EndpointA.Counterparty.ChannelID)

if tc.expPass {
suite.Require().NoError(err)
Expand Down
1 change: 1 addition & 0 deletions modules/core/05-port/types/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ type IBCModule interface {
portID,
channelID string,
counterpartyVersion string,
counterpartyChannelID string,
Comment on lines 54 to +55
Copy link
Contributor

Choose a reason for hiding this comment

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

could you change the ordering such that counterpartyChannelID comes before counterpartyVersion? See proposed spec changes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, I'll do it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the contribution!

This needs a changelog entry under the API breaking section and an addition to the docs/v2-to-v3.md migrations docs, but I can add both in a followup pr if you feel uncertain about adding that

I can make the 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.

#1086 I just made this pr

) error

// OnChanOpenConfirm will perform custom CONFIRM logic and may error to abort the handshake.
Expand Down
2 changes: 1 addition & 1 deletion modules/core/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ func (k Keeper) ChannelOpenAck(goCtx context.Context, msg *channeltypes.MsgChann
}

// Perform application logic callback
if err = cbs.OnChanOpenAck(ctx, msg.PortId, msg.ChannelId, msg.CounterpartyVersion); err != nil {
if err = cbs.OnChanOpenAck(ctx, msg.PortId, msg.ChannelId, msg.CounterpartyVersion, msg.CounterpartyChannelId); err != nil {
return nil, sdkerrors.Wrap(err, "channel open ack callback failed")
}

Expand Down
1 change: 1 addition & 0 deletions testing/mock/ibc_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type MockIBCApp struct {
portID,
channelID string,
counterpartyVersion string,
counterpartyChannelID string,
) error

OnChanOpenConfirm func(
Expand Down
4 changes: 2 additions & 2 deletions testing/mock/ibc_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ func (im IBCModule) OnChanOpenTry(
}

// OnChanOpenAck implements the IBCModule interface.
func (im IBCModule) OnChanOpenAck(ctx sdk.Context, portID string, channelID string, counterpartyVersion string) error {
func (im IBCModule) OnChanOpenAck(ctx sdk.Context, portID string, channelID string, counterpartyVersion string, counterpartyChannelID string) error {
if im.IBCApp.OnChanOpenAck != nil {
return im.IBCApp.OnChanOpenAck(ctx, portID, channelID, counterpartyVersion)
return im.IBCApp.OnChanOpenAck(ctx, portID, channelID, counterpartyVersion, counterpartyChannelID)
}

return nil
Expand Down