Skip to content

Commit

Permalink
remove getcounterpartyv2
Browse files Browse the repository at this point in the history
  • Loading branch information
bznein committed Sep 19, 2024
1 parent 2c15b97 commit 51be553
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 44 deletions.
26 changes: 0 additions & 26 deletions modules/core/04-channel/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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
}
13 changes: 0 additions & 13 deletions modules/core/packet-server/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
5 changes: 2 additions & 3 deletions modules/core/packet-server/keeper/relay_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ package keeper
import (
"bytes"
"context"
"strconv"

"slices"
"strconv"

errorsmod "cosmossdk.io/errors"

Expand All @@ -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)
}
Expand Down
3 changes: 1 addition & 2 deletions modules/core/packet-server/types/expected_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 51be553

Please sign in to comment.