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

docs: payee registration and fee distribution for relayer operators #1577

Merged
merged 7 commits into from
Jun 27, 2022
Merged
Show file tree
Hide file tree
Changes from 5 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
5 changes: 5 additions & 0 deletions docs/.vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,11 @@ module.exports = {
directory: false,
path: "/middleware/ics29-fee/integration.html"
},
{
title: "Fee Distribution",
directory: false,
path: "/middleware/ics29-fee/fee-distribution.html"
},
]
},
]
Expand Down
90 changes: 90 additions & 0 deletions docs/middleware/ics29-fee/fee-distribution.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<!--
order: 4
-->

# Fee Distribution
damiannolan marked this conversation as resolved.
Show resolved Hide resolved

Learn about payee registration for distribution of packet fees. The following document is intended for relayer operators {synopsis}
damiannolan marked this conversation as resolved.
Show resolved Hide resolved

## Pre-requisite Readings
damiannolan marked this conversation as resolved.
Show resolved Hide resolved

* [Fee Middleware](overview.md) {prereq}

Packet fees are divided into 3 distinct amounts in order to compensate relayer operators for packet relaying on fee enabled IBC channels.

- `RecvFee`: The sum of all packet receive fees distributed to a payee for successful execution of `MsgRecvPacket`.
Copy link
Contributor

@seantking seantking Jun 24, 2022

Choose a reason for hiding this comment

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

Seeing as we're saying the sum of all packet receive fees it might be worth noting above that a packet fee can be 'topped up' multiple times. wdyt?

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe that could be added to the section Escrowing and paying out fees of @charleenfei's PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, possibly adding to @charleenfei's PR would be a nice idea and segway into linking to this docs page.

#1572 (comment)

Copy link
Member

Choose a reason for hiding this comment

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

Yea, though the fact that the fees are stored as separate structs is an implementation detail imo. I think it makes sense to say that RecvFee here is the fee that will be distributed to the payee for a successful execution of RecvPacket

And in the escrowing section we can document that the recvFee along with other fees can be topped up multiple times. wdyt?

- `AckFee`: The sum of all packet acknowledgement fees distributed to a payee for successful execution of `MsgAcknowledgement`.
- `TimeoutFee`: The sum of all packet timeout fees distributed to a payee for successful execution of `MsgTimeout`.

## Register a payee address for forward relaying

As mentioned previously in [ICS29 Concepts](../ics29-fee/overview.md#concepts), the forward relayer describes the actor who performs the submission of `MsgRecvPacket` on the destination chain.
damiannolan marked this conversation as resolved.
Show resolved Hide resolved
Fee distribution for incentivized packet relays takes place on the packet source chain.
Relayer operators are expected to register a counterparty payee address, in order to be compensated accordingly with `RecvFees` upon completion of a packet lifecycle.
damiannolan marked this conversation as resolved.
Show resolved Hide resolved
The counterparty payee address registered on the destination chain is encoded into the packet acknowledgement and communicated as such to the source chain for fee distribution.
If a counterparty payee is not registered for the forward relayer on the destination chain, the escrowed fees will be refunded upon fee distribution.

A transaction must be submitted to the desintation chain including a `CounterpartyPayee` address of an account on the source chain.
Copy link
Member

Choose a reason for hiding this comment

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

destination

The transaction must be signed by the `Relayer`.

```go
type MsgRegisterCounterpartyPayee struct {
// unique port identifier
PortId string
// unique channel identifier
ChannelId string
// the relayer address
Relayer string
// the counterparty payee address
CounterpartyPayee string
}
```

This message is expected to fail if:

- `PortId` is invalid (see [24-host naming requirements](https://github.com/cosmos/ibc/blob/master/spec/core/ics-024-host-requirements/README.md#paths-identifiers-separators).
- `ChannelId` is invalid (see [24-host naming requirements](https://github.com/cosmos/ibc/blob/master/spec/core/ics-024-host-requirements/README.md#paths-identifiers-separators)).
- `Relayer` is an invalid address (see [Cosmos SDK Addresses](https://github.com/cosmos/cosmos-sdk/blob/main/docs/basics/accounts.md#Addresses)).
- `CounterpartyPayee` is empty.

See below for an example CLI command:

```
simd tx ibc-fee register-counterparty-payee transfer channel-0 cosmos1rsp837a4kvtgp2m4uqzdge0zzu6efqgucm0qdh osmo1v5y0tz01llxzf4c2afml8s3awue0ymju22wxx2 --from cosmos1rsp837a4kvtgp2m4uqzdge0zzu6efqgucm0qdh
```

## Register a payee address for reverse and timeout relaying

As mentioned previously in [ICS29 Concepts](../ics29-fee/overview.md#concepts), the reverse relayer describes the actor who performs the submission of `MsgAcknowledgement` on the source chain.
damiannolan marked this conversation as resolved.
Show resolved Hide resolved
Similarly the timeout relayer describes the actor who performs the submission of `MsgTimeout` on the source chain.
damiannolan marked this conversation as resolved.
Show resolved Hide resolved
Relayer operators may choose to register an optional payee address, in order to be compensated accordingly with `AckFees` and `TimeoutFees` upon completion of a packet life cycle.
damiannolan marked this conversation as resolved.
Show resolved Hide resolved
If a payee is not registered for the reverse or timeout relayer on the source chain, then fee distribution assumes the default behaviour, where fees are paid out to the relayer account which delivers `MsgAcknowledgement` or `MsgTimeout`.
damiannolan marked this conversation as resolved.
Show resolved Hide resolved

A transaction must be submitted to the source chain including a `Payee` address of an account on the source chain.
The transaction must be signed by the `Relayer`.

```go
type MsgRegisterPayee struct {
// unique port identifier
PortId string
// unique channel identifier
ChannelId string
// the relayer address
Relayer string
// the payee address
Payee string
}
```

This message is expected to fail if:

- `PortId` is invalid (see [24-host naming requirements](https://github.com/cosmos/ibc/blob/master/spec/core/ics-024-host-requirements/README.md#paths-identifiers-separators).
- `ChannelId` is invalid (see [24-host naming requirements](https://github.com/cosmos/ibc/blob/master/spec/core/ics-024-host-requirements/README.md#paths-identifiers-separators)).
- `Relayer` is an invalid address (see [Cosmos SDK Addresses](https://github.com/cosmos/cosmos-sdk/blob/main/docs/basics/accounts.md#Addresses)).
- `Payee` is an invalid address (see [Cosmos SDK Addresses](https://github.com/cosmos/cosmos-sdk/blob/main/docs/basics/accounts.md#Addresses)).

See below for an example CLI command:

```
simd tx ibc-fee register-payee transfer channel-0 cosmos1rsp837a4kvtgp2m4uqzdge0zzu6efqgucm0qdh cosmos153lf4zntqt33a4v0sm5cytrxyqn78q7kz8j8x5 --from cosmos1rsp837a4kvtgp2m4uqzdge0zzu6efqgucm0qdh
```