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: msg types for fee middleware #1572

Merged
merged 14 commits into from
Jun 27, 2022
Merged
2 changes: 1 addition & 1 deletion docs/.vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ module.exports = {
title: "IBC Middleware Modules",
children: [
{
title: "ICS29 Fee Middleware",
title: "Fee Middleware",
Copy link
Member

@damiannolan damiannolan Jun 24, 2022

Choose a reason for hiding this comment

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

We should add this new page to the children array! I think you'll need to merge main first

directory: true,
path: "/middleware",
children: [
Expand Down
64 changes: 64 additions & 0 deletions docs/middleware/ics29-fee/msgs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<!--
order: 3
-->

# Escrowing and paying out fees
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this section be titled just Escrowing fees? Since I think there is only a reference to the messages to escrow fees here and the part about paying out fees is talked about in the next section.


The fee middleware module exposes two different ways to pay fees for relaying IBC packets:

1. `MsgPayPacketFee`, which enables the escrowing of fees for a packet at the next sequence send and should be combined into one `MultiMsgTx` with the message that will be paid for.

Note that the `Relayers` field has been set up to allow for an optional whitelist of relayers permitted to the receive this fee, however, this feature has not yet been enabled at this time.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Note that the `Relayers` field has been set up to allow for an optional whitelist of relayers permitted to the receive this fee, however, this feature has not yet been enabled at this time.
Note that the `Relayers` field has been set up to allow for an optional whitelist of relayers permitted to receive this fee, however, this feature has not yet been enabled at this time.


```
MsgPayPacketFee{
Fee Fee,
SourcePortId string,
SourceChannelId string,
Signer string,
Relayers []string,
}
```
Copy link
Member

Choose a reason for hiding this comment

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

Should we maybe use Go type definitions here instead? Alternatively we could use proto but I think Go is more fitting considering.Eg. remove trailing commas and add type declaration

Suggested change
```
MsgPayPacketFee{
Fee Fee,
SourcePortId string,
SourceChannelId string,
Signer string,
Relayers []string,
}
```
```
type MsgPayPacketFee struct {
Fee Fee
SourcePortId string
SourceChannelId string
Signer string
Relayers []string
}
```


The `Fee` message contained in this synchronous fee payment method configures different fees which will be paid out for `RecvPackets`, `Acknowledgements`, and `Timeouts`.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
The `Fee` message contained in this synchronous fee payment method configures different fees which will be paid out for `RecvPackets`, `Acknowledgements`, and `Timeouts`.
The `Fee` message contained in this synchronous fee payment method configures different fees which will be paid out for `MsgRecvPacket`, `MsgAcknowledgement`, and `MsgTimeout`/`MsgTimeoutOnClose`.


```
Fee {
RecvFee types.Coins
AckFee types.Coins
TimeoutFee types.Coins

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change

}
```

2. `MsgPayPacketFeeAsync`, which enables the asynchronous escrowing of fees for a specified packet:

```
MsgPayPacketFeeAsync{
Copy link
Contributor

Choose a reason for hiding this comment

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

The alignment is a bit off here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's on purpose, otherwise the generated HackMD doesnt look right

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe worth doing a make view docs and see how it looks there? If you look at the github readme version it seems a bit off too :)

PacketId channeltypes.PacketId,
Copy link
Contributor

Choose a reason for hiding this comment

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

Should you explain a bit what PacketId is?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i thought it was kind of self explanatory....the ID of the packet?

Copy link
Member

Choose a reason for hiding this comment

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

In my opinion we should add the Go type definitions with the in line comments. We can probably omit the protobuf and json tags within the back ticks.

type MsgPayPacketFeeAsync struct {
	// unique packet identifier comprised of the channel ID, port ID and sequence
	PacketId types.PacketId `protobuf:"bytes,1,opt,name=packet_id,json=packetId,proto3" json:"packet_id" yaml:"packet_id"`
	// the packet fee associated with a particular IBC packet
	PacketFee PacketFee `protobuf:"bytes,2,opt,name=packet_fee,json=packetFee,proto3" json:"packet_fee" yaml:"packet_fee"`
}

Copy link
Contributor

Choose a reason for hiding this comment

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

I thought that maybe explaining that packet ID consists of port ID, channel ID and sequence would be helpful, but feel free to keep it like this if you think that mentioning this is just too obvious...

PacketFee PacketFee,
}
```

where the PacketFee also specifies the `Fee` to be paid as well as the refund address for fees which are not paid out
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
where the PacketFee also specifies the `Fee` to be paid as well as the refund address for fees which are not paid out
where the `PacketFee` also specifies the `Fee` to be paid as well as the refund address for fees which are not paid out:

```
PacketFee {
Copy link
Member

Choose a reason for hiding this comment

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

ditto! for all types :)

Fee Fee
RefundAddress string
Relayers []]string
}
```

Please see our [wiki](https://github.com/cosmos/ibc-go/wiki/Fee-enabled-fungible-token-transfers) for example flows on how to use these messages to incentivise a token transfer channel.

# Paying out the escrowed fees

In the case of a successful transaction, `RecvFee` will be paid out to the designated counterparty payee address which has been registered on the receiver chain and sent back with the `Acknowledgement`, `AckFee` will be paid out to the relayer address which has submitted the `Acknowledgement` on the sending chain (or the registered payee in case one has been registered for the relayer address), and `TimeoutFee` will be reimbursed to the account which escrowed the fee. In cases of timeout transactions, `RecvFee` and `AckFee` will be reimbursed.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
In the case of a successful transaction, `RecvFee` will be paid out to the designated counterparty payee address which has been registered on the receiver chain and sent back with the `Acknowledgement`, `AckFee` will be paid out to the relayer address which has submitted the `Acknowledgement` on the sending chain (or the registered payee in case one has been registered for the relayer address), and `TimeoutFee` will be reimbursed to the account which escrowed the fee. In cases of timeout transactions, `RecvFee` and `AckFee` will be reimbursed.
In the case of a successful transaction, `RecvFee` will be paid out to the designated counterparty payee address which has been registered on the receiver chain and sent back with the `MsgAcknowledgement`, `AckFee` will be paid out to the relayer address which has submitted the `MsgAcknowledgement` on the sending chain (or the registered payee in case one has been registered for the relayer address), and `TimeoutFee` will be reimbursed to the account which escrowed the fee. In cases of timeout transactions, `RecvFee` and `AckFee` will be reimbursed.


Please note that fee payments are built on the assumption that sender chains are the source of incentives — the chain that sends the packets is the same chain where fee payments will occur -- please see <relayer operater> section to understand the flow for registering fee-receiving addresses.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

note: i'll update the relayer operator section link once the pr from @damiannolan is in

Copy link
Member

Choose a reason for hiding this comment

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

I've opened #1577 for docs about fee distribution and relayer operators.
What do you think about this? #1577 (comment)

Copy link
Member

Choose a reason for hiding this comment

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

Should we consider using the "payee" terminology here?

Suggested change
Please note that fee payments are built on the assumption that sender chains are the source of incentives — the chain that sends the packets is the same chain where fee payments will occur -- please see <relayer operater> section to understand the flow for registering fee-receiving addresses.
Please note that fee payments are built on the assumption that sender chains are the source of incentives — the chain that sends the packets is the same chain where fee payments will occur -- please see <relayer operater> section to understand the flow for registering fee payee addresses.


# A locked fee middleware module
crodriguezvega marked this conversation as resolved.
Show resolved Hide resolved

The fee middleware module can become locked if the situation arises that the escrow account for the fees does not have sufficient funds to pay out the fees which have been registered for each packet. This situation indicates a severe bug. In this case, the fee module will be locked until manual intervention fixes the issue.
Copy link
Member

@damiannolan damiannolan Jun 24, 2022

Choose a reason for hiding this comment

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

nit: feel free to ignore

Suggested change
The fee middleware module can become locked if the situation arises that the escrow account for the fees does not have sufficient funds to pay out the fees which have been registered for each packet. This situation indicates a severe bug. In this case, the fee module will be locked until manual intervention fixes the issue.
The fee middleware module can become locked if the situation arises that the escrow account for the fees does not have sufficient funds to pay out the fees which have been escrowed for each packet. This situation indicates a severe bug. In this case, the fee module will be locked until manual intervention fixes the issue.


A locked fee module will simply skip fee logic and continue on to the underlying packet flow. A channel with a locked fee module will temporarily function as a fee disabled channel, and the locking of a fee module will not affect the continued flow of packets over the channel.