From 51be5536ac489686d06c56c87f38c8d241b7a636 Mon Sep 17 00:00:00 2001 From: bznein Date: Thu, 19 Sep 2024 16:18:03 +0100 Subject: [PATCH] remove getcounterpartyv2 --- modules/core/04-channel/keeper/keeper.go | 26 ------------------- modules/core/packet-server/keeper/keeper.go | 13 ---------- modules/core/packet-server/keeper/relay_v2.go | 5 ++-- .../packet-server/types/expected_keepers.go | 3 +-- 4 files changed, 3 insertions(+), 44 deletions(-) diff --git a/modules/core/04-channel/keeper/keeper.go b/modules/core/04-channel/keeper/keeper.go index eb7b9017df7..8e3c96eb40a 100644 --- a/modules/core/04-channel/keeper/keeper.go +++ b/modules/core/04-channel/keeper/keeper.go @@ -3,8 +3,6 @@ package keeper import ( "context" "errors" - commitmenttypes "github.com/cosmos/ibc-go/v9/modules/core/23-commitment/types" - packetservertypes "github.com/cosmos/ibc-go/v9/modules/core/packet-server/types" "strconv" "strings" @@ -851,27 +849,3 @@ func (k *Keeper) PruneAcknowledgements(ctx context.Context, portID, channelID st return totalPruned, totalRemaining, nil } - -// GetV2Counterparty returns a version 2 counterparty for the given port and channel ID -// by converting the channel into a version 2 counterparty -func (k *Keeper) GetV2Counterparty(ctx context.Context, portID, channelID string) (packetservertypes.Counterparty, bool) { - channel, ok := k.GetChannel(ctx, portID, channelID) - if !ok { - return packetservertypes.Counterparty{}, false - } - // Do not allow channel to be converted into a version 2 counterparty - // if the channel is not OPEN or if it is ORDERED - if channel.State != types.OPEN || channel.Ordering == types.ORDERED { - return packetservertypes.Counterparty{}, false - } - connection, ok := k.connectionKeeper.GetConnection(ctx, channel.ConnectionHops[0]) - if !ok { - return packetservertypes.Counterparty{}, false - } - merklePathPrefix := commitmenttypes.NewMerklePath(connection.Counterparty.Prefix.KeyPrefix, []byte("")) - counterparty := packetservertypes.Counterparty{ - ClientId: connection.ClientId, - MerklePathPrefix: merklePathPrefix, - } - return counterparty, true -} diff --git a/modules/core/packet-server/keeper/keeper.go b/modules/core/packet-server/keeper/keeper.go index 927c0fb9600..8c98d623a12 100644 --- a/modules/core/packet-server/keeper/keeper.go +++ b/modules/core/packet-server/keeper/keeper.go @@ -66,16 +66,3 @@ func (k *Keeper) GetCounterparty(ctx context.Context, clientID string) (types.Co k.cdc.MustUnmarshal(bz, &counterparty) return counterparty, true } - -// GetCounterparty gets the Counterparty for a given client identifier. -func (k *Keeper) GetCounterpartyV2(ctx context.Context, portID, channelID, clientID string) (types.Counterparty, bool) { - store := k.ChannelStore(ctx, clientID) - bz := store.Get([]byte(types.CounterpartyKey)) - if len(bz) == 0 { - return k.ChannelKeeper.GetV2Counterparty(ctx, portID, channelID) - } - - var counterparty types.Counterparty - k.cdc.MustUnmarshal(bz, &counterparty) - return counterparty, true -} diff --git a/modules/core/packet-server/keeper/relay_v2.go b/modules/core/packet-server/keeper/relay_v2.go index 01ba5d9bdb4..2b7485f5444 100644 --- a/modules/core/packet-server/keeper/relay_v2.go +++ b/modules/core/packet-server/keeper/relay_v2.go @@ -3,9 +3,8 @@ package keeper import ( "bytes" "context" - "strconv" - "slices" + "strconv" errorsmod "cosmossdk.io/errors" @@ -26,7 +25,7 @@ func (k Keeper) SendPacketV2( data []channeltypes.PacketData, ) (uint64, error) { // Lookup counterparty associated with our source channel to retrieve the destination channel - counterparty, ok := k.GetCounterpartyV2(ctx, "transfer", "channel-2", sourceID) + counterparty, ok := k.GetCounterparty(ctx, sourceID) if !ok { return 0, errorsmod.Wrap(types.ErrCounterpartyNotFound, sourceID) } diff --git a/modules/core/packet-server/types/expected_keepers.go b/modules/core/packet-server/types/expected_keepers.go index b83bf44529c..9bd93fa871b 100644 --- a/modules/core/packet-server/types/expected_keepers.go +++ b/modules/core/packet-server/types/expected_keepers.go @@ -2,6 +2,7 @@ package types import ( "context" + clienttypes "github.com/cosmos/ibc-go/v9/modules/core/02-client/types" "github.com/cosmos/ibc-go/v9/modules/core/04-channel/types" "github.com/cosmos/ibc-go/v9/modules/core/exported" @@ -43,8 +44,6 @@ type ChannelKeeper interface { GetMultiAcknowledgement(ctx context.Context, portID, channelID string, sequence uint64) (types.MultiAcknowledgement, bool) // SetMultiAcknowledgement writes the multi ack under the multi ack path. SetMultiAcknowledgement(ctx context.Context, portID, channelID string, sequence uint64, recvResults types.MultiAcknowledgement) - - GetV2Counterparty(ctx context.Context, portID, channelID string) (Counterparty, bool) } type ClientKeeper interface {