diff --git a/docs/docs/05-migrations/13-v8-to-v9.md b/docs/docs/05-migrations/13-v8-to-v9.md index d8db9c400af..6479e64ae63 100644 --- a/docs/docs/05-migrations/13-v8-to-v9.md +++ b/docs/docs/05-migrations/13-v8-to-v9.md @@ -27,6 +27,7 @@ There are four sections based on the four potential user groups of this document ### API removals The `exported.ChannelI` and `exported.CounterpartyChannelI` interfaces has been removed. Please use the concrete types. +The `exported.ConnectionI` interface has been removed. Please use the concrete types. The functions `GetState()`, `GetOrdering()`, `GetCounterparty()`, `GetConnectionHops()`, `GetVersion()` of the `Channel` type have been removed. The functions `GetPortID()`, `GetChannelID()` of the `CounterpartyChannel` type have been removed. diff --git a/modules/apps/27-interchain-accounts/types/expected_keepers.go b/modules/apps/27-interchain-accounts/types/expected_keepers.go index 09cf6c22024..de2eb9de245 100644 --- a/modules/apps/27-interchain-accounts/types/expected_keepers.go +++ b/modules/apps/27-interchain-accounts/types/expected_keepers.go @@ -7,8 +7,8 @@ import ( paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" + connectiontypes "github.com/cosmos/ibc-go/v8/modules/core/03-connection/types" channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" - ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported" ) // AccountKeeper defines the expected account keeper @@ -24,7 +24,7 @@ type AccountKeeper interface { type ChannelKeeper interface { GetChannel(ctx sdk.Context, srcPort, srcChan string) (channel channeltypes.Channel, found bool) GetNextSequenceSend(ctx sdk.Context, portID, channelID string) (uint64, bool) - GetConnection(ctx sdk.Context, connectionID string) (ibcexported.ConnectionI, error) + GetConnection(ctx sdk.Context, connectionID string) (connectiontypes.ConnectionEnd, error) GetAllChannelsWithPortPrefix(ctx sdk.Context, portPrefix string) []channeltypes.IdentifiedChannel } diff --git a/modules/core/02-client/migrations/v7/solomachine.go b/modules/core/02-client/migrations/v7/solomachine.go index d083af969ea..4f0e219097a 100644 --- a/modules/core/02-client/migrations/v7/solomachine.go +++ b/modules/core/02-client/migrations/v7/solomachine.go @@ -158,14 +158,6 @@ func (ClientState) VerifyClientConsensusState( panic(errors.New("legacy solo machine is deprecated")) } -// VerifyConnectionState panics! -func (ClientState) VerifyConnectionState( - storetypes.KVStore, codec.BinaryCodec, exported.Height, - exported.Prefix, []byte, string, exported.ConnectionI, -) error { - panic(errors.New("legacy solo machine is deprecated")) -} - // VerifyPacketCommitment panics! func (ClientState) VerifyPacketCommitment( sdk.Context, storetypes.KVStore, codec.BinaryCodec, exported.Height, diff --git a/modules/core/03-connection/keeper/verify.go b/modules/core/03-connection/keeper/verify.go index 17948b8c020..847b7c77d49 100644 --- a/modules/core/03-connection/keeper/verify.go +++ b/modules/core/03-connection/keeper/verify.go @@ -9,11 +9,10 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" - connectiontypes "github.com/cosmos/ibc-go/v8/modules/core/03-connection/types" + "github.com/cosmos/ibc-go/v8/modules/core/03-connection/types" channeltypes "github.com/cosmos/ibc-go/v8/modules/core/04-channel/types" commitmenttypes "github.com/cosmos/ibc-go/v8/modules/core/23-commitment/types" host "github.com/cosmos/ibc-go/v8/modules/core/24-host" - ibcerrors "github.com/cosmos/ibc-go/v8/modules/core/errors" "github.com/cosmos/ibc-go/v8/modules/core/exported" ) @@ -21,7 +20,7 @@ import ( // stored on the target machine func (k Keeper) VerifyClientState( ctx sdk.Context, - connection exported.ConnectionI, + connection types.ConnectionEnd, height exported.Height, proof []byte, clientState exported.ClientState, @@ -62,7 +61,7 @@ func (k Keeper) VerifyClientState( // specified client stored on the target machine. func (k Keeper) VerifyClientConsensusState( ctx sdk.Context, - connection exported.ConnectionI, + connection types.ConnectionEnd, height exported.Height, consensusHeight exported.Height, proof []byte, @@ -104,11 +103,11 @@ func (k Keeper) VerifyClientConsensusState( // specified connection end stored on the target machine. func (k Keeper) VerifyConnectionState( ctx sdk.Context, - connection exported.ConnectionI, + connection types.ConnectionEnd, height exported.Height, proof []byte, connectionID string, - counterpartyConnection exported.ConnectionI, // opposite connection + counterpartyConnection types.ConnectionEnd, // opposite connection ) error { clientID := connection.GetClientID() clientState, clientStore, err := k.getClientStateAndVerificationStore(ctx, clientID) @@ -126,12 +125,7 @@ func (k Keeper) VerifyConnectionState( return err } - connectionEnd, ok := counterpartyConnection.(connectiontypes.ConnectionEnd) - if !ok { - return errorsmod.Wrapf(ibcerrors.ErrInvalidType, "invalid connection type %T", counterpartyConnection) - } - - bz, err := k.cdc.Marshal(&connectionEnd) + bz, err := k.cdc.Marshal(&counterpartyConnection) if err != nil { return err } @@ -151,7 +145,7 @@ func (k Keeper) VerifyConnectionState( // channel end, under the specified port, stored on the target machine. func (k Keeper) VerifyChannelState( ctx sdk.Context, - connection exported.ConnectionI, + connection types.ConnectionEnd, height exported.Height, proof []byte, portID, @@ -194,7 +188,7 @@ func (k Keeper) VerifyChannelState( // the specified port, specified channel, and specified sequence. func (k Keeper) VerifyPacketCommitment( ctx sdk.Context, - connection exported.ConnectionI, + connection types.ConnectionEnd, height exported.Height, proof []byte, portID, @@ -237,7 +231,7 @@ func (k Keeper) VerifyPacketCommitment( // acknowledgement at the specified port, specified channel, and specified sequence. func (k Keeper) VerifyPacketAcknowledgement( ctx sdk.Context, - connection exported.ConnectionI, + connection types.ConnectionEnd, height exported.Height, proof []byte, portID, @@ -281,7 +275,7 @@ func (k Keeper) VerifyPacketAcknowledgement( // specified sequence. func (k Keeper) VerifyPacketReceiptAbsence( ctx sdk.Context, - connection exported.ConnectionI, + connection types.ConnectionEnd, height exported.Height, proof []byte, portID, @@ -323,7 +317,7 @@ func (k Keeper) VerifyPacketReceiptAbsence( // received of the specified channel at the specified port. func (k Keeper) VerifyNextSequenceRecv( ctx sdk.Context, - connection exported.ConnectionI, + connection types.ConnectionEnd, height exported.Height, proof []byte, portID, @@ -364,7 +358,7 @@ func (k Keeper) VerifyNextSequenceRecv( // VerifyChannelUpgradeError verifies a proof of the provided upgrade error receipt. func (k Keeper) VerifyChannelUpgradeError( ctx sdk.Context, - connection exported.ConnectionI, + connection types.ConnectionEnd, height exported.Height, proof []byte, portID, @@ -406,7 +400,7 @@ func (k Keeper) VerifyChannelUpgradeError( // VerifyChannelUpgrade verifies the proof that a particular proposed upgrade has been stored in the upgrade path. func (k Keeper) VerifyChannelUpgrade( ctx sdk.Context, - connection exported.ConnectionI, + connection types.ConnectionEnd, proofHeight exported.Height, upgradeProof []byte, portID, @@ -447,7 +441,7 @@ func (k Keeper) VerifyChannelUpgrade( // getBlockDelay calculates the block delay period from the time delay of the connection // and the maximum expected time per block. -func (k Keeper) getBlockDelay(ctx sdk.Context, connection exported.ConnectionI) uint64 { +func (k Keeper) getBlockDelay(ctx sdk.Context, connection types.ConnectionEnd) uint64 { // expectedTimePerBlock should never be zero, however if it is then return a 0 block delay for safety // as the expectedTimePerBlock parameter was not set. expectedTimePerBlock := k.GetParams(ctx).MaxExpectedTimePerBlock diff --git a/modules/core/03-connection/types/codec.go b/modules/core/03-connection/types/codec.go index e551228ca5e..9da606deab4 100644 --- a/modules/core/03-connection/types/codec.go +++ b/modules/core/03-connection/types/codec.go @@ -12,11 +12,6 @@ import ( // RegisterInterfaces register the ibc interfaces submodule implementations to protobuf // Any. func RegisterInterfaces(registry codectypes.InterfaceRegistry) { - registry.RegisterInterface( - "ibc.core.connection.v1.ConnectionI", - (*exported.ConnectionI)(nil), - &ConnectionEnd{}, - ) registry.RegisterInterface( "ibc.core.connection.v1.CounterpartyConnectionI", (*exported.CounterpartyConnectionI)(nil), diff --git a/modules/core/03-connection/types/codec_test.go b/modules/core/03-connection/types/codec_test.go index ca1d5b7c7c2..829ca77d7bc 100644 --- a/modules/core/03-connection/types/codec_test.go +++ b/modules/core/03-connection/types/codec_test.go @@ -18,11 +18,6 @@ func TestCodecTypeRegistration(t *testing.T) { typeURL string expPass bool }{ - { - "success: ConnectionEnd", - sdk.MsgTypeURL(&types.ConnectionEnd{}), - true, - }, { "success: Counterparty", sdk.MsgTypeURL(&types.Counterparty{}), diff --git a/modules/core/03-connection/types/connection.go b/modules/core/03-connection/types/connection.go index e341088d7e7..3c68dd93eab 100644 --- a/modules/core/03-connection/types/connection.go +++ b/modules/core/03-connection/types/connection.go @@ -9,8 +9,6 @@ import ( "github.com/cosmos/ibc-go/v8/modules/core/exported" ) -var _ exported.ConnectionI = (*ConnectionEnd)(nil) - // NewConnectionEnd creates a new ConnectionEnd instance. func NewConnectionEnd(state State, clientID string, counterparty Counterparty, versions []*Version, delayPeriod uint64) ConnectionEnd { return ConnectionEnd{ diff --git a/modules/core/04-channel/keeper/keeper.go b/modules/core/04-channel/keeper/keeper.go index 2aa04fae6ae..5272554204d 100644 --- a/modules/core/04-channel/keeper/keeper.go +++ b/modules/core/04-channel/keeper/keeper.go @@ -457,27 +457,27 @@ func (k Keeper) GetChannelClientState(ctx sdk.Context, portID, channelID string) } // GetConnection wraps the connection keeper's GetConnection function. -func (k Keeper) GetConnection(ctx sdk.Context, connectionID string) (exported.ConnectionI, error) { +func (k Keeper) GetConnection(ctx sdk.Context, connectionID string) (connectiontypes.ConnectionEnd, error) { connection, found := k.connectionKeeper.GetConnection(ctx, connectionID) if !found { - return nil, errorsmod.Wrapf(connectiontypes.ErrConnectionNotFound, "connection-id: %s", connectionID) + return connectiontypes.ConnectionEnd{}, errorsmod.Wrapf(connectiontypes.ErrConnectionNotFound, "connection-id: %s", connectionID) } return connection, nil } // GetChannelConnection returns the connection ID and state associated with the given port and channel identifier. -func (k Keeper) GetChannelConnection(ctx sdk.Context, portID, channelID string) (string, exported.ConnectionI, error) { +func (k Keeper) GetChannelConnection(ctx sdk.Context, portID, channelID string) (string, connectiontypes.ConnectionEnd, error) { channel, found := k.GetChannel(ctx, portID, channelID) if !found { - return "", nil, errorsmod.Wrapf(types.ErrChannelNotFound, "port-id: %s, channel-id: %s", portID, channelID) + return "", connectiontypes.ConnectionEnd{}, errorsmod.Wrapf(types.ErrChannelNotFound, "port-id: %s, channel-id: %s", portID, channelID) } connectionID := channel.ConnectionHops[0] connection, found := k.connectionKeeper.GetConnection(ctx, connectionID) if !found { - return "", nil, errorsmod.Wrapf(connectiontypes.ErrConnectionNotFound, "connection-id: %s", connectionID) + return "", connectiontypes.ConnectionEnd{}, errorsmod.Wrapf(connectiontypes.ErrConnectionNotFound, "connection-id: %s", connectionID) } return connectionID, connection, nil diff --git a/modules/core/04-channel/types/expected_keepers.go b/modules/core/04-channel/types/expected_keepers.go index 3a40aaab978..b5025a253ac 100644 --- a/modules/core/04-channel/types/expected_keepers.go +++ b/modules/core/04-channel/types/expected_keepers.go @@ -28,7 +28,7 @@ type ConnectionKeeper interface { ) (uint64, error) VerifyChannelState( ctx sdk.Context, - connection exported.ConnectionI, + connection connectiontypes.ConnectionEnd, height exported.Height, proof []byte, portID, @@ -37,7 +37,7 @@ type ConnectionKeeper interface { ) error VerifyPacketCommitment( ctx sdk.Context, - connection exported.ConnectionI, + connection connectiontypes.ConnectionEnd, height exported.Height, proof []byte, portID, @@ -47,7 +47,7 @@ type ConnectionKeeper interface { ) error VerifyPacketAcknowledgement( ctx sdk.Context, - connection exported.ConnectionI, + connection connectiontypes.ConnectionEnd, height exported.Height, proof []byte, portID, @@ -57,7 +57,7 @@ type ConnectionKeeper interface { ) error VerifyPacketReceiptAbsence( ctx sdk.Context, - connection exported.ConnectionI, + connection connectiontypes.ConnectionEnd, height exported.Height, proof []byte, portID, @@ -66,7 +66,7 @@ type ConnectionKeeper interface { ) error VerifyNextSequenceRecv( ctx sdk.Context, - connection exported.ConnectionI, + connection connectiontypes.ConnectionEnd, height exported.Height, proof []byte, portID, @@ -75,7 +75,7 @@ type ConnectionKeeper interface { ) error VerifyChannelUpgrade( ctx sdk.Context, - connection exported.ConnectionI, + connection connectiontypes.ConnectionEnd, height exported.Height, proof []byte, portID, @@ -84,7 +84,7 @@ type ConnectionKeeper interface { ) error VerifyChannelUpgradeError( ctx sdk.Context, - connection exported.ConnectionI, + connection connectiontypes.ConnectionEnd, height exported.Height, proof []byte, portID, diff --git a/modules/core/exported/connection.go b/modules/core/exported/connection.go index f4353ffc278..00b55913bd0 100644 --- a/modules/core/exported/connection.go +++ b/modules/core/exported/connection.go @@ -3,14 +3,6 @@ package exported // LocalhostConnectionID is the sentinel connection ID for the localhost connection. const LocalhostConnectionID string = "connection-localhost" -// ConnectionI describes the required methods for a connection. -type ConnectionI interface { - GetClientID() string - GetCounterparty() CounterpartyConnectionI - GetDelayPeriod() uint64 - ValidateBasic() error -} - // CounterpartyConnectionI describes the required methods for a counterparty connection. type CounterpartyConnectionI interface { GetClientID() string