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

feat: fee payer #45

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open

feat: fee payer #45

wants to merge 9 commits into from

Conversation

ratik
Copy link
Contributor

@ratik ratik commented Jan 23, 2023

@ratik ratik force-pushed the feat/NTRN-331-sudo-fees-payer branch 2 times, most recently from e4238b9 to edae216 Compare January 23, 2023 12:50
@@ -21,10 +21,29 @@ The module requires smart-contracts, which use [Transfer](../transfer/messages#m
* `ack_fee` - amount of coins to refund relayer for submittting ack message for a particular IBC packet (i.e. `500untrn`);
* `timeout_fee` - amount of coins to refund relayer for submitting timeout message for a particular IBC packet (i.e. `500untrn`);
* `recv_fee` - currently is used for compatibility with ICS-29 interface only and **must be set to zero** (i.e. `0untrn`), because Neutron's fee module can't refund relayers for submission of `Recv` IBC packets due to compatibility with target chains.
* `payer` - optional address of the contract which will pay for the fees. Please note that payer must give allowance to the contract to spend fees.
Copy link
Collaborator

Choose a reason for hiding this comment

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

optional address of the contract

looks a bit weird

@@ -2,7 +2,7 @@

The FeeRefunder module stores one [FeeInfo](https://github.com/neutron-org/neutron/blob/a9e8ba5ebb9230bec97a4f2826d75a4e0e6130d9/proto/feerefunder/genesis.proto#L18) per [`channel_id`, `port_id` and `sequence`](https://github.com/neutron-org/neutron/blob/a9e8ba5ebb9230bec97a4f2826d75a4e0e6130d9/x/feerefunder/types/keys.go#L28).
`FeeInfo` contains all the necessary info to store data about fees to properly refund relayers and return fees to the original caller of IBC messages:
* `payer` - stores an address of the smart-contract which issues `Transfer` or `SubmitTx` message;
* `payer` - stores an address of the smart-contract (or fee payer) which issues `Transfer` or `SubmitTx` message;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks a bit weird now, cause fee payer doesn't issue Transfer or SubmitTx messages


2. The fee payer can grant an allowance to a contract address, which allows the contract to use tokens from this address for the fees. Optionally, a limit, expire date, and period can be set, please refer to the [feegrant module's documentation in the Cosmos SDK](https://docs.cosmos.network/v0.46/modules/feegrant/) for more information.

3. When an interchain transaction is requested by a contract, the feerefunder module checks the allowance in general by using the feegrant module's GetAllowance function.
Copy link
Collaborator

Choose a reason for hiding this comment

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

or transfer message

@ratik ratik requested a review from pr0n00gler January 24, 2023 16:21
docs/neutron/feerefunder/overview.md Outdated Show resolved Hide resolved
docs/neutron/feerefunder/overview.md Outdated Show resolved Hide resolved
docs/neutron/feerefunder/overview.md Outdated Show resolved Hide resolved
docs/neutron/feerefunder/overview.md Outdated Show resolved Hide resolved
@@ -2,7 +2,7 @@

The FeeRefunder module stores one [FeeInfo](https://github.com/neutron-org/neutron/blob/a9e8ba5ebb9230bec97a4f2826d75a4e0e6130d9/proto/feerefunder/genesis.proto#L18) per [`channel_id`, `port_id` and `sequence`](https://github.com/neutron-org/neutron/blob/a9e8ba5ebb9230bec97a4f2826d75a4e0e6130d9/x/feerefunder/types/keys.go#L28).
`FeeInfo` contains all the necessary info to store data about fees to properly refund relayers and return fees to the original caller of IBC messages:
* `payer` - stores an address of the smart-contract which issues `Transfer` or `SubmitTx` message;
* `payer` - stores an address of the smart-contract (or fee payer) which will be refunded after the IBC packet is processed;
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe stores the fee payer address (smart contract or other fee payer) which will be refunded after the IBC packet is processed?

docs/neutron/feerefunder/overview.md Show resolved Hide resolved
@@ -53,5 +53,6 @@ Output:
timeout_fee:
- denom: "untrn"
amount: "500"
payer: neutron10h9stc5v6ntgeygf5xf945njqq5h32r54rf7kf
Copy link
Contributor

Choose a reason for hiding this comment

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

please fix the fee-info command description above:
Screenshot 2023-01-26 at 15 17 07

@@ -21,10 +21,29 @@ The module requires smart-contracts, which use [Transfer](../transfer/messages#m
* `ack_fee` - amount of coins to refund relayer for submittting ack message for a particular IBC packet (i.e. `500untrn`);
* `timeout_fee` - amount of coins to refund relayer for submitting timeout message for a particular IBC packet (i.e. `500untrn`);
* `recv_fee` - currently is used for compatibility with ICS-29 interface only and **must be set to zero** (i.e. `0untrn`), because Neutron's fee module can't refund relayers for submission of `Recv` IBC packets due to compatibility with target chains.
* `payer` - optional address which will pay for the fees. Please note that payer must give allowance to the contract to spend fees.
Copy link
Contributor

Choose a reason for hiding this comment

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

to have a link to the relative feegrant doc page will be very handy here. or a link to the Details on Fee Payer section


> **Note:** the fees can be specified only in native Cosmos-SDK coins. CW-20 coins are not supported!

When a smart-contract issues `Transfer` or `SubmitTx` message, the fee Module deduct the whole specified fee amount (`ack_fee + timeout_fee + recv_fee`) and locks that amount in the module's escrow address. When a relayer submits `Ack` message for a particular packet, the module sends the specified amount of `ack_fee` to the relayer from the escrow address and return the specified `timeout_fee` to the contract which issued the original `Transfer` or `SubmitTx` message. In case when relayer submits `Timeout` message, things go the other way around: the relayer is refunded with `timeout_fee` and the contract gets `ack_fee` back.
When a smart-contract issues `Transfer` or `SubmitTx` message, the fee Module deduct the whole specified fee amount (`ack_fee + timeout_fee + recv_fee`) from contract address or from payer address (if it is defined and there is allowance from payer to contract address) and locks that amount in the module's escrow address. When a relayer submits `Ack` message for a particular packet, the module sends the specified amount of `ack_fee` to the relayer from the escrow address and return the specified `timeout_fee` to the contract (or fee payer) which issued the original `Transfer` or `SubmitTx` message. In case when relayer submits `Timeout` message, things go the other way around: the relayer is refunded with `timeout_fee` and the contract gets `ack_fee` back.
Copy link
Contributor

Choose a reason for hiding this comment

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

please correct:

message, the fee Module (1) deduct (2) the whole:

  1. the FeeRefunder Module
  2. deducts

the relayer is refunded with timeout_fee and the contract (1) gets ack_fee back

  1. and the contract (or fee payer)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants