Skip to content

Commit ceefeec

Browse files
authored
remove NegotiateAppVersion and AppVersion gRPC (#643)
The NegotiateAppVersion callback has been removed from the IBC Application interface. The gRPC AppVersion has been removed. The app version negoitation will be handled by applications by returning the version in OnChanOpenTry.
1 parent 2273ef3 commit ceefeec

File tree

15 files changed

+1
-488
lines changed

15 files changed

+1
-488
lines changed

docs/ibc/proto-docs.md

-67
Original file line numberDiff line numberDiff line change
@@ -207,12 +207,6 @@
207207

208208
- [Msg](#ibc.core.connection.v1.Msg)
209209

210-
- [ibc/core/port/v1/query.proto](#ibc/core/port/v1/query.proto)
211-
- [QueryAppVersionRequest](#ibc.core.port.v1.QueryAppVersionRequest)
212-
- [QueryAppVersionResponse](#ibc.core.port.v1.QueryAppVersionResponse)
213-
214-
- [Query](#ibc.core.port.v1.Query)
215-
216210
- [ibc/core/types/v1/genesis.proto](#ibc/core/types/v1/genesis.proto)
217211
- [GenesisState](#ibc.core.types.v1.GenesisState)
218212

@@ -3107,67 +3101,6 @@ Msg defines the ibc/connection Msg service.
31073101

31083102

31093103

3110-
<a name="ibc/core/port/v1/query.proto"></a>
3111-
<p align="right"><a href="#top">Top</a></p>
3112-
3113-
## ibc/core/port/v1/query.proto
3114-
3115-
3116-
3117-
<a name="ibc.core.port.v1.QueryAppVersionRequest"></a>
3118-
3119-
### QueryAppVersionRequest
3120-
QueryAppVersionRequest is the request type for the Query/AppVersion RPC method
3121-
3122-
3123-
| Field | Type | Label | Description |
3124-
| ----- | ---- | ----- | ----------- |
3125-
| `port_id` | [string](#string) | | port unique identifier |
3126-
| `connection_id` | [string](#string) | | connection unique identifier |
3127-
| `ordering` | [ibc.core.channel.v1.Order](#ibc.core.channel.v1.Order) | | whether the channel is ordered or unordered |
3128-
| `counterparty` | [ibc.core.channel.v1.Counterparty](#ibc.core.channel.v1.Counterparty) | | counterparty channel end |
3129-
| `proposed_version` | [string](#string) | | proposed version |
3130-
3131-
3132-
3133-
3134-
3135-
3136-
<a name="ibc.core.port.v1.QueryAppVersionResponse"></a>
3137-
3138-
### QueryAppVersionResponse
3139-
QueryAppVersionResponse is the response type for the Query/AppVersion RPC method.
3140-
3141-
3142-
| Field | Type | Label | Description |
3143-
| ----- | ---- | ----- | ----------- |
3144-
| `port_id` | [string](#string) | | port id associated with the request identifiers |
3145-
| `version` | [string](#string) | | supported app version |
3146-
3147-
3148-
3149-
3150-
3151-
<!-- end messages -->
3152-
3153-
<!-- end enums -->
3154-
3155-
<!-- end HasExtensions -->
3156-
3157-
3158-
<a name="ibc.core.port.v1.Query"></a>
3159-
3160-
### Query
3161-
Query defines the gRPC querier service
3162-
3163-
| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint |
3164-
| ----------- | ------------ | ------------- | ------------| ------- | -------- |
3165-
| `AppVersion` | [QueryAppVersionRequest](#ibc.core.port.v1.QueryAppVersionRequest) | [QueryAppVersionResponse](#ibc.core.port.v1.QueryAppVersionResponse) | AppVersion queries an IBC Port and determines the appropriate application version to be used | |
3166-
3167-
<!-- end services -->
3168-
3169-
3170-
31713104
<a name="ibc/core/types/v1/genesis.proto"></a>
31723105
<p align="right"><a href="#top">Top</a></p>
31733106

modules/apps/27-interchain-accounts/controller/ibc_module.go

-12
Original file line numberDiff line numberDiff line change
@@ -163,15 +163,3 @@ func (im IBCModule) OnTimeoutPacket(
163163

164164
return im.app.OnTimeoutPacket(ctx, packet, relayer)
165165
}
166-
167-
// NegotiateAppVersion implements the IBCModule interface
168-
func (im IBCModule) NegotiateAppVersion(
169-
ctx sdk.Context,
170-
order channeltypes.Order,
171-
connectionID string,
172-
portID string,
173-
counterparty channeltypes.Counterparty,
174-
proposedVersion string,
175-
) (string, error) {
176-
return "", sdkerrors.Wrap(icatypes.ErrInvalidChannelFlow, "ICS-27 app version negotiation is unsupported on controller chains")
177-
}

modules/apps/27-interchain-accounts/controller/ibc_module_test.go

-56
Original file line numberDiff line numberDiff line change
@@ -630,59 +630,3 @@ func (suite *InterchainAccountsTestSuite) TestOnTimeoutPacket() {
630630
})
631631
}
632632
}
633-
634-
func (suite *InterchainAccountsTestSuite) TestNegotiateAppVersion() {
635-
var (
636-
proposedVersion string
637-
)
638-
testCases := []struct {
639-
name string
640-
malleate func()
641-
expPass bool
642-
}{
643-
{
644-
"ICA OnRecvPacket fails with ErrInvalidChannelFlow", func() {}, false,
645-
},
646-
}
647-
648-
for _, tc := range testCases {
649-
tc := tc
650-
651-
suite.Run(tc.name, func() {
652-
suite.SetupTest()
653-
path := NewICAPath(suite.chainA, suite.chainB)
654-
suite.coordinator.SetupConnections(path)
655-
656-
err := InitInterchainAccount(path.EndpointA, TestOwnerAddress)
657-
suite.Require().NoError(err)
658-
659-
module, _, err := suite.chainA.GetSimApp().GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), path.EndpointA.ChannelConfig.PortID)
660-
suite.Require().NoError(err)
661-
662-
cbs, ok := suite.chainA.GetSimApp().GetIBCKeeper().Router.GetRoute(module)
663-
suite.Require().True(ok)
664-
665-
counterpartyPortID, err := icatypes.GeneratePortID(TestOwnerAddress, path.EndpointA.ConnectionID, path.EndpointB.ConnectionID)
666-
suite.Require().NoError(err)
667-
668-
counterparty := channeltypes.Counterparty{
669-
PortId: counterpartyPortID,
670-
ChannelId: path.EndpointB.ChannelID,
671-
}
672-
673-
proposedVersion = icatypes.VersionPrefix
674-
675-
tc.malleate()
676-
677-
version, err := cbs.NegotiateAppVersion(suite.chainA.GetContext(), channeltypes.ORDERED, path.EndpointA.ConnectionID, path.EndpointA.ChannelConfig.PortID, counterparty, proposedVersion)
678-
if tc.expPass {
679-
suite.Require().NoError(err)
680-
suite.Require().NoError(icatypes.ValidateVersion(version))
681-
suite.Require().Equal(TestVersion, version)
682-
} else {
683-
suite.Require().Error(err)
684-
suite.Require().Empty(version)
685-
}
686-
})
687-
}
688-
}

modules/apps/27-interchain-accounts/host/ibc_module.go

-12
Original file line numberDiff line numberDiff line change
@@ -137,15 +137,3 @@ func (im IBCModule) OnTimeoutPacket(
137137
) error {
138138
return sdkerrors.Wrap(icatypes.ErrInvalidChannelFlow, "cannot cause a packet timeout on a host channel end, a host chain does not send a packet over the channel")
139139
}
140-
141-
// NegotiateAppVersion implements the IBCModule interface
142-
func (im IBCModule) NegotiateAppVersion(
143-
ctx sdk.Context,
144-
order channeltypes.Order,
145-
connectionID string,
146-
portID string,
147-
counterparty channeltypes.Counterparty,
148-
proposedVersion string,
149-
) (string, error) {
150-
return im.keeper.NegotiateAppVersion(ctx, order, connectionID, portID, counterparty, proposedVersion)
151-
}

modules/apps/27-interchain-accounts/host/ibc_module_test.go

-58
Original file line numberDiff line numberDiff line change
@@ -584,61 +584,3 @@ func (suite *InterchainAccountsTestSuite) TestOnTimeoutPacket() {
584584
})
585585
}
586586
}
587-
588-
func (suite *InterchainAccountsTestSuite) TestNegotiateAppVersion() {
589-
var (
590-
proposedVersion string
591-
)
592-
testCases := []struct {
593-
name string
594-
malleate func()
595-
expPass bool
596-
}{
597-
{
598-
"success", func() {}, true,
599-
},
600-
{
601-
"invalid proposed version", func() {
602-
proposedVersion = "invalid version"
603-
}, false,
604-
},
605-
}
606-
607-
for _, tc := range testCases {
608-
tc := tc
609-
610-
suite.Run(tc.name, func() {
611-
suite.SetupTest()
612-
path := NewICAPath(suite.chainA, suite.chainB)
613-
suite.coordinator.SetupConnections(path)
614-
615-
module, _, err := suite.chainA.GetSimApp().GetIBCKeeper().PortKeeper.LookupModuleByPort(suite.chainA.GetContext(), icatypes.PortID)
616-
suite.Require().NoError(err)
617-
618-
cbs, ok := suite.chainA.GetSimApp().GetIBCKeeper().Router.GetRoute(module)
619-
suite.Require().True(ok)
620-
621-
counterpartyPortID, err := icatypes.GeneratePortID(TestOwnerAddress, path.EndpointA.ConnectionID, path.EndpointB.ConnectionID)
622-
suite.Require().NoError(err)
623-
624-
counterparty := &channeltypes.Counterparty{
625-
PortId: counterpartyPortID,
626-
ChannelId: path.EndpointB.ChannelID,
627-
}
628-
629-
proposedVersion = icatypes.VersionPrefix
630-
631-
tc.malleate()
632-
633-
version, err := cbs.NegotiateAppVersion(suite.chainA.GetContext(), channeltypes.ORDERED, path.EndpointA.ConnectionID, icatypes.PortID, *counterparty, proposedVersion)
634-
if tc.expPass {
635-
suite.Require().NoError(err)
636-
suite.Require().NoError(icatypes.ValidateVersion(version))
637-
suite.Require().Equal(TestVersion, version)
638-
} else {
639-
suite.Require().Error(err)
640-
suite.Require().Empty(version)
641-
}
642-
})
643-
}
644-
}

modules/apps/27-interchain-accounts/host/keeper/keeper.go

-21
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,13 @@ import (
77
baseapp "github.com/cosmos/cosmos-sdk/baseapp"
88
"github.com/cosmos/cosmos-sdk/codec"
99
sdk "github.com/cosmos/cosmos-sdk/types"
10-
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
1110
capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper"
1211
capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types"
1312
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
1413
"github.com/tendermint/tendermint/libs/log"
1514

1615
"github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/host/types"
1716
icatypes "github.com/cosmos/ibc-go/v3/modules/apps/27-interchain-accounts/types"
18-
channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types"
1917
host "github.com/cosmos/ibc-go/v3/modules/core/24-host"
2018
)
2119

@@ -180,22 +178,3 @@ func (k Keeper) SetInterchainAccountAddress(ctx sdk.Context, portID string, addr
180178
store := ctx.KVStore(k.storeKey)
181179
store.Set(icatypes.KeyOwnerAccount(portID), []byte(address))
182180
}
183-
184-
// NegotiateAppVersion handles application version negotation for the IBC interchain accounts module
185-
func (k Keeper) NegotiateAppVersion(
186-
ctx sdk.Context,
187-
order channeltypes.Order,
188-
connectionID string,
189-
portID string,
190-
counterparty channeltypes.Counterparty,
191-
proposedVersion string,
192-
) (string, error) {
193-
if proposedVersion != icatypes.VersionPrefix {
194-
return "", sdkerrors.Wrapf(icatypes.ErrInvalidVersion, "failed to negotiate app version: expected %s, got %s", icatypes.VersionPrefix, proposedVersion)
195-
}
196-
197-
moduleAccAddr := k.accountKeeper.GetModuleAddress(icatypes.ModuleName)
198-
accAddr := icatypes.GenerateAddress(moduleAccAddr, counterparty.PortId)
199-
200-
return icatypes.NewAppVersion(icatypes.VersionPrefix, accAddr.String()), nil
201-
}

modules/apps/transfer/ibc_module.go

-16
Original file line numberDiff line numberDiff line change
@@ -279,19 +279,3 @@ func (im IBCModule) OnTimeoutPacket(
279279

280280
return nil
281281
}
282-
283-
// NegotiateAppVersion implements the IBCModule interface
284-
func (im IBCModule) NegotiateAppVersion(
285-
ctx sdk.Context,
286-
order channeltypes.Order,
287-
connectionID string,
288-
portID string,
289-
counterparty channeltypes.Counterparty,
290-
proposedVersion string,
291-
) (string, error) {
292-
if proposedVersion != types.Version {
293-
return "", sdkerrors.Wrapf(types.ErrInvalidVersion, "failed to negotiate app version: expected %s, got %s", types.Version, proposedVersion)
294-
}
295-
296-
return types.Version, nil
297-
}

modules/core/05-port/keeper/grpc_query.go

-52
This file was deleted.

0 commit comments

Comments
 (0)