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

General Fee Payment Spec #581

Merged
merged 26 commits into from
Jul 9, 2021
Merged
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
4b57075
Start defining general relayer fee payment protocol
ethanfrey Jun 1, 2021
b1d5114
Provide high-level implementation details
ethanfrey Jun 1, 2021
98d35ce
add to example
AdityaSripal Jun 2, 2021
9eaaadb
writeup interfaces
AdityaSripal Jun 2, 2021
8f6d4c0
writeup connection/channel changes
AdityaSripal Jun 2, 2021
5372351
Apply suggestions from code review
AdityaSripal Jun 3, 2021
6f0c93b
address reviews
AdityaSripal Jun 3, 2021
0c920c1
Merge branch 'start-fee-payment-spec' of github.com:cosmos/ibc into s…
AdityaSripal Jun 3, 2021
c85b2bd
writeup fee module requirements
AdityaSripal Jun 3, 2021
a8dfa2c
simplify connection version
AdityaSripal Jun 3, 2021
eda8453
partially address chris reviews
AdityaSripal Jun 7, 2021
c276b67
Apply suggestions from code review
AdityaSripal Jun 7, 2021
811d986
address ethan, chris reviews
AdityaSripal Jun 7, 2021
e4e6116
Merge branch 'start-fee-payment-spec' of github.com:cosmos/ibc into s…
AdityaSripal Jun 7, 2021
7944b5e
add fee middleware
AdityaSripal Jun 8, 2021
274ddcc
Merge branch 'master' of github.com:cosmos/ibc into start-fee-payment…
AdityaSripal Jun 8, 2021
dcdd939
Update spec/app/ics-029-fee-payment/README.md
AdityaSripal Jun 15, 2021
7d3693d
add port discussion, remove backwards compatibility from app and move…
AdityaSripal Jun 18, 2021
aa3e2c7
update metadata
AdityaSripal Jun 18, 2021
b57ff40
Merge branch 'start-fee-payment-spec' of github.com:cosmos/ibc into s…
AdityaSripal Jun 18, 2021
4ead1f3
add middleware spec
AdityaSripal Jun 21, 2021
a2b17cb
cleanup and complete specs
AdityaSripal Jun 23, 2021
40e1930
add fee definitions
AdityaSripal Jun 23, 2021
524697f
clarify fee payment messages
AdityaSripal Jun 24, 2021
7a2f416
clarify forward relaying and ics4 wrapper logic
AdityaSripal Jul 7, 2021
c838afb
update correctness section
AdityaSripal Jul 7, 2021
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
53 changes: 36 additions & 17 deletions spec/app/ics-029-fee-payment/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ define a clear interface that can be easily adopted by any application, but not
- One direction works, even when one chain does not support concept of fungible tokens
AdityaSripal marked this conversation as resolved.
Show resolved Hide resolved
- Opt-in for each chain implementing this. eg. ICS27 with fee support on chain A could connect to ICS27 without fee support on chain B.
- Standardized interface for each chain implementing this extension
- Allow each chain/application to customize fee-handling logic
- Permissionless relaying
AdityaSripal marked this conversation as resolved.
Show resolved Hide resolved

cwgoes marked this conversation as resolved.
Show resolved Hide resolved
## Technical Specification
Expand Down Expand Up @@ -83,6 +84,8 @@ The sender chain will escrow 0.003 channel-7/ATOM and 0.002 IRIS. In the case th

The logic involved in collecting fees from users and then paying it out to the relevant relayers is encapsulated by a separate fee module and may vary between implementations. However, all fee modules must implement a uniform interface such that the ICS-4 handlers can correctly pay out fees to the right relayers, and so that relayers themselves can easily determine the fees they can expect for relaying a packet.
ethanfrey marked this conversation as resolved.
Show resolved Hide resolved

### Fee Module Contract

```typescript
function PayFee(packet: Packet, forward_relayer: string, reverse_relayer: string) {
ethanfrey marked this conversation as resolved.
Show resolved Hide resolved
// pay the forward fee to the forward relayer address
Expand All @@ -96,7 +99,33 @@ function PayTimeoutFee(packet: Packet, timeout_relayer: string) {
}
```

These functions will then be utilized in the ICS-4 handlers like so:

The fee module should also expose the following queries so that relayers may query their expected fee:

```typescript
// Gets the fee expected for submitting ReceivePacket msg for this packet
function GetReceiveFee(packet) Fee
AdityaSripal marked this conversation as resolved.
Show resolved Hide resolved

// Gets the fee expected for submitting AcknowledgePacket msg for this packet
function GetAckFee(packet) Fee

// Gets the fee expected for submitting TimeoutPacket msg for this packet
function GetTimeoutFee(packet) Fee
```

Since different chains may have different representations for fungible tokens and this information is not being sent to other chains; this ICS does not specify a particular representation for the `Fee`. Each chain may choose its own representation, it is incumbent on relayers to interpret the Fee correctly.
AdityaSripal marked this conversation as resolved.
Show resolved Hide resolved

### Connection Negotiation

The chains must agree to enable the incentivization feature during the connection handshake. This can be done by adding an incentivization feature to the connection version.

```{"1", ["ORDER_ORDERED", "ORDER_UNORDERED", "INCENTIVE_V1"]}```
AdityaSripal marked this conversation as resolved.
Show resolved Hide resolved

If the negotiated connection includes the incentivization feature, then the ICS-4 `WriteAcknowledgement` function must write the forward relayer address into a structured acknowledgement and the ICS-4 handlers for `AcknowledgePacket` and `TimeoutPacket` must pay fees through the ibc fee module callbacks. If the negotiated connection does not include the incentivization feature, then the ICS-4 handlers must not modify the acknowledgement provided by the application and should not call any fee callbacks even if relayer incentivization is enabled on the chain.

AdityaSripal marked this conversation as resolved.
Show resolved Hide resolved
### Channel Changes

The ibc-fee callbacks will then be utilized in the ICS-4 handlers like so:

```typescript
function acknowledgePacket(
Expand All @@ -105,15 +134,13 @@ function acknowledgePacket(
proof: CommitmentProof,
proofHeight: Height,
relayer: string): Packet {
// ...
// get the forward relayer from the acknowledgement
// and pay fees to forward and reverse relayers.
// reverse_relayer is submitter of acknowledgement message
// provided in function arguments
// NOTE: Fee may be zero
forward_relayer = getForwardRelayer(acknowledgement)
AdityaSripal marked this conversation as resolved.
Show resolved Hide resolved
PayFee(packet, forward_relayer, relayer)
// ...
}

function timeoutPacket(
Expand All @@ -122,32 +149,24 @@ function timeoutPacket(
proofHeight: Height,
nextSequenceRecv: Maybe<uint64>,
relayer: string): Packet {
// ...
// get the timeout relayer from function arguments
// and pay timeout fee.
// NOTE: Fee may be zero
PayTimeoutFee(packet, relayer)
}
```

The fee module should also expose the following queries so that relayers may query their expected fee:

```typescript
// Gets the fee expected for submitting ReceivePacket msg for this packet
function GetReceiveFee(packet) Fee
#### Reasoning

// Gets the fee expected for submitting AcknowledgePacket msg for this packet
function GetAckFee(packet) Fee
This proposal satisfies the desired properties. All parts of the packet flow (receive/acknowledge/timeout) can be properly incentivized and rewarded. The protocol does not specify the relayer beforehand, thus the incentivization is permissionless. The escrowing and distribution of funds is completely handled on source chain, thus there is no need for additional IBC packets or the use of ICS-20 in the fee protocol. The fee protocol only assumes existence of fungible tokens on the source chain. Using the connection version, the protocol enables opt-in incentivization and backwards compatibility. The fee module can implement arbitrary custom logic so long as it respects the callback interfaces that IBC expects.
AdityaSripal marked this conversation as resolved.
Show resolved Hide resolved

// Gets the fee expected for submitting TimeoutPacket msg for this packet
function GetTimeoutFee(packet) Fee
```
##### Correctness

Since different chains may have different representations for fungible tokens and this information is not being sent to other chains; this ICS does not specify a particular representation for the `Fee`. Each chain may choose its own representation, it is incumbent on relayers to interpret the Fee correctly.
The fee module is responsible for correctly escrowing and distributing funds to the provided relayers. It is IBC's responsibility to provide the fee module with the correct relayers. The ack and timeout relayers are trivially retrievable since they are the senders of the acknowledgment and timeout message.

#### Reasoning
The receive relayer submits the message to the counterparty chain. Thus the counterparty chain must communicate the knowledge of who relayed the receive packet to the source chain using the acknowledgement. The address that is sent back **must** be the address of the forward relayer on the source chain.
AdityaSripal marked this conversation as resolved.
Show resolved Hide resolved

##### Correctness
With the forward relayer embedded in the acknowledgement, and the reverse and timeout relayers available directly in the message; IBC is able to provide the correct relayer addresses to the fee module for each step of the packet flow.

#### Optional addenda

Expand Down