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

refactor: rename RegisterCounterpartyAddress rpc to RegisterCounterpartyPayee #1513

Merged
merged 13 commits into from
Jun 14, 2022
Merged
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
28 changes: 14 additions & 14 deletions docs/ibc/proto-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@
- [MsgPayPacketFeeAsync](#ibc.applications.fee.v1.MsgPayPacketFeeAsync)
- [MsgPayPacketFeeAsyncResponse](#ibc.applications.fee.v1.MsgPayPacketFeeAsyncResponse)
- [MsgPayPacketFeeResponse](#ibc.applications.fee.v1.MsgPayPacketFeeResponse)
- [MsgRegisterCounterpartyAddress](#ibc.applications.fee.v1.MsgRegisterCounterpartyAddress)
- [MsgRegisterCounterpartyAddressResponse](#ibc.applications.fee.v1.MsgRegisterCounterpartyAddressResponse)
- [MsgRegisterCounterpartyPayee](#ibc.applications.fee.v1.MsgRegisterCounterpartyPayee)
- [MsgRegisterCounterpartyPayeeResponse](#ibc.applications.fee.v1.MsgRegisterCounterpartyPayeeResponse)
- [MsgRegisterPayee](#ibc.applications.fee.v1.MsgRegisterPayee)
- [MsgRegisterPayeeResponse](#ibc.applications.fee.v1.MsgRegisterPayeeResponse)

Expand Down Expand Up @@ -1342,28 +1342,28 @@ MsgPayPacketFeeResponse defines the response type for the PayPacketFee rpc



<a name="ibc.applications.fee.v1.MsgRegisterCounterpartyAddress"></a>
<a name="ibc.applications.fee.v1.MsgRegisterCounterpartyPayee"></a>

### MsgRegisterCounterpartyAddress
MsgRegisterCounterpartyAddress defines the request type for the RegisterCounterpartyAddress rpc
### MsgRegisterCounterpartyPayee
MsgRegisterCounterpartyPayee defines the request type for the RegisterCounterpartyPayee rpc


| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| `address` | [string](#string) | | the relayer address |
| `counterparty_address` | [string](#string) | | the counterparty relayer address |
| `port_id` | [string](#string) | | unique port identifier |
| `channel_id` | [string](#string) | | unique channel identifier |
| `relayer` | [string](#string) | | the relayer address |
| `counterparty_payee` | [string](#string) | | the counterparty payee address |






<a name="ibc.applications.fee.v1.MsgRegisterCounterpartyAddressResponse"></a>
<a name="ibc.applications.fee.v1.MsgRegisterCounterpartyPayeeResponse"></a>

### MsgRegisterCounterpartyAddressResponse
MsgRegisterCounterpartyAddressResponse defines the response type for the RegisterCounterpartyAddress rpc
### MsgRegisterCounterpartyPayeeResponse
MsgRegisterCounterpartyPayeeResponse defines the response type for the RegisterCounterpartyPayee rpc



Expand All @@ -1380,8 +1380,8 @@ MsgRegisterPayee defines the request type for the RegisterPayee rpc
| ----- | ---- | ----- | ----------- |
| `port_id` | [string](#string) | | unique port identifier |
| `channel_id` | [string](#string) | | unique channel identifier |
| `relayer_address` | [string](#string) | | the relayer address |
| `payee` | [string](#string) | | the fee payee address |
| `relayer` | [string](#string) | | the relayer address |
| `payee` | [string](#string) | | the payee address |



Expand Down Expand Up @@ -1411,8 +1411,8 @@ Msg defines the ICS29 Msg service.

| Method Name | Request Type | Response Type | Description | HTTP Verb | Endpoint |
| ----------- | ------------ | ------------- | ------------| ------- | -------- |
| `RegisterPayee` | [MsgRegisterPayee](#ibc.applications.fee.v1.MsgRegisterPayee) | [MsgRegisterPayeeResponse](#ibc.applications.fee.v1.MsgRegisterPayeeResponse) | RegisterPayee defines a rpc handler method for MsgRegisterPayee RegisterPayee is called by the relayer on each channelEnd and allows them to set an optional payee to which escrowed packet fees will be paid out. The payee should be registered on the source chain from which packets originate as this is where fee distribution takes place. This function may be called more than once by a relayer, in which case, the latest payee is always used. | |
| `RegisterCounterpartyAddress` | [MsgRegisterCounterpartyAddress](#ibc.applications.fee.v1.MsgRegisterCounterpartyAddress) | [MsgRegisterCounterpartyAddressResponse](#ibc.applications.fee.v1.MsgRegisterCounterpartyAddressResponse) | RegisterCounterpartyAddress defines a rpc handler method for MsgRegisterCounterpartyAddress RegisterCounterpartyAddress is called by the relayer on each channelEnd and allows them to specify their counterparty address before relaying. This ensures they will be properly compensated for forward relaying since destination chain must send back relayer's source address (counterparty address) in acknowledgement. This function may be called more than once by a relayer, in which case, the latest counterparty address is always used. | |
| `RegisterPayee` | [MsgRegisterPayee](#ibc.applications.fee.v1.MsgRegisterPayee) | [MsgRegisterPayeeResponse](#ibc.applications.fee.v1.MsgRegisterPayeeResponse) | RegisterPayee defines a rpc handler method for MsgRegisterPayee RegisterPayee is called by the relayer on each channelEnd and allows them to set an optional payee to which reverse and timeout relayer packet fees will be paid out. The payee should be registered on the source chain from which packets originate as this is where fee distribution takes place. This function may be called more than once by a relayer, in which case, the latest payee is always used. | |
| `RegisterCounterpartyPayee` | [MsgRegisterCounterpartyPayee](#ibc.applications.fee.v1.MsgRegisterCounterpartyPayee) | [MsgRegisterCounterpartyPayeeResponse](#ibc.applications.fee.v1.MsgRegisterCounterpartyPayeeResponse) | RegisterCounterpartyPayee defines a rpc handler method for MsgRegisterCounterpartyPayee RegisterCounterpartyPayee is called by the relayer on each channelEnd and allows them to specify the counterparty payee address before relaying. This ensures they will be properly compensated for forward relaying since the destination chain must include the registered counterparty payee address in the acknowledgement. This function may be called more than once by a relayer, in which case, the latest counterparty payee address is always used. | |
Copy link
Contributor

Choose a reason for hiding this comment

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

This ensures they will be properly compensated for forward relaying since the destination chain must include the registered counterparty payee address in the acknowledgement. This is not complete true with the introduction of the the MsgRegisterPayee, right? Because the payee that you register could get the fees even if the counterparty address is not registered. An operator could decide not to use the counterparty payee at all and only the payee, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

I've updated must to may and included an additional note:

// A registered payee on the source chain will always override a registered counterparty payee.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, @damiannolan, I think my comment above is not correct. I just realized while I was writing this comment on the other PR. I think you still need to register the counterparty address, otherwise we wouldn't know on the source chain to which payee to pay out the fees. The counterparty address may or may not have a payee registered.

Copy link
Contributor

Choose a reason for hiding this comment

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

After the conversation this morning in the planning call, I think we need to update this comment again, right?

Copy link
Member Author

@damiannolan damiannolan Jun 13, 2022

Choose a reason for hiding this comment

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

Yep, done! Feel free to suggest changes

| `PayPacketFee` | [MsgPayPacketFee](#ibc.applications.fee.v1.MsgPayPacketFee) | [MsgPayPacketFeeResponse](#ibc.applications.fee.v1.MsgPayPacketFeeResponse) | PayPacketFee defines a rpc handler method for MsgPayPacketFee PayPacketFee is an open callback that may be called by any module/user that wishes to escrow funds in order to incentivize the relaying of the packet at the next sequence NOTE: This method is intended to be used within a multi msg transaction, where the subsequent msg that follows initiates the lifecycle of the incentivized packet | |
| `PayPacketFeeAsync` | [MsgPayPacketFeeAsync](#ibc.applications.fee.v1.MsgPayPacketFeeAsync) | [MsgPayPacketFeeAsyncResponse](#ibc.applications.fee.v1.MsgPayPacketFeeAsyncResponse) | PayPacketFeeAsync defines a rpc handler method for MsgPayPacketFeeAsync PayPacketFeeAsync is an open callback that may be called by any module/user that wishes to escrow funds in order to incentivize the relaying of a known packet (i.e. at a particular sequence) | |

Expand Down
2 changes: 1 addition & 1 deletion modules/apps/29-fee/client/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ func NewTxCmd() *cobra.Command {

txCmd.AddCommand(
NewRegisterPayeeCmd(),
NewRegisterCounterpartyPayeeCmd(),
NewPayPacketFeeAsyncTxCmd(),
NewRegisterCounterpartyAddressCmd(),
)

return txCmd
Expand Down
52 changes: 26 additions & 26 deletions modules/apps/29-fee/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const (
// NewRegisterPayeeCmd returns the command to create a MsgRegisterPayee
func NewRegisterPayeeCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "register-payee [port-id] [channel-id] [relayer-address] [payee-address] ",
Use: "register-payee [port-id] [channel-id] [relayer] [payee] ",
Short: "Register a payee on a given channel.",
Long: strings.TrimSpace(`Register a payee address on a given channel.`),
Example: fmt.Sprintf("%s tx ibc-fee register-payee transfer channel-0 cosmos1rsp837a4kvtgp2m4uqzdge0zzu6efqgucm0qdh cosmos153lf4zntqt33a4v0sm5cytrxyqn78q7kz8j8x5", version.AppName),
Expand All @@ -47,6 +47,31 @@ func NewRegisterPayeeCmd() *cobra.Command {
return cmd
}

// NewRegisterCounterpartyPayeeCmd returns the command to create a MsgRegisterCounterpartyPayee
func NewRegisterCounterpartyPayeeCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "register-counterparty-payee [port-id] [channel-id] [relayer] [counterparty-payee] ",
Short: "Register a counterparty payee address on a given channel.",
Long: strings.TrimSpace(`Register a counterparty payee address on a given channel.`),
Copy link
Contributor

Choose a reason for hiding this comment

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

[nit] unnecessary strings.TrimSpace call, this is just a regular string.

Copy link
Member Author

Choose a reason for hiding this comment

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

I left this in from existing code and I think there's a good few of them around. Maybe we could open a follow up PR to remove them if you want, some general housekeeping.

Example: fmt.Sprintf("%s tx ibc-fee register-counterparty-payee transfer channel-0 cosmos1rsp837a4kvtgp2m4uqzdge0zzu6efqgucm0qdh osmo1v5y0tz01llxzf4c2afml8s3awue0ymju22wxx2", version.AppName),
Args: cobra.ExactArgs(4),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
}

msg := types.NewMsgRegisterCounterpartyPayee(args[0], args[1], args[2], args[3])

return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
},
}

flags.AddTxFlagsToCmd(cmd)

return cmd
}

// NewPayPacketFeeAsyncTxCmd returns the command to create a MsgPayPacketFeeAsync
func NewPayPacketFeeAsyncTxCmd() *cobra.Command {
cmd := &cobra.Command{
Expand Down Expand Up @@ -122,28 +147,3 @@ func NewPayPacketFeeAsyncTxCmd() *cobra.Command {

return cmd
}

// NewRegisterCounterpartyAddressCmd returns the command to create a MsgRegisterCounterpartyAddress
func NewRegisterCounterpartyAddressCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "register-counterparty [port-id] [channel-id] [address] [counterparty-address] ",
Short: "Register a counterparty relayer address on a given channel.",
Long: strings.TrimSpace(`Register a counterparty relayer address on a given channel.`),
Example: fmt.Sprintf("%s tx ibc-fee register-counterparty transfer channel-0 cosmos1rsp837a4kvtgp2m4uqzdge0zzu6efqgucm0qdh osmo1v5y0tz01llxzf4c2afml8s3awue0ymju22wxx2", version.AppName),
Args: cobra.ExactArgs(4),
RunE: func(cmd *cobra.Command, args []string) error {
clientCtx, err := client.GetClientTxContext(cmd)
if err != nil {
return err
}

msg := types.NewMsgRegisterCounterpartyAddress(args[0], args[1], args[2], args[3])

return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
},
}

flags.AddTxFlagsToCmd(cmd)

return cmd
}
2 changes: 1 addition & 1 deletion modules/apps/29-fee/ibc_middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ func (im IBCMiddleware) OnRecvPacket(
}

// if forwardRelayer is not found we refund recv_fee
forwardRelayer, _ := im.keeper.GetCounterpartyAddress(ctx, relayer.String(), packet.GetDestChannel())
forwardRelayer, _ := im.keeper.GetCounterpartyPayeeAddress(ctx, relayer.String(), packet.GetDestChannel())

return types.NewIncentivizedAcknowledgement(forwardRelayer, ack.Acknowledgement(), ack.Success())
}
Expand Down
6 changes: 3 additions & 3 deletions modules/apps/29-fee/ibc_middleware_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ func (suite *FeeTestSuite) TestOnRecvPacket() {
{
"forward address is not found",
func() {
suite.chainB.GetSimApp().IBCFeeKeeper.SetCounterpartyAddress(suite.chainB.GetContext(), suite.chainA.SenderAccount.GetAddress().String(), "", suite.path.EndpointB.ChannelID)
suite.chainB.GetSimApp().IBCFeeKeeper.SetCounterpartyPayeeAddress(suite.chainB.GetContext(), suite.chainA.SenderAccount.GetAddress().String(), "", suite.path.EndpointB.ChannelID)
},
false,
true,
Expand All @@ -566,7 +566,7 @@ func (suite *FeeTestSuite) TestOnRecvPacket() {
cbs, ok := suite.chainB.App.GetIBCKeeper().Router.GetRoute(module)
suite.Require().True(ok)

suite.chainB.GetSimApp().IBCFeeKeeper.SetCounterpartyAddress(suite.chainB.GetContext(), suite.chainA.SenderAccount.GetAddress().String(), suite.chainB.SenderAccount.GetAddress().String(), suite.path.EndpointB.ChannelID)
suite.chainB.GetSimApp().IBCFeeKeeper.SetCounterpartyPayeeAddress(suite.chainB.GetContext(), suite.chainA.SenderAccount.GetAddress().String(), suite.chainB.SenderAccount.GetAddress().String(), suite.path.EndpointB.ChannelID)

// malleate test case
tc.malleate()
Expand All @@ -575,7 +575,7 @@ func (suite *FeeTestSuite) TestOnRecvPacket() {

switch {
case tc.name == "success":
forwardAddr, _ := suite.chainB.GetSimApp().IBCFeeKeeper.GetCounterpartyAddress(suite.chainB.GetContext(), suite.chainA.SenderAccount.GetAddress().String(), suite.path.EndpointB.ChannelID)
forwardAddr, _ := suite.chainB.GetSimApp().IBCFeeKeeper.GetCounterpartyPayeeAddress(suite.chainB.GetContext(), suite.chainA.SenderAccount.GetAddress().String(), suite.path.EndpointB.ChannelID)

expectedAck := types.IncentivizedAcknowledgement{
AppAcknowledgement: ibcmock.MockAcknowledgement.Acknowledgement(),
Expand Down
2 changes: 1 addition & 1 deletion modules/apps/29-fee/ica_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func (suite *FeeTestSuite) TestFeeInterchainAccounts() {
suite.Require().True(suite.chainB.GetSimApp().IBCFeeKeeper.IsFeeEnabled(suite.chainB.GetContext(), path.EndpointB.ChannelConfig.PortID, path.EndpointB.ChannelID))

// register counterparty address on destination chainB as chainA.SenderAccounts[1] for recv fee distribution
suite.chainB.GetSimApp().IBCFeeKeeper.SetCounterpartyAddress(suite.chainB.GetContext(), suite.chainB.SenderAccount.GetAddress().String(), suite.chainA.SenderAccounts[1].SenderAccount.GetAddress().String(), path.EndpointB.ChannelID)
suite.chainB.GetSimApp().IBCFeeKeeper.SetCounterpartyPayeeAddress(suite.chainB.GetContext(), suite.chainB.SenderAccount.GetAddress().String(), suite.chainA.SenderAccounts[1].SenderAccount.GetAddress().String(), path.EndpointB.ChannelID)

// escrow a packet fee for the next send sequence
expectedFee := types.NewFee(defaultRecvFee, defaultAckFee, defaultTimeoutFee)
Expand Down
2 changes: 1 addition & 1 deletion modules/apps/29-fee/keeper/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func (k Keeper) InitGenesis(ctx sdk.Context, state types.GenesisState) {
}

for _, relayer := range state.RegisteredRelayers {
k.SetCounterpartyAddress(ctx, relayer.Address, relayer.CounterpartyAddress, relayer.ChannelId)
k.SetCounterpartyPayeeAddress(ctx, relayer.Address, relayer.CounterpartyAddress, relayer.ChannelId)
}

for _, forwardAddr := range state.ForwardRelayers {
Expand Down
4 changes: 2 additions & 2 deletions modules/apps/29-fee/keeper/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (suite *KeeperTestSuite) TestInitGenesis() {
suite.Require().True(isEnabled)

// check relayers
addr, found := suite.chainA.GetSimApp().IBCFeeKeeper.GetCounterpartyAddress(suite.chainA.GetContext(), suite.chainA.SenderAccount.GetAddress().String(), ibctesting.FirstChannelID)
addr, found := suite.chainA.GetSimApp().IBCFeeKeeper.GetCounterpartyPayeeAddress(suite.chainA.GetContext(), suite.chainA.SenderAccount.GetAddress().String(), ibctesting.FirstChannelID)
suite.Require().True(found)
suite.Require().Equal(genesisState.RegisteredRelayers[0].CounterpartyAddress, addr)

Expand All @@ -82,7 +82,7 @@ func (suite *KeeperTestSuite) TestExportGenesis() {
sender := suite.chainA.SenderAccount.GetAddress().String()
counterparty := suite.chainB.SenderAccount.GetAddress().String()
// set counterparty address
suite.chainA.GetSimApp().IBCFeeKeeper.SetCounterpartyAddress(suite.chainA.GetContext(), sender, counterparty, ibctesting.FirstChannelID)
suite.chainA.GetSimApp().IBCFeeKeeper.SetCounterpartyPayeeAddress(suite.chainA.GetContext(), sender, counterparty, ibctesting.FirstChannelID)

// set forward relayer address
suite.chainA.GetSimApp().IBCFeeKeeper.SetRelayerAddressForAsyncAck(suite.chainA.GetContext(), packetID, sender)
Expand Down
2 changes: 1 addition & 1 deletion modules/apps/29-fee/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ func (k Keeper) CounterpartyAddress(goCtx context.Context, req *types.QueryCount

ctx := sdk.UnwrapSDKContext(goCtx)

counterpartyAddr, found := k.GetCounterpartyAddress(ctx, req.RelayerAddress, req.ChannelId)
counterpartyAddr, found := k.GetCounterpartyPayeeAddress(ctx, req.RelayerAddress, req.ChannelId)
if !found {
return nil, status.Errorf(codes.NotFound, "counterparty address not found for address: %s on channel: %s", req.RelayerAddress, req.ChannelId)
}
Expand Down
2 changes: 1 addition & 1 deletion modules/apps/29-fee/keeper/grpc_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ func (suite *KeeperTestSuite) TestQueryCounterpartyAddress() {
pk := secp256k1.GenPrivKey().PubKey()
expectedCounterpartyAddr := sdk.AccAddress(pk.Address())

suite.chainA.GetSimApp().IBCFeeKeeper.SetCounterpartyAddress(
suite.chainA.GetSimApp().IBCFeeKeeper.SetCounterpartyPayeeAddress(
suite.chainA.GetContext(),
suite.chainA.SenderAccount.GetAddress().String(),
expectedCounterpartyAddr.String(),
Expand Down
24 changes: 12 additions & 12 deletions modules/apps/29-fee/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ func (k Keeper) GetAllFeeEnabledChannels(ctx sdk.Context) []types.FeeEnabledChan
// GetPayeeAddress retrieves the fee payee address stored in state given the provided channel identifier and relayer address
func (k Keeper) GetPayeeAddress(ctx sdk.Context, relayerAddr, channelID string) (string, bool) {
store := ctx.KVStore(k.storeKey)
key := types.KeyPayeeAddress(relayerAddr, channelID)
key := types.KeyPayee(relayerAddr, channelID)

if !store.Has(key) {
return "", false
Expand All @@ -162,13 +162,13 @@ func (k Keeper) GetPayeeAddress(ctx sdk.Context, relayerAddr, channelID string)
// SetPayeeAddress stores the fee payee address in state keyed by the provided channel identifier and relayer address
func (k Keeper) SetPayeeAddress(ctx sdk.Context, relayerAddr, payeeAddr, channelID string) {
store := ctx.KVStore(k.storeKey)
store.Set(types.KeyPayeeAddress(relayerAddr, channelID), []byte(payeeAddr))
store.Set(types.KeyPayee(relayerAddr, channelID), []byte(payeeAddr))
}

// GetAllPayeeAddresses returns all registered payees
func (k Keeper) GetAllPayeeAddresses(ctx sdk.Context) []types.RegisteredPayee {
store := ctx.KVStore(k.storeKey)
iterator := sdk.KVStorePrefixIterator(store, []byte(types.PayeeAddressKeyPrefix))
iterator := sdk.KVStorePrefixIterator(store, []byte(types.PayeeKeyPrefix))
defer iterator.Close()

var registeredPayees []types.RegisteredPayee
Expand All @@ -190,17 +190,17 @@ func (k Keeper) GetAllPayeeAddresses(ctx sdk.Context) []types.RegisteredPayee {
return registeredPayees
}

// SetCounterpartyAddress maps the destination chain relayer address to the source relayer address
// The receiving chain must store the mapping from: address -> counterpartyAddress for the given channel
func (k Keeper) SetCounterpartyAddress(ctx sdk.Context, address, counterpartyAddress, channelID string) {
// SetCounterpartyPayeeAddress maps the destination chain counterparty payee address to the source relayer address
// The receiving chain must store the mapping from: address -> counterpartyPayeeAddress for the given channel
func (k Keeper) SetCounterpartyPayeeAddress(ctx sdk.Context, address, counterpartyAddress, channelID string) {
store := ctx.KVStore(k.storeKey)
store.Set(types.KeyCounterpartyRelayer(address, channelID), []byte(counterpartyAddress))
store.Set(types.KeyCounterpartyPayee(address, channelID), []byte(counterpartyAddress))
}

// GetCounterpartyAddress gets the relayer counterparty address given a destination relayer address
func (k Keeper) GetCounterpartyAddress(ctx sdk.Context, address, channelID string) (string, bool) {
// GetCounterpartyPayeeAddress gets the counterparty payee address given a destination relayer address
func (k Keeper) GetCounterpartyPayeeAddress(ctx sdk.Context, address, channelID string) (string, bool) {
store := ctx.KVStore(k.storeKey)
key := types.KeyCounterpartyRelayer(address, channelID)
key := types.KeyCounterpartyPayee(address, channelID)

if !store.Has(key) {
return "", false
Expand All @@ -213,12 +213,12 @@ func (k Keeper) GetCounterpartyAddress(ctx sdk.Context, address, channelID strin
// GetAllRelayerAddresses returns all registered relayer addresses
func (k Keeper) GetAllRelayerAddresses(ctx sdk.Context) []types.RegisteredRelayerAddress {
store := ctx.KVStore(k.storeKey)
iterator := sdk.KVStorePrefixIterator(store, []byte(types.CounterpartyRelayerAddressKeyPrefix))
iterator := sdk.KVStorePrefixIterator(store, []byte(types.CounterpartyPayeeKeyPrefix))
defer iterator.Close()

var registeredAddrArr []types.RegisteredRelayerAddress
for ; iterator.Valid(); iterator.Next() {
address, channelID, err := types.ParseKeyCounterpartyRelayer(string(iterator.Key()))
address, channelID, err := types.ParseKeyCounterpartyPayee(string(iterator.Key()))
if err != nil {
panic(err)
}
Expand Down
2 changes: 1 addition & 1 deletion modules/apps/29-fee/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ func (suite *KeeperTestSuite) TestGetAllRelayerAddresses() {
sender := suite.chainA.SenderAccount.GetAddress().String()
counterparty := suite.chainB.SenderAccount.GetAddress().String()

suite.chainA.GetSimApp().IBCFeeKeeper.SetCounterpartyAddress(suite.chainA.GetContext(), sender, counterparty, ibctesting.FirstChannelID)
suite.chainA.GetSimApp().IBCFeeKeeper.SetCounterpartyPayeeAddress(suite.chainA.GetContext(), sender, counterparty, ibctesting.FirstChannelID)

expectedAddr := []types.RegisteredRelayerAddress{
{
Expand Down
Loading